@miravo/cli-linux-arm64-musl 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/console-dist/assets/api-BG2sUkwk.js +1 -0
- package/console-dist/assets/api-CKfC8_zv.js +1 -0
- package/console-dist/assets/{asset-detail-C4zF_8rm.js → asset-detail-B2YDSfM1.js} +1 -1
- package/console-dist/assets/{asset-detail-actions-Dv9g2Z9t.js → asset-detail-actions-BrttEn24.js} +1 -1
- package/console-dist/assets/{backup-power-CAc85zvh.js → backup-power-Cm_Ij5yj.js} +1 -1
- package/console-dist/assets/{by-path-DmADo_qX.js → by-path-e6y8DTMV.js} +1 -1
- package/console-dist/assets/catalog-Bz24KMiz.js +1 -0
- package/console-dist/assets/{catalog-BMLSbdye.js → catalog-DOGCbTe4.js} +1 -1
- package/console-dist/assets/{catalog-template-icons-DGyxSm-F.js → catalog-template-icons-7CBAYTtP.js} +1 -1
- package/console-dist/assets/{commercial-building-CINKWcQV.js → commercial-building-D95MTyEI.js} +1 -1
- package/console-dist/assets/{console-panel-Cg2sBJcN.js → console-panel-iWo8EgKP.js} +1 -1
- package/console-dist/assets/{control-B-TcWj5c.js → control-BMhNX7vM.js} +1 -1
- package/console-dist/assets/control-CML5aS8w.js +1 -0
- package/console-dist/assets/{district-heating-DqGtrEKq.js → district-heating-B_YycTG-.js} +1 -1
- package/console-dist/assets/{events-Dz_zsLGE.js → events-5RYkaW81.js} +1 -1
- package/console-dist/assets/events-z582V8se.js +1 -0
- package/console-dist/assets/{export-tab-BS4GlLBV.js → export-tab-BsV7px7m.js} +1 -1
- package/console-dist/assets/factory-3x3_UmJZ.js +1 -0
- package/console-dist/assets/factory-LkZOsGje.js +1 -0
- package/console-dist/assets/{floor-page-BOlkyLaW.js → floor-page-D0qm0GgG.js} +1 -1
- package/console-dist/assets/{get-error-message-CEvauOXv.js → get-error-message-C9VW9IZB.js} +1 -1
- package/console-dist/assets/{index-B7ZG1VO6.js → index-M2C34y3X.js} +3 -3
- package/console-dist/assets/{integration-api-iM6SWQ6d.js → integration-api-ChbzMP5N.js} +1 -1
- package/console-dist/assets/integrations-BpOu11IH.js +1 -0
- package/console-dist/assets/{integrations-NcPRP3je.js → integrations-Cop24rSE.js} +1 -1
- package/console-dist/assets/{login-snbitj6V.js → login-BZANmwgH.js} +1 -1
- package/console-dist/assets/{models-Dy_JFNac.js → models-BgGuH6PQ.js} +1 -1
- package/console-dist/assets/models-C09Ba-2G.js +1 -0
- package/console-dist/assets/{pharma-cleanroom-CBgNUnIv.js → pharma-cleanroom-BbYfEQjP.js} +1 -1
- package/console-dist/assets/{protocol-card-Cp8O59cX.js → protocol-card-B8XGneNM.js} +1 -1
- package/console-dist/assets/{registry-Kj-oMlVm.js → registry-BXGfJ4np.js} +2 -2
- package/console-dist/assets/{status-kit-BLG7OeIE.js → status-kit-pFRjEjVU.js} +1 -1
- package/console-dist/assets/tags-BjW65yls.js +1 -0
- package/console-dist/assets/{tags-bloWH2Qa.js → tags-Bw7b0x14.js} +1 -1
- package/console-dist/assets/{transition-nav-link-CBN2nulP.js → transition-nav-link-CSrpkA7_.js} +1 -1
- package/console-dist/assets/use-engine-command-mutation-DrMOfYty.js +1 -0
- package/console-dist/assets/{use-transition-navigate-BDkvJJsk.js → use-transition-navigate-D2Y8kfw6.js} +2 -2
- package/console-dist/assets/{useQuery-smgfSdOx.js → useQuery-Cl48zZ73.js} +1 -1
- package/console-dist/assets/{validation-BOdAwXQ_.js → validation-Cxhiswz2.js} +1 -1
- package/console-dist/assets/{water-treatment-BJXMtYlP.js → water-treatment-jG0T2rhc.js} +1 -1
- package/console-dist/index.html +23 -23
- package/miravo +1 -1
- package/package.json +1 -1
- package/console-dist/assets/api-Dw9ti2cu.js +0 -1
- package/console-dist/assets/api-tM5PSXjr.js +0 -1
- package/console-dist/assets/catalog-Ccubt-hm.js +0 -1
- package/console-dist/assets/control-DXA-_1Gu.js +0 -1
- package/console-dist/assets/events-iYGC0JpW.js +0 -1
- package/console-dist/assets/factory-BCPLmUx4.js +0 -1
- package/console-dist/assets/factory-CBXx3oBo.js +0 -1
- package/console-dist/assets/integrations-Bw0jY-xH.js +0 -1
- package/console-dist/assets/models-CsdLFBfC.js +0 -1
- package/console-dist/assets/tags-BRYVC9vb.js +0 -1
- package/console-dist/assets/use-engine-command-mutation-oLQW2r4F.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,r as t}from"./rolldown-runtime-COnpUsM8.js";import{c as n}from"./vendor-charts-95ykyDlI.js";var r=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},i=new class extends r{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},a={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},o=new class{#e=a;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function s(e){setTimeout(e,0)}var c=typeof window>`u`||`Deno`in globalThis;function l(){}function u(e,t){return typeof e==`function`?e(t):e}function d(e){return typeof e==`number`&&e>=0&&e!==1/0}function f(e,t){return Math.max(e+(t||0)-Date.now(),0)}function p(e,t){return typeof e==`function`?e(t):e}function m(e,t){return typeof e==`function`?e(t):e}function ee(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==ne(o,t.options))return!1}else if(!ie(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function te(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(re(t.options.mutationKey)!==re(a))return!1}else if(!ie(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function ne(e,t){return(t?.queryKeyHashFn||re)(e)}function re(e){return JSON.stringify(e,(e,t)=>le(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function ie(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>ie(e[n],t[n])):!1}var ae=Object.prototype.hasOwnProperty;function oe(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ce(e)&&ce(t);if(!r&&!(le(e)&&le(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ae.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=oe(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function se(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ce(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function le(e){if(!ue(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ue(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function ue(e){return Object.prototype.toString.call(e)===`[object Object]`}function de(e){return new Promise(t=>{o.setTimeout(t,e)})}function fe(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:oe(e,t)}function pe(e){return e}function me(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function he(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ge=Symbol();function _e(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ge?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ve(e,t){return typeof e==`function`?e(...t):!!e}function ye(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var be=(()=>{let e=()=>c;return{isServer(){return e()},setIsServer(t){e=t}}})();function xe(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}function Se(e){let t;if(e.then(e=>(t=e,e),l)?.catch(l),t!==void 0)return{data:t}}function Ce(e){return e}function we(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}function Te(e,t,n){let r=()=>{let r=e.promise?.then(t).catch(e=>n(e)?Promise.reject(Error(`redacted`)):Promise.reject(e));return r?.catch(l),r};return{dehydratedAt:Date.now(),state:{...e.state,...e.state.data!==void 0&&{data:t(e.state.data)}},queryKey:e.queryKey,queryHash:e.queryHash,...e.state.status===`pending`&&{promise:r()},...e.meta&&{meta:e.meta}}}function Ee(e){return e.state.isPaused}function De(e){return e.state.status===`success`}function Oe(e){return!0}function ke(e,t={}){let n=t.shouldDehydrateMutation??e.getDefaultOptions().dehydrate?.shouldDehydrateMutation??Ee,r=e.getMutationCache().getAll().flatMap(e=>n(e)?[we(e)]:[]),i=t.shouldDehydrateQuery??e.getDefaultOptions().dehydrate?.shouldDehydrateQuery??De,a=t.shouldRedactErrors??e.getDefaultOptions().dehydrate?.shouldRedactErrors??Oe,o=t.serializeData??e.getDefaultOptions().dehydrate?.serializeData??Ce;return{mutations:r,queries:e.getQueryCache().getAll().flatMap(e=>i(e)?[Te(e,o,a)]:[])}}function Ae(e,t,n){if(typeof t!=`object`||!t)return;let r=e.getMutationCache(),i=e.getQueryCache(),a=n?.defaultOptions?.deserializeData??e.getDefaultOptions().hydrate?.deserializeData??Ce,o=t.mutations||[],s=t.queries||[];o.forEach(({state:t,...i})=>{r.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...i},t)}),s.forEach(({queryKey:t,state:r,queryHash:o,meta:s,promise:c,dehydratedAt:u})=>{let d=c?Se(c):void 0,f=r.data===void 0?d?.data:r.data,p=f===void 0?f:a(f),m=i.get(o),ee=m?.state.status===`pending`,te=m?.state.fetchStatus===`fetching`;if(m){let e=d&&u!==void 0&&u>m.state.dataUpdatedAt;if(r.dataUpdatedAt>m.state.dataUpdatedAt||e){let{fetchStatus:e,...t}=r;m.setState({...t,data:p})}}else m=i.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:t,queryHash:o,meta:s},{...r,data:p,fetchStatus:`idle`,status:p===void 0?r.status:`success`});c&&!ee&&!te&&(u===void 0||u>m.state.dataUpdatedAt)&&m.fetch(void 0,{initialPromise:Promise.resolve(c).then(a)}).catch(l)})}var je=s;function Me(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=je,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var h=Me(),Ne=new class extends r{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Pe(e){return Math.min(1e3*2**e,3e4)}function Fe(e){return(e??`online`)===`online`?Ne.isOnline():!0}var Ie=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Le(e){let t=!1,n=0,r,a=xe(),o=()=>a.status!==`pending`,s=t=>{if(!o()){let n=new Ie(t);p(n),e.onCancel?.(n)}},c=()=>{t=!0},l=()=>{t=!1},u=()=>i.isFocused()&&(e.networkMode===`always`||Ne.isOnline())&&e.canRun(),d=()=>Fe(e.networkMode)&&e.canRun(),f=e=>{o()||(r?.(),a.resolve(e))},p=e=>{o()||(r?.(),a.reject(e))},m=()=>new Promise(t=>{r=e=>{(o()||u())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,o()||e.onContinue?.()}),ee=()=>{if(o())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(f).catch(r=>{if(o())return;let i=e.retry??(be.isServer()?0:3),a=e.retryDelay??Pe,s=typeof a==`function`?a(n,r):a,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){p(r);return}n++,e.onFail?.(n,r),de(s).then(()=>u()?void 0:m()).then(()=>{t?p(r):ee()})})};return{promise:a,status:()=>a.status,cancel:s,continue:()=>(r?.(),a),cancelRetry:c,continueRetry:l,canStart:d,start:()=>(d()?ee():m().then(ee),a)}}var Re=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),d(this.gcTime)&&(this.#e=o.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(be.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(o.clearTimeout(this.#e),this.#e=void 0)}},ze=class extends Re{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=He(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=He(this.options);e.data!==void 0&&(this.setState(Ve(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=fe(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(l).catch(l):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>m(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ge||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>p(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!f(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=_e(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=Le({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Ie&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Ie){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Be(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Ve(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),h.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function Be(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Fe(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Ve(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function He(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}function Ue(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ye(e,()=>t.signal,()=>n=!0)},u=_e(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?he:me;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Ge:We,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:We(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function We(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ge(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Ke(e,t){return t?We(e,t)!=null:!1}function qe(e,t){return!t||!e.getPreviousPageParam?!1:Ge(e,t)!=null}var Je=class extends Re{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ye(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Le({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),h.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ye(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Xe=class extends r{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Je({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Ze(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Ze(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Ze(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Ze(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){h.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>te(t,e))}findAll(e={}){return this.getAll().filter(t=>te(e,t))}notify(e){h.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return h.batch(()=>Promise.all(e.map(e=>e.continue().catch(l))))}};function Ze(e){return e.options.scope?.id}var Qe=class extends r{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ne(r,t),a=this.get(i);return a||(a=new ze({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){h.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ee(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ee(e,t)):t}notify(e){h.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){h.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){h.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},$e=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Qe,this.#t=e.mutationCache||new Xe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=i.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Ne.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(p(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=u(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return h.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;h.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return h.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=h.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(l).catch(l)}invalidateQueries(e,t={}){return h.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=h.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(l)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(l)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(p(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(l).catch(l)}fetchInfiniteQuery(e){return e.behavior=Ue(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(l).catch(l)}ensureInfiniteQueryData(e){return e.behavior=Ue(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ne.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{ie(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(re(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{ie(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ne(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ge&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},et=e(n(),1),tt=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},nt=(e=>e?tt(e):tt),rt=e=>e;function it(e,t=rt){let n=et.useSyncExternalStore(e.subscribe,et.useCallback(()=>t(e.getState()),[e,t]),et.useCallback(()=>t(e.getInitialState()),[e,t]));return et.useDebugValue(n),n}var at=e=>{let t=nt(e),n=e=>it(t,e);return Object.assign(n,t),n},ot=(e=>e?at(e):at),st=200,ct=60,lt=1e3,ut=`miravo:runtime-snapshot`;function dt(e){try{sessionStorage.setItem(ut,JSON.stringify(e))}catch{}}function ft(){try{sessionStorage.removeItem(ut)}catch{}}function pt(e){if(typeof e!=`object`||!e)return!1;let t=e;if(typeof t.revision!=`number`||typeof t.state!=`object`||t.state===null||typeof t.metrics!=`object`||t.metrics===null)return!1;let n=t.metrics;return typeof n.core!=`object`||n.core===null?!1:Array.isArray(t.templates)}function mt(){try{let e=sessionStorage.getItem(ut);if(!e)return null;let t=JSON.parse(e);return pt(t)?t:(ft(),null)}catch{return ft(),null}}function ht(e){let t=e.metrics.core.tickCount,n=e.metrics.core.actualTicksPerSecond,r=Date.now();return{connectionState:`live`,connectionStateSince:r,reconnectAttempts:0,fatalError:null,lastRevision:e.revision,factoryName:e.state.factoryName??e.metrics.factoryName??``,seed:e.state.config.seed,engineState:e.metrics.core.state,tick:t,simulationTime:e.metrics.core.simulationTimeSeconds,tickIntervalMs:e.state.config.tickIntervalMs,lastTickReceivedAt:r,assetCount:e.metrics.core.assetCount,memberValueCount:e.metrics.core.memberValueCount,quarantinedAssetCount:e.metrics.core.quarantinedAssetCount,engineErrorsCount:e.metrics.core.engineErrorsCount,tickOverrunsCount:e.metrics.core.tickOverrunsCount,circuitBreakerTripsCount:e.metrics.core.circuitBreakerTripsCount,tps:n,uptimeMs:e.metrics.core.uptimeMs,speedMultiplier:e.state.config.timeMultiplier,assets:[...e.state.assets],models:[...e.state.models],tpsHistory:[{tick:t,tps:n,sampledAtMs:r}],lines:[...e.state.lines??[]],templates:[...e.templates],bootTemplate:e.state.config.template,availableAdapters:e.state.availableAdapters??[],adapterMetrics:e.metrics.adapters??[],memberValues:new Map,events:[]}}function gt(e,t){return{connectionState:`live`,connectionStateSince:e.connectionState===`live`?e.connectionStateSince:t,reconnectAttempts:0,fatalError:null}}var _t=ot((e,t)=>({connectionState:`booting`,connectionStateSince:Date.now(),reconnectAttempts:0,fatalError:null,lastRevision:0,factoryName:``,seed:null,engineState:`idle`,tick:0,simulationTime:0,tickIntervalMs:1e3,lastTickReceivedAt:0,assetCount:0,memberValueCount:0,quarantinedAssetCount:0,engineErrorsCount:0,tickOverrunsCount:0,circuitBreakerTripsCount:0,tps:0,uptimeMs:0,speedMultiplier:1,assets:[],models:[],tpsHistory:[],lines:[],templates:[],bootTemplate:void 0,availableAdapters:[],adapterMetrics:[],memberValues:new Map,events:[],replaceRuntime:(n,r)=>{let i=t().lastRevision;i>0&&(n.revision<i&&!r?.allowRevisionRewind||n.revision===i&&!r?.allowSameRevision)||(e(()=>ht(n)),dt(n))},applyTick:n=>{let r=t();if(n.revision<=r.lastRevision)return;let i=n.delta??[],a=n.tick??r.tick,o=n.simulationTime??r.simulationTime,s=n.assetCount??r.assetCount,c=n.metrics.core.actualTicksPerSecond,l=Date.now();if(!(i.length>0||a!==r.tick||o!==r.simulationTime||s!==r.assetCount||n.metrics.adapters!==r.adapterMetrics||n.metrics.core.engineErrorsCount!==r.engineErrorsCount||n.metrics.core.tickOverrunsCount!==r.tickOverrunsCount||n.metrics.core.circuitBreakerTripsCount!==r.circuitBreakerTripsCount||n.metrics.core.memberValueCount!==r.memberValueCount||n.metrics.core.quarantinedAssetCount!==r.quarantinedAssetCount||c!==r.tps)){e({...gt(r,l),lastTickReceivedAt:l,lastRevision:n.revision});return}let u={...gt(r,l),tick:a,simulationTime:o,lastTickReceivedAt:l,assetCount:s,memberValueCount:n.metrics.core.memberValueCount,quarantinedAssetCount:n.metrics.core.quarantinedAssetCount,engineErrorsCount:n.metrics.core.engineErrorsCount,tickOverrunsCount:n.metrics.core.tickOverrunsCount,circuitBreakerTripsCount:n.metrics.core.circuitBreakerTripsCount,tps:c,uptimeMs:n.metrics.core.uptimeMs,adapterMetrics:n.metrics.adapters,lastRevision:n.revision},d=r.tpsHistory.at(-1),f={tps:c,tick:a,sampledAtMs:l};if(!d||l-d.sampledAtMs>=lt?u.tpsHistory=[...r.tpsHistory,f].slice(-ct):u.tpsHistory=[...r.tpsHistory.slice(0,-1),f],i.length>0){let e=new Map(r.memberValues),t=new Set;for(let n of i){if(!t.has(n.assetId)){let r=e.get(n.assetId);e.set(n.assetId,new Map(r)),t.add(n.assetId)}e.get(n.assetId)?.set(n.memberName,{value:n.value,quality:n.quality})}u.memberValues=e}e(u)},applyEvent:(n,r)=>{let i=t();if(r<=i.lastRevision)return;let a=Date.now(),o=[n,...i.events].slice(0,st),s={...gt(i,a),events:o,lastRevision:r};if(n.kind===`asset:removed`){let t=new Map(i.memberValues);t.delete(n.id),e({...s,memberValues:t});return}if(n.kind===`fault:triggered`||n.kind===`fault:cleared`){let t=i.assets.map(e=>{if(e.id!==n.assetId)return e;let t=n.kind===`fault:triggered`?[...e.activeFaults,n.fault]:e.activeFaults.filter(e=>e!==n.fault);return{...e,activeFaults:t}});e({...s,assets:t});return}if(n.kind===`lifecycle:changed`||n.kind===`asset:maintenance`){let t=i.assets.map(e=>e.id===n.assetId?{...e,lifecycleStage:n.to,operatingHours:n.operatingHours}:e);e({...s,assets:t});return}if(n.kind===`engine:state`){e({...s,engineState:n.to});return}e(s)},markConnection:n=>{t().connectionState!==n&&e({connectionState:n,connectionStateSince:Date.now()})},markFatal:t=>{e({connectionState:`fatal`,connectionStateSince:Date.now(),fatalError:t})},markUnauthenticated:()=>{t().connectionState!==`unauthenticated`&&e({connectionState:`unauthenticated`,connectionStateSince:Date.now()})},noteReconnectAttempt:()=>{e(e=>({reconnectAttempts:e.reconnectAttempts+1}))},resetReconnectAttempts:()=>{t().reconnectAttempts!==0&&e({reconnectAttempts:0})}})),g;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(g||={});var vt;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(vt||={});var _=g.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),v=e=>{switch(typeof e){case`undefined`:return _.undefined;case`string`:return _.string;case`number`:return Number.isNaN(e)?_.nan:_.number;case`boolean`:return _.boolean;case`function`:return _.function;case`bigint`:return _.bigint;case`symbol`:return _.symbol;case`object`:return Array.isArray(e)?_.array:e===null?_.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?_.promise:typeof Map<`u`&&e instanceof Map?_.map:typeof Set<`u`&&e instanceof Set?_.set:typeof Date<`u`&&e instanceof Date?_.date:_.object;default:return _.unknown}},y=g.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),yt=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,`$1:`),b=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,g.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};b.create=e=>new b(e);var bt=(e,t)=>{let n;switch(e.code){case y.invalid_type:n=e.received===_.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,g.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:n=`Unrecognized key(s) in object: ${g.joinValues(e.keys,`, `)}`;break;case y.invalid_union:n=`Invalid input`;break;case y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${g.joinValues(e.options)}`;break;case y.invalid_enum_value:n=`Invalid enum value. Expected ${g.joinValues(e.options)}, received '${e.received}'`;break;case y.invalid_arguments:n=`Invalid function arguments`;break;case y.invalid_return_type:n=`Invalid function return type`;break;case y.invalid_date:n=`Invalid date`;break;case y.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:g.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case y.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case y.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case y.custom:n=`Invalid input`;break;case y.invalid_intersection_types:n=`Intersection results could not be merged`;break;case y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case y.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,g.assertNever(e)}return{message:n}},xt=bt;function St(e){xt=e}function Ct(){return xt}var wt=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},Tt=[];function x(e,t){let n=Ct(),r=wt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===bt?void 0:bt].filter(e=>!!e)});e.common.issues.push(r)}var S=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return C;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return C;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},C=Object.freeze({status:`aborted`}),Et=e=>({status:`dirty`,value:e}),w=e=>({status:`valid`,value:e}),Dt=e=>e.status===`aborted`,Ot=e=>e.status===`dirty`,kt=e=>e.status===`valid`,At=e=>typeof Promise<`u`&&e instanceof Promise,T;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(T||={});var E=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},jt=(e,t)=>{if(kt(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new b(e.common.issues),this._error}}};function D(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var O=class{get description(){return this._def.description}_getType(e){return v(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:v(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:v(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(At(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:v(e)};return jt(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:v(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return kt(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>kt(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:v(e)},r=this._parse({data:e,path:n.path,parent:n});return jt(n,await(At(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:y.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new M({schema:this,typeName:F.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return N.create(this,this._def)}nullable(){return P.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return hn.create(this)}promise(){return jn.create(this,this._def)}or(e){return _n.create([this,e],this._def)}and(e){return xn.create(this,e,this._def)}transform(e){return new M({...D(this._def),schema:this,typeName:F.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Mn({...D(this._def),innerType:this,defaultValue:t,typeName:F.ZodDefault})}brand(){return new In({typeName:F.ZodBranded,type:this,...D(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Nn({...D(this._def),innerType:this,catchValue:t,typeName:F.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ln.create(this,e)}readonly(){return Rn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Mt=/^c[^\s-]{8,}$/i,Nt=/^[0-9a-z]+$/,Pt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ft=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,It=/^[a-z0-9_-]{21}$/i,Lt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,zt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Bt=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Vt,Ht=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ut=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Wt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Gt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Kt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Jt=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,Yt=RegExp(`^${Jt}$`);function Xt(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Zt(e){return RegExp(`^${Xt(e)}$`)}function Qt(e){let t=`${Jt}T${Xt(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function $t(e,t){return!!((t===`v4`||!t)&&Ht.test(e)||(t===`v6`||!t)&&Wt.test(e))}function en(e,t){if(!Lt.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function tn(e,t){return!!((t===`v4`||!t)&&Ut.test(e)||(t===`v6`||!t)&&Gt.test(e))}var nn=class e extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.string,received:t.parsedType}),C}let t=new S,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?x(n,{code:y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&x(n,{code:y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)zt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`email`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)Vt||=new RegExp(Bt,`u`),Vt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`emoji`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Ft.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`uuid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)It.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`nanoid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Mt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cuid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Nt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cuid2`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Pt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`ulid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),x(n,{validation:`url`,code:y.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`regex`,code:y.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Qt(r).test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Yt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Zt(r).test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Rt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`duration`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?$t(e.data,r.version)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`ip`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?en(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`jwt`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?tn(e.data,r.version)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cidr`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Kt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`base64`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?qt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`base64url`,code:y.invalid_string,message:r.message}),t.dirty()):g.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:y.invalid_string,...T.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...T.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...T.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...T.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...T.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...T.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...T.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...T.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...T.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...T.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...T.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...T.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...T.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...T.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...T.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...T.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...T.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...T.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...T.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...T.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...T.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...T.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...T.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...T.errToObj(t)})}nonempty(e){return this.min(1,T.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};nn.create=e=>new nn({checks:[],typeName:F.ZodString,coerce:e?.coerce??!1,...D(e)});function rn(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var an=class e extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.number,received:t.parsedType}),C}let t,n=new S;for(let r of this._def.checks)r.kind===`int`?g.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),x(t,{code:y.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?rn(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),x(t,{code:y.not_finite,message:r.message}),n.dirty()):g.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,T.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,T.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,T.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,T.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:T.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:T.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:T.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:T.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:T.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:T.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:T.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&g.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};an.create=e=>new an({checks:[],typeName:F.ZodNumber,coerce:e?.coerce||!1,...D(e)});var on=class e extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==_.bigint)return this._getInvalidInput(e);let t,n=new S;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):g.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.bigint,received:t.parsedType}),C}gte(e,t){return this.setLimit(`min`,e,!0,T.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,T.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,T.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,T.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:T.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:T.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:T.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};on.create=e=>new on({checks:[],typeName:F.ZodBigInt,coerce:e?.coerce??!1,...D(e)});var sn=class extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.boolean,received:t.parsedType}),C}return w(e.data)}};sn.create=e=>new sn({typeName:F.ZodBoolean,coerce:e?.coerce||!1,...D(e)});var cn=class e extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.date,received:t.parsedType}),C}if(Number.isNaN(e.data.getTime()))return x(this._getOrReturnCtx(e),{code:y.invalid_date}),C;let t=new S,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):g.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:T.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:T.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};cn.create=e=>new cn({checks:[],coerce:e?.coerce||!1,typeName:F.ZodDate,...D(e)});var ln=class extends O{_parse(e){if(this._getType(e)!==_.symbol){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.symbol,received:t.parsedType}),C}return w(e.data)}};ln.create=e=>new ln({typeName:F.ZodSymbol,...D(e)});var un=class extends O{_parse(e){if(this._getType(e)!==_.undefined){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.undefined,received:t.parsedType}),C}return w(e.data)}};un.create=e=>new un({typeName:F.ZodUndefined,...D(e)});var dn=class extends O{_parse(e){if(this._getType(e)!==_.null){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.null,received:t.parsedType}),C}return w(e.data)}};dn.create=e=>new dn({typeName:F.ZodNull,...D(e)});var fn=class extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return w(e.data)}};fn.create=e=>new fn({typeName:F.ZodAny,...D(e)});var pn=class extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return w(e.data)}};pn.create=e=>new pn({typeName:F.ZodUnknown,...D(e)});var k=class extends O{_parse(e){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.never,received:t.parsedType}),C}};k.create=e=>new k({typeName:F.ZodNever,...D(e)});var mn=class extends O{_parse(e){if(this._getType(e)!==_.undefined){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.void,received:t.parsedType}),C}return w(e.data)}};mn.create=e=>new mn({typeName:F.ZodVoid,...D(e)});var hn=class e extends O{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==_.array)return x(t,{code:y.invalid_type,expected:_.array,received:t.parsedType}),C;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(x(t,{code:e?y.too_big:y.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(x(t,{code:y.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(x(t,{code:y.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new E(t,e,t.path,n)))).then(e=>S.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new E(t,e,t.path,n)));return S.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:T.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:T.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:T.toString(n)}})}nonempty(e){return this.min(1,e)}};hn.create=(e,t)=>new hn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:F.ZodArray,...D(t)});function gn(e){if(e instanceof A){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=N.create(gn(r))}return new A({...e._def,shape:()=>t})}else if(e instanceof hn)return new hn({...e._def,type:gn(e.element)});else if(e instanceof N)return N.create(gn(e.unwrap()));else if(e instanceof P)return P.create(gn(e.unwrap()));else if(e instanceof j)return j.create(e.items.map(e=>gn(e)));else return e}var A=class e extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:g.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==_.object){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.object,received:t.parsedType}),C}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof k&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new E(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof k){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(x(n,{code:y.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new E(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>S.mergeObjectSync(t,e)):S.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return T.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:T.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:F.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of g.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of g.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return gn(this)}partial(t){let n={};for(let e of g.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of g.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof N;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return On(g.objectKeys(this.shape))}};A.create=(e,t)=>new A({shape:()=>e,unknownKeys:`strip`,catchall:k.create(),typeName:F.ZodObject,...D(t)}),A.strictCreate=(e,t)=>new A({shape:()=>e,unknownKeys:`strict`,catchall:k.create(),typeName:F.ZodObject,...D(t)}),A.lazycreate=(e,t)=>new A({shape:e,unknownKeys:`strip`,catchall:k.create(),typeName:F.ZodObject,...D(t)});var _n=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new b(e.ctx.common.issues));return x(t,{code:y.invalid_union,unionErrors:n}),C}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new b(e));return x(t,{code:y.invalid_union,unionErrors:i}),C}}get options(){return this._def.options}};_n.create=(e,t)=>new _n({options:e,typeName:F.ZodUnion,...D(t)});var vn=e=>e instanceof En?vn(e.schema):e instanceof M?vn(e.innerType()):e instanceof Dn?[e.value]:e instanceof kn?e.options:e instanceof An?g.objectValues(e.enum):e instanceof Mn?vn(e._def.innerType):e instanceof un?[void 0]:e instanceof dn?[null]:e instanceof N?[void 0,...vn(e.unwrap())]:e instanceof P?[null,...vn(e.unwrap())]:e instanceof In||e instanceof Rn?vn(e.unwrap()):e instanceof Nn?vn(e._def.innerType):[],yn=class e extends O{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return x(t,{code:y.invalid_type,expected:_.object,received:t.parsedType}),C;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(x(t,{code:y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),C)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=vn(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:F.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...D(r)})}};function bn(e,t){let n=v(e),r=v(t);if(e===t)return{valid:!0,data:e};if(n===_.object&&r===_.object){let n=g.objectKeys(t),r=g.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=bn(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===_.array&&r===_.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=bn(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===_.date&&r===_.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var xn=class extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Dt(e)||Dt(r))return C;let i=bn(e.value,r.value);return i.valid?((Ot(e)||Ot(r))&&t.dirty(),{status:t.value,value:i.data}):(x(n,{code:y.invalid_intersection_types}),C)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};xn.create=(e,t,n)=>new xn({left:e,right:t,typeName:F.ZodIntersection,...D(n)});var j=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return x(n,{code:y.invalid_type,expected:_.array,received:n.parsedType}),C;if(n.data.length<this._def.items.length)return x(n,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),C;!this._def.rest&&n.data.length>this._def.items.length&&(x(n,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new E(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>S.mergeArray(t,e)):S.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};j.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new j({items:e,typeName:F.ZodTuple,rest:null,...D(t)})};var Sn=class e extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return x(n,{code:y.invalid_type,expected:_.object,received:n.parsedType}),C;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new E(n,e,n.path,e)),value:a._parse(new E(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?S.mergeObjectAsync(t,r):S.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof O?new e({keyType:t,valueType:n,typeName:F.ZodRecord,...D(r)}):new e({keyType:nn.create(),valueType:t,typeName:F.ZodRecord,...D(n)})}},Cn=class extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return x(n,{code:y.invalid_type,expected:_.map,received:n.parsedType}),C;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new E(n,e,n.path,[a,`key`])),value:i._parse(new E(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return C;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return C;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Cn.create=(e,t,n)=>new Cn({valueType:t,keyType:e,typeName:F.ZodMap,...D(n)});var wn=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return x(n,{code:y.invalid_type,expected:_.set,received:n.parsedType}),C;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(x(n,{code:y.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(x(n,{code:y.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return C;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new E(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:T.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:T.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};wn.create=(e,t)=>new wn({valueType:e,minSize:null,maxSize:null,typeName:F.ZodSet,...D(t)});var Tn=class e extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return x(t,{code:y.invalid_type,expected:_.function,received:t.parsedType}),C;function n(e,n){return wt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ct(),bt].filter(e=>!!e),issueData:{code:y.invalid_arguments,argumentsError:n}})}function r(e,n){return wt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ct(),bt].filter(e=>!!e),issueData:{code:y.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof jn){let e=this;return w(async function(...t){let o=new b([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return w(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new b([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new b([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:j.create(t).rest(pn.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||j.create([]).rest(pn.create()),returns:n||pn.create(),typeName:F.ZodFunction,...D(r)})}},En=class extends O{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};En.create=(e,t)=>new En({getter:e,typeName:F.ZodLazy,...D(t)});var Dn=class extends O{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return x(t,{received:t.data,code:y.invalid_literal,expected:this._def.value}),C}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Dn.create=(e,t)=>new Dn({value:e,typeName:F.ZodLiteral,...D(t)});function On(e,t){return new kn({values:e,typeName:F.ZodEnum,...D(t)})}var kn=class e extends O{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return x(t,{expected:g.joinValues(n),received:t.parsedType,code:y.invalid_type}),C}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return x(t,{received:t.data,code:y.invalid_enum_value,options:n}),C}return w(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};kn.create=On;var An=class extends O{_parse(e){let t=g.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let e=g.objectValues(t);return x(n,{expected:g.joinValues(e),received:n.parsedType,code:y.invalid_type}),C}if(this._cache||=new Set(g.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=g.objectValues(t);return x(n,{received:n.data,code:y.invalid_enum_value,options:e}),C}return w(e.data)}get enum(){return this._def.values}};An.create=(e,t)=>new An({values:e,typeName:F.ZodNativeEnum,...D(t)});var jn=class extends O{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==_.promise&&t.common.async===!1?(x(t,{code:y.invalid_type,expected:_.promise,received:t.parsedType}),C):w((t.parsedType===_.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};jn.create=(e,t)=>new jn({type:e,typeName:F.ZodPromise,...D(t)});var M=class extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===F.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{x(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return C;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?C:r.status===`dirty`||t.value===`dirty`?Et(r.value):r});{if(t.value===`aborted`)return C;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?C:r.status===`dirty`||t.value===`dirty`?Et(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?C:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?C:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!kt(e))return C;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>kt(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):C);g.assertNever(r)}};M.create=(e,t,n)=>new M({schema:e,typeName:F.ZodEffects,effect:t,...D(n)}),M.createWithPreprocess=(e,t,n)=>new M({schema:t,effect:{type:`preprocess`,transform:e},typeName:F.ZodEffects,...D(n)});var N=class extends O{_parse(e){return this._getType(e)===_.undefined?w(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};N.create=(e,t)=>new N({innerType:e,typeName:F.ZodOptional,...D(t)});var P=class extends O{_parse(e){return this._getType(e)===_.null?w(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};P.create=(e,t)=>new P({innerType:e,typeName:F.ZodNullable,...D(t)});var Mn=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Mn.create=(e,t)=>new Mn({innerType:e,typeName:F.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...D(t)});var Nn=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return At(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new b(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new b(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Nn.create=(e,t)=>new Nn({innerType:e,typeName:F.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...D(t)});var Pn=class extends O{_parse(e){if(this._getType(e)!==_.nan){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.nan,received:t.parsedType}),C}return{status:`valid`,value:e.data}}};Pn.create=e=>new Pn({typeName:F.ZodNaN,...D(e)});var Fn=Symbol(`zod_brand`),In=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Ln=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?C:e.status===`dirty`?(t.dirty(),Et(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?C:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:F.ZodPipeline})}},Rn=class extends O{_parse(e){let t=this._def.innerType._parse(e),n=e=>(kt(e)&&(e.value=Object.freeze(e.value)),e);return At(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Rn.create=(e,t)=>new Rn({innerType:e,typeName:F.ZodReadonly,...D(t)});function zn(e,t){let n=typeof e==`function`?e(t):typeof e==`string`?{message:e}:e;return typeof n==`string`?{message:n}:n}function Bn(e,t={},n){return e?fn.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(e=>{if(!e){let e=zn(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}});if(!a){let e=zn(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}}):fn.create()}var Vn={object:A.lazycreate},F;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(F||={});var Hn=(e,t={message:`Input not instance of ${e.name}`})=>Bn(t=>t instanceof e,t),I=nn.create,L=an.create,Un=Pn.create,Wn=on.create,R=sn.create,Gn=cn.create,Kn=ln.create,qn=un.create,Jn=dn.create,Yn=fn.create,z=pn.create,Xn=k.create,Zn=mn.create,B=hn.create,V=A.create,Qn=A.strictCreate,H=_n.create,U=yn.create,$n=xn.create,er=j.create,W=Sn.create,tr=Cn.create,nr=wn.create,rr=Tn.create,ir=En.create,G=Dn.create,K=kn.create,ar=An.create,or=jn.create,sr=M.create,cr=N.create,lr=P.create,ur=M.createWithPreprocess,dr=Ln.create,fr=()=>I().optional(),pr=()=>L().optional(),mr=()=>R().optional(),hr={string:(e=>nn.create({...e,coerce:!0})),number:(e=>an.create({...e,coerce:!0})),boolean:(e=>sn.create({...e,coerce:!0})),bigint:(e=>on.create({...e,coerce:!0})),date:(e=>cn.create({...e,coerce:!0}))},gr=C,_r=t({BRAND:()=>Fn,DIRTY:()=>Et,EMPTY_PATH:()=>Tt,INVALID:()=>C,NEVER:()=>gr,OK:()=>w,ParseStatus:()=>S,Schema:()=>O,ZodAny:()=>fn,ZodArray:()=>hn,ZodBigInt:()=>on,ZodBoolean:()=>sn,ZodBranded:()=>In,ZodCatch:()=>Nn,ZodDate:()=>cn,ZodDefault:()=>Mn,ZodDiscriminatedUnion:()=>yn,ZodEffects:()=>M,ZodEnum:()=>kn,ZodError:()=>b,ZodFirstPartyTypeKind:()=>F,ZodFunction:()=>Tn,ZodIntersection:()=>xn,ZodIssueCode:()=>y,ZodLazy:()=>En,ZodLiteral:()=>Dn,ZodMap:()=>Cn,ZodNaN:()=>Pn,ZodNativeEnum:()=>An,ZodNever:()=>k,ZodNull:()=>dn,ZodNullable:()=>P,ZodNumber:()=>an,ZodObject:()=>A,ZodOptional:()=>N,ZodParsedType:()=>_,ZodPipeline:()=>Ln,ZodPromise:()=>jn,ZodReadonly:()=>Rn,ZodRecord:()=>Sn,ZodSchema:()=>O,ZodSet:()=>wn,ZodString:()=>nn,ZodSymbol:()=>ln,ZodTransformer:()=>M,ZodTuple:()=>j,ZodType:()=>O,ZodUndefined:()=>un,ZodUnion:()=>_n,ZodUnknown:()=>pn,ZodVoid:()=>mn,addIssueToContext:()=>x,any:()=>Yn,array:()=>B,bigint:()=>Wn,boolean:()=>R,coerce:()=>hr,custom:()=>Bn,date:()=>Gn,datetimeRegex:()=>Qt,defaultErrorMap:()=>bt,discriminatedUnion:()=>U,effect:()=>sr,enum:()=>K,function:()=>rr,getErrorMap:()=>Ct,getParsedType:()=>v,instanceof:()=>Hn,intersection:()=>$n,isAborted:()=>Dt,isAsync:()=>At,isDirty:()=>Ot,isValid:()=>kt,late:()=>Vn,lazy:()=>ir,literal:()=>G,makeIssue:()=>wt,map:()=>tr,nan:()=>Un,nativeEnum:()=>ar,never:()=>Xn,null:()=>Jn,nullable:()=>lr,number:()=>L,object:()=>V,objectUtil:()=>vt,oboolean:()=>mr,onumber:()=>pr,optional:()=>cr,ostring:()=>fr,pipeline:()=>dr,preprocess:()=>ur,promise:()=>or,quotelessJson:()=>yt,record:()=>W,set:()=>nr,setErrorMap:()=>St,strictObject:()=>Qn,string:()=>I,symbol:()=>Kn,transformer:()=>sr,tuple:()=>er,undefined:()=>qn,union:()=>H,unknown:()=>z,util:()=>g,void:()=>Zn}),vr=V({username:I().min(1),password:I().min(1)}),yr=V({ok:G(!0),changePassword:R()}),br=V({oldPassword:I().min(1),newPassword:I().min(6)}),xr=V({ok:G(!0)}),Sr=V({authenticated:R(),username:I().optional()});V({password:I().min(1)});var Cr=class extends Error{fix;context;constructor(e,t,n){super(e),this.name=`MiravoError`,this.fix=t,this.context=n}},wr=`0.12.0`,Tr=1883,Er=4840,Dr=1502,Or={mqtt:Tr,opcua:Er,modbus:Dr},kr=65535;function Ar(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=65535}var jr=1e4,Mr=1e3,Nr=1e6,Pr=1e5,q=/^[a-zA-Z0-9_-]{1,64}$/,Fr=/^\$param\.(\S+)$/,Ir=L().int().min(1).max(kr),Lr=V({state:K([`healthy`,`busy`,`saturated`]),pendingWorkCount:L().finite().int().nonnegative(),completedLastTick:L().finite().int().nonnegative()}),Rr=V({active:L().finite().int().nonnegative(),subscriptions:L().finite().int().nonnegative().optional(),reads:L().finite().int().nonnegative().optional(),writes:L().finite().int().nonnegative().optional()}),zr=V({connected:R(),messagesPublished:L().finite().int().nonnegative(),messagesAttempted:L().finite().int().nonnegative(),messagesFiltered:L().finite().int().nonnegative(),errorsCount:L().finite().int().nonnegative(),rejectedWrites:L().finite().int().nonnegative().optional(),lastPublishMs:L().finite().nonnegative(),health:Lr.optional(),clients:Rr.optional()});V({name:I().min(1),enabled:R().default(!0)}).passthrough();var Br=V({name:I().min(1),enabled:R(),pending:R().optional(),endpoint:I().optional(),boundPort:Ir.optional(),config:W(I(),z())}),J=V({factoryName:I().min(1).optional(),core:V({state:K([`idle`,`running`,`paused`,`stopped`]),tickCount:L().int().nonnegative(),simulationTimeSeconds:L().finite().nonnegative(),pauseAtSimulationSeconds:L().finite().positive().optional(),assetCount:L().int().nonnegative(),memberValueCount:L().int().nonnegative(),quarantinedAssetCount:L().int().nonnegative(),engineErrorsCount:L().int().nonnegative(),lastEngineError:V({context:I(),message:I()}).optional(),tickOverrunsCount:L().int().nonnegative(),circuitBreakerTripsCount:L().int().nonnegative(),uptimeMs:L().finite().nonnegative(),actualTicksPerSecond:L().finite().nonnegative()}),fleet:V({modelBreakdown:B(V({model:I().min(1),count:L().int().nonnegative()})),lifecycleBreakdown:W(I(),L().int().nonnegative()),activeFaultCount:L().int().nonnegative(),faultBreakdown:B(V({fault:I().min(1),count:L().int().nonnegative()}))}),adapters:B(V({name:I().min(1),metrics:zr}))}),Vr=V({lines:B(V({line:I(),stations:B(V({id:I(),state:I(),good:L().int().nonnegative(),scrap:L().int().nonnegative()})),buffers:B(V({after:I(),level:L().int().nonnegative(),capacity:L().int().positive()}))})).optional(),factoryName:I().min(1).optional(),models:B(V({name:I().min(1),memberCount:L().int().nonnegative(),faultCount:L().int().nonnegative(),faultNames:B(I().min(1)),hasLifecycle:R()})),assets:B(V({id:I().min(1),model:I().min(1),browsePath:B(I().min(1)),lifecycleStage:I().min(1),operatingHours:L().finite().nonnegative(),activeFaults:B(I().min(1)),isQuarantined:R(),production:W(I(),H([L(),I(),R()])).optional()})),config:V({seed:L().int().nonnegative(),tickIntervalMs:L().int().positive(),timeMultiplier:L().finite().positive(),adapters:B(I().min(1)),template:V({name:I().min(1),path:I().min(1)}).optional()}),availableAdapters:B(Br).optional()}),Hr=V({templateId:I().min(1),templateName:I().min(1),templatePath:I().min(1),entryHash:I().min(1).optional(),assetIds:B(I().min(1)),models:B(I().min(1)),areas:B(V({name:I().min(1),lines:B(I().min(1))}))}),Ur=V({name:I().min(1),value:H([L().finite(),I(),R()]),quality:K([`good`,`bad`,`uncertain`]),unit:I().nullable(),kind:I().min(1),dataType:I().min(1)}),Wr=V({id:I().min(1),name:I().min(1),members:B(Ur),inputs:B(V({port:I().min(1),asset:I().min(1),member:I().min(1)}))}),Gr=V({state:Vr,metrics:J,templates:B(Hr),assetDetails:B(Wr),revision:L().int().nonnegative()}),Kr=U(`authenticated`,[V({authenticated:G(!1)}),V({authenticated:G(!0),username:I().min(1),runtime:Gr,viewToken:I().min(1).optional()})]),qr=V({assetId:I().min(1),memberName:I().min(1),value:H([L().finite(),I(),R()]),quality:K([`good`,`bad`,`uncertain`]),timestamp:L().finite().optional()}),Jr=U(`kind`,[V({kind:G(`fault:triggered`),assetId:I().min(1),fault:I().min(1),effects:W(I(),z())}),V({kind:G(`fault:cleared`),assetId:I().min(1),fault:I().min(1)}),V({kind:G(`lifecycle:changed`),assetId:I().min(1),from:I().min(1),to:I().min(1),operatingHours:L().finite().nonnegative()}),V({kind:G(`asset:maintenance`),assetId:I().min(1),from:I().min(1),to:I().min(1),operatingHours:L().finite().nonnegative(),reason:K([`manual`,`scheduled`])}),V({kind:G(`asset:created`),id:I().min(1),assetType:I().min(1),browsePath:B(I().min(1))}),V({kind:G(`asset:removed`),id:I().min(1)}),V({kind:K([`template:loaded`,`template:unloaded`]),templateId:I().min(1),assetCount:L().int().nonnegative()}),V({kind:G(`engine:state`),from:J.shape.core.shape.state,to:J.shape.core.shape.state}),V({kind:G(`engine:error`),context:I(),message:I(),fix:I().optional()}),V({kind:G(`adapter:enabled`),name:I().min(1),endpoint:I().min(1)}),V({kind:G(`adapter:disabled`),name:I().min(1)})]),Yr=V({core:V({memberValueCount:J.shape.core.shape.memberValueCount,quarantinedAssetCount:J.shape.core.shape.quarantinedAssetCount,engineErrorsCount:J.shape.core.shape.engineErrorsCount,tickOverrunsCount:J.shape.core.shape.tickOverrunsCount,circuitBreakerTripsCount:J.shape.core.shape.circuitBreakerTripsCount,uptimeMs:J.shape.core.shape.uptimeMs,actualTicksPerSecond:J.shape.core.shape.actualTicksPerSecond}),adapters:J.shape.adapters}),Xr=U(`type`,[V({type:G(`runtime:snapshot`),snapshot:Gr}),V({type:G(`runtime:tick`),revision:L().int().nonnegative(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),delta:B(qr),assetCount:L().int().nonnegative(),lines:Vr.shape.lines.unwrap(),timeMultiplier:L().finite().positive(),metrics:Yr}),V({type:G(`runtime:event`),revision:L().int().nonnegative(),event:Jr}),V({type:G(`runtime:resync-required`),revision:L().int().nonnegative(),reason:I().min(1)})]),Zr=/^[A-Za-z0-9_-]+$/;function Qr(e){let t=/^(.+)-(\d+)$/.exec(e);if(!t)return null;let n=t[1],r=t[2];if(!n||!r)return null;let i=Number(r);return!Number.isSafeInteger(i)||i<1?null:{prefix:n,counter:i}}function $r(e){let t=e.trim();if(t.length===0)return`Name is required.`;let n=t.split(`-`);if(n.some(e=>e.length===0))return`Use hyphen-delimited segments without empty parts.`;for(let e of n)if(!Zr.test(e))return`Use only letters, numbers, underscores, and hyphens.`;return null}function ei(e){let t=e.trim();return t.length===0?null:t.length>120?`Use at most 120 characters.`:$r(e)}var Y=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`,X=K([`mqtt`,`opcua`,`modbus`]),ti=B(X).min(1),ni=V({asset:I().regex(q,Y),member:I().regex(q,Y)}).strict(),ri=V({model:I().min(1),id:I().regex(q,Y).optional(),count:L().int().positive().default(1),variation:L().min(0).max(1).default(0),parameters:W(I(),L().finite()).optional(),inputs:W(I().regex(q,Y),ni).optional(),starting_hours:L().finite().nonnegative().optional(),protocol_scope:ti.optional()}).strict(),ii=V({asset:I().min(1),ideal_cycle_s:L().finite().positive(),scrap_rate:L().finite().min(0).max(1).default(0),cycle_cv:L().finite().min(0).max(.5).default(.02),buffer_after:V({capacity:L().int().positive(),initial:L().int().nonnegative().default(0)}).strict().refine(e=>e.initial<=e.capacity,`Reduce initial to buffer capacity.`).optional()}).strict(),ai=V({source:G(`unlimited`),stations:B(ii).min(1)}).strict(),oi=K([`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`]),si=I().regex(/^([01]\d|2[0-3]):[0-5]\d$/,`Use HH:MM (00:00–23:59).`),ci=V({start:I().regex(/^(mon|tue|wed|thu|fri|sat|sun) ([01]\d|2[0-3]):[0-5]\d$/,`Use <day> HH:MM, e.g. mon 06:00.`).default(`mon 06:00`),timezone_offset_h:L().finite().min(-14).max(14).default(0),pattern:B(V({days:B(oi).min(1),start:si,end:si,breaks:B(V({start:si,minutes:L().finite().positive()}).strict()).default([])}).strict()).min(1),changeovers:B(V({every_parts:L().int().positive(),minutes:L().finite().positive(),station:I().min(1)}).strict()).default([])}).strict(),li=V({name:I().regex(q,Y),assets:B(ri).min(1),flow:ai.optional(),protocol_scope:ti.optional()}).strict(),ui=V({name:I().regex(q,Y),lines:B(li).min(1),protocol_scope:ti.optional()}).strict(),di=H([V({enterprise:I().regex(q,Y),site:I().regex(q,Y)}).strict(),V({prefix:I().regex(q,Y)}).strict()]),fi=V({maxAttempts:L().finite().int().min(0).default(0),initialDelayMs:L().finite().int().positive().default(1e3),maxDelayMs:L().finite().int().positive().default(3e4)}).strict(),pi=V({enabled:R().default(!1),deadband:L().finite().nonnegative().default(0)}).strict(),mi=K([`base`,`full`]),hi=V({embedded:R().default(!0),port:L().int().min(0).max(65535).default(1883),host:I().default(`127.0.0.1`),external:I().optional(),retain:R().default(!0),username:I().optional(),password:I().optional(),reconnect:fi.optional(),rbe:pi.optional(),metadata:mi.default(`base`),drain_budget:L().int().min(512).max(65536).optional(),batch_size:L().int().min(64).max(16384).optional(),broker_concurrency:L().int().min(10).max(5e3).optional()});function gi(e){return e.refine(e=>!(e.embedded&&e.external),{message:`Cannot use both 'embedded: true' and 'external' URL. Set 'embedded: false' when using an external broker.`}).refine(e=>!e.password||e.username,{message:`Cannot set 'password' without 'username'.`})}gi(hi);var _i=V({port:L().int().min(0).max(65535).default(Er),host:I().default(`127.0.0.1`),security:K([`none`]).default(`none`),buildInfo:V({productName:I().default(`Miravo`)}).strict().optional(),write_budget:L().int().min(512).max(65536).optional()}).strict(),vi=V({port:L().int().min(0).max(65535).default(Dr),host:I().default(`127.0.0.1`)}).strict(),yi=V({mqtt:gi(hi.strict()).optional(),opcua:_i.optional(),modbus:vi.optional()}).strict(),bi=V({max_members_per_model:L().int().positive().max(Pr).default(Mr),max_asset_count:L().int().positive().max(Nr).default(jr)}).strict(),xi=V({tick_interval_ms:L().int().min(10).default(1e3),max_step_s:L().finite().positive().default(1),max_substeps:L().int().min(1).default(60),time_multiplier:L().positive().max(1e3).default(1),random_faults:R().default(!0),seed:L().int().optional(),overrun_threshold_multiplier:L().min(1).max(10).optional(),limits:bi.optional()}).strict();V({kind:G(`MiravoTemplate`),version:G(`1`),name:I().min(1),description:I().optional(),namespace:di.optional(),areas:B(ui).min(1),protocols:yi.optional(),shifts:ci.optional(),settings:xi.optional()}).strict().superRefine((e,t)=>{let n=new Set,r=new Set;e.areas.forEach((e,i)=>{e.lines.forEach((e,a)=>{let o=[`areas`,i,`lines`,a];e.assets.forEach((e,r)=>{e.id&&(e.count!==1||n.has(e.id))&&t.addIssue({code:y.custom,path:[...o,`assets`,r],message:`Assignment id '${e.id}' must be unique with count: 1. Fix: use a unique id and count: 1.`}),e.id&&n.add(e.id)});let s=e.flow;(s?.stations??[]).forEach((n,i)=>{let a=[...o,`flow`,`stations`,i],c=e.assets.find(e=>e.id===n.asset);(!c||c.count!==1||r.has(n.asset))&&t.addIssue({code:y.custom,path:[...a,`asset`],message:`Invalid station '${n.asset}'. Fix: reference a unique assignment id with count: 1 in this same line.`}),r.add(n.asset),s&&i<s.stations.length-1&&!n.buffer_after&&t.addIssue({code:y.custom,path:a,message:`Station '${n.asset}' needs buffer_after. Fix: add buffer_after: { capacity: 1 }.`})})})});for(let n of e.shifts?.changeovers??[])r.has(n.station)||t.addIssue({code:y.custom,message:`Unknown changeover station '${n.station}'. Fix: reference a flow station id.`});let i=e.settings?.limits?.max_asset_count??1e4;for(let n=0;n<e.areas.length;n++){let r=e.areas[n];if(r)for(let e=0;e<r.lines.length;e++){let a=r.lines[e];if(a)for(let r=0;r<a.assets.length;r++){let o=a.assets[r];!o||o.count<=i||t.addIssue({code:y.custom,path:[`areas`,n,`lines`,e,`assets`,r,`count`],message:`Asset assignment count must be at most ${i}. Fix: reduce count or set settings.limits.max_asset_count higher.`})}}}});var Si=1e3,Z=V({correlationId:I().optional()}),Ci=I().trim().min(1).superRefine((e,t)=>{let n=ei(e);n&&t.addIssue({code:y.custom,message:n})}),wi=Z.extend({type:G(`spawn`),model:I().min(1),count:L().int().positive().max(jr),assetName:Ci.optional(),assetPrefix:Ci.optional(),protocolScope:ti.optional(),dryRun:R().optional()}),Ti=Z.extend({type:G(`removeAsset`),assetId:I().min(1)}),Ei=Z.extend({type:G(`setParameter`),assetId:I().min(1),parameter:I().min(1),value:L().finite()}),Di=Z.extend({type:G(`triggerFault`),assetId:I().min(1),fault:I().min(1)}),Oi=Z.extend({type:G(`clearFault`),assetId:I().min(1),fault:I().min(1)}),ki=Z.extend({type:G(`pause`)}),Ai=Z.extend({type:G(`resume`)}),ji=Z.extend({type:G(`setSpeed`),multiplier:L().positive().finite().max(Si)}),Mi=Z.extend({type:G(`unquarantine`),assetId:I().min(1)}),Ni=Z.extend({type:G(`invokeMethod`),assetId:I().min(1),method:I().min(1),arguments:W(I().min(1),H([L().finite(),I(),R()])).optional()}),Pi=Z.extend({type:G(`loadTemplate`),templatePath:I().min(1)}),Fi=Z.extend({type:G(`unloadTemplate`),templateId:I().min(1)}),Ii=Z.extend({type:G(`resetFactory`)}),Li=Z.extend({type:G(`enableAdapter`),adapter:I().min(1),config:W(I(),z()).optional()}),Ri=Z.extend({type:G(`disableAdapter`),adapter:I().min(1)}),zi=U(`type`,[wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri]),Bi=V({success:R(),command:I(),correlationId:I().optional(),message:I(),data:z().optional(),error:I().optional()}),Vi=`/api`,Hi=H([L().finite(),I(),R()]),Ui=er([L().finite(),L().finite()]),Wi=V({name:I().min(1),dataType:I().min(1),description:I().nullable()}),Gi=V({description:I().nullable(),inputArguments:B(Wi),outputArguments:B(Wi)}),Ki=V({id:I().min(1),assetType:I().min(1),browsePath:B(I().min(1)),lifecycleStage:I().min(1),operatingHours:L().finite().nonnegative(),activeFaults:B(I().min(1)),isQuarantined:R(),parameters:W(I().min(1),V({value:Hi,type:I().min(1),unit:I().optional()})),inputs:W(I().min(1),V({value:L().finite(),default:L().finite(),unit:I().optional(),binding:V({asset:I().min(1),member:I().min(1)}).nullable()})),members:W(I().min(1),V({value:Hi,quality:K([`good`,`bad`,`uncertain`]),timestamp:L().finite(),meta:V({kind:I().min(1),dataType:I().min(1),access:I().min(1),unit:I().nullable(),euRange:Ui.nullable()})})),methods:W(I().min(1),Gi)}),qi=V({name:I().min(1),description:I().nullable(),memberCount:L().int().nonnegative(),methodCount:L().int().nonnegative(),faultCount:L().int().nonnegative(),hasLifecycle:R(),lifecycleStageCount:L().int().nonnegative(),source:I().min(1)}),Ji=V({model:I().min(1),count:L().int().nonnegative(),variation:L().finite().nonnegative(),parameters:W(I().min(1),L().finite()).optional(),protocol_scope:B(X).optional()}),Yi=V({name:I().min(1),assets:B(Ji),protocol_scope:B(X).optional()}),Xi=V({name:I().min(1),lines:B(Yi),protocol_scope:B(X).optional()}),Zi=V({id:I().min(1),name:I().min(1),description:I().nullable(),category:I().min(1),models:B(I().min(1)),assetCount:L().int().nonnegative(),memberCount:L().int().nonnegative(),source:I().min(1)}),Qi=Zi,$i=Zi.extend({topology:B(Xi),namespace:V({enterprise:I().min(1).optional(),site:I().min(1).optional(),prefix:I().min(1).optional()}).optional(),settings:V({tickIntervalMs:L().int().positive().optional(),timeMultiplier:L().finite().positive().optional(),limits:V({maxMembersPerModel:L().int().positive().optional(),maxAssetCount:L().int().positive().optional()}).optional()}).optional()}),ea=K([`idle`,`running`,`paused`,`stopped`]),ta=V({events:B(U(`type`,[V({id:L().int().nonnegative(),type:G(`fault:triggered`),assetId:I().min(1),fault:I().min(1),effects:W(I(),z()),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`fault:cleared`),assetId:I().min(1),fault:I().min(1),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`lifecycle:changed`),assetId:I().min(1),from:I().min(1),to:I().min(1),operatingHours:L().finite().nonnegative(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`asset:maintenance`),assetId:I().min(1),from:I().min(1),to:I().min(1),operatingHours:L().finite().nonnegative(),reason:K([`manual`,`scheduled`]),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`asset:created`),assetId:I().min(1),assetType:I().min(1),browsePath:B(I().min(1)),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`asset:removed`),assetId:I().min(1),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:K([`template:loaded`,`template:unloaded`]),templateId:I().min(1),assetCount:L().int().nonnegative(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`engine:state-changed`),from:ea,to:ea,tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`engine:error`),context:I(),message:I(),fix:I().optional(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`integration:resource`),operationId:I().min(1),operationType:K([`apply`,`cleanup`]),templateId:I().min(1),targetLabel:I().min(1),hostname:I().min(1),phase:I().min(1),resourceType:I().min(1),resourceName:I().min(1),action:I().min(1),status:K([`success`,`failed`]),error:I().optional(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`integration:operation`),operationId:I().min(1),operationType:K([`apply`,`cleanup`]),templateId:I().min(1),targetLabel:I().min(1),hostname:I().min(1),applied:L().int().nonnegative(),failed:L().int().nonnegative(),duration:L().int().nonnegative(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()})])),nextCursor:L().int().nonnegative().nullable(),hasMore:R()}),na=`litmus-edge`,ra=W(X,Ir),ia=V({id:I().min(1),integrationId:I().min(1),label:I().min(1),hostname:I().min(1),apiTokenSet:R(),sourceHostname:I().min(1),exposedPorts:ra.optional(),lastUsedAt:L().int().nonnegative().optional()}).strict(),aa=V({targets:B(ia)}).strict(),oa=V({integrationId:I().min(1).default(na),label:I().min(1),hostname:I().min(1),apiToken:I().min(1),sourceHostname:I().min(1)}),sa=V({integrationId:I().min(1).optional(),label:I().min(1).optional(),hostname:I().min(1).optional(),apiToken:I().min(1).optional(),sourceHostname:I().min(1).optional()}),ca=V({targetId:I().min(1).optional(),hostname:I().min(1),apiToken:I().min(1).optional(),sourceHostname:I().min(1)}).superRefine((e,t)=>{!e.targetId&&!e.apiToken&&t.addIssue({code:y.custom,message:`apiToken is required when targetId is omitted.`,path:[`apiToken`]})}),la=U(`connected`,[V({connected:G(!0),hostname:I().min(1),sourceHostname:I().min(1),litmusEdgeVersion:I().min(1).optional(),warning:I().min(1).optional()}),V({connected:G(!1),error:I().min(1)})]),ua=K([`devices`,`models`,`assets`]),da=K([`create`,`update`,`replace`,`delete`,`noop`,`blocked`]),fa=K([`device`,`model`,`asset`,`param-sync`]),pa=K([`apply`,`cleanup`]),ma=K([`success`,`partial`,`blocked`,`noop`,`failed`]);K([`device`,`model`,`asset`,`param-sync`]),K([`create`,`update`,`replace`,`delete`]);var ha=V({area:I().min(1).optional(),line:I().min(1).optional(),asset:I().min(1).optional()}),ga=V({action:da,resourceType:fa,name:I().min(1),resourceId:I().min(1).optional(),protocol:X.optional(),endpoint:I().min(1).optional(),detail:I().min(1).optional(),blockReason:I().min(1).optional()}),_a=V({sourceMode:K([`static`,`managed`]),targetHost:I().min(1),sourceHostname:I().min(1).optional(),scope:B(ua),filters:ha,entries:B(ga)}),va=V({plan:_a}),ya=`Provide exactly one of 'templateId' (a running template) or 'assetId' (a running standalone asset).`;function ba(e,t){let n=(e,n)=>{if(e.code===`unrecognized_keys`&&e.keys.some(e=>e===`templateId`||e===`assetId`))return{message:t};if(e.code!==`invalid_union`)return{message:n.defaultError};let r=n.data,i=typeof r==`object`&&r?r:{},a=`templateId`in i;return a===`assetId`in i?{message:t}:{message:e.unionErrors[+!a]?.issues.map(e=>e.message).join(`; `)??t}};return H([V({...e,templateId:I().min(1)},{errorMap:n}).strict(),V({...e,assetId:I().min(1)},{errorMap:n}).strict()],{errorMap:n})}var xa=ba({targetId:I().min(1),protocol:X.optional(),scope:B(ua).optional(),ifUnmanaged:K([`fail`,`skip`]).optional(),exposedPorts:ra.optional()},ya),Sa=V({plan:_a,applied:L().int().nonnegative(),failed:L().int().nonnegative(),error:I().min(1).optional()}),Ca=ba({targetId:I().min(1),scope:B(ua).optional()},`Provide exactly one of 'templateId' or 'assetId'.`),wa=V({plan:_a,deleted:L().int().nonnegative(),failed:L().int().nonnegative(),error:I().min(1).optional()}),Ta=V({create:L().int().nonnegative(),update:L().int().nonnegative(),replace:L().int().nonnegative(),delete:L().int().nonnegative(),noop:L().int().nonnegative(),failed:L().int().nonnegative(),total:L().int().nonnegative()}),Ea=V({device:Ta,model:Ta,asset:Ta,"param-sync":Ta}),Da=V({operations:B(V({schemaVersion:G(1),operationId:I().min(1),operationType:pa,status:ma,factoryName:I().min(1),templateId:I().min(1).optional(),assetId:I().min(1).optional(),targetId:I().min(1),targetLabel:I().min(1),hostname:I().min(1),scope:B(I().min(1)),successCount:L().int().nonnegative(),failedCount:L().int().nonnegative(),blockedCount:L().int().nonnegative(),startedAt:L().int().nonnegative(),completedAt:L().int().nonnegative(),durationMs:L().int().nonnegative(),resourceCounts:Ea,error:I().min(1).optional()}).refine(e=>e.templateId===void 0!=(e.assetId===void 0),{message:`An operation record names exactly one of 'templateId' or 'assetId'.`})),total:L().int().nonnegative(),hasMore:R()}),Oa=V({type:pa.optional(),targetId:I().min(1).optional(),templateId:I().min(1).optional(),assetId:I().min(1).optional(),limit:hr.number().int().positive().max(500).optional(),offset:hr.number().int().nonnegative().optional()}),ka=V({cancelled:G(!0)}),Aa=V({operationId:I().min(1),type:pa,templateId:I().min(1).optional(),assetId:I().min(1).optional(),targetLabel:I().min(1),totalPlanned:L().int().nonnegative(),attempt:L().int().positive().optional(),maxAttempts:L().int().positive().optional()}),ja=V({operationId:I().min(1),type:pa,targetId:I().min(1).optional(),templateId:I().min(1).optional(),assetId:I().min(1).optional()}),Ma=V({operationId:I().min(1),phase:fa,total:L().int().nonnegative()}),Na=V({operationId:I().min(1),phase:fa,name:I().min(1),action:da,status:K([`success`,`failed`]),error:I().min(1).optional(),index:L().int().positive(),of:L().int().positive()}),Pa=V({operationId:I().min(1),applied:L().int().nonnegative().optional(),deleted:L().int().nonnegative().optional(),failed:L().int().nonnegative(),duration:L().int().nonnegative(),plan:_a}),Fa=Pa,Ia=Pa,La=V({operationId:I().min(1),attempt:L().int().positive(),maxAttempts:L().int().positive(),delayMs:L().int().nonnegative(),error:I().min(1)}),Ra=V({message:I().min(1)}),za=V({level:K([`info`,`warn`,`error`]),message:I().min(1),protocol:X.optional(),port:Ir.optional(),templatePort:Ir.optional()}),Ba=U(`event`,[V({event:G(`log`),data:za}),V({event:G(`started`),data:Aa}),V({event:G(`accepted`),data:ja}),V({event:G(`phase`),data:Ma}),V({event:G(`resource`),data:Na}),V({event:G(`complete`),data:Fa}),V({event:G(`cancelled`),data:Ia}),V({event:G(`retrying`),data:La}),V({event:G(`error`),data:Ra})]),Va=V({enabled:R(),port:L().int().positive().optional()}),Ha=V({asset:I().min(1),browsePath:I(),member:I().min(1),model:I().min(1),dataType:I().min(1),unit:I().optional(),euRange:er([L().finite(),L().finite()]).optional(),access:I().min(1),kind:K([`variable`,`property`]),protocols:W(I(),W(I(),z()))}),Ua=V({template:I().min(1).optional(),generatedAt:I().datetime(),protocols:W(I(),Va),tags:B(Ha),summary:V({totalTags:L().int().nonnegative(),totalAssets:L().int().nonnegative(),enabledProtocols:B(I().min(1))})}),Wa=V({name:I().min(1),description:I().nullable(),parameters:W(I().min(1),V({type:I().min(1),default:Hi,unit:I().optional()})),inputs:W(I().min(1),V({default:L().finite(),unit:I().optional(),description:I().optional()})).optional(),members:W(I().min(1),V({kind:I().min(1),dataType:I().min(1),access:I().min(1),unit:I().nullable(),euRange:Ui.nullable(),default:Hi.nullable()})),methods:W(I().min(1),Gi),faults:B(I().min(1)),lifecycle:V({stages:B(I().min(1)),totalHours:L().finite().nonnegative()}).nullable()}),Ga=V({status:K([`ok`,`fail`]),factoryState:J.shape.core.shape.state,tickCount:L().int().nonnegative(),mqttEnabled:R(),mqttConnected:R().nullable(),opcuaEnabled:R(),opcuaConnected:R().nullable(),modbusEnabled:R(),modbusConnected:R().nullable(),stalled:R(),reason:I().optional(),factoryName:I().min(1).optional(),processId:I().min(1).optional()}),Ka=V({reason:I().min(1).optional()}),qa=V({status:G(`shutting_down`)}),Ja=V({id:I().min(1)}),Ya=V({name:I().min(1)}),Xa=V({id:I().min(1)}),Za=V({operationId:I().min(1)}),Qa=V({id:I().min(1)}),$a=V({type:K([`fault:triggered`,`fault:cleared`,`lifecycle:changed`,`asset:maintenance`,`asset:created`,`asset:removed`,`template:loaded`,`template:unloaded`,`engine:state-changed`,`engine:error`,`integration:resource`,`integration:operation`]).optional(),assetId:I().min(1).optional(),limit:hr.number().int().positive().max(1e3).optional(),cursor:hr.number().int().nonnegative().optional()}),eo=hr.number().int().min(1).max(kr).optional(),to=V({host:I().min(1),protocol:X.optional(),modbusPort:eo,opcuaPort:eo,mqttPort:eo}),no=W(I(),z()),ro=W(I(),z());function Q(e){return`${Vi}${e}`}var io=[{method:`GET`,path:Q(`/openapi.json`),operationId:`openApiDocument`,auth:`none`,response:{kind:`json`,schema:ro},description:`Generated OpenAPI document for the Miravo admin API.`},{method:`GET`,path:Q(`/healthz`),operationId:`health`,auth:`none`,response:{kind:`json`,schema:Ga},description:`Liveness probe for the Miravo admin server.`},{method:`GET`,path:Q(`/readyz`),operationId:`readiness`,auth:`none`,response:{kind:`json`,schema:Ga},description:`Readiness probe for the Miravo admin server.`},{method:`GET`,path:Q(`/metrics`),operationId:`metrics`,auth:`required`,response:{kind:`json`,schema:J},description:`Engine metrics snapshot.`},{method:`GET`,path:Q(`/state`),operationId:`state`,auth:`required`,response:{kind:`json`,schema:Vr},description:`Engine state snapshot.`},{method:`GET`,path:Q(`/bootstrap`),operationId:`bootstrap`,auth:`none`,response:{kind:`json`,schema:Kr},description:`Console bootstrap payload.`},{method:`POST`,path:Q(`/commands`),operationId:`commands`,auth:`required`,body:zi,response:{kind:`json`,schema:Bi},description:`Execute an engine command.`},{method:`POST`,path:Q(`/shutdown`),operationId:`shutdown`,auth:`required`,body:Ka,response:{kind:`json`,schema:qa},description:`Request graceful shutdown.`},{method:`GET`,path:Q(`/assets/:id`),operationId:`assetDetail`,auth:`required`,params:Ja,response:{kind:`json`,schema:Ki},description:`Inspect a running asset.`},{method:`GET`,path:Q(`/models/:name`),operationId:`modelDetail`,auth:`required`,params:Ya,response:{kind:`json`,schema:Wa},description:`Inspect a registered model schema.`},{method:`GET`,path:Q(`/events`),operationId:`events`,auth:`required`,query:$a,response:{kind:`json`,schema:ta},description:`Read paginated event log entries.`},{method:`GET`,path:Q(`/catalog/models`),operationId:`catalogModels`,auth:`required`,response:{kind:`json`,schema:B(qi)},description:`List catalog models.`},{method:`GET`,path:Q(`/catalog/models/:name/le-dt.json`),operationId:`catalogModelLeDt`,auth:`required`,params:Ya,response:{kind:`json`,schema:no},description:`Download LE Digital Twin JSON for a catalog model.`},{method:`GET`,path:Q(`/catalog/models/:name/yaml`),operationId:`catalogModelYaml`,auth:`required`,params:Ya,response:{kind:`yaml`},description:`Read raw YAML for a catalog model.`},{method:`GET`,path:Q(`/catalog/models/:name`),operationId:`catalogModelDetail`,auth:`required`,params:Ya,response:{kind:`json`,schema:Wa},description:`Read catalog model schema.`},{method:`GET`,path:Q(`/catalog/templates/:id/le-template.json`),operationId:`catalogTemplateLeTemplateJson`,auth:`required`,params:Xa,query:to,response:{kind:`passthrough`},description:`Download LE template JSON export.`},{method:`GET`,path:Q(`/catalog/templates/:id/le-tags.csv`),operationId:`catalogTemplateLeTagsCsv`,auth:`required`,params:Xa,query:to,response:{kind:`passthrough`},description:`Download LE tags CSV export.`},{method:`GET`,path:Q(`/catalog/templates/:id/yaml`),operationId:`catalogTemplateYaml`,auth:`required`,params:Xa,response:{kind:`yaml`},description:`Read raw YAML for a catalog template.`},{method:`GET`,path:Q(`/catalog/templates/:id`),operationId:`catalogTemplateDetail`,auth:`required`,params:Xa,response:{kind:`json`,schema:$i},description:`Read catalog template detail.`},{method:`GET`,path:Q(`/catalog/templates`),operationId:`catalogTemplates`,auth:`required`,response:{kind:`json`,schema:B(Qi)},description:`List catalog templates.`},{method:`GET`,path:Q(`/templates`),operationId:`templates`,auth:`required`,response:{kind:`json`,schema:B(Hr)},description:`List templates loaded into the factory.`},{method:`GET`,path:Q(`/manifest`),operationId:`manifest`,auth:`required`,response:{kind:`json`,schema:Ua},description:`Read unified protocol manifest.`},{method:`POST`,path:Q(`/auth/login`),operationId:`authLogin`,auth:`none`,body:vr,response:{kind:`json`,schema:yr},description:`Authenticate and create an admin session.`},{method:`POST`,path:Q(`/auth/logout`),operationId:`authLogout`,auth:`none`,response:{kind:`json`,schema:xr},description:`Destroy the current admin session.`},{method:`PUT`,path:Q(`/auth/password`),operationId:`authPassword`,auth:`required`,body:br,response:{kind:`json`,schema:xr},description:`Change the admin password.`},{method:`GET`,path:Q(`/auth/status`),operationId:`authStatus`,auth:`none`,response:{kind:`json`,schema:Sr},description:`Check the current auth status.`},{method:`GET`,path:Q(`/ws`),operationId:`runtimeWebSocket`,auth:`required`,response:{kind:`passthrough`},description:`Upgrade to the runtime WebSocket stream.`},{method:`GET`,path:Q(`/integrations/le/operations`),operationId:`integrationOperations`,auth:`required`,query:Oa,response:{kind:`json`,schema:Da},description:`List persisted integration operation summaries, optionally for one template or asset.`},{method:`GET`,path:Q(`/integrations/le/targets`),operationId:`integrationTargets`,auth:`required`,response:{kind:`json`,schema:aa},description:`List saved LE targets.`},{method:`POST`,path:Q(`/integrations/le/targets`),operationId:`integrationTargetCreate`,auth:`required`,body:oa,response:{kind:`json`,schema:ia},description:`Create an LE target.`},{method:`POST`,path:Q(`/integrations/le/targets/test`),operationId:`integrationConnectionTest`,auth:`required`,body:ca,response:{kind:`json`,schema:la},description:`Test LE target connectivity.`},{method:`GET`,path:Q(`/integrations/le/targets/:id`),operationId:`integrationTargetDetail`,auth:`required`,params:Qa,response:{kind:`json`,schema:ia},description:`Read one LE target.`},{method:`PUT`,path:Q(`/integrations/le/targets/:id`),operationId:`integrationTargetById`,auth:`required`,params:Qa,body:sa,response:{kind:`json`,schema:ia},description:`Update one LE target.`},{method:`DELETE`,path:Q(`/integrations/le/targets/:id`),operationId:`integrationTargetDelete`,auth:`required`,params:Qa,response:{kind:`json`,schema:V({message:I().min(1)})},description:`Delete one LE target.`},{method:`POST`,path:Q(`/integrations/le/plan`),operationId:`integrationPlan`,auth:`required`,body:xa,response:{kind:`json`,schema:va},description:`Preview applying a running template or standalone asset to an LE target.`},{method:`POST`,path:Q(`/integrations/le/apply`),operationId:`integrationApply`,auth:`required`,body:xa,response:{kind:`json`,schema:Sa},additionalSuccessResponses:{207:Sa},description:`Apply a running template or standalone asset to an LE target.`},{method:`POST`,path:Q(`/integrations/le/cleanup/plan`),operationId:`integrationCleanupPlan`,auth:`required`,body:Ca,response:{kind:`json`,schema:va},description:`Preview removing what a template or standalone asset of this factory applied to an LE target.`},{method:`POST`,path:Q(`/integrations/le/cleanup`),operationId:`integrationCleanup`,auth:`required`,body:Ca,response:{kind:`json`,schema:wa},additionalSuccessResponses:{207:wa},description:`Remove what a template or standalone asset of this factory applied to an LE target.`},{method:`POST`,path:Q(`/integrations/le/operations/:operationId/cancel`),operationId:`integrationOperationCancel`,auth:`required`,params:Za,response:{kind:`json`,schema:ka},description:`Cancel an in-flight streaming LE operation.`},{method:`POST`,path:Q(`/integrations/le/apply/stream`),operationId:`integrationApplyStream`,auth:`required`,body:xa,response:{kind:`passthrough`},description:`Stream LE apply progress over SSE.`},{method:`POST`,path:Q(`/integrations/le/cleanup/stream`),operationId:`integrationCleanupStream`,auth:`required`,body:Ca,response:{kind:`passthrough`},description:`Stream LE cleanup progress over SSE.`}],ao=V({code:K([`UNAUTHORIZED`,`NOT_FOUND`,`INVALID_REQUEST`,`INTERNAL_ERROR`]),message:I(),hint:I().optional()}),oo={UNAUTHORIZED:401,NOT_FOUND:404,INVALID_REQUEST:400,INTERNAL_ERROR:500},so=class extends Error{code;status;hint;constructor(e){super(e.message),this.name=`ApiError`,this.code=e.code,this.status=e.status??oo[e.code],this.hint=e.hint}static is(e){return e instanceof Error&&e.name===`ApiError`}};function co(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function lo(e,t){return e?._def?.typeName===t}function uo(e,t){let n=e.ZodType.prototype[t];e.ZodType.prototype[t]=function(...e){let t=n.apply(this,e);return t._def.openapi=this._def.openapi,t}}function fo(e){if(e.ZodType.prototype.openapi!==void 0)return;e.ZodType.prototype.openapi=function(e,t){let n=(typeof e==`string`?t:e)??{},{param:r}=n,i=co(n,[`param`]),a=Object.assign(Object.assign({},this._def.openapi?._internal),typeof e==`string`?{refId:e}:void 0),o=Object.assign(Object.assign(Object.assign({},this._def.openapi?.metadata),i),this._def.openapi?.metadata?.param||r?{param:Object.assign(Object.assign({},this._def.openapi?.metadata?.param),r)}:void 0),s=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(a).length>0?{_internal:a}:void 0),Object.keys(o).length>0?{metadata:o}:void 0)}));if(lo(this,`ZodObject`)){let e=this.extend;s.extend=function(...t){let n=e.apply(this,t);return n._def.openapi={_internal:{extendedFrom:this._def.openapi?._internal?.refId?{refId:this._def.openapi?._internal?.refId,schema:this}:this._def.openapi?._internal?.extendedFrom},metadata:n._def.openapi?.metadata},n}}return s},uo(e,`optional`),uo(e,`nullable`),uo(e,`default`),uo(e,`transform`),uo(e,`refine`);let t=e.ZodObject.prototype.deepPartial;e.ZodObject.prototype.deepPartial=function(){let e=this._def.shape(),n=t.apply(this),r=n._def.shape();return Object.entries(r).forEach(([t,n])=>{n._def.openapi=e[t]?._def?.openapi}),n._def.openapi=void 0,n};let n=e.ZodObject.prototype.pick;e.ZodObject.prototype.pick=function(...e){let t=n.apply(this,e);return t._def.openapi=void 0,t};let r=e.ZodObject.prototype.omit;e.ZodObject.prototype.omit=function(...e){let t=r.apply(this,e);return t._def.openapi=void 0,t}}var po=class{constructor(e){this.parents=e,this._definitions=[]}get definitions(){return[...this.parents?.flatMap(e=>e.definitions)??[],...this._definitions]}register(e,t){let n=this.schemaWithRefId(e,t);return this._definitions.push({type:`schema`,schema:n}),n}registerParameter(e,t){let n=this.schemaWithRefId(e,t),r=n._def.openapi?.metadata,i=n.openapi(Object.assign(Object.assign({},r),{param:Object.assign(Object.assign({},r?.param),{name:r?.param?.name??e})}));return this._definitions.push({type:`parameter`,schema:i}),i}registerPath(e){this._definitions.push({type:`route`,route:e})}registerWebhook(e){this._definitions.push({type:`webhook`,webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:`component`,componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}};fo(_r),new po,U(`type`,[wi.openapi(`SpawnCommand`),Ti.openapi(`RemoveAssetCommand`),Ei.openapi(`SetParameterCommand`),Di.openapi(`TriggerFaultCommand`),Oi.openapi(`ClearFaultCommand`),ki.openapi(`PauseCommand`),Ai.openapi(`ResumeCommand`),ji.openapi(`SetSpeedCommand`),Mi.openapi(`UnquarantineCommand`),Ni.openapi(`InvokeMethodCommand`),Pi.openapi(`LoadTemplateCommand`),Fi.openapi(`UnloadTemplateCommand`),Ii.openapi(`ResetFactoryCommand`),Li.openapi(`EnableAdapterCommand`),Ri.openapi(`DisableAdapterCommand`)]).openapi(`EngineCommand`);var mo=new Map(io.map(e=>[`${e.method} ${e.path}`,e]));function $(e,t){let n=mo.get(`${e} ${t}`);if(!n)throw Error(`Missing admin route definition for ${e} ${t}`);return n}var ho={assetDetail:$(`GET`,`/api/assets/:id`),authLogin:$(`POST`,`/api/auth/login`),authLogout:$(`POST`,`/api/auth/logout`),authPassword:$(`PUT`,`/api/auth/password`),authStatus:$(`GET`,`/api/auth/status`),bootstrap:$(`GET`,`/api/bootstrap`),catalogModelDetail:$(`GET`,`/api/catalog/models/:name`),catalogModelLeDt:$(`GET`,`/api/catalog/models/:name/le-dt.json`),catalogModels:$(`GET`,`/api/catalog/models`),catalogModelYaml:$(`GET`,`/api/catalog/models/:name/yaml`),catalogTemplateDetail:$(`GET`,`/api/catalog/templates/:id`),catalogTemplateLeTagsCsv:$(`GET`,`/api/catalog/templates/:id/le-tags.csv`),catalogTemplateLeTemplateJson:$(`GET`,`/api/catalog/templates/:id/le-template.json`),catalogTemplates:$(`GET`,`/api/catalog/templates`),catalogTemplateYaml:$(`GET`,`/api/catalog/templates/:id/yaml`),commands:$(`POST`,`/api/commands`),events:$(`GET`,`/api/events`),health:$(`GET`,`/api/healthz`),integrationApply:$(`POST`,`/api/integrations/le/apply`),integrationApplyStream:$(`POST`,`/api/integrations/le/apply/stream`),integrationCleanup:$(`POST`,`/api/integrations/le/cleanup`),integrationCleanupPlan:$(`POST`,`/api/integrations/le/cleanup/plan`),integrationCleanupStream:$(`POST`,`/api/integrations/le/cleanup/stream`),integrationConnectionTest:$(`POST`,`/api/integrations/le/targets/test`),integrationOperationCancel:$(`POST`,`/api/integrations/le/operations/:operationId/cancel`),integrationOperations:$(`GET`,`/api/integrations/le/operations`),integrationPlan:$(`POST`,`/api/integrations/le/plan`),integrationTargetById:$(`PUT`,`/api/integrations/le/targets/:id`),integrationTargetCreate:$(`POST`,`/api/integrations/le/targets`),integrationTargetDelete:$(`DELETE`,`/api/integrations/le/targets/:id`),integrationTargetDetail:$(`GET`,`/api/integrations/le/targets/:id`),integrationTargets:$(`GET`,`/api/integrations/le/targets`),manifest:$(`GET`,`/api/manifest`),metrics:$(`GET`,`/api/metrics`),modelDetail:$(`GET`,`/api/models/:name`),openApiDocument:$(`GET`,`/api/openapi.json`),readiness:$(`GET`,`/api/readyz`),runtimeWebSocket:$(`GET`,`/api/ws`),shutdown:$(`POST`,`/api/shutdown`),state:$(`GET`,`/api/state`),templates:$(`GET`,`/api/templates`)},go=`miravo:console-username`;function _o(){try{let e=sessionStorage.getItem(go);return typeof e==`string`&&e.length>0?e:``}catch{return``}}function vo(e){try{e!==null&&e.length>0?sessionStorage.setItem(go,e):sessionStorage.removeItem(go)}catch{}}var yo=new $e({defaultOptions:{queries:{staleTime:3e4,gcTime:10*6e4,retry:(e,t)=>{if(t instanceof Error&&t.message===`Session expired`)return!1;if(so.is(t)){let e=t.status;if(e>=400&&e<500)return!1}return e<2},refetchOnWindowFocus:!1}}}),bo={catalog:{templates:()=>[`catalog`,`templates`],models:()=>[`catalog`,`models`],templateDetail:e=>[`catalog`,`template`,e],modelSchema:e=>[`catalog`,`model-schema`,e],modelSchemasBatch:e=>[`catalog`,`model-schemas-batch`,e]},spawnPreviewAll:[`spawn`,`preview`],spawnPreview:(e,t,n,r)=>[`spawn`,`preview`,e,t,n,r],events:(e,t)=>[`events`,e,t],tags:{manifest:e=>[`tags`,`manifest`,e]},integrations:{targets:()=>[`integrations`,`targets`],operationsList:()=>[`integrations`,`operations`,`list`],operationsFactory:()=>[`integrations`,`operations`,`factory`],plan:(e,t)=>[`integrations`,`plan`,e,t],operationsForTarget:e=>[`integrations`,`operations`,`target`,e],operations:()=>[`integrations`,`operations`]},assets:{detail:e=>[`assets`,e]},floor:{state:()=>[`floor`,`state`]}},xo=`miravo:query-cache:v2`,So=5*6e4,Co=bo.integrations.targets(),wo=`bootstrap`,To=!0;function Eo(e){try{let t=sessionStorage.getItem(xo);if(!t)return;let n=JSON.parse(t);if(typeof n!=`object`||!n)return;let r=n;if(typeof r.timestamp!=`number`)return;if(Date.now()-r.timestamp>So){sessionStorage.removeItem(xo);return}Ae(e,r.state)}catch{}}function Do(e){try{let t=ke(e,{shouldDehydrateQuery:e=>e.state.status===`success`&&e.queryKey[0]!==wo&&!(e.queryKey[0]===Co[0]&&e.queryKey[1]===Co[1])}),n={timestamp:Date.now(),state:t};sessionStorage.setItem(xo,JSON.stringify(n))}catch{}}function Oo(e){let t=null,n=e.getQueryCache().subscribe(()=>{To&&(t&&clearTimeout(t),t=setTimeout(()=>{To&&Do(e)},500))});return()=>{t&&clearTimeout(t),n()}}function ko(){try{sessionStorage.removeItem(xo)}catch{}}function Ao(){To=!0}function jo(){To=!1}var Mo=(void 0)?.trim()||`/api`;function No(e,t){return`${e.trim().replace(/\/+$/,``)||`/api`}${t.startsWith(`/`)?t:`/${t}`}`}function Po(){jo(),yo.cancelQueries(),yo.setQueryData([`bootstrap`],{authenticated:!1}),yo.removeQueries({predicate:e=>e.queryKey[0]!==`bootstrap`}),ko(),ft(),vo(null)}function Fo(){typeof window>`u`||(Po(),window.location.pathname!==`/login`&&window.location.replace(`/login`))}var Io=class extends Error{result;constructor(e){super(e.message),this.name=`CommandError`,this.result=e}};function Lo(e,t){let n=`${e} ${t}`;return e===502||e===503||e===504?`${n} — the Miravo server may not be running, or a reverse proxy cannot reach it.`:n}async function Ro(e){try{let t=await e.json(),n=ao.safeParse(t);if(n.success)return new so({code:n.data.code,status:e.status,message:n.data.message,hint:n.data.hint})}catch{}return Error(Lo(e.status,e.statusText))}async function zo(e,t){return Ho(`/auth/login`,ho.authLogin,{body:{username:e,password:t}})}async function Bo(){await Ho(`/auth/logout`,ho.authLogout)}function Vo(e,t){if(e.response.kind!==`json`)throw Error(`requestJSON requires a JSON route definition for ${e.method} ${e.path}`);return e.additionalSuccessResponses?.[t]??e.response.schema}async function Ho(e,t,n={}){let{body:r,init:i}=n,a={method:t.method,credentials:`include`,...i};if(t.body){let e=t.body.safeParse(r);if(!e.success)throw Error(`Invalid request for ${t.method} ${t.path}: ${e.error.message}`);a.headers={"content-type":`application/json`,...i?.headers??{}},a.body=JSON.stringify(e.data)}else if(r!==void 0)throw Error(`Route ${t.method} ${t.path} does not accept a JSON body.`);let o=await fetch(No(Mo,e),a);if(o.status===401&&t.auth===`required`)throw Fo(),Error(`Session expired`);if(!o.ok)throw await Ro(o);let s;try{s=await o.json()}catch{throw Error(`Invalid JSON response for ${t.method} ${t.path}`)}let c=Vo(t,o.status).safeParse(s);if(!c.success)throw Error(`Invalid response for ${t.method} ${t.path}: ${c.error.message}`);return c.data}async function Uo(e,t){return Ho(`/auth/password`,ho.authPassword,{body:{oldPassword:e,newPassword:t}})}async function Wo(){return Ho(`/bootstrap`,ho.bootstrap)}async function Go(e,t){return Ho(e,t)}async function Ko(e){let t=await Ho(`/commands`,ho.commands,{body:e});if(!t.success)throw new Io(t);return t}async function qo(e,t){if(t.response.kind!==`passthrough`)throw Error(`fetchBlob requires a passthrough route definition for ${t.method} ${t.path}`);let n=await fetch(No(Mo,e),{credentials:`include`});if(n.status===401&&t.auth===`required`)throw Fo(),Error(`Session expired`);if(!n.ok)throw Error(Lo(n.status,n.statusText));return n.blob()}async function Jo(e,t){if(t.response.kind!==`yaml`)throw Error(`fetchText requires a YAML route definition for ${t.method} ${t.path}`);let n=await fetch(No(Mo,e),{credentials:`include`});if(n.status===401&&t.auth===`required`)throw Fo(),Error(`Session expired`);if(!n.ok)throw Error(Lo(n.status,n.statusText));return n.text()}export{I as $,Qr as A,wr as B,so as C,ve as Ct,ni as D,r as Dt,Vi as E,i as Et,Tr as F,R as G,Ar as H,Er as I,ir as J,U as K,Or as L,ei as M,Xr as N,X as O,Dr as P,W as Q,q as R,ho as S,se as St,Ba as T,o as Tt,Cr as U,Fr as V,B as W,L as X,G as Y,V as Z,Oo as _,l as _t,qo as a,mt as at,vo as b,m as bt,Wo as c,Ke as ct,Ko as d,Be as dt,er as et,Fo as f,h as ft,Eo as g,pe as gt,Ao as h,d as ht,Po as i,ft as it,$r as j,ti as k,zo as l,qe as lt,No as m,be as mt,Io as n,z as nt,Go as o,_t as ot,Ho as p,xe as pt,K as q,Uo as r,y as rt,Jo as s,ot as st,Mo as t,H as tt,Bo as u,Ue as ut,bo as v,fe as vt,ao as w,f as wt,_o as x,p as xt,yo as y,oe as yt,Mr as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./catalog-BMLSbdye.js";export{e as CatalogPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./control-B-TcWj5c.js";export{e as ControlPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./events-Dz_zsLGE.js";export{e as EventsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./factory-CBXx3oBo.js";export{e as FactoryPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{ot as n}from"./vendor-ui-D8j69UH4.js";import{S as r,o as i,ot as a,v as o,y as s}from"./api-tM5PSXjr.js";import{f as c,t as l}from"./useQuery-smgfSdOx.js";import{t as u,u as d}from"./proxy-CWZabK8f.js";import{t as f}from"./AnimatePresence-BSSlw02V.js";import{i as p,n as m,r as h}from"./dist-xY0pK9Wy.js";import{n as g,s as _}from"./chunk-OE4NN4TA-DBWZidbW.js";import{a as v,i as y,n as b,o as ee,r as x,t as te}from"./dialog-B5PqrKVw.js";import{t as S}from"./shallow-Cin0mLuv.js";import{C,S as ne,T as w,c as re,d as T,g as E,h as D,l as O,m as k,p as A,s as j,u as M,v as N,w as P,y as ie}from"./format-Bx7DF-TB.js";import{n as F,t as I}from"./utils-XFKvwlFT.js";import{t as L}from"./activity-Cy_niK56.js";import{n as R,r as z,t as ae}from"./server-BVem_egD.js";import{c as oe,i as se,n as ce,s as le,t as ue}from"./dropdown-menu-B_MMNbTy.js";import{i as de,n as fe,t as pe}from"./catalog-template-icons-DGyxSm-F.js";import{t as me}from"./chevron-down-x70Pto6j.js";import{t as he}from"./chevron-right-CrNKVFcI.js";import{n as ge,t as _e}from"./circle-x-6JtFdy1_.js";import{a as ve,c as ye,i as be,l as xe,o as Se,p as Ce,s as we,t as Te,u as Ee}from"./integration-api-iM6SWQ6d.js";import{t as De}from"./protocol-card-Cp8O59cX.js";import{t as Oe}from"./copy-button-CSUP1VjU.js";import{n as ke,r as Ae,t as je}from"./source-host-miravo-B8eM2IHw.js";import{i as Me,n as Ne,t as Pe}from"./registry-Kj-oMlVm.js";import{t as B}from"./loader-circle-DjgHgHHl.js";import{c as Fe,i as Ie,o as Le,t as Re}from"./use-engine-command-mutation-oLQW2r4F.js";import{t as ze}from"./plus-Cl4Ay5Ry.js";import{t as Be}from"./radio-BxpVYiyS.js";import{t as Ve}from"./query-fetch-error-CWLZA2L5.js";import{t as He}from"./rocket-KZ5oHK1G.js";import{a as Ue,f as We,i as Ge,n as Ke,o as qe,r as Je}from"./export-tab-BS4GlLBV.js";import{t as Ye}from"./trash-2-BH9HDsZv.js";import{t as Xe}from"./triangle-alert-DoAwrRgk.js";import{i as V,n as H,t as U}from"./tooltip-B3vOB1Vu.js";import{n as Ze,t as Qe}from"./use-transition-navigate-BDkvJJsk.js";import{t as $e}from"./badge-Bk1DaL6C.js";import{n as et}from"./transition-types-BKZuWApE.js";import{t as tt}from"./label-2sIXTEUK.js";import{n as nt,t as rt}from"./get-error-message-CEvauOXv.js";import{i as W,n as G,r as K,t as it}from"./console-panel-Cg2sBJcN.js";import{i as at,n as ot,r as st,t as ct}from"./tabs-Ch_VG8_S.js";import{a as lt,i as ut,n as dt,o as ft,r as pt,s as mt,t as ht}from"./combobox-B8h0-NHs.js";import{c as gt,i as q,n as _t,s as vt,t as yt}from"./select-BWlrSYlA.js";import{a as J,c as bt,i as xt,n as St,o as Ct,r as wt,s as Tt}from"./select-display-items-DN2G8DNG.js";import{t as Et}from"./checkbox-DEAkDfFr.js";import{n as Dt,r as Ot,t as kt}from"./integration-targets-Byvdd3Or.js";var At=F(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),jt=F(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),Mt=F(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),Nt=F(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Pt=F(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Ft=F(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),It=F(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),Lt=F(`component`,[[`path`,{d:`M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z`,key:`1uwlt4`}],[`path`,{d:`M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z`,key:`10291m`}],[`path`,{d:`M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z`,key:`1tqoq1`}],[`path`,{d:`M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z`,key:`1x6lto`}]]),Rt=F(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),zt=F(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Bt=F(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),Vt=F(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Ht=F(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),Y=e(t(),1),X=n();function Z({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`skeleton`,className:I(`animate-pulse rounded-[var(--miravo-radius-tight)] bg-muted`,e),...t})}var Ut=`https://miravo.dev/docs`;function Wt(){let{adapters:e,metrics:t}=a(S(e=>({adapters:e.availableAdapters,metrics:e.adapterMetrics}))),n=e.filter(e=>e.enabled&&!e.pending&&e.endpoint),r=e.filter(e=>!n.includes(e)),i=e=>t.find(t=>t.name===e)?.metrics.clients?.active??0,o=n.reduce((e,t)=>e+i(t.name),0);return(0,X.jsxs)(it,{id:`connect`,icon:Bt,title:`Connect`,description:`Point a client here to read live values.`,aside:(0,X.jsxs)(W,{tone:o>0?`live`:n.length>0?`idle`:`off`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:o}),(0,X.jsx)(K,{children:o===1?`client`:`clients`})]}),bodyClassName:`gap-2`,footer:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(g,{to:`/control`,className:G,children:[`Configure protocols`,(0,X.jsx)(z,{className:`size-3`,"aria-hidden":!0})]}),(0,X.jsxs)(`a`,{href:`${Ut}/protocols`,target:`_blank`,rel:`noopener noreferrer`,className:I(G,`ml-auto`),children:[(0,X.jsx)(jt,{className:`size-3`,"aria-hidden":!0}),`Protocol docs`]})]}),children:[n.length===0&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No protocol is serving yet.`}),n.map(e=>{let t=i(e.name),n=De[e.name]??e.name;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 rounded-[var(--miravo-radius-stadium-sm)] border border-muted-foreground/20 bg-background/40 px-3 py-2.5 transition-colors hover:border-muted-foreground/25`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:I(`size-1.5 shrink-0 rounded-full`,t>0?`bg-success`:`bg-muted-foreground/55`)}),(0,X.jsx)(`span`,{className:`text-sm font-medium tracking-tight`,children:n}),(0,X.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:t>0?`text-foreground`:void 0,children:t}),` `,`connected`]})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 pl-3.5`,children:[(0,X.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.endpoint}),(0,X.jsx)(Oe,{value:e.endpoint??``,label:`Copy ${n} endpoint`})]})]},e.name)}),r.length>0&&(0,X.jsxs)(`p`,{className:`pt-1 text-xs text-muted-foreground`,children:[r.map(e=>De[e.name]??e.name).join(`, `),` `,r.length===1?`is`:`are`,` off.`]})]})}var Gt=[`devices`,`models`,`assets`],Kt=[`assets`,`models`,`devices`],qt={devices:`DeviceHub devices`,models:`Digital Twins models`,assets:`Digital Twins instances`},Jt={devices:{apply:`DeviceHub device records and settings on Litmus Edge.`,cleanup:`Remove DeviceHub device records managed from Miravo.`},models:{apply:`Digital Twins model definitions synced to the integration.`,cleanup:`Remove Digital Twins model definitions created by Miravo.`},assets:{apply:`Digital Twins instances bound to DeviceHub devices.`,cleanup:`Remove Digital Twins instances deployed for this target.`}},Yt=`Miravo calls this API.`,Xt={assets:`models`};function Zt(e,t){let n=new Set(e);if(n.has(t)){n.delete(t);for(let[e,r]of Object.entries(Xt))r===t&&n.delete(e)}else{n.add(t);let e=Xt[t];e&&n.add(e)}return n}var Qt=[{value:`fail`,title:`Fail if unmanaged exists`,hint:`Stop if the target has unmanaged resources.`},{value:`skip`,title:`Skip unmanaged resources`,hint:`Only update resources managed by Miravo.`}];function $t({open:e,onOpenChange:t,isApply:n,scopeOptions:r,scope:i,onToggleScope:a,ifUnmanaged:o,onIfUnmanagedChange:s}){let c=(0,Y.useId)(),l=`if-unmanaged-${c}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`group flex w-full items-center justify-between gap-2 rounded-[var(--miravo-radius-tight)] bg-muted/40 px-2.5 py-2 text-left text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground aria-expanded:bg-muted/55 aria-expanded:text-foreground`,onClick:()=>t(!e),"aria-expanded":e,children:[`Advanced`,(0,X.jsx)(me,{className:I(`size-3.5 shrink-0 text-muted-foreground transition-transform ease-out group-hover:text-foreground/80`,e?`duration-500 rotate-180 text-foreground/80`:`duration-280`),"aria-hidden":!0})]}),(0,X.jsxs)(u.div,{initial:!1,animate:{maxHeight:e?520:0,opacity:+!!e},transition:{maxHeight:{duration:e?.52:.28,ease:e?[.16,1,.3,1]:[.4,0,.2,1]},opacity:{duration:e?.42:.24,ease:e?[.16,1,.3,1]:[.4,0,.2,1]}},className:I(`overflow-hidden`,!e&&`pointer-events-none`),"aria-hidden":!e,inert:!e,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-1 pt-px`,children:r.map(e=>{let t=Object.entries(Xt).find(([t,n])=>n===e)?.[0],r=t!==void 0&&i.has(t),o=n?Jt[e].apply:Jt[e].cleanup;return(0,X.jsxs)(tt,{htmlFor:`scope-${e}`,className:I(`flex min-h-9 cursor-pointer items-start gap-2 rounded-[var(--miravo-radius-tight)] border border-border/40 bg-muted/10 px-2.5 py-1.5 text-[11px] transition-colors`,r?`opacity-95`:`hover:bg-muted/25`),children:[(0,X.jsx)(`span`,{className:`pt-0.5`,children:(0,X.jsx)(Et,{id:`scope-${e}`,checked:i.has(e),disabled:r,onCheckedChange:()=>a(e)})}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 leading-snug`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:qt[e]}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-[11px] font-normal leading-tight text-muted-foreground`,children:o})]}),r?(0,X.jsx)(`span`,{className:`shrink-0 self-start rounded-[var(--miravo-radius-tight)] border border-primary/35 bg-primary/10 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wide text-primary`,title:`Required when Digital Twins instances are selected (models must stay in scope).`,children:`Required`}):null]},e)})}),n&&(0,X.jsxs)(`div`,{className:`mt-2.5 space-y-1.5 border-t border-border/40 pt-2`,children:[(0,X.jsx)(`p`,{id:`${c}-legend`,className:`text-[11px] font-medium uppercase tracking-wide text-foreground/80`,children:`Collision policy`}),(0,X.jsx)(`div`,{role:`radiogroup`,"aria-labelledby":`${c}-legend`,className:`flex flex-col gap-1`,children:Qt.map(e=>(0,X.jsxs)(tt,{htmlFor:`if-unmanaged-${e.value}`,className:I(`flex cursor-pointer items-start gap-2 rounded-[var(--miravo-radius-tight)] border px-2.5 py-2 text-[11px] transition-colors`,o===e.value?`border-primary/45 bg-primary/8`:`border-border/40 bg-muted/10 hover:bg-muted/25`),children:[(0,X.jsx)(`input`,{id:`if-unmanaged-${e.value}`,type:`radio`,name:l,value:e.value,checked:o===e.value,onChange:()=>s(e.value),className:`mt-0.5 size-3.5 shrink-0 accent-primary`}),(0,X.jsxs)(`span`,{className:`min-w-0`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`mt-px block text-[11px] leading-tight text-foreground/74`,children:e.hint})]})]},e.value))})]})]})]})}function en({label:e,help:t,mono:n=!1,children:r}){return(0,X.jsxs)(`div`,{className:`grid grid-cols-2 items-start gap-x-4 border-b border-border/35 py-2.5 first:pt-0`,children:[t?(0,X.jsx)(`dt`,{className:`min-w-0 pt-px`,children:(0,X.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium leading-snug text-muted-foreground`,children:e}),(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{type:`button`,className:`inline-flex size-5 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`About ${e}`,children:(0,X.jsx)(Ce,{className:`size-3`,"aria-hidden":!0})}),(0,X.jsx)(H,{side:`top`,align:`start`,className:`max-w-xs text-left`,children:t})]})]})}):(0,X.jsx)(`dt`,{className:`min-w-0 pt-px text-[11px] font-medium text-muted-foreground`,children:e}),n?(0,X.jsx)(`dd`,{className:`min-w-0 break-all font-mono text-[11px] leading-normal text-foreground/90`,children:r}):(0,X.jsx)(`dd`,{className:`min-w-0 wrap-break-word font-medium text-foreground`,children:r})]})}function tn({targetId:e,subject:t,result:n}){return{targetId:e,...t.kind===`template`?{templateId:t.templateId}:{assetId:t.assetId,protocol:t.protocol},scope:n.scope,ifUnmanaged:n.ifUnmanaged,exposedPorts:n.exposedPorts}}function nn({targetId:e,subject:t,result:n}){return{targetId:e,...t.kind===`template`?{templateId:t.templateId}:{assetId:t.assetId},scope:n.scope}}var rn=/^\(?unchanged\)?$/i,an=/^device=(\S+)/;function on(e){let t=e.blockReason??e.detail;if(!(!t||rn.test(t)))return t.replace(/^\((.*)\)$/,`$1`)}function sn(e){let t=new Map;for(let n of e)n.resourceType===`param-sync`&&t.set(n.name,n);let n=[],r=new Set;for(let i of e){if(i.resourceType===`param-sync`)continue;let e=i.resourceType===`asset`?t.get(i.name):void 0;e&&r.add(i.name);let a=e!==void 0&&i.action===`noop`&&e.action!==`noop`;n.push({action:a?e.action:i.action,resourceType:i.resourceType,name:i.name,protocol:i.protocol,note:a?`device binding changes`:on(i),boundDevice:e?.detail?.match(an)?.[1]})}for(let[e,i]of t)r.has(e)||n.push({action:i.action,resourceType:`asset`,name:e,note:on(i),boundDevice:i.detail?.match(an)?.[1]});return n}function cn(e){let t=new Map;for(let n of e){let e=t.get(n.action);e?e.push(n):t.set(n.action,[n])}return t}function ln(e){return sn(e).filter(e=>e.action!==`noop`&&e.action!==`blocked`).length}var un={create:{label:`Create`,phrase:`to create`,dot:`bg-success`,text:`text-success`},update:{label:`Update`,phrase:`to update`,dot:`bg-info`,text:`text-info`},replace:{label:`Replace`,phrase:`to replace`,dot:`bg-chart-2`,text:`text-chart-2`},delete:{label:`Remove`,phrase:`to remove`,dot:`bg-destructive`,text:`text-destructive`},blocked:{label:`Skipped`,phrase:`skipped`,dot:`bg-warning`,text:`text-warning`},noop:{label:`Unchanged`,phrase:`unchanged`,dot:`bg-muted-foreground/40`,text:`text-muted-foreground`}},dn=[`create`,`update`,`replace`,`delete`,`noop`],fn=[`create`,`update`,`replace`,`delete`],pn=6,mn={device:[`device`,`devices`],model:[`twin model`,`twin models`],asset:[`twin instance`,`twin instances`]};function hn(e,[t,n]){return`${e} ${e===1?t:n}`}function gn(e){let t=new Map;for(let n of e){let e=t.get(n.resourceType);e?e.push(n):t.set(n.resourceType,[n])}return[...t]}function _n(e){return gn(e).map(([e,t])=>hn(t.length,mn[e])).join(` · `)}function vn(e){return`${e.action}-${e.resourceType}-${e.name}-${e.protocol??``}`}function yn(e){return e.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(`, `)}function bn({groups:e}){return(0,X.jsx)(`div`,{"aria-hidden":!0,className:`flex h-1.5 w-full gap-0.5 overflow-hidden rounded-full`,children:[`blocked`,...dn].map(t=>{let n=e.get(t)?.length??0;return n>0?(0,X.jsx)(`span`,{className:I(`h-full rounded-full`,un[t].dot),style:{flexGrow:n}},t):null})})}function xn({entry:e}){let{note:t}=e;return(0,X.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-2 py-1`,children:[(0,X.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[11.5px] text-foreground`,title:e.name,children:e.name}),e.protocol?(0,X.jsx)(`span`,{className:`shrink-0 rounded-[var(--miravo-radius-tight)] border border-border/60 px-1 font-mono text-[9.5px] uppercase text-muted-foreground`,children:e.protocol}):null,e.boundDevice?(0,X.jsxs)(`span`,{className:`shrink-0 font-mono text-[10.5px] text-muted-foreground`,title:`Device this twin instance reads from`,children:[`→ `,e.boundDevice]}):null,t?(0,X.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted-foreground`,title:t,children:t}):null]})}function Sn({action:e,entries:t,open:n,onToggle:r}){let i=un[e];return(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:r,"aria-expanded":n,className:`group flex w-full min-w-0 items-center gap-3 rounded-[var(--miravo-radius-tight)] px-2 py-2 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:I(`size-2 shrink-0 rounded-full`,i.dot)}),(0,X.jsx)(`span`,{className:I(`w-20 shrink-0 text-sm font-medium`,e===`noop`?`text-muted-foreground`:`text-foreground`),children:i.label}),(0,X.jsx)(`span`,{className:I(`w-8 shrink-0 font-mono text-sm tabular-nums`,i.text),children:t.length}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:_n(t)}),(0,X.jsx)(he,{"aria-hidden":!0,className:I(`size-3.5 shrink-0 text-muted-foreground transition-transform duration-200`,n&&`rotate-90`)})]}),n?(0,X.jsx)(`div`,{className:`mb-2 ml-[1.1rem] flex flex-col gap-2 border-l border-border/60 pt-1 pl-[1.9rem]`,children:gn(t).map(([e,t])=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:mn[e][1]}),(0,X.jsx)(`ul`,{children:t.map(e=>(0,X.jsx)(xn,{entry:e},vn(e)))})]},e))}):null]})}function Cn({entries:e}){return(0,X.jsxs)(`div`,{role:`note`,className:`rounded-[var(--miravo-radius-tight)] border border-warning/30 bg-warning/8 px-3 py-2.5`,children:[(0,X.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-warning`,children:[(0,X.jsx)(Xe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),e.length,` `,e.length===1?`resource is`:`resources are`,` skipped`]}),(0,X.jsx)(`ul`,{className:`mt-1 pl-5.5`,children:e.map(e=>(0,X.jsx)(xn,{entry:e},vn(e)))})]})}function wn({groups:e,planKind:t}){let n=fn.filter(t=>(e.get(t)?.length??0)>0);return n.length===0?(0,X.jsx)(`p`,{className:`font-heading text-base font-semibold tracking-tight`,children:t===`cleanup`?`Nothing to remove`:`Nothing to change`}):(0,X.jsx)(`p`,{className:`font-heading text-base font-semibold tracking-tight`,children:n.map((t,n)=>(0,X.jsxs)(Y.Fragment,{children:[n>0?(0,X.jsx)(`span`,{className:`mx-1.5 font-normal text-muted-foreground/60`,children:`·`}):null,(0,X.jsx)(`span`,{className:I(`font-mono tabular-nums`,un[t].text),children:e.get(t)?.length}),` `,(0,X.jsx)(`span`,{className:`font-normal text-foreground/90`,children:un[t].phrase})]},t))})}function Tn({plan:e,planKind:t=`apply`}){let n=sn(e.entries),r=cn(n),i=fn.reduce((e,t)=>e+(r.get(t)?.length??0),0),[a,o]=(0,Y.useState)(()=>new Set(i<=pn?fn:[])),s=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),c=r.get(`blocked`)??[],l=r.get(`noop`)?.length??0;return(0,X.jsxs)(`section`,{"aria-label":`Dry run`,className:`flex flex-col gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 bg-background/40 p-4`,children:[(0,X.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsxs)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:[t===`cleanup`?`Expected removals`:`Expected changes`,(0,X.jsx)(`span`,{className:`ml-2 normal-case tracking-normal text-muted-foreground/80`,children:`dry run · nothing runs until you confirm`})]}),(0,X.jsx)(wn,{groups:r,planKind:t}),(0,X.jsxs)(`p`,{className:`font-mono text-[11px] text-muted-foreground`,children:[l>0?`${l} already in place · `:``,yn(e.scope)]})]})}),n.length>0?(0,X.jsx)(bn,{groups:r}):null,c.length>0?(0,X.jsx)(Cn,{entries:c}):null,n.length>0?(0,X.jsx)(`ul`,{className:`-mx-2 flex flex-col`,children:dn.map(e=>{let t=r.get(e);return t?(0,X.jsx)(Sn,{action:e,entries:t,open:a.has(e),onToggle:()=>s(e)},e):null})}):(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t===`cleanup`?`No Miravo-managed resources matched this scope on the target.`:`The target already matches this template.`})]})}var En=[`a`,`b`,`c`];function Dn(){return(0,X.jsxs)(`div`,{role:`status`,"aria-busy":!0,"aria-label":`Loading dry run`,className:`flex flex-col gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-border/60 bg-background/40 p-4`,children:[(0,X.jsx)(Z,{className:`h-2.5 w-28`}),(0,X.jsx)(Z,{className:`h-5 w-56`}),(0,X.jsx)(Z,{className:`h-3 w-40`}),(0,X.jsx)(Z,{className:`h-1.5 w-full rounded-full`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2 pt-1`,children:En.map(e=>(0,X.jsx)(Z,{className:`h-7 w-full`},e))})]})}var On={modbus:`Modbus`,opcua:`OPC UA`,mqtt:`MQTT`},kn=Je.map(e=>({value:e,label:On[e]}));function An({open:e,onOpenChange:t,action:n,subject:r,label:i,target:a,stream:s}){let c=n===`apply`,u=c?Gt:Kt,[d,f]=(0,Y.useState)(new Set(u)),[p,m]=(0,Y.useState)(`fail`),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(Object.keys(a.exposedPorts??{}).length>0),[S,ne]=(0,Y.useState)(Ue(a.exposedPorts)),[w,re]=(0,Y.useState)(r.kind===`asset`?r.protocol:Je[0]??`modbus`),T=r.kind===`asset`?{kind:`asset`,assetId:r.assetId,protocol:w}:r,E=r.kind===`asset`?[w]:Je,D=c?Ge(a.exposedPorts,S,E):{},O=u.filter(e=>d.has(e)),k=O.length>0&&D!==null,A={scope:O,ifUnmanaged:p,...c&&D?{exposedPorts:D}:{}},j=tn({targetId:a.id,subject:T,result:A}),M=nn({targetId:a.id,subject:T,result:A}),N=l({queryKey:o.integrations.plan(n,JSON.stringify(c?j:M)),queryFn:({signal:e})=>c?ye(j,{signal:e}):we(M,{signal:e}),enabled:e&&k,retry:!1,gcTime:0}),P=s.status===`running`,ie=()=>{k&&(s.operation&&s.status!==`running`&&s.reset(),c?s.startApply(j):s.startCleanup(M),t(!1))},F=N.data?.plan,I=F?ln(F.entries):null,L;L=c?I===null?`Apply`:I===0?`Re-apply anyway`:`Apply ${I} ${I===1?`change`:`changes`}`:I?`Clean up ${I} ${I===1?`resource`:`resources`}`:`Clean up`;let R=N.error?[nt(N.error,`Plan failed`),rt(N.error)].filter(Boolean).join(`. `):null;return(0,X.jsx)(te,{open:e,onOpenChange:t,children:(0,X.jsxs)(b,{showCloseButton:!0,className:`flex max-h-[90vh] min-h-0 flex-col gap-0 overflow-hidden p-0 sm:max-w-3xl`,children:[(0,X.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 px-5 pb-3 pt-5`,children:[(0,X.jsxs)(ee,{className:`flex items-center gap-2 text-sm font-semibold leading-snug`,children:[c?(0,X.jsx)(He,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,X.jsx)(Ye,{className:`size-3.5 shrink-0 text-destructive`,"aria-hidden":!0}),c?`Apply`:`Clean up`,` `,i,` `,c?`to`:`from`,` `,a.label]}),(0,X.jsxs)(x,{className:`mt-1 font-mono text-[11px] text-muted-foreground`,children:[a.hostname,c?(0,X.jsx)(`span`,{className:`font-sans`,children:` · reaches Miravo at `}):null,c?a.sourceHostname:null]})]}),(0,X.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-5 pt-4 pb-3`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[c&&r.kind===`asset`?(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Protocol`}),(0,X.jsxs)(yt,{value:w,onValueChange:e=>e&&re(e),items:kn,children:[(0,X.jsx)(vt,{size:`sm`,className:`w-32`,"aria-label":`Protocol`,children:(0,X.jsx)(gt,{})}),(0,X.jsx)(_t,{alignItemWithTrigger:!1,align:`start`,children:kn.map(e=>(0,X.jsx)(q,{value:e.value,children:e.label},e.value))})]})]}):null,k?R?(0,X.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 text-xs`,children:[(0,X.jsxs)(`p`,{className:`text-destructive`,children:[`Dry run failed: `,R]}),(0,X.jsx)(C,{size:`sm`,variant:`outline`,onClick:()=>void N.refetch(),children:`Retry dry run`})]}):F?(0,X.jsx)(Tn,{plan:F,planKind:n}):(0,X.jsx)(Dn,{}):(0,X.jsx)(`p`,{className:`text-[11px] text-destructive`,children:O.length===0?`Select at least one scope under Advanced.`:`Fix the invalid host port under Advanced.`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)($t,{open:h,onOpenChange:g,isApply:c,scopeOptions:u,scope:d,onToggleScope:e=>f(t=>Zt(t,e)),ifUnmanaged:p,onIfUnmanagedChange:m}),h?(0,X.jsxs)(`dl`,{className:`flex flex-col gap-0 text-xs leading-snug`,children:[(0,X.jsx)(en,{label:`Litmus Edge API`,help:Yt,mono:!0,children:a.hostname}),(0,X.jsx)(en,{label:ke,help:je,mono:!0,children:a.sourceHostname}),c?(0,X.jsx)(`div`,{className:`border-b border-border/35 py-2.5`,children:(0,X.jsx)(Ke,{open:_,onOpenChange:v,protocols:E,values:S,onChange:ne,hint:`Enter the host port Litmus Edge should dial. Leave blank to use Miravo's own port. Saved for this target.`})}):null]}):null]})]})}),(0,X.jsxs)(y,{className:`mx-0 mb-0 shrink-0 flex flex-col gap-2 border-t border-border/60 px-5 py-4 sm:flex-row sm:justify-end`,children:[(0,X.jsx)(C,{type:`button`,variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsxs)(C,{type:`button`,variant:c?`default`:`destructive`,onClick:ie,disabled:!k||P,children:[c?(0,X.jsx)(He,{className:`size-3`,"aria-hidden":!0}):(0,X.jsx)(Ye,{className:`size-3`,"aria-hidden":!0}),L]})]})]})})}function jn(e,t,n){let r=new Set,i=[];for(let a of e){if(a.targetId!==t||a.factoryName!==n)continue;let e=a.templateId===void 0?`asset`:`template`,o=a.templateId??a.assetId;if(o===void 0)continue;let s=`${e}:${o}`;r.has(s)||(r.add(s),a.operationType===`apply`?a.status===`success`||a.status===`partial`||a.status===`noop`?i.push({subjectId:o,kind:e,completedAt:a.completedAt}):r.delete(s):a.status!==`success`&&a.status!==`noop`&&r.delete(s))}return i}var Mn=500;function Nn(e){return e.kind===`template`?`template:${e.templateId}`:`asset:${e.assetId}`}function Pn(e,t){return`${Nn(e)}|${t}`}function Fn(e){return e.operationType===`apply`?e.status===`success`||e.status===`partial`||e.status===`noop`?`applied`:`failed`:e.status===`success`||e.status===`noop`?`none`:`failed`}function In(e,t){let n=new Map;for(let r of e){if(r.factoryName!==t)continue;let e=r.templateId===void 0?r.assetId===void 0?null:{kind:`asset`,assetId:r.assetId,protocol:`modbus`}:{kind:`template`,templateId:r.templateId};if(!e)continue;let i=Pn(e,r.targetId);n.has(i)||n.set(i,{status:Fn(r),operationType:r.operationType,targetId:r.targetId,targetLabel:r.targetLabel,completedAt:r.completedAt,error:r.error})}return n}function Ln(e,t){let n=0,r=0;for(let i of e.values())t!==void 0&&i.targetId!==t||(i.status===`applied`?n+=1:i.status===`failed`&&(r+=1));return{applied:n,failed:r}}function Rn(){let e=a(e=>e.factoryName),t=l({queryKey:o.integrations.operationsFactory(),queryFn:()=>ve({limit:Mn})});return{query:t,cells:(0,Y.useMemo)(()=>In(t.data?.operations??[],e),[t.data,e])}}var zn=5,Bn=`grid min-h-11 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 px-4 py-2 @lg/deploy:grid-cols-[minmax(0,1fr)_minmax(9rem,auto)_6.5rem]`;function Vn(e){return e.kind===`template`?e.templateId:e.assetId}function Hn({row:e}){return(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[e.subject.kind===`template`?(0,X.jsx)(pe,{id:e.subject.templateId,className:`size-3.5 shrink-0 text-primary`}):(0,X.jsx)(Lt,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.label}),e.detail?(0,X.jsx)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:e.detail}):null]})]})}function Un({cell:e,running:t}){if(t)return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-primary`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-primary`}),`Running…`]});if(!e||e.status===`none`)return(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full border border-muted-foreground/60`}),`Not applied`]});let n=e.status===`applied`;return(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 text-xs`,title:e.error??void 0,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:I(`size-1.5 shrink-0 rounded-full`,n?`bg-success`:`bg-destructive`)}),(0,X.jsx)(`span`,{className:n?`text-foreground`:`text-destructive`,children:n?`Applied`:e.operationType===`cleanup`?`Clean up failed`:`Failed`}),(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:k(e.completedAt)})]})}function Wn({row:e,target:t,cell:n,running:r,disabled:i,indent:a,onAction:o}){let s=`${e.label} on ${t.label}`,c=n?.status===`applied`||n?.status===`failed`;return(0,X.jsxs)(`li`,{className:I(Bn,`transition-colors hover:bg-muted/20`,a&&`pl-9`),children:[(0,X.jsx)(Hn,{row:e}),(0,X.jsxs)(`div`,{className:`col-start-1 row-start-2 @lg/deploy:col-start-auto @lg/deploy:row-start-auto`,children:[(0,X.jsx)(Un,{cell:n,running:r}),n?.status===`failed`&&n.error?(0,X.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-[11px] text-destructive/80`,children:n.error}):null]}),(0,X.jsxs)(`div`,{className:`col-start-2 row-span-2 row-start-1 flex items-center justify-end gap-1 @lg/deploy:col-start-auto @lg/deploy:row-span-1 @lg/deploy:row-start-auto`,children:[n?.status===`applied`?null:(0,X.jsx)(C,{size:`xs`,variant:`outline`,disabled:i,"aria-label":`${n?.status===`failed`?`Retry`:`Apply`} ${s}`,className:Ie,onClick:()=>o(`apply`),children:n?.status===`failed`?`Retry`:`Apply`}),c?(0,X.jsxs)(ue,{children:[(0,X.jsx)(le,{render:(0,X.jsx)(C,{size:`icon-xs`,variant:`ghost`,disabled:i,"aria-label":`More actions for ${s}`,className:`text-muted-foreground hover:text-foreground`}),children:(0,X.jsx)(Rt,{"aria-hidden":!0})}),(0,X.jsxs)(ce,{align:`end`,className:`min-w-40`,children:[(0,X.jsxs)(se,{className:`gap-2 text-xs`,onClick:()=>o(`apply`),children:[(0,X.jsx)(Ht,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Re-apply`]}),(0,X.jsxs)(se,{variant:`destructive`,className:`gap-2 text-xs`,onClick:()=>o(`cleanup`),children:[(0,X.jsx)(Ye,{className:`size-3.5`,"aria-hidden":!0}),`Clean up`]})]})]}):null]})]})}function Gn({target:e,running:t,disabled:n,onCleanup:r}){let i=a(e=>e.factoryName),s=jn(l({queryKey:o.integrations.operationsForTarget(e.id),queryFn:()=>be(e.id)}).data??[],e.id,i).filter(e=>!t.has(e.subjectId));return s.length===0?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`li`,{className:`bg-muted/20 px-4 pt-2.5 pb-1.5`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:`No longer running`}),(0,X.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:[`Still on `,e.label,` from an earlier apply. Clean up removes what Miravo created.`]})]}),s.map(t=>{let i=t.kind===`template`?{subject:{kind:`template`,templateId:t.subjectId},label:t.subjectId}:{subject:{kind:`asset`,assetId:t.subjectId,protocol:`modbus`},label:t.subjectId};return(0,X.jsxs)(`li`,{className:I(Bn,`bg-muted/20`),children:[(0,X.jsx)(Hn,{row:i}),(0,X.jsxs)(`span`,{className:`col-start-1 row-start-2 inline-flex items-center gap-1.5 text-xs text-muted-foreground @lg/deploy:col-start-auto @lg/deploy:row-start-auto`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 rounded-full bg-muted-foreground/60`}),`Applied`,(0,X.jsx)(`span`,{className:`font-mono text-[11px]`,children:k(t.completedAt)})]}),(0,X.jsx)(`div`,{className:`col-start-2 row-span-2 row-start-1 flex justify-end @lg/deploy:col-start-auto @lg/deploy:row-span-1 @lg/deploy:row-start-auto`,children:(0,X.jsxs)(C,{size:`xs`,variant:`ghost`,disabled:n,"aria-label":`Clean up ${t.subjectId} on ${e.label}`,className:`text-muted-foreground hover:bg-destructive/12 hover:text-destructive`,onClick:()=>r(i),children:[(0,X.jsx)(Ye,{className:`size-3`,"aria-hidden":!0}),`Clean up`]})})]},`${t.kind}:${t.subjectId}`)})]})}function Kn(e,t){return t>0?`fault`:e>0?`live`:`off`}function qn({target:e,templates:t,assets:n,running:r,cells:i,stream:a,onAction:o}){let[s,c]=(0,Y.useState)(!1),{applied:l,failed:u}=Ln(i,e.id),d=a.status===`running`,f=t=>i.get(Pn(t.subject,e.id)),p=n.length>zn,m=n.filter(e=>f(e)?.status===`applied`).length,h=(t,n=!1)=>{let r=a.operation,i=d&&r?.label===Vn(t.subject)&&(r.targetLabel===e.label||r.targetLabel===e.id);return(0,X.jsx)(Wn,{row:t,target:e,cell:f(t),running:i,disabled:d,indent:n,onAction:n=>o(t,e,n)},`${t.subject.kind}:${t.label}`)};return(0,X.jsx)(it,{icon:ae,title:e.label,description:(0,X.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.hostname}),aside:(0,X.jsxs)(W,{tone:Kn(l,u),children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:l}),(0,X.jsx)(K,{children:`applied`}),u>0?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mx-1.5 text-muted-foreground/60`,children:`·`}),(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-destructive`,children:u}),(0,X.jsx)(K,{children:`failed`})]}):null]}),className:`@container/deploy`,bodyClassName:`p-0`,children:(0,X.jsxs)(`ul`,{className:`divide-y divide-border/50 py-1`,children:[t.length===0&&n.length===0?(0,X.jsx)(`li`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:`Nothing is running. Load a template to send it to Litmus Edge.`}):null,t.map(e=>h(e)),p?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`li`,{className:Bn,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>c(e=>!e),"aria-expanded":s,className:`flex min-w-0 items-center gap-2 rounded-[var(--miravo-radius-tight)] text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(he,{className:I(`size-3.5 shrink-0 text-muted-foreground transition-transform`,s&&`rotate-90`),"aria-hidden":!0}),`Standalone assets`,(0,X.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:n.length})]}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:m>0?`${m} applied`:`Not applied`})]}),s?n.map(e=>h(e,!0)):null]}):n.map(e=>h(e)),(0,X.jsx)(Gn,{target:e,running:r,disabled:d,onCleanup:t=>o(t,e,`cleanup`)})]})})}function Jn({targets:e,cells:t,stream:n}){let{templates:r,assets:i}=a(S(e=>({templates:e.templates,assets:e.assets}))),[o,s]=(0,Y.useState)(null);if(e.length===0)return(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(ae,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),`No Litmus Edge target yet`]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add a device with its hostname and an API token. Then apply templates and assets to it from here.`}),(0,X.jsxs)(g,{to:`/integrations`,className:P({size:`sm`}),children:[(0,X.jsx)(ze,{className:`size-3.5`,"aria-hidden":!0}),`Add target`]})]});let c=new Set(r.flatMap(e=>e.assetIds)),l=r.map(e=>({subject:{kind:`template`,templateId:e.templateId},label:e.templateName,detail:e.templateId})),u=i.filter(e=>!c.has(e.id)).map(e=>({subject:{kind:`asset`,assetId:e.id,protocol:`modbus`},label:e.id})),d=new Set([...r.map(e=>e.templateId),...i.map(e=>e.id)]);return(0,X.jsxs)(`section`,{"aria-label":`Deployments`,className:I(`grid items-start gap-4`,e.length>1&&`@5xl/main:grid-cols-2`),children:[e.map(e=>(0,X.jsx)(qn,{target:e,templates:l,assets:u,running:d,cells:t,stream:n,onAction:(e,t,n)=>s({row:e,target:t,action:n})},e.id)),o?(0,X.jsx)(An,{open:!0,onOpenChange:e=>!e&&s(null),action:o.action,subject:o.row.subject,label:o.row.label,target:o.target,stream:n}):null]})}var Yn={status:`idle`,operation:null,error:null,logs:[],cancelRequested:!1},Xn=200;function Zn(){let[e,t]=(0,Y.useState)(Yn),n=(0,Y.useRef)(null),r=(0,Y.useRef)(0),i=c(),a=(0,Y.useRef)(0),s=(0,Y.useCallback)(e=>{let n=nt(e,`Integration operation failed.`),r=rt(e),i=r?`${n} ${r}`:n;t(e=>({...e,status:`error`,cancelRequested:!1,error:i,operation:e.operation?{...e.operation,status:`error`,error:i}:null}))},[]),l=(0,Y.useCallback)(e=>{switch(e.event){case`accepted`:Qn(e.data,t);break;case`log`:er({...e.data,id:`log-${r.current++}`},t);break;case`started`:tr(e.data,t);break;case`phase`:nr(e.data,t);break;case`resource`:rr(e.data,t);break;case`complete`:ir(e.data,t);break;case`cancelled`:or(e.data,t);break;case`retrying`:sr(e.data,t);break;case`error`:s(Error(e.data.message));break}},[s]),u=(0,Y.useCallback)(e=>{let c=++a.current;n.current?.abort(),r.current=0,t({status:`running`,operation:null,error:null,logs:[],cancelRequested:!1}),n.current=xe(e,e=>{a.current===c&&(l(e),cr(e)&&(i.invalidateQueries({queryKey:o.integrations.targets()}),i.invalidateQueries({queryKey:o.integrations.operations()}),n.current?.abort(),n.current=null))},e=>{a.current===c&&(n.current=null,s(e))})},[l,s,i]),d=(0,Y.useCallback)(e=>{let c=++a.current;n.current?.abort(),r.current=0,t({status:`running`,operation:null,error:null,logs:[],cancelRequested:!1}),n.current=Ee(e,e=>{a.current===c&&(l(e),cr(e)&&(i.invalidateQueries({queryKey:o.integrations.operations()}),n.current?.abort(),n.current=null))},e=>{a.current===c&&(n.current=null,s(e))})},[l,s,i]),f=(0,Y.useCallback)(()=>{a.current++,n.current?.abort(),n.current=null,t(Yn)},[]),p=(0,Y.useCallback)(async()=>{let n=e.operation?.operationId;if(!(!n||e.status!==`running`||e.cancelRequested)){t(e=>ar(e,n));try{await Te(n)||s(Error(`Operation finished before cancellation was accepted.`))}catch(e){s(e instanceof Error?e:Error(`Cancellation failed.`))}}},[e.operation?.operationId,e.status,e.cancelRequested,s]);return(0,Y.useEffect)(()=>()=>{a.current++,n.current?.abort(),n.current=null},[]),{...e,startApply:u,startCleanup:d,reset:f,cancel:p}}function Qn(e,t){t(t=>({...t,status:`running`,cancelRequested:!1,error:null,operation:{operationId:e.operationId,type:e.type,label:e.templateId??e.assetId??(e.type===`apply`?`Preparing apply`:`Preparing cleanup`),targetLabel:e.targetId??`Resolving target`,totalPlanned:0,phases:[],applied:0,failed:0,status:`running`,startedAt:Date.now()}}))}function $n(e){return e.templateId??e.assetId??`unknown`}function er(e,t){t(t=>({...t,logs:[...t.logs,e].slice(-Xn)}))}function tr(e,t){t(t=>({...t,status:`running`,cancelRequested:!1,error:null,operation:{operationId:e.operationId,type:e.type,label:$n(e),targetLabel:e.targetLabel,totalPlanned:e.totalPlanned,phases:[],applied:0,failed:0,status:`running`,startedAt:Date.now(),attempt:e.attempt,maxAttempts:e.maxAttempts}}))}function nr(e,t){t(t=>{if(!Q(t,e.operationId))return t;let n=t.operation.phases.map(e=>e.status===`active`?{...e,status:`done`}:e),r=n.findIndex(t=>t.name===e.phase),i=r>=0?n.map((t,n)=>n===r?{...t,status:`active`,total:e.total}:t):[...n,{name:e.phase,total:e.total,resources:[],status:`active`}];return{...t,operation:{...t.operation,phases:i}}})}function rr(e,t){t(t=>{if(!Q(t,e.operationId))return t;let n={name:e.name,action:e.action,status:e.status,error:e.error},r=t.operation.phases.map(t=>t.name===e.phase&&t.status===`active`?{...t,resources:[...t.resources,n]}:t);return{...t,operation:{...t.operation,phases:r,applied:t.operation.applied+ +(e.status===`success`&&e.action!==`noop`),failed:t.operation.failed+ +(e.status===`failed`)}}})}function ir(e,t){t(t=>{if(!Q(t,e.operationId))return t;let n=t.operation.phases.map(e=>e.status===`active`?{...e,status:`done`}:e);return{...t,status:`complete`,cancelRequested:!1,error:null,operation:{...t.operation,phases:n,applied:e.applied??e.deleted??0,failed:e.failed,duration:e.duration,status:`complete`}}})}function ar(e,t){return!Q(e,t)||e.status!==`running`?e:{...e,cancelRequested:!0}}function or(e,t){t(t=>{if(!Q(t,e.operationId))return t;let n=t.operation.phases.map(e=>e.status===`active`?{...e,status:`done`}:e);return{...t,status:`complete`,cancelRequested:!1,error:null,operation:{...t.operation,phases:n,applied:e.applied??e.deleted??0,failed:e.failed,duration:e.duration,status:`cancelled`}}})}function sr(e,t){t(t=>Q(t,e.operationId)?{...t,status:`running`,cancelRequested:!1,error:null,operation:{...t.operation,status:`running`,retryPending:!0,retryDelayMs:e.delayMs,attempt:e.attempt,maxAttempts:e.maxAttempts,error:e.error,applied:0,failed:0,phases:[]}}:t)}function Q(e,t){return e.operation?.operationId===t}function cr(e){return e.event===`complete`||e.event===`cancelled`||e.event===`error`}var lr={initial:{scale:0,opacity:0},animate:{scale:1,opacity:1,originY:0},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:350,damping:40}},ur={initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{type:`tween`,duration:.22,ease:[.16,1,.3,1]}};function dr({children:e,variant:t=`default`}){let n=t===`default`;return(0,X.jsx)(u.div,{...n?lr:ur,layout:n,className:`mx-auto w-full`,children:e})}var fr=Y.memo(({children:e,className:t,delay:n=1e3,...r})=>{let[i,a]=(0,Y.useState)(0),o=(0,Y.useMemo)(()=>Y.Children.toArray(e),[e]);(0,Y.useEffect)(()=>{let e=null;return i<o.length-1&&(e=setTimeout(()=>{a(e=>(e+1)%o.length)},n)),()=>{e!==null&&clearTimeout(e)}},[i,n,o.length]);let s=(0,Y.useMemo)(()=>o.slice(0,i+1).reverse(),[i,o]);return(0,X.jsx)(`div`,{className:I(`flex flex-col items-center gap-4`,t),...r,children:(0,X.jsx)(f,{children:s.map(e=>(0,X.jsx)(dr,{children:e},e.key))})})});fr.displayName=`AnimatedList`;function pr({type:e,errorMessage:t,className:n}){return null}var mr=`text-destructive hover:bg-destructive/25 hover:text-foreground`,hr={device:`Devices`,tags:`Tags`,model:`Models`,asset:`Assets`,"param-sync":`Parameters`};function gr(e){return hr[e]??e}function _r(e){switch(e){case`create`:return`border border-success/30 bg-success/15 text-success`;case`update`:return`border border-chart-3/30 bg-chart-3/15 text-chart-3`;case`replace`:return`border border-warning/30 bg-warning/15 text-warning`;case`delete`:return`border border-destructive/30 bg-destructive/15 text-destructive`;case`noop`:return`border border-border/60 bg-muted/70 text-foreground/75`;default:return`border border-border/50 bg-muted/80 text-foreground/85`}}function vr(e){return e===`noop`?`no-op`:e}function yr({status:e}){switch(e){case`success`:return(0,X.jsx)(ge,{className:`size-3.5 shrink-0 text-success`});case`failed`:return(0,X.jsx)(_e,{className:`size-3.5 shrink-0 text-destructive`});case`pending`:return(0,X.jsx)(B,{className:`size-3.5 shrink-0 animate-spin text-primary/90`})}}function br({status:e}){switch(e){case`done`:return(0,X.jsx)(ge,{className:`size-3.5 text-success`});case`active`:return(0,X.jsx)(B,{className:`size-3.5 animate-spin text-primary`});case`pending`:return(0,X.jsx)(Ft,{className:`size-3.5 text-foreground/55`})}}function xr({entry:e}){let[t,n]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsxs)(`button`,{type:`button`,className:I(`flex items-center gap-2 rounded-[var(--miravo-radius-tight)] px-2 py-1 text-left transition-colors`,e.error?`cursor-pointer hover:bg-muted/40`:`cursor-default`),onClick:()=>e.error&&n(!t),disabled:!e.error,children:[(0,X.jsx)(yr,{status:e.status}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-foreground`,children:e.name}),(0,X.jsx)(`span`,{className:I(`inline-flex rounded-[var(--miravo-radius-tight)] px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wider`,_r(e.action)),children:vr(e.action)}),e.error&&(0,X.jsx)(me,{className:I(`size-3 text-foreground/75 transition-transform`,t&&`rotate-180`)})]}),(0,X.jsx)(f,{initial:!1,children:t&&e.error&&(0,X.jsxs)(u.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.18},className:`overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`mb-0 flex min-w-0 w-full items-center gap-1.5 rounded-[var(--miravo-radius-tight)] border border-destructive/40 bg-destructive/15 px-2.5 py-1.5 text-[10px] font-medium leading-relaxed`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-left whitespace-normal break-words text-destructive [overflow-wrap:anywhere]`,children:e.error}),(0,X.jsx)(Oe,{value:e.error,label:`Copy error`,className:I(mr,`shrink-0`)})]}),(0,X.jsx)(pr,{type:`apply`,errorMessage:e.error,className:`mb-1 mt-2.5 w-full min-w-0`})]})})]})}function Sr({phase:e,open:t,onOpenChange:n}){let r=e.resources.length,i=r===e.total,a=e.resources.length>0;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsxs)(`button`,{type:`button`,className:I(`flex w-full items-center gap-2 rounded-[var(--miravo-radius-tight)] px-1 py-1 text-left transition-colors`,a&&`hover:bg-muted/40`,!a&&`cursor-default`),disabled:!a,"aria-expanded":a?t:void 0,onClick:()=>a&&n(!t),children:[(0,X.jsx)(br,{status:e.status}),(0,X.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-foreground`,children:gr(e.name)}),(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-foreground/70`,children:[r,`/`,e.total]}),(0,X.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:[i&&e.status===`done`&&(0,X.jsx)(ge,{className:`size-3 text-success`}),a&&(0,X.jsx)(me,{className:I(`size-3 text-foreground/75 transition-transform`,!t&&`-rotate-90`),"aria-hidden":!0})]})]}),(0,X.jsx)(f,{initial:!1,children:a&&t&&(0,X.jsx)(u.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:`auto`},exit:{opacity:0,height:0},transition:{duration:.25,ease:[.16,1,.3,1]},className:`overflow-hidden`,children:(0,X.jsx)(`div`,{className:`ml-2 flex min-w-0 flex-col border-l border-border/55 pl-2.5 pr-1.5 pb-1 pt-0.5`,children:(0,X.jsx)(d.Provider,{value:null,children:e.resources.map((e,t)=>(0,X.jsx)(dr,{variant:`subtle`,children:(0,X.jsx)(xr,{entry:e})},`${e.name}-${t}`))})})})})]})}function Cr({operation:e}){let t=e.status===`complete`,n=e.status===`cancelled`,r=e.failed>0,i=e.totalPlanned>0?Math.min(100,Tr(e)/e.totalPlanned*100):0;return(0,X.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/55`,role:`progressbar`,"aria-valuenow":Math.round(i),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Operation progress`,children:(0,X.jsx)(u.div,{"aria-hidden":`true`,className:I(`h-full rounded-full transition-colors duration-500`,n?`bg-foreground/30`:t&&!r?`bg-success`:`bg-warning`),initial:{width:`0%`},animate:{width:`${i}%`},transition:{duration:.4,ease:[.25,.1,.25,1]}})})}function wr(e){return e.duration==null?(Date.now()-e.startedAt)/1e3:e.duration/1e3}function Tr(e){let t=e.applied+e.failed;return e.totalPlanned>0?Math.min(t,e.totalPlanned):t}var Er={complete:{Icon:ge,className:`size-4 text-success`},partial:{Icon:Pt,className:`size-4 text-warning`},cancelled:{Icon:At,className:`size-4 text-foreground/65`},error:{Icon:_e,className:`size-4 text-destructive`},running:{Icon:B,className:`size-4 animate-spin text-warning`}};function Dr({icon:e,className:t}){return(0,X.jsx)(u.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:500,damping:30},className:`shrink-0`,children:(0,X.jsx)(e,{className:t})})}function Or({operation:e,sourceLabel:t,isAllExpanded:n,onToggleAll:r}){let i=wr(e),a=Tr(e),o=e.status===`complete`,s=e.status===`cancelled`,c=e.status===`error`,l=e.failed>0,d=o&&!l?`complete`:o&&l?`partial`:s?`cancelled`:c?`error`:`running`,p=Er[d];return(0,X.jsxs)(`div`,{className:I(`sticky top-0 z-10 flex min-w-0 w-full flex-col gap-1.5 rounded-[var(--miravo-radius-stadium-sm)] border px-3 pt-2.5 pb-3.5 backdrop-blur-sm transition-colors duration-500`,o&&!l&&`border-success/30 bg-success/5`,o&&l&&`border-warning/30 bg-warning/5`,s&&`border-border/60 bg-muted/50`,c&&`border-destructive/30 bg-destructive/5`,!o&&!s&&!c&&`border-warning/20 bg-warning/5`),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,X.jsx)(f,{mode:`wait`,initial:!1,children:(0,X.jsx)(Dr,{icon:p.Icon,className:p.className},d)}),(0,X.jsx)(`span`,{className:`text-xs font-medium leading-none text-foreground`,children:s?`Cancelled`:o?l?`Completed with errors`:`Complete`:c?`Failed`:e.retryPending?`Failed, retrying attempt ${e.attempt?e.attempt+1:2}/${e.maxAttempts} in ${e.retryDelayMs?e.retryDelayMs/1e3:3}s...`:e.attempt&&e.maxAttempts&&e.attempt>1?`Retrying attempt ${e.attempt}/${e.maxAttempts}...`:e.type===`apply`?`Applying...`:`Cleaning up...`}),(0,X.jsxs)(`span`,{className:`w-full min-w-0 text-[10px] leading-tight text-foreground/78`,children:[(0,X.jsx)(`span`,{className:`font-sans break-words`,children:t}),(0,X.jsx)(`span`,{className:`font-mono break-words`,children:` → ${e.targetLabel}`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,X.jsx)($e,{variant:`secondary`,className:`h-5 min-h-5 gap-0 overflow-hidden border border-border/50 bg-muted/70 px-1.5 !py-0 font-mono text-[10px] leading-none text-foreground shadow-sm [&>span]:inline-flex [&>span]:items-center`,children:(0,X.jsxs)(`span`,{className:`gap-1`,children:[(0,X.jsx)(f,{mode:`popLayout`,initial:!1,children:(0,X.jsx)(u.span,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{type:`spring`,stiffness:500,damping:35},className:`inline tabular-nums`,children:a},a)}),`/`,e.totalPlanned,(0,X.jsx)(`span`,{className:`text-foreground/72`,children:e.type===`apply`?`applied`:`deleted`})]})}),(0,X.jsx)(f,{initial:!1,children:e.failed>0&&(0,X.jsx)(u.div,{className:`inline-flex items-center`,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:500,damping:30},children:(0,X.jsxs)($e,{variant:`destructive`,className:`h-5 min-h-5 gap-0 border border-destructive/35 bg-destructive/20 px-1.5 !py-0 font-mono text-[10px] font-semibold leading-none text-destructive`,children:[e.failed,` failed`]})})})]}),(0,X.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-[10px] leading-none text-foreground/75`,children:[(0,X.jsx)(It,{className:`size-3 shrink-0 block text-foreground/65`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`tabular-nums leading-none`,children:typeof i==`number`?`${i.toFixed(1)}s`:`...`})]}),r&&(0,X.jsx)(`div`,{className:`flex items-center border-l border-border/40 pl-2`,children:(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`flex size-4.5 items-center justify-center rounded-[var(--miravo-radius-tight)] text-foreground/55 transition-colors hover:bg-muted/60 hover:text-foreground`,"aria-label":n?`Collapse all phases`:`Expand all phases`,title:n?`Collapse all`:`Expand all`,children:(0,X.jsx)(Nt,{className:I(`size-3.5 transition-transform duration-300`,!n&&`opacity-70 scale-y-[-1]`)})})})]})]}),(0,X.jsx)(Cr,{operation:e})]})]})}function kr(e){return e?e.closest(`[data-edge-op-scroll]`)??e.closest(`.overflow-y-auto`):null}var Ar=350;function jr(e){e?.scrollIntoView({block:`end`,behavior:`auto`,inline:`nearest`})}function Mr(e){let t=()=>jr(e);t(),requestAnimationFrame(t),requestAnimationFrame(()=>requestAnimationFrame(t)),window.setTimeout(t,0),window.setTimeout(t,48),window.setTimeout(t,120)}function Nr({logs:e}){return e.length===0?null:(0,X.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1.5 px-2 pb-2`,children:e.map(e=>(0,X.jsxs)(`div`,{className:I(`flex min-w-0 items-start gap-2 rounded-[var(--miravo-radius-tight)] border px-2.5 py-2 text-xs`,e.level===`error`?`border-destructive/35 bg-destructive/12 text-destructive`:e.level===`warn`?`border-warning/35 bg-warning/12 text-warning`:`border-primary/25 bg-primary/8 text-foreground/82`),children:[e.level===`info`?(0,X.jsx)(R,{className:`mt-0.5 size-3.5 shrink-0 text-primary`,"aria-hidden":!0}):(0,X.jsx)(Pt,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`min-w-0 wrap-anywhere`,children:e.message})]},e.id))})}function Pr({operation:e,logs:t}){let n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(!0),a=(0,Y.useRef)(e.status);a.current=e.status;let o=(0,Y.useRef)(!1),[s,c]=(0,Y.useState)(new Set),l=e.label;(0,Y.useLayoutEffect)(()=>{let e=kr(n.current);if(!e)return;let t=()=>{i.current=e.scrollHeight-e.scrollTop-e.clientHeight<Ar};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>{e.removeEventListener(`scroll`,t)}},[]),(0,Y.useLayoutEffect)(()=>{if(e.status===`running`){i.current&&jr(r.current),o.current=!0;return}o.current&&=(Mr(r.current),!1)},[e.status,e.applied,e.failed,e.phases]),(0,Y.useEffect)(()=>{if(e.status!==`running`)return;let t=n.current;if(!t)return;let o=0,s=new ResizeObserver(()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{a.current===`running`&&i.current&&jr(r.current)})});return s.observe(t),i.current&&jr(r.current),()=>{s.disconnect(),cancelAnimationFrame(o)}},[e.status]);let d=e.phases.length>0,p=s.size===0;return(0,X.jsxs)(`div`,{ref:n,className:`flex min-w-0 w-full flex-col gap-2`,children:[(0,X.jsx)(Or,{operation:e,sourceLabel:l,isAllExpanded:p,onToggleAll:d?()=>{c(p?new Set(e.phases.map(e=>e.name)):new Set)}:void 0}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1 px-2 pt-2 pb-4`,children:e.phases.map(e=>(0,X.jsx)(`div`,{children:(0,X.jsx)(Sr,{phase:e,open:!s.has(e.name),onOpenChange:t=>{c(n=>{let r=new Set(n);return t?r.delete(e.name):r.add(e.name),r})}})},e.name))}),(0,X.jsx)(f,{initial:!1,children:e.error&&e.retryPending&&(0,X.jsxs)(u.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},className:`sticky bottom-2 z-20 mx-2 mt-auto mb-2 flex items-center gap-2 overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-destructive/40 bg-destructive/15 px-3 py-2 text-xs font-medium text-destructive shadow-md backdrop-blur-md`,children:[(0,X.jsx)(B,{className:`size-4 shrink-0 animate-spin`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.error})]})}),(0,X.jsx)(f,{initial:!1,children:e.error&&e.status===`error`&&(0,X.jsxs)(u.div,{initial:{opacity:0,height:0,marginTop:0},animate:{opacity:1,height:`auto`,marginTop:8},exit:{opacity:0,height:0,marginTop:0},transition:{duration:.2},className:`mx-2 mb-4 flex min-w-0 flex-col gap-0 overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-destructive/40 bg-destructive/15 px-3 py-2 text-xs font-medium`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`min-w-0 flex-1 text-left wrap-anywhere text-destructive`,children:e.error}),(0,X.jsx)(Oe,{value:e.error,label:`Copy error`,className:I(mr,`shrink-0`)})]}),(0,X.jsx)(pr,{type:e.type,errorMessage:e.error,className:`mt-3 w-full min-w-0`})]})}),t&&t.length>0?(0,X.jsx)(Nr,{logs:t}):null,(0,X.jsx)(`div`,{ref:r,className:`h-px w-full shrink-0`,"aria-hidden":!0})]})}function Fr({title:e,subtitle:t,footerAction:n,canDismiss:r=!0,onDismiss:i,children:a}){return(0,Y.useEffect)(()=>{function e(e){e.key===`Escape`&&r&&i()}return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[r,i]),(0,X.jsx)(u.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},exit:{opacity:0,y:16},transition:{type:`spring`,stiffness:380,damping:30},className:`pointer-events-none fixed bottom-4 left-4 right-4 z-[60] sm:left-auto sm:w-full sm:max-w-md`,children:(0,X.jsxs)(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)(Be,{className:`size-4 shrink-0 text-primary`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`font-heading text-xs font-semibold tracking-tight text-foreground`,children:e}),t?(0,X.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/80`,children:t}):null]})]}),r?(0,X.jsx)(C,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`shrink-0 text-foreground/70 hover:bg-muted/80 hover:text-foreground`,onClick:i,"aria-label":`Dismiss operation panel`,children:(0,X.jsx)(w,{className:`size-3.5`,"aria-hidden":!0})}):null]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2.5 pt-2.5 sm:px-3 sm:pt-3`,"data-edge-op-scroll":``,children:a}),n?(0,X.jsx)(`div`,{className:`flex w-full shrink-0 min-w-0 items-center gap-2 border-t border-border/40 bg-muted/15 p-2.5 sm:p-3`,children:n}):null]})})}function Ir(e){let t=e.operation,n=t?.type===`apply`?`apply`:`cleanup`;switch(e.status){case`running`:return{title:`Operation in progress`,subtitle:`Streaming ${n} steps to Litmus Edge`};case`complete`:return t?.status===`cancelled`?{title:`Operation cancelled`,subtitle:`Stopped — resources created so far remain in Litmus Edge.`}:{title:`Operation complete`,subtitle:n===`apply`?`Apply finished — review the summary below.`:`Cleanup finished — review the summary below.`};case`error`:return{title:`Operation failed`,subtitle:e.error??t?.error??`The operation ended with an error.`};default:return{title:`Operation`,subtitle:``}}}function Lr({stream:e,onReset:t}){if(!e.operation&&e.status!==`running`)return null;let{title:n,subtitle:r}=Ir(e),i=e.status===`complete`,a=e.status===`error`,o=e.status===`running`,s=i||a,c=e.cancelRequested;async function l(){await e.cancel().catch(()=>{})}return(0,X.jsx)(Fr,{title:n,subtitle:r,canDismiss:!o,footerAction:o&&e.operation?.operationId?(0,X.jsx)(`div`,{className:`ml-auto shrink-0`,children:(0,X.jsx)(`button`,{type:`button`,onClick:l,disabled:c,"aria-busy":c,className:I(P({variant:`outline`,size:`sm`}),`group h-8 gap-1.5 px-3 text-xs`,c?`cursor-not-allowed`:`hover:bg-destructive/12 hover:text-destructive hover:border-destructive/35`),children:c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(B,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(u.span,{animate:{opacity:[1,.72,1]},transition:{duration:1.25,repeat:1/0,ease:`easeInOut`},className:`font-medium text-foreground`,children:`Cancelling…`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(w,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,X.jsx)(u.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})})}):s?(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 w-full flex-1 flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,X.jsxs)(g,{to:`/integrations?tab=activity`,className:I(P({variant:`ghost`,size:`xs`}),`group inline-flex h-6 shrink-0 items-center gap-1.5 px-2 text-[11px] font-medium text-foreground/80`,`hover:bg-primary/12 hover:text-primary`),children:[(0,X.jsx)(L,{className:`size-3 shrink-0 text-foreground/70 group-hover:text-primary`,"aria-hidden":!0}),`View full activity`,(0,X.jsx)(he,{className:`size-2.5 shrink-0 text-foreground/50 group-hover:text-primary`,"aria-hidden":!0})]}),(0,X.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,X.jsx)(C,{type:`button`,variant:`secondary`,size:`xs`,className:`h-6 px-2.5 text-[11px] font-medium`,onClick:t,children:`Close`})})]}),e.operation?.status===`cancelled`||a&&e.operation?(0,X.jsx)(pr,{type:e.operation.type,errorMessage:e.operation.error,className:`mt-2.5 w-full min-w-0`}):null]}):void 0,onDismiss:t,children:e.operation?(0,X.jsx)(Pr,{operation:e.operation,logs:e.logs}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(B,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/78`,children:`Connecting to Litmus Edge…`})]}),(0,X.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/55`,children:(0,X.jsx)(u.div,{className:`h-full w-2/5 rounded-full bg-primary`,animate:{x:[`-100%`,`250%`]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}})})]})})}function Rr({targetCount:e,applied:t,failed:n,lastOp:r}){return(0,X.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,X.jsx)(`div`,{"aria-hidden":!0,className:`flex size-9 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border border-border/60 bg-background/70 text-primary`,children:(0,X.jsx)(ae,{className:`size-4`})}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h2`,{className:`font-heading text-lg font-semibold tracking-tight`,children:`Litmus Edge`}),(0,X.jsx)(`p`,{className:`mt-0.5 max-w-2xl text-pretty text-xs text-muted-foreground`,children:`Send running templates and assets to Litmus Edge devices: devices, tags and flows. Each change is planned before it runs, and clean up removes only what Miravo created.`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(W,{tone:e>0?`live`:`off`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:e}),(0,X.jsx)(K,{children:e===1?`target`:`targets`})]}),(0,X.jsxs)(W,{tone:t>0?`live`:`off`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-foreground`,children:t}),(0,X.jsx)(K,{children:`applied`})]}),n>0?(0,X.jsxs)(W,{tone:`fault`,children:[(0,X.jsx)(`span`,{className:`mr-1.5 font-mono font-semibold tabular-nums text-destructive`,children:n}),(0,X.jsx)(K,{children:`failed`})]}):null,r?(0,X.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`last run `,k(r.completedAt)]}):null,(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,X.jsxs)(g,{to:`/integrations`,className:G+` text-xs text-muted-foreground`,children:[(0,X.jsx)(We,{className:`size-3`,"aria-hidden":!0}),`Manage targets`]}),(0,X.jsxs)(g,{to:`/integrations?tab=activity`,className:G+` text-xs text-muted-foreground`,children:[(0,X.jsx)(L,{className:`size-3`,"aria-hidden":!0}),`Activity`]}),(0,X.jsxs)(`a`,{href:`${Ut}/integrations/litmus-edge`,target:`_blank`,rel:`noopener noreferrer`,className:G+` text-xs text-muted-foreground`,children:[(0,X.jsx)(jt,{className:`size-3`,"aria-hidden":!0}),`Docs`]})]})]})}function zr(){let e=Zn(),t=l({queryKey:o.integrations.targets(),queryFn:()=>Se()}),{query:n,cells:r}=Rn(),i=t.data,a=n.data?.operations;if(!i||!a){let e=t.error??n.error;return e?(0,X.jsx)(Ve,{message:nt(e,`Could not load Litmus Edge status.`),onRetry:()=>{t.refetch(),n.refetch()},isRetrying:t.isFetching||n.isFetching}):(0,X.jsx)(Z,{className:`h-64 w-full`})}let{applied:s,failed:c}=Ln(r),u=a[0];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(Rr,{targetCount:i.length,applied:s,failed:c,lastOp:u}),(0,X.jsx)(Jn,{targets:i,cells:r,stream:e}),e.operation||e.status===`running`?(0,X.jsx)(Lr,{stream:e,onReset:e.reset}):null]})}function Br(){let e=l({queryKey:o.integrations.targets(),queryFn:()=>Se()}),{cells:t}=Rn(),n=e.data?.length??0,{applied:r,failed:i}=Ln(t);return(0,X.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:I(`size-1.5 shrink-0 rounded-full`,i>0?`bg-destructive`:r>0?`bg-success`:`bg-muted-foreground/50`)}),n===0?(0,X.jsx)(`span`,{className:`font-sans`,children:`No target yet`}):(0,X.jsxs)(`span`,{className:`truncate`,children:[n,` `,n===1?`target`:`targets`,` ·`,` `,(0,X.jsx)(`span`,{className:`text-foreground`,children:r}),` applied`,i>0?(0,X.jsxs)(`span`,{className:`text-destructive`,children:[` · `,i,` failed`]}):null]})]})}var Vr={"litmus-edge":{icon:ae,Panel:zr,Summary:Br}};function Hr(e){return e?`/?tab=integrations&integration=${e}`:`/?tab=integrations`}function Ur(){return(0,X.jsxs)(it,{icon:Vt,title:`Integrations`,description:`Send this factory to the platforms you build on.`,bodyClassName:`gap-1 px-2 py-2`,footer:(0,X.jsxs)(g,{to:Hr(),className:G,children:[`Open integrations`,(0,X.jsx)(z,{className:`size-3`,"aria-hidden":!0})]}),children:[kt.map(e=>{let{icon:t,Summary:n}=Vr[e.id];return(0,X.jsxs)(g,{to:Hr(e.id),className:`group flex min-w-0 items-center gap-3 rounded-[var(--miravo-radius-tight)] px-2 py-2 outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(t,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.label}),(0,X.jsx)(n,{})]}),(0,X.jsx)(he,{className:`size-3.5 shrink-0 text-muted-foreground transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0})]},e.id)}),(0,X.jsxs)(`p`,{className:`px-2 pt-1 pb-0.5 text-[11px] text-muted-foreground`,children:[`Coming soon: `,Dt.map(e=>e.label).join(`, `),`.`]})]})}function Wr(e){return s.prefetchQuery({queryKey:o.assets.detail(e),queryFn:()=>i(`/assets/${e}`,r.assetDetail),staleTime:2e3})}var Gr=`Commissioning → asset is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`;function Kr(e,t,n,r){let i=n===`asc`?1:-1;return[...e].sort((e,n)=>{switch(t){case`id`:return e.id.localeCompare(n.id)*i;case`template`:return(r.get(e.id)??``).localeCompare(r.get(n.id)??``)*i;case`model`:return e.model.localeCompare(n.model)*i;case`lifecycle`:return e.lifecycleStage.localeCompare(n.lifecycleStage)*i;case`hours`:return(e.operatingHours-n.operatingHours)*i;case`faults`:return(e.activeFaults.length-n.activeFaults.length)*i;case`status`:{let t=e=>e.isQuarantined?2:+(e.activeFaults.length>0);return(t(e)-t(n))*i}default:return 0}})}function qr(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var Jr={healthy:{pip:`bg-success`,ring:`border-success/40 text-success`,label:`healthy`,help:`No active faults, not quarantined.`},faulted:{pip:`bg-warning`,ring:`border-warning/40 text-warning`,label:`faulted`,help:`One or more active faults; asset is still running.`},quarantined:{pip:`bg-destructive`,ring:`border-destructive/40 text-destructive`,label:`quarantined`,help:`Asset isolated from production flows pending review.`}};function Yr({state:e}){let t=Jr[e];return(0,X.jsxs)(U,{children:[(0,X.jsxs)(V,{render:(0,X.jsx)(`span`,{className:I(`inline-flex h-5 items-center gap-1.5 rounded-(--miravo-radius-pill) border bg-background/30 px-2 text-[11px] font-medium`,t.ring)}),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:I(`size-1.5 shrink-0 rounded-full`,t.pip)}),(0,X.jsx)(`span`,{children:re(t.label)})]}),(0,X.jsx)(H,{side:`top`,children:t.help})]})}function $({label:e,sortKey:t,subtitle:n,tooltip:r,current:i,direction:a,onSort:o,className:s}){let c=i===t,l=c?a===`asc`?`ascending`:`descending`:`none`,u=(0,X.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 whitespace-nowrap rounded-(--miravo-radius-tight) text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,onClick:()=>o(t),children:[(0,X.jsxs)(`span`,{className:`inline-flex items-baseline gap-1`,children:[(0,X.jsx)(`span`,{children:e}),n&&(0,X.jsx)(`span`,{className:`text-[10px] font-normal text-muted-foreground`,children:n})]}),(0,X.jsx)(oe,{className:I(`size-3`,c?`text-foreground`:`text-muted-foreground`),"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:c?`, sorted ${a===`asc`?`ascending`:`descending`}. Click to toggle.`:`, click to sort`})]});return(0,X.jsx)(Ct,{className:s,"aria-sort":l,children:r?(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{render:u}),(0,X.jsx)(H,{side:`top`,children:r})]}):u})}function Xr({title:e,body:t,action:n}){return(0,X.jsx)(bt,{children:(0,X.jsx)(J,{colSpan:8,className:`py-10`,children:(0,X.jsxs)(`div`,{className:`mx-auto flex max-w-sm flex-col items-center gap-2 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:e}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}),n&&(0,X.jsxs)(g,{to:n.href,className:`mt-1 inline-flex items-center gap-1 rounded-(--miravo-radius-tight) text-xs font-medium text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring`,children:[n.label,(0,X.jsx)(z,{className:`size-3`,"aria-hidden":!0})]})]})})})}function Zr({assets:e,state:t,templateByAsset:n,sortKey:r,sortDir:i,onSort:a,onOpenAsset:o}){return(0,X.jsx)(ft,{className:`py-0`,children:(0,X.jsx)(mt,{className:`p-0 [&_thead_tr_th:last-child]:w-6 [&_thead_tr_th:last-child]:px-1 sm:[&_thead_tr_th:last-child]:w-8 sm:[&_thead_tr_th:last-child]:px-2 [&_tbody_tr_td:last-child]:px-1 sm:[&_tbody_tr_td:last-child]:px-2`,children:(0,X.jsxs)(wt,{children:[(0,X.jsx)(Tt,{children:(0,X.jsxs)(bt,{children:[(0,X.jsx)($,{label:`Asset`,sortKey:`id`,current:r,direction:i,onSort:a}),(0,X.jsx)($,{label:`Template`,sortKey:`template`,current:r,direction:i,onSort:a,className:`hidden md:table-cell`}),(0,X.jsx)($,{label:`Model`,sortKey:`model`,current:r,direction:i,onSort:a,className:`hidden sm:table-cell`}),(0,X.jsx)($,{label:`Lifecycle`,sortKey:`lifecycle`,current:r,direction:i,onSort:a,tooltip:Gr}),(0,X.jsx)($,{label:`Operating age`,sortKey:`hours`,current:r,direction:i,onSort:a,tooltip:`Cumulative operating hours since the asset started running.`,className:`hidden text-right md:table-cell`}),(0,X.jsx)($,{label:`Faults`,sortKey:`faults`,current:r,direction:i,onSort:a,tooltip:`Count of active (uncleared) faults on this asset.`}),(0,X.jsx)($,{label:`Status`,sortKey:`status`,current:r,direction:i,onSort:a}),(0,X.jsx)(Ct,{children:(0,X.jsx)(`span`,{className:`sr-only`,children:`Navigate to asset`})})]})}),(0,X.jsx)(xt,{children:t===`connecting`?(0,X.jsx)(Xr,{title:`Connecting to runtime`,body:`Live asset data will appear once the connection is up.`}):t===`empty`?(0,X.jsx)(Xr,{title:`No running assets`,body:`Start a factory from the Catalog to see assets.`,action:{label:`Open Catalog`,href:`/catalog`}}):e.length===0?(0,X.jsx)(Xr,{title:`No matches`,body:`Adjust filters or clear them to see all assets.`}):e.map(e=>{let t=qr(e),r=j(e.id);return(0,X.jsxs)(bt,{tabIndex:0,"aria-label":`Open asset ${r}`,className:I(`group cursor-pointer outline-none transition-colors`,`focus-visible:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-inset`),onClick:()=>o(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e.id))},onMouseEnter:()=>{Ze(`/asset/${e.id}`),Wr(e.id)},onFocus:()=>{Ze(`/asset/${e.id}`),Wr(e.id)},children:[(0,X.jsx)(J,{className:`text-sm`,children:(0,X.jsx)(Y.ViewTransition,{name:`asset-${e.id}`,default:`none`,children:(0,X.jsx)(`span`,{className:`inline-flex max-w-full truncate rounded-(--miravo-radius-tight) text-left`,title:e.id,children:r})})}),(0,X.jsx)(J,{className:`hidden text-sm text-muted-foreground md:table-cell`,children:n.get(e.id)??`Standalone`}),(0,X.jsx)(J,{className:`hidden text-sm sm:table-cell`,children:M(e.model)}),(0,X.jsx)(J,{children:(0,X.jsx)($e,{variant:`secondary`,className:`text-xs`,children:E(e.lifecycleStage)})}),(0,X.jsx)(J,{className:`hidden font-mono text-sm md:table-cell`,children:A(e.operatingHours)}),(0,X.jsx)(J,{children:e.activeFaults.length>0?(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{render:(0,X.jsx)(`span`,{className:`inline-flex h-5 min-w-5 items-center justify-center rounded-(--miravo-radius-pill) bg-destructive/15 px-1.5 font-mono text-[11px] font-semibold tabular-nums text-destructive`}),children:e.activeFaults.length}),(0,X.jsxs)(H,{side:`top`,children:[e.activeFaults.slice(0,4).join(`, `),e.activeFaults.length>4&&` + ${e.activeFaults.length-4} more`]})]}):(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:`no faults`}),(0,X.jsx)(`span`,{"aria-hidden":!0,children:`—`})]})}),(0,X.jsx)(J,{children:(0,X.jsx)(Yr,{state:t})}),(0,X.jsx)(J,{children:(0,X.jsx)(z,{className:`size-3.5 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100`,"aria-hidden":!0})})]},e.id)})})]})})})}var Qr=`~all`,$r=`~standalone`;function ei(e){return e===``||e===`healthy`||e===`faulted`||e===`quarantined`}function ti(){let{assets:e,templates:t,connectionState:n}=a(S(e=>({assets:e.assets,templates:e.templates,connectionState:e.connectionState}))),[r,i]=p(`q`,m.withDefault(``)),[o,s]=p(`model`,m.withDefault(``)),[c,l]=p(`lifecycle`,m.withDefault(``)),[u,d]=p(`template`,m.withDefault(``)),[f,h]=p(`standalone`,m.withDefault(``)),g=f===`1`,[_,v]=p(`status`,m.withDefault(``)),y=ei(_)?_:``,[b,ee]=(0,Y.useState)(`id`),[x,te]=(0,Y.useState)(`asc`),C=(0,Y.useRef)(null),re=Qe(),[T,D]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),C.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let O=(0,Y.useCallback)(e=>{e===b?te(e=>e===`asc`?`desc`:`asc`):(ee(e),te(`asc`))},[b]),k=(0,Y.useMemo)(()=>{let e=new Map;for(let n of t)for(let t of n.assetIds)e.set(t,n.templateName);return e},[t]),A=(0,Y.useMemo)(()=>[{value:Qr,label:`All templates`},{value:$r,label:`Standalone`},...t.map(e=>({value:e.templateId,label:e.templateName}))],[t]),j=(0,Y.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.model,(t.get(n.model)??0)+1);return[...t.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[e]),P=(0,Y.useMemo)(()=>[...new Set(e.map(e=>e.lifecycleStage))].sort(),[e]),F=(0,Y.useMemo)(()=>[{value:`all`,label:`All stages`},...P.map(e=>({value:e,label:E(e)}))],[P]),I=(0,Y.useMemo)(()=>T?j.filter(([e])=>ie(e,T)):j,[j,T]),L=(0,Y.useMemo)(()=>o?{value:o,label:M(o)}:null,[o]),R=(0,Y.useMemo)(()=>{let n=e;if(g)n=n.filter(e=>!k.has(e.id));else if(u){let e=new Set(t.find(e=>e.templateId===u)?.assetIds);n=n.filter(t=>e.has(t.id))}return o&&(n=n.filter(e=>e.model===o)),c&&(n=n.filter(e=>e.lifecycleStage===c)),r&&(n=n.filter(e=>N(e.id,r)||ie(e.model,r))),y===`faulted`&&(n=n.filter(e=>e.activeFaults.length>0)),y===`quarantined`&&(n=n.filter(e=>e.isQuarantined)),y===`healthy`&&(n=n.filter(e=>e.activeFaults.length===0&&!e.isQuarantined)),Kr(n,b,x,k)},[e,t,k,u,g,r,y,o,c,b,x]),z=y!==``||u!==``||g||o!==``||c!==``||r!==``,ae=(0,Y.useCallback)(()=>{i(``),v(``),d(``),h(``),s(``),l(``)},[i,v,d,h,s,l]),oe=(0,Y.useCallback)(e=>{re(`/asset/${e}`,{transitionType:et})},[re]),se=e.length>0?`rows`:n===`live`?`empty`:`connecting`;return(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t.length>0&&(0,X.jsxs)(yt,{value:g?$r:u||Qr,onValueChange:e=>{h(e===$r?`1`:``),d(!e||e===Qr||e===$r?``:e)},items:A,children:[(0,X.jsx)(vt,{className:`h-8 w-44`,"aria-label":`Template filter`,children:(0,X.jsx)(gt,{placeholder:`All templates`})}),(0,X.jsx)(_t,{alignItemWithTrigger:!1,align:`start`,children:A.map(e=>(0,X.jsx)(q,{value:e.value,children:e.label},e.value))})]}),(0,X.jsxs)(ht,{value:L,onValueChange:e=>void s(e?.value??``),isItemEqualToValue:(e,t)=>e?.value===t?.value,onInputValueChange:D,children:[(0,X.jsx)(pt,{placeholder:`All models`,className:`h-8 w-48`,showClear:!!o}),(0,X.jsx)(dt,{children:(0,X.jsxs)(lt,{children:[I.map(([e,t])=>(0,X.jsxs)(ut,{value:{value:e,label:M(e)},children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:M(e)}),(0,X.jsxs)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:[`(`,t,`)`]})]},e)),I.length===0&&(0,X.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]}),P.length>1&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsxs)(yt,{value:c||`all`,onValueChange:e=>void l(!e||e===`all`?``:e),items:F,children:[(0,X.jsx)(vt,{className:`h-8 w-36`,"aria-label":`Lifecycle stage`,children:(0,X.jsx)(gt,{placeholder:`All stages`})}),(0,X.jsxs)(_t,{alignItemWithTrigger:!1,align:`start`,children:[(0,X.jsx)(q,{value:`all`,children:`All stages`}),P.map(e=>(0,X.jsx)(q,{value:e,children:E(e)},e))]})]}),(0,X.jsxs)(U,{children:[(0,X.jsx)(V,{render:(0,X.jsx)(`button`,{type:`button`,"aria-label":`About lifecycle stages`,className:`flex size-6 items-center justify-center rounded-(--miravo-radius-tight) text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`}),children:(0,X.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0})}),(0,X.jsx)(H,{side:`top`,children:`Commissioning → asset is running startup diagnostics. Operating → running normally. Decommissioning → winding down.`})]})]}),(0,X.jsxs)(yt,{value:y||`all`,onValueChange:e=>void v(!e||e===`all`?``:e),items:St,children:[(0,X.jsx)(vt,{className:`h-8 w-32`,"aria-label":`Status filter`,children:(0,X.jsx)(gt,{placeholder:`All status`})}),(0,X.jsxs)(_t,{alignItemWithTrigger:!1,align:`start`,children:[(0,X.jsx)(q,{value:`all`,children:`All status`}),(0,X.jsx)(q,{value:`healthy`,children:`Healthy`}),(0,X.jsx)(q,{value:`faulted`,children:`Faulted`}),(0,X.jsx)(q,{value:`quarantined`,children:`Quarantined`})]})]}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(ne,{ref:C,placeholder:`Search...`,value:r,onChange:e=>void i(e.target.value),"aria-label":`Search assets by id or model`,className:`h-8 w-40 pr-7 text-xs`}),!r&&(0,X.jsx)(`kbd`,{className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 rounded-(--miravo-radius-tight) border border-border bg-muted px-1 font-mono text-[10px] text-muted-foreground`,children:`/`})]}),z&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:ae,className:`flex items-center gap-1 rounded-(--miravo-radius-tight) px-1 text-xs text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(w,{className:`size-3`,"aria-hidden":!0}),`Clear`]}),(0,X.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,"aria-live":`polite`,children:[R.length,` of `,e.length]})]})]}),(0,X.jsx)(Zr,{assets:R,state:se,templateByAsset:k,sortKey:b,sortDir:x,onSort:O,onOpenAsset:oe})]})}var ni={running:`live`,paused:`idle`,stopped:`fault`};function ri(){let{factoryName:e,engineState:t,seed:n,speed:r,bootTemplate:i}=a(S(e=>({factoryName:e.factoryName,engineState:e.engineState,seed:e.seed,speed:e.speedMultiplier,bootTemplate:e.bootTemplate})));return(0,X.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:e&&!Fe(e)?D(e):`Factory`}),(0,X.jsx)(W,{tone:ni[t]??`off`,children:(0,X.jsx)(K,{children:t})})]}),(0,X.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-muted-foreground`,children:[e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{children:[`id `,(0,X.jsx)(`span`,{className:`text-foreground`,children:e})]}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`})]}):null,(0,X.jsxs)(`span`,{children:[`seed `,(0,X.jsx)(`span`,{className:`text-foreground`,children:n??`-`})]}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,X.jsxs)(`span`,{children:[(0,X.jsxs)(`span`,{className:`text-foreground`,children:[r,`×`]}),` speed`]}),i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-3 w-px bg-border/60`}),(0,X.jsxs)(`span`,{children:[`booted with `,(0,X.jsx)(`span`,{className:`text-foreground`,children:i.name})]})]}):null]})]}),(0,X.jsxs)(g,{to:`/catalog`,className:P({size:`sm`}),children:[(0,X.jsx)(ze,{className:`size-3.5`,"aria-hidden":!0}),`Load template`]})]})}var ii=kt.map(e=>e.id),ai=`inline-flex h-8 shrink-0 items-center gap-2 rounded-[var(--miravo-radius-pill)] border px-3 text-xs outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring`;function oi(){let[e,t]=p(`integration`,h(ii).withDefault(Ot.id)),{Panel:n}=Vr[e];return(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`nav`,{"aria-label":`Integrations`,className:`flex flex-wrap gap-2`,children:[kt.map(n=>{let{icon:r}=Vr[n.id],i=n.id===e;return(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":i,onClick:()=>void t(n.id),className:I(ai,i?`border-primary/45 bg-primary/10 text-foreground`:`border-border/60 text-muted-foreground hover:border-muted-foreground/50 hover:text-foreground`),children:[(0,X.jsx)(r,{className:I(`size-3.5`,i&&`text-primary`),"aria-hidden":!0}),n.label]},n.id)}),Dt.map(e=>(0,X.jsxs)(`span`,{"aria-disabled":!0,className:I(ai,`cursor-default border-dashed border-border/60 text-muted-foreground/70`),children:[(0,X.jsx)(Vt,{className:`size-3.5`,"aria-hidden":!0}),e.label,(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em]`,children:`Soon`})]},e.id))]}),(0,X.jsx)(n,{})]})}function si(e={}){let t=new URLSearchParams({tab:`assets`});return e.template&&t.set(`template`,e.template),e.standalone&&t.set(`standalone`,`1`),e.model&&t.set(`model`,e.model),e.status&&t.set(`status`,e.status),`/?${t.toString()}`}var ci={healthy:`border-muted-foreground/25 bg-muted/40 text-foreground/90 hover:border-muted-foreground/50`,faulted:`border-destructive/40 bg-destructive/10 text-destructive hover:border-destructive/70`,quarantined:`border-warning/40 bg-warning/10 text-warning hover:border-warning/70`},li={healthy:`bg-success`,faulted:`bg-destructive`,quarantined:`bg-warning`};function ui({group:e,label:t,templateId:n}){let[r]=e.ids;return(0,X.jsxs)(g,{to:e.ids.length===1&&r?`/asset/${r}`:si({model:e.model,template:n}),title:e.ids.join(`, `),className:I(`inline-flex h-6 items-center gap-1.5 rounded-[var(--miravo-radius-tight)] border px-1.5 font-mono text-[11px] outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring`,ci[e.health]),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:I(`size-1.5 shrink-0 rounded-full`,li[e.health])}),t,e.ids.length>1&&(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`×`,e.ids.length]}),e.health!==`healthy`&&(0,X.jsxs)(`span`,{className:`sr-only`,children:[`, `,e.health]})]})}function di(e){return e.isQuarantined?`quarantined`:e.activeFaults.length>0?`faulted`:`healthy`}var fi=24;function pi(){let{assets:e,templates:t}=a(S(e=>({assets:e.assets,templates:e.templates}))),[n,r]=(0,Y.useState)(!1),i=new Set(t.flatMap(e=>e.assetIds)),o=e.filter(e=>!i.has(e.id));if(o.length===0)return null;let s=n?o:o.slice(0,fi);return(0,X.jsxs)(`section`,{"aria-label":`Standalone assets`,className:I(Le,`flex flex-col gap-4 p-5`),children:[(0,X.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] bg-primary/10 text-primary`,children:(0,X.jsx)(Lt,{className:`size-5`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-heading text-sm font-semibold uppercase tracking-wide`,children:`Standalone assets`}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/75`,children:`Spawned from a model, outside any template.`})]})]}),(0,X.jsxs)(`ul`,{className:`flex flex-wrap gap-1.5`,children:[s.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(ui,{group:{model:e.model,ids:[e.id],health:di(e)},label:e.id})},e.id)),o.length>fi&&(0,X.jsx)(`li`,{children:(0,X.jsx)(C,{size:`xs`,variant:`ghost`,onClick:()=>r(e=>!e),children:n?`Show fewer`:`+${o.length-fi} more`})})]}),(0,X.jsxs)(`div`,{className:`mt-auto font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:o.length}),` asset`,o.length===1?``:`s`]}),(0,X.jsxs)(`footer`,{className:`flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,X.jsxs)(g,{to:si({standalone:!0}),className:I(P({size:`sm`,variant:`outline`}),Ie),children:[(0,X.jsx)(Mt,{className:`size-3.5`,"aria-hidden":!0}),`View assets`]}),(0,X.jsxs)(g,{to:`/models`,className:I(P({size:`sm`,variant:`ghost`}),`ml-auto text-muted-foreground`),children:[(0,X.jsx)(ze,{className:`size-3.5`,"aria-hidden":!0}),`Spawn asset`]})]})]})}function mi({template:e,open:t,onOpenChange:n}){let r=Re(),[i,a]=(0,Y.useState)(!1);return(0,X.jsx)(te,{open:t,onOpenChange:n,children:(0,X.jsxs)(b,{children:[(0,X.jsxs)(v,{children:[(0,X.jsxs)(ee,{children:[`Unload `,e.templateName]}),(0,X.jsxs)(x,{children:[`Removes its `,e.assetIds.length,` asset`,e.assetIds.length===1?``:`s`,`. Standalone assets stay.`]})]}),(0,X.jsxs)(y,{children:[(0,X.jsx)(C,{variant:`outline`,onClick:()=>n(!1),disabled:i,children:`Cancel`}),(0,X.jsx)(C,{variant:`destructive`,disabled:i,onClick:async()=>{a(!0);try{await r.mutateAsync({type:`unloadTemplate`,templateId:e.templateId}),n(!1)}catch{}finally{a(!1)}},children:`Unload`})]})]})})}function hi({value:e,label:t}){return(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e}),` `,t,e===1?``:`s`]})}function gi(e,t){let n=new Set(e.assetIds),r=new Set;for(let e of t)n.has(e.id)&&di(e)!==`healthy`&&r.add(M(e.model));return[...r]}function _i({template:e,highlighted:t=!1}){let{assets:n,engineState:s}=a(S(e=>({assets:e.assets,engineState:e.engineState}))),c=l({queryKey:o.catalog.templates(),queryFn:()=>i(`/catalog/templates`,r.catalogTemplates)}),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),m=c.data?.find(t=>t.id===e.templateId)?.description,h=new Set(e.assetIds),_=n.filter(e=>h.has(e.id)&&di(e)!==`healthy`).length,v=_>0?gi(e,n):[],y=e.areas.reduce((e,t)=>e+t.lines.length,0);return(0,X.jsxs)(`section`,{id:`template-${e.templateId}`,"aria-label":e.templateName,className:I(Le,`flex scroll-mt-4 flex-col gap-4 p-5 transition-shadow`,t&&`ring-2 ring-ring`),children:[(0,X.jsxs)(`header`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] bg-primary/10 text-primary`,children:(0,X.jsx)(pe,{id:e.templateId,className:`size-5`})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,X.jsx)(`h2`,{className:`truncate font-heading text-sm font-semibold uppercase tracking-wide`,children:e.templateName}),(0,X.jsx)(`span`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:e.templateId})]}),_>0?(0,X.jsxs)(W,{tone:`fault`,children:[(0,X.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:_}),` `,(0,X.jsx)(K,{children:`faulted`})]}):(0,X.jsx)(W,{tone:s===`running`?`live`:`idle`,children:(0,X.jsx)(K,{children:s===`running`?`running`:`paused`})})]}),m?(0,X.jsx)(`p`,{className:`line-clamp-2 text-pretty text-xs leading-relaxed text-muted-foreground`,children:m}):null,(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsx)(hi,{value:e.areas.length,label:`area`}),(0,X.jsx)(hi,{value:y,label:`line`}),(0,X.jsx)(hi,{value:e.assetIds.length,label:`asset`}),(0,X.jsx)(hi,{value:e.models.length,label:`model`})]}),v.length>0?(0,X.jsxs)(g,{to:si({template:e.templateId,status:`faulted`}),className:`flex min-w-0 items-center gap-2 rounded-[var(--miravo-radius-tight)] border border-destructive/30 bg-destructive/8 px-2.5 py-1.5 text-xs text-destructive outline-none transition-colors hover:border-destructive/60 focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,X.jsx)(Xe,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 truncate`,children:[(0,X.jsxs)(`span`,{className:`font-medium`,children:[_,` faulted:`]}),` `,v.join(`, `)]})]}):null,(0,X.jsxs)(`footer`,{className:`mt-auto flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,X.jsxs)(C,{type:`button`,size:`sm`,variant:`outline`,className:Ie,onClick:()=>p(!0),children:[(0,X.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),Ne(e.templateId)?(0,X.jsxs)(g,{to:Pe(e.templateId),className:P({size:`sm`,variant:`ghost`}),children:[(0,X.jsx)(Me,{className:`size-3.5`,"aria-hidden":!0}),`Open floor`]}):null,(0,X.jsx)(C,{size:`sm`,variant:`ghost`,className:`ml-auto text-muted-foreground hover:bg-destructive/12 hover:text-destructive`,onClick:()=>d(!0),children:`Unload`})]}),(0,X.jsx)(mi,{template:e,open:u,onOpenChange:d}),(0,X.jsx)(fe,{templateId:f?e.templateId:null,onClose:()=>p(!1),live:{assetIds:e.assetIds,models:e.models},actions:(0,X.jsxs)(g,{to:si({template:e.templateId}),className:P({size:`sm`,variant:`ghost`}),children:[(0,X.jsx)(Mt,{className:`size-3.5`,"aria-hidden":!0}),`View assets`]}),fallbackTitle:e.templateName})]})}var vi={success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`,foreground:`bg-foreground/60`,primary:`bg-primary`},yi={success:`text-success`,warning:`text-warning`,destructive:`text-destructive`,foreground:`text-foreground`,primary:`text-primary`},bi={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus`};function xi({label:e,pip:t,pulse:n}){return(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t&&(n?(0,X.jsxs)(`span`,{"aria-hidden":!0,className:`relative flex size-1.5 shrink-0 items-center justify-center`,children:[(0,X.jsx)(`span`,{className:I(`absolute inline-flex h-full w-full animate-ping rounded-full opacity-75`,vi[t])}),(0,X.jsx)(`span`,{className:I(`relative inline-flex size-1.5 rounded-full`,vi[t])})]}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:I(`size-1.5 shrink-0 rounded-full`,vi[t])})),(0,X.jsx)(`span`,{className:`truncate text-[10px] font-medium uppercase tracking-(--miravo-tracking-eyebrow) text-muted-foreground`,children:e})]})}function Si({children:e,tone:t=`foreground`,live:n}){return(0,X.jsx)(`span`,{...n?{role:`status`,"aria-live":`polite`}:{},className:I(`mt-1 block min-w-0 truncate font-mono text-2xl font-semibold tabular-nums leading-none transition-colors duration-300`,yi[t]),children:e})}function Ci({children:e}){return(0,X.jsx)(`span`,{className:`mt-1 min-w-0 truncate text-[10px] text-muted-foreground`,children:e})}function wi(e,t){return e===t?``:t}function Ti({statusFilter:e,onStatusFilter:t}){let{assets:n,tps:r,memberValueCount:i,availableAdapters:o,adapterMetrics:s}=a(S(e=>({assets:e.assets,tps:e.tps,memberValueCount:e.memberValueCount,availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),c=(0,Y.useMemo)(()=>{let e=n.filter(e=>!e.isQuarantined&&e.activeFaults.length===0).length,t=n.filter(e=>!e.isQuarantined&&e.activeFaults.length>0).length,r=n.filter(e=>e.isQuarantined).length,i=n.length;return{healthy:e,faulted:t,quarantined:r,total:i,pct:i>0?Math.round(e/i*100):100,activeFaultCount:n.reduce((e,t)=>e+t.activeFaults.length,0),modelCount:new Set(n.map(e=>e.model)).size,affectedCount:new Set(n.filter(e=>e.activeFaults.length>0).map(e=>e.id)).size}},[n]),l=(0,Y.useMemo)(()=>{let e=o.filter(e=>e.enabled);return{enabled:e,totalMessages:e.reduce((e,t)=>e+(s.find(e=>e.name===t.name)?.metrics?.messagesPublished??0),0),totalErrors:e.reduce((e,t)=>e+(s.find(e=>e.name===t.name)?.metrics?.errorsCount??0),0),labels:e.map(e=>bi[e.name]??e.name)}},[o,s]),u=c.activeFaultCount>0,d=u?`destructive`:c.quarantined>0?`warning`:`success`,f=u?`faulted`:`healthy`;return(0,X.jsxs)(`section`,{"aria-label":`Asset status`,className:`grid w-full min-w-0 max-w-full grid-cols-2 overflow-hidden rounded-(--miravo-radius-stadium-sm) border *:border-border/40 *:odd:border-r *:nth-[-n+2]:border-b @2xl/main:grid-cols-4 @2xl/main:*:border-b-0 @2xl/main:*:not-last:border-r`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>t(wi(e,f)),"aria-pressed":e===`healthy`||e===`faulted`,"aria-label":u?`Filter to faulted assets`:`Filter to healthy assets`,className:I(`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 text-left outline-none transition-colors duration-150`,`hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,(e===`healthy`||e===`faulted`)&&`bg-muted/50`),children:[(0,X.jsx)(xi,{label:`Health`,pip:d}),(0,X.jsxs)(Si,{tone:u?`destructive`:`success`,children:[c.pct,`%`]}),(0,X.jsx)(Ci,{children:c.total===0?`No assets`:[`${c.total} asset${c.total===1?``:`s`}`,c.faulted>0&&`${c.faulted} faulted`,c.quarantined>0&&`${c.quarantined} quarantined`,`${c.modelCount} model${c.modelCount===1?``:`s`}`].filter(Boolean).join(` · `)})]}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>t(e===`faulted`?``:`faulted`),"aria-pressed":e===`faulted`,"aria-label":`Filter to faulted assets`,className:I(`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 text-left outline-none transition-colors duration-150`,`hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`,e===`faulted`&&`bg-muted/50`),children:[(0,X.jsx)(xi,{label:`Faults`,pip:u?`destructive`:`success`}),(0,X.jsx)(Si,{tone:u?`destructive`:`foreground`,live:!0,children:c.activeFaultCount}),(0,X.jsx)(Ci,{children:u?`${c.affectedCount} asset${c.affectedCount===1?``:`s`} affected`:`all clear`})]}),(0,X.jsxs)(U,{children:[(0,X.jsxs)(V,{render:(0,X.jsx)(g,{to:`/tags`,"aria-label":`Open tag stream`,className:`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 outline-none transition-colors duration-150 hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`}),children:[(0,X.jsx)(xi,{label:`Tags`,pip:`primary`,pulse:!0}),(0,X.jsx)(Si,{children:T(i)}),(0,X.jsxs)(Ci,{children:[(0,X.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` tps · live`]})]}),(0,X.jsx)(H,{side:`bottom`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-[11px]`,children:[(0,X.jsx)(`span`,{children:`Live tags tracked across the fleet.`}),i>=1e6&&(0,X.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[O(i),` tags`]}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Updating at `,(0,X.jsx)(`span`,{className:`font-mono tabular-nums`,children:r.toFixed(1)}),` per second.`]})]})})]}),l.enabled.length>0&&(0,X.jsx)(Ei,{labels:l.labels,totalMessages:l.totalMessages,totalErrors:l.totalErrors,perAdapter:l.enabled.map(e=>({name:bi[e.name]??e.name,metrics:s.find(t=>t.name===e.name)?.metrics}))})]})}function Ei({labels:e,totalMessages:t,totalErrors:n,perAdapter:r}){return(0,X.jsxs)(U,{children:[(0,X.jsxs)(V,{render:(0,X.jsx)(g,{to:`/control`,"aria-label":`Open control — protocol adapters`,className:`flex min-w-0 flex-1 flex-col overflow-hidden px-4 py-3 outline-none transition-colors duration-150 hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset`}),children:[(0,X.jsx)(xi,{label:`Protocol`,pip:`primary`,pulse:!0}),(0,X.jsx)(Si,{tone:n>0?`warning`:`foreground`,live:!0,children:T(t)}),(0,X.jsxs)(Ci,{children:[e.join(` · `),n>0&&` · ${n} error${n===1?``:`s`}`]})]}),(0,X.jsx)(H,{side:`bottom`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px]`,children:[(0,X.jsx)(`span`,{children:`Messages published since session start.`}),t>=1e6&&(0,X.jsxs)(`span`,{className:`font-mono tabular-nums text-muted-foreground`,children:[O(t),` total`]}),(0,X.jsx)(`div`,{className:`flex flex-col gap-0.5 border-t border-tooltip-border/60 pt-1`,children:r.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,X.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[O(e.metrics?.messagesPublished??0),` msg`]}),e.metrics&&e.metrics.errorsCount>0&&(0,X.jsxs)(`span`,{className:`font-mono tabular-nums text-destructive`,children:[`· `,e.metrics.errorsCount,` err`]})]},e.name))})]})})]})}var Di=2500,Oi=[`overview`,`assets`,`integrations`];function ki({value:e}){return(0,X.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 font-mono text-[10px] leading-4 tabular-nums text-muted-foreground`,children:e})}function Ai({children:e}){return(0,X.jsx)(u.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},children:e})}function ji(){return(0,X.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(zt,{className:`size-4 text-muted-foreground`,"aria-hidden":!0}),`Nothing is running yet`]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Load a template from the catalog. Its areas, lines and assets show up here, live.`}),(0,X.jsx)(g,{to:`/catalog`,className:P({size:`sm`}),children:`Open catalog`})]})}function Mi({highlight:e}){let{templates:t,assetCount:n}=a(S(e=>({templates:e.templates,assetCount:e.assets.length})));return(0,X.jsx)(`div`,{className:`@container/overview`,children:(0,X.jsxs)(`div`,{className:`grid items-start gap-5 @3xl/overview:grid-cols-[minmax(0,1fr)_20rem] @7xl/overview:grid-cols-[minmax(0,1fr)_22rem]`,children:[t.length===0&&n===0?(0,X.jsx)(ji,{}):(0,X.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(min(100%,22rem),1fr))] gap-4`,children:[t.map(t=>(0,X.jsx)(_i,{template:t,highlighted:t.templateId===e},t.templateId)),(0,X.jsx)(pi,{})]}),(0,X.jsxs)(`div`,{className:`grid min-w-0 gap-5 @xl/overview:grid-cols-2 @3xl/overview:sticky @3xl/overview:top-4 @3xl/overview:grid-cols-1`,children:[(0,X.jsx)(Wt,{}),(0,X.jsx)(Ur,{})]})]})})}function Ni(){let{hash:e}=_(),{templates:t,assetCount:n}=a(S(e=>({templates:e.templates,assetCount:e.assets.length}))),[r,i]=p(`tab`,h(Oi).withDefault(`overview`)),[o,s]=p(`highlight`,m.withDefault(``)),[c,l]=p(`status`,m.withDefault(``)),u=c===`healthy`||c===`faulted`||c===`quarantined`?c:``;(0,Y.useEffect)(()=>{if(!e)return;e===`#connect`&&i(null);let t=setTimeout(()=>{let t=document.getElementById(e.slice(1));t?.scrollIntoView({behavior:`smooth`,block:`start`}),t?.focus({preventScroll:!0})},50);return()=>clearTimeout(t)},[e,i]);let d=t.some(e=>e.templateId===o);return(0,Y.useEffect)(()=>{if(!o||!d)return;document.getElementById(`template-${o}`)?.scrollIntoView({behavior:`smooth`,block:`center`});let e=setTimeout(()=>void s(null,{history:`replace`}),Di);return()=>clearTimeout(e)},[o,d,s]),(0,X.jsxs)(`div`,{className:`mx-auto flex w-full max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,X.jsx)(ri,{}),(0,X.jsx)(Ti,{statusFilter:u,onStatusFilter:e=>{l(e||null),e!==``&&i(`assets`)}}),(0,X.jsxs)(ct,{value:r,onValueChange:e=>void i(e),children:[(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(st,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,X.jsxs)(at,{value:`overview`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(de,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Overview`,(0,X.jsx)(ki,{value:t.length})]}),(0,X.jsxs)(at,{value:`assets`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(Mt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Assets`,(0,X.jsx)(ki,{value:n})]}),(0,X.jsxs)(at,{value:`integrations`,className:`gap-1.5 px-3 text-sm`,children:[(0,X.jsx)(Vt,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),`Integrations`]})]})}),(0,X.jsx)(ot,{value:`overview`,className:`py-2`,children:(0,X.jsx)(Ai,{children:(0,X.jsx)(Mi,{highlight:o})})}),(0,X.jsx)(ot,{value:`assets`,className:`py-2`,children:(0,X.jsx)(Ai,{children:(0,X.jsx)(ti,{})})}),(0,X.jsx)(ot,{value:`integrations`,className:`py-2`,children:(0,X.jsx)(Ai,{children:(0,X.jsx)(oi,{})})})]})]})}export{Ft as a,zt as i,Ut as n,Mt as o,Vt as r,jt as s,Ni as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./integrations-NcPRP3je.js";export{e as IntegrationsPage};
|