@miravo/cli-linux-arm64-musl 0.7.2 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/console-dist/assets/{AnimatePresence-DOKfbxUr.js → AnimatePresence-CPmH1DMY.js} +1 -1
  2. package/console-dist/assets/{activity-CHJbwIn_.js → activity-Cy_niK56.js} +1 -1
  3. package/console-dist/assets/{api-DUOCKS6t.js → api-DimikzPd.js} +1 -1
  4. package/console-dist/assets/arrow-right-BjBb4z7g.js +1 -0
  5. package/console-dist/assets/{arrow-up-down-Dpy1cI5X.js → arrow-up-down-C1oJAmrw.js} +1 -1
  6. package/console-dist/assets/{auth-screen-backdrop-UsGua6Zt.js → auth-screen-backdrop-Cr8qBSXP.js} +1 -1
  7. package/console-dist/assets/{badge-Dl0qmCnt.js → badge-eIn_7YrK.js} +1 -1
  8. package/console-dist/assets/catalog-8tLjGq7E.js +1 -0
  9. package/console-dist/assets/catalog-CbdG58Mn.js +1 -0
  10. package/console-dist/assets/{catalog-source-m5FRUDDK.js → catalog-source-C4jQdH37.js} +1 -1
  11. package/console-dist/assets/{catalog-template-icons-MOd-xD7l.js → catalog-template-icons-3S8RvUxD.js} +1 -1
  12. package/console-dist/assets/{checkbox-_saaQAja.js → checkbox-C_4HRnS_.js} +1 -1
  13. package/console-dist/assets/{chunk-OE4NN4TA-m2UhO8Q2.js → chunk-OE4NN4TA-DBWZidbW.js} +1 -1
  14. package/console-dist/assets/{circle-question-mark-BwjC8Yj-.js → circle-question-mark-CJvcT6V6.js} +1 -1
  15. package/console-dist/assets/{combobox-BqGaRFom.js → combobox-BCaV1Wbo.js} +1 -1
  16. package/console-dist/assets/control-4ugKUt8n.js +1 -0
  17. package/console-dist/assets/control-BVr4X_wI.js +1 -0
  18. package/console-dist/assets/{copy-button-BYq-qqmM.js → copy-button-BvU3RDZa.js} +1 -1
  19. package/console-dist/assets/{dist-jROhexoH.js → dist-xY0pK9Wy.js} +1 -1
  20. package/console-dist/assets/{download-BP5RD-RZ.js → download-DmUZKo9N.js} +1 -1
  21. package/console-dist/assets/{dropdown-menu-6JrsGi7P.js → dropdown-menu-CrPXVXpG.js} +1 -1
  22. package/console-dist/assets/{engine-store-BXfht5ME.js → engine-store-DMULdR_V.js} +1 -1
  23. package/console-dist/assets/events-BP1rvN5g.js +1 -0
  24. package/console-dist/assets/events-BcZCvJ63.js +1 -0
  25. package/console-dist/assets/fleet-ne7gllQE.js +1 -0
  26. package/console-dist/assets/fleet-nhb_0n25.js +1 -0
  27. package/console-dist/assets/{format-B243kebG.js → format-CshN6yEB.js} +1 -1
  28. package/console-dist/assets/index-D1lU9Fg9.css +2 -0
  29. package/console-dist/assets/index-Ds1n4iXS.js +12 -0
  30. package/console-dist/assets/instance-detail-k6fWu2DS.js +1 -0
  31. package/console-dist/assets/{label-CM_MIru8.js → label-CMBWxUhA.js} +1 -1
  32. package/console-dist/assets/{layers-Cg3yeSqL.js → layers-1figUpjG.js} +1 -1
  33. package/console-dist/assets/{login-DG5yhrqi.js → login-BmyMgUK4.js} +1 -1
  34. package/console-dist/assets/{models-CZEVv1PS.js → models-C_UOiHSF.js} +1 -1
  35. package/console-dist/assets/models-DiO_AS9_.js +1 -0
  36. package/console-dist/assets/{not-found-49MUUPk7.js → not-found-D0nX2nrf.js} +1 -1
  37. package/console-dist/assets/{platform-targets-DkU1GIU_.js → platform-targets-BIQ1lKOg.js} +1 -1
  38. package/console-dist/assets/platforms-CmsbDw-2.js +1 -0
  39. package/console-dist/assets/platforms-npS30Kgk.js +1 -0
  40. package/console-dist/assets/{proxy-Dd7NWn5E.js → proxy-Be4WzmcS.js} +1 -1
  41. package/console-dist/assets/query-fetch-error-Bcg_UjHM.js +1 -0
  42. package/console-dist/assets/route-preload-BO6weHRR.js +2 -0
  43. package/console-dist/assets/{select-TsdpHrOx.js → select-CmlY1M1a.js} +1 -1
  44. package/console-dist/assets/{select-display-items-C6R8SaIm.js → select-display-items-Bqb6Sbg6.js} +1 -1
  45. package/console-dist/assets/{shallow-ODRQsuRf.js → shallow-Cin0mLuv.js} +1 -1
  46. package/console-dist/assets/{tabs-CrmZxWmX.js → tabs-4SeH2unv.js} +1 -1
  47. package/console-dist/assets/tags-DORoU260.js +4 -0
  48. package/console-dist/assets/tags-nwfbo5cT.js +1 -0
  49. package/console-dist/assets/{tooltip-5y0snV5M.js → tooltip-D1ydB4g3.js} +1 -1
  50. package/console-dist/assets/{transition-nav-link-rkgf5kGR.js → transition-nav-link-nVD3H66a.js} +1 -1
  51. package/console-dist/assets/{triangle-alert-B7bgkvtE.js → triangle-alert-BXrJNk3g.js} +1 -1
  52. package/console-dist/assets/{use-engine-command-mutation-BHd8IkoT.js → use-engine-command-mutation-C8S_hX0O.js} +1 -1
  53. package/console-dist/assets/use-platform-stream-CZLW085n.js +2 -0
  54. package/console-dist/assets/use-transition-navigate-jMR-y4bs.js +1 -0
  55. package/console-dist/assets/{utils-CH98NBUe.js → utils-XFKvwlFT.js} +1 -1
  56. package/console-dist/assets/{validation-CEcQWBjy.js → validation-DLydiTzj.js} +1 -1
  57. package/console-dist/assets/{vendor-charts-CAZdaPlq.js → vendor-charts-95ykyDlI.js} +1 -1
  58. package/console-dist/assets/{vendor-table-CymGcez5.js → vendor-table-BAHQgdwg.js} +1 -1
  59. package/console-dist/assets/{vendor-ui-BcvPjvmT.js → vendor-ui-CWUk2ulb.js} +1 -1
  60. package/console-dist/index.html +52 -53
  61. package/miravo +0 -0
  62. package/package.json +1 -1
  63. package/console-dist/assets/arrow-right-DzTjpAuX.js +0 -1
  64. package/console-dist/assets/catalog-CJE-3rom.js +0 -1
  65. package/console-dist/assets/catalog-D7hkpcg7.js +0 -1
  66. package/console-dist/assets/control-C3s_d_cd.js +0 -1
  67. package/console-dist/assets/control-CVg7wZ1b.js +0 -1
  68. package/console-dist/assets/events-PFkU6dri.js +0 -1
  69. package/console-dist/assets/events-uH2B0ni-.js +0 -1
  70. package/console-dist/assets/fleet-B1apknqo.js +0 -1
  71. package/console-dist/assets/fleet-CdoQJU1v.js +0 -1
  72. package/console-dist/assets/index-CTIFAVGZ.js +0 -12
  73. package/console-dist/assets/index-DUzq1mEZ.css +0 -2
  74. package/console-dist/assets/instance-detail-BH62ZPtN.js +0 -1
  75. package/console-dist/assets/models-S3NJFuma.js +0 -1
  76. package/console-dist/assets/platforms-Czbg-aTO.js +0 -1
  77. package/console-dist/assets/platforms-DbF8XkYf.js +0 -1
  78. package/console-dist/assets/query-fetch-error-B2TVF0yM.js +0 -1
  79. package/console-dist/assets/route-preload-iLKZvgav.js +0 -2
  80. package/console-dist/assets/skeleton-BK5ydi_g.js +0 -1
  81. package/console-dist/assets/tags-Burz8TZx.js +0 -4
  82. package/console-dist/assets/tags-zlkQYLKu.js +0 -1
  83. package/console-dist/assets/use-platform-stream-EUBU4hC1.js +0 -2
  84. package/console-dist/assets/use-transition-navigate-BQAQi11k.js +0 -1
  85. /package/console-dist/assets/{get-error-message-CCNo4ZY0.js → get-error-message-Dk8elqEP.js} +0 -0
  86. /package/console-dist/assets/{runtime-link-ocutSVA8.js → runtime-link-PMxeHxd6.js} +0 -0
  87. /package/console-dist/assets/{transition-types-BNgNegH3.js → transition-types-2i1blGlR.js} +0 -0
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{at as n}from"./vendor-ui-BcvPjvmT.js";import{J as r,S as i,Y as a,b as o,o as s,q as c,x as l}from"./api-DUOCKS6t.js";import{a as u,c as d,i as f,r as p,t as m}from"./query-fetch-error-B2TVF0yM.js";import{t as h}from"./proxy-Dd7NWn5E.js";import{t as g}from"./AnimatePresence-DOKfbxUr.js";import{i as _,r as v}from"./dist-jROhexoH.js";import{n as y}from"./chunk-OE4NN4TA-m2UhO8Q2.js";import{a as b,i as x,l as S,n as C,o as w,r as ee,s as T,t as E}from"./copy-button-BYq-qqmM.js";import{C as D,S as O,m as k,o as A,u as j,w as M,x as N}from"./format-B243kebG.js";import{n as P,t as F}from"./utils-CH98NBUe.js";import{t as I}from"./activity-CHJbwIn_.js";import{t as L}from"./arrow-right-DzTjpAuX.js";import{C as R,O as z,S as B,T as te,_ as ne,a as V,c as H,d as re,f as ie,h as ae,i as oe,l as se,m as ce,n as le,o as U,p as ue,r as de,s as fe,t as pe,u as me,v as he,w as ge,x as _e,y as ve}from"./use-platform-stream-EUBU4hC1.js";import{n as ye,t as be}from"./catalog-template-icons-MOd-xD7l.js";import{c as xe,i as W,l as Se,n as Ce,s as we,t as Te}from"./select-TsdpHrOx.js";import{a as Ee,i as De,r as G}from"./platform-targets-DkU1GIU_.js";import{c as Oe,i as ke,n as Ae,o as je,r as Me,s as Ne,t as Pe}from"./tabs-CrmZxWmX.js";import{i as Fe,n as Ie,r as Le,t as Re}from"./checkbox-_saaQAja.js";import{t as ze}from"./layers-Cg3yeSqL.js";import{t as Be}from"./triangle-alert-B7bgkvtE.js";import{t as K}from"./skeleton-BK5ydi_g.js";import{i as Ve,n as He,t as Ue}from"./tooltip-5y0snV5M.js";import{t as We}from"./badge-Dl0qmCnt.js";import{a as Ge,i as Ke,n as qe,o as Je,r as Ye,s as Xe,t as Ze}from"./dropdown-menu-6JrsGi7P.js";import{t as Qe}from"./label-CM_MIru8.js";import{t as q}from"./get-error-message-CCNo4ZY0.js";var $e=class extends d{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:a()})}getOptimisticResult(e){return e.behavior=a(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,i=super.createResult(e,t),{isFetching:a,isRefetching:o,isError:s,isRefetchError:l}=i,u=n.fetchMeta?.fetchMore?.direction,d=s&&u===`forward`,f=a&&u===`forward`,p=s&&u===`backward`,m=a&&u===`backward`;return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:c(t,n.data),hasPreviousPage:r(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:p,isFetchingPreviousPage:m,isRefetchError:l&&!d&&!p,isRefetching:o&&!f&&!m}}};function et(e,t){return u(e,$e,t)}var tt=P(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),nt=P(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),rt=P(`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`}]]),it=P(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),at=P(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),J=e(t(),1),Y=n(),ot=`rounded-(--miravo-radius-stadium-sm) border border-dashed border-border/55 bg-muted/10`;function st(){return(0,Y.jsx)(`p`,{className:`mt-2 text-pretty text-sm leading-relaxed text-muted-foreground`,children:`Add a target to get started.`})}function ct({onClick:e}){return(0,Y.jsxs)(O,{type:`button`,size:`sm`,className:`h-7 shrink-0 gap-1.5 text-xs`,onClick:e,children:[(0,Y.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}),`Add Target`]})}function lt({titleId:e,frameIcon:t,description:n,children:r}){return(0,Y.jsx)(`section`,{"aria-labelledby":e,className:ot,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-4 py-10 text-center`,children:[(0,Y.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-(--miravo-radius-stadium-sm) border border-dashed border-border/50`,children:t}),(0,Y.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Y.jsx)(`h2`,{id:e,className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`No targets yet`}),n]}),r]})})}function ut({stream:e,onReset:t,catalogTemplates:n}){if(!e.operation&&e.status!==`running`)return null;let{title:r,subtitle:i}=oe(e),a=e.status===`complete`,o=e.status===`error`,s=e.status===`running`,c=a||o,l=e.cancelRequested;async function u(){await e.cancel().catch(()=>{})}return(0,Y.jsx)(ce,{title:r,subtitle:i,footerAction:s&&e.operation?.operationId?(0,Y.jsx)(`div`,{className:`ml-auto shrink-0`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:u,disabled:l,"aria-busy":l,className:F(D({variant:`outline`,size:`sm`}),`group h-8 gap-1.5 px-3 text-xs`,l?`cursor-not-allowed`:`hover:bg-destructive/12 hover:text-destructive hover:border-destructive/35`),children:l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(je,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsx)(h.span,{animate:{opacity:[1,.72,1]},transition:{duration:1.25,repeat:1/0,ease:`easeInOut`},className:`font-medium text-foreground`,children:`Cancelling…`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(M,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,Y.jsx)(h.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})})}):c?(0,Y.jsxs)(`div`,{className:`flex w-full flex-col gap-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 w-full flex-1 flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,Y.jsxs)(y,{to:`/platforms?tab=activity`,className:F(D({variant:`ghost`,size:`xs`}),`group inline-flex h-6 shrink-0 items-center gap-1.5 px-2 text-[11px] font-medium text-foreground/80`,`hover:bg-primary/12 hover:text-primary`),children:[(0,Y.jsx)(I,{className:`size-3 shrink-0 text-foreground/70 group-hover:text-primary`,"aria-hidden":!0}),`View full activity`,(0,Y.jsx)(Ee,{className:`size-2.5 shrink-0 text-foreground/50 group-hover:text-primary`,"aria-hidden":!0})]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,Y.jsx)(O,{type:`button`,variant:`secondary`,size:`xs`,className:`h-6 px-2.5 text-[11px] font-medium`,onClick:t,children:`Close`})})]}),e.operation?.status===`cancelled`||o&&e.operation?(0,Y.jsx)(he,{type:e.operation.type,errorMessage:e.operation.error,className:`mt-2.5 w-full min-w-0`}):null]}):void 0,onDismiss:t,children:e.operation?(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(ne,{operation:e.operation,catalogTemplates:n}),e.logs.length>0?(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1.5 px-2 pb-2`,children:e.logs.map(e=>(0,Y.jsxs)(`div`,{className:F(`flex min-w-0 items-start gap-2 rounded-[var(--miravo-radius-tight)] border px-2.5 py-2 text-xs`,e.level===`error`?`border-destructive/35 bg-destructive/12 text-destructive`:e.level===`warn`?`border-warning/35 bg-warning/12 text-warning`:`border-primary/25 bg-primary/8 text-foreground/82`),children:[e.level===`info`?(0,Y.jsx)(Fe,{className:`mt-0.5 size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,Y.jsx)(z,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 wrap-anywhere`,children:e.message})]},e.id))}):null]}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(je,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`text-xs text-foreground/78`,children:`Connecting to Litmus Edge…`})]}),(0,Y.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/55`,children:(0,Y.jsx)(h.div,{className:`h-full w-2/5 rounded-full bg-primary`,animate:{x:[`-100%`,`250%`]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}})})]})})}var dt=`miravo:platforms:recent-template-ids`,ft=8,pt=`miravo:platforms:last-target-id`;function X(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(dt),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function mt(e){if(typeof window>`u`)return;let t=[e,...X().filter(t=>t!==e)].slice(0,ft);try{window.localStorage.setItem(dt,JSON.stringify(t))}catch{}}function ht(){if(!(typeof window>`u`))try{return window.localStorage.getItem(pt)??void 0}catch{return}}function gt(e){if(!(typeof window>`u`))try{window.localStorage.setItem(pt,e)}catch{}}function _t(e){return e instanceof DOMException&&e.name===`AbortError`||e instanceof Error&&e.name===`AbortError`}function vt(e){return e.map(e=>e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join(`, `)}function yt({onCloseTable:e,planKind:t=`apply`}){return(0,Y.jsx)(`div`,{className:`border-b border-border/40 px-3 py-3 sm:px-4`,children:(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-border/50 bg-muted/15`,children:(0,Y.jsx)(tt,{className:`size-4 text-muted-foreground`,"aria-hidden":!0})}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-1 pt-0.5 sm:gap-2`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,Y.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.14em] text-foreground`,children:t===`cleanup`?`Expected removals`:`Expected changes`}),(0,Y.jsx)(`span`,{className:`rounded-[var(--miravo-radius-tight)] border border-primary/25 bg-primary/5 px-1.5 py-px font-mono text-[9px] uppercase tracking-wider text-primary/90`,children:`Draft`})]}),(0,Y.jsx)(`p`,{className:`mt-1.5 max-w-prose text-[10px] leading-relaxed text-muted-foreground`,children:t===`cleanup`?`Preview only — nothing runs until you confirm cleanup.`:`Preview only — nothing runs until you confirm deploy.`})]}),e&&(0,Y.jsx)(O,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 text-muted-foreground hover:text-foreground`,onClick:e,"aria-label":`Close table`,children:(0,Y.jsx)(M,{className:`size-4`,"aria-hidden":!0})})]})]})})}var bt={create:`border-success/30 bg-success/12 text-success`,update:`border-info/30 bg-info/12 text-info`,replace:`border-chart-2/30 bg-chart-2/12 text-chart-2`,delete:`border-destructive/30 bg-destructive/12 text-destructive`,blocked:`border-warning/30 bg-warning/12 text-warning`};function xt({plan:e,planKind:t}){let n=t===`apply`&&e.sourceHostname!=null&&e.sourceHostname!==``;return(0,Y.jsx)(`div`,{className:`border-b border-border/35 bg-muted/10 px-3 py-2 sm:px-4`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-[10px] leading-snug sm:flex-row sm:flex-wrap sm:items-baseline sm:gap-x-4 sm:gap-y-1`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-[9px] uppercase tracking-wider text-muted-foreground/85`,children:`Target LE`}),(0,Y.jsx)(`span`,{className:`font-mono text-foreground/90 wrap-anywhere`,children:e.targetHost})]}),n?(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5 sm:border-l sm:border-border/50 sm:pl-4`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-[9px] uppercase tracking-wider text-muted-foreground/85`,children:_e}),(0,Y.jsx)(`span`,{className:`font-mono text-foreground/90 wrap-anywhere`,children:e.sourceHostname})]}):null]})})}function St({entries:e}){let t=e.reduce((e,t)=>(e[t.action]++,e),{create:0,update:0,replace:0,delete:0,blocked:0});return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/35 px-3 py-2.5 sm:px-4`,children:[(0,Y.jsx)(`span`,{className:`sr-only`,children:`Summary of planned actions`}),(0,Y.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Manifest`}),(0,Y.jsx)(`span`,{className:`hidden h-3 w-px bg-border/60 sm:block`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[t.create>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-success/25 bg-success/10 px-2 py-0.5 font-mono text-[10px] tabular-nums text-success`,children:[`+`,t.create,` new`]}),t.update>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-info/25 bg-info/10 px-2 py-0.5 font-mono text-[10px] tabular-nums text-info`,children:[`~`,t.update,` update`]}),t.replace>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-chart-2/25 bg-chart-2/10 px-2 py-0.5 font-mono text-[10px] tabular-nums text-chart-2`,children:[`↺`,t.replace,` replace`]}),t.delete>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-destructive/25 bg-destructive/10 px-2 py-0.5 font-mono text-[10px] tabular-nums text-destructive`,children:[`−`,t.delete,` remove`]}),t.blocked>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-warning/25 bg-warning/10 px-2 py-0.5 font-mono text-[10px] tabular-nums text-warning`,children:[t.blocked,` skipped`]})]})]})}function Ct({plan:e,onCloseTable:t,planKind:n=`apply`}){return e.entries.length===0?(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border/55`,children:[(0,Y.jsx)(yt,{onCloseTable:t,planKind:n}),(0,Y.jsx)(xt,{plan:e,planKind:n}),(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-3 px-4 py-10 text-center`,children:[(0,Y.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-border/50`,children:(0,Y.jsx)(tt,{className:`size-6 text-muted-foreground/45`,"aria-hidden":!0})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:n===`cleanup`?`Nothing to remove`:`Nothing to change`}),(0,Y.jsx)(`p`,{className:`mx-auto mt-2 max-w-sm text-[11px] leading-relaxed text-muted-foreground`,children:n===`cleanup`?`No Miravo-managed resources matched this cleanup scope on the environment — nothing would be deleted.`:`This environment already matches what is on the target — no create or update steps.`})]})]})]}):(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-border/45`,children:[(0,Y.jsx)(yt,{onCloseTable:t,planKind:n}),(0,Y.jsx)(xt,{plan:e,planKind:n}),(0,Y.jsx)(St,{entries:e.entries}),(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full min-w-lg text-xs`,children:[(0,Y.jsx)(`caption`,{className:`sr-only`,children:n===`cleanup`?`Detailed list of planned cleanup actions in deletion order`:`Detailed list of create, update, and delete actions in deployment order`}),(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`border-b border-border/45`,children:[(0,Y.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-10 bg-background px-3 py-2 text-left font-heading text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground sm:px-3.5`,children:`Action`}),(0,Y.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-10 bg-background px-3 py-2 text-left font-heading text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground sm:px-3.5`,children:`Type`}),(0,Y.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-10 bg-background px-3 py-2 text-left font-heading text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground sm:px-3.5`,children:`Name`}),(0,Y.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-10 hidden bg-background px-3 py-2 text-left font-heading text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground sm:table-cell sm:px-3.5`,children:`Protocol`}),(0,Y.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-10 hidden bg-background px-3 py-2 text-left font-heading text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground md:table-cell md:px-3.5`,children:`Detail`})]})}),(0,Y.jsx)(`tbody`,{children:e.entries.map((e,t)=>(0,Y.jsxs)(`tr`,{className:F(`border-b border-border/25 transition-colors`,t%2==1?`bg-muted/35`:`bg-transparent`,`hover:bg-primary/4`),children:[(0,Y.jsx)(`td`,{className:`px-3 py-2 align-middle sm:px-3.5`,children:(0,Y.jsx)(We,{variant:`outline`,className:F(`border px-1.5 py-0 font-mono text-[10px] uppercase tracking-wide`,bt[e.action]),children:e.action})}),(0,Y.jsx)(`td`,{className:`px-3 py-2 align-middle font-mono text-[11px] text-foreground sm:px-3.5`,children:e.resourceType}),(0,Y.jsx)(`td`,{className:`max-w-[min(16rem,28vw)] truncate px-3 py-2 align-middle font-mono text-[11px] text-foreground sm:max-w-xs sm:px-3.5`,children:e.name}),(0,Y.jsx)(`td`,{className:`hidden px-3 py-2 align-middle font-mono text-[11px] text-muted-foreground sm:table-cell sm:px-3.5`,children:e.protocol??`—`}),(0,Y.jsx)(`td`,{className:`hidden max-w-xs truncate px-3 py-2 align-middle text-[11px] text-muted-foreground md:table-cell md:px-3.5`,children:e.blockReason??e.detail??`—`})]},`${e.action}-${e.resourceType}-${e.name}-${e.protocol??``}-${e.detail??e.blockReason??``}`))})]})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border/40 px-3 py-3 text-[10px] text-muted-foreground sm:flex-row sm:items-center sm:justify-between sm:gap-4 sm:px-4`,children:[(0,Y.jsxs)(`span`,{children:[(0,Y.jsx)(`span`,{className:`font-mono tabular-nums text-foreground/90`,children:e.entries.length}),` `,(0,Y.jsxs)(`span`,{className:`text-muted-foreground/90`,children:[e.entries.length===1?`action`:`actions`,` queued`]})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[10px] wrap-anywhere`,children:[(0,Y.jsx)(`span`,{className:`shrink-0 text-[9px] uppercase tracking-wider text-muted-foreground/80`,children:`Scope`}),(0,Y.jsx)(`span`,{className:`min-w-0 text-foreground/90`,children:vt(e.scope)})]})]})]})}var wt=[`s1`,`s2`,`s3`,`s4`];function Tt(){return(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-border/45`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,Y.jsx)(`span`,{className:`sr-only`,children:`Loading plan preview`}),(0,Y.jsx)(`div`,{className:`border-b border-border/40 px-3 py-3 sm:px-4`,children:(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Y.jsx)(K,{className:`size-10 shrink-0 rounded-[var(--miravo-radius-stadium-sm)]`}),(0,Y.jsx)(`div`,{className:`flex min-w-0 flex-1 items-start gap-1 pt-0.5 sm:gap-2`,children:(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,Y.jsx)(K,{className:`h-3.5 w-40`}),(0,Y.jsx)(K,{className:`h-4 w-11 rounded-[var(--miravo-radius-tight)] border`})]}),(0,Y.jsx)(K,{className:`mt-1.5 h-3 max-w-prose`})]})})]})}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/35 px-3 py-2.5 sm:px-4`,children:[(0,Y.jsx)(K,{className:`h-2.5 w-14`}),(0,Y.jsx)(K,{className:`hidden h-3 w-px shrink-0 sm:block`}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(K,{className:`h-5 w-18 rounded-[var(--miravo-radius-tight)]`}),(0,Y.jsx)(K,{className:`h-5 w-24 rounded-[var(--miravo-radius-tight)]`}),(0,Y.jsx)(K,{className:`h-5 w-20 rounded-[var(--miravo-radius-tight)]`})]})]}),(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full min-w-lg text-xs`,"aria-hidden":!0,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`border-b border-border/45`,children:[(0,Y.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-10 bg-background px-3 py-2 text-left sm:px-3.5`,children:(0,Y.jsx)(K,{className:`h-2.5 w-12`})}),(0,Y.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-10 bg-background px-3 py-2 text-left sm:px-3.5`,children:(0,Y.jsx)(K,{className:`h-2.5 w-9`})}),(0,Y.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-10 bg-background px-3 py-2 text-left sm:px-3.5`,children:(0,Y.jsx)(K,{className:`h-2.5 w-10`})}),(0,Y.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-10 hidden bg-background px-3 py-2 text-left sm:table-cell sm:px-3.5`,children:(0,Y.jsx)(K,{className:`h-2.5 w-14`})}),(0,Y.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-10 hidden bg-background px-3 py-2 text-left md:table-cell md:px-3.5`,children:(0,Y.jsx)(K,{className:`h-2.5 w-11`})})]})}),(0,Y.jsx)(`tbody`,{children:wt.map((e,t)=>(0,Y.jsxs)(`tr`,{className:F(`border-b border-border/25 transition-colors`,t%2==1?`bg-muted/35`:`bg-transparent`,`hover:bg-primary/4`),children:[(0,Y.jsx)(`td`,{className:`px-3 py-2 align-middle sm:px-3.5`,children:(0,Y.jsx)(K,{className:`h-5 w-13 rounded-[var(--miravo-radius-tight)]`})}),(0,Y.jsx)(`td`,{className:`px-3 py-2 align-middle sm:px-3.5`,children:(0,Y.jsx)(K,{className:`h-3.5 w-16 font-mono`})}),(0,Y.jsx)(`td`,{className:`max-w-[min(16rem,28vw)] px-3 py-2 align-middle sm:max-w-xs sm:px-3.5`,children:(0,Y.jsx)(K,{className:`h-3.5 w-full max-w-48 font-mono`})}),(0,Y.jsx)(`td`,{className:`hidden px-3 py-2 align-middle sm:table-cell sm:px-3.5`,children:(0,Y.jsx)(K,{className:`h-3.5 w-10 font-mono`})}),(0,Y.jsx)(`td`,{className:`hidden max-w-xs px-3 py-2 align-middle md:table-cell md:px-3.5`,children:(0,Y.jsx)(K,{className:`h-3.5 w-full max-w-40`})})]},e))})]})}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border/40 px-3 py-3 text-[10px] text-muted-foreground sm:flex-row sm:items-center sm:justify-between sm:gap-4 sm:px-4`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(K,{className:`inline-block h-3 w-6 rounded-[var(--miravo-radius-tight)]`}),(0,Y.jsx)(K,{className:`inline-block h-3 w-28`})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 font-mono text-[10px] wrap-anywhere`,children:[(0,Y.jsx)(K,{className:`h-2.5 w-8 shrink-0`}),(0,Y.jsx)(K,{className:`h-6 min-w-32 rounded-[var(--miravo-radius-tight)] border border-border/50 px-2 py-0.5`}),(0,Y.jsx)(K,{className:`h-1 w-1 shrink-0 rounded-full`}),(0,Y.jsx)(K,{className:`h-2.5 w-10 shrink-0`}),(0,Y.jsx)(K,{className:`h-3 min-w-16 max-w-56 flex-1`})]})]})]})}var Et=50;function Dt({open:e,type:t,targetLabel:n,targetHostname:r,templates:i,templatesLoading:a,templatesError:o,onRetryTemplates:s,onOpenChange:c,onSelect:l}){let[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(X),m=(0,J.useDeferredValue)(u);(0,J.useEffect)(()=>{e&&(d(``),p(X()))},[e]);let h=(0,J.useMemo)(()=>{let e=m.trim().toLowerCase(),t=new Map(f.map((e,t)=>[e,t])),n=[],r=new Set;for(let t of i){if(r.has(t.id))continue;r.add(t.id);let i=[t.name,t.id,t.category,t.description??``,t.models.join(` `)].join(` `).toLowerCase();e!==``&&!i.includes(e)||n.push(t)}return n.sort((e,n)=>{let r=t.get(e.id)??1/0,i=t.get(n.id)??1/0;return r===i?e.name.localeCompare(n.name):r-i}),{items:n.slice(0,Et),total:n.length,recentRank:t}},[i,m,f]),g=t===`apply`?`Apply environment`:`Cleanup environment`,_=e=>{mt(e.id),l(e)};return(0,Y.jsx)(C,{open:e,onOpenChange:c,children:(0,Y.jsxs)(ee,{className:`flex max-h-[82vh] min-h-0 flex-col gap-0 overflow-hidden p-0 sm:max-w-xl`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 px-5 pb-3 pt-5`,children:[(0,Y.jsx)(T,{className:`text-sm font-semibold`,children:g}),(0,Y.jsxs)(x,{className:`mt-1 text-xs`,children:[n,` / `,r]})]}),(0,Y.jsx)(`div`,{className:`shrink-0 border-b border-border/45 px-5 py-3`,children:(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(R,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsx)(N,{value:u,onChange:e=>d(e.currentTarget.value),className:`h-9 pl-8`,placeholder:`Search environments`,autoFocus:!0})]})}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:a&&i.length===0?(0,Y.jsx)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`Loading environments...`}):o&&i.length===0?(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-[var(--miravo-radius-tight)] border border-warning/25 bg-warning/5 px-3 py-2 text-xs text-warning`,children:[(0,Y.jsx)(`span`,{children:`Could not load environments.`}),(0,Y.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 text-warning hover:text-warning`,onClick:s,children:`Retry`})]}):h.items.length===0?(0,Y.jsx)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 px-3 py-2 text-xs text-muted-foreground`,children:`No matching environments.`}):(0,Y.jsx)(`div`,{className:`flex flex-col gap-1`,children:h.items.map(e=>{let t=h.recentRank.has(e.id);return(0,Y.jsxs)(`button`,{type:`button`,className:`flex min-h-12 w-full min-w-0 items-center gap-2 rounded-[var(--miravo-radius-tight)] px-2 py-2 text-left text-xs transition-colors hover:bg-muted/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70`,onClick:()=>_(e),children:[(0,Y.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border border-border/35 bg-muted/25 text-primary`,children:(0,Y.jsx)(be,{id:e.id,className:`size-3.5`})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:e.name}),t?(0,Y.jsx)(`span`,{className:`shrink-0 rounded-[var(--miravo-radius-tight)] border border-primary/25 bg-primary/8 px-1.5 py-px font-mono text-[9px] uppercase tracking-wider text-primary`,children:`Recent`}):null]}),(0,Y.jsxs)(`span`,{className:`mt-0.5 block truncate font-mono text-[11px] text-muted-foreground`,children:[e.id,` / `,e.instanceCount,` instances`]})]})]},e.id)})})}),h.total>h.items.length?(0,Y.jsxs)(`div`,{className:`shrink-0 border-t border-border/45 px-5 py-2 text-[11px] text-muted-foreground`,children:[`Showing `,h.items.length,` of `,h.total,`. Refine search.`]}):null]})})}function Ot({targets:e,stream:t}){let[n,r]=(0,J.useState)(`apply`),[a,c]=(0,J.useState)(``),[l,u]=(0,J.useState)(``),[d,p]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1),[C,w]=(0,J.useState)(!1),[ee]=(0,J.useState)(ht),T=(0,J.useRef)(0),E=(0,J.useRef)(null),D=t.status===`running`,k=n===`apply`,A=f({queryKey:o.catalog.templates(),queryFn:()=>s(`/catalog/templates`,i.catalogTemplates)}),j=A.data??[],N=j.find(e=>e.id===l),P=e.find(e=>e.id===a),I=k?!!a&&!!l:!!a&&(d||!!l),L=(0,J.useCallback)(()=>{T.current+=1,E.current?.abort(),E.current=null,y(!1),_(null)},[]);(0,J.useEffect)(()=>{if(!(l||j.length===0||d))for(let e of X()){let t=j.find(t=>t.id===e);if(t){u(t.id);return}}},[l,j,d]);let R=(0,J.useCallback)(()=>{L(),S.message(`Preview cancelled`)},[L]),z=e=>{D||(r(e),L(),p(!1))},te=(0,J.useCallback)(async e=>{if(e===`apply`){if(!a||!l)return}else if(!a||!d&&!l)return;t.operation&&t.status!==`running`&&t.reset(),E.current?.abort(),T.current+=1;let n=T.current,r=new AbortController;E.current=r,y(!0),_(null);try{let t=e===`apply`?await me({targetId:a,template:l},{signal:r.signal}):await se({targetId:a,...d?{allManaged:!0}:{template:l}},{signal:r.signal});if(n!==T.current)return;_(t.plan)}catch(t){if(n!==T.current||_t(t))return;S.error(q(t,e===`apply`?`Plan failed`:`Cleanup plan failed`))}finally{n===T.current&&y(!1)}},[a,l,d,t]),ne=(0,J.useCallback)(e=>{x(!1),L();let{scope:r,ifUnmanaged:i}=e;gt(a),l&&mt(l),n===`apply`?t.startApply({targetId:a,template:l,scope:r,ifUnmanaged:i}):t.startCleanup({targetId:a,...d?{allManaged:!0}:{template:l},scope:r})},[n,a,l,d,t,L]),V=!k&&d,H=I&&!D,re=k?Le:B,oe=`Awaiting selection`;H&&(oe=k?`Commit apply`:`Commit cleanup`);let ce=V?`All managed resources`:N?.name??`Select environment`,U=(0,Y.jsx)(ze,{className:`size-3.5`,"aria-hidden":!0});V?U=(0,Y.jsx)(B,{className:`size-3.5`,"aria-hidden":!0}):N&&(U=(0,Y.jsx)(be,{id:N.id,className:`size-3.5`}));let ue=k?`Provisions devices, tags, and Digital Twin models from the selected environment on the selected target.`:`Removes Miravo-managed resources for this environment from the selected target.`;V&&(ue=`Removes all Miravo-managed resources from the target (ignores environment scope).`);let de=P?`${P.label} / ${ce}`:`Select target and environment`;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Y.jsxs)(`div`,{role:`toolbar`,"aria-label":`Operation mode`,className:`inline-flex items-center gap-0.5 rounded-[var(--miravo-radius-pill)] border border-border/50 bg-muted/15 p-0.5`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":k,className:F(`relative flex items-center gap-1.5 rounded-[var(--miravo-radius-pill)] px-4 py-1.5 text-xs font-medium transition-colors`,k?`text-primary`:`text-muted-foreground hover:text-foreground`),onClick:()=>z(`apply`),disabled:D,children:[k&&(0,Y.jsx)(h.span,{layoutId:`mode-pill`,className:`absolute inset-0 rounded-[var(--miravo-radius-pill)] bg-primary/15 shadow-sm`,transition:{type:`spring`,stiffness:500,damping:40}}),(0,Y.jsx)(at,{className:`relative z-10 size-3.5`}),(0,Y.jsx)(`span`,{className:`relative z-10`,children:`Apply`})]}),(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":!k,className:F(`relative flex items-center gap-1.5 rounded-[var(--miravo-radius-pill)] px-4 py-1.5 text-xs font-medium transition-colors`,k?`text-muted-foreground hover:text-foreground`:`text-destructive`),onClick:()=>z(`cleanup`),disabled:D,children:[!k&&(0,Y.jsx)(h.span,{layoutId:`mode-pill`,className:`absolute inset-0 rounded-[var(--miravo-radius-pill)] bg-destructive/15 shadow-sm`,transition:{type:`spring`,stiffness:500,damping:40}}),(0,Y.jsx)(B,{className:`relative z-10 size-3.5`}),(0,Y.jsx)(`span`,{className:`relative z-10`,children:`Cleanup`})]})]}),(0,Y.jsx)(le,{stream:t})]}),(0,Y.jsx)(ae,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-border/25 pb-3`,children:[(0,Y.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-primary/25 bg-primary/9 shadow-[inset_0_1px_0_0_var(--miravo-inset-highlight)]`,children:(0,Y.jsx)(ze,{className:`size-4 text-primary`,"aria-hidden":!0})}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.12em] text-foreground`,children:`Litmus Edge`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-muted-foreground`,children:ue})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(Qe,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Target`}),(0,Y.jsx)(ie,{targets:e,value:a,onValueChange:e=>{c(e),gt(e),L()},preferredTargetId:ee,disabled:D,size:`sm`,className:`min-w-0 w-full text-xs`})]}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(Qe,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Environment`}),A.isError&&!A.data&&(0,Y.jsx)(m,{message:q(A.error,`Failed to load environments.`),onRetry:()=>void A.refetch(),isRetrying:A.isFetching&&!A.isPending}),(0,Y.jsxs)(`button`,{type:`button`,disabled:V||D||!P,onClick:()=>w(!0),className:F(`flex h-9 min-h-9 w-full min-w-0 items-center justify-between gap-1.5 rounded-[var(--miravo-radius-stadium-sm)] border border-input bg-input/30 px-2.5 py-0 text-left text-xs outline-none transition-colors select-none`,`hover:bg-input/50 focus-visible:border-primary/35 focus-visible:ring-2 focus-visible:ring-primary/22`,`disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50`),"aria-label":`Environment`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-border/35 bg-muted/25 text-primary`,children:U}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:ce})]}),(0,Y.jsx)(Se,{className:`pointer-events-none size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]})]})]}),(0,Y.jsxs)(`button`,{type:`button`,disabled:!H||v,onClick:()=>x(!0),className:F(`group flex w-full min-h-14 min-w-0 items-stretch overflow-hidden rounded-[var(--miravo-radius-stadium-lg)] text-left outline-none`,`transition-[border-color,box-shadow,background-color] duration-200 ease-out`,`focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:pointer-events-none disabled:opacity-55`,H?[`border-2 border-primary/40 bg-background`,`bg-linear-to-r from-primary/12 via-background to-background`,`shadow-[inset_0_1px_0_0_rgba(255,255,255,0.025)]`,`hover:border-primary/56 hover:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.025),0_0_14px_-8px_color-mix(in_srgb,var(--primary)_18%,transparent),0_0_22px_-12px_color-mix(in_srgb,var(--primary)_8%,transparent)]`]:[`border border-dashed border-border/65 bg-muted/15`,`hover:bg-muted/22`]),children:[(0,Y.jsx)(`span`,{className:`relative flex w-18 shrink-0 items-center justify-center bg-transparent`,"aria-hidden":!0,children:(0,Y.jsx)(re,{className:F(`relative size-5`,H?`text-primary`:`text-muted-foreground`)})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-0.5 overflow-hidden px-3 py-2.5 sm:px-4`,children:[(0,Y.jsx)(`span`,{className:F(`font-heading text-[11px] font-semibold uppercase tracking-[0.18em]`,H?`text-primary`:`text-muted-foreground`),children:oe}),(0,Y.jsx)(`span`,{className:F(`truncate font-mono text-[13px] leading-tight tracking-tight`,H?`text-foreground`:`text-muted-foreground`),children:de})]}),(0,Y.jsx)(`span`,{className:F(`flex shrink-0 items-center pr-2.5 sm:pr-3`,H&&`pl-1`),children:(0,Y.jsx)(`span`,{className:F(`flex size-9 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border bg-transparent transition-[border-color,color] duration-200`,H?`border-primary/40 text-primary group-hover:border-primary/55`:`border-border/45 text-muted-foreground`),"aria-hidden":!0,children:(0,Y.jsx)(Ee,{className:`size-4`,strokeWidth:2.25})})})]}),!k&&(0,Y.jsx)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-end gap-2`,children:(0,Y.jsxs)(Qe,{id:`all-managed-label`,htmlFor:`all-managed`,"aria-disabled":D,className:F(`inline-flex h-8 w-fit max-w-full cursor-pointer items-center gap-2 text-xs font-medium leading-none`,D&&`pointer-events-none opacity-40`),children:[(0,Y.jsx)(Re,{id:`all-managed`,checked:d,onCheckedChange:e=>{p(e===!0),L()},disabled:D}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Remove all Miravo managed resources`})]})})]})}),(v||g)&&!D&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[v&&(0,Y.jsx)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-end gap-2`,children:(0,Y.jsxs)(O,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:R,children:[(0,Y.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}),`Cancel preview`]})}),v&&(0,Y.jsx)(Tt,{}),g&&!v&&(0,Y.jsx)(Ct,{plan:g,planKind:k?`apply`:`cleanup`,onCloseTable:L})]}),P&&C?(0,Y.jsx)(Dt,{open:!0,type:n,targetLabel:P.label,targetHostname:P.hostname,templates:j,templatesLoading:A.isPending&&A.data===void 0,templatesError:A.isError&&j.length===0,onRetryTemplates:()=>void A.refetch(),onOpenChange:w,onSelect:e=>{u(e.id),mt(e.id),p(!1),L(),k&&t.reset(),w(!1)}}):null,P&&(0,Y.jsx)(ve,{open:b,onOpenChange:x,type:n,label:V?`All managed resources`:N?.name??l,targetLabel:P.label,hostname:P.hostname,sourceHostname:P.sourceHostname,onConfirm:ne,applyPreview:k?{onPreview:()=>void te(`apply`),planLoading:v,disabled:!a||!l||D}:void 0,cleanupPreview:k?void 0:{onPreview:()=>void te(`cleanup`),planLoading:v,disabled:!a||!d&&!l||D}})]})}function kt(){return(0,Y.jsx)(`section`,{"aria-labelledby":`platforms-operation-log-empty-title`,className:ot,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-4 px-4 py-8 text-center sm:py-10`,children:[(0,Y.jsx)(`div`,{className:`flex size-12 items-center justify-center rounded-(--miravo-radius-stadium-sm) border border-dashed border-border/50`,children:(0,Y.jsx)(I,{className:`size-6 text-muted-foreground/45`,"aria-hidden":!0})}),(0,Y.jsxs)(`div`,{className:`max-w-sm`,children:[(0,Y.jsx)(`h2`,{id:`platforms-operation-log-empty-title`,className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`No operations yet`}),(0,Y.jsx)(`p`,{className:`mt-2 text-pretty text-sm leading-relaxed text-muted-foreground`,children:`Run apply or cleanup from the Operations tab. Finished runs show up here with full detail.`})]})]})})}function At(e){let t=new Date(e),n=new Date,r=new Date(n);return r.setDate(n.getDate()-1),t.toDateString()===n.toDateString()?`Today`:t.toDateString()===r.toDateString()?`Yesterday`:t.toLocaleDateString(`en-US`,{weekday:`short`,month:`short`,day:`numeric`})}function jt(e){let t=new Map;for(let n of e){let e=new Date(n.completedAt).toDateString(),r=t.get(e);r?r.push(n):t.set(e,[n])}return Array.from(t.entries()).map(([,e])=>({label:At(e[0]?.completedAt??Date.now()),ops:e}))}function Z(e,t){return e===`device`?t.operationType===`apply`?`Tag/register writes per device step—not a device count.`:`One count per device removed from DeviceHub.`:e===`model`?`One count per model in this run.`:e===`instance`?`One count per twin instance in this run.`:`Sets the device parameter to the bound DeviceHub device.`}var Mt={devices:`Devices`,models:`DT models`,instances:`DT instances`},Q={create:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-success/35 bg-success/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-success`,update:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-primary/35 bg-primary/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-primary`,replace:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-chart-2/35 bg-chart-2/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-chart-2`,delete:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-destructive/35 bg-destructive/12 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-destructive`,failed:`inline-flex items-center rounded-[var(--miravo-radius-tight)] border border-destructive/40 bg-destructive/18 px-1.5 py-0.5 font-mono text-[10px] font-semibold tabular-nums text-destructive`};function Nt(e){return[{key:`device`,title:`DeviceHub — protocol tags`,subtitle:Z(`device`,e),counts:e.resourceCounts.device},{key:`model`,title:`Digital Twin models`,subtitle:Z(`model`,e),counts:e.resourceCounts.model},{key:`instance`,title:`Twin instances`,subtitle:Z(`instance`,e),counts:e.resourceCounts.instance},{key:`param-sync`,title:`Parameter sync`,subtitle:Z(`param-sync`,e),counts:e.resourceCounts[`param-sync`]}].filter(e=>e.counts.total>0||e.counts.failed>0)}function Pt(e){return e.length===0?`Default (devices, models, instances)`:e.map(e=>Mt[e]??e).join(` · `)}function Ft(e){let t=[];return e.filters.area&&t.push(`Area ${e.filters.area}`),e.filters.line&&t.push(`Line ${e.filters.line}`),e.filters.instance&&t.push(`Instance ${e.filters.instance}`),t.length>0?t.join(` · `):null}function $(e,t,n){if(e===`device`)switch(t){case`create`:return`+${n} tags (new device)`;case`update`:return`${n} tags rewritten`;case`replace`:return`↻${n} tags (device replaced)`;case`delete`:return`−${n} removed`}switch(t){case`create`:return`+${n} created`;case`update`:return`${n} updated`;case`replace`:return`↻${n} replaced`;case`delete`:return`−${n} removed`}}function It({row:e}){let{key:t,counts:n}=e;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-1.5`,children:[n.create>0&&(0,Y.jsx)(`span`,{className:Q.create,children:$(t,`create`,n.create)}),n.update>0&&(0,Y.jsx)(`span`,{className:Q.update,children:$(t,`update`,n.update)}),n.replace>0&&(0,Y.jsx)(`span`,{className:Q.replace,children:$(t,`replace`,n.replace)}),n.delete>0&&(0,Y.jsx)(`span`,{className:Q.delete,children:$(t,`delete`,n.delete)}),n.failed>0&&(0,Y.jsx)(`span`,{className:Q.failed,children:`${n.failed} failed`})]})}function Lt({op:e}){let t=Ft(e);return(0,Y.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 bg-muted/25 px-3 py-2.5`,children:[(0,Y.jsx)(`p`,{className:`font-mono text-[10px] uppercase tracking-[0.16em] text-foreground/72`,children:`Run context`}),(0,Y.jsxs)(`dl`,{className:`mt-2 grid grid-cols-[minmax(0,7.5rem)_1fr] gap-x-3 gap-y-1.5 text-xs sm:grid-cols-[9rem_1fr]`,children:[(0,Y.jsx)(`dt`,{className:`text-foreground/70`,children:`Operation`}),(0,Y.jsx)(`dd`,{className:`font-medium capitalize text-foreground`,children:e.operationType}),(0,Y.jsx)(`dt`,{className:`text-foreground/70`,children:`Target host`}),(0,Y.jsx)(`dd`,{className:`break-all font-mono text-[11px] text-foreground`,children:e.hostname}),(0,Y.jsx)(`dt`,{className:`text-foreground/70`,children:`Scope`}),(0,Y.jsx)(`dd`,{className:`text-foreground`,children:Pt(e.scope)}),t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-foreground/70`,children:`Filters`}),(0,Y.jsx)(`dd`,{className:`text-foreground`,children:t})]}),(0,Y.jsx)(`dt`,{className:`text-foreground/70`,children:`Duration`}),(0,Y.jsxs)(`dd`,{className:`tabular-nums text-foreground`,children:[(e.durationMs/1e3).toFixed(1),`s`]}),(0,Y.jsx)(`dt`,{className:`text-foreground/70`,children:`Outcome`}),(0,Y.jsxs)(`dd`,{className:`text-foreground`,children:[(0,Y.jsx)(`span`,{className:`tabular-nums`,children:e.successCount}),` steps succeeded`,e.failedCount>0&&(0,Y.jsxs)(`span`,{className:`text-destructive`,children:[` `,`· `,(0,Y.jsx)(`span`,{className:`tabular-nums`,children:e.failedCount}),` failed`]}),e.blockedCount>0&&(0,Y.jsxs)(`span`,{className:`text-warning`,children:[` `,`· `,(0,Y.jsx)(`span`,{className:`tabular-nums`,children:e.blockedCount}),` blocked in plan`]})]})]})]})}function Rt({status:e}){switch(e){case`success`:return(0,Y.jsx)(Oe,{className:`mt-px size-4 shrink-0 text-success`});case`failed`:return(0,Y.jsx)(Ne,{className:`mt-px size-4 shrink-0 text-destructive`});case`partial`:case`blocked`:return(0,Y.jsx)(Be,{className:`mt-px size-4 shrink-0 text-warning`});case`noop`:return(0,Y.jsx)(nt,{className:`mt-px size-4 shrink-0 text-foreground/55`})}}function zt(e){let t=e.operationType===`apply`?`Applied`:`Cleaned up`,n=`${(e.durationMs/1e3).toFixed(1)}s`,r=[];return e.successCount>0&&r.push(`${e.successCount} resources`),e.failedCount>0&&r.push(`${e.failedCount} failed`),e.blockedCount>0&&r.push(`${e.blockedCount} blocked`),r.length===0?`${t} · no changes · ${n}`:`${t} · ${r.join(`, `)} · ${n}`}function Bt(e){return e.operationType===`cleanup`&&e.successCount===0&&e.failedCount===0&&e.blockedCount===0?`No Miravo-managed resources were found to clean up.`:e.failedCount>0&&e.blockedCount>0?`No per-phase counts — failures and blocked plan entries.`:e.failedCount>0?`No per-phase counts — run failed.`:e.blockedCount>0?`No per-phase counts — blocked plan entries.`:`No per-phase counts recorded.`}function Vt({op:e}){let t=Nt(e);return t.length===0?(0,Y.jsx)(`p`,{className:`py-1 text-sm text-foreground/75`,children:Bt(e)}):(0,Y.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col divide-y divide-border/45 rounded-[var(--miravo-radius-tight)] border border-border/50`,children:t.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2.5 sm:flex-row sm:items-start sm:gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 shrink-0 sm:w-[11.5rem]`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium leading-snug text-foreground`,children:e.title}),(0,Y.jsxs)(Ue,{children:[(0,Y.jsx)(Ve,{type:`button`,className:`inline-flex shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] p-0.5 text-foreground/60 hover:bg-muted/50 hover:text-foreground`,"aria-label":`About ${e.title}`,children:(0,Y.jsx)(Fe,{className:`size-3.5`,"aria-hidden":!0})}),(0,Y.jsx)(He,{side:`top`,className:`max-w-xs text-left`,children:e.subtitle})]})]}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-snug text-foreground/72 sm:hidden`,children:e.subtitle})]}),(0,Y.jsx)(It,{row:e})]},e.key))}),e.blockedCount>0&&(0,Y.jsxs)(`p`,{className:`rounded-[var(--miravo-radius-tight)] border border-warning/20 bg-warning/5 px-2.5 py-1.5 text-[11px] text-warning`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:e.blockedCount}),` plan entries were blocked (skipped). Open a `,(0,Y.jsx)(`span`,{className:`font-medium`,children:`deploy preview`}),` before running to see block reasons.`]})]})}function Ht({operation:e}){let[t,n]=(0,J.useState)(!1),r=e.targetLabel;return(0,Y.jsxs)(`div`,{className:F(`overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-border/55`,`transition-colors duration-150`),children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(e=>!e),className:F(`flex w-full items-start gap-3 p-3.5 text-left`,`transition-colors duration-100`,`hover:bg-muted/25`,t&&`bg-muted/18`),children:[(0,Y.jsx)(Rt,{status:e.status}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`p`,{className:`min-w-0 truncate text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium text-foreground`,children:j(e.templateId)}),(0,Y.jsx)(`span`,{className:`mx-1.5 text-foreground/50`,children:`→`}),(0,Y.jsx)(`span`,{className:`text-foreground/82`,children:r})]}),(0,Y.jsx)(`time`,{dateTime:new Date(e.completedAt).toISOString(),title:A(e.completedAt),className:`shrink-0 text-xs text-foreground/75`,children:k(e.completedAt)})]}),(0,Y.jsx)(`p`,{className:`text-xs text-foreground/78`,children:zt(e)}),(e.failedCount>0||e.status===`failed`)&&(0,Y.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/72`,children:`Temporary edge issue? Run apply again from Operations — Miravo usually succeeds on retry.`})]}),(0,Y.jsx)(Se,{className:F(`mt-0.5 size-3.5 shrink-0 text-foreground/55 transition-transform duration-150`,t&&`rotate-180`)})]}),(0,Y.jsx)(g,{initial:!1,children:t&&(0,Y.jsx)(h.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.2,ease:`easeOut`},className:`overflow-hidden`,children:(0,Y.jsxs)(`div`,{className:`space-y-3 border-t border-border/45 px-4 pb-3 pt-3`,children:[(0,Y.jsx)(Lt,{op:e}),e.error&&(0,Y.jsxs)(`div`,{className:`relative rounded-[var(--miravo-radius-tight)] border border-destructive/40 bg-destructive/15 px-3 py-2 pr-10 text-xs font-medium`,children:[(0,Y.jsx)(`div`,{className:`absolute top-1.5 right-1.5 z-10`,children:(0,Y.jsx)(E,{value:e.error,label:`Copy error`,className:`text-destructive hover:bg-destructive/25 hover:text-foreground`})}),(0,Y.jsx)(`p`,{className:`whitespace-normal break-words text-destructive [overflow-wrap:anywhere]`,children:e.error}),(0,Y.jsx)(`p`,{className:`mt-2 text-[11px] font-normal leading-snug text-foreground/78 [overflow-wrap:anywhere]`,children:`Retry apply if the edge was slow or unreachable.`})]}),(0,Y.jsx)(Vt,{op:e})]})})})]})}function Ut({label:e}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,Y.jsx)(`div`,{className:`h-px flex-1 bg-border/65`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground/78`,children:e}),(0,Y.jsx)(`div`,{className:`h-px flex-1 bg-border/65`})]})}var Wt={type:``,status:``,target:``,search:``},Gt={_all:`All types`,apply:`Apply`,cleanup:`Cleanup`},Kt={_all:`All statuses`,success:`Success`,partial:`Partial`,failed:`Failed`,blocked:`Blocked`,noop:`No-op`},qt=`h-7 min-h-7 gap-1.5 border-border/50 bg-transparent px-2 text-xs hover:bg-muted/30 focus:ring-0`;function Jt({filters:e,targetOptions:t,hasFilters:n,searchRef:r,onTypeChange:i,onStatusChange:a,onTargetChange:o,onSearchChange:s,onClear:c}){return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b border-border/50 px-3 py-2`,children:[(0,Y.jsxs)(Te,{value:e.type||`_all`,onValueChange:e=>e&&i(e===`_all`?``:e),children:[(0,Y.jsx)(we,{size:`sm`,className:qt,"aria-label":`Operation type`,children:(0,Y.jsx)(xe,{children:e=>Gt[e??`_all`]??Gt._all})}),(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(W,{value:`_all`,children:`All types`}),(0,Y.jsx)(W,{value:`apply`,children:`Apply`}),(0,Y.jsx)(W,{value:`cleanup`,children:`Cleanup`})]})]}),(0,Y.jsxs)(Te,{value:e.status||`_all`,onValueChange:e=>e&&a(e===`_all`?``:e),children:[(0,Y.jsx)(we,{size:`sm`,className:qt,"aria-label":`Operation status`,children:(0,Y.jsx)(xe,{children:e=>Kt[e??`_all`]??Kt._all})}),(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(W,{value:`_all`,children:`All statuses`}),(0,Y.jsx)(W,{value:`success`,children:`Success`}),(0,Y.jsx)(W,{value:`partial`,children:`Partial`}),(0,Y.jsx)(W,{value:`failed`,children:`Failed`}),(0,Y.jsx)(W,{value:`blocked`,children:`Blocked`}),(0,Y.jsx)(W,{value:`noop`,children:`No-op`})]})]}),t.length>1&&(0,Y.jsxs)(Te,{value:e.target||`_all`,onValueChange:e=>e&&o(e===`_all`?``:e),children:[(0,Y.jsx)(we,{size:`sm`,className:qt,"aria-label":`Target filter`,children:(0,Y.jsx)(xe,{children:e=>!e||e===`_all`?`All targets`:e})}),(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(W,{value:`_all`,children:`All targets`}),t.map(e=>(0,Y.jsx)(W,{value:e,children:e},e))]})]}),(0,Y.jsxs)(`div`,{className:`relative flex min-w-[140px] flex-1 items-center`,children:[(0,Y.jsx)(`input`,{ref:r,type:`search`,value:e.search,onChange:e=>s(e.target.value),placeholder:`Search environment or target…`,"aria-describedby":`ops-search-shortcut`,className:F(`h-7 w-full rounded-[var(--miravo-radius-tight)] border border-border/50 bg-transparent pl-2 pr-7 text-xs`,`placeholder:text-foreground/60 focus:outline-none focus:ring-1 focus:ring-ring/40`,e.search&&`pr-2`)}),(0,Y.jsx)(`span`,{id:`ops-search-shortcut`,className:`sr-only`,children:`Press slash to focus search`}),!e.search&&(0,Y.jsx)(`kbd`,{"aria-hidden":!0,className:`pointer-events-none absolute right-2 flex h-4 items-center rounded-[var(--miravo-radius-tight)] border border-border/60 bg-muted/50 px-1 font-mono text-[10px] text-foreground/65`,children:`/`})]}),n&&(0,Y.jsxs)(`button`,{type:`button`,onClick:c,className:`flex h-7 items-center gap-1 rounded-[var(--miravo-radius-tight)] px-2 text-xs text-foreground/72 transition-colors hover:bg-muted/40 hover:text-foreground`,children:[(0,Y.jsx)(M,{className:`size-3`}),`Clear`]})]})}function Yt({operations:e,totalKnown:t,isLoading:n,error:r,onRefresh:i,hasNextPage:a=!1,isFetchingNextPage:o=!1,loadMoreError:s=null,onRetryLoadMore:c,onLoadMore:l}){let[u,d]=(0,J.useState)(!1),[f,m]=(0,J.useState)(Wt),_=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),_.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let v=()=>{d(!0),i(),S.success(`Operations refreshed`),setTimeout(()=>d(!1),600)},y=(0,J.useMemo)(()=>{let t=new Set;for(let n of e){let e=n.targetLabel;t.add(e)}return[...t].sort()},[e]),b=(0,J.useMemo)(()=>{let t=e;if(f.type&&(t=t.filter(e=>e.operationType===f.type)),f.status&&(t=t.filter(e=>e.status===f.status)),f.target&&(t=t.filter(e=>e.targetLabel===f.target)),f.search){let e=f.search.toLowerCase();t=t.filter(t=>{let n=t.targetLabel;return t.templateId.toLowerCase().includes(e)||j(t.templateId).toLowerCase().includes(e)||n.toLowerCase().includes(e)})}return t},[e,f]),x=f.type!==``||f.status!==``||f.target!==``||f.search!==``,C=(0,J.useMemo)(()=>jt(b),[b]);return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col rounded-[var(--miravo-radius-stadium-sm)] border border-border/55`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/50 px-3.5 py-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Operation log`}),e.length>0&&(0,Y.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-foreground/75`,children:typeof t==`number`&&t>0&&e.length<t?`${e.length} / ${t}`:String(e.length)})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:v,disabled:u,"aria-label":`Refresh operation list`,className:`relative rounded-[var(--miravo-radius-tight)] p-1 text-foreground/70 transition-colors before:absolute before:inset-[-10px] before:content-[''] hover:bg-muted/50 hover:text-foreground disabled:pointer-events-none`,children:(0,Y.jsx)(p,{className:F(`size-3.5`,u&&`animate-spin`),"aria-hidden":!0})})]}),(0,Y.jsx)(Jt,{filters:f,targetOptions:y,hasFilters:x,searchRef:_,onTypeChange:e=>m(t=>({...t,type:e})),onStatusChange:e=>m(t=>({...t,status:e})),onTargetChange:e=>m(t=>({...t,target:e})),onSearchChange:e=>m(t=>({...t,search:e})),onClear:()=>m(Wt)}),(0,Y.jsxs)(`div`,{className:`flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto overscroll-y-contain p-3`,children:[r&&(0,Y.jsxs)(`p`,{className:`py-2 text-xs text-destructive`,children:[`✕ `,r.message]}),n&&e.length===0&&!r&&(0,Y.jsx)(`p`,{className:`py-4 text-sm text-foreground/75`,children:`Loading…`}),!n&&e.length===0&&!r&&(0,Y.jsx)(kt,{}),!n&&e.length>0&&b.length===0&&(0,Y.jsxs)(`p`,{className:`py-6 text-center text-sm text-foreground/75`,children:[`No operations match your filters.`,` `,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>m(Wt),className:`text-primary hover:underline`,children:`Clear filters`})]}),x&&b.length>0&&b.length!==e.length&&(0,Y.jsxs)(`p`,{className:`text-xs text-foreground/75`,children:[`Showing`,` `,(0,Y.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:b.length}),` of`,` `,(0,Y.jsx)(`span`,{className:`tabular-nums`,children:e.length}),` loaded`]}),!x&&typeof t==`number`&&t>0&&e.length<t&&(0,Y.jsxs)(`p`,{className:`text-xs text-foreground/75`,children:[`Showing`,` `,(0,Y.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:e.length}),` `,`of `,(0,Y.jsx)(`span`,{className:`tabular-nums`,children:t}),`. Load more for older entries.`]}),(0,Y.jsx)(g,{initial:!1,children:C.map(e=>(0,Y.jsxs)(h.div,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(Ut,{label:e.label}),(0,Y.jsx)(g,{initial:!1,children:e.ops.map(e=>(0,Y.jsx)(h.div,{initial:b.length>40?!1:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{type:`spring`,stiffness:400,damping:35},children:(0,Y.jsx)(Ht,{operation:e})},`${e.operationId}-${e.completedAt}`))})]},e.label))}),s?(0,Y.jsxs)(`div`,{role:`alert`,className:`flex shrink-0 flex-col items-center gap-2 border-t border-border/50 pt-3 pb-1 text-center`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Could not load older entries: `,s.message]}),c?(0,Y.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:`Retry`}):null]}):a&&l?(0,Y.jsx)(`div`,{className:`flex shrink-0 justify-center border-t border-border/50 pt-3 pb-1`,children:(0,Y.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,className:`min-w-[7rem]`,disabled:o,"aria-busy":o,"aria-label":o?`Loading older operations`:`Load older operations`,onClick:l,children:o?`Loading…`:`Load more`})}):null]})]})}function Xt({target:e,templates:t,templatesLoading:n,templatesError:r,isStreaming:i,onRetryTemplates:a,onSelect:o}){let s=t.length===0&&!n&&!r,[c,l]=(0,J.useState)(null);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`absolute right-3 top-3 z-20`,children:(0,Y.jsxs)(Ze,{children:[(0,Y.jsx)(Xe,{render:(0,Y.jsx)(O,{type:`button`,variant:`ghost`,size:`icon-sm`,disabled:i,className:`border border-border/45 bg-background/70 text-muted-foreground shadow-[inset_0_1px_0_0_var(--miravo-inset-highlight)] hover:border-primary/30 hover:bg-muted/55 hover:text-foreground`,"aria-label":`Open quick actions for ${e.label}`}),children:(0,Y.jsx)(rt,{className:`size-3.5`,"aria-hidden":!0})}),(0,Y.jsx)(qe,{align:`end`,sideOffset:6,className:`min-w-56`,children:(0,Y.jsxs)(Ye,{children:[(0,Y.jsx)(Ge,{className:`text-[10px] uppercase tracking-[0.14em]`,children:`Quick actions`}),(0,Y.jsx)(Je,{className:`bg-border/60`}),(0,Y.jsxs)(Ke,{disabled:s,className:`h-9 gap-2 text-xs`,onClick:()=>l(`apply`),children:[(0,Y.jsx)(Le,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:`Apply environment...`})]}),(0,Y.jsxs)(Ke,{disabled:s,className:`h-9 gap-2 text-xs`,onClick:()=>l(`cleanup`),children:[(0,Y.jsx)(B,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:`Cleanup environment...`})]}),(0,Y.jsx)(Je,{className:`bg-border/60`}),(0,Y.jsxs)(Ke,{variant:`destructive`,className:`h-9 gap-2 text-xs`,onClick:()=>o({type:`cleanup`,target:e,allManaged:!0}),children:[(0,Y.jsx)(B,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:`Cleanup all managed`})]})]})})]})}),c?(0,Y.jsx)(Dt,{open:!0,type:c,targetLabel:e.label,targetHostname:e.hostname,templates:t,templatesLoading:n,templatesError:r,onRetryTemplates:a,onOpenChange:e=>{e||l(null)},onSelect:t=>{o({type:c,target:e,templateId:t.id}),l(null)}},c):null]})}function Zt({selection:e,templates:t,stream:n,onSelectionChange:r}){let[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),u=(0,J.useRef)(0),d=(0,J.useRef)(null),f=(0,J.useRef)(!1),p=n.status===`running`,m=(0,J.useCallback)(()=>{u.current+=1,f.current=!1,d.current?.abort(),d.current=null,l(!1),s(null)},[]);(0,J.useEffect)(()=>{e&&(m(),a(!0))},[e,m]),(0,J.useEffect)(()=>()=>{u.current+=1,f.current=!1,d.current?.abort(),d.current=null},[]);let h=e?.templateId==null?void 0:t.find(t=>t.id===e.templateId)?.name??e.templateId,g=e?.type===`cleanup`&&e.allManaged?`All managed resources`:h??``,_=(0,J.useCallback)(async()=>{if(!e||e.type===`apply`&&!e.templateId||e.type===`cleanup`&&!e.allManaged&&!e.templateId)return;n.operation&&n.status!==`running`&&n.reset(),f.current=!0,d.current?.abort(),u.current+=1;let t=u.current,r=new AbortController;d.current=r,l(!0),s(null);try{let n=e.type===`apply`?await me({targetId:e.target.id,template:e.templateId},{signal:r.signal}):await se({targetId:e.target.id,...e.allManaged?{allManaged:!0}:{template:e.templateId}},{signal:r.signal});if(t!==u.current)return;s(n.plan)}catch(n){if(t!==u.current||_t(n))return;S.error(q(n,e.type===`apply`?`Plan failed`:`Cleanup plan failed`))}finally{t===u.current&&(l(!1),f.current=!1)}},[e,n]),v=(0,J.useCallback)(t=>{if(e){if(a(!1),m(),r(null),e.type===`apply`){n.startApply({targetId:e.target.id,template:e.templateId,scope:t.scope,ifUnmanaged:t.ifUnmanaged,...t.deviceName?{deviceName:t.deviceName}:{}});return}n.startCleanup({targetId:e.target.id,...e.allManaged?{allManaged:!0}:{template:e.templateId},scope:t.scope})}},[e,n,m,r]),y=e=>{a(e),!(e||f.current)&&(m(),r(null))},b=()=>{m(),r(null)};return(0,Y.jsxs)(Y.Fragment,{children:[e&&(0,Y.jsx)(ve,{open:i,onOpenChange:y,type:e.type,label:g,targetLabel:e.target.label,hostname:e.target.hostname,sourceHostname:e.target.sourceHostname,onConfirm:v,applyPreview:e.type===`apply`?{onPreview:()=>void _(),planLoading:c,disabled:!e.templateId||p}:void 0,cleanupPreview:e.type===`cleanup`?{onPreview:()=>void _(),planLoading:c,disabled:!e.allManaged&&!e.templateId||p}:void 0}),(c||o)&&!p&&e?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(te,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[`Preview for `,e.target.label,`: `,g]})]}),(0,Y.jsxs)(O,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:b,children:[(0,Y.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}),`Close preview`]})]}),c?(0,Y.jsx)(Tt,{}):o?(0,Y.jsx)(Ct,{plan:o,planKind:e.type,onCloseTable:b}):null]}):null]})}function Qt(e){return De.find(t=>t.id===e)?.label??e}function $t(e){if(!e)return`var(--tooltip-border)`;switch(e.status){case`success`:return`var(--success)`;case`partial`:case`blocked`:return`var(--warning)`;case`noop`:return`var(--muted-foreground)`;case`failed`:return`var(--destructive)`}}function en({status:e}){switch(e){case`success`:return(0,Y.jsx)(Oe,{className:`size-3 text-success`});case`partial`:case`blocked`:return(0,Y.jsx)(Be,{className:`size-3 text-warning`});case`noop`:return(0,Y.jsx)(nt,{className:`size-3 text-muted-foreground`});case`failed`:return(0,Y.jsx)(Ne,{className:`size-3 text-destructive`})}}function tn({target:e,lastOp:t,onEdit:n,onDelete:r,quickActions:i}){return(0,Y.jsxs)(`div`,{className:`env-orbital relative overflow-hidden border`,style:{"--_status":$t(t)},children:[i,(0,Y.jsx)(`div`,{className:`relative z-10 px-4 pt-3.5 pb-3 pr-12`,children:(0,Y.jsx)(`p`,{className:`font-heading text-[13px] font-semibold leading-tight tracking-tight text-foreground`,children:e.label})}),(0,Y.jsx)(`div`,{className:`relative z-10 px-4 py-0.5`,children:(0,Y.jsx)(`p`,{className:`font-mono text-xs tracking-tight text-muted-foreground`,children:e.hostname})}),(0,Y.jsxs)(`div`,{className:`relative z-10 mx-4 mb-3 flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-muted-foreground`,children:e.sourceHostname}),(0,Y.jsx)(`div`,{className:`env-orbital-path min-w-6 flex-1`}),(0,Y.jsx)(L,{className:`size-3 shrink-0 text-muted-foreground`})]}),(0,Y.jsxs)(`div`,{className:`relative z-10 flex items-center gap-2 border-t border-border/30 px-3 py-1.5`,children:[(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border/40 px-2 py-0.5`,children:[(0,Y.jsx)(`span`,{className:`protocol-card-live-dot size-[5px]`}),(0,Y.jsx)(`span`,{className:`text-[11px] font-medium tracking-wide text-muted-foreground`,children:Qt(e.platformId)})]}),t&&(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 truncate text-[11px] text-muted-foreground`,children:[(0,Y.jsx)(en,{status:t.status}),t.operationType===`apply`?`Applied`:`Cleaned`,` `,(0,Y.jsx)(`time`,{dateTime:new Date(t.completedAt).toISOString(),title:A(t.completedAt),children:k(t.completedAt)})]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Y.jsx)(O,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit target`,onClick:n,children:(0,Y.jsx)(it,{className:`size-3`})}),(0,Y.jsx)(O,{variant:`ghost`,size:`icon-sm`,className:`text-destructive hover:text-destructive`,"aria-label":`Delete target`,onClick:r,children:(0,Y.jsx)(B,{className:`size-3`})})]})]})]})}function nn({onClick:e}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:`env-orbital group h-full w-full flex flex-col items-center justify-center gap-2 border border-dashed py-10 text-muted-foreground transition-colors hover:border-primary/30 hover:text-primary`,style:{"--_status":`var(--tooltip-border)`},children:[(0,Y.jsx)(ge,{className:`size-5 transition-transform group-hover:scale-110`}),(0,Y.jsx)(`span`,{className:`text-xs`,children:`Add Target`})]})}function rn({targets:e,onMutate:t,lastOpByTarget:n,templates:r,templatesLoading:i,templatesError:a,onRetryTemplates:o,stream:s}){let[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(G.id),[m,_]=(0,J.useState)({label:``,hostname:``,apiToken:``,sourceHostname:``}),[v,y]=(0,J.useState)(!1),[E,D]=(0,J.useState)(!1),{testing:k,runTest:A,cancelInFlight:j}=de(),[M,N]=(0,J.useState)(null),[P,F]=(0,J.useState)(null),I=s.status===`running`,L=f===G.id&&m.hostname.trim().length>0&&m.sourceHostname.trim().length>0&&(u!==null||m.apiToken.trim().length>0),R=()=>{d(null),p(G.id),_({label:``,hostname:``,apiToken:``,sourceHostname:``}),D(!1),l(!0)},z=e=>{d(e.id),p(De.some(t=>t.id===e.platformId)?e.platformId:G.id),_({label:e.label,hostname:e.hostname,apiToken:``,sourceHostname:e.sourceHostname}),D(!1),l(!0)},B=async()=>{if(f!==G.id){S.error(`${Qt(f)} target setup is coming soon.`);return}if(!m.label||!m.hostname||!m.sourceHostname){S.error(`Label, hostname, and source host are required.`);return}if(!u&&!m.apiToken){S.error(`API token is required for new targets.`);return}y(!0);try{u?(await re(u,{platformId:f,label:m.label,hostname:m.hostname,sourceHostname:m.sourceHostname,...m.apiToken?{apiToken:m.apiToken}:{}}),S.success(`Target updated.`)):(await V({...m,platformId:f}),S.success(`Target added.`)),l(!1),t()}catch(e){S.error(q(e,`Failed to save target.`))}finally{y(!1)}};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`h2`,{className:`flex h-5 items-center text-xs font-medium leading-none uppercase tracking-wider text-muted-foreground`,children:`Platform Targets`}),e.length>0?(0,Y.jsx)(We,{variant:`secondary`,className:`relative -top-px h-5 shrink-0 px-1.5 py-0 font-mono text-[10px] leading-none tabular-nums`,children:e.length}):null]}),(0,Y.jsxs)(O,{size:`sm`,className:`h-7 shrink-0 gap-1.5 text-xs`,onClick:R,children:[(0,Y.jsx)(ge,{className:`size-3.5`}),` Add Target`]})]}),e.length===0?(0,Y.jsx)(lt,{titleId:`platforms-targets-empty-title`,frameIcon:(0,Y.jsx)(Ie,{className:`size-6 text-muted-foreground/45`,"aria-hidden":!0}),description:(0,Y.jsx)(st,{}),children:(0,Y.jsx)(ct,{onClick:R})}):(0,Y.jsx)(`div`,{className:`grid grid-cols-1 gap-3 @2xl/main:grid-cols-2 @5xl/main:grid-cols-3`,children:(0,Y.jsxs)(g,{children:[e.map((e,t)=>(0,Y.jsx)(h.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,scale:.96,transition:{duration:.15}},transition:{type:`spring`,stiffness:380,damping:30,delay:t*.04},children:(0,Y.jsx)(tn,{target:e,lastOp:n.get(e.id),onEdit:()=>z(e),onDelete:()=>N(e),quickActions:(0,Y.jsx)(Xt,{target:e,templates:r,templatesLoading:i,templatesError:a,isStreaming:I,onRetryTemplates:o,onSelect:F})})},e.id)),(0,Y.jsx)(h.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{type:`spring`,stiffness:380,damping:30,delay:e.length*.04},children:(0,Y.jsx)(nn,{onClick:R})},`add-card`)]})}),(0,Y.jsx)(Zt,{selection:P,templates:r,stream:s,onSelectionChange:F}),(0,Y.jsx)(ue,{open:c,editing:u!==null,platformId:f,form:m,showToken:E,saving:v,testing:k,canTestConnection:L,onOpenChange:l,onPlatformChange:p,onFormChange:_,onShowTokenChange:D,onSave:()=>void B(),onTestConnection:()=>{L&&A({...u?{targetId:u}:{},hostname:m.hostname.trim(),sourceHostname:m.sourceHostname.trim(),...m.apiToken.trim()?{apiToken:m.apiToken.trim()}:{}})},onCancelInFlight:j}),(0,Y.jsx)(C,{open:M!==null,onOpenChange:e=>!e&&N(null),children:(0,Y.jsxs)(ee,{children:[(0,Y.jsxs)(w,{children:[(0,Y.jsx)(T,{children:`Remove Target`}),(0,Y.jsxs)(x,{children:[`Remove “`,M?.label,`”? This only deletes the saved credentials — it does not affect resources on the target platform.`]})]}),(0,Y.jsxs)(b,{children:[(0,Y.jsx)(O,{variant:`outline`,onClick:()=>N(null),children:`Cancel`}),(0,Y.jsx)(O,{variant:`destructive`,onClick:async()=>{if(!M)return;let e=M.id;N(null);try{await U(e),S.success(`Target removed.`),t()}catch(e){S.error(q(e,`Failed to remove target.`))}},children:`Remove`})]})]})})]})}var an=25;function on({status:e}){switch(e){case`success`:return(0,Y.jsx)(Oe,{className:`size-3 text-success`});case`partial`:case`blocked`:return(0,Y.jsx)(Be,{className:`size-3 text-warning`});case`noop`:return(0,Y.jsx)(nt,{className:`size-3 text-muted-foreground`});case`failed`:return(0,Y.jsx)(Ne,{className:`size-3 text-destructive`})}}function sn({targetCount:e,opCount:t,lastOp:n}){return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Ie,{className:`size-3`}),(0,Y.jsx)(`span`,{className:`font-mono`,children:e}),` target`,e===1?``:`s`]}),(0,Y.jsx)(`span`,{className:`hidden h-3 w-px bg-border/40 sm:inline-block`}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(g,{mode:`popLayout`,initial:!1,children:(0,Y.jsx)(h.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`font-mono tabular-nums`,children:t},t)}),` `,`operation`,t===1?``:`s`]}),n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`hidden h-3 w-px bg-border/40 sm:inline-block`}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(on,{status:n.status}),(0,Y.jsxs)(`span`,{children:[n.operationType===`apply`?`Applied`:`Cleaned`,` `,(0,Y.jsx)(`time`,{dateTime:new Date(n.completedAt).toISOString(),title:A(n.completedAt),children:k(n.completedAt)})]})]})]})]})}function cn(){let e=f({queryKey:o.platforms.targets(),queryFn:()=>H()}),t=e.data??[],n=et({queryKey:o.platforms.operationsList(),queryFn:({pageParam:e})=>fe({limit:an,offset:e}),initialPageParam:0,getNextPageParam:(e,t,n)=>e.hasMore&&e.operations.length>0?n+an:void 0}),r=(0,J.useMemo)(()=>n.data?.pages.flatMap(e=>e.operations)??[],[n.data]),a=n.data?.pages[0]?.total??0,c=f({queryKey:o.catalog.templates(),queryFn:()=>s(`/catalog/templates`,i.catalogTemplates)}),u=c.data??[],d=pe(),p=(0,J.useRef)(d.status);(0,J.useEffect)(()=>{let e=p.current;p.current=d.status,e===`running`&&d.status===`complete`&&l.invalidateQueries({queryKey:o.platforms.operationsList()})},[d.status]);let y=(0,J.useMemo)(()=>{let e=new Map;for(let t of r)e.has(t.targetId)||e.set(t.targetId,t);return e},[r]),[b,x]=_(`tab`,v([`targets`,`operations`,`activity`]).withDefault(`targets`)),S;return S=e.isPending&&e.data===void 0?(0,Y.jsxs)(`div`,{role:`status`,"aria-busy":`true`,className:ot,children:[(0,Y.jsx)(`span`,{className:`sr-only`,children:`Loading targets`}),(0,Y.jsxs)(`div`,{className:`mx-auto flex max-w-md flex-col items-center gap-4 px-4 py-10`,children:[(0,Y.jsx)(K,{className:`h-5 w-48`}),(0,Y.jsx)(K,{className:`h-4 w-full max-w-sm`}),(0,Y.jsx)(K,{className:`h-9 w-40 rounded-(--miravo-radius-stadium-sm)`})]})]}):e.isError&&e.data===void 0?(0,Y.jsx)(m,{message:q(e.error,`Could not load targets.`),onRetry:()=>void e.refetch(),isRetrying:e.isFetching&&!e.isPending}):t.length===0?(0,Y.jsx)(lt,{titleId:`platforms-operations-empty-title`,frameIcon:(0,Y.jsx)(Ie,{className:`size-6 text-muted-foreground/45`,"aria-hidden":!0}),description:(0,Y.jsx)(st,{}),children:(0,Y.jsx)(ct,{onClick:()=>void x(`targets`)})}):(0,Y.jsx)(Ot,{targets:t,stream:d}),(0,Y.jsxs)(`div`,{className:`mx-auto flex h-full w-full min-w-0 max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[(0,Y.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Platforms`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connect Platforms as targets, then apply templates or run cleanup from Operations.`}),(0,Y.jsx)(sn,{targetCount:t.length,opCount:a,lastOp:r[0]})]}),(0,Y.jsxs)(Pe,{value:b,onValueChange:e=>{x(e)},className:`flex-1 min-h-0`,children:[(0,Y.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,Y.jsxs)(Me,{variant:`line`,className:`h-10! gap-0.5 min-w-max`,children:[(0,Y.jsxs)(ke,{value:`targets`,className:`gap-1.5 px-3 text-sm`,children:[(0,Y.jsx)(Ie,{className:`size-3.5 shrink-0`}),`Targets`]}),(0,Y.jsxs)(ke,{value:`operations`,className:`gap-1.5 px-3 text-sm`,children:[(0,Y.jsx)(ye,{className:`size-3.5 shrink-0`}),`Operations`]}),(0,Y.jsxs)(ke,{value:`activity`,className:`gap-1.5 px-3 text-sm`,children:[(0,Y.jsx)(I,{className:`size-3.5 shrink-0`}),`Activity`]})]})}),(0,Y.jsx)(Ae,{value:`targets`,className:`flex-1 py-2`,children:(0,Y.jsx)(h.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:e.isError&&e.data===void 0?(0,Y.jsx)(m,{message:q(e.error,`Failed to load targets.`),onRetry:()=>void e.refetch(),isRetrying:e.isFetching&&!e.isPending}):(0,Y.jsx)(rn,{targets:t,onMutate:()=>void e.refetch(),lastOpByTarget:y,templates:u,templatesLoading:c.isPending&&c.data===void 0,templatesError:c.isError&&u.length===0,onRetryTemplates:()=>void c.refetch(),stream:d})},`targets`)}),(0,Y.jsx)(Ae,{value:`operations`,className:`flex-1 py-2`,children:(0,Y.jsx)(h.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:S},`operations`)}),(0,Y.jsx)(Ae,{value:`activity`,className:`flex flex-col flex-1 min-h-0 py-2`,children:(0,Y.jsx)(h.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`flex flex-col flex-1 min-h-0`,children:(0,Y.jsx)(Yt,{operations:r,totalKnown:a,isLoading:n.isPending&&!n.data,error:n.error,onRefresh:()=>void l.invalidateQueries({queryKey:o.platforms.operationsList()}),hasNextPage:n.hasNextPage,isFetchingNextPage:n.isFetchingNextPage,loadMoreError:n.isFetchNextPageError&&n.error instanceof Error?n.error:null,onRetryLoadMore:()=>void n.fetchNextPage(),onLoadMore:()=>void n.fetchNextPage()})},`activity`)})]}),(0,Y.jsx)(g,{children:d.operation||d.status===`running`?(0,Y.jsx)(ut,{stream:d,onReset:d.reset,catalogTemplates:u}):null})]})}export{cn as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./platforms-Czbg-aTO.js";export{e as PlatformsPage};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{at as n}from"./vendor-ui-BcvPjvmT.js";import{$ as r,Q as i,X as a,Z as o,at as s,ct as c,dt as l,et as u,it as d,lt as f,nt as p,ot as m,rt as h,st as g,ut as _}from"./api-DUOCKS6t.js";import{S as v}from"./format-B243kebG.js";import{n as y,t as b}from"./utils-CH98NBUe.js";var x=class extends l{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=i(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),C(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return w(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return w(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof d(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!m(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&T(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||d(this.options.enabled,this.#t)!==d(t.enabled,this.#t)||s(this.options.staleTime,this.#t)!==s(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||d(this.options.enabled,this.#t)!==d(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return D(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(p)),t}#g(){this.#b();let e=s(this.options.staleTime,this.#t);if(r.isServer()||this.#r.isStale||!u(e))return;let t=c(this.#r.dataUpdatedAt,e)+1;this.#d=f.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(r.isServer()||d(this.options.enabled,this.#t)===!1||!u(this.#p)||this.#p===0)&&(this.#f=f.setInterval(()=>{(this.options.refetchIntervalInBackground||_.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(f.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(f.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,o=this.#r,s=this.#i,c=this.#a,l=e===n?this.#n:e.state,{state:u}=e,f={...u},p=!1,m;if(t._optimisticResults){let i=this.hasListeners(),o=!i&&C(e,t),s=i&&T(e,n,t,r);(o||s)&&(f={...f,...a(u.data,e.options)}),t._optimisticResults===`isRestoring`&&(f.fetchStatus=`idle`)}let{error:g,errorUpdatedAt:_,status:v}=f;m=f.data;let y=!1;if(t.placeholderData!==void 0&&m===void 0&&v===`pending`){let e;o?.isPlaceholderData&&t.placeholderData===c?.placeholderData?(e=o.data,y=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(v=`success`,m=h(o?.data,e,t),p=!0)}if(t.select&&m!==void 0&&!y)if(o&&m===s?.data&&t.select===this.#c)m=this.#l;else try{this.#c=t.select,m=t.select(m),m=h(o?.data,m,t),this.#l=m,this.#s=null}catch(e){this.#s=e}this.#s&&(g=this.#s,m=this.#l,_=Date.now(),v=`error`);let b=f.fetchStatus===`fetching`,x=v===`pending`,S=v===`error`,w=x&&b,D=m!==void 0,O={status:v,fetchStatus:f.fetchStatus,isPending:x,isSuccess:v===`success`,isError:S,isInitialLoading:w,isLoading:w,data:m,dataUpdatedAt:f.dataUpdatedAt,error:g,errorUpdatedAt:_,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:f.dataUpdateCount>l.dataUpdateCount||f.errorUpdateCount>l.errorUpdateCount,isFetching:b,isRefetching:b&&!x,isLoadingError:S&&!D,isPaused:f.fetchStatus===`paused`,isPlaceholderData:p,isRefetchError:S&&D,isStale:E(e,t),refetch:this.refetch,promise:this.#o,isEnabled:d(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=O.data!==void 0,r=O.status===`error`&&!t,a=e=>{r?e.reject(O.error):t&&e.resolve(O.data)},o=()=>{a(this.#o=O.promise=i())},s=this.#o;switch(s.status){case`pending`:e.queryHash===n.queryHash&&a(s);break;case`fulfilled`:(r||O.data!==s.value)&&o();break;case`rejected`:(!r||O.error!==s.reason)&&o();break}}return O}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!m(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){o.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function S(e,t){return d(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function C(e,t){return S(e,t)||e.state.data!==void 0&&w(e,t,t.refetchOnMount)}function w(e,t,n){if(d(t.enabled,e)!==!1&&s(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&E(e,t)}return!1}function T(e,t,n,r){return(e!==t||d(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&E(e,n)}function E(e,t){return d(t.enabled,e)!==!1&&e.isStaleByTime(s(t.staleTime,e))}function D(e,t){return!m(e.getCurrentResult(),t)}var O=e(t(),1),k=n(),A=O.createContext(void 0),j=e=>{let t=O.useContext(A);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},M=({client:e,children:t})=>(O.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,k.jsx)(A.Provider,{value:e,children:t})),N=O.createContext(!1),P=()=>O.useContext(N);N.Provider;function F(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var I=O.createContext(F()),L=()=>O.useContext(I),R=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?g(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},z=e=>{O.useEffect(()=>{e.clearReset()},[e])},B=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||g(n,[e.error,r])),V=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},H=(e,t)=>e.isLoading&&e.isFetching&&!t,U=(e,t)=>e?.suspense&&t.isPending,W=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function G(e,t,n){let i=P(),a=L(),s=j(n),c=s.defaultQueryOptions(e);s.getDefaultOptions().queries?._experimental_beforeQuery?.(c);let l=s.getQueryCache().get(c.queryHash);c._optimisticResults=i?`isRestoring`:`optimistic`,V(c),R(c,a,l),z(a);let u=!s.getQueryCache().get(c.queryHash),[d]=O.useState(()=>new t(s,c)),f=d.getOptimisticResult(c),m=!i&&e.subscribed!==!1;if(O.useSyncExternalStore(O.useCallback(e=>{let t=m?d.subscribe(o.batchCalls(e)):p;return d.updateResult(),t},[d,m]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),O.useEffect(()=>{d.setOptions(c)},[c,d]),U(c,f))throw W(c,d,a);if(B({result:f,errorResetBoundary:a,throwOnError:c.throwOnError,query:l,suspense:c.suspense}))throw f.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(c,f),c.experimental_prefetchInRender&&!r.isServer()&&H(f,i)&&(u?W(c,d,a):l?.promise)?.catch(p).finally(()=>{d.updateResult()}),c.notifyOnChangeProps?f:d.trackResult(f)}function K(e,t){return G(e,x,t)}var q=y(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);function J({role:e=`status`,"aria-live":t=`polite`,"aria-atomic":n=!0,className:r,eyebrow:i,stamp:a,title:o,children:s,detailLabel:c=`Technical detail`,detail:l,primaryLabel:u,onPrimary:d,primaryIcon:f,primaryDisabled:p,primaryBusy:m,secondaryLabel:h,onSecondary:g}){return(0,k.jsx)(`div`,{role:e,"aria-live":t,"aria-atomic":n,className:b(`relative overflow-hidden rounded-[var(--miravo-radius-stadium-lg)] border border-primary/20 bg-transparent`,r),children:(0,k.jsx)(`div`,{className:`p-5 sm:p-6`,children:(0,k.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,k.jsxs)(`div`,{className:`space-y-3`,children:[(0,k.jsx)(`p`,{className:`font-mono text-[0.65rem] uppercase tracking-[0.38em] text-muted-foreground`,children:i}),(0,k.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,k.jsx)(`span`,{className:`font-heading text-3xl font-black leading-none tracking-[-0.06em] text-transparent [-webkit-text-stroke:1px_color-mix(in_srgb,var(--primary)_50%,transparent)] sm:text-4xl`,"aria-hidden":!0,children:a}),(0,k.jsx)(`div`,{className:`mb-1.5 h-px min-w-8 flex-1 bg-linear-to-r from-primary/55 to-transparent`})]}),(0,k.jsx)(`h2`,{className:`text-lg font-semibold tracking-[-0.03em] text-foreground sm:text-xl`,children:o}),s?(0,k.jsx)(`div`,{className:`space-y-2 text-sm leading-relaxed text-muted-foreground`,children:s}):null]}),(0,k.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-stadium-sm)] border border-border/80 bg-background/55 p-4 backdrop-blur-sm`,children:[(0,k.jsx)(`div`,{className:`mb-2 font-mono text-[0.65rem] uppercase tracking-[0.28em] text-muted-foreground`,children:c}),(0,k.jsx)(`p`,{className:`wrap-break-word font-mono text-sm leading-relaxed text-primary`,children:l})]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[(0,k.jsxs)(v,{type:`button`,onClick:d,disabled:!!(p||m),"aria-busy":m,className:b(`inline-flex w-full items-center justify-center gap-2 rounded-[var(--miravo-radius-stadium-sm)] border border-foreground/15 bg-foreground px-4 py-2.5 font-medium text-background shadow-none transition hover:bg-foreground/90 sm:w-auto`,m&&`pointer-events-none opacity-90`),children:[f,u]}),h&&g?(0,k.jsx)(v,{type:`button`,variant:`ghost`,size:`sm`,className:`sm:self-center`,onClick:g,children:h}):null]})]})})})}function Y({message:e,onRetry:t,isRetrying:n}){return(0,k.jsxs)(J,{role:`alert`,eyebrow:`Data link fault`,stamp:`ERR`,title:`Couldn't reach Miravo`,detail:e,primaryLabel:`Retry request`,onPrimary:t,primaryBusy:!!n,primaryIcon:(0,k.jsx)(q,{className:b(`size-4 shrink-0`,n&&`animate-spin`),"aria-hidden":!0}),children:[(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-foreground`,children:`Most often:`}),` the Miravo admin server isn't running, or this browser can't reach it (wrong host, port, or firewall).`]}),(0,k.jsx)(`p`,{children:`Start or restart Miravo if needed, use the correct link to the Miravo Console, then try again.`})]})}export{G as a,x as c,K as i,J as n,M as o,q as r,j as s,Y as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fleet-B1apknqo.js","assets/fleet-CdoQJU1v.js","assets/rolldown-runtime-COnpUsM8.js","assets/chunk-OE4NN4TA-m2UhO8Q2.js","assets/vendor-charts-CAZdaPlq.js","assets/api-DUOCKS6t.js","assets/vendor-ui-BcvPjvmT.js","assets/format-B243kebG.js","assets/utils-CH98NBUe.js","assets/arrow-right-DzTjpAuX.js","assets/arrow-up-down-Dpy1cI5X.js","assets/select-TsdpHrOx.js","assets/circle-question-mark-BwjC8Yj-.js","assets/dist-jROhexoH.js","assets/engine-store-BXfht5ME.js","assets/shallow-ODRQsuRf.js","assets/badge-Dl0qmCnt.js","assets/combobox-BqGaRFom.js","assets/skeleton-BK5ydi_g.js","assets/select-display-items-C6R8SaIm.js","assets/tooltip-5y0snV5M.js","assets/transition-types-BNgNegH3.js","assets/catalog-CJE-3rom.js","assets/catalog-D7hkpcg7.js","assets/query-fetch-error-B2TVF0yM.js","assets/AnimatePresence-DOKfbxUr.js","assets/proxy-Dd7NWn5E.js","assets/use-platform-stream-EUBU4hC1.js","assets/platform-targets-DkU1GIU_.js","assets/tabs-CrmZxWmX.js","assets/copy-button-BYq-qqmM.js","assets/checkbox-_saaQAja.js","assets/triangle-alert-B7bgkvtE.js","assets/label-CM_MIru8.js","assets/catalog-template-icons-MOd-xD7l.js","assets/catalog-source-m5FRUDDK.js","assets/download-BP5RD-RZ.js","assets/get-error-message-CCNo4ZY0.js","assets/use-engine-command-mutation-BHd8IkoT.js","assets/runtime-link-ocutSVA8.js","assets/models-S3NJFuma.js","assets/models-CZEVv1PS.js","assets/activity-CHJbwIn_.js","assets/events-PFkU6dri.js","assets/events-uH2B0ni-.js","assets/auth-screen-backdrop-UsGua6Zt.js","assets/use-transition-navigate-BQAQi11k.js","assets/control-CVg7wZ1b.js","assets/control-C3s_d_cd.js","assets/validation-CEcQWBjy.js","assets/layers-Cg3yeSqL.js","assets/transition-nav-link-rkgf5kGR.js","assets/tags-zlkQYLKu.js","assets/tags-Burz8TZx.js","assets/vendor-table-CymGcez5.js","assets/dropdown-menu-6JrsGi7P.js","assets/platforms-DbF8XkYf.js","assets/platforms-Czbg-aTO.js","assets/instance-detail-BH62ZPtN.js","assets/login-DG5yhrqi.js"])))=>i.map(i=>d[i]);
2
- import{d as e}from"./chunk-OE4NN4TA-m2UhO8Q2.js";var t=[{test:e=>e===`/`,load:()=>e(()=>import(`./fleet-B1apknqo.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]))},{test:e=>e===`/catalog`,load:()=>e(()=>import(`./catalog-CJE-3rom.js`),__vite__mapDeps([22,23,2,5,6,4,24,7,8,25,26,27,11,28,29,12,30,20,31,32,16,33,34,35,36,37,38,14,39]))},{test:e=>e===`/models`,load:()=>e(()=>import(`./models-S3NJFuma.js`),__vite__mapDeps([40,41,2,5,6,4,24,7,8,25,26,42,27,11,28,29,12,30,20,31,32,16,33,35,36,37,38,14,39]))},{test:e=>e===`/events`,load:()=>e(()=>import(`./events-PFkU6dri.js`),__vite__mapDeps([43,44,2,3,4,5,6,24,7,8,25,26,11,14,45,16,17,19,46,37,39,21]))},{test:e=>e===`/control`,load:()=>e(()=>import(`./control-CVg7wZ1b.js`),__vite__mapDeps([47,48,2,5,6,4,7,8,25,26,42,9,11,29,30,20,49,31,50,38,14,39,32,13,15,51,3,46,16,17,33]))},{test:e=>e===`/tags`,load:()=>e(()=>import(`./tags-zlkQYLKu.js`),__vite__mapDeps([52,53,2,3,4,5,6,24,7,8,54,10,11,28,30,20,36,13,14,45,17,55,33,18,37]))},{test:e=>e===`/platforms`,load:()=>e(()=>import(`./platforms-DbF8XkYf.js`),__vite__mapDeps([56,57,2,3,4,5,6,24,7,8,25,26,42,9,27,11,28,29,12,30,20,31,32,16,33,34,50,13,55,18,37]))},{test:e=>e.startsWith(`/instance/`),load:()=>e(()=>import(`./instance-detail-BH62ZPtN.js`),__vite__mapDeps([58,2,3,4,5,6,24,7,8,26,42,29,30,20,49,38,14,39,32,13,45,16,37,21]))},{test:e=>e===`/login`,load:()=>e(()=>import(`./login-DG5yhrqi.js`),__vite__mapDeps([59,2,5,6,4,51,3,46,37]))}],n=new Set;function r(e){if(!e.startsWith(`/`))return null;let t=e.indexOf(`?`),n=e.indexOf(`#`),r=t===-1?n===-1?e.length:n:n===-1?t:Math.min(t,n);return e.slice(0,r)}function i(e){let i=r(e);if(!i||n.has(i))return;let a=t.find(e=>e.test(i));a&&(n.add(i),a.load().catch(()=>{n.delete(i)}))}export{i as t};
@@ -1 +0,0 @@
1
- import{at as e}from"./vendor-ui-BcvPjvmT.js";import{t}from"./utils-CH98NBUe.js";var n=e();function r({className:e,...r}){return(0,n.jsx)(`div`,{"data-slot":`skeleton`,className:t(`animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted`,e),...r})}export{r as t};
@@ -1,4 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{at as n}from"./vendor-ui-BcvPjvmT.js";import{S as r,b as i,o as a,tt as o}from"./api-DUOCKS6t.js";import{i as s,t as c}from"./query-fetch-error-B2TVF0yM.js";import{i as l,n as u,t as d}from"./dist-jROhexoH.js";import{n as f}from"./chunk-OE4NN4TA-m2UhO8Q2.js";import{a as p,i as m,n as h,o as g,r as _,s as v,t as y}from"./copy-button-BYq-qqmM.js";import{S as b,c as x,u as S,v as ee,w as C,x as w,y as te}from"./format-B243kebG.js";import{n as T,t as ne}from"./utils-CH98NBUe.js";import{t as E}from"./arrow-up-down-Dpy1cI5X.js";import{c as D,i as O,l as re,n as k,s as A,t as j}from"./select-TsdpHrOx.js";import{a as ie,n as M,r as N}from"./platform-targets-DkU1GIU_.js";import{t as ae}from"./download-BP5RD-RZ.js";import{t as oe}from"./skeleton-BK5ydi_g.js";import{i as P,n as F,t as I}from"./tooltip-5y0snV5M.js";import{r as se}from"./engine-store-BXfht5ME.js";import{n as ce}from"./auth-screen-backdrop-UsGua6Zt.js";import{a as le,i as ue,n as de,o as fe,r as pe,s as me,t as he}from"./dropdown-menu-6JrsGi7P.js";import{t as L}from"./label-CM_MIru8.js";import{t as ge}from"./get-error-message-CCNo4ZY0.js";import{a as R,i as z,n as B,o as _e,r as V,s as ve,t as H}from"./combobox-BqGaRFom.js";import{a as ye,i as be,n as xe,o as Se,r as Ce,t as we}from"./vendor-table-CymGcez5.js";var Te=T(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Ee=T(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),De=T(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Oe=T(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),ke=T(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),Ae=T(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),je=T(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),U=e(t(),1),Me={mqtt:`MQTT Client`,opcua:`OPC UA Client Advanced`,modbus:`Modbus TCP`},W={Boolean:`bool`,Int32:`int32`,UInt16:`uint16`,UInt32:`uint32`,Float:`float32`,Double:`float64`,String:`string`},G={float32:`float32`,int32:`int32`,uint32:`uint32`,uint16:`word`,boolean:`word`},Ne=`deviceId,deviceName,driverName,name,tagName,description,valueType,registerId,publishCoV,tagFormula,metaData,Retain,Qos,address,count,pollingInterval,endianness`;function Pe(e,t,n){let r=[Ne];for(let i of n){let n=Me[i]??i;for(let a of e){let e=a.protocols[i];e&&r.push(K(i,{deviceName:t,driverName:n,memberName:a.member,browsePath:a.browsePath,dataType:a.dataType,protocolData:e,unit:a.unit,euRange:a.euRange,model:a.model,instance:a.instance,access:a.access}))}}return`${r.join(`
2
- `)}\n`}function K(e,t){switch(e){case`mqtt`:return q(t);case`opcua`:return Fe(t);case`modbus`:return Ie(t);default:throw Error(`Unsupported LE export protocol: "${e}"`)}}function q(e){let t=typeof e.protocolData?.topic==`string`?e.protocolData.topic:`${e.browsePath}/${e.memberName}`;return[``,J(e.deviceName),J(e.driverName),J(t),J(e.memberName),``,`string`,``,`false`,``,Y(e),`Disable`,`0`,``,``,``,``].join(`,`)}function Fe(e){let t=typeof e.protocolData?.nodeId==`string`?e.protocolData.nodeId:`ns=1;s=${e.browsePath}/${e.memberName}`,n=W[e.dataType]??`string`;return[``,J(e.deviceName),J(e.driverName),J(t),J(e.memberName),``,n,``,`false`,``,Y(e),``,``,``,``,``,``].join(`,`)}function Ie(e){let t=G[String(e.protocolData?.registerType??``)]??`float32`,n=e.protocolData?.address;return[``,J(e.deviceName),J(e.driverName),`H`,J(e.memberName),``,t,``,`false`,``,Y(e),``,``,typeof n==`number`?String(n):`0`,`1`,`1.0000000000`,`AB CD`].join(`,`)}function J(e){return e.includes(`,`)||e.includes(`"`)||e.includes(`
3
- `)?`"${e.replace(/"/g,`""`)}"`:e}function Y(e){let t={uns_path:e.browsePath?`${e.browsePath}/${e.memberName}`:e.memberName,model:e.model,instance:e.instance,access:e.access};return e.unit!=null&&(t.unit=e.unit),e.euRange!=null&&(t.eu_range_min=String(e.euRange[0]),t.eu_range_max=String(e.euRange[1])),J(JSON.stringify(t))}var X=n(),Z={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus`},Le=[{id:N.id,label:N.label}];function Re({open:e,onOpenChange:t,tags:n,totalTags:r,enabledProtocols:i,selectedInstance:a}){let[o,s]=(0,U.useState)(`litmus-edge`),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(``),f=(0,U.useRef)(null),y=(0,U.useRef)(!1);(0,U.useEffect)(()=>{e&&!y.current&&(s(N.id),l(a??``),d(i[0]??``),setTimeout(()=>f.current?.focus(),80)),y.current=e},[e,i,a]);let x=c.trim()!==``&&u!==``,S=o===N.id?x:!1,ee=(0,U.useCallback)(()=>{if(o===N.id){let e=Pe(n,c.trim(),[u]),r=new Blob([e],{type:`text/csv`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${c.trim()}-litmus-edge-tags.csv`,a.click(),URL.revokeObjectURL(i),t(!1)}},[o,c,n,u,t]),C=n.length<r,te=(0,U.useMemo)(()=>[...Le.map(e=>({value:e.id,label:e.label})),...M.map(e=>({value:e.id,label:e.label}))],[]),T=(0,U.useMemo)(()=>i.map(e=>({value:e,label:Z[e]??e.toUpperCase()})),[i]);return(0,X.jsx)(h,{open:e,onOpenChange:t,children:(0,X.jsxs)(_,{className:`sm:max-w-lg`,children:[(0,X.jsxs)(g,{children:[(0,X.jsx)(v,{children:`Export for Platform`}),(0,X.jsx)(m,{children:C?`Exporting ${n.length} of ${r} tags based on current table filters.`:`Exporting all ${n.length} tags. Use table filters to narrow scope.`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 py-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(L,{className:`text-sm`,children:`Platform`}),(0,X.jsxs)(j,{value:o,onValueChange:e=>e&&s(e),items:te,children:[(0,X.jsx)(A,{className:`w-full text-sm`,children:(0,X.jsx)(D,{placeholder:`Select platform`})}),(0,X.jsxs)(k,{children:[Le.map(e=>(0,X.jsx)(O,{value:e.id,children:e.label},e.id)),M.map(e=>(0,X.jsx)(O,{value:e.id,disabled:!0,children:e.label},e.id))]})]})]}),o===N.id&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(L,{htmlFor:`device-name`,className:`text-sm`,children:[`Device name `,(0,X.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,X.jsx)(w,{id:`device-name`,ref:f,placeholder:`e.g. DTW-FAB-PLC`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&S&&ee(),className:`font-mono text-sm`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(L,{className:`text-sm`,children:`Protocol`}),(0,X.jsxs)(j,{value:u||void 0,onValueChange:e=>e&&d(e),items:T,children:[(0,X.jsx)(A,{className:`w-full text-sm`,children:(0,X.jsx)(D,{placeholder:`Select a protocol`})}),(0,X.jsx)(k,{children:i.map(e=>(0,X.jsx)(O,{value:e,children:Z[e]??e.toUpperCase()},e))})]})]})]})]}),(0,X.jsxs)(p,{children:[(0,X.jsx)(b,{variant:`outline`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsxs)(b,{size:`sm`,className:`gap-1.5`,disabled:!S,onClick:ee,children:[(0,X.jsx)(ae,{className:`size-3.5`}),`Download CSV`]})]})]})})}var ze=`border-border/70 bg-popover/98 font-body text-sm shadow-xl ring-1 ring-foreground/12 backdrop-blur-sm supports-backdrop-filter:bg-popover/90 p-1.5`,Be=`px-2 pb-1 font-heading text-[9px] font-semibold tracking-[0.14em] text-muted-foreground uppercase`,Ve=`h-8 gap-1.5 border-border/80 bg-background/80 text-xs font-medium shadow-sm transition-colors hover:border-primary/35 hover:bg-accent/40`,He=`gap-2.5 rounded-[var(--miravo-radius-tight)] py-2 pl-2 pr-2 text-[13px] data-[highlighted]:bg-sidebar-accent data-[highlighted]:text-sidebar-accent-foreground`;function Ue({protocol:e,instance:t,model:n,member:r,enabledProtocols:i,hasFilters:a,memberSearchRef:o,onProtocolChange:s,onInstanceChange:c,onModelChange:l,onMemberChange:u,onClearFilters:d,onInstanceSearch:f,onModelSearch:p,filteredInstanceOptions:m,filteredModelOptions:h}){let g=(0,U.useMemo)(()=>[{value:`all`,label:`All protocols`},...i.map(e=>({value:e,label:e.toUpperCase()}))],[i]);return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(j,{value:e||`all`,onValueChange:e=>s(!e||e===`all`?``:e),items:g,children:[(0,X.jsx)(A,{className:`h-8 w-[140px]`,"aria-label":`Protocol filter`,children:(0,X.jsx)(D,{placeholder:`All protocols`})}),(0,X.jsxs)(k,{alignItemWithTrigger:!1,align:`start`,children:[(0,X.jsx)(O,{value:`all`,children:`All protocols`}),i.map(e=>(0,X.jsx)(O,{value:e,children:e.toUpperCase()},e))]})]}),(0,X.jsxs)(H,{value:t?{value:t,label:x(t)}:null,onValueChange:e=>c(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:f,children:[(0,X.jsx)(V,{placeholder:`All instances`,className:`h-8 w-[200px]`,showClear:!!t}),(0,X.jsx)(B,{children:(0,X.jsxs)(R,{children:[m.map(([e,t])=>(0,X.jsxs)(z,{value:{value:e,label:x(e)},children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:x(e)}),(0,X.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),m.length===0&&(0,X.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]}),(0,X.jsxs)(H,{value:n?{value:n,label:S(n)}:null,onValueChange:e=>l(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:p,children:[(0,X.jsx)(V,{placeholder:`All models`,className:`h-8 w-[200px]`,showClear:!!n}),(0,X.jsx)(B,{children:(0,X.jsxs)(R,{children:[h.map(([e,t])=>(0,X.jsxs)(z,{value:{value:e,label:S(e)},children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:S(e)}),(0,X.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),h.length===0&&(0,X.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(w,{ref:o,placeholder:`Search member…`,className:`h-8 w-[160px] pr-7`,value:r,onChange:e=>u(e.target.value)}),!r&&(0,X.jsx)(`kbd`,{className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 rounded-[var(--miravo-radius-tight)] border border-border bg-muted px-1 font-mono text-[10px] text-muted-foreground`,children:`/`})]}),a&&(0,X.jsxs)(b,{variant:`ghost`,size:`sm`,className:`h-8 gap-1 text-xs`,onClick:d,children:[(0,X.jsx)(C,{className:`size-3`}),`Clear`]})]})}function Q({sorted:e}){return e===`asc`?(0,X.jsx)(Ee,{className:`ml-1 inline size-3`}):e===`desc`?(0,X.jsx)(Te,{className:`ml-1 inline size-3`}):(0,X.jsx)(E,{className:`ml-1 inline size-3 opacity-30`})}function We(e,t=1,n=2){let r=e.split(`/`);return r.length<=t+n+1?e:[...r.slice(0,t),`...`,...r.slice(-n)].join(`/`)}function Ge({label:e,value:t,collapsible:n}){let r=n?We(t):t;return(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:e}),(0,X.jsx)(y,{value:t,label:`Copy ${e}`,tooltipSide:`top`,render:({icon:e})=>(0,X.jsxs)(`button`,{type:`button`,className:`mt-0.5 flex items-start gap-1 font-mono text-xs hover:text-foreground`,children:[n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`break-all lg:hidden`,children:r}),(0,X.jsx)(`span`,{className:`hidden break-all lg:inline`,children:t})]}):(0,X.jsx)(`span`,{className:`break-all`,children:t}),(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0 text-muted-foreground`,children:e})]})})]})}function Ke({tag:e,enabledProtocols:t}){let n=`${e.browsePath}/${e.member}`,r=e.protocols.opcua,i=e.protocols.modbus,a=e.access===`readwrite`?`rw`:e.access;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 text-xs`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-10 gap-y-2.5`,children:[(0,X.jsx)(Ge,{label:`Topic / UNS`,value:n,collapsible:!0}),t.includes(`opcua`)&&typeof r?.nodeId==`string`&&(0,X.jsx)(Ge,{label:`OPC UA NodeId`,value:r.nodeId,collapsible:!0}),t.includes(`modbus`)&&i?.address!=null&&(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:`Modbus`}),(0,X.jsxs)(`p`,{className:`mt-0.5 font-mono`,children:[`addr=`,String(i.address),` regs=`,String(i.count),` `,String(i.registerType)]})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-muted-foreground`,children:[(0,X.jsxs)(I,{children:[(0,X.jsx)(P,{className:`font-mono`,render:(0,X.jsx)(`span`,{}),children:e.dataType}),(0,X.jsx)(F,{side:`top`,children:`Data type`})]}),e.unit&&(0,X.jsxs)(I,{children:[(0,X.jsx)(P,{className:`font-mono`,render:(0,X.jsx)(`span`,{}),children:e.unit}),(0,X.jsx)(F,{side:`top`,children:`Unit`})]}),(0,X.jsxs)(I,{children:[(0,X.jsx)(P,{className:`font-mono`,render:(0,X.jsx)(`span`,{}),children:a}),(0,X.jsx)(F,{side:`top`,children:`Access: r / w / rw`})]}),e.euRange&&(0,X.jsxs)(I,{children:[(0,X.jsxs)(P,{className:`font-mono`,render:(0,X.jsx)(`span`,{}),children:[`[`,e.euRange[0],`, `,e.euRange[1],`]`]}),(0,X.jsx)(F,{side:`top`,children:`EU range (min, max)`})]}),(0,X.jsxs)(I,{children:[(0,X.jsxs)(P,{render:(0,X.jsx)(f,{to:`/instance/${e.instance}`,className:`inline-flex items-center gap-1 text-primary underline-offset-4 hover:underline`,"aria-label":`Open instance`}),children:[`View instance`,(0,X.jsx)(Ae,{className:`size-3`})]}),(0,X.jsx)(F,{side:`top`,children:`Open instance`})]})]})]})}var qe=[{id:`expand`,meta:{cellClass:`!pl-2 !pr-0 w-0`},header:()=>(0,X.jsx)(`span`,{className:`sr-only`,children:`Expand row`}),enableSorting:!1,cell:({row:e})=>(0,X.jsx)(`button`,{type:`button`,className:`inline-flex size-5 items-center justify-center rounded-[var(--miravo-radius-tight)] text-muted-foreground hover:text-foreground`,"aria-label":e.getIsExpanded()?`Collapse row`:`Expand row`,"aria-expanded":e.getIsExpanded(),onClick:t=>{t.stopPropagation(),e.toggleExpanded()},children:(0,X.jsx)(re,{className:`size-3.5 transition-transform ${e.getIsExpanded()?`rotate-0`:`-rotate-90`}`})})},{accessorKey:`instance`,header:({column:e})=>(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center`,onClick:e.getToggleSortingHandler(),children:[`Instance`,(0,X.jsx)(Q,{sorted:e.getIsSorted()})]}),cell:({getValue:e})=>(0,X.jsx)(`span`,{className:`block max-w-[18rem] truncate font-mono text-xs`,title:e(),children:e()})},{accessorKey:`member`,header:({column:e})=>(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center`,onClick:e.getToggleSortingHandler(),children:[`Member`,(0,X.jsx)(Q,{sorted:e.getIsSorted()})]}),cell:({getValue:e})=>(0,X.jsx)(`span`,{className:`block max-w-[20rem] truncate font-mono text-xs`,title:e(),children:e()})},{accessorKey:`model`,header:({column:e})=>(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center`,onClick:e.getToggleSortingHandler(),children:[`Model`,(0,X.jsx)(Q,{sorted:e.getIsSorted()})]}),cell:({getValue:e})=>(0,X.jsx)(`span`,{className:`block max-w-[18rem] truncate text-xs`,title:e(),children:e()})},{accessorKey:`dataType`,meta:{hideClass:`hidden lg:table-cell`},header:({column:e})=>(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center`,onClick:e.getToggleSortingHandler(),children:[`Type`,(0,X.jsx)(Q,{sorted:e.getIsSorted()})]}),cell:({getValue:e})=>(0,X.jsx)(`span`,{className:`font-mono text-xs`,children:e()})},{accessorKey:`unit`,meta:{hideClass:`hidden lg:table-cell`},header:`Unit`,enableSorting:!1,cell:({getValue:e})=>(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e()??`—`})},{accessorKey:`access`,meta:{hideClass:`hidden lg:table-cell`},header:`Access`,enableSorting:!1,cell:({getValue:e})=>{let t=e();return(0,X.jsx)(`span`,{className:`font-mono text-xs`,children:t===`readwrite`?`rw`:t})}}];function Je(e,t){let n=new Blob([e],{type:`text/csv`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}var Ye=[`loading-1`,`loading-2`,`loading-3`,`loading-4`,`loading-5`,`loading-6`,`loading-7`,`loading-8`],Xe=[10,15,25,50,100],Ze=15,Qe=100;function $e(e){return Xe.includes(e)?e:Ze}function et(e){return/[",\r\n]/.test(e)?`"${e.replaceAll(`"`,`""`)}"`:e}function $(){let[e,t]=(0,U.useState)(!1),n=(0,U.useRef)(null);(0,U.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),n.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[p,m]=l(`protocol`,u.withDefault(``)),[h,g]=l(`instance`,u.withDefault(``)),[_,v]=l(`model`,u.withDefault(``)),[y,x]=l(`member`,u.withDefault(``)),[S,C]=l(`perPage`,d.withDefault(Ze)),w=$e(S),T=se(e=>e.instanceCount),E=s({queryKey:i.tags.manifest(T),queryFn:()=>a(`/manifest`,r.manifest),placeholderData:o}),M=E.data??null,N=E.isError,P=E.isPending&&!M&&!N,F=ge(E.error,`Failed to fetch manifest.`),I=M?.tags??[],L=M?.summary?.enabledProtocols??[],R=(0,U.useDeferredValue)(y),z=(0,U.useMemo)(()=>I.filter(e=>e.kind===`variable`),[I]),B=(0,U.useMemo)(()=>{let e=new Map;for(let t of z)e.set(t.instance,(e.get(t.instance)??0)+1);return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[z]),V=(0,U.useMemo)(()=>{let e=new Map;for(let t of z)e.set(t.model,(e.get(t.model)??0)+1);return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[z]),H=(0,U.useMemo)(()=>{let e=R.trim().toLowerCase();if(!p&&!h&&!_&&!e)return z;let t=[];for(let n of z)p&&n.protocols[p]==null||h&&n.instance!==h||_&&n.model!==_||e&&!n.member.toLowerCase().includes(e)||t.push(n);return t},[z,p,h,_,R]),[Te,Ee]=(0,U.useState)([]),[Ae,Me]=(0,U.useState)({}),[W,G]=(0,U.useState)(0),Ne=p!==``||h!==``||_!==``||y!==``,Pe=(0,U.useCallback)(()=>{m(``),g(``),v(``),x(``),G(0)},[m,g,v,x]),K=xe({data:H,columns:qe,getCoreRowModel:Ce(),getSortedRowModel:Se(),getExpandedRowModel:be(),getRowCanExpand:()=>!0,getPaginationRowModel:ye(),onSortingChange:Ee,onExpandedChange:Me,onPaginationChange:e=>{let t=typeof e==`function`?e({pageIndex:W,pageSize:w}):e;G(t.pageIndex),C(t.pageSize)},state:{sorting:Te,expanded:Ae,pagination:{pageIndex:W,pageSize:w}}}),q=Math.ceil(H.length/w);(0,U.useEffect)(()=>{S!==w&&C(w)},[w,S,C]),(0,U.useEffect)(()=>{q>0&&W>=q&&G(q-1)},[q,W]);let Fe=(0,U.useCallback)(e=>{G(0),C(e)},[C]),Ie=(0,U.useCallback)(e=>{G(0),m(e)},[m]),J=(0,U.useCallback)(e=>{G(0),g(e)},[g]),Y=(0,U.useCallback)(e=>{G(0),v(e)},[v]),Z=(0,U.useCallback)(e=>{G(0),x(e)},[x]),[Le,Q]=(0,U.useState)(``),[We,Ge]=(0,U.useState)(``),$=(0,U.useDeferredValue)(Le),tt=(0,U.useDeferredValue)(We),nt=(0,U.useMemo)(()=>($?B.filter(([e])=>ee(e,$)):B).slice(0,Qe),[B,$]),rt=(0,U.useMemo)(()=>(tt?V.filter(([e])=>te(e,tt)):V).slice(0,Qe),[V,tt]),it=K.getRowModel().rows,at=it.length,ot=at===0||H.length===0?0:W*w+1,st=at===0||H.length===0?0:W*w+at,ct=q,lt=H.length===0||ct===0?0:W+1,ut=(0,U.useCallback)(()=>{let e=p?[p]:L,t=[`instance`,`member`,`model`,`dataType`,`unit`,`access`,`browsePath`,...e.includes(`mqtt`)?[`mqtt_topic`]:[],...e.includes(`opcua`)?[`opcua_nodeId`]:[],...e.includes(`modbus`)?[`modbus_address`,`modbus_count`,`modbus_encoding`]:[]],n=H.map(t=>{let n=t.protocols.mqtt,r=t.protocols.opcua,i=t.protocols.modbus;return[t.instance,t.member,t.model,t.dataType,t.unit??``,t.access,t.browsePath,...e.includes(`mqtt`)?[String(n?.topic??``)]:[],...e.includes(`opcua`)?[String(r?.nodeId??``)]:[],...e.includes(`modbus`)?[String(i?.address??``),String(i?.count??``),String(i?.registerType??``)]:[]]});Je([t.map(et).join(`,`),...n.map(e=>e.map(et).join(`,`))].join(`
4
- `),`miravo-tags.csv`)},[H,p,L]);return N&&!M?(0,X.jsx)(ce,{className:`min-h-full`,children:(0,X.jsx)(`div`,{className:`flex min-h-[40vh] flex-col items-center justify-center p-6 sm:p-12`,children:(0,X.jsx)(`div`,{className:`w-full max-w-md`,children:(0,X.jsx)(c,{message:F,onRetry:()=>void E.refetch(),isRetrying:E.isFetching})})})}):(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:[N&&M?(0,X.jsx)(c,{message:`${F} Showing cached tags.`,onRetry:()=>void E.refetch(),isRetrying:E.isFetching}):null,(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Tag Explorer`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:P?`Loading tag manifest...`:`${M?.summary?.totalInstances??0} instances · ${L.length} protocols`})]}),(0,X.jsxs)(he,{children:[(0,X.jsxs)(me,{render:(0,X.jsx)(b,{variant:`outline`,size:`sm`,className:ne(Ve,`px-3`)}),children:[(0,X.jsx)(ae,{className:`size-3.5 opacity-90`,"aria-hidden":!0}),`Export`,(0,X.jsx)(re,{className:`size-3 opacity-60`,"aria-hidden":!0})]}),(0,X.jsx)(de,{align:`end`,sideOffset:6,className:ne(`min-w-[13.5rem]`,ze),children:(0,X.jsxs)(pe,{children:[(0,X.jsx)(le,{className:Be,children:`Export`}),(0,X.jsx)(fe,{className:`bg-border/60`}),(0,X.jsxs)(ue,{onClick:ut,className:He,children:[(0,X.jsx)(je,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),`Download CSV`]}),(0,X.jsxs)(ue,{onClick:()=>t(!0),className:He,children:[(0,X.jsx)(De,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),`Export for Platform…`]})]})})]})]}),(0,X.jsx)(Ue,{protocol:p,instance:h,model:_,member:y,enabledProtocols:L,hasFilters:Ne,memberSearchRef:n,onProtocolChange:Ie,onInstanceChange:J,onModelChange:Y,onMemberChange:Z,onClearFilters:Pe,onInstanceSearch:Q,onModelSearch:Ge,filteredInstanceOptions:nt,filteredModelOptions:rt}),H.length!==z.length&&z.length>0&&(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Showing`,` `,(0,X.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:H.length}),` of`,` `,(0,X.jsx)(`span`,{className:`tabular-nums`,children:z.length}),` tags`]}),(0,X.jsx)(_e,{className:`min-w-0 py-0`,children:(0,X.jsx)(ve,{className:`p-0`,children:(0,X.jsx)(`div`,{className:`min-w-0 overflow-auto`,children:(0,X.jsxs)(`table`,{className:`w-full caption-bottom text-sm`,children:[(0,X.jsx)(`thead`,{className:`sticky top-0 z-10 border-b bg-background [&_tr]:border-b`,children:K.getHeaderGroups().map(e=>(0,X.jsx)(`tr`,{className:`border-b transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,children:e.headers.map(e=>{let t=e.column.columnDef.meta;return(0,X.jsx)(`th`,{className:`h-10 whitespace-nowrap px-1.5 text-left text-xs font-medium text-muted-foreground sm:px-4 ${t?.hideClass??``} ${t?.cellClass??``}`,children:e.isPlaceholder?null:we(e.column.columnDef.header,e.getContext())},e.id)})},e.id))}),(0,X.jsx)(`tbody`,{className:`[&_tr:last-child]:border-0`,children:P?Ye.map(e=>(0,X.jsx)(`tr`,{"aria-hidden":!0,children:(0,X.jsx)(`td`,{colSpan:qe.length,className:`px-4 py-2`,children:(0,X.jsx)(oe,{className:`h-8 bg-muted/30`})})},e)):it.length>0?it.map(e=>{let t=e.getIsExpanded(),n=e.getVisibleCells();return(0,X.jsxs)(U.Fragment,{children:[(0,X.jsx)(`tr`,{"aria-expanded":t,tabIndex:0,className:`cursor-pointer border-b transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent focus-visible:outline-none`,onClick:()=>e.toggleExpanded(),onKeyDown:t=>{t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),e.toggleExpanded())},children:n.map(e=>{let t=e.column.columnDef.meta;return(0,X.jsx)(`td`,{className:`whitespace-nowrap px-1.5 py-1.5 text-left sm:px-4 ${t?.hideClass??``} ${t?.cellClass??``}`,children:we(e.column.columnDef.cell,e.getContext())},e.id)})}),t&&(0,X.jsx)(`tr`,{children:(0,X.jsx)(`td`,{colSpan:n.length,className:`p-0`,children:(0,X.jsx)(`div`,{className:`border-b`,children:(0,X.jsx)(`div`,{className:`px-1.5 py-3 pl-6 sm:px-4 sm:pl-10`,children:(0,X.jsx)(Ke,{tag:e.original,enabledProtocols:L})})})})})]},e.id)}):(0,X.jsx)(`tr`,{children:(0,X.jsx)(`td`,{colSpan:qe.length,className:`h-32 px-2 text-center sm:px-4`,children:z.length===0?(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,X.jsx)(ke,{className:`size-8 text-muted-foreground`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No tags available`}),(0,X.jsx)(f,{to:`/catalog`,className:`text-xs text-primary underline-offset-4 hover:underline`,children:`Start an environment from the Catalog to generate tags`})]}):(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No matching tags.`,` `,(0,X.jsx)(`span`,{className:`text-xs`,children:`Try adjusting your filters.`})]})})})})]})})})}),(0,X.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 sm:justify-start sm:gap-5`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 leading-tight`,children:[(0,X.jsx)(`span`,{className:`font-medium tabular-nums text-foreground`,children:ot===0?`0`:`${ot}\u2013${st}`}),` `,(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`of `,H.length,` tags`]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 whitespace-nowrap`,children:[(0,X.jsxs)(j,{value:String(w),onValueChange:e=>e&&Fe(Number(e)),children:[(0,X.jsx)(A,{className:`h-8 w-[4.25rem]`,"aria-label":`Rows per page`,children:(0,X.jsx)(D,{})}),(0,X.jsx)(k,{children:Xe.map(e=>(0,X.jsx)(O,{value:String(e),children:e},e))})]}),(0,X.jsx)(`span`,{className:`hidden text-muted-foreground sm:inline`,children:`per page`})]})]}),(0,X.jsxs)(`nav`,{className:`flex items-center justify-center gap-2 border-border/60 border-t pt-2 sm:justify-end sm:border-0 sm:pt-0`,"aria-label":`Table pages`,children:[(0,X.jsx)(b,{variant:`outline`,size:`sm`,className:`h-8 w-8 shrink-0 p-0`,disabled:!K.getCanPreviousPage(),onClick:()=>K.previousPage(),"aria-label":`Previous page`,children:(0,X.jsx)(Oe,{className:`size-3.5`})}),(0,X.jsxs)(`span`,{className:`min-w-[5ch] text-center text-sm font-medium tabular-nums whitespace-nowrap text-foreground`,children:[lt,` / `,ct]}),(0,X.jsx)(b,{variant:`outline`,size:`sm`,className:`h-8 w-8 shrink-0 p-0`,disabled:!K.getCanNextPage(),onClick:()=>K.nextPage(),"aria-label":`Next page`,children:(0,X.jsx)(ie,{className:`size-3.5`})})]})]})}),(0,X.jsx)(Re,{open:e,onOpenChange:t,tags:H,totalTags:I.length,enabledProtocols:L,selectedInstance:h||void 0})]})}export{$ as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./tags-Burz8TZx.js";export{e as TagsPage};
@@ -1,2 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{at as n}from"./vendor-ui-BcvPjvmT.js";import{C as r,S as i,T as a,f as o,m as s,p as c,t as l,w as u}from"./api-DUOCKS6t.js";import{t as d,u as f}from"./proxy-Dd7NWn5E.js";import{t as p}from"./AnimatePresence-DOKfbxUr.js";import{a as m,i as h,l as g,n as _,o as v,r as ee,s as te,t as y}from"./copy-button-BYq-qqmM.js";import{S as b,T as x,w as S,x as C}from"./format-B243kebG.js";import{n as w,t as T}from"./utils-CH98NBUe.js";import{a as E,c as D,i as O,l as ne,n as k,o as A,r as j,s as M,t as N}from"./select-TsdpHrOx.js";import{i as P,n as F,r as I,t as re}from"./platform-targets-DkU1GIU_.js";import{a as L,c as R,o as z,s as ie}from"./tabs-CrmZxWmX.js";import{t as B}from"./circle-question-mark-BwjC8Yj-.js";import{i as ae,n as oe,r as se,t as ce}from"./checkbox-_saaQAja.js";import{t as le}from"./triangle-alert-B7bgkvtE.js";import{i as V,n as H,t as U}from"./tooltip-5y0snV5M.js";import{t as ue}from"./badge-Dl0qmCnt.js";import{t as W}from"./label-CM_MIru8.js";var de=w(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),fe=w(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),pe=w(`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`}]]),me=w(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),he=w(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),ge=w(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),_e=w(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),G=w(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),ve=w(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ye=w(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),K=w(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),q=e(t(),1),be=[`devices`,`models`,`instances`],xe=[`instances`,`models`,`devices`],Se={devices:`DeviceHub devices`,models:`Digital Twins models`,instances:`Digital Twins instances`},Ce={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 platform.`,cleanup:`Remove Digital Twins model definitions created by Miravo.`},instances:{apply:`Digital Twins instances bound to DeviceHub devices.`,cleanup:`Remove Digital Twins instances deployed for this target.`}},we=`Miravo calls this API.`;function Te(e){return e.length>120?`Use at most 120 characters.`:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)?null:`Use lowercase letters, numbers, and hyphens only (e.g. motor-001).`}var J=`Source host (Miravo)`,Y=`Address Litmus Edge uses to reach your running Miravo environment.`,X=n();function Ee({open:e,onOpenChange:t,type:n,label:r,targetLabel:i,hostname:a,sourceHostname:o,onConfirm:s,defaultDeviceName:c,applyPreview:l,cleanupPreview:u}){let f=n===`apply`?be:xe,[p,g]=(0,q.useState)(new Set(f)),[v,y]=(0,q.useState)(!1),[x,S]=(0,q.useState)(!1),[w,E]=(0,q.useState)(``),[D,O]=(0,q.useState)(null),[k,A]=(0,q.useState)(`fail`),j=(0,q.useId)(),M=(0,q.useId)(),N=`if-unmanaged-${M}`,P=n===`apply`,F=P&&c!==void 0&&c!==``;(0,q.useEffect)(()=>{e&&(g(new Set(f)),y(!1),O(null),E(F?c??``:``),A(`fail`),S(!1))},[e,f,F,c]);let I={instances:`models`},re=e=>{g(t=>{let n=new Set(t);if(n.has(e)){n.delete(e);for(let[t,r]of Object.entries(I))r===e&&n.delete(t)}else{n.add(e);let t=I[e];t&&n.add(t)}return n})},L=P?l:u,R=()=>{L?.onPreview(),t(!1)};return(0,X.jsx)(_,{open:e,onOpenChange:t,children:(0,X.jsxs)(ee,{showCloseButton:!0,className:`flex max-h-[90vh] min-h-0 flex-col gap-0 overflow-hidden p-0 sm:max-w-120`,children:[(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 px-5 pb-3 pt-5`,children:[(0,X.jsxs)(te,{className:`flex items-center gap-2 text-sm font-semibold leading-snug`,children:[P?(0,X.jsx)(se,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,X.jsx)(K,{className:`size-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),P?`Apply to Litmus Edge`:`Clean up Litmus Edge`]}),(0,X.jsx)(h,{className:`sr-only`,children:P?`Review connection details and scope before applying.`:`Review target and cleanup scope before confirming.`})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 pt-4 pb-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(`div`,{className:`text-xs leading-snug`,children:(0,X.jsxs)(`dl`,{className:`flex flex-col gap-0`,children:[(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:[(0,X.jsx)(`dt`,{className:`min-w-0 pt-px text-[11px] font-medium text-muted-foreground`,children:P?`Resource`:`Target`}),(0,X.jsx)(`dd`,{className:`min-w-0 wrap-break-word font-medium text-foreground`,children:r})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 items-start gap-x-4 border-b border-border/35 py-2.5`,children:[(0,X.jsx)(`dt`,{className:`min-w-0 pt-px text-[11px] font-medium text-muted-foreground`,children:`Target`}),(0,X.jsx)(`dd`,{className:`min-w-0 wrap-break-word font-medium text-foreground`,children:i})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 items-start gap-x-4 border-b border-border/35 py-2.5`,children:[(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:`Litmus Edge API`}),(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 Litmus Edge API`,children:(0,X.jsx)(B,{className:`size-3`,"aria-hidden":!0})}),(0,X.jsx)(H,{side:`top`,align:`start`,className:`max-w-xs text-left`,children:we})]})]})}),(0,X.jsx)(`dd`,{className:`min-w-0`,children:(0,X.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-normal text-foreground/90`,children:a})})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 items-start gap-x-4 border-b border-border/35 py-2.5`,children:[(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:J}),(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 ${J}`,children:(0,X.jsx)(B,{className:`size-3`,"aria-hidden":!0})}),(0,X.jsx)(H,{side:`top`,align:`start`,className:`max-w-xs text-left`,children:Y})]})]})}),(0,X.jsx)(`dd`,{className:`min-w-0`,children:(0,X.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-normal text-foreground/90`,children:o})})]})]})}),L?(0,X.jsxs)(W,{className:T(`flex cursor-pointer items-center gap-2.5 text-[11px] font-medium leading-snug`,L.disabled&&`pointer-events-none opacity-50`),children:[(0,X.jsx)(`span`,{className:`flex shrink-0 items-center`,children:(0,X.jsx)(ce,{checked:x,onCheckedChange:e=>S(e===!0),disabled:L.disabled})}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 leading-snug`,children:P?`Dry run only — preview the plan without deploying`:`Dry run only — preview the plan without removing resources`})]}):null,F?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(W,{htmlFor:j,className:`text-[11px] font-medium`,children:`Device name`}),(0,X.jsx)(C,{id:j,value:w,onChange:e=>{E(e.target.value),O(null)},placeholder:c,autoComplete:`off`,spellCheck:!1,className:T(`h-9 font-mono text-xs`,D&&`border-destructive`),"aria-invalid":D!=null,"aria-describedby":`${j}-hint`}),(0,X.jsx)(`p`,{id:`${j}-hint`,className:`text-[11px] leading-snug text-foreground/76`,children:`Same name on a later run updates this device; change it to add another.`}),D?(0,X.jsx)(`p`,{className:`text-[11px] text-destructive`,children:D}):null]}):null,(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,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:()=>y(e=>!e),"aria-expanded":v,children:[`Advanced`,(0,X.jsx)(ne,{className:T(`size-3.5 shrink-0 text-muted-foreground transition-transform ease-out group-hover:text-foreground/80`,v?`duration-500 rotate-180 text-foreground/80`:`duration-280`),"aria-hidden":!0})]}),(0,X.jsxs)(d.div,{initial:!1,animate:{maxHeight:v?520:0,opacity:+!!v},transition:{maxHeight:{duration:v?.52:.28,ease:v?[.16,1,.3,1]:[.4,0,.2,1]},opacity:{duration:v?.42:.24,ease:v?[.16,1,.3,1]:[.4,0,.2,1]}},className:T(`overflow-hidden`,!v&&`pointer-events-none`),"aria-hidden":!v,inert:!v,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-1 pt-px`,children:f.map(e=>{let t=Object.entries(I).find(([t,n])=>n===e)?.[0],n=t!==void 0&&p.has(t),r=P?Ce[e].apply:Ce[e].cleanup;return(0,X.jsxs)(W,{htmlFor:`scope-${e}`,className:T(`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`,n?`opacity-95`:`hover:bg-muted/25`),children:[(0,X.jsx)(`span`,{className:`pt-0.5`,children:(0,X.jsx)(ce,{id:`scope-${e}`,checked:p.has(e),disabled:n,onCheckedChange:()=>re(e)})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 leading-snug`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:Se[e]}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-[11px] font-normal leading-tight text-muted-foreground`,children:r})]}),n?(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)})}),P&&(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:`${M}-legend`,className:`text-[11px] font-medium uppercase tracking-wide text-foreground/80`,children:`Collision policy`}),(0,X.jsxs)(`div`,{role:`radiogroup`,"aria-labelledby":`${M}-legend`,className:`flex flex-col gap-1`,children:[(0,X.jsxs)(W,{htmlFor:`if-unmanaged-fail`,className:T(`flex cursor-pointer items-start gap-2 rounded-[var(--miravo-radius-tight)] border px-2.5 py-2 text-[11px] transition-colors`,k===`fail`?`border-primary/45 bg-primary/8`:`border-border/40 bg-muted/10 hover:bg-muted/25`),children:[(0,X.jsx)(`input`,{id:`if-unmanaged-fail`,type:`radio`,name:N,value:`fail`,checked:k===`fail`,onChange:()=>A(`fail`),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:`Fail if unmanaged exists`}),(0,X.jsx)(`span`,{className:`mt-px block text-[11px] leading-tight text-foreground/74`,children:`Stop if the target has unmanaged resources.`})]})]}),(0,X.jsxs)(W,{htmlFor:`if-unmanaged-skip`,className:T(`flex cursor-pointer items-start gap-2 rounded-[var(--miravo-radius-tight)] border px-2.5 py-2 text-[11px] transition-colors`,k===`skip`?`border-primary/45 bg-primary/8`:`border-border/40 bg-muted/10 hover:bg-muted/25`),children:[(0,X.jsx)(`input`,{id:`if-unmanaged-skip`,type:`radio`,name:N,value:`skip`,checked:k===`skip`,onChange:()=>A(`skip`),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:`Skip unmanaged resources`}),(0,X.jsx)(`span`,{className:`mt-px block text-[11px] leading-tight text-foreground/74`,children:`Only update resources managed by Miravo.`})]})]})]})]})]}),p.size===0&&!(x&&L)?(0,X.jsx)(`p`,{className:`text-[11px] text-destructive`,children:`Select at least one scope or reopen to reset.`}):null]})]})}),(0,X.jsxs)(m,{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)(b,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsx)(b,{type:`button`,variant:P||x&&u?`default`:`destructive`,onClick:()=>{if(x&&L){R();return}let e=f.filter(e=>p.has(e));if(e.length!==0){if(F){let t=w.trim(),n=t===``?c??``:t.toLowerCase(),r=Te(n);if(r){O(r);return}O(null),s({scope:e,deviceName:n,ifUnmanaged:k});return}s({scope:e,ifUnmanaged:k})}},disabled:x&&L?L.disabled||L.planLoading:p.size===0,children:P?x&&l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(G,{className:`size-3`,"aria-hidden":!0}),`Preview changes`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(se,{className:`size-3`,"aria-hidden":!0}),`Apply`]}):x&&u?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(G,{className:`size-3`,"aria-hidden":!0}),`Preview changes`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{className:`size-3`,"aria-hidden":!0}),`Clean up`]})})]})]})})}var De={initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,originY:0},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:350,damping:40}},Oe={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 ke({children:e,variant:t=`default`}){let n=t===`default`;return(0,X.jsx)(d.div,{...n?De:Oe,layout:n,className:`mx-auto w-full`,children:e})}var Ae=q.memo(({children:e,className:t,delay:n=1e3,...r})=>{let[i,a]=(0,q.useState)(0),o=(0,q.useMemo)(()=>q.Children.toArray(e),[e]);(0,q.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,q.useMemo)(()=>o.slice(0,i+1).reverse(),[i,o]);return(0,X.jsx)(`div`,{className:T(`flex flex-col items-center gap-4`,t),...r,children:(0,X.jsx)(p,{children:s.map(e=>(0,X.jsx)(ke,{children:e},e.key))})})});Ae.displayName=`AnimatedList`;function je({type:e,errorMessage:t,className:n}){let r=e===`apply`?t?.toLowerCase()??``:``,i=e===`cleanup`?`Try cleanup again to resume.`:r.includes(`unmanaged device`)||r.includes(`unmanaged instance`)?`Update the collision policy, try apply again to resume, or clean up the created resources.`:`Try apply again to resume, or clean up the created resources.`;return(0,X.jsxs)(`div`,{className:T(`flex items-start gap-1.5 rounded-[var(--miravo-radius-tight)] border border-info/40 bg-info/10 px-2.5 py-1.5 text-[10px] font-medium leading-relaxed`,n),children:[(0,X.jsx)(ae,{className:`mt-0.5 size-3 shrink-0 text-info`,"aria-hidden":!0}),(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-left whitespace-normal break-words text-foreground/80 [overflow-wrap:anywhere]`,children:i})]})}var Me=`text-destructive hover:bg-destructive/25 hover:text-foreground`,Ne={device:`Devices`,tags:`Tags`,model:`Models`,instance:`Instances`,"param-sync":`Parameters`};function Pe(e){return Ne[e]??e}function Fe(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`;default:return`border border-border/50 bg-muted/80 text-foreground/85`}}function Ie({status:e}){switch(e){case`success`:return(0,X.jsx)(R,{className:`size-3.5 shrink-0 text-success`});case`failed`:return(0,X.jsx)(ie,{className:`size-3.5 shrink-0 text-destructive`});case`pending`:return(0,X.jsx)(z,{className:`size-3.5 shrink-0 animate-spin text-primary/90`})}}function Le({status:e}){switch(e){case`done`:return(0,X.jsx)(R,{className:`size-3.5 text-success`});case`active`:return(0,X.jsx)(z,{className:`size-3.5 animate-spin text-primary`});case`pending`:return(0,X.jsx)(me,{className:`size-3.5 text-foreground/55`})}}function Re({entry:e}){let[t,n]=(0,q.useState)(!1);return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsxs)(`button`,{type:`button`,className:T(`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)(Ie,{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:T(`inline-flex rounded-[var(--miravo-radius-tight)] px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wider`,Fe(e.action)),children:e.action}),e.error&&(0,X.jsx)(ne,{className:T(`size-3 text-foreground/75 transition-transform`,t&&`rotate-180`)})]}),(0,X.jsx)(p,{initial:!1,children:t&&e.error&&(0,X.jsxs)(d.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)(y,{value:e.error,label:`Copy error`,className:T(Me,`shrink-0`)})]}),(0,X.jsx)(je,{type:`apply`,errorMessage:e.error,className:`mb-1 mt-2.5 w-full min-w-0`})]})})]})}function ze({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:T(`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)(Le,{status:e.status}),(0,X.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-foreground`,children:Pe(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)(R,{className:`size-3 text-success`}),a&&(0,X.jsx)(ne,{className:T(`size-3 text-foreground/75 transition-transform`,!t&&`-rotate-90`),"aria-hidden":!0})]})]}),(0,X.jsx)(p,{initial:!1,children:a&&t&&(0,X.jsx)(d.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)(f.Provider,{value:null,children:e.resources.map((e,t)=>(0,X.jsx)(ke,{variant:`subtle`,children:(0,X.jsx)(Re,{entry:e})},`${e.name}-${t}`))})})})})]})}function Be({operation:e}){let t=e.status===`complete`,n=e.status===`cancelled`,r=e.failed>0,i=e.totalPlanned>0?Math.min(100,He(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)(d.div,{"aria-hidden":`true`,className:T(`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 Ve(e){return e.duration==null?(Date.now()-e.startedAt)/1e3:e.duration/1e3}function He(e){let t=e.applied+e.failed;return e.totalPlanned>0?Math.min(t,e.totalPlanned):t}function Ue(e,t){let n=e.label;return t?.length?t.find(e=>e.id===n)?.name??n:n}var We={complete:{Icon:R,className:`size-4 text-success`},partial:{Icon:pe,className:`size-4 text-warning`},cancelled:{Icon:de,className:`size-4 text-foreground/65`},error:{Icon:ie,className:`size-4 text-destructive`},running:{Icon:z,className:`size-4 animate-spin text-warning`}};function Ge({icon:e,className:t}){return(0,X.jsx)(d.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:500,damping:30},className:`shrink-0`,children:(0,X.jsx)(e,{className:t})})}function Ke({operation:e,sourceLabel:t,isAllExpanded:n,onToggleAll:r}){let i=Ve(e),a=He(e),o=e.status===`complete`,s=e.status===`cancelled`,c=e.status===`error`,l=e.failed>0,u=o&&!l?`complete`:o&&l?`partial`:s?`cancelled`:c?`error`:`running`,f=We[u];return(0,X.jsxs)(`div`,{className:T(`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)(p,{mode:`wait`,initial:!1,children:(0,X.jsx)(Ge,{icon:f.Icon,className:f.className},u)}),(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.environment}`})]})]}),(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)(ue,{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)(p,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(d.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)(p,{initial:!1,children:e.failed>0&&(0,X.jsx)(d.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)(ue,{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)(he,{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)(fe,{className:T(`size-3.5 transition-transform duration-300`,!n&&`opacity-70 scale-y-[-1]`)})})})]})]}),(0,X.jsx)(Be,{operation:e})]})]})}function qe(e){return e?e.closest(`[data-edge-op-scroll]`)??e.closest(`.overflow-y-auto`):null}var Je=350;function Z(e){e?.scrollIntoView({block:`end`,behavior:`auto`,inline:`nearest`})}function Ye(e){let t=()=>Z(e);t(),requestAnimationFrame(t),requestAnimationFrame(()=>requestAnimationFrame(t)),window.setTimeout(t,0),window.setTimeout(t,48),window.setTimeout(t,120)}function Xe({operation:e,catalogTemplates:t}){let n=(0,q.useRef)(null),r=(0,q.useRef)(null),i=(0,q.useRef)(!0),a=(0,q.useRef)(e.status);a.current=e.status;let o=(0,q.useRef)(!1),[s,c]=(0,q.useState)(new Set),l=(0,q.useMemo)(()=>Ue(e,t),[e,t]);(0,q.useLayoutEffect)(()=>{let e=qe(n.current);if(!e)return;let t=()=>{i.current=e.scrollHeight-e.scrollTop-e.clientHeight<Je};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>{e.removeEventListener(`scroll`,t)}},[]),(0,q.useLayoutEffect)(()=>{if(e.status===`running`){i.current&&Z(r.current),o.current=!0;return}o.current&&=(Ye(r.current),!1)},[e.status,e.applied,e.failed,e.phases]),(0,q.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&&Z(r.current)})});return s.observe(t),i.current&&Z(r.current),()=>{s.disconnect(),cancelAnimationFrame(o)}},[e.status]);let u=e.phases.length>0,f=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)(Ke,{operation:e,sourceLabel:l,isAllExpanded:f,onToggleAll:u?()=>{c(f?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)(ze,{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)(p,{initial:!1,children:e.error&&e.retryPending&&(0,X.jsxs)(d.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)(z,{className:`size-4 shrink-0 animate-spin`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.error})]})}),(0,X.jsx)(p,{initial:!1,children:e.error&&e.status===`error`&&(0,X.jsxs)(d.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)(y,{value:e.error,label:`Copy error`,className:T(Me,`shrink-0`)})]}),(0,X.jsx)(je,{type:e.type,errorMessage:e.error,className:`mt-3 w-full min-w-0`})]})}),(0,X.jsx)(`div`,{ref:r,className:`h-px w-full shrink-0`,"aria-hidden":!0})]})}function Ze({format:e,kind:t}){return e===`source-yaml`?t===`model`?`Raw twin model definition. Edit locally, version-control, or use as input for the CLI.`:`Raw environment definition with topology and namespace. Edit, share, or apply via CLI.`:e===`litmus-edge`?t===`model`?`Litmus Edge Digital Twin JSON for manual import via the LE UI or GraphQL API.`:`Litmus Edge template JSON (DeviceHub devices + Digital Twins). Import directly via the Litmus Edge UI.`:`Select a format to download.`}function Qe({children:e,className:t}){return(0,X.jsx)(`div`,{className:T(`max-h-[min(36rem,75vh)] min-h-0 overflow-y-auto rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 p-4 sm:p-5`,t),children:e})}function $e({title:e,subtitle:t,footerAction:n,onDismiss:r,children:i}){return(0,q.useEffect)(()=>{function e(e){e.key===`Escape`&&r()}return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[r]),(0,X.jsx)(d.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)(Qe,{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)(L,{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]})]}),(0,X.jsx)(b,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`shrink-0 text-foreground/70 hover:bg-muted/80 hover:text-foreground`,onClick:r,"aria-label":`Dismiss operation panel`,children:(0,X.jsx)(S,{className:`size-3.5`,"aria-hidden":!0})})]}),(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:i}),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]})})}var et={...Object.fromEntries(P.map(e=>[e.id,e.exportLabel])),"source-yaml":`Source YAML`};function tt(e){return e==null||e===``?`Select platform`:typeof e==`string`?et[e]??e:`Select platform`}function nt(e){return P.find(t=>t.id===e)?.label??e}function Q({id:e,label:t,hint:n,className:r,labelAdornment:i,children:a}){return(0,X.jsxs)(`div`,{className:T(`flex flex-col gap-2`,r),children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,X.jsx)(W,{htmlFor:e,className:`text-[11px] font-medium text-foreground`,children:t}),i]}),n?(0,X.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:n}):null]}),a]})}function rt({open:e,editing:t,platformId:n,form:r,showToken:i,saving:a,testing:o,canTestConnection:s,onOpenChange:c,onPlatformChange:l,onFormChange:u,onShowTokenChange:d,onSave:f,onTestConnection:p,onCancelInFlight:g}){let y=n===I.id,x=t?`Edit Target`:`Add Target`,S=t?`Update the deployment connection.`:`Add the target used for platform deploys.`,w=t?`Leave empty to keep the current token.`:`Required for the first save and connection test.`;return(0,X.jsx)(_,{open:e,onOpenChange:e=>{e||g(),c(e)},children:(0,X.jsxs)(ee,{showCloseButton:!0,className:`flex max-h-[min(84vh,38rem)] min-h-0 flex-col gap-0 overflow-hidden p-0 sm:max-w-[38rem]`,children:[(0,X.jsxs)(v,{className:`shrink-0 border-b border-border/60 px-4 pb-3.5 pt-4 pr-12 sm:px-5 sm:pr-14`,children:[(0,X.jsx)(te,{className:`text-base tracking-tight`,children:x}),(0,X.jsx)(h,{className:`max-w-xl text-sm leading-relaxed`,children:S})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-4 sm:px-5`,style:{scrollbarGutter:`stable`},children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[t?(0,X.jsx)(Q,{label:`Platform`,children:(0,X.jsx)(`div`,{className:`flex h-9 items-center rounded-[var(--miravo-radius-stadium-sm)] border border-input bg-input/30 px-3 text-sm text-foreground`,children:nt(n)})}):(0,X.jsx)(Q,{label:`Platform`,children:(0,X.jsxs)(N,{value:n,onValueChange:e=>l(e),children:[(0,X.jsx)(M,{className:`h-9 w-full text-sm data-placeholder:text-muted-foreground/55`,"aria-label":`Platform type`,children:(0,X.jsx)(D,{placeholder:`Select platform`,children:e=>tt(e)})}),(0,X.jsxs)(k,{children:[(0,X.jsxs)(j,{children:[(0,X.jsx)(E,{children:`Available`}),re.map(e=>(0,X.jsx)(O,{value:e.id,children:e.label},e.id))]}),(0,X.jsx)(A,{}),(0,X.jsxs)(j,{children:[(0,X.jsx)(E,{children:`Coming soon`}),F.map(e=>(0,X.jsx)(O,{value:e.id,children:e.label},e.id))]})]})]})}),y?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{id:`env-label`,label:`Label`,children:(0,X.jsx)(C,{id:`env-label`,placeholder:`Production`,value:r.label,onChange:e=>u({...r,label:e.currentTarget.value}),autoComplete:`off`,className:`h-9 placeholder:text-muted-foreground/55`})}),(0,X.jsx)(Q,{id:`env-hostname`,label:`Hostname`,children:(0,X.jsx)(C,{id:`env-hostname`,placeholder:`192.168.1.100`,value:r.hostname,onChange:e=>u({...r,hostname:e.currentTarget.value}),autoCapitalize:`none`,autoComplete:`off`,spellCheck:!1,className:`h-9 font-mono text-[13px] placeholder:text-muted-foreground/55`})}),(0,X.jsx)(Q,{id:`env-source`,label:J,labelAdornment:(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 ${J}`,children:(0,X.jsx)(B,{className:`size-3`,"aria-hidden":!0})}),(0,X.jsx)(H,{side:`top`,align:`start`,className:`max-w-xs text-left`,children:Y})]}),children:(0,X.jsx)(C,{id:`env-source`,placeholder:`host.docker.internal`,value:r.sourceHostname,onChange:e=>u({...r,sourceHostname:e.currentTarget.value}),autoCapitalize:`none`,autoComplete:`off`,spellCheck:!1,className:`h-9 font-mono text-[13px] placeholder:text-muted-foreground/55`})}),(0,X.jsx)(Q,{id:`env-token`,label:`API token`,labelAdornment:(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 API token`,children:(0,X.jsx)(B,{className:`size-3`,"aria-hidden":!0})}),(0,X.jsx)(H,{side:`top`,align:`start`,className:`max-w-xs text-left`,children:w})]}),children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(C,{id:`env-token`,type:i?`text`:`password`,placeholder:t?`••••••••`:`Enter API token`,value:r.apiToken,onChange:e=>u({...r,apiToken:e.currentTarget.value}),autoCapitalize:`none`,autoComplete:`off`,spellCheck:!1,className:`h-9 pr-11 font-mono text-[13px] placeholder:text-muted-foreground/55`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(!i),"aria-label":i?`Hide token`:`Show token`,"aria-pressed":i,className:`absolute inset-y-0 right-0 flex w-11 items-center justify-center rounded-r-[var(--miravo-radius-stadium-sm)] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50`,children:i?(0,X.jsx)(ge,{className:`size-3.5`,"aria-hidden":!0}):(0,X.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0})})]})})]}):(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border/70 px-4 py-3 text-sm text-muted-foreground`,children:[nt(n),` setup is not available yet. Switch back to Litmus Edge to finish target setup now.`]})]})}),(0,X.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:o&&y?`Checking connection to Litmus Edge…`:``}),(0,X.jsxs)(m,{className:`mx-0 mb-0 shrink-0 flex-col gap-2 border-t border-border/60 bg-background px-4 py-3 sm:flex-row sm:justify-end sm:px-5`,children:[(0,X.jsx)(b,{type:`button`,variant:`outline`,size:`lg`,className:`w-full justify-center sm:mr-auto sm:w-auto`,disabled:a||o||!s,"aria-busy":o,onClick:p,children:o?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),`Testing connection`]}):`Test connection`}),(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-2 sm:w-auto sm:flex-row`,children:[(0,X.jsx)(b,{variant:`outline`,size:`lg`,className:`w-full sm:w-auto`,onClick:()=>{g(),c(!1)},disabled:a,children:`Cancel`}),(0,X.jsx)(b,{size:`lg`,className:`w-full sm:w-auto`,onClick:f,disabled:a||!y,children:a?`Saving...`:t?`Save Target`:`Add Target`})]})]})]})})}var it=`flex size-7 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-border/35 bg-muted/25 text-primary`;function at({targets:e,value:t,onValueChange:n,size:r=`default`,disabled:i,className:a,preferredTargetId:o,onAddNew:s}){return(0,q.useEffect)(()=>{if(t||e.length===0)return;let r=(o?e.find(e=>e.id===o):void 0)??e[0];r&&n(r.id)},[t,e,o,n]),e.length===0&&s?(0,X.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 self-start text-[11px] text-primary hover:underline`,onClick:s,children:[(0,X.jsx)(ve,{className:`inline size-3`}),` Add target`]}):(0,X.jsxs)(N,{value:t,onValueChange:e=>e&&n(e),disabled:i,children:[(0,X.jsx)(M,{size:r,className:T(`w-full`,r===`sm`&&`h-9! min-h-9 py-0`,r===`default`&&`h-auto! min-h-9 py-2 **:data-[slot=select-value]:line-clamp-none`,a),children:(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,X.jsx)(`span`,{className:it,"aria-hidden":!0,children:(0,X.jsx)(oe,{className:`size-3.5`})}),(0,X.jsx)(D,{placeholder:`Select target`,className:`min-w-0 flex-1`,children:t=>{let n=e.find(e=>e.id===t);return n?r===`sm`?n.label:(0,X.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium leading-tight`,children:n.label}),(0,X.jsx)(`span`,{className:`font-mono text-[11px] leading-none text-muted-foreground`,children:n.hostname})]}):`Select target`}})]})}),(0,X.jsx)(k,{className:`rounded-[var(--miravo-radius-stadium-sm)] p-1.5`,children:e.map(e=>(0,X.jsxs)(O,{value:e.id,className:`h-auto items-center gap-2 rounded-[var(--miravo-radius-stadium-sm)] py-2 pr-8 pl-2`,children:[(0,X.jsx)(`span`,{className:it,"aria-hidden":!0,children:(0,X.jsx)(oe,{className:`size-3.5`})}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-left`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs font-medium leading-tight text-foreground`,children:e.label}),(0,X.jsx)(`span`,{className:`truncate font-mono text-[11px] leading-none text-muted-foreground`,children:e.hostname})]})]},e.id))})]})}async function ot(){return(await c(`/platforms/le/targets`,i.platformTargets)).targets}function st(e){return c(`/platforms/le/targets`,i.platformTargetCreate,{body:e})}function ct(e,t){return c(`/platforms/le/targets/${e}`,i.platformTargetById,{body:t})}function lt(e){return c(`/platforms/le/targets/${e}`,i.platformTargetDelete)}function ut(e,t){return c(`/platforms/le/targets/test`,i.platformConnectionTest,{body:e,init:{signal:t?.signal}})}function dt(e,t){return c(`/platforms/le/plan`,i.platformPlan,{body:e,init:{signal:t?.signal}})}function ft(e,t){return c(`/platforms/le/cleanup/plan`,i.platformCleanupPlan,{body:e,init:{signal:t?.signal}})}function pt(e={}){let t=new URLSearchParams;e.type&&t.set(`type`,e.type),e.targetId&&t.set(`targetId`,e.targetId),typeof e.limit==`number`&&t.set(`limit`,String(e.limit)),typeof e.offset==`number`&&t.set(`offset`,String(e.offset));let n=t.toString();return c(n?`/platforms/le/operations?${n}`:`/platforms/le/operations`,i.platformOperations)}async function mt(e){try{return await c(`/platforms/le/operations/${e}/cancel`,i.platformOperationCancel),!0}catch(e){if(r.is(e)&&e.status===404)return!1;throw e}}function ht(e,t,n){return _t(`/platforms/le/apply/stream`,i.platformApplyStream,e,t,n)}function gt(e,t,n){return _t(`/platforms/le/cleanup/stream`,i.platformCleanupStream,e,t,n)}function _t(e,t,n,i,c){let d=new AbortController;return(async()=>{try{let c=t.body.safeParse(n);if(!c.success)throw Error(`Invalid request for ${t.method} ${t.path}: ${c.error.message}`);let f=await fetch(s(l,e),{method:t.method,headers:{"content-type":`application/json`},credentials:`include`,body:JSON.stringify(c.data),signal:d.signal});if(f.status===401&&t.auth===`required`)throw o(),Error(`Session expired`);if(!f.ok){let e=`HTTP ${f.status}`;try{let e=await f.json(),t=u.safeParse(e);if(t.success)throw new r({code:t.data.code,status:f.status,message:t.data.message,hint:t.data.hint})}catch(e){if(e instanceof r)throw e}throw Error(e)}if(!f.body)throw Error(`No response body`);let p=f.body.getReader(),m=new TextDecoder,h=``,g=``,_=``,v=!1;for(;;){let{done:e,value:t}=await p.read();if(e)break;h+=m.decode(t,{stream:!0});let n=h.split(`
2
- `);h=n.pop()??``;for(let e of n)if(e.startsWith(`event: `))g=e.slice(7).trim();else if(e.startsWith(`data: `))_=e.slice(6);else if(e===``&&g&&_){let e=!1;try{let t=JSON.parse(_),n=a.safeParse({event:g,data:t});n.success&&((n.data.event===`complete`||n.data.event===`cancelled`||n.data.event===`error`)&&(v=!0,e=!0),i(n.data))}catch{}if(g=``,_=``,e){await p.cancel();return}}}if(!v&&!d.signal.aborted)throw Error(`Connection to server was lost unexpectedly`)}catch(e){if(d.signal.aborted)return;c(e instanceof Error?e:Error(String(e)))}})(),d}function vt(e){return e.status===`running`?e.operation?e.operation.type===`apply`?`Apply`:`Cleanup`:`Connecting`:e.status===`error`?`Failed`:e.operation&&e.status===`complete`?e.operation.status===`cancelled`?`Cancelled`:`Complete`:null}function yt(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 bt(e){let t=e.trim();if(t.length===0)return{message:`Connection test failed with no details from the server.`};let n=t.toLowerCase();if(t.includes(`timed out`))return{message:`Litmus Edge did not respond in time.`,description:`Check the hostname, VPN or firewall, and that the device is online.`};if(/\b401\b/.test(t)||/\b403\b/.test(t)||n.includes(`unauthorized`))return{message:`The API token was rejected.`,description:`Create or copy a valid token in Litmus Edge and paste it into the API token field.`};if(/\b404\b/.test(t)&&(n.includes(`sysinfo`)||n.includes(`/sysinfo/`)))return{message:`This Litmus Edge host or version does not expose the system info API.`,description:`Confirm the hostname and that Litmus Edge is running a build with GET /sysinfo/version.`};if(n.includes(`econnrefused`)||n.includes(`connection refused`)||n.includes(`enotfound`)||n.includes(`getaddrinfo`)||n.includes(`failed`)&&n.includes(`fetch`))return{message:`Could not reach the Litmus Edge host.`,description:`Check the hostname or IP, TLS, and that this computer can reach the edge network.`};if(t.includes(`Session expired`))return{message:`Your session expired. Sign in again, then retry the connection test.`};if(n.includes(`environment not found`))return{message:`That target was removed. Close the dialog and refresh the list.`};if(n.includes(`unsupported platform`)&&n.includes(`connection`))return{message:`This platform type does not support connection tests yet.`,description:`Use Litmus Edge for remote apply and connection testing.`};if(n.includes(`invalid request body`)||n.includes(`api token is required`))return{message:`Some required fields are missing or invalid.`,description:`Fill in hostname, source host (Miravo), and API token (for new targets).`};let r=t.replace(/^LE\s+\S+\s+/i,``).trim();return{message:`Could not verify the connection to Litmus Edge.`,description:r.length>0&&r.length<=220?r:xt(t,200)}}function xt(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function St(e){if(e.connected){g.success(`Connected to ${e.hostname}.`);return}let{message:t,description:n}=bt(e.error);g.error(t,n?{description:n}:void 0)}function Ct(e){let{message:t,description:n}=bt(e instanceof Error?e.message:String(e));g.error(t,n?{description:n}:void 0)}function wt(e){return!!(typeof DOMException<`u`&&e instanceof DOMException&&e.name===`AbortError`||e instanceof Error&&(e.name===`AbortError`||/aborted/i.test(e.message)))}function Tt(){let[e,t]=(0,q.useState)(!1),n=(0,q.useRef)(null),r=(0,q.useCallback)(()=>{n.current?.abort()},[]);return{testing:e,runTest:(0,q.useCallback)(async e=>{let r=new AbortController;n.current=r,t(!0);try{St(await ut(e,{signal:r.signal}))}catch(e){if(wt(e))return;Ct(e)}finally{n.current===r&&(n.current=null),t(!1)}},[]),cancelInFlight:r}}function Et({stream:e,className:t}){let n=vt(e);if(!n)return null;let r=e.status===`running`,i=e.status===`error`,a=e.status===`complete`&&e.operation?.status===`cancelled`,o=e.status===`complete`&&!a;return(0,X.jsxs)(`span`,{className:T(`inline-flex h-6 w-fit min-w-0 shrink-0 items-center justify-center gap-1 rounded-full border px-2 py-0`,`text-xs font-medium leading-none tracking-wide uppercase shadow-[inset_0_1px_0_0_rgba(255,255,255,0.05)]`,t,o&&`border-success/45 bg-success/[0.1] text-success`,a&&`border-muted-foreground/30 bg-muted/[0.1] text-muted-foreground shadow-none`,i&&`border-destructive/50 bg-destructive/[0.1] text-destructive shadow-none`,r&&`border-primary/40 bg-primary/[0.1] text-primary border-primary/35`),children:[o?(0,X.jsx)(x,{className:`size-3 shrink-0 opacity-95`,strokeWidth:2.5,"aria-hidden":!0}):a?(0,X.jsx)(de,{className:`size-3 shrink-0 opacity-95`,"aria-hidden":!0}):i?(0,X.jsx)(le,{className:`size-3 shrink-0 opacity-95`,"aria-hidden":!0}):(0,X.jsx)(z,{className:`size-3 shrink-0 animate-spin`,"aria-hidden":!0}),n]})}var Dt={status:`idle`,operation:null,error:null,logs:[],cancelRequested:!1},Ot=200;function kt(){let[e,t]=(0,q.useState)(Dt),n=(0,q.useRef)(null),r=(0,q.useRef)(0),i=(0,q.useRef)(0),a=(0,q.useCallback)(e=>{t(t=>({...t,status:`error`,cancelRequested:!1,error:e.message,operation:t.operation?{...t.operation,status:`error`,error:e.message}:null}))},[]),o=(0,q.useCallback)(e=>{switch(e.event){case`accepted`:At(e.data,t);break;case`log`:Mt({...e.data,id:`log-${r.current++}`},t);break;case`started`:Nt(e.data,t);break;case`phase`:Pt(e.data,t);break;case`resource`:Ft(e.data,t);break;case`complete`:It(e.data,t);break;case`cancelled`:Rt(e.data,t);break;case`retrying`:zt(e.data,t);break;case`error`:a(Error(e.data.message));break}},[a]),s=(0,q.useCallback)(e=>{let s=++i.current;n.current?.abort(),r.current=0,t({status:`running`,operation:null,error:null,logs:[],cancelRequested:!1}),n.current=ht(e,e=>{i.current===s&&(o(e),Bt(e)&&(n.current?.abort(),n.current=null))},e=>{i.current===s&&(n.current=null,a(e))})},[o,a]),c=(0,q.useCallback)(e=>{let s=++i.current;n.current?.abort(),r.current=0,t({status:`running`,operation:null,error:null,logs:[],cancelRequested:!1}),n.current=gt(e,e=>{i.current===s&&(o(e),Bt(e)&&(n.current?.abort(),n.current=null))},e=>{i.current===s&&(n.current=null,a(e))})},[o,a]),l=(0,q.useCallback)(()=>{i.current++,n.current?.abort(),n.current=null,t(Dt)},[]),u=(0,q.useCallback)(async()=>{let r=e.operation?.operationId;!r||e.status!==`running`||e.cancelRequested||(mt(r).catch(()=>!1),n.current?.abort(),n.current=null,t(e=>Lt(e,r)))},[e.operation?.operationId,e.status,e.cancelRequested]);return(0,q.useEffect)(()=>()=>{i.current++,n.current?.abort(),n.current=null},[]),{...e,startApply:s,startCleanup:c,reset:l,cancel:u}}function At(e,t){t(t=>({...t,status:`running`,cancelRequested:!1,error:null,operation:{operationId:e.operationId,type:e.type,label:e.template??e.model??(e.type===`apply`?`Preparing apply`:`Preparing cleanup`),environment:e.targetId??`Resolving target`,totalPlanned:0,phases:[],applied:0,failed:0,status:`running`,startedAt:Date.now()}}))}function jt(e){return(e.template??e.model)||(e.type===`cleanup`?`All managed resources`:`unknown`)}function Mt(e,t){t(t=>({...t,logs:[...t.logs,e].slice(-Ot)}))}function Nt(e,t){t(t=>({...t,status:`running`,cancelRequested:!1,error:null,operation:{operationId:e.operationId,type:e.type,label:jt(e),environment:e.environment,totalPlanned:e.totalPlanned,phases:[],applied:0,failed:0,status:`running`,startedAt:Date.now(),attempt:e.attempt,maxAttempts:e.maxAttempts}}))}function Pt(e,t){t(t=>{if(!$(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 Ft(e,t){t(t=>{if(!$(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`),failed:t.operation.failed+ +(e.status===`failed`)}}})}function It(e,t){t(t=>{if(!$(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 Lt(e,t){if(!$(e,t)||e.status!==`running`)return e;let n=e.operation.phases.map(e=>e.status===`active`?{...e,status:`done`}:e);return{...e,status:`complete`,cancelRequested:!1,error:null,operation:{...e.operation,phases:n,duration:Date.now()-e.operation.startedAt,status:`cancelled`}}}function Rt(e,t){t(t=>{if(!$(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 zt(e,t){t(t=>$(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 $(e,t){return e.operation?.operationId===t}function Bt(e){return e.event===`complete`||e.event===`cancelled`||e.event===`error`}export{ye as C,me as D,_e as E,pe as O,K as S,G as T,Xe as _,st as a,Y as b,ot as c,ct as d,at as f,Ze as g,Qe as h,yt as i,ft as l,$e as m,Et as n,lt as o,rt as p,Tt as r,pt as s,kt as t,dt as u,je as v,ve as w,J as x,Ee as y};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{s as t}from"./vendor-charts-CAZdaPlq.js";import{c as n}from"./chunk-OE4NN4TA-m2UhO8Q2.js";import{t as r}from"./route-preload-iLKZvgav.js";var i=e(t(),1);function a(){let e=n();return(0,i.useCallback)((t,n)=>{n?.preload!==!1&&r(t),(0,i.startTransition)(()=>{n?.transitionType&&(0,i.addTransitionType)(n.transitionType),e(t,{replace:n?.replace})})},[e])}export{a as t};