@miravo/cli-linux-arm64-musl 0.8.1 → 0.9.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.
Files changed (68) hide show
  1. package/console-dist/assets/api-0DOQsu1W.js +1 -0
  2. package/console-dist/assets/api-DdyA1QMC.js +1 -0
  3. package/console-dist/assets/asset-detail-D-coMgED.js +1 -0
  4. package/console-dist/assets/{badge-i00PiRCo.js → badge-DuuEINVl.js} +1 -1
  5. package/console-dist/assets/catalog-Ca9rhNLN.js +1 -0
  6. package/console-dist/assets/catalog-CdbAE0Ki.js +1 -0
  7. package/console-dist/assets/catalog-source-CPFWtBJF.js +1 -0
  8. package/console-dist/assets/catalog-template-icons-aec8m5-A.js +1 -0
  9. package/console-dist/assets/{checkbox-C84IyqEB.js → checkbox-BL44aFel.js} +1 -1
  10. package/console-dist/assets/{combobox-BJecIYHE.js → combobox-B5iFVe7N.js} +1 -1
  11. package/console-dist/assets/control-CtvncuAA.js +1 -0
  12. package/console-dist/assets/control-DYdEZmP0.js +1 -0
  13. package/console-dist/assets/{copy-button-DnGsXbVV.js → copy-button-RVCJ3aqM.js} +1 -1
  14. package/console-dist/assets/events-Bp3BqWYo.js +1 -0
  15. package/console-dist/assets/events-D5uZ2cwr.js +1 -0
  16. package/console-dist/assets/fleet-CBXZ0Xts.js +1 -0
  17. package/console-dist/assets/fleet-CRB8-QDg.js +1 -0
  18. package/console-dist/assets/{format-B9CcV2dj.js → format-6q8Tnwmn.js} +1 -1
  19. package/console-dist/assets/{get-error-message-CFs0lSQP.js → get-error-message-BowDodwy.js} +1 -1
  20. package/console-dist/assets/index-BPmjm3uU.css +2 -0
  21. package/console-dist/assets/index-Chh5Cd8X.js +12 -0
  22. package/console-dist/assets/integrations-BrZWbG5Q.js +1 -0
  23. package/console-dist/assets/integrations-D4x6ee5M.js +1 -0
  24. package/console-dist/assets/{login-CtfweHfy.js → login-O9dnrHI9.js} +2 -2
  25. package/console-dist/assets/models-BDeOqKQk.js +1 -0
  26. package/console-dist/assets/models-CgWCVmnx.js +1 -0
  27. package/console-dist/assets/{query-fetch-error-2yqCNP9X.js → query-fetch-error-ytmF7SP9.js} +1 -1
  28. package/console-dist/assets/{select-CMOnuEoT.js → select-Cg2u0NQI.js} +1 -1
  29. package/console-dist/assets/{select-display-items-Bqb6Sbg6.js → select-display-items-BEVMAho-.js} +1 -1
  30. package/console-dist/assets/{spawn-protocol-scope-picker-DUXJ8giB.js → spawn-protocol-scope-picker-DDi-hZwj.js} +1 -1
  31. package/console-dist/assets/tabs-BJs5Kci7.js +1 -0
  32. package/console-dist/assets/tags-CcmWc8Xj.js +1 -0
  33. package/console-dist/assets/tags-DnyhyxDB.js +4 -0
  34. package/console-dist/assets/{transition-nav-link-CDSeWWsP.js → transition-nav-link-Crj9XTbK.js} +1 -1
  35. package/console-dist/assets/use-engine-command-mutation-OZ8_Roso.js +1 -0
  36. package/console-dist/assets/use-integration-stream-CFkuEB9r.js +2 -0
  37. package/console-dist/assets/use-transition-navigate-BBXUEW59.js +2 -0
  38. package/console-dist/assets/validation-BvXCKp12.js +1 -0
  39. package/console-dist/index.html +29 -29
  40. package/miravo +2 -2
  41. package/package.json +1 -1
  42. package/console-dist/assets/api-5BZroqlO.js +0 -1
  43. package/console-dist/assets/api-BwgmLQCC.js +0 -1
  44. package/console-dist/assets/catalog-B477tO5a.js +0 -1
  45. package/console-dist/assets/catalog-BRYmHbXV.js +0 -1
  46. package/console-dist/assets/catalog-source-DL6GXE84.js +0 -1
  47. package/console-dist/assets/catalog-template-icons-3S8RvUxD.js +0 -1
  48. package/console-dist/assets/control-Dc6xLiUf.js +0 -1
  49. package/console-dist/assets/control-HqgjVMLG.js +0 -1
  50. package/console-dist/assets/events-BvwhACji.js +0 -1
  51. package/console-dist/assets/events-przfMV9x.js +0 -1
  52. package/console-dist/assets/fleet-C2Ipwzu5.js +0 -1
  53. package/console-dist/assets/fleet-D3Y6h1O_.js +0 -1
  54. package/console-dist/assets/index-AfBFCD9D.js +0 -12
  55. package/console-dist/assets/index-DmjK3skd.css +0 -2
  56. package/console-dist/assets/instance-detail-CQ6RO9hI.js +0 -1
  57. package/console-dist/assets/models-C57soXUz.js +0 -1
  58. package/console-dist/assets/models-CX3jQBRk.js +0 -1
  59. package/console-dist/assets/platforms-DMUEIKyH.js +0 -1
  60. package/console-dist/assets/platforms-nMtu3Mg5.js +0 -1
  61. package/console-dist/assets/tabs-D64chVAn.js +0 -1
  62. package/console-dist/assets/tags-BbNGPS4O.js +0 -1
  63. package/console-dist/assets/tags-Cl6Nj2-E.js +0 -4
  64. package/console-dist/assets/use-engine-command-mutation-CIly3RgV.js +0 -1
  65. package/console-dist/assets/use-platform-stream-BBDJCrNY.js +0 -2
  66. package/console-dist/assets/use-transition-navigate-Bxh77tVE.js +0 -2
  67. package/console-dist/assets/validation-Bt4EQDja.js +0 -1
  68. /package/console-dist/assets/{platform-targets-BIQ1lKOg.js → integration-targets-ChYQ8POe.js} +0 -0
@@ -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.runningTemplates)}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,environmentName:e.state.environmentName??e.metrics.environmentName??``,seed:e.state.config.seed,engineState:e.metrics.core.state,tick:t,simulationTime:e.metrics.core.simulationTimeSeconds,tickIntervalMs:e.state.config.tickIntervalMs,lastTickReceivedAt:r,instanceCount:e.metrics.core.instanceCount,memberValueCount:e.metrics.core.memberValueCount,quarantinedInstanceCount:e.metrics.core.quarantinedInstanceCount,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,instances:[...e.state.instances],models:[...e.state.models],tpsHistory:[{tick:t,tps:n,sampledAtMs:r}],templateRuns:[...e.runningTemplates],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,environmentName:``,seed:null,engineState:`idle`,tick:0,simulationTime:0,tickIntervalMs:1e3,lastTickReceivedAt:0,instanceCount:0,memberValueCount:0,quarantinedInstanceCount:0,engineErrorsCount:0,tickOverrunsCount:0,circuitBreakerTripsCount:0,tps:0,uptimeMs:0,speedMultiplier:1,instances:[],models:[],tpsHistory:[],templateRuns:[],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.instanceCount??r.instanceCount,c=n.metrics.core.actualTicksPerSecond,l=Date.now();if(!(i.length>0||a!==r.tick||o!==r.simulationTime||s!==r.instanceCount||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.quarantinedInstanceCount!==r.quarantinedInstanceCount||c!==r.tps)){e({...gt(r,l),lastTickReceivedAt:l,lastRevision:n.revision});return}let u={...gt(r,l),tick:a,simulationTime:o,lastTickReceivedAt:l,instanceCount:s,memberValueCount:n.metrics.core.memberValueCount,quarantinedInstanceCount:n.metrics.core.quarantinedInstanceCount,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.instanceId)){let r=e.get(n.instanceId);e.set(n.instanceId,new Map(r)),t.add(n.instanceId)}e.get(n.instanceId)?.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===`instance: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.instances.map(e=>{if(e.id!==n.instanceId)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,instances:t});return}if(n.kind===`lifecycle:changed`){let t=i.instances.map(e=>e.id===n.instanceId?{...e,lifecycleStage:n.to,operatingHours:n.operatingHours}:e);e({...s,instances: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`,T=e=>e.status===`valid`,kt=e=>typeof Promise<`u`&&e instanceof Promise,E;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(E||={});var D=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}},At=(e,t)=>{if(T(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 O(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 k=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(kt(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 At(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 T(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=>T(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 At(n,await(kt(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 P({schema:this,typeName:L.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 F.create(this,this._def)}nullable(){return I.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return mn.create(this)}promise(){return kn.create(this,this._def)}or(e){return gn.create([this,e],this._def)}and(e){return yn.create(this,e,this._def)}transform(e){return new P({...O(this._def),schema:this,typeName:L.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new An({...O(this._def),innerType:this,defaultValue:t,typeName:L.ZodDefault})}brand(){return new Pn({typeName:L.ZodBranded,type:this,...O(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new jn({...O(this._def),innerType:this,catchValue:t,typeName:L.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Fn.create(this,e)}readonly(){return In.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},jt=/^c[^\s-]{8,}$/i,Mt=/^[0-9a-z]+$/,Nt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Pt=/^[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,Ft=/^[a-z0-9_-]{21}$/i,It=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Lt=/^[-+]?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)?)??$/,Rt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zt=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Bt,Vt=/^(?:(?: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])$/,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])\/(3[0-2]|[12]?[0-9])$/,Ut=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Gt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Kt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,qt=`((\\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])))`,Jt=RegExp(`^${qt}$`);function Yt(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 Xt(e){return RegExp(`^${Yt(e)}$`)}function Zt(e){let t=`${qt}T${Yt(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Qt(e,t){return!!((t===`v4`||!t)&&Vt.test(e)||(t===`v6`||!t)&&Ut.test(e))}function $t(e,t){if(!It.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 en(e,t){return!!((t===`v4`||!t)&&Ht.test(e)||(t===`v6`||!t)&&Wt.test(e))}var tn=class e extends k{_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`)Rt.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`)Bt||=new RegExp(zt,`u`),Bt.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`)Pt.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`)Ft.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`)jt.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`)Mt.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`)Nt.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`?Zt(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`?Jt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Xt(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`?Lt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`duration`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Qt(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`?$t(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`?en(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`?Gt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`base64`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Kt.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,...E.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...E.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...E.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...E.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...E.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...E.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...E.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...E.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...E.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...E.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...E.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...E.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...E.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...E.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,...E.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,...E.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...E.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...E.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...E.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...E.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...E.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...E.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...E.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...E.errToObj(t)})}nonempty(e){return this.min(1,E.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}};tn.create=e=>new tn({checks:[],typeName:L.ZodString,coerce:e?.coerce??!1,...O(e)});function nn(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 rn=class e extends k{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`?nn(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,E.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,E.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,E.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,E.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:E.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:E.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:E.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:E.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:E.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:E.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:E.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:E.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:E.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:E.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)}};rn.create=e=>new rn({checks:[],typeName:L.ZodNumber,coerce:e?.coerce||!1,...O(e)});var an=class e extends k{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,E.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,E.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,E.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,E.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:E.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:E.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:E.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:E.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:E.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:E.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}};an.create=e=>new an({checks:[],typeName:L.ZodBigInt,coerce:e?.coerce??!1,...O(e)});var on=class extends k{_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)}};on.create=e=>new on({typeName:L.ZodBoolean,coerce:e?.coerce||!1,...O(e)});var sn=class e extends k{_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:E.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:E.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)}};sn.create=e=>new sn({checks:[],coerce:e?.coerce||!1,typeName:L.ZodDate,...O(e)});var cn=class extends k{_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)}};cn.create=e=>new cn({typeName:L.ZodSymbol,...O(e)});var ln=class extends k{_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)}};ln.create=e=>new ln({typeName:L.ZodUndefined,...O(e)});var un=class extends k{_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)}};un.create=e=>new un({typeName:L.ZodNull,...O(e)});var dn=class extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return w(e.data)}};dn.create=e=>new dn({typeName:L.ZodAny,...O(e)});var fn=class extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return w(e.data)}};fn.create=e=>new fn({typeName:L.ZodUnknown,...O(e)});var A=class extends k{_parse(e){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.never,received:t.parsedType}),C}};A.create=e=>new A({typeName:L.ZodNever,...O(e)});var pn=class extends k{_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)}};pn.create=e=>new pn({typeName:L.ZodVoid,...O(e)});var mn=class e extends k{_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 D(t,e,t.path,n)))).then(e=>S.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new D(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:E.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:E.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:E.toString(n)}})}nonempty(e){return this.min(1,e)}};mn.create=(e,t)=>new mn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:L.ZodArray,...O(t)});function hn(e){if(e instanceof j){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=F.create(hn(r))}return new j({...e._def,shape:()=>t})}else if(e instanceof mn)return new mn({...e._def,type:hn(e.element)});else if(e instanceof F)return F.create(hn(e.unwrap()));else if(e instanceof I)return I.create(hn(e.unwrap()));else if(e instanceof N)return N.create(e.items.map(e=>hn(e)));else return e}var j=class e extends k{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 A&&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 D(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof A){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 D(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 E.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:E.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:L.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 hn(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 F;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return En(g.objectKeys(this.shape))}};j.create=(e,t)=>new j({shape:()=>e,unknownKeys:`strip`,catchall:A.create(),typeName:L.ZodObject,...O(t)}),j.strictCreate=(e,t)=>new j({shape:()=>e,unknownKeys:`strict`,catchall:A.create(),typeName:L.ZodObject,...O(t)}),j.lazycreate=(e,t)=>new j({shape:e,unknownKeys:`strip`,catchall:A.create(),typeName:L.ZodObject,...O(t)});var gn=class extends k{_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}};gn.create=(e,t)=>new gn({options:e,typeName:L.ZodUnion,...O(t)});var M=e=>e instanceof wn?M(e.schema):e instanceof P?M(e.innerType()):e instanceof Tn?[e.value]:e instanceof Dn?e.options:e instanceof On?g.objectValues(e.enum):e instanceof An?M(e._def.innerType):e instanceof ln?[void 0]:e instanceof un?[null]:e instanceof F?[void 0,...M(e.unwrap())]:e instanceof I?[null,...M(e.unwrap())]:e instanceof Pn||e instanceof In?M(e.unwrap()):e instanceof jn?M(e._def.innerType):[],_n=class e extends k{_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=M(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:L.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...O(r)})}};function vn(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=vn(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=vn(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 yn=class extends k{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Dt(e)||Dt(r))return C;let i=vn(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}))}};yn.create=(e,t,n)=>new yn({left:e,right:t,typeName:L.ZodIntersection,...O(n)});var N=class e extends k{_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 D(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})}};N.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new N({items:e,typeName:L.ZodTuple,rest:null,...O(t)})};var bn=class e extends k{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 D(n,e,n.path,e)),value:a._parse(new D(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 k?new e({keyType:t,valueType:n,typeName:L.ZodRecord,...O(r)}):new e({keyType:tn.create(),valueType:t,typeName:L.ZodRecord,...O(n)})}},xn=class extends k{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 D(n,e,n.path,[a,`key`])),value:i._parse(new D(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}}}};xn.create=(e,t,n)=>new xn({valueType:t,keyType:e,typeName:L.ZodMap,...O(n)});var Sn=class e extends k{_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 D(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:E.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:E.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Sn.create=(e,t)=>new Sn({valueType:e,minSize:null,maxSize:null,typeName:L.ZodSet,...O(t)});var Cn=class e extends k{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 kn){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:N.create(t).rest(fn.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||N.create([]).rest(fn.create()),returns:n||fn.create(),typeName:L.ZodFunction,...O(r)})}},wn=class extends k{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})}};wn.create=(e,t)=>new wn({getter:e,typeName:L.ZodLazy,...O(t)});var Tn=class extends k{_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}};Tn.create=(e,t)=>new Tn({value:e,typeName:L.ZodLiteral,...O(t)});function En(e,t){return new Dn({values:e,typeName:L.ZodEnum,...O(t)})}var Dn=class e extends k{_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})}};Dn.create=En;var On=class extends k{_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}};On.create=(e,t)=>new On({values:e,typeName:L.ZodNativeEnum,...O(t)});var kn=class extends k{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})))}};kn.create=(e,t)=>new kn({type:e,typeName:L.ZodPromise,...O(t)});var P=class extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===L.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(!T(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=>T(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):C);g.assertNever(r)}};P.create=(e,t,n)=>new P({schema:e,typeName:L.ZodEffects,effect:t,...O(n)}),P.createWithPreprocess=(e,t,n)=>new P({schema:t,effect:{type:`preprocess`,transform:e},typeName:L.ZodEffects,...O(n)});var F=class extends k{_parse(e){return this._getType(e)===_.undefined?w(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(e,t)=>new F({innerType:e,typeName:L.ZodOptional,...O(t)});var I=class extends k{_parse(e){return this._getType(e)===_.null?w(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};I.create=(e,t)=>new I({innerType:e,typeName:L.ZodNullable,...O(t)});var An=class extends k{_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}};An.create=(e,t)=>new An({innerType:e,typeName:L.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...O(t)});var jn=class extends k{_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 kt(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}};jn.create=(e,t)=>new jn({innerType:e,typeName:L.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...O(t)});var Mn=class extends k{_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}}};Mn.create=e=>new Mn({typeName:L.ZodNaN,...O(e)});var Nn=Symbol(`zod_brand`),Pn=class extends k{_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}},Fn=class e extends k{_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:L.ZodPipeline})}},In=class extends k{_parse(e){let t=this._def.innerType._parse(e),n=e=>(T(e)&&(e.value=Object.freeze(e.value)),e);return kt(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};In.create=(e,t)=>new In({innerType:e,typeName:L.ZodReadonly,...O(t)});function Ln(e,t){let n=typeof e==`function`?e(t):typeof e==`string`?{message:e}:e;return typeof n==`string`?{message:n}:n}function Rn(e,t={},n){return e?dn.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(e=>{if(!e){let e=Ln(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}});if(!a){let e=Ln(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}}):dn.create()}var zn={object:j.lazycreate},L;(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`})(L||={});var Bn=(e,t={message:`Input not instance of ${e.name}`})=>Rn(t=>t instanceof e,t),R=tn.create,z=rn.create,Vn=Mn.create,Hn=an.create,B=on.create,Un=sn.create,Wn=cn.create,Gn=ln.create,Kn=un.create,qn=dn.create,V=fn.create,Jn=A.create,Yn=pn.create,H=mn.create,U=j.create,Xn=j.strictCreate,Zn=gn.create,W=_n.create,Qn=yn.create,$n=N.create,G=bn.create,er=xn.create,tr=Sn.create,nr=Cn.create,rr=wn.create,K=Tn.create,q=Dn.create,ir=On.create,ar=kn.create,or=P.create,sr=F.create,cr=I.create,lr=P.createWithPreprocess,ur=Fn.create,dr=()=>R().optional(),fr=()=>z().optional(),pr=()=>B().optional(),mr={string:(e=>tn.create({...e,coerce:!0})),number:(e=>rn.create({...e,coerce:!0})),boolean:(e=>on.create({...e,coerce:!0})),bigint:(e=>an.create({...e,coerce:!0})),date:(e=>sn.create({...e,coerce:!0}))},hr=C,gr=t({BRAND:()=>Nn,DIRTY:()=>Et,EMPTY_PATH:()=>Tt,INVALID:()=>C,NEVER:()=>hr,OK:()=>w,ParseStatus:()=>S,Schema:()=>k,ZodAny:()=>dn,ZodArray:()=>mn,ZodBigInt:()=>an,ZodBoolean:()=>on,ZodBranded:()=>Pn,ZodCatch:()=>jn,ZodDate:()=>sn,ZodDefault:()=>An,ZodDiscriminatedUnion:()=>_n,ZodEffects:()=>P,ZodEnum:()=>Dn,ZodError:()=>b,ZodFirstPartyTypeKind:()=>L,ZodFunction:()=>Cn,ZodIntersection:()=>yn,ZodIssueCode:()=>y,ZodLazy:()=>wn,ZodLiteral:()=>Tn,ZodMap:()=>xn,ZodNaN:()=>Mn,ZodNativeEnum:()=>On,ZodNever:()=>A,ZodNull:()=>un,ZodNullable:()=>I,ZodNumber:()=>rn,ZodObject:()=>j,ZodOptional:()=>F,ZodParsedType:()=>_,ZodPipeline:()=>Fn,ZodPromise:()=>kn,ZodReadonly:()=>In,ZodRecord:()=>bn,ZodSchema:()=>k,ZodSet:()=>Sn,ZodString:()=>tn,ZodSymbol:()=>cn,ZodTransformer:()=>P,ZodTuple:()=>N,ZodType:()=>k,ZodUndefined:()=>ln,ZodUnion:()=>gn,ZodUnknown:()=>fn,ZodVoid:()=>pn,addIssueToContext:()=>x,any:()=>qn,array:()=>H,bigint:()=>Hn,boolean:()=>B,coerce:()=>mr,custom:()=>Rn,date:()=>Un,datetimeRegex:()=>Zt,defaultErrorMap:()=>bt,discriminatedUnion:()=>W,effect:()=>or,enum:()=>q,function:()=>nr,getErrorMap:()=>Ct,getParsedType:()=>v,instanceof:()=>Bn,intersection:()=>Qn,isAborted:()=>Dt,isAsync:()=>kt,isDirty:()=>Ot,isValid:()=>T,late:()=>zn,lazy:()=>rr,literal:()=>K,makeIssue:()=>wt,map:()=>er,nan:()=>Vn,nativeEnum:()=>ir,never:()=>Jn,null:()=>Kn,nullable:()=>cr,number:()=>z,object:()=>U,objectUtil:()=>vt,oboolean:()=>pr,onumber:()=>fr,optional:()=>sr,ostring:()=>dr,pipeline:()=>ur,preprocess:()=>lr,promise:()=>ar,quotelessJson:()=>yt,record:()=>G,set:()=>tr,setErrorMap:()=>St,strictObject:()=>Xn,string:()=>R,symbol:()=>Wn,transformer:()=>or,tuple:()=>$n,undefined:()=>Gn,union:()=>Zn,unknown:()=>V,util:()=>g,void:()=>Yn}),_r=U({username:R().min(1),password:R().min(1)}),vr=U({ok:K(!0),changePassword:B()}),yr=U({oldPassword:R().min(1),newPassword:R().min(6)}),br=U({ok:K(!0)}),xr=U({authenticated:B(),username:R().optional()});U({password:R().min(1)});var Sr=`0.8.1`,Cr=1883,wr=4840,Tr=1502,Er=65535,Dr=1e4,Or=1e3,kr=1e6,Ar=1e5,jr=/^[a-zA-Z0-9_-]{1,64}$/,Mr=/^\$param\.(\S+)$/,Nr=z().int().min(1).max(Er),Pr=U({state:q([`healthy`,`busy`,`saturated`]),pendingWorkCount:z().finite().int().nonnegative(),completedLastTick:z().finite().int().nonnegative()}),Fr=U({connected:B(),messagesPublished:z().finite().int().nonnegative(),messagesAttempted:z().finite().int().nonnegative(),messagesFiltered:z().finite().int().nonnegative(),errorsCount:z().finite().int().nonnegative(),lastPublishMs:z().finite().nonnegative(),health:Pr.optional()});U({name:R().min(1),enabled:B().default(!0)}).passthrough();var Ir=U({name:R().min(1),enabled:B(),pending:B().optional(),endpoint:R().optional(),boundPort:Nr.optional(),config:G(R(),V())}),J=U({environmentName:R().min(1).optional(),core:U({state:q([`idle`,`running`,`paused`,`stopped`]),tickCount:z().int().nonnegative(),simulationTimeSeconds:z().finite().nonnegative(),instanceCount:z().int().nonnegative(),memberValueCount:z().int().nonnegative(),quarantinedInstanceCount:z().int().nonnegative(),engineErrorsCount:z().int().nonnegative(),tickOverrunsCount:z().int().nonnegative(),circuitBreakerTripsCount:z().int().nonnegative(),uptimeMs:z().finite().nonnegative(),actualTicksPerSecond:z().finite().nonnegative()}),fleet:U({modelBreakdown:H(U({model:R().min(1),count:z().int().nonnegative()})),lifecycleBreakdown:G(R(),z().int().nonnegative()),activeFaultCount:z().int().nonnegative(),faultBreakdown:H(U({fault:R().min(1),count:z().int().nonnegative()}))}),adapters:H(U({name:R().min(1),metrics:Fr}))}),Lr=U({environmentName:R().min(1).optional(),models:H(U({name:R().min(1),memberCount:z().int().nonnegative(),faultCount:z().int().nonnegative(),faultNames:H(R().min(1)),hasLifecycle:B()})),instances:H(U({id:R().min(1),model:R().min(1),browsePath:H(R().min(1)),lifecycleStage:R().min(1),operatingHours:z().finite().nonnegative(),activeFaults:H(R().min(1)),isQuarantined:B()})),config:U({seed:z().int().nonnegative(),tickIntervalMs:z().int().positive(),timeMultiplier:z().finite().positive(),adapters:H(R().min(1)),template:U({name:R().min(1),path:R().min(1)}).optional()}),availableAdapters:H(Ir).optional()}),Rr=U({templateRunId:z().int().nonnegative(),templateName:R().min(1),prefix:R().min(1),instanceIds:H(R().min(1)),models:H(R().min(1)),templatePath:R().min(1).optional()}),zr=U({state:Lr,metrics:J,runningTemplates:H(Rr),revision:z().int().nonnegative()}),Br=W(`authenticated`,[U({authenticated:K(!1)}),U({authenticated:K(!0),username:R().min(1),runtime:zr})]),Vr=U({instanceId:R().min(1),memberName:R().min(1),value:Zn([z().finite(),R(),B()]),quality:q([`good`,`bad`,`uncertain`]),timestamp:z().finite().optional()}),Hr=W(`kind`,[U({kind:K(`fault:triggered`),instanceId:R().min(1),fault:R().min(1),effects:G(R(),V())}),U({kind:K(`fault:cleared`),instanceId:R().min(1),fault:R().min(1)}),U({kind:K(`lifecycle:changed`),instanceId:R().min(1),from:R().min(1),to:R().min(1),operatingHours:z().finite().nonnegative()}),U({kind:K(`instance:created`),id:R().min(1),assetType:R().min(1),browsePath:H(R().min(1))}),U({kind:K(`instance:removed`),id:R().min(1)}),U({kind:K(`engine:state`),from:J.shape.core.shape.state,to:J.shape.core.shape.state}),U({kind:K(`adapter:enabled`),name:R().min(1),endpoint:R().min(1)}),U({kind:K(`adapter:disabled`),name:R().min(1)})]),Ur=U({core:U({memberValueCount:J.shape.core.shape.memberValueCount,quarantinedInstanceCount:J.shape.core.shape.quarantinedInstanceCount,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}),Wr=W(`type`,[U({type:K(`runtime:snapshot`),snapshot:zr}),U({type:K(`runtime:tick`),revision:z().int().nonnegative(),tick:z().int().nonnegative(),simulationTime:z().finite().nonnegative(),delta:H(Vr),instanceCount:z().int().nonnegative(),metrics:Ur}),U({type:K(`runtime:event`),revision:z().int().nonnegative(),event:Hr}),U({type:K(`runtime:resync-required`),revision:z().int().nonnegative(),reason:R().min(1)})]),Gr=/^[A-Za-z0-9_-]+$/;function Kr(e){let t=e.split(/[-_]/).filter(e=>e.length>0);return t[t.length-1]??e}function qr(e){return String(e).padStart(3,`0`)}function Jr(e,t){return`${e}-${qr(t)}`}function Yr(e){return e.replace(/[\\/]+/g,`-`)}function Xr(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(!Gr.test(e))return`Use only letters, numbers, underscores, and hyphens.`;return null}function Zr(e){let t=e.trim();return t.length===0?null:t.length>120?`Use at most 120 characters.`:Xr(e)}var Qr=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`,Y=q([`mqtt`,`opcua`,`modbus`]),$r=H(Y).min(1),ei=U({model:R().min(1),count:z().int().positive().default(1),variation:z().min(0).max(1).default(0),parameters:G(R(),z().finite()).optional(),starting_hours:z().finite().nonnegative().optional(),protocol_scope:$r.optional()}).strict(),ti=U({name:R().regex(jr,Qr),twins:H(ei).min(1),protocol_scope:$r.optional()}).strict(),ni=U({name:R().regex(jr,Qr),lines:H(ti).min(1),protocol_scope:$r.optional()}).strict(),ri=Zn([U({enterprise:R().regex(jr,Qr),site:R().regex(jr,Qr)}).strict(),U({prefix:R().regex(jr,Qr)}).strict()]),ii=U({maxAttempts:z().finite().int().min(0).default(0),initialDelayMs:z().finite().int().positive().default(1e3),maxDelayMs:z().finite().int().positive().default(3e4)}).strict(),ai=U({enabled:B().default(!1),deadband:z().finite().nonnegative().default(0)}).strict(),oi=q([`base`,`full`]),si=U({embedded:B().default(!0),port:z().int().min(0).max(65535).default(1883),external:R().optional(),retain:B().default(!1),username:R().optional(),password:R().optional(),reconnect:ii.optional(),rbe:ai.optional(),metadata:oi.default(`base`),drain_budget:z().int().min(512).max(65536).optional(),batch_size:z().int().min(64).max(16384).optional(),broker_concurrency:z().int().min(10).max(5e3).optional()}).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'.`}),ci=U({port:z().int().min(0).max(65535).default(wr),host:R().default(`0.0.0.0`),security:q([`none`]).default(`none`),buildInfo:U({productName:R().default(`Miravo`)}).strict().optional(),write_budget:z().int().min(512).max(65536).optional()}),li=U({port:z().int().min(0).max(65535).default(Tr),host:R().default(`0.0.0.0`)}),ui=U({mqtt:si.optional(),opcua:ci.optional(),modbus:li.optional()}).strict(),di=q([`real-time`,`accelerated`]),fi=U({max_members_per_model:z().int().positive().max(Ar).default(Or),max_twin_count:z().int().positive().max(kr).default(Dr)}).strict(),pi=U({tick_interval_ms:z().int().positive().default(1e3),time_mode:di.default(`real-time`),time_multiplier:z().positive().default(1),seed:z().int().optional(),overrun_threshold_multiplier:z().min(1).max(10).optional(),limits:fi.optional()}).strict();U({kind:K(`MiravoTemplate`),version:K(`1`),name:R().min(1),description:R().optional(),namespace:ri.optional(),areas:H(ni).min(1),protocols:ui.optional(),settings:pi.optional()}).strict().superRefine((e,t)=>{let n=e.settings?.limits?.max_twin_count??1e4;for(let r=0;r<e.areas.length;r++){let i=e.areas[r];if(i)for(let e=0;e<i.lines.length;e++){let a=i.lines[e];if(a)for(let i=0;i<a.twins.length;i++){let o=a.twins[i];!o||o.count<=n||t.addIssue({code:y.custom,path:[`areas`,r,`lines`,e,`twins`,i,`count`],message:`Twin assignment count must be at most ${n}. Fix: reduce count or set settings.limits.max_twin_count higher.`})}}}});var mi=1e3,X=U({correlationId:R().optional()}),hi=R().trim().min(1).superRefine((e,t)=>{let n=Zr(e);n&&t.addIssue({code:y.custom,message:n})}),gi=X.extend({type:K(`spawn`),model:R().min(1),count:z().int().positive().max(Dr),instanceName:hi.optional(),instancePrefix:hi.optional(),variation:z().min(0).max(1).optional(),unsBasePath:R().min(1).optional(),parameterOverrides:G(R(),z().finite()).optional(),startingHours:z().nonnegative().finite().optional(),protocolScope:$r.optional()}),_i=X.extend({type:K(`removeInstance`),instanceId:R().min(1)}),vi=X.extend({type:K(`setParameter`),instanceId:R().min(1),parameter:R().min(1),value:z().finite()}),yi=X.extend({type:K(`triggerFault`),instanceId:R().min(1),fault:R().min(1)}),bi=X.extend({type:K(`clearFault`),instanceId:R().min(1),fault:R().min(1)}),xi=X.extend({type:K(`pause`)}),Si=X.extend({type:K(`resume`)}),Ci=X.extend({type:K(`setSpeed`),multiplier:z().positive().finite().max(mi)}),wi=X.extend({type:K(`unquarantine`),instanceId:R().min(1)}),Ti=X.extend({type:K(`invokeMethod`),instanceId:R().min(1),method:R().min(1),arguments:G(R().min(1),Zn([z().finite(),R(),B()])).optional()}),Ei=X.extend({type:K(`loadTemplate`),templatePath:R().min(1),count:z().int().positive().default(1),namePrefix:hi.optional()}),Di=X.extend({type:K(`unloadTemplateRun`),templateRunId:z().int().positive()}),Oi=X.extend({type:K(`resetEnvironment`),clearPersistence:B().optional()}),ki=X.extend({type:K(`enableAdapter`),adapter:R().min(1),config:G(R(),V()).optional()}),Ai=X.extend({type:K(`disableAdapter`),adapter:R().min(1)}),ji=W(`type`,[gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai]),Mi=U({success:B(),command:R(),correlationId:R().optional(),message:R(),data:V().optional(),error:R().optional()}),Ni=`/api`,Pi=U({name:R().min(1),description:R().nullable(),memberCount:z().int().nonnegative(),methodCount:z().int().nonnegative(),faultCount:z().int().nonnegative(),hasLifecycle:B(),lifecycleStageCount:z().int().nonnegative(),source:R().min(1)}),Fi=U({model:R().min(1),count:z().int().nonnegative(),variation:z().finite().nonnegative(),parameters:G(R().min(1),z().finite()).optional(),protocol_scope:H(Y).optional()}),Ii=U({name:R().min(1),twins:H(Fi),protocol_scope:H(Y).optional()}),Li=U({name:R().min(1),lines:H(Ii),protocol_scope:H(Y).optional()}),Ri=U({id:R().min(1),name:R().min(1),description:R().nullable(),category:R().min(1),models:H(R().min(1)),instanceCount:z().int().nonnegative(),memberCount:z().int().nonnegative(),source:R().min(1)}),zi=Ri,Bi=Ri.extend({topology:H(Li),namespace:U({enterprise:R().min(1).optional(),site:R().min(1).optional(),prefix:R().min(1).optional()}).optional(),settings:U({tickIntervalMs:z().int().positive().optional(),timeMultiplier:z().finite().positive().optional(),limits:U({maxMembersPerModel:z().int().positive().optional(),maxTwinCount:z().int().positive().optional()}).optional()}).optional()}),Vi=q([`idle`,`running`,`paused`,`stopped`]),Hi=U({events:H(W(`type`,[U({id:z().int().nonnegative(),type:K(`fault:triggered`),instanceId:R().min(1),fault:R().min(1),effects:G(R(),V()),tick:z().int().nonnegative(),simulationTime:z().finite().nonnegative(),timestamp:z().finite().nonnegative()}),U({id:z().int().nonnegative(),type:K(`fault:cleared`),instanceId:R().min(1),fault:R().min(1),tick:z().int().nonnegative(),simulationTime:z().finite().nonnegative(),timestamp:z().finite().nonnegative()}),U({id:z().int().nonnegative(),type:K(`lifecycle:changed`),instanceId:R().min(1),from:R().min(1),to:R().min(1),operatingHours:z().finite().nonnegative(),tick:z().int().nonnegative(),simulationTime:z().finite().nonnegative(),timestamp:z().finite().nonnegative()}),U({id:z().int().nonnegative(),type:K(`instance:created`),instanceId:R().min(1),assetType:R().min(1),browsePath:H(R().min(1)),tick:z().int().nonnegative(),simulationTime:z().finite().nonnegative(),timestamp:z().finite().nonnegative()}),U({id:z().int().nonnegative(),type:K(`instance:removed`),instanceId:R().min(1),tick:z().int().nonnegative(),simulationTime:z().finite().nonnegative(),timestamp:z().finite().nonnegative()}),U({id:z().int().nonnegative(),type:K(`engine:state-changed`),from:Vi,to:Vi,tick:z().int().nonnegative(),simulationTime:z().finite().nonnegative(),timestamp:z().finite().nonnegative()}),U({id:z().int().nonnegative(),type:K(`platform:resource`),operationId:R().min(1),operationType:q([`apply`,`cleanup`]),templateId:R().min(1),targetLabel:R().min(1),hostname:R().min(1),phase:R().min(1),resourceType:R().min(1),resourceName:R().min(1),action:R().min(1),status:q([`success`,`failed`]),error:R().optional(),tick:z().int().nonnegative(),simulationTime:z().finite().nonnegative(),timestamp:z().finite().nonnegative()}),U({id:z().int().nonnegative(),type:K(`platform:operation`),operationId:R().min(1),operationType:q([`apply`,`cleanup`]),templateId:R().min(1),targetLabel:R().min(1),hostname:R().min(1),applied:z().int().nonnegative(),failed:z().int().nonnegative(),duration:z().int().nonnegative(),tick:z().int().nonnegative(),simulationTime:z().finite().nonnegative(),timestamp:z().finite().nonnegative()})])),nextCursor:z().int().nonnegative().nullable(),hasMore:B()}),Ui=Zn([z().finite(),R(),B()]),Wi=$n([z().finite(),z().finite()]),Gi=U({name:R().min(1),dataType:R().min(1),description:R().nullable()}),Ki=U({description:R().nullable(),inputArguments:H(Gi),outputArguments:H(Gi)}),qi=U({id:R().min(1),assetType:R().min(1),browsePath:H(R().min(1)),lifecycleStage:R().min(1),operatingHours:z().finite().nonnegative(),activeFaults:H(R().min(1)),isQuarantined:B(),parameters:G(R().min(1),U({value:Ui,type:R().min(1),unit:R().optional()})),members:G(R().min(1),U({value:Ui,quality:q([`good`,`bad`,`uncertain`]),timestamp:z().finite(),meta:U({kind:R().min(1),dataType:R().min(1),access:R().min(1),unit:R().nullable(),euRange:Wi.nullable()})})),methods:G(R().min(1),Ki)}),Ji=U({enabled:B(),port:z().int().positive().optional()}),Yi=U({instance:R().min(1),browsePath:R(),member:R().min(1),model:R().min(1),dataType:R().min(1),unit:R().optional(),euRange:$n([z().finite(),z().finite()]).optional(),access:R().min(1),kind:q([`variable`,`property`]),protocols:G(R(),G(R(),V()))}),Xi=U({template:R().min(1).optional(),generatedAt:R().datetime(),protocols:G(R(),Ji),tags:H(Yi),summary:U({totalTags:z().int().nonnegative(),totalInstances:z().int().nonnegative(),enabledProtocols:H(R().min(1))})}),Zi=U({name:R().min(1),description:R().nullable(),parameters:G(R().min(1),U({type:R().min(1),default:Ui,unit:R().optional()})),members:G(R().min(1),U({kind:R().min(1),dataType:R().min(1),access:R().min(1),unit:R().nullable(),euRange:Wi.nullable(),default:Ui.nullable()})),methods:G(R().min(1),Ki),faults:H(R().min(1)),lifecycle:U({stages:H(R().min(1)),totalHours:z().finite().nonnegative()}).nullable()}),Qi=q([`devices`,`models`,`instances`]),$i=q([`create`,`update`,`replace`,`delete`,`noop`,`blocked`]),ea=q([`device`,`model`,`instance`,`param-sync`]),ta=q([`apply`,`cleanup`]),na=q([`success`,`partial`,`blocked`,`noop`,`failed`]);q([`device`,`model`,`instance`,`param-sync`]),q([`create`,`update`,`replace`,`delete`]);var ra=U({area:R().min(1).optional(),line:R().min(1).optional(),instance:R().min(1).optional()}),ia=U({action:$i,resourceType:ea,name:R().min(1),resourceId:R().min(1).optional(),protocol:Y.optional(),endpoint:R().min(1).optional(),detail:R().min(1).optional(),blockReason:R().min(1).optional()}),aa=U({sourceMode:q([`static`,`managed`]),targetHost:R().min(1),sourceHostname:R().min(1).optional(),scope:H(Qi),filters:ra,entries:H(ia)}),oa=U({plan:aa}),sa=R().trim().min(1).superRefine((e,t)=>{let n=Zr(e);n&&t.addIssue({code:y.custom,message:n})}),ca=U({targetId:R().min(1),template:R().min(1).optional(),model:R().min(1).optional(),protocol:Y.optional(),scope:H(Qi).optional(),area:R().min(1).optional(),line:R().min(1).optional(),instance:R().min(1).optional(),ifUnmanaged:q([`fail`,`skip`]).optional(),deviceName:sa.optional(),namePrefix:sa.optional()}),la=U({plan:aa,applied:z().int().nonnegative(),failed:z().int().nonnegative(),error:R().min(1).optional()}),ua=U({targetId:R().min(1),template:R().min(1).optional(),allManaged:B().optional(),scope:H(Qi).optional(),area:R().min(1).optional(),line:R().min(1).optional(),instance:R().min(1).optional()}),da=U({plan:aa,deleted:z().int().nonnegative(),failed:z().int().nonnegative(),error:R().min(1).optional()}),fa=U({create:z().int().nonnegative(),update:z().int().nonnegative(),replace:z().int().nonnegative(),delete:z().int().nonnegative(),noop:z().int().nonnegative(),failed:z().int().nonnegative(),total:z().int().nonnegative()}),pa=U({device:fa,model:fa,instance:fa,"param-sync":fa}),ma=U({operations:H(U({schemaVersion:K(1),operationId:R().min(1),operationType:ta,status:na,templateId:R().min(1),targetId:R().min(1),targetLabel:R().min(1),hostname:R().min(1),scope:H(R().min(1)),filters:ra,successCount:z().int().nonnegative(),failedCount:z().int().nonnegative(),blockedCount:z().int().nonnegative(),startedAt:z().int().nonnegative(),completedAt:z().int().nonnegative(),durationMs:z().int().nonnegative(),resourceCounts:pa,error:R().min(1).optional()})),total:z().int().nonnegative(),hasMore:B()}),ha=U({type:ta.optional(),targetId:R().min(1).optional(),limit:mr.number().int().positive().max(500).optional(),offset:mr.number().int().nonnegative().optional()}),ga=U({cancelled:K(!0)}),_a=U({operationId:R().min(1),type:ta,template:R().min(1).optional(),model:R().min(1).optional(),environment:R().min(1),totalPlanned:z().int().nonnegative(),attempt:z().int().positive().optional(),maxAttempts:z().int().positive().optional()}),va=U({operationId:R().min(1),type:ta,targetId:R().min(1).optional(),template:R().min(1).optional(),model:R().min(1).optional()}),ya=U({operationId:R().min(1),phase:ea,total:z().int().nonnegative()}),ba=U({operationId:R().min(1),phase:ea,name:R().min(1),action:$i,status:q([`success`,`failed`]),error:R().min(1).optional(),index:z().int().positive(),of:z().int().positive()}),xa=U({operationId:R().min(1),applied:z().int().nonnegative().optional(),deleted:z().int().nonnegative().optional(),failed:z().int().nonnegative(),duration:z().int().nonnegative(),plan:aa}),Sa=xa,Ca=xa,wa=U({operationId:R().min(1),attempt:z().int().positive(),maxAttempts:z().int().positive(),delayMs:z().int().nonnegative(),error:R().min(1)}),Ta=U({message:R().min(1)}),Ea=U({level:q([`info`,`warn`,`error`]),message:R().min(1),protocol:Y.optional(),port:Nr.optional(),templatePort:Nr.optional()}),Da=W(`event`,[U({event:K(`log`),data:Ea}),U({event:K(`started`),data:_a}),U({event:K(`accepted`),data:va}),U({event:K(`phase`),data:ya}),U({event:K(`resource`),data:ba}),U({event:K(`complete`),data:Sa}),U({event:K(`cancelled`),data:Ca}),U({event:K(`retrying`),data:wa}),U({event:K(`error`),data:Ta})]),Oa=`litmus-edge`,ka=U({id:R().min(1),platformId:R().min(1),label:R().min(1),hostname:R().min(1),apiTokenSet:B(),sourceHostname:R().min(1),lastUsedAt:z().int().nonnegative().optional()}).strict(),Aa=U({targets:H(ka)}).strict(),ja=U({platformId:R().min(1).default(Oa),label:R().min(1),hostname:R().min(1),apiToken:R().min(1),sourceHostname:R().min(1)}),Ma=U({platformId:R().min(1).optional(),label:R().min(1).optional(),hostname:R().min(1).optional(),apiToken:R().min(1).optional(),sourceHostname:R().min(1).optional()}),Na=U({targetId:R().min(1).optional(),hostname:R().min(1),apiToken:R().min(1).optional(),sourceHostname:R().min(1)}).superRefine((e,t)=>{!e.targetId&&!e.apiToken&&t.addIssue({code:y.custom,message:`apiToken is required when targetId is omitted.`,path:[`apiToken`]})}),Pa=W(`connected`,[U({connected:K(!0),hostname:R().min(1),sourceHostname:R().min(1),litmusEdgeVersion:R().min(1).optional(),warning:R().min(1).optional()}),U({connected:K(!1),error:R().min(1)})]),Fa=U({status:q([`ok`,`fail`]),environmentState:J.shape.core.shape.state,tickCount:z().int().nonnegative(),mqttEnabled:B(),mqttConnected:B().nullable(),opcuaEnabled:B(),opcuaConnected:B().nullable(),modbusEnabled:B(),modbusConnected:B().nullable(),stalled:B(),reason:R().optional(),environmentName:R().min(1).optional(),runId:R().min(1).optional()}),Ia=U({reason:R().min(1).optional()}),La=U({status:K(`shutting_down`)}),Ra=U({id:R().min(1)}),za=U({name:R().min(1)}),Ba=U({id:R().min(1)}),Va=U({operationId:R().min(1)}),Ha=U({id:R().min(1)}),Ua=U({type:q([`fault:triggered`,`fault:cleared`,`lifecycle:changed`,`instance:created`,`instance:removed`,`engine:state-changed`,`platform:resource`,`platform:operation`]).optional(),instanceId:R().min(1).optional(),limit:mr.number().int().positive().max(1e3).optional(),cursor:mr.number().int().nonnegative().optional()}),Wa=U({host:R().min(1),protocol:Y.optional()}),Ga=G(R(),V()),Ka=G(R(),V());function Z(e){return`${Ni}${e}`}var qa=[{method:`GET`,path:Z(`/openapi.json`),operationId:`openApiDocument`,auth:`none`,response:{kind:`json`,schema:Ka},description:`Generated OpenAPI document for the Miravo admin API.`},{method:`GET`,path:Z(`/healthz`),operationId:`health`,auth:`none`,response:{kind:`json`,schema:Fa},description:`Liveness probe for the Miravo admin server.`},{method:`GET`,path:Z(`/readyz`),operationId:`readiness`,auth:`none`,response:{kind:`json`,schema:Fa},description:`Readiness probe for the Miravo admin server.`},{method:`GET`,path:Z(`/metrics`),operationId:`metrics`,auth:`required`,response:{kind:`json`,schema:J},description:`Engine metrics snapshot.`},{method:`GET`,path:Z(`/state`),operationId:`state`,auth:`required`,response:{kind:`json`,schema:Lr},description:`Engine state snapshot.`},{method:`GET`,path:Z(`/bootstrap`),operationId:`bootstrap`,auth:`none`,response:{kind:`json`,schema:Br},description:`Console bootstrap payload.`},{method:`POST`,path:Z(`/commands`),operationId:`commands`,auth:`required`,body:ji,response:{kind:`json`,schema:Mi},description:`Execute an engine command.`},{method:`POST`,path:Z(`/shutdown`),operationId:`shutdown`,auth:`required`,body:Ia,response:{kind:`json`,schema:La},description:`Request graceful shutdown.`},{method:`GET`,path:Z(`/instances/:id`),operationId:`instanceDetail`,auth:`required`,params:Ra,response:{kind:`json`,schema:qi},description:`Inspect a running instance.`},{method:`GET`,path:Z(`/models/:name`),operationId:`modelDetail`,auth:`required`,params:za,response:{kind:`json`,schema:Zi},description:`Inspect a registered model schema.`},{method:`GET`,path:Z(`/events`),operationId:`events`,auth:`required`,query:Ua,response:{kind:`json`,schema:Hi},description:`Read paginated event log entries.`},{method:`GET`,path:Z(`/catalog/models`),operationId:`catalogModels`,auth:`required`,response:{kind:`json`,schema:H(Pi)},description:`List catalog models.`},{method:`GET`,path:Z(`/catalog/models/:name/le-dt.json`),operationId:`catalogModelLeDt`,auth:`required`,params:za,response:{kind:`json`,schema:Ga},description:`Download LE Digital Twin JSON for a catalog model.`},{method:`GET`,path:Z(`/catalog/models/:name/yaml`),operationId:`catalogModelYaml`,auth:`required`,params:za,response:{kind:`yaml`},description:`Read raw YAML for a catalog model.`},{method:`GET`,path:Z(`/catalog/models/:name`),operationId:`catalogModelDetail`,auth:`required`,params:za,response:{kind:`json`,schema:Zi},description:`Read catalog model schema.`},{method:`GET`,path:Z(`/catalog/templates/:id/le-template.json`),operationId:`catalogTemplateLeTemplateJson`,auth:`required`,params:Ba,query:Wa,response:{kind:`passthrough`},description:`Download LE template JSON export.`},{method:`GET`,path:Z(`/catalog/templates/:id/le-tags.csv`),operationId:`catalogTemplateLeTagsCsv`,auth:`required`,params:Ba,query:Wa,response:{kind:`passthrough`},description:`Download LE tags CSV export.`},{method:`GET`,path:Z(`/catalog/templates/:id/yaml`),operationId:`catalogTemplateYaml`,auth:`required`,params:Ba,response:{kind:`yaml`},description:`Read raw YAML for a catalog template.`},{method:`GET`,path:Z(`/catalog/templates/:id`),operationId:`catalogTemplateDetail`,auth:`required`,params:Ba,response:{kind:`json`,schema:Bi},description:`Read catalog template detail.`},{method:`GET`,path:Z(`/catalog/templates`),operationId:`catalogTemplates`,auth:`required`,response:{kind:`json`,schema:H(zi)},description:`List catalog templates.`},{method:`GET`,path:Z(`/running-templates`),operationId:`runningTemplates`,auth:`required`,response:{kind:`json`,schema:H(Rr)},description:`List running template runs.`},{method:`GET`,path:Z(`/manifest`),operationId:`manifest`,auth:`required`,response:{kind:`json`,schema:Xi},description:`Read unified protocol manifest.`},{method:`POST`,path:Z(`/auth/login`),operationId:`authLogin`,auth:`none`,body:_r,response:{kind:`json`,schema:vr},description:`Authenticate and create an admin session.`},{method:`POST`,path:Z(`/auth/logout`),operationId:`authLogout`,auth:`none`,response:{kind:`json`,schema:br},description:`Destroy the current admin session.`},{method:`PUT`,path:Z(`/auth/password`),operationId:`authPassword`,auth:`required`,body:yr,response:{kind:`json`,schema:br},description:`Change the admin password.`},{method:`GET`,path:Z(`/auth/status`),operationId:`authStatus`,auth:`none`,response:{kind:`json`,schema:xr},description:`Check the current auth status.`},{method:`GET`,path:Z(`/ws`),operationId:`runtimeWebSocket`,auth:`required`,response:{kind:`passthrough`},description:`Upgrade to the runtime WebSocket stream.`},{method:`GET`,path:Z(`/platforms/le/operations`),operationId:`platformOperations`,auth:`required`,query:ha,response:{kind:`json`,schema:ma},description:`List persisted platform operation summaries.`},{method:`GET`,path:Z(`/platforms/le/targets`),operationId:`platformTargets`,auth:`required`,response:{kind:`json`,schema:Aa},description:`List saved LE targets.`},{method:`POST`,path:Z(`/platforms/le/targets`),operationId:`platformTargetCreate`,auth:`required`,body:ja,response:{kind:`json`,schema:ka},description:`Create an LE target.`},{method:`POST`,path:Z(`/platforms/le/targets/test`),operationId:`platformConnectionTest`,auth:`required`,body:Na,response:{kind:`json`,schema:Pa},description:`Test LE target connectivity.`},{method:`GET`,path:Z(`/platforms/le/targets/:id`),operationId:`platformTargetDetail`,auth:`required`,params:Ha,response:{kind:`json`,schema:ka},description:`Read one LE target.`},{method:`PUT`,path:Z(`/platforms/le/targets/:id`),operationId:`platformTargetById`,auth:`required`,params:Ha,body:Ma,response:{kind:`json`,schema:ka},description:`Update one LE target.`},{method:`DELETE`,path:Z(`/platforms/le/targets/:id`),operationId:`platformTargetDelete`,auth:`required`,params:Ha,response:{kind:`json`,schema:U({message:R().min(1)})},description:`Delete one LE target.`},{method:`POST`,path:Z(`/platforms/le/plan`),operationId:`platformPlan`,auth:`required`,body:ca,response:{kind:`json`,schema:oa},description:`Preview an LE apply plan.`},{method:`POST`,path:Z(`/platforms/le/apply`),operationId:`platformApply`,auth:`required`,body:ca,response:{kind:`json`,schema:la},additionalSuccessResponses:{207:la},description:`Apply a platform plan.`},{method:`POST`,path:Z(`/platforms/le/cleanup/plan`),operationId:`platformCleanupPlan`,auth:`required`,body:ua,response:{kind:`json`,schema:oa},description:`Preview an LE cleanup plan.`},{method:`POST`,path:Z(`/platforms/le/cleanup`),operationId:`platformCleanup`,auth:`required`,body:ua,response:{kind:`json`,schema:da},additionalSuccessResponses:{207:da},description:`Execute LE cleanup.`},{method:`POST`,path:Z(`/platforms/le/operations/:operationId/cancel`),operationId:`platformOperationCancel`,auth:`required`,params:Va,response:{kind:`json`,schema:ga},description:`Cancel an in-flight streaming LE operation.`},{method:`POST`,path:Z(`/platforms/le/apply/stream`),operationId:`platformApplyStream`,auth:`required`,body:ca,response:{kind:`passthrough`},description:`Stream LE apply progress over SSE.`},{method:`POST`,path:Z(`/platforms/le/cleanup/stream`),operationId:`platformCleanupStream`,auth:`required`,body:ua,response:{kind:`passthrough`},description:`Stream LE cleanup progress over SSE.`}],Ja=U({code:q([`UNAUTHORIZED`,`NOT_FOUND`,`INVALID_REQUEST`,`INTERNAL_ERROR`]),message:R(),hint:R().optional()}),Ya={UNAUTHORIZED:401,NOT_FOUND:404,INVALID_REQUEST:400,INTERNAL_ERROR:500},Xa=class extends Error{code;status;hint;constructor(e){super(e.message),this.name=`ApiError`,this.code=e.code,this.status=e.status??Ya[e.code],this.hint=e.hint}static is(e){return e instanceof Error&&e.name===`ApiError`}};function Za(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 Qa(e,t){return e?._def?.typeName===t}function $a(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 eo(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=Za(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(Qa(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},$a(e,`optional`),$a(e,`nullable`),$a(e,`default`),$a(e,`transform`),$a(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 to=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)}};eo(gr),new to,W(`type`,[gi.openapi(`SpawnCommand`),_i.openapi(`RemoveInstanceCommand`),vi.openapi(`SetParameterCommand`),yi.openapi(`TriggerFaultCommand`),bi.openapi(`ClearFaultCommand`),xi.openapi(`PauseCommand`),Si.openapi(`ResumeCommand`),Ci.openapi(`SetSpeedCommand`),wi.openapi(`UnquarantineCommand`),Ti.openapi(`InvokeMethodCommand`),Ei.openapi(`LoadTemplateCommand`),Di.openapi(`UnloadTemplateRunCommand`),Oi.openapi(`ResetEnvironmentCommand`),ki.openapi(`EnableAdapterCommand`),Ai.openapi(`DisableAdapterCommand`)]).openapi(`EngineCommand`);var no=new Map(qa.map(e=>[`${e.method} ${e.path}`,e]));function Q(e,t){let n=no.get(`${e} ${t}`);if(!n)throw Error(`Missing admin route definition for ${e} ${t}`);return n}var ro={authLogin:Q(`POST`,`/api/auth/login`),authLogout:Q(`POST`,`/api/auth/logout`),authPassword:Q(`PUT`,`/api/auth/password`),authStatus:Q(`GET`,`/api/auth/status`),bootstrap:Q(`GET`,`/api/bootstrap`),catalogModelDetail:Q(`GET`,`/api/catalog/models/:name`),catalogModelLeDt:Q(`GET`,`/api/catalog/models/:name/le-dt.json`),catalogModels:Q(`GET`,`/api/catalog/models`),catalogModelYaml:Q(`GET`,`/api/catalog/models/:name/yaml`),catalogTemplateDetail:Q(`GET`,`/api/catalog/templates/:id`),catalogTemplateLeTagsCsv:Q(`GET`,`/api/catalog/templates/:id/le-tags.csv`),catalogTemplateLeTemplateJson:Q(`GET`,`/api/catalog/templates/:id/le-template.json`),catalogTemplates:Q(`GET`,`/api/catalog/templates`),catalogTemplateYaml:Q(`GET`,`/api/catalog/templates/:id/yaml`),commands:Q(`POST`,`/api/commands`),events:Q(`GET`,`/api/events`),health:Q(`GET`,`/api/healthz`),instanceDetail:Q(`GET`,`/api/instances/:id`),manifest:Q(`GET`,`/api/manifest`),metrics:Q(`GET`,`/api/metrics`),modelDetail:Q(`GET`,`/api/models/:name`),openApiDocument:Q(`GET`,`/api/openapi.json`),platformApply:Q(`POST`,`/api/platforms/le/apply`),platformApplyStream:Q(`POST`,`/api/platforms/le/apply/stream`),platformCleanup:Q(`POST`,`/api/platforms/le/cleanup`),platformCleanupPlan:Q(`POST`,`/api/platforms/le/cleanup/plan`),platformCleanupStream:Q(`POST`,`/api/platforms/le/cleanup/stream`),platformConnectionTest:Q(`POST`,`/api/platforms/le/targets/test`),platformOperationCancel:Q(`POST`,`/api/platforms/le/operations/:operationId/cancel`),platformOperations:Q(`GET`,`/api/platforms/le/operations`),platformPlan:Q(`POST`,`/api/platforms/le/plan`),platformTargetById:Q(`PUT`,`/api/platforms/le/targets/:id`),platformTargetCreate:Q(`POST`,`/api/platforms/le/targets`),platformTargetDelete:Q(`DELETE`,`/api/platforms/le/targets/:id`),platformTargetDetail:Q(`GET`,`/api/platforms/le/targets/:id`),platformTargets:Q(`GET`,`/api/platforms/le/targets`),readiness:Q(`GET`,`/api/readyz`),runningTemplates:Q(`GET`,`/api/running-templates`),runtimeWebSocket:Q(`GET`,`/api/ws`),shutdown:Q(`POST`,`/api/shutdown`),state:Q(`GET`,`/api/state`)},io=`miravo:console-username`;function ao(){try{let e=sessionStorage.getItem(io);return typeof e==`string`&&e.length>0?e:``}catch{return``}}function oo(e){try{e!==null&&e.length>0?sessionStorage.setItem(io,e):sessionStorage.removeItem(io)}catch{}}var so=new $e({defaultOptions:{queries:{staleTime:3e4,gcTime:10*6e4,retry:(e,t)=>{if(t instanceof Error&&t.message===`Session expired`)return!1;if(Xa.is(t)){let e=t.status;if(e>=400&&e<500)return!1}return e<2},refetchOnWindowFocus:!1}}}),co={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]},events:(e,t)=>[`events`,e,t],tags:{manifest:e=>[`tags`,`manifest`,e]},platforms:{targets:()=>[`platforms`,`targets`],operationsList:()=>[`platforms`,`operations`,`list`]},instances:{detail:e=>[`instances`,e]}},lo=`miravo:query-cache:v1`,uo=5*6e4,fo=co.platforms.targets(),po=`bootstrap`,mo=!0;function ho(e){try{let t=sessionStorage.getItem(lo);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>uo){sessionStorage.removeItem(lo);return}Ae(e,r.state)}catch{}}function go(e){try{let t=ke(e,{shouldDehydrateQuery:e=>e.state.status===`success`&&e.queryKey[0]!==po&&!(e.queryKey[0]===fo[0]&&e.queryKey[1]===fo[1])}),n={timestamp:Date.now(),state:t};sessionStorage.setItem(lo,JSON.stringify(n))}catch{}}function _o(e){let t=null,n=e.getQueryCache().subscribe(()=>{mo&&(t&&clearTimeout(t),t=setTimeout(()=>{mo&&go(e)},500))});return()=>{t&&clearTimeout(t),n()}}function vo(){try{sessionStorage.removeItem(lo)}catch{}}function yo(){mo=!0}function bo(){mo=!1}var xo=(void 0)?.trim()||`/api`;function So(e,t){return`${e.trim().replace(/\/+$/,``)||`/api`}${t.startsWith(`/`)?t:`/${t}`}`}function Co(){bo(),so.cancelQueries(),so.setQueryData([`bootstrap`],{authenticated:!1}),so.removeQueries({predicate:e=>e.queryKey[0]!==`bootstrap`}),vo(),ft(),oo(null)}function wo(){typeof window>`u`||(Co(),window.location.pathname!==`/login`&&window.location.replace(`/login`))}var To=class extends Error{result;constructor(e){super(e.message),this.name=`CommandError`,this.result=e}};function Eo(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 Do(e){try{let t=await e.json(),n=Ja.safeParse(t);if(n.success)return new Xa({code:n.data.code,status:e.status,message:n.data.message,hint:n.data.hint})}catch{}return Error(Eo(e.status,e.statusText))}async function Oo(e,t){return $(`/auth/login`,ro.authLogin,{body:{username:e,password:t}})}async function ko(){await $(`/auth/logout`,ro.authLogout)}function Ao(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 $(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(So(xo,e),a);if(o.status===401&&t.auth===`required`)throw wo(),Error(`Session expired`);if(!o.ok)throw await Do(o);let s;try{s=await o.json()}catch{throw Error(`Invalid JSON response for ${t.method} ${t.path}`)}let c=Ao(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 jo(e,t){return $(`/auth/password`,ro.authPassword,{body:{oldPassword:e,newPassword:t}})}async function Mo(){return $(`/bootstrap`,ro.bootstrap)}async function No(e,t){return $(e,t)}async function Po(e){let t=await $(`/commands`,ro.commands,{body:e});if(!t.success)throw new To(t);return t}async function Fo(e,t){if(t.response.kind!==`passthrough`)throw Error(`fetchBlob requires a passthrough route definition for ${t.method} ${t.path}`);let n=await fetch(So(xo,e),{credentials:`include`});if(n.status===401&&t.auth===`required`)throw wo(),Error(`Session expired`);if(!n.ok)throw Error(Eo(n.status,n.statusText));return n.blob()}async function Io(e,t){if(t.response.kind!==`yaml`)throw Error(`fetchText requires a YAML route definition for ${t.method} ${t.path}`);let n=await fetch(So(xo,e),{credentials:`include`});if(n.status===401&&t.auth===`required`)throw wo(),Error(`Session expired`);if(!n.ok)throw Error(Eo(n.status,n.statusText));return n.text()}export{Zn as $,Kr as A,Sr as B,Xa as C,i as Ct,Y as D,Ni as E,Tr as F,q as G,H,Cr as I,z as J,rr as K,wr as L,Xr as M,Zr as N,$r as O,Wr as P,$n as Q,jr as R,ro as S,o as St,Da as T,B as U,Mr as V,W,G as X,U as Y,R as Z,_o as _,m as _t,Fo as a,ot as at,oo as b,ve as bt,Mo as c,Ue as ct,Po as d,xe as dt,V as et,wo as f,be as ft,ho as g,fe as gt,yo as h,l as ht,Co as i,_t as it,Yr as j,Jr as k,Oo as l,Be as lt,So as m,pe as mt,To as n,ft as nt,No as o,Ke as ot,$ as p,d as pt,K as q,jo as r,mt as rt,Io as s,qe as st,xo as t,y as tt,ko as u,h as ut,co as v,p as vt,Ja as w,r as wt,ao as x,f as xt,so as y,se as yt,Or as z};
@@ -1 +0,0 @@
1
- import{r as e}from"./api-5BZroqlO.js";export{e as changePassword};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{N as r,S as i,j as a,o,v as s}from"./api-5BZroqlO.js";import{i as c,t as l}from"./query-fetch-error-2yqCNP9X.js";import{t as u}from"./proxy-Be4WzmcS.js";import{t as d}from"./AnimatePresence-CPmH1DMY.js";import{a as f,i as p,l as m,n as h,o as ee,r as g,s as _,t as v}from"./copy-button-DnGsXbVV.js";import{C as y,S as b,c as te,d as x,g as S,l as C}from"./format-B9CcV2dj.js";import{n as w,t as T}from"./utils-XFKvwlFT.js";import{M as E,P as D,j as ne,n as O,t as k}from"./use-platform-stream-BBDJCrNY.js";import{t as A}from"./catalog-template-icons-3S8RvUxD.js";import{l as j}from"./select-CMOnuEoT.js";import{a as M}from"./platform-targets-BIQ1lKOg.js";import{i as N,n as P,r as F,t as I}from"./tabs-D64chVAn.js";import{r as re}from"./checkbox-C84IyqEB.js";import{a as L,c as R,d as z,i as B,l as V,n as H,o as ie,r as ae,s as oe,t as se,u as ce}from"./catalog-source-DL6GXE84.js";import{c as U,i as W,n as G,r as K,t as le}from"./use-engine-command-mutation-CIly3RgV.js";import{t as q}from"./badge-i00PiRCo.js";import{t as ue}from"./label-DTHSKF2S.js";import{n as J}from"./get-error-message-CFs0lSQP.js";var de=w(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),fe=w(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),pe=w(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),Y=e(t(),1),X=n(),Z=20,me=14,Q=`flex w-3.5 shrink-0 items-center justify-center`;function he({instance:e,depth:t,area:n,line:r,detail:i}){let[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),l=a?e.tags:e.tags.slice(0,10),u=e.tags.length-10;return(0,X.jsxs)(X.Fragment,{children:[l.map(a=>(0,X.jsx)(ge,{member:a,depth:t,area:n,line:r,instanceId:e.id,detail:i},a.name)),!a&&u>0&&(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-1.5 border-t border-border/30 py-2 text-left font-mono text-xs text-muted-foreground hover:bg-muted/40 touch-manipulation sm:min-h-0 sm:py-1.5`,style:{paddingLeft:`${t*14+Z}px`},onClick:()=>o(!0),children:[(0,X.jsx)(`span`,{className:Q,"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[`+`,u,` more tags`]})]}),e.properties.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-1.5 border-t border-border/30 py-2 text-left font-mono text-xs text-muted-foreground hover:bg-muted/40 touch-manipulation sm:min-h-0 sm:py-1.5`,style:{paddingLeft:`${t*14+Z}px`},onClick:()=>c(e=>!e),children:[(0,X.jsx)(`span`,{className:Q,"aria-hidden":!0,children:s?(0,X.jsx)(j,{className:`size-3.5 opacity-60`,"aria-hidden":!0}):(0,X.jsx)(M,{className:`size-3.5 opacity-60`,"aria-hidden":!0})}),(0,X.jsxs)(`span`,{children:[e.properties.length,` properties`]})]}),s&&e.properties.map(a=>(0,X.jsx)(ge,{member:a,depth:t,area:n,line:r,instanceId:e.id,detail:i},a.name))]})]})}function ge({member:e,depth:t,area:n,line:r,instanceId:i,detail:a}){let o=e.kind===`property`,s=t*14+Z+(o?me:0),c=a.namespace,l=[c?.enterprise?`${c.enterprise}/${c.site??``}`:c?.prefix??``,n,r,i,e.name].filter(Boolean).join(`/`);return(0,X.jsx)(v,{value:l,label:`Copy UNS path`,successMessage:`UNS path copied`,successDescription:l,tooltipSide:`top`,render:()=>(0,X.jsxs)(`button`,{type:`button`,className:T(`flex w-full cursor-pointer flex-col gap-1 border-t border-border/25 py-2 text-left font-mono text-xs hover:bg-muted/35 touch-manipulation sm:min-h-0 sm:flex-row sm:items-center sm:gap-1.5 sm:py-1.5`,o&&`opacity-65`),style:{paddingLeft:`${s}px`},children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:Q,"aria-hidden":!0,children:(0,X.jsx)(`span`,{className:T(`size-1 rounded-full ring-1 ring-border/50`,o?`bg-muted-foreground/25`:`bg-primary/50`)})}),(0,X.jsx)(`span`,{title:e.name,className:T(`min-w-0 truncate`,o?`text-muted-foreground`:`text-foreground`),children:te(e.name)}),o&&(0,X.jsx)(`span`,{className:`shrink-0 rounded-[var(--miravo-radius-tight)] bg-muted/60 px-1 py-px text-[10px] text-muted-foreground`,children:`PROP`})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 pl-0 sm:ml-auto sm:flex-1 sm:justify-end sm:pl-0 sm:pr-1`,children:[(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.dataType}),e.unit&&(0,X.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e.unit}),e.euRange&&(0,X.jsxs)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground`,children:[`[`,e.euRange[0],`–`,e.euRange[1],`]`]})]})]})})}function $({depth:e,label:t,labelTitle:n,tag:r,tagKind:i,subtitle:a,subtitleTitle:o,count:s,expanded:c,onToggle:l,hasChildren:u}){let d=c?j:M,f=i===`area`?`text-primary`:`text-foreground`;return(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full flex-col gap-1 border-t border-border/35 py-2 pr-2 text-left text-xs transition-colors touch-manipulation first:border-t-0 hover:bg-muted/40 sm:min-h-0 sm:flex-row sm:flex-wrap sm:items-center sm:gap-1.5 sm:gap-y-0 sm:py-1.5`,style:{paddingLeft:`${12+e*14}px`},onClick:l,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 w-full items-center gap-1.5 sm:w-auto sm:flex-1 sm:flex-wrap sm:items-center`,children:[u?(0,X.jsx)(d,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,X.jsx)(`span`,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{title:n??void 0,className:T(`min-w-0 flex-1 truncate font-medium`,f),children:t}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] tracking-wide text-muted-foreground uppercase`,children:r}),a&&(0,X.jsx)(`span`,{title:o??void 0,className:`hidden min-w-0 max-w-[min(11rem,38vw)] shrink truncate font-mono text-xs text-muted-foreground sm:inline`,children:a}),s!==void 0&&(0,X.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-xs text-muted-foreground`,children:s})]}),a&&(0,X.jsx)(`span`,{title:o??void 0,className:`min-w-0 truncate pl-7 font-mono text-xs text-muted-foreground sm:hidden`,children:a})]})}function _e(e){let t=e.split(/[-_]/).filter(e=>e.length>0);return t[t.length-1]??e}function ve(e,t,n){let r=[];for(let i of e){let e=_e(i.model),a=t.get(i.model),o=[],s=[];if(a)for(let[e,t]of Object.entries(a.members)){let n={name:e,kind:t.kind,dataType:t.dataType,unit:t.unit,euRange:t.euRange};t.kind===`property`?s.push(n):o.push(n)}for(let t=0;t<i.count;t++){let t=(n.get(i.model)??0)+1;n.set(i.model,t),r.push({id:`${e}-${String(t).padStart(3,`0`)}`,model:i.model,tags:o,properties:s})}}return r}function ye({detail:e}){let[t,n]=(0,Y.useState)(new Set),r=(0,Y.useRef)(null),a=(0,Y.useMemo)(()=>[...new Set(e.models)],[e.models]),u=a.join(`,`),d=c({queryKey:s.catalog.modelSchemasBatch(u),queryFn:async()=>Promise.all(a.map(e=>o(`/catalog/models/${e}`,i.catalogModelDetail)))}),f=d.isPending&&!d.data,p=(0,Y.useMemo)(()=>{let e=new Map;if(!d.data)return e;for(let[t,n]of d.data.entries())e.set(a[t],n);return e},[d.data,a]),m=(0,Y.useMemo)(()=>{let t=new Map,n=new Map;for(let r of e.topology)for(let e of r.lines)n.set(`${r.name}/${e.name}`,ve(e.twins,p,t));return n},[e.topology,p]);(0,Y.useEffect)(()=>{if(f)return;let t=e.name;if(r.current===t)return;let i=new Set;for(let t of e.topology){i.add(`area:${t.name}`);for(let e of t.lines)i.add(`line:${t.name}/${e.name}`)}outer:for(let t of e.topology)for(let e of t.lines){let n=(m.get(`${t.name}/${e.name}`)??[])[0];if(n){i.add(`inst:${t.name}/${e.name}/${n.id}`);break outer}}n(i),r.current=t},[f,e.name,e.topology,m]);let h=(0,Y.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return f?null:d.isError&&!d.data?(0,X.jsx)(l,{message:J(d.error,`Failed to load model schemas.`),onRetry:()=>void d.refetch(),isRetrying:d.isFetching&&!d.isPending}):(0,X.jsx)(`div`,{className:`overflow-hidden rounded-[var(--miravo-radius-stadium-sm)] border border-border/50 py-2 pl-1 pr-2 touch-manipulation sm:py-2.5 sm:pl-1.5 sm:pr-2.5`,children:e.topology.map(n=>{let r=`area:${n.name}`,i=t.has(r);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{depth:0,label:S(n.name),labelTitle:n.name,tag:`AREA`,tagKind:`area`,expanded:i,onToggle:()=>h(r),hasChildren:!0}),i&&n.lines.map(r=>{let i=`line:${n.name}/${r.name}`,a=t.has(i),o=m.get(`${n.name}/${r.name}`)??[];return(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{depth:1,label:S(r.name),labelTitle:r.name,tag:`LINE`,tagKind:`line`,count:o.length,expanded:a,onToggle:()=>h(i),hasChildren:!0}),a&&o.map(i=>{let a=`inst:${n.name}/${r.name}/${i.id}`,o=t.has(a);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)($,{depth:2,label:C(i.id),labelTitle:i.id,tag:`INST`,tagKind:`inst`,subtitle:S(i.model),subtitleTitle:i.model,count:i.tags.length+i.properties.length,expanded:o,onToggle:()=>h(a),hasChildren:i.tags.length+i.properties.length>0}),o&&(0,X.jsx)(he,{instance:i,depth:3,area:n.name,line:r.name,detail:e})]},i.id)})]},r.name)})]},n.name)})})}function be(e){return e.lines.reduce((e,t)=>e+t.twins.reduce((e,t)=>e+t.count,0),0)}function xe(e){return Object.values(e.members).filter(e=>e.kind!==`property`).length}function Se(e,t){let n=0;for(let r of e.topology)for(let e of r.lines)for(let r of e.twins){let e=t.get(r.model),i=e?xe(e):0;n+=r.count*i}return n}function Ce({template:e,onClose:t}){let[n,r]=(0,Y.useState)(new Set),a=c({queryKey:s.catalog.templateDetail(e?.id??``),queryFn:()=>o(`/catalog/templates/${e?.id}`,i.catalogTemplateDetail),enabled:e!==null}),d=a.data,f=a.isPending&&!d,p=a.isError,h=J(a.error,`Failed to load environment.`),ee=d?.models?.join(`,`)??``,g=c({queryKey:s.catalog.modelSchemasBatch(ee),queryFn:async()=>{let e=d?.models??[];return e.length===0?[]:Promise.all(e.map(e=>o(`/catalog/models/${e}`,i.catalogModelDetail)))},enabled:d!==null}),_=(0,Y.useMemo)(()=>{if(!d||!g.data)return null;let e=new Map;for(let[t,n]of g.data.entries())e.set(d.models[t],n);return Se(d,e)},[d,g.data]);(0,Y.useEffect)(()=>{e&&d&&r(new Set(d.topology.map(e=>e.name)))},[e,d]);let v=(0,Y.useCallback)(e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),y=k(),b=y.status===`running`;return(0,X.jsx)(L,{open:e!==null,onOpenChange:e=>{if(!e){if(b){m.message(`Deploy still running. Cancel it or wait before closing.`);return}y.reset(),t()}},children:(0,X.jsx)(ie,{side:`right`,showCloseButton:!b,className:`flex w-full flex-col gap-4 touch-manipulation`,children:f?null:p&&!d?(0,X.jsx)(`div`,{className:`flex flex-1 flex-col justify-center px-2`,children:(0,X.jsx)(l,{message:h,onRetry:()=>void a.refetch(),isRetrying:a.isFetching})}):d?(0,X.jsxs)(u.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.18},className:`flex min-h-0 flex-1 flex-col gap-4`,children:[(0,X.jsxs)(R,{className:`gap-1 pb-0 pe-12`,children:[(0,X.jsx)(V,{className:`font-heading text-base uppercase tracking-wide`,children:d.name}),d.description&&(0,X.jsx)(oe,{className:`text-xs leading-relaxed text-foreground/88`,children:d.description})]}),(0,X.jsxs)(I,{defaultValue:`overview`,className:`flex min-h-0 flex-1 flex-col gap-1 pt-0`,children:[(0,X.jsxs)(F,{variant:`line`,className:`h-8! shrink-0 gap-0.5 border-b-border/60 px-2 py-0.5`,children:[(0,X.jsx)(N,{value:`overview`,className:`min-h-10 px-2 py-1 text-xs text-foreground/82 after:bottom-[-3px] data-active:text-foreground sm:min-h-0 sm:px-2.5 sm:py-1`,children:`Overview`}),(0,X.jsx)(N,{value:`uns`,className:`min-h-10 px-2 py-1 text-xs text-foreground/82 after:bottom-[-3px] data-active:text-foreground sm:min-h-0 sm:px-2.5 sm:py-1`,children:`UNS`}),(0,X.jsx)(N,{value:`deploy`,className:`min-h-10 px-2 py-1 text-xs text-foreground/82 after:bottom-[-3px] data-active:text-foreground sm:min-h-0 sm:px-2.5 sm:py-1`,children:`Deploy`})]}),(0,X.jsx)(P,{value:`overview`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 pb-1 pt-0.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.topology.length,` areas`]}),(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.instanceCount,` twins`]}),(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.models.length,` models`]}),_!==null&&(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[_,` tags`]}),d.settings?.tickIntervalMs&&(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[`tick `,d.settings.tickIntervalMs,`ms`]}),d.settings?.timeMultiplier&&d.settings.timeMultiplier!==1&&(0,X.jsxs)(q,{variant:`outline`,className:`font-mono text-xs`,children:[d.settings.timeMultiplier,`× speed`]}),(0,X.jsx)(O,{stream:y})]}),d.namespace&&(d.namespace.enterprise||d.namespace.site||d.namespace.prefix)&&(0,X.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-[var(--miravo-radius-tight)] border border-border/60 px-2.5 py-2`,children:[(0,X.jsx)(`h3`,{className:`font-heading text-xs font-semibold uppercase tracking-[0.12em] text-primary`,children:`Namespace`}),(0,X.jsxs)(`dl`,{className:`mt-1 grid grid-cols-1 gap-x-4 gap-y-1.5 sm:grid-cols-2`,children:[d.namespace.enterprise&&(0,X.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,X.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Enterprise`}),(0,X.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:d.namespace.enterprise})]}),d.namespace.site&&(0,X.jsxs)(`div`,{className:`min-w-0 sm:max-w-[min(100%,16rem)]`,children:[(0,X.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Site`}),(0,X.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:d.namespace.site})]}),d.namespace.prefix&&(0,X.jsxs)(`div`,{className:`min-w-0 sm:col-span-2`,children:[(0,X.jsx)(`dt`,{className:`font-heading text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:`Prefix`}),(0,X.jsx)(`dd`,{className:`mt-1 font-mono text-xs leading-snug text-foreground [overflow-wrap:anywhere] break-words`,children:d.namespace.prefix})]})]})]}),d.topology.map(e=>(0,X.jsx)(we,{area:e,expanded:n.has(e.name),onToggle:()=>v(e.name)},e.name)),d.settings&&(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/50 p-2`,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 font-heading text-xs font-semibold uppercase tracking-[0.12em] text-warning`,children:[(0,X.jsx)(ce,{className:`size-3.5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:`Settings`})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-1.5 font-mono text-xs sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`tick interval`}),(0,X.jsxs)(`span`,{className:`text-foreground`,children:[d.settings.tickIntervalMs??1e3,`ms`]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`time multiplier`}),(0,X.jsxs)(`span`,{className:`text-foreground`,children:[d.settings.timeMultiplier??1,`×`]})]})]})]})]})})})}),(0,X.jsx)(P,{value:`uns`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,X.jsx)(`div`,{className:`pb-1 pt-0.5`,children:(0,X.jsx)(ye,{detail:d})})})})}),(0,X.jsx)(P,{value:`deploy`,keepMounted:!0,className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pt-0`,children:(0,X.jsx)(B,{kind:`template`,id:d.id,displayName:d.name,yamlPath:`/catalog/templates/${d.id}/yaml`,yamlFilename:`${d.id}.miravo.yaml`,stream:y})})})]})]},d.id):(0,X.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Environment not found`})})})}function we({area:e,expanded:t,onToggle:n}){let r=be(e);return(0,X.jsxs)(`div`,{className:K,children:[(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full items-center gap-1.5 px-2.5 py-2 text-left text-xs font-medium transition-colors hover:bg-muted/30 touch-manipulation sm:min-h-0 sm:py-1.5`,onClick:n,children:[(0,X.jsx)(de,{className:`size-3.5 text-primary`}),(0,X.jsx)(`span`,{className:`uppercase tracking-wider text-primary`,children:S(e.name)}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,X.jsxs)(q,{variant:`secondary`,className:`text-xs`,children:[r,` twins`]}),(0,X.jsxs)(q,{variant:`secondary`,className:`text-xs`,children:[e.lines.length,` lines`]}),(0,X.jsx)(j,{className:`size-3 text-muted-foreground transition-transform ${t?`rotate-180`:``}`})]})]}),(0,X.jsx)(d,{initial:!1,children:t&&(0,X.jsx)(u.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:`easeOut`},className:`overflow-hidden`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5 border-t border-border p-2`,children:e.lines.map(e=>(0,X.jsx)(Te,{line:e},e.name))})},`content`)})]})}function Te({line:e}){return(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/60 bg-muted/10 p-2`,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(pe,{className:`size-3.5`}),(0,X.jsx)(`span`,{title:e.name,children:S(e.name)}),(0,X.jsx)(fe,{className:`ml-auto size-3.5 text-muted-foreground`}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.twins.reduce((e,t)=>e+t.count,0),` twins`]})]}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.twins.map(e=>(0,X.jsx)(Ee,{twin:e},`${e.model}-${e.count}`))})]})}function Ee({twin:e}){let t=e.parameters&&Object.keys(e.parameters).length>0;return(0,X.jsxs)(`div`,{className:`rounded-[var(--miravo-radius-tight)] border border-border/30 bg-background/50 px-2.5 py-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,X.jsx)(`span`,{className:`font-mono font-medium text-primary`,title:e.model,children:S(e.model)}),(0,X.jsxs)(q,{variant:`secondary`,className:`shrink-0 px-1 py-0 text-xs`,children:[`×`,e.count]}),e.variation>0&&(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`±`,(e.variation*100).toFixed(0),`% variation`]})]}),t&&e.parameters&&(0,X.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-4 gap-y-1 border-t border-border/20 pt-1.5 font-mono text-xs`,children:Object.entries(e.parameters).map(([e,t])=>(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,X.jsx)(`span`,{className:`text-foreground`,children:t})]},e))})]})}var De=[`builtin`,`personal`];function Oe(){let[e,t]=(0,Y.useState)(``),[n,m]=(0,Y.useState)(`all`),[v,te]=(0,Y.useState)({}),[S,C]=(0,Y.useState)(null),[w,E]=(0,Y.useState)(null),[D,O]=(0,Y.useState)(``),[k,A]=(0,Y.useState)(null),[j,M]=(0,Y.useState)(null),N=(0,Y.useRef)(null),P=le();(0,Y.useEffect)(()=>{let e=e=>{if(e.key!==`/`||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||(e.preventDefault(),N.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let F=c({queryKey:s.catalog.templates(),queryFn:()=>o(`/catalog/templates`,i.catalogTemplates)}),I=F.data??[],L=w===null?null:I.find(e=>e.id===w)??null,R=F.isPending&&!F.data,z=F.isError&&!F.data,B=F.isError&&!!F.data,V=J(F.error,`Failed to load environments.`),H=e=>v[e]??1,ie=(0,Y.useCallback)((e,t)=>{te(n=>({...n,[e]:Math.max(1,Math.min(10,t))}))},[]),oe=(0,Y.useCallback)(e=>{M(e)},[]),se=(0,Y.useCallback)(e=>{E(e);let t=a(e);O(t),A(r(t))},[]),ce=async e=>{let t=r(D);if(t)return A(t),!1;A(null),C(e);try{return await P.mutateAsync({type:`loadTemplate`,templatePath:e,count:H(e),namePrefix:D.trim()||a(e)}),!0}catch{return!1}finally{C(null)}},U=(0,Y.useMemo)(()=>{let e={all:I.length};for(let t of De)e[t]=0;for(let t of I){let n=ae(t.source);e[n]=(e[n]??0)+1}return e},[I]),W=e.toLowerCase(),G=I.filter(e=>n===`all`||ae(e.source)===n).filter(e=>W?e.name.toLowerCase().includes(W)||e.id.toLowerCase().includes(W)||(e.description?.toLowerCase().includes(W)??!1):!0);return(0,X.jsxs)(`div`,{className:`@container/templates mx-auto flex w-full max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Environment Catalog`}),(0,X.jsx)(q,{variant:`outline`,className:`text-xs`,children:z?(0,X.jsx)(`span`,{className:`text-destructive`,children:`Unavailable`}):R&&I.length===0?(0,X.jsx)(X.Fragment,{children:`Loading...`}):(0,X.jsxs)(X.Fragment,{children:[new Set(I.map(e=>e.id)).size,` environments`]})})]}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Choose an environment to launch a realistic industrial system. Each environment includes pre-configured asset models with realistic physics, lifecycle degradation, and fault modes.`})]}),z&&(0,X.jsx)(l,{message:V,onRetry:()=>void F.refetch(),isRetrying:F.isFetching}),B&&(0,X.jsx)(l,{message:`${V} Showing cached environments.`,onRetry:()=>void F.refetch(),isRetrying:F.isFetching}),!z&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,X.jsxs)(`div`,{className:`relative max-w-xs flex-1 min-w-[14rem]`,children:[(0,X.jsx)(ne,{className:`absolute left-2.5 top-2.5 size-4 text-muted-foreground`}),(0,X.jsx)(b,{ref:N,placeholder:`Filter environments...`,value:e,onChange:e=>t(e.target.value),className:`pl-9 pr-7`}),!e&&(0,X.jsx)(`kbd`,{className:`pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 rounded-[var(--miravo-radius-tight)] border border-border bg-muted px-1 font-mono text-[10px] text-muted-foreground`,children:`/`})]}),(0,X.jsx)(je,{value:n,counts:U,onChange:m})]}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-4 @[720px]/templates:grid-cols-2`,"aria-busy":R&&!z,children:z?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(d,{children:G.map((e,t)=>(0,X.jsx)(u.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,scale:.96,transition:{duration:.15}},transition:{type:`spring`,stiffness:380,damping:30,delay:t*.04},className:`grid`,children:(0,X.jsx)(ke,{template:e,count:H(e.id),launching:S===e.id,onCountChange:ie,onInspect:oe,onLaunch:se})},`${e.source}:${e.id}`))}),G.length===0&&I.length>0&&(0,X.jsx)(`p`,{className:`col-span-full py-8 text-center text-sm text-muted-foreground`,children:`No environments match the current filters.`})]})}),I.length>0&&(0,X.jsx)(`div`,{className:T(K,`p-0`),children:(0,X.jsx)(`div`,{className:`community-teaser relative overflow-hidden rounded-[inherit]`,children:(0,X.jsx)(`div`,{className:`relative z-10 mx-auto max-w-3xl px-5 py-10 sm:px-10 sm:py-12`,children:(0,X.jsxs)(`div`,{className:`grid items-center gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,17rem)]`,children:[(0,X.jsxs)(`div`,{className:`order-2 flex min-w-0 flex-col gap-4 lg:order-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1`,children:[(0,X.jsx)(`p`,{className:`blueprint-title text-primary`,children:`Future channel`}),(0,X.jsx)(`span`,{className:`blueprint-stat text-[10px] text-muted-foreground`,children:`MIRAVO_REGISTRY · NOT_CONNECTED`})]}),(0,X.jsx)(`h2`,{className:`font-heading text-xl font-semibold tracking-tight sm:text-2xl`,children:`Community Environments`}),(0,X.jsx)(`p`,{className:`max-w-xl text-sm leading-relaxed text-muted-foreground`,children:`Share your industrial environments with the Miravo community. Publish custom environments, discover configurations from other engineers, and fork them as your starting point.`}),(0,X.jsx)(`div`,{children:(0,X.jsx)(q,{variant:`outline`,className:`community-teaser-soon border-primary/35 bg-primary/5 text-[10px] text-primary`,children:`Coming Soon`})})]}),(0,X.jsx)(`div`,{className:`order-1 flex justify-center lg:order-2 lg:justify-end`,children:(0,X.jsxs)(`div`,{className:`community-teaser-module relative flex w-full max-w-[14rem] flex-col items-center justify-center gap-3 border border-primary/15 bg-muted/15 py-8 sm:max-w-[15.5rem] sm:py-10`,"aria-hidden":!0,children:[(0,X.jsx)(`div`,{className:`community-teaser-icon-ring relative z-[1] flex size-[4.25rem] items-center justify-center rounded-[var(--miravo-radius-tight)] border border-primary/35 bg-gradient-to-br from-primary/18 to-primary/5`,children:(0,X.jsx)(re,{className:`size-9 text-primary`,"aria-hidden":!0})}),(0,X.jsx)(`span`,{className:`blueprint-stat relative z-[1] text-[9px] tracking-[0.18em] text-muted-foreground`,children:`AWAITING SIGNAL`}),(0,X.jsx)(`span`,{className:`blueprint-stat relative z-[1] text-[9px] text-muted-foreground`,children:`Uplink idle`})]})})]})})})}),(0,X.jsx)(h,{open:w!==null,onOpenChange:e=>{e||E(null)},children:(0,X.jsxs)(g,{className:`min-w-0 sm:max-w-md`,children:[(0,X.jsxs)(ee,{children:[(0,X.jsx)(_,{children:`Launch environment?`}),(0,X.jsx)(p,{children:L!==null&&(0,X.jsxs)(X.Fragment,{children:[`This adds `,H(L.id),` instance`,H(L.id)===1?``:`s`,` of`,` `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:x(L.name)}),` `,`to the running environment.`]})})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,X.jsx)(ue,{htmlFor:`launch-name-prefix`,className:`text-xs font-medium text-foreground`,children:`Name prefix`}),(0,X.jsx)(b,{id:`launch-name-prefix`,value:D,maxLength:120,onChange:e=>{let t=e.target.value;O(t),A(r(t))},placeholder:L?a(L.id):`Prefix`,className:T(`min-w-0 font-mono text-xs`,k&&`border-destructive`),"aria-invalid":k!=null,"aria-describedby":`launch-name-prefix-hint`}),(0,X.jsxs)(`p`,{id:`launch-name-prefix-hint`,className:`min-w-0 wrap-break-word text-[11px] text-muted-foreground`,children:[`Generated IDs use this prefix. Example`,` `,(0,X.jsx)(`span`,{className:`break-all font-mono text-foreground`,children:`${D.trim()||(L?a(L.id):`env`)}-pump-001`})]}),k?(0,X.jsx)(`p`,{className:`text-[11px] text-destructive`,children:k}):null]}),(0,X.jsxs)(f,{children:[(0,X.jsx)(y,{variant:`outline`,disabled:S!==null,onClick:()=>E(null),children:`Cancel`}),(0,X.jsx)(y,{disabled:S!==null||L===null||k!=null,onClick:async()=>{L!==null&&await ce(L.id)&&E(null)},children:S===L?.id?`Launching...`:`Launch`})]})]})}),(0,X.jsx)(Ce,{template:j,onClose:()=>M(null)})]})}var ke=(0,Y.memo)(function({template:e,count:t,launching:n,onCountChange:r,onInspect:i,onLaunch:a}){return(0,X.jsxs)(`div`,{className:T(W,`flex flex-col gap-4 p-5`),children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] bg-primary/10 text-primary`,children:(0,X.jsx)(A,{id:e.id,className:`size-5`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,X.jsx)(`span`,{className:`font-heading text-sm font-semibold uppercase tracking-wide`,children:x(e.name)}),(0,X.jsx)(`p`,{className:`line-clamp-3 text-xs leading-relaxed text-foreground/75`,children:e.description??`Industrial environment.`}),(0,X.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.id})]})]}),(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.models.map(e=>(0,X.jsx)(q,{variant:`outline`,className:`h-auto min-h-5 rounded-[var(--miravo-radius-tight)] px-1.5 py-0 font-mono text-[10px] font-normal text-primary`,children:e},e))})}),(0,X.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-4 font-mono text-[11px] text-muted-foreground`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e.instanceCount}),` instances`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`text-foreground`,children:e.models.length}),` models`]}),e.memberCount>0&&(0,X.jsxs)(`span`,{children:[`~`,(0,X.jsx)(`span`,{className:`text-foreground`,children:Ae(e.memberCount)}),` tags/cycle`]}),(0,X.jsx)(q,{variant:`outline`,className:T(`ml-auto shrink-0 font-sans text-[10px] font-medium uppercase tracking-wide`,se(e.source)),children:H(e.source)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border/30 pt-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center rounded-[var(--miravo-radius-tight)] border bg-muted/30`,children:[(0,X.jsx)(y,{variant:`ghost`,size:`icon`,className:`size-7 rounded-none rounded-l-md`,disabled:t<=1,"aria-label":`Decrease count`,onClick:n=>{n.stopPropagation(),r(e.id,t-1)},children:(0,X.jsx)(z,{className:`size-3`})}),(0,X.jsx)(`span`,{className:`flex size-7 items-center justify-center border-x font-mono text-xs`,children:t}),(0,X.jsx)(y,{variant:`ghost`,size:`icon`,className:`size-7 rounded-none rounded-r-md`,disabled:t>=10,"aria-label":`Increase count`,onClick:n=>{n.stopPropagation(),r(e.id,t+1)},children:(0,X.jsx)(E,{className:`size-3`})})]}),(0,X.jsxs)(y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(e),className:G,children:[(0,X.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),`Inspect`]}),(0,X.jsxs)(y,{size:`sm`,className:`ml-auto`,disabled:n,onClick:()=>a(e.id),children:[(0,X.jsx)(U,{className:`mr-1 size-3`}),n?`...`:`Launch`]})]})]})});function Ae(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function je({value:e,counts:t,onChange:n}){return(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`radiogroup`,"aria-label":`Filter by source`,children:[{id:`all`,label:`All`},...De.map(e=>({id:e,label:H(e)}))].map(r=>{let i=e===r.id,a=t[r.id]??0,o=r.id!==`all`&&a===0;return(0,X.jsxs)(`label`,{className:T(`inline-flex h-7 items-center gap-1.5 rounded-[var(--miravo-radius-pill)] border px-3 text-xs font-medium transition-colors`,i?`border-primary/60 bg-primary/15 text-primary`:`border-border/60 bg-card/30 text-muted-foreground hover:border-border hover:bg-muted/40 hover:text-foreground`,o?`cursor-not-allowed opacity-40 hover:border-border/60 hover:bg-card/30 hover:text-muted-foreground`:`cursor-pointer`),children:[(0,X.jsx)(`input`,{type:`radio`,name:`catalog-source-filter`,value:r.id,checked:i,disabled:o,onChange:()=>n(r.id),className:`sr-only`}),(0,X.jsx)(`span`,{children:r.label}),(0,X.jsx)(`span`,{className:`font-mono text-[10px] opacity-70`,children:a})]},r.id)})})}export{Oe as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./catalog-B477tO5a.js";export{e as CatalogPage};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{$ as n,J as r,Q as i,X as a,Y as o,Z as s,at as c,q as l}from"./vendor-ui-CWUk2ulb.js";import{A as ee,S as u,a as d,o as te,s as ne,v as f}from"./api-5BZroqlO.js";import{i as re,s as ie,t as ae}from"./query-fetch-error-2yqCNP9X.js";import{t as p}from"./proxy-Be4WzmcS.js";import{t as oe}from"./AnimatePresence-CPmH1DMY.js";import{a as se,i as ce,l as m,n as le,o as ue,r as de,s as fe}from"./copy-button-DnGsXbVV.js";import{C as h,S as pe,T as g}from"./format-B9CcV2dj.js";import{n as _,t as v}from"./utils-XFKvwlFT.js";import{C as me,E as he,N as ge,O as _e,S as ve,T as ye,_ as be,a as xe,b as Se,c as Ce,d as we,g as Te,h as Ee,i as De,k as Oe,o as ke,p as Ae,r as je,s as Me,w as Ne,y as Pe}from"./use-platform-stream-BBDJCrNY.js";import{a as Fe,c as Ie,i as y,n as Le,o as Re,r as ze,s as Be,t as Ve}from"./select-CMOnuEoT.js";import{a as He,i as Ue,n as We,r as b,t as Ge}from"./platform-targets-BIQ1lKOg.js";import{a as Ke,o as x}from"./tabs-D64chVAn.js";import{t as qe}from"./download-DmUZKo9N.js";import{r as Je}from"./checkbox-C84IyqEB.js";import{t as Ye}from"./badge-i00PiRCo.js";import{t as S}from"./label-DTHSKF2S.js";import{n as C}from"./get-error-message-CFs0lSQP.js";var Xe=_(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),w=_(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),T=c();function E({...e}){return(0,T.jsx)(r,{"data-slot":`sheet`,...e})}function D({...e}){return(0,T.jsx)(o,{"data-slot":`sheet-portal`,...e})}function O({className:e,...t}){return(0,T.jsx)(n,{"data-slot":`sheet-overlay`,className:v(`fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs`,e),...t})}function k({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...o}){return(0,T.jsxs)(D,{children:[(0,T.jsx)(O,{}),(0,T.jsxs)(a,{"data-slot":`sheet-content`,"data-side":n,className:v(`fixed z-50 flex flex-col gap-4 bg-background bg-clip-padding text-sm shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-[calc(100vw-1rem)] data-[side=left]:max-w-md data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-[calc(100vw-1rem)] data-[side=right]:max-w-xl data-[side=right]:border-l data-[side=right]:pl-1 data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem]`,e),...o,children:[t,r&&(0,T.jsxs)(i,{"data-slot":`sheet-close`,render:(0,T.jsx)(h,{variant:`ghost`,className:`absolute top-3 right-3`,size:`icon-sm`}),children:[(0,T.jsx)(g,{}),(0,T.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function A({className:e,...t}){return(0,T.jsx)(`div`,{"data-slot":`sheet-header`,className:v(`flex flex-col gap-0.5 p-2`,e),...t})}function j({className:e,...t}){return(0,T.jsx)(l,{"data-slot":`sheet-title`,className:v(`text-base font-medium text-foreground`,e),...t})}function Ze({className:e,...t}){return(0,T.jsx)(s,{"data-slot":`sheet-description`,className:v(`text-sm text-muted-foreground`,e),...t})}var M=e(t(),1),N=[{value:`opcua`,label:`OPC UA`},{value:`mqtt`,label:`MQTT`},{value:`modbus`,label:`Modbus`}];function Qe({value:e,onValueChange:t,labelledBy:n}){return(0,T.jsx)(`fieldset`,{"aria-labelledby":n,className:`min-w-0 border-0 p-0`,children:(0,T.jsx)(`div`,{className:`flex gap-1.5`,children:N.map(n=>{let r=e===n.value;return(0,T.jsx)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>t(n.value),className:v(`flex flex-1 items-center justify-center rounded-[var(--miravo-radius-pill)] border py-1.5 text-center transition-[background-color,border-color,color,box-shadow] duration-200`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/80 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,r?`border-primary/45 bg-primary/10 text-primary shadow-[inset_0_1px_0_0_rgba(255,255,255,0.06),0_0_0_1px_color-mix(in_srgb,var(--primary)_25%,transparent)]`:`border-border/75 bg-background/55 text-foreground/82 hover:border-border/90 hover:bg-background/70 hover:text-foreground/92`),children:(0,T.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-1.5 font-mono text-[11px] font-medium leading-none tracking-wide`,children:[(0,T.jsx)(Ke,{className:`size-2.5 shrink-0 -translate-y-px opacity-80`,"aria-hidden":!0}),(0,T.jsx)(`span`,{children:n.label})]})},n.value)})})})}var P=`172.17.0.1`;async function $e(e){let t=await te(`/catalog/models/${encodeURIComponent(e)}/le-dt.json`,u.catalogModelLeDt);return JSON.stringify(t,null,2)}async function et(e,t={host:P}){let n=u.catalogTemplateLeTemplateJson.query;if(!n)throw Error(`Missing query schema for ${u.catalogTemplateLeTemplateJson.method} ${u.catalogTemplateLeTemplateJson.path}`);let r=n.safeParse(t);if(!r.success)throw Error(`Invalid request for ${u.catalogTemplateLeTemplateJson.method} ${u.catalogTemplateLeTemplateJson.path}: ${r.error.message}`);return d(tt(e,r.data),u.catalogTemplateLeTemplateJson)}function tt(e,t){return`/catalog/templates/${encodeURIComponent(e)}/le-template.json${F(t)}`}function F(e){let t=new URLSearchParams;return e.host&&t.set(`host`,e.host),e.protocol&&t.set(`protocol`,e.protocol),t.size>0?`?${t.toString()}`:``}function nt(e){return`${ee(e)}-001`}function rt(e,t){return[t,...e?.filter(e=>e.id!==t.id)??[]]}async function it(e){let t=await e.create();e.onCreated(t);try{await e.refresh()}catch(t){e.onRefreshFailed(t)}}function at(e){return Ue.find(t=>t.id===e)?.label??e}function ot(e){return e===`template`?`Litmus Edge Template`:`Litmus Edge`}function st({kind:e,id:t,displayName:n,yamlPath:r,yamlFilename:i,stream:a}){let o=ie(),s=re({queryKey:f.platforms.targets(),queryFn:()=>we()}),c=s.data??[],[l,ee]=(0,M.useState)(``),[d,te]=(0,M.useState)(`opcua`),[_,Ke]=(0,M.useState)(`litmus-edge`),[Xe,w]=(0,M.useState)(!1),[E,D]=(0,M.useState)(!1),[O,k]=(0,M.useState)(b.id),[A,j]=(0,M.useState)({label:``,hostname:``,apiToken:``,sourceHostname:``}),[Ze,N]=(0,M.useState)(!1),[tt,F]=(0,M.useState)(!1),{testing:st,runTest:I,cancelInFlight:L}=ke(),[ct,R]=(0,M.useState)(!1),[z,B]=(0,M.useState)(P),[V,lt]=(0,M.useState)(!1),[H,U]=(0,M.useState)(null),[W,ut]=(0,M.useState)(!1),G=(0,M.useRef)(0),K=(0,M.useRef)(null),dt=(0,M.useRef)(a.status),ft=(0,M.useId)(),q=(0,M.useCallback)(()=>{G.current+=1,K.current?.abort(),K.current=null,ut(!1),U(null)},[]);(0,M.useEffect)(()=>()=>{G.current+=1,K.current?.abort(),K.current=null},[]),(0,M.useEffect)(()=>{let e=dt.current;dt.current=a.status,e===`running`&&a.status===`complete`&&o.invalidateQueries({queryKey:f.platforms.operationsList()})},[o,a.status]),(0,M.useEffect)(()=>{E&&(k(b.id),j({label:``,hostname:``,apiToken:``,sourceHostname:``}),N(!1))},[E]);let pt=O===b.id&&A.hostname.trim().length>0&&A.sourceHostname.trim().length>0&&A.apiToken.trim().length>0,J=c.find(e=>e.id===l),mt=(0,M.useCallback)(n=>{w(!1),q(),l&&(e===`model`?a.startApply(ye({targetId:l,model:t,protocol:d,result:n})):a.startApply(he({targetId:l,template:t,result:n})))},[l,t,e,d,a,q]),ht=(0,M.useCallback)(async n=>{if(!l)return;a.operation&&a.status!==`running`&&a.reset(),K.current?.abort(),G.current+=1;let r=G.current,i=new AbortController;K.current=i,ut(!0),U(null);try{let a=await Ae(e===`model`?ye({targetId:l,model:t,protocol:d,result:n}):he({targetId:l,template:t,result:n}),{signal:i.signal});if(r!==G.current)return;U(a.plan)}catch(e){if(r!==G.current||xe(e))return;m.error(C(e,`Plan failed.`))}finally{r===G.current&&ut(!1)}},[l,e,t,d,a]),gt=(0,M.useCallback)(async()=>{if(O!==b.id){m.error(`${at(O)} target setup is coming soon.`);return}if(!A.label||!A.hostname||!A.sourceHostname){m.error(`Label, hostname, and source host are required.`);return}if(!A.apiToken){m.error(`API token is required for new targets.`);return}F(!0);try{await it({create:()=>Ce({...A,platformId:O}),onCreated:e=>{o.setQueryData(f.platforms.targets(),t=>rt(t,e)),ee(e.id),D(!1),m.success(`Target added.`)},refresh:async()=>{let e=await s.refetch();if(e.error)throw e.error},onRefreshFailed:e=>{m.error(`Target added, but target list refresh failed.`,{description:`${C(e,`Target list refresh failed.`)} Reload targets before retrying another add.`})}})}catch(e){m.error(C(e,`Failed to add target.`))}finally{F(!1)}},[O,A,s,o]),_t=(0,M.useCallback)(()=>{pt&&I({hostname:A.hostname.trim(),sourceHostname:A.sourceHostname.trim(),apiToken:A.apiToken.trim()})},[pt,A,I]),vt=_===`source-yaml`,yt=_===`litmus-edge`||vt,Y=(0,M.useCallback)(async n=>{if(vt){try{let t=await ne(r,e===`model`?u.catalogModelYaml:u.catalogTemplateYaml),n=new Blob([t],{type:`text/yaml`}),a=URL.createObjectURL(n),o=document.createElement(`a`);o.href=a,o.download=i,o.click(),URL.revokeObjectURL(a),m.success(`Exported ${i}`)}catch{m.error(`Failed to export YAML`)}return}if(_===`litmus-edge`)try{if(e===`model`){let e=await $e(t),n=new Blob([e],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t}.le-dt.json`,i.click(),URL.revokeObjectURL(r),m.success(`Exported ${t}.le-dt.json`)}else{let e=n?.templateHost?.trim()??``,r=e.length>0?e:P,i=`${t}.le-template.json`,a=await et(t,{host:r}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=i,s.click(),URL.revokeObjectURL(o),m.success(`Exported ${i}`)}}catch{m.error(`Failed to export platform format`)}},[_,vt,e,t,r,i]),bt=(0,M.useCallback)(()=>{if(yt){if(_===`litmus-edge`&&e===`template`){B(P),R(!0);return}Y()}},[yt,_,e,Y]),xt=(0,M.useCallback)(async()=>{lt(!0);try{await Y({templateHost:z}),R(!1)}finally{lt(!1)}},[z,Y]),X=a.status===`running`,Z=a.cancelRequested,Q=!!l&&!X,St=!!a.operation||X,$=St?Me(a):null;return(0,T.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-6 px-1 py-2`,children:[(0,T.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-2`,children:(0,T.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,T.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.2em] text-foreground`,children:`Deploy`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(S,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Target`}),s.isError&&s.data===void 0&&(0,T.jsx)(ae,{message:C(s.error,`Failed to load targets.`),onRetry:()=>void s.refetch(),isRetrying:s.isFetching&&!s.isPending}),(0,T.jsx)(Ee,{targets:c,value:l,onValueChange:ee,loading:s.isPending&&s.data===void 0,size:`sm`,className:`min-w-0 w-full border-border/65 bg-background/55 text-xs text-foreground`,onAddNew:()=>D(!0)})]}),e===`model`&&c.length>0&&(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(S,{id:ft,className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Protocol binding`}),(0,T.jsx)(Qe,{value:d,onValueChange:te,labelledBy:ft})]}),c.length>0&&(0,T.jsxs)(`button`,{type:`button`,disabled:!Q,onClick:()=>w(!0),className:v(`group flex w-full min-h-14 min-w-0 items-stretch overflow-hidden rounded-[var(--miravo-radius-stadium-lg)] text-left outline-none`,`transition-[border-color,box-shadow,background-color] duration-200 ease-out`,`focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-offset-2 focus-visible:ring-offset-background`,`disabled:pointer-events-none disabled:opacity-55`,Q?[`border-2 border-primary/40 bg-background`,`bg-linear-to-r from-primary/12 via-background to-background`,`shadow-[inset_0_1px_0_0_rgba(255,255,255,0.025)]`,`hover:border-primary/56 hover:shadow-[inset_0_1px_0_0_rgba(255,255,255,0.025),0_0_14px_-8px_color-mix(in_srgb,var(--primary)_18%,transparent),0_0_22px_-12px_color-mix(in_srgb,var(--primary)_8%,transparent)]`]:[`border border-dashed border-border/65 bg-muted/15`,`hover:bg-muted/22`]),children:[(0,T.jsxs)(`span`,{className:`relative flex w-18 shrink-0 items-center justify-center bg-transparent`,"aria-hidden":!0,children:[(0,T.jsx)(`span`,{className:v(`absolute inset-y-2 -right-px w-px bg-linear-to-b from-transparent via-primary/30 to-transparent opacity-70`,!Q&&`via-border/80`)}),(0,T.jsx)(Je,{className:v(`relative size-5`,Q?`text-primary`:`text-foreground/75`)})]}),(0,T.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-0.5 overflow-hidden px-3 py-2.5 sm:px-4`,children:[(0,T.jsx)(`span`,{className:v(`font-heading text-[11px] font-semibold uppercase tracking-[0.16em]`,Q?`text-primary`:`text-foreground/78`),children:Q?`Review deploy`:X?`Deploy in progress…`:`Awaiting target`}),(0,T.jsx)(`span`,{className:v(`truncate font-mono text-[13px] leading-tight tracking-tight`,Q?`text-foreground`:`text-foreground/80`),children:J?.label??`Select a target above`})]}),(0,T.jsx)(`span`,{className:v(`flex shrink-0 items-center pr-2.5 sm:pr-3`,Q&&`pl-1`),children:(0,T.jsx)(`span`,{className:v(`flex size-9 items-center justify-center rounded-[var(--miravo-radius-stadium-sm)] border bg-transparent transition-[border-color,color] duration-200`,Q?`border-primary/40 text-primary group-hover:border-primary/55`:`border-border/75 text-foreground/75`),"aria-hidden":!0,children:(0,T.jsx)(He,{className:`size-4`,strokeWidth:2.25})})})]})]})}),(0,T.jsx)(oe,{children:St&&$?(0,T.jsx)(be,{title:$.title,subtitle:$.subtitle,canDismiss:!X,footerAction:X&&a.operation?.operationId?(0,T.jsx)(h,{variant:`outline`,size:`sm`,disabled:Z,"aria-busy":Z,className:v(`ml-auto group h-8 gap-1.5 px-3 text-xs`,Z?`cursor-not-allowed`:`hover:bg-destructive/12 hover:text-destructive hover:border-destructive/35`),onClick:()=>{a.cancel().catch(()=>{})},children:Z?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(x,{className:`size-3.5 shrink-0 animate-spin text-muted-foreground`,"aria-hidden":!0}),(0,T.jsx)(p.span,{animate:{opacity:[1,.72,1]},transition:{duration:1.25,repeat:1/0,ease:`easeInOut`},className:`font-medium text-foreground`,children:`Cancelling…`})]}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(g,{className:`size-3.5 shrink-0 text-foreground/65 group-hover:text-destructive`,"aria-hidden":!0}),(0,T.jsx)(p.span,{animate:{opacity:[1,.88,1]},transition:{duration:2.2,repeat:1/0,ease:`easeInOut`},children:`Cancel`})]})}):(0,T.jsx)(`div`,{className:`ml-auto shrink-0 flex items-center`,children:(0,T.jsx)(h,{type:`button`,variant:`secondary`,size:`xs`,className:`h-7 px-3 text-[10px] font-medium`,onClick:a.reset,children:`Close`})}),onDismiss:a.reset,children:a.operation?(0,T.jsx)(Se,{operation:a.operation,catalogTemplates:[{id:t,name:n}],logs:a.logs}):(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 py-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(x,{className:`size-3.5 animate-spin text-primary`,"aria-hidden":!0}),(0,T.jsx)(`span`,{className:`text-xs text-foreground/88`,children:`Connecting to Litmus Edge…`})]}),(0,T.jsx)(`div`,{className:`h-1 w-full overflow-hidden rounded-full bg-muted/40`,children:(0,T.jsx)(p.div,{className:`h-full w-2/5 rounded-full bg-primary`,animate:{x:[`-100%`,`250%`]},transition:{duration:1.2,repeat:1/0,ease:`easeInOut`}})})]})},`deploy-stream`):null}),(W||H)&&!X?(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,T.jsx)(ge,{className:`size-3.5 shrink-0 text-primary`,"aria-hidden":!0}),(0,T.jsxs)(`span`,{className:`truncate`,children:[`Preview for `,J?.label??`target`,`: `,n]})]}),(0,T.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,className:`h-8 shrink-0 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:q,children:[(0,T.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),`Close preview`]})]}),W?(0,T.jsx)(De,{}):H?(0,T.jsx)(je,{plan:H,planKind:`apply`,onCloseTable:q}):null]}):null,(0,T.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border/40 pt-5`,children:[(0,T.jsx)(`p`,{className:`font-heading text-[11px] font-semibold uppercase tracking-[0.2em] text-foreground`,children:`Export`}),(0,T.jsxs)(`div`,{className:`space-y-2`,children:[(0,T.jsx)(S,{className:`font-heading text-[11px] font-medium uppercase tracking-[0.14em] text-foreground/78`,children:`Format`}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,T.jsxs)(Ve,{value:_,onValueChange:e=>{e&&Ke(e)},children:[(0,T.jsx)(Be,{size:`sm`,className:`h-9! min-h-9 min-w-0 flex-1 border-border/65 bg-background/55 py-0 text-xs text-foreground`,children:(0,T.jsx)(Ie,{placeholder:`Select format`,children:t=>{if(t===`source-yaml`)return`Source YAML`;let n=Ue.find(e=>e.id===t);return n?.id===`litmus-edge`?ot(e):n?.exportLabel??`Select format`}})}),(0,T.jsxs)(Le,{children:[(0,T.jsxs)(ze,{children:[(0,T.jsx)(Fe,{children:`Platform`}),Ge.map(t=>(0,T.jsx)(y,{value:t.id,children:t.id===`litmus-edge`?ot(e):t.exportLabel},t.id)),We.map(e=>(0,T.jsx)(y,{value:e.id,disabled:!0,children:(0,T.jsxs)(`span`,{className:`flex items-center gap-2`,children:[e.exportLabel,(0,T.jsx)(Ye,{variant:`outline`,className:`px-1 py-0 text-[10px] text-foreground/72`,children:`Coming Soon`})]})},e.id))]}),(0,T.jsx)(Re,{}),(0,T.jsxs)(ze,{children:[(0,T.jsx)(Fe,{children:`Source`}),(0,T.jsxs)(y,{value:`source-yaml`,children:[`Source YAML`,` `,(0,T.jsx)(`span`,{className:`text-foreground/72`,children:e===`model`?`.twin.yaml`:`.miravo.yaml`})]})]})]})]}),(0,T.jsxs)(h,{variant:`outline`,size:`sm`,className:`h-9 min-h-9 shrink-0 gap-1.5 border-border/70 bg-background/50 px-4 text-xs font-medium text-foreground sm:w-auto`,disabled:!yt,onClick:bt,children:[(0,T.jsx)(qe,{className:`size-3.5`}),`Download`]})]})]}),(0,T.jsx)(`p`,{className:`text-[11px] leading-snug text-foreground/70`,children:(0,T.jsx)(Pe,{format:_,kind:e})})]}),J&&(0,T.jsx)(ve,{open:Xe,onOpenChange:w,type:`apply`,label:n,targetLabel:J.label,hostname:J.hostname,sourceHostname:J.sourceHostname,onConfirm:mt,defaultDeviceName:e===`model`?nt(t):void 0,defaultNamePrefix:e===`template`?t:void 0,metadata:e===`model`?[{label:`Protocol`,value:d.toUpperCase()},_e]:Oe,applyPreview:{onPreview:e=>void ht(e),planLoading:W,disabled:!l||X}}),(0,T.jsx)(Te,{open:E,editing:!1,platformId:O,form:A,showToken:Ze,saving:tt,testing:st,canTestConnection:pt,onOpenChange:D,onPlatformChange:k,onFormChange:j,onShowTokenChange:N,onSave:()=>void gt(),onTestConnection:_t,onCancelInFlight:L}),(0,T.jsx)(le,{open:ct,onOpenChange:e=>{R(e),e||B(P)},children:(0,T.jsxs)(de,{className:`sm:max-w-md`,children:[(0,T.jsxs)(ue,{children:[(0,T.jsx)(fe,{children:`Download Litmus Edge Template`}),(0,T.jsx)(ce,{children:me})]}),(0,T.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,T.jsx)(S,{htmlFor:`deploy-export-source-host`,children:Ne}),(0,T.jsx)(pe,{id:`deploy-export-source-host`,value:z,onChange:e=>B(e.target.value),placeholder:P,autoComplete:`off`,className:`font-mono text-sm`}),(0,T.jsxs)(`p`,{className:`text-[11px] leading-snug text-muted-foreground`,children:[`Use an IP or hostname reachable from Litmus Edge (e.g.`,` `,(0,T.jsx)(`span`,{className:`font-mono`,children:P}),` for Docker bridge).`]})]}),(0,T.jsxs)(se,{className:`gap-2 sm:gap-0`,children:[(0,T.jsx)(h,{type:`button`,variant:`outline`,onClick:()=>R(!1),disabled:V,children:`Cancel`}),(0,T.jsxs)(h,{type:`button`,className:`gap-1.5`,onClick:()=>void xt(),disabled:V,"aria-busy":V,children:[V?(0,T.jsx)(x,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,T.jsx)(qe,{className:`size-3.5`,"aria-hidden":!0}),`Download`]})]})]})})]})}var I={builtin:`Built-in`,personal:`Personal`,community:`Community`},L=`border-border/60 bg-muted/40 text-muted-foreground`,ct={builtin:L,personal:`border-primary/40 bg-primary/10 text-primary`,community:`border-accent/40 bg-accent/10 text-accent`};function R(e){return e===`cwd`||e===`namespace`?`personal`:e}function z(e){return I[R(e)]??e}function B(e){return ct[R(e)]??L}export{E as a,A as c,Xe as d,st as i,j as l,z as n,k as o,R as r,Ze as s,B as t,w as u};
@@ -1 +0,0 @@
1
- import{at as e}from"./vendor-ui-CWUk2ulb.js";import{n as t,t as n}from"./utils-XFKvwlFT.js";var r=t(`building`,[[`path`,{d:`M12 10h.01`,key:`1nrarc`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M12 6h.01`,key:`1vi96p`}],[`path`,{d:`M16 10h.01`,key:`1m94wz`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M16 6h.01`,key:`1x0f13`}],[`path`,{d:`M8 10h.01`,key:`19clt8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M8 6h.01`,key:`1dz90k`}],[`path`,{d:`M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3`,key:`cabbwy`}],[`rect`,{x:`4`,y:`2`,width:`16`,height:`20`,rx:`2`,key:`1uxh74`}]]),i=t(`droplet`,[[`path`,{d:`M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z`,key:`c7niix`}]]),a=t(`factory`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M16 16h.01`,key:`1f9h7w`}],[`path`,{d:`M3 19a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a.5.5 0 0 0-.769-.422l-4.462 2.844A.5.5 0 0 1 15 10.5v-2a.5.5 0 0 0-.769-.422L9.77 10.922A.5.5 0 0 1 9 10.5V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z`,key:`1iv0i2`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),o=t(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),s=t(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),c=e();function l({id:e,className:t}){let l=n(`shrink-0 text-primary`,t);switch(e){case`smart-factory`:return(0,c.jsx)(a,{className:l,"aria-hidden":!0});case`water-treatment`:return(0,c.jsx)(i,{className:l,"aria-hidden":!0});case`commercial-building`:return(0,c.jsx)(r,{className:l,"aria-hidden":!0});case`backup-power`:return(0,c.jsx)(s,{className:l,"aria-hidden":!0});default:return(0,c.jsx)(o,{className:l,"aria-hidden":!0})}}export{s as n,l as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./control-HqgjVMLG.js";export{e as ControlPage};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{c as t}from"./vendor-charts-95ykyDlI.js";import{at as n}from"./vendor-ui-CWUk2ulb.js";import{A as r,B as i,F as a,I as o,L as s,N as c,it as l,k as u}from"./api-5BZroqlO.js";import{t as d}from"./proxy-Be4WzmcS.js";import{t as f}from"./AnimatePresence-CPmH1DMY.js";import{i as p,r as m}from"./dist-xY0pK9Wy.js";import{a as h,i as g,l as ee,n as _,o as v,r as te,s as y,t as b}from"./copy-button-DnGsXbVV.js";import{t as x}from"./shallow-Cin0mLuv.js";import{C as S,S as C,T as ne,d as re,f as w,u as T}from"./format-B9CcV2dj.js";import{n as E,t as D}from"./utils-XFKvwlFT.js";import{t as ie}from"./activity-Cy_niK56.js";import{t as O}from"./arrow-right-BjBb4z7g.js";import{c as k,i as A,l as ae,n as oe,s as se,t as ce}from"./select-CMOnuEoT.js";import{a as le,c as j,i as ue,n as M,o as N,r as de,s as fe,t as pe}from"./tabs-D64chVAn.js";import{a as P,c as me,i as he,l as ge,n as _e,r as ve,s as F,t as I}from"./validation-Bt4EQDja.js";import{i as ye,n as be,r as xe,t as Se}from"./checkbox-C84IyqEB.js";import{t as Ce}from"./layers-1figUpjG.js";import{c as we,r as Te,t as L}from"./use-engine-command-mutation-CIly3RgV.js";import{t as R}from"./triangle-alert-BXrJNk3g.js";import{i as Ee,n as De,t as Oe}from"./tooltip-D1ydB4g3.js";import{t as ke}from"./transition-nav-link-CDSeWWsP.js";import{t as z}from"./badge-i00PiRCo.js";import{t as B}from"./label-DTHSKF2S.js";import{a as V,c as H,i as U,l as W,n as G,o as K,r as q,s as J,t as Y}from"./combobox-BJecIYHE.js";import{t as Ae}from"./spawn-protocol-scope-picker-DUXJ8giB.js";var je=E(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Me=E(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),Ne=E(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),Pe=E(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Fe=E(`power-off`,[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ie=E(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Le=E(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),Re=E(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ze=E(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Be=E(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),X=e(t(),1),Z=n(),Ve={mqtt:le,opcua:be,modbus:Me},He={mqtt:`MQTT`,opcua:`OPC UA`,modbus:`Modbus TCP`},Ue={mqtt:o,opcua:s,modbus:a};function We({adapter:e}){let t=e.pending?`pending`:e.enabled?`enabled`:`disabled`;return(0,Z.jsx)(f,{mode:`wait`,initial:!1,children:(0,Z.jsx)(d.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{type:`spring`,stiffness:500,damping:30},children:e.pending?(0,Z.jsxs)(z,{className:`gap-1 bg-info/20 text-info hover:bg-info/20`,children:[(0,Z.jsx)(N,{className:`size-3 animate-spin`}),e.enabled?`Disabling...`:`Enabling...`]}):e.enabled?(0,Z.jsxs)(z,{className:`gap-1 bg-success/20 text-success hover:bg-success/20`,children:[(0,Z.jsx)(j,{className:`size-3`}),`Enabled`]}):(0,Z.jsxs)(z,{variant:`outline`,className:`gap-1 text-muted-foreground`,children:[(0,Z.jsx)(je,{className:`size-2`}),`Disabled`]})},t)})}function Ge({metrics:e}){return e?e.connected?null:(0,Z.jsxs)(z,{variant:`destructive`,className:`gap-1`,children:[(0,Z.jsx)(fe,{className:`size-3`}),`Disconnected`]}):null}function Ke({health:e}){if(!e)return null;let t={healthy:`bg-success/20 text-success hover:bg-success/20`,busy:`bg-warning/20 text-warning hover:bg-warning/20`,saturated:`bg-destructive/20 text-destructive hover:bg-destructive/20`},n=e.state,r=`size-3 shrink-0`,i=n===`healthy`?(0,Z.jsx)(j,{className:r,"aria-hidden":!0}):n===`busy`?(0,Z.jsx)(ie,{className:r,"aria-hidden":!0}):n===`saturated`?(0,Z.jsx)(R,{className:r,"aria-hidden":!0}):null;return(0,Z.jsxs)(z,{className:D(`gap-1`,t[n]??``),children:[i,n]})}function Q({label:e,value:t,valueClassName:n}){return(0,Z.jsxs)(`div`,{className:`flex min-h-[3.35rem] flex-col justify-center rounded-[var(--miravo-radius-stadium-sm)] border border-border/55 px-3 py-2 transition-colors hover:border-muted-foreground/25`,children:[(0,Z.jsx)(`span`,{className:`blueprint-title text-[10px] leading-tight text-muted-foreground`,children:e}),(0,Z.jsx)(`span`,{className:D(`mt-1.5 font-mono text-[13px] leading-none tabular-nums tracking-tight text-foreground`,n),children:t})]})}function qe({metrics:e}){return(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(Q,{label:`Messages sent`,value:T(e.messagesPublished)}),(0,Z.jsx)(Q,{label:`Attempted`,value:T(e.messagesAttempted)}),(0,Z.jsx)(Q,{label:`Skipped (unchanged)`,value:T(e.messagesFiltered)}),(0,Z.jsx)(Q,{label:`Errors`,value:T(e.errorsCount),valueClassName:e.errorsCount>0?`text-destructive`:void 0}),(0,Z.jsx)(Q,{label:`Publish latency`,value:`${e.lastPublishMs.toFixed(1)} ms`}),e.health?(0,Z.jsx)(Q,{label:`Queued messages`,value:String(e.health.pendingWorkCount)}):null]})}function Je({port:e}){return(0,Z.jsxs)(`div`,{className:`flex gap-2 rounded-[var(--miravo-radius-stadium-sm)] border border-warning/30 bg-warning/10 p-3 text-sm text-warning`,children:[(0,Z.jsx)(R,{className:`mt-0.5 size-4 shrink-0`}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Before enabling`}),(0,Z.jsxs)(`p`,{className:`mt-1 text-warning`,children:[`Ensure port `,(0,Z.jsx)(`code`,{className:`font-mono font-bold`,children:e}),` is available on the host.`]}),(0,Z.jsxs)(`ul`,{className:`mt-1 list-inside list-disc space-y-0.5 text-warning`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:`Docker:`}),` Restart with`,` `,(0,Z.jsxs)(`code`,{className:`font-mono`,children:[`-p `,e,`:`,e]}),` `,`to expose the port.`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:`Bare metal:`}),` Run `,(0,Z.jsxs)(`code`,{className:`font-mono`,children:[`lsof -i :`,e]}),` to check availability.`]})]})]})]})}function Ye({adapter:e,metrics:t}){let[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(!1),c=L(),l=Ve[e.name]??be,u=He[e.name]??e.name,p=Ue[e.name]??0,m=o||e.pending===!0,h=(0,X.useMemo)(()=>{let t=e.config?.port;return typeof t==`number`?t:p},[e.config,p]);return(0,Z.jsxs)(`div`,{className:`protocol-card-art min-w-0 border`,children:[(0,Z.jsxs)(`div`,{className:`relative z-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,"aria-expanded":n,className:`group/row flex w-full min-w-0 cursor-pointer gap-3 px-4 py-3 text-left transition-colors duration-[var(--miravo-duration-base)] ease-[var(--miravo-ease)] hover:bg-muted/35`,onClick:()=>r(!n),children:[(0,Z.jsx)(l,{className:`mt-0.5 size-5 shrink-0 text-muted-foreground transition-[transform,color] duration-[var(--miravo-duration-base)] ease-[var(--miravo-ease)] group-hover/row:-rotate-[8deg] group-hover/row:scale-[1.08] group-hover/row:text-primary motion-reduce:transition-none motion-reduce:group-hover/row:rotate-0 motion-reduce:group-hover/row:scale-100`,"aria-hidden":!0}),(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-start justify-between gap-x-3 gap-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[e.enabled&&!e.pending&&(0,Z.jsx)(`span`,{className:`protocol-card-live-dot`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`whitespace-nowrap font-medium tracking-tight`,children:u}),(0,Z.jsx)(We,{adapter:e}),e.enabled&&!e.pending&&t&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ge,{metrics:t}),t.health?(0,Z.jsx)(Ke,{health:t.health}):(0,Z.jsxs)(z,{className:`gap-1 bg-success/20 text-success hover:bg-success/20`,children:[(0,Z.jsx)(j,{className:`size-3 shrink-0`,"aria-hidden":!0}),`healthy`]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[e.enabled&&t&&!e.pending&&(0,Z.jsxs)(`span`,{className:`protocol-card-metric-readout text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-normal uppercase tracking-[0.12em] text-muted-foreground`,children:`out`}),` `,(0,Z.jsx)(`span`,{className:`text-foreground`,children:T(t.messagesPublished)}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:` msgs`}),t.errorsCount>0&&(0,Z.jsxs)(`span`,{className:`ml-1.5 text-destructive`,children:[t.errorsCount,` err`]})]}),(0,Z.jsx)(ae,{className:`size-4 shrink-0 text-muted-foreground transition-[transform,color] duration-[var(--miravo-duration-base)] ease-[var(--miravo-ease)] group-hover/row:translate-y-0.5 group-hover/row:text-primary motion-reduce:transition-none motion-reduce:group-hover/row:translate-y-0 ${n?`rotate-180`:``}`})]})]})})]}),e.enabled&&!e.pending&&e.endpoint&&(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 px-4 pb-2 pl-11`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,children:e.endpoint}),(0,Z.jsx)(b,{value:e.endpoint,label:`Copy endpoint URL`})]})]}),(0,Z.jsx)(f,{initial:!1,children:n&&(0,Z.jsx)(d.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:`easeOut`},className:`overflow-hidden`,children:(0,Z.jsx)(`div`,{className:`protocol-card-art-body border-t`,children:e.enabled&&t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`px-4 pb-4 pt-4`,"aria-labelledby":`protocol-telemetry-${e.name}`,children:[(0,Z.jsxs)(`div`,{className:`mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3`,children:[(0,Z.jsx)(`h4`,{id:`protocol-telemetry-${e.name}`,className:`blueprint-title shrink-0 text-muted-foreground`,children:`Telemetry`}),(0,Z.jsxs)(ke,{to:`/tags?protocol=${e.name}`,className:`group/footer-link inline-flex w-full min-h-8 min-w-0 max-w-full shrink-0 items-center justify-start gap-1.5 rounded-[var(--miravo-radius-pill)] border border-primary/25 bg-primary/5 px-2.5 py-1.5 text-xs font-medium leading-tight text-primary transition-colors hover:border-primary/40 hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background sm:w-fit`,children:[(0,Z.jsx)(`span`,{className:`whitespace-nowrap`,children:`Browse Tags`}),(0,Z.jsx)(O,{className:`size-3 shrink-0 text-primary transition-transform group-hover/footer-link:translate-x-0.5`})]})]}),(0,Z.jsx)(qe,{metrics:t})]}),(0,Z.jsx)(`footer`,{className:`protocol-card-art-footer flex flex-col gap-4 border-t border-border/80 px-4 pb-4 pt-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,Z.jsxs)(S,{variant:`destructive`,size:`sm`,className:`gap-1.5`,disabled:m,onClick:async()=>{s(!0);try{await c.mutateAsync({type:`disableAdapter`,adapter:e.name})}catch{}finally{s(!1)}},children:[m?(0,Z.jsx)(N,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(Fe,{className:`size-3.5`}),m?`Disabling...`:`Disable ${u}`]}),!m&&(0,Z.jsx)(`span`,{className:`text-xs leading-snug text-muted-foreground`,children:`Active connections will be dropped.`})]})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 py-4`,children:[!m&&(0,Z.jsx)(Je,{port:i&&Number(i)||h}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(B,{htmlFor:`port-${e.name}`,className:`text-xs`,children:`Port`}),(0,Z.jsx)(C,{id:`port-${e.name}`,type:`number`,placeholder:String(h),value:i,onChange:e=>a(e.target.value),className:`w-28`,disabled:m})]}),(0,Z.jsxs)(S,{size:`sm`,className:`gap-1.5`,disabled:m,onClick:async()=>{s(!0);try{let t=i?Number(i):void 0,n={};t&&Number.isFinite(t)&&(n.port=t),await c.mutateAsync({type:`enableAdapter`,adapter:e.name,...Object.keys(n).length>0?{config:n}:{}})}catch{}finally{s(!1)}},children:[m?(0,Z.jsx)(N,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(Ie,{className:`size-3.5`}),m?`Enabling...`:`Enable ${u}`]})]})]})})},`panel`)})]})}function Xe(){let{instances:e,models:t,templateRuns:n}=l(x(e=>({instances:e.instances,models:e.models,templateRuns:e.templateRuns}))),i=L(),[a,o]=(0,X.useState)(``),[s,p]=(0,X.useState)(`1`),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(``),[v,te]=(0,X.useState)([]),[y,b]=(0,X.useState)(null),[w,T]=(0,X.useState)(null),[E,ie]=(0,X.useState)(``),O=(0,X.useMemo)(()=>E?t.filter(e=>e.name.toLowerCase().includes(E.toLowerCase())):t,[t,E]),k=Number(s)||1,A=a?r(a):``,ae=m.trim()?m.trim():u(g.trim()||A||`instance`,1);return(0,Z.jsxs)(K,{className:`h-full min-w-0`,children:[(0,Z.jsx)(H,{className:`pb-3`,children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(Ce,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Fleet Management`]})}),(0,Z.jsxs)(J,{className:`flex flex-1 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Spawn Instances`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-0 sm:flex-1`,children:(0,Z.jsxs)(Y,{value:a||null,onValueChange:e=>o(e??``),onInputValueChange:ie,children:[(0,Z.jsx)(q,{placeholder:`Select model`,className:`h-8 w-full min-w-0`,showClear:!!a}),(0,Z.jsx)(G,{children:(0,Z.jsxs)(V,{children:[O.map(e=>(0,Z.jsx)(U,{value:e.name,children:e.name},e.name)),O.length===0&&(0,Z.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No models found`})]})})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsx)(C,{type:`number`,value:s,onChange:e=>p(e.target.value),className:`h-8 w-16 text-xs`,min:`1`,"aria-label":`Number of instances to spawn`}),(0,Z.jsx)(S,{size:`sm`,className:`h-8`,disabled:y!=null||w!=null||!a,onClick:()=>{if(m.trim()&&k!==1){ee.error(`Exact instance ID requires count 1.`);return}let e=P(he,{model:a,count:k,...m.trim()?{instanceName:m.trim()}:{},...g.trim()?{instancePrefix:g.trim()}:{},...v.length>0?{protocolScope:v}:{}});e&&i.mutate({type:`spawn`,...e})},children:`Spawn`})]})]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-2 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(B,{htmlFor:`fleet-station-instance-name`,className:`text-[10px]`,children:`Exact instance ID`}),(0,Z.jsx)(C,{id:`fleet-station-instance-name`,value:m,maxLength:120,onChange:e=>{let t=e.target.value;h(t),t&&(_(``),T(null)),b(c(t))},placeholder:k===1?`Exact instance ID`:`Exact name needs count 1`,disabled:k!==1,className:D(`h-8 min-w-0 font-mono text-xs`,y&&`border-destructive`),"aria-invalid":y!=null,"aria-label":`Exact instance ID`}),y?(0,Z.jsx)(`p`,{className:`text-[10px] text-destructive`,children:y}):null]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(B,{htmlFor:`fleet-station-instance-prefix`,className:`text-[10px]`,children:`Generated prefix`}),(0,Z.jsx)(C,{id:`fleet-station-instance-prefix`,value:g,maxLength:120,onChange:e=>{let t=e.target.value;_(t),t&&(h(``),b(null)),T(c(t))},placeholder:A||`Generated prefix`,className:D(`h-8 min-w-0 font-mono text-xs`,w&&`border-destructive`),"aria-invalid":w!=null,"aria-label":`Generated prefix`}),w?(0,Z.jsx)(`p`,{className:`text-[10px] text-destructive`,children:w}):null]})]}),(0,Z.jsx)(Ae,{value:v,onChange:te,className:`pt-1`}),(0,Z.jsxs)(`span`,{className:`min-w-0 wrap-break-word text-[10px] text-muted-foreground`,children:[t.length,` models · `,e.length,` running · default`,` `,(0,Z.jsx)(`span`,{className:`font-mono`,children:A||`auto`}),` · preview`,` `,(0,Z.jsx)(`span`,{className:`break-all font-mono text-foreground`,children:ae})]})]}),n.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Environment Runs`}),(0,Z.jsx)(f,{initial:!1,children:n.map(e=>(0,Z.jsx)(d.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4,transition:{duration:.12}},transition:{type:`spring`,stiffness:400,damping:30},children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-[var(--miravo-radius-tight)] border px-2.5 py-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 overflow-hidden`,children:[(0,Z.jsx)(`span`,{className:`truncate text-xs font-medium`,children:re(e.templateName)}),(0,Z.jsxs)(z,{variant:`secondary`,className:`shrink-0 text-[10px]`,children:[e.instanceIds.length,` inst`]})]}),(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,className:`h-6 shrink-0 px-1.5 text-destructive hover:text-destructive`,"aria-label":`Unload environment run`,onClick:()=>i.mutate({type:`unloadTemplateRun`,templateRunId:e.templateRunId}),children:(0,Z.jsx)(ne,{className:`size-3`})})]})},e.templateRunId))})]})]})]})]})}function Ze(){let{instances:e,models:t}=l(x(e=>({instances:e.instances,models:e.models}))),n=L(),[r,i]=(0,X.useState)(``),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(``),u=(0,X.useMemo)(()=>s?e.filter(e=>e.id.toLowerCase().includes(s.toLowerCase())):e,[e,s]),p=(0,X.useMemo)(()=>{let n=e.find(e=>e.id===r);return n?t.find(e=>e.name===n.model)?.faultNames??[]:[]},[r,e,t]),m=(0,X.useMemo)(()=>e.filter(e=>e.activeFaults.length>0),[e]),h=m.reduce((e,t)=>e+t.activeFaults.length,0);return(0,Z.jsxs)(K,{className:`h-full min-w-0`,children:[(0,Z.jsx)(H,{className:`pb-3`,children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(R,{className:`size-3.5 ${h>0?`text-destructive`:`text-muted-foreground`}`}),`Fault Lab`,(0,Z.jsx)(f,{children:h>0&&(0,Z.jsx)(d.div,{initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{type:`spring`,stiffness:500,damping:30},children:(0,Z.jsxs)(z,{variant:`destructive`,className:`text-[10px]`,children:[h,` active`]})},`fault-count`)})]})}),(0,Z.jsxs)(J,{className:`flex flex-1 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Z.jsxs)(Y,{value:r||null,onValueChange:e=>{i(e??``),o(``)},onInputValueChange:c,children:[(0,Z.jsx)(q,{placeholder:`Select instance`,className:`h-8 min-h-11 w-full min-w-0 touch-manipulation sm:min-h-8`,showClear:!!r}),(0,Z.jsx)(G,{children:(0,Z.jsxs)(V,{children:[u.map(e=>(0,Z.jsxs)(U,{value:e.id,children:[(0,Z.jsx)(`span`,{className:`font-mono`,children:e.id}),e.activeFaults.length>0&&(0,Z.jsx)(z,{variant:`destructive`,className:`ml-auto text-[10px]`,children:e.activeFaults.length})]},e.id)),u.length===0&&(0,Z.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]}),(0,Z.jsxs)(ce,{value:a,onValueChange:e=>o(e??``),children:[(0,Z.jsx)(se,{className:`h-8 min-h-11 w-full touch-manipulation sm:min-h-8`,"aria-label":`Fault type`,children:(0,Z.jsx)(k,{placeholder:r?`Select fault`:`Pick instance first`})}),(0,Z.jsx)(oe,{alignItemWithTrigger:!1,align:`start`,children:p.map(e=>(0,Z.jsx)(A,{value:e,children:e},e))})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(S,{variant:`destructive`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!a,onClick:()=>{let e=P(I,{instanceId:r,fault:a});e&&n.mutate({type:`triggerFault`,...e})},children:`Trigger`}),(0,Z.jsx)(S,{variant:`secondary`,size:`sm`,className:`h-7 min-h-11 touch-manipulation text-xs sm:min-h-7`,disabled:!r||!a,onClick:()=>{let e=P(I,{instanceId:r,fault:a});e&&n.mutate({type:`clearFault`,...e})},children:`Clear`})]}),(0,Z.jsx)(F,{}),(0,Z.jsx)(f,{mode:`wait`,initial:!1,children:m.length>0?(0,Z.jsxs)(d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Faulted Instances`}),(0,Z.jsx)(f,{initial:!1,children:m.map(e=>(0,Z.jsx)(d.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},exit:{opacity:0,x:6,transition:{duration:.1}},transition:{type:`spring`,stiffness:400,damping:35},children:(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-h-11 w-full touch-manipulation items-center justify-between rounded-[var(--miravo-radius-tight)] border border-destructive/20 bg-destructive/5 px-2.5 py-1.5 text-left transition-colors hover:bg-destructive/10 sm:min-h-0`,onClick:()=>{i(e.id),o(``)},children:[(0,Z.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.id}),(0,Z.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-destructive`,children:e.activeFaults.join(`, `)})]})},e.id))})]},`faulted`):(0,Z.jsxs)(d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex items-center gap-2 py-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(j,{className:`size-3.5 text-success`}),`All clear — no active faults`]},`all-clear`)})]})]})}function Qe(){let e=l(e=>e.instances),t=L(),[n,r]=(0,X.useState)(``),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),c=(0,X.useMemo)(()=>o?e.filter(e=>e.id.toLowerCase().includes(o.toLowerCase())):e,[e,o]),u=(0,X.useMemo)(()=>e.filter(e=>e.isQuarantined),[e]),p=(0,X.useMemo)(()=>e.filter(e=>!e.isQuarantined&&e.activeFaults.length===0).length,[e]),m=(0,X.useMemo)(()=>e.filter(e=>!e.isQuarantined&&e.activeFaults.length>0).length,[e]);return(0,Z.jsxs)(K,{className:`h-full min-w-0`,children:[(0,Z.jsx)(H,{className:`pb-3`,children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(Re,{className:`size-3.5 text-muted-foreground`}),`Instance Actions`]})}),(0,Z.jsxs)(J,{className:`flex flex-1 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Remove Instance`}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 w-full sm:min-w-0 sm:flex-1`,children:(0,Z.jsxs)(Y,{value:n||null,onValueChange:e=>{r(e??``),a(!1)},onInputValueChange:s,children:[(0,Z.jsx)(q,{placeholder:`Select instance`,className:`h-8 w-full min-w-0`,showClear:!!n}),(0,Z.jsx)(G,{children:(0,Z.jsxs)(V,{children:[c.map(e=>(0,Z.jsx)(U,{value:e.id,children:(0,Z.jsx)(`span`,{className:`font-mono`,children:e.id})},e.id)),c.length===0&&(0,Z.jsx)(`p`,{className:`py-2 text-center text-xs text-muted-foreground`,children:`No instances found`})]})})]})}),i&&n?(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] text-destructive`,children:`Remove?`}),(0,Z.jsx)(S,{size:`sm`,variant:`destructive`,className:`h-7 text-xs`,onClick:()=>{t.mutate({type:`removeInstance`,instanceId:n}),a(!1),r(``)},children:`Confirm`}),(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>a(!1),children:`Cancel`})]}):(0,Z.jsxs)(S,{className:`h-8 w-full shrink-0 gap-1.5 sm:w-auto`,variant:`destructive`,size:`sm`,disabled:!n,onClick:()=>{P(_e,{instanceId:n})&&a(!0)},children:[(0,Z.jsx)(Be,{className:`size-3`}),`Remove`]})]})]}),(0,Z.jsx)(F,{}),(0,Z.jsx)(f,{mode:`wait`,initial:!1,children:u.length>0?(0,Z.jsxs)(d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wider text-warning`,children:[`Quarantined`,(0,Z.jsx)(z,{variant:`secondary`,className:`text-[10px] text-warning`,children:u.length})]}),(0,Z.jsx)(f,{initial:!1,children:u.map(e=>(0,Z.jsx)(d.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},exit:{opacity:0,transition:{duration:.1}},transition:{type:`spring`,stiffness:400,damping:35},children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between rounded-[var(--miravo-radius-tight)] border border-warning/20 bg-warning/5 px-2.5 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.id}),(0,Z.jsx)(S,{size:`sm`,variant:`outline`,className:`h-6 shrink-0 text-[10px]`,onClick:()=>t.mutate({type:`unquarantine`,instanceId:e.id}),children:`Unquarantine`})]})},e.id))})]},`quarantined`):(0,Z.jsxs)(d.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Fleet Health`}),(0,Z.jsx)(`div`,{className:`flex items-center gap-4 text-xs`,children:e.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`size-2 rounded-full bg-success`}),(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:p}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`healthy`})]}),m>0&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`size-2 rounded-full bg-warning`}),(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:m}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`faulted`})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(ze,{className:`size-3 text-success`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`0 quarantined`})]})]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`No instances running`})})]},`fleet-health`)})]})]})}function $e(e){let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}function et(e){if(!Number.isFinite(e)||e<=0)return`0s`;if(e<60)return`${e.toFixed(1)}s`;let t=Math.floor(e),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60),a=t%60;return n>0?r>0?`${n}d ${r}h`:i>0?`${n}d ${i}m`:`${n}d`:r>0?`${r}h ${i}m`:i>0?`${i}m ${a}s`:`${a}s`}function tt({data:e}){let t=(0,X.useMemo)(()=>{if(e.length<2)return null;let t=e.map(e=>e.tps),n=Math.max(...t,.1),r=Math.min(...t,0),i=n-r||1;return{points:t.map((e,n)=>{let a=n/(t.length-1)*200,o=2+(1-(e-r)/i)*28;return`${n===0?`M`:`L`}${a.toFixed(1)},${o.toFixed(1)}`}).join(` `),min:r,max:n}},[e]);return t?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`svg`,{viewBox:`0 0 200 32`,className:`h-8 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":`TPS trend sparkline`,children:[(0,Z.jsx)(`line`,{x1:`0`,y1:`10.7`,x2:`200`,y2:`10.7`,stroke:`currentColor`,strokeWidth:`0.5`,strokeDasharray:`3,2`,className:`text-border`}),(0,Z.jsx)(`line`,{x1:`0`,y1:`21.3`,x2:`200`,y2:`21.3`,stroke:`currentColor`,strokeWidth:`0.5`,strokeDasharray:`3,2`,className:`text-border`}),(0,Z.jsx)(`path`,{d:t.points,fill:`none`,stroke:`var(--primary)`,strokeWidth:`1.5`})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between text-[9px] text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{children:[`60s ago · `,t.min.toFixed(1)]}),(0,Z.jsxs)(`span`,{children:[t.max.toFixed(1),` · now`]})]})]}):(0,Z.jsx)(`div`,{className:`flex h-8 items-center text-[10px] text-muted-foreground`,children:`Collecting...`})}var nt={running:`bg-success`,paused:`bg-warning`,idle:`bg-muted-foreground`,stopped:`bg-destructive`};function rt({state:e}){let t=nt[e]??`bg-muted-foreground`,n=e===`running`;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Z.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:`size-2.5 rounded-full ${t}`}),n&&(0,Z.jsx)(`span`,{className:`absolute size-2.5 animate-ping rounded-full ${t} opacity-40`})]}),(0,Z.jsx)(f,{mode:`wait`,initial:!1,children:(0,Z.jsx)(d.span,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},exit:{opacity:0,y:5},transition:{type:`spring`,stiffness:500,damping:30},className:`font-mono text-lg font-bold uppercase tracking-wider`,children:e},e)})]})}function $({label:e,tooltip:t,tooltipClassName:n}){return(0,Z.jsxs)(`div`,{className:`inline-flex w-fit min-w-0 max-w-full items-center gap-1`,children:[(0,Z.jsx)(`span`,{className:`blueprint-title min-w-0 shrink text-[11px] leading-tight text-muted-foreground`,children:e}),(0,Z.jsxs)(Oe,{children:[(0,Z.jsx)(Ee,{className:`inline-flex size-4 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border-0 bg-transparent p-0 text-muted-foreground shadow-none outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring`,render:(0,Z.jsx)(`button`,{type:`button`}),"aria-label":`About ${e}`,children:(0,Z.jsx)(ye,{className:`size-3`,"aria-hidden":!0})}),(0,Z.jsx)(De,{side:`top`,className:D(`max-w-xs`,n),children:t})]})]})}function it(){let{engineState:e,connectionState:t}=l(x(e=>({engineState:e.engineState,connectionState:e.connectionState}))),n=L();return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)($,{label:`Run state`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Whether the scheduler is running, paused, idle, or stopped. Pause freezes simulated time; resume continues from the same tick.`})}),(0,Z.jsx)(rt,{state:e}),t===`live`&&(e===`running`||e===`paused`)&&(0,Z.jsx)(`div`,{className:`mt-1 flex items-center gap-2`,children:(0,Z.jsxs)(S,{type:`button`,size:`sm`,variant:e===`paused`?`default`:`outline`,className:D(`h-8 min-h-11 w-fit touch-manipulation gap-1.5 px-3 text-xs sm:min-h-8`,e===`running`&&`border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 hover:text-warning focus-visible:border-warning/50 focus-visible:ring-warning/25 border-warning/35`),onClick:()=>n.mutate({type:e===`paused`?`resume`:`pause`}),children:[e===`paused`?(0,Z.jsx)(we,{className:`size-3`}):(0,Z.jsx)(Pe,{className:`size-3`}),e===`paused`?`Resume`:`Pause`]})})]})}function at(){let{speedMultiplier:e,connectionState:t}=l(x(e=>({speedMultiplier:e.speedMultiplier,connectionState:e.connectionState}))),n=L(),[r,i]=(0,X.useState)(String(e)),a=t===`live`;return(0,X.useEffect)(()=>{i(String(e))},[e]),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)($,{label:`Speed`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Runs the environment at this multiple of real time. 1× is real time; higher values speed up the model. Change it with the field and Set.`})}),(0,Z.jsxs)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:[e,`x`]}),(0,Z.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(B,{htmlFor:`speed-multiplier`,className:`sr-only`,children:`Speed multiplier`}),(0,Z.jsx)(C,{id:`speed-multiplier`,type:`number`,value:r,onChange:e=>i(e.target.value),className:`h-8 min-h-11 w-[4.75rem] touch-manipulation font-mono text-xs tabular-nums sm:min-h-8`,min:`1`,max:`1000`,disabled:!a}),(0,Z.jsx)(S,{type:`button`,size:`sm`,variant:`outline`,className:`h-8 min-h-11 touch-manipulation px-3 text-xs sm:min-h-8`,disabled:!a,onClick:()=>{let e=P(ve,{multiplier:Number(r)});e&&n.mutate({type:`setSpeed`,multiplier:e.multiplier})},children:`Set`})]})]})}function ot(){let{tick:e,simulationTime:t,tps:n,tpsHistory:r,uptimeMs:i,instanceCount:a,memberValueCount:o}=l(x(e=>({tick:e.tick,simulationTime:e.simulationTime,tps:e.tps,tpsHistory:e.tpsHistory,uptimeMs:e.uptimeMs,instanceCount:e.instanceCount,memberValueCount:e.memberValueCount})));return(0,Z.jsxs)(`div`,{className:D(Te,`px-4 py-3`),children:[(0,Z.jsxs)(`header`,{className:`mb-3 border-b border-border/60 pb-2`,children:[(0,Z.jsx)(`h2`,{className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`Engine vitals`}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`Scheduler, speed, cycle count, and throughput for this session.`})]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-2 gap-3 @2xl/main:gap-4 @3xl/main:grid-cols-3 @5xl/main:grid-cols-6`,children:[(0,Z.jsx)(it,{}),(0,Z.jsx)(at,{}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)($,{label:`Cycle`,tooltipClassName:`flex flex-col items-start gap-2 text-left`,tooltip:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Cycle`}),` compares simulated progress with wall time: how many steps ran, how much model time advanced, and how long this session has been open.`]}),(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[`The number is `,(0,Z.jsx)(`span`,{className:`font-medium`,children:`tick`}),` count — completed scheduler steps since this run. Each tick refreshes the plant model and live tags.`]}),(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Sim`}),` is simulated elapsed time. Each tick adds (tick interval × speed) to this clock. Generators, lifecycle, and in-model timestamps use Sim, not your system clock. It stops advancing while paused.`]}),(0,Z.jsxs)(`p`,{className:`text-[11px] leading-snug`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Real`}),` is wall-clock uptime since the run started (real time).`]})]})}),(0,Z.jsx)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:T(e)}),(0,Z.jsxs)(`div`,{className:`mt-1 flex w-full min-w-0 flex-col gap-0.5 leading-tight`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-10 shrink-0 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Sim`}),(0,Z.jsx)(`span`,{className:`min-w-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:et(t)})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`w-10 shrink-0 text-[9px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Real`}),(0,Z.jsx)(`span`,{className:`min-w-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:$e(i)})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)($,{label:`Throughput`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Ticks per second: how fast the engine is stepping. Rises and falls with workload, speed setting, and CPU headroom.`})}),(0,Z.jsxs)(`span`,{className:`w-fit font-mono text-lg font-bold tabular-nums`,children:[n.toFixed(1),` tps`]}),(0,Z.jsxs)(`span`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[a,` inst · `,w(o),` tags`]})]}),(0,Z.jsxs)(`div`,{className:`col-span-2 flex flex-col gap-2`,children:[(0,Z.jsx)($,{label:`TPS Trend`,tooltip:(0,Z.jsx)(`p`,{className:`text-[11px] leading-snug`,children:`Recent ticks-per-second samples over about the last minute. Flat or noisy lines usually mean load or speed changes.`})}),(0,Z.jsx)(tt,{data:r})]})]})]})}var st=[`MQTT Sparkplug B`,`EtherNet/IP`,`Siemens S7`];function ct({enabled:e,total:t}){let n=t===0?`empty`:e===0?`idle`:`live`;return(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 rounded-[var(--miravo-radius-pill)] border border-border/60 bg-background/60 px-2.5 py-1 backdrop-blur-sm`,children:[(0,Z.jsxs)(`span`,{className:`relative flex size-1.5 items-center justify-center`,children:[(0,Z.jsx)(`span`,{className:D(`size-1.5 rounded-full`,n===`live`?`bg-success shadow-[0_0_0_1px_color-mix(in_srgb,var(--success)_50%,transparent),0_0_12px_color-mix(in_srgb,var(--success)_42%,transparent)]`:n===`idle`?`bg-warning/85 shadow-[0_0_0_1px_color-mix(in_srgb,var(--warning)_50%,transparent),0_0_12px_color-mix(in_srgb,var(--warning)_38%,transparent)]`:`bg-muted-foreground/55`)}),n===`live`&&(0,Z.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-success/60`})]}),(0,Z.jsxs)(`span`,{className:`text-[11px] leading-none text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-mono font-semibold tabular-nums text-foreground`,children:e}),(0,Z.jsx)(`span`,{className:`mx-1 text-muted-foreground/60`,children:`/`}),(0,Z.jsx)(`span`,{className:`font-mono tabular-nums`,children:t}),(0,Z.jsx)(`span`,{className:`ml-1.5 text-[10px] uppercase tracking-[0.14em]`,children:`active`})]})]})}function lt(){let{availableAdapters:e,adapterMetrics:t}=l(x(e=>({availableAdapters:e.availableAdapters,adapterMetrics:e.adapterMetrics}))),n=e.filter(e=>e.enabled).length;return(0,Z.jsxs)(`section`,{className:D(Te,`flex min-w-0 flex-col hover:border-border`),children:[(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-border/60 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-[var(--miravo-radius-tight)] border border-border/60 bg-background/70 text-muted-foreground`,"aria-hidden":!0,children:(0,Z.jsx)(Le,{className:`size-3.5`})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`font-heading text-sm font-semibold tracking-tight text-foreground`,children:`Protocol Gateway`}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-pretty text-xs text-muted-foreground`,children:`Northbound adapters publishing engine telemetry to external systems.`})]})]}),(0,Z.jsx)(ct,{enabled:n,total:e.length})]}),e.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-col gap-2 px-4 py-4`,children:(0,Z.jsx)(f,{children:e.map((e,n)=>{let r=t.find(t=>t.name===e.name)?.metrics;return(0,Z.jsx)(d.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0},transition:{type:`spring`,stiffness:380,damping:30,delay:n*.05},children:(0,Z.jsx)(Ye,{adapter:e,metrics:r})},e.name)})})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 border-t border-border/60 bg-background/40 px-4 py-2.5`,role:`status`,"aria-label":`Upcoming protocol adapters: ${st.join(`, `)}, and more`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,Z.jsx)(xe,{className:`size-3 text-muted-foreground/70`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground`,children:`Roadmap`})]}),(0,Z.jsxs)(`ul`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[st.map(e=>(0,Z.jsx)(`li`,{className:`rounded-[var(--miravo-radius-tight)] border border-dashed border-border/70 bg-background/40 px-2 py-0.5 font-mono text-[10px] leading-[15px] tracking-tight text-muted-foreground`,children:e},e)),(0,Z.jsx)(`li`,{className:`font-mono text-[10px] leading-[15px] tracking-tight text-muted-foreground/75`,children:`+ more`})]})]})]})}function ut(){let e=l(e=>e.instances),t=L(),[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1);return(0,Z.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col`,children:[(0,Z.jsxs)(K,{className:`h-full min-w-0`,children:[(0,Z.jsx)(H,{className:`pb-3`,children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 text-xs font-medium uppercase tracking-wider`,children:[(0,Z.jsx)(Ne,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),`Danger Zone`]})}),(0,Z.jsx)(J,{className:`flex flex-1 flex-col`,children:(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-3 rounded-[var(--miravo-radius-stadium-sm)] border border-dashed border-border p-3 @2xl/main:flex-row @2xl/main:items-center @2xl/main:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Reset environment`}),(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Removes `,e.length,` running instance`,e.length===1?``:`s`,` and all loaded environments.`]})]}),(0,Z.jsx)(S,{className:`min-h-11 w-full shrink-0 touch-manipulation @2xl/main:w-auto sm:min-h-7`,variant:`destructive`,size:`sm`,onClick:()=>r(!0),children:`Reset`})]})})]}),(0,Z.jsx)(_,{open:n,onOpenChange:e=>{r(e),e||a(!1)},children:(0,Z.jsxs)(te,{children:[(0,Z.jsxs)(v,{children:[(0,Z.jsx)(y,{children:`Reset Environment`}),(0,Z.jsx)(g,{children:`Removes all running instances and loaded environments.`})]}),(0,Z.jsx)(`div`,{className:`space-y-3 text-sm`,children:(0,Z.jsx)(`div`,{className:`rounded-[var(--miravo-radius-stadium-sm)] border p-3`,children:(0,Z.jsxs)(B,{htmlFor:`clear-persisted-state`,className:`items-start`,children:[(0,Z.jsx)(Se,{id:`clear-persisted-state`,checked:i,onCheckedChange:e=>a(e===!0)}),(0,Z.jsxs)(`span`,{className:`space-y-1`,children:[(0,Z.jsx)(`span`,{className:`block font-medium text-foreground`,children:`Also clear persisted state`}),(0,Z.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Start empty on the next restart.`})]})]})})}),(0,Z.jsxs)(h,{children:[(0,Z.jsx)(S,{variant:`outline`,className:`min-h-11 w-full touch-manipulation sm:min-h-8 sm:w-auto`,onClick:()=>{r(!1),a(!1)},disabled:o,children:`Cancel`}),(0,Z.jsx)(S,{variant:`destructive`,className:`min-h-11 w-full touch-manipulation sm:min-h-8 sm:w-auto`,disabled:o,onClick:async()=>{s(!0);try{await t.mutateAsync({type:`resetEnvironment`,...i?{clearPersistence:!0}:{}}),r(!1),a(!1)}catch{}finally{s(!1)}},children:o?`Resetting...`:`Confirm Reset`})]})]})})]})}function dt(){let[e,t]=p(`tab`,m([`monitor`,`operate`]).withDefault(`monitor`));return(0,Z.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-screen-2xl flex-col gap-5 p-4 sm:gap-6 sm:p-6`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`font-heading text-2xl font-semibold tracking-tight`,children:`Mission Control`}),(0,Z.jsxs)(z,{variant:`outline`,title:`Miravo version ${i}`,className:`font-mono text-[10px] leading-none text-muted-foreground`,children:[`v`,i]})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Engine telemetry, protocol management, and fleet operations.`})]}),(0,Z.jsxs)(pe,{value:e,onValueChange:e=>{t(e)},className:`min-h-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`shrink-0 overflow-x-auto`,children:(0,Z.jsxs)(de,{variant:`line`,className:`h-10! min-w-max gap-0.5`,children:[(0,Z.jsxs)(ue,{value:`monitor`,className:`gap-1.5 px-3 text-sm`,children:[(0,Z.jsx)(ge,{className:`size-3.5 shrink-0`}),`Monitor`]}),(0,Z.jsxs)(ue,{value:`operate`,className:`gap-1.5 px-3 text-sm`,children:[(0,Z.jsx)(me,{className:`size-3.5 shrink-0`}),`Operate`]})]})}),(0,Z.jsx)(M,{value:`monitor`,className:`flex-1 py-2`,children:(0,Z.jsxs)(d.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`flex flex-col gap-5 sm:gap-6`,children:[(0,Z.jsx)(ot,{}),(0,Z.jsx)(lt,{})]},`monitor`)}),(0,Z.jsx)(M,{value:`operate`,className:`flex-1 py-2`,children:(0,Z.jsxs)(d.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:`easeOut`},className:`grid min-h-0 min-w-0 grid-cols-1 items-stretch gap-5 @2xl/main:grid-cols-2 @2xl/main:gap-4`,children:[(0,Z.jsx)(Xe,{}),(0,Z.jsx)(Qe,{}),(0,Z.jsx)(Ze,{}),(0,Z.jsx)(ut,{})]},`operate`)})]})]})}export{Le as n,dt as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./events-przfMV9x.js";export{e as EventsPage};