okengine 0.2.1 → 0.2.3

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 (59) hide show
  1. package/README.md +8 -8
  2. package/package.json +2 -1
  3. package/src/cli/dev-app-runner.ts +6 -2
  4. package/src/cli/dev.ts +84 -15
  5. package/src/cli/doctor.ts +3 -18
  6. package/src/cli/index.ts +4 -1
  7. package/src/cli/json-out.test.ts +1 -1
  8. package/src/cli/load-config.images.test.ts +75 -0
  9. package/src/cli/load-config.ts +67 -2
  10. package/src/cli/ports.test.ts +51 -0
  11. package/src/cli/ports.ts +81 -0
  12. package/src/cli/registry.help.test.ts +18 -0
  13. package/src/cli/registry.ts +0 -4
  14. package/src/cli/safe-defaults.test.ts +3 -3
  15. package/src/console/server/app.ts +2 -1
  16. package/src/console/server/claim.test.ts +7 -4
  17. package/src/console/server/claim.ts +2 -7
  18. package/src/console/server/flows.ts +1 -0
  19. package/src/console/server/index.ts +5 -0
  20. package/src/console/server/operator-db.test.ts +75 -0
  21. package/src/console/server/operator-db.ts +324 -0
  22. package/src/console/server/serve.ts +39 -0
  23. package/src/console/server/state.ts +13 -1
  24. package/src/console/ui/dist/assets/index-Bnf_3Hei.js +10 -0
  25. package/src/console/ui/dist/assets/panel-access-Dd37LU2c.js +64 -0
  26. package/src/console/ui/dist/assets/panel-ai-CC7LR6-J.js +1 -0
  27. package/src/console/ui/dist/assets/panel-architecture-B5b3iKCz.js +1 -0
  28. package/src/console/ui/dist/assets/panel-channels-CeNjTKXp.js +1 -0
  29. package/src/console/ui/dist/assets/panel-clock-DgFTLoHV.js +1 -0
  30. package/src/console/ui/dist/assets/panel-diff-DxehccqB.js +1 -0
  31. package/src/console/ui/dist/assets/panel-flows-BtrVn-Eg.js +45 -0
  32. package/src/console/ui/dist/assets/panel-gates-Z9MKRGdH.js +1 -0
  33. package/src/console/ui/dist/assets/panel-overview-Dt_AeXgd.js +1 -0
  34. package/src/console/ui/dist/assets/panel-plugins-DWd0TowH.js +1 -0
  35. package/src/console/ui/dist/assets/panel-runs-DGstFHeq.js +1 -0
  36. package/src/console/ui/dist/assets/panel-signals-DzEa2Fnt.js +1 -0
  37. package/src/console/ui/dist/assets/panel-store-BJkbNgxx.js +1 -0
  38. package/src/console/ui/dist/assets/panel-traces-BaRVO3gM.js +1 -0
  39. package/src/console/ui/dist/assets/panel-vault-BbfWdox0.js +1 -0
  40. package/src/console/ui/dist/assets/rolldown-runtime-CNC7AqOf.js +1 -0
  41. package/src/console/ui/dist/assets/style-C8MxEWPd.css +3 -0
  42. package/src/console/ui/dist/favicon.svg +7 -0
  43. package/src/console/ui/dist/index.html +15 -0
  44. package/src/console/ui/shell/App.tsx +34 -2
  45. package/src/console/ui/shell/components/oke-logo.tsx +40 -0
  46. package/src/console/ui/shell/index.html +1 -0
  47. package/src/console/ui/shell/layout/Shell.tsx +2 -3
  48. package/src/console/ui/shell/panels/overview/OverviewPanel.tsx +8 -0
  49. package/src/console/ui/shell/public/favicon.svg +7 -0
  50. package/src/console/ui/shell/setup/Wizard.tsx +5 -2
  51. package/src/docker/derive.ts +3 -1
  52. package/src/docker/dockerfile.integration.test.ts +1 -1
  53. package/src/docker/stack.integration.test.ts +1 -1
  54. package/src/docs-origin.ts +19 -0
  55. package/src/kernel/errors.registry.test.ts +4 -2
  56. package/src/kernel/errors.ts +3 -1
  57. package/src/kernel/fx.test.ts +2 -2
  58. package/src/term.test.ts +51 -0
  59. package/src/term.ts +158 -0
@@ -0,0 +1,64 @@
1
+ import{a as e,r as t,t as n}from"./rolldown-runtime-CNC7AqOf.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 h(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==_(o,t.options))return!1}else if(!y(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 g(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(v(t.options.mutationKey)!==v(a))return!1}else if(!y(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function _(e,t){return(t?.queryKeyHashFn||v)(e)}function v(e){return JSON.stringify(e,(e,t)=>w(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function y(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<t.length;n++)if(!y(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!y(e[r],t[r]))return!1;return!0}return!1}var b=Object.prototype.hasOwnProperty;function x(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=C(e)&&C(t);if(!r&&!(w(e)&&w(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:b.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=x(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function S(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 C(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function w(e){if(!T(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!T(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function T(e){return Object.prototype.toString.call(e)===`[object Object]`}function E(e){return new Promise(t=>{o.setTimeout(t,e)})}function D(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:x(e,t)}function O(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function k(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var A=Symbol();function ee(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===A?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function j(e,t){return typeof e==`function`?e(...t):!!e}function M(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 N=(()=>{let e=()=>c;return{isServer(){return e()},setIsServer(t){e=t}}})();function te(){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}var P=s;function ne(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=P,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 F=ne(),re=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 ie(e){return Math.min(1e3*2**e,3e4)}function ae(e){return(e??`online`)!==`online`||re.isOnline()}var oe=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function se(e){let t=!1,n=0,r,a=te(),o=()=>a.status!==`pending`,s=t=>{if(!o()){let n=new oe(t);p(n),e.onCancel?.(n)}},c=()=>{t=!0},l=()=>{t=!1},u=()=>i.isFocused()&&(e.networkMode===`always`||re.isOnline())&&e.canRun(),d=()=>ae(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?.()}),h=()=>{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??(N.isServer()?0:3),a=e.retryDelay??ie,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),E(s).then(()=>u()?void 0:m()).then(()=>{t?p(r):h()})})};return{promise:a,status:()=>a.status,cancel:s,continue:()=>(r?.(),a),cancelRetry:c,continueRetry:l,canStart:d,start:()=>(d()?h():m().then(h),a)}}var ce=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??(N.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(o.clearTimeout(this.#e),this.#e=void 0)}};function le(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=>{M(e,()=>t.signal,()=>n=!0)},u=ee(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?k:O;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?de:ue,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:ue(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 ue(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 de(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var fe=class extends ce{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=he(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=he(this.options);e.data!==void 0&&(this.setState(me(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=D(this.state.data,e,this.options);return this.#l({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#l({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(l).catch(l):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}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===A||!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`)}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.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.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.#a&&(this.#s||this.#c()?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#l({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.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.#s=!0,n.signal)})},i=()=>{let e=ee(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!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.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?le(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#l({type:`fetch`,meta:a.fetchOptions?.meta}),this.#a=se({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof oe&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#l({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#l({type:`pause`})},onContinue:()=>{this.#l({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#a.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof oe){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#l({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#l(e){let t=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,...pe(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...me(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=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=t(this.state),F.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function pe(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:ae(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function me(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`}}var ge=class extends r{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=te(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),ve(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return ye(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return ye(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof m(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!S(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&be(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||m(this.options.enabled,this.#t)!==m(t.enabled,this.#t)||p(this.options.staleTime,this.#t)!==p(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||m(this.options.enabled,this.#t)!==m(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Se(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(l)),t}#g(){this.#b();let e=p(this.options.staleTime,this.#t);if(N.isServer()||this.#r.isStale||!d(e))return;let t=f(this.#r.dataUpdatedAt,e)+1;this.#d=o.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(N.isServer()||m(this.options.enabled,this.#t)===!1||!d(this.#p)||this.#p===0)&&(this.#f=o.setInterval(()=>{(this.options.refetchIntervalInBackground||i.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(o.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(o.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&ve(e,t),o=i&&be(e,n,t,r);(a||o)&&(l={...l,...pe(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:h}=l;d=l.data;let g=!1;if(t.placeholderData!==void 0&&d===void 0&&h===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,g=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(h=`success`,d=D(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!g)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=D(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),h=`error`);let _=l.fetchStatus===`fetching`,v=h===`pending`,y=h===`error`,b=v&&_,x=d!==void 0,S={status:h,fetchStatus:l.fetchStatus,isPending:v,isSuccess:h===`success`,isError:y,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:_,isRefetching:_&&!v,isLoadingError:y&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:y&&x,isStale:xe(e,t),refetch:this.refetch,promise:this.#o,isEnabled:m(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=S.data!==void 0,r=S.status===`error`&&!t,i=e=>{r?e.reject(S.error):t&&e.resolve(S.data)},a=()=>{let e=this.#o=S.promise=te();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||S.data!==o.value)&&a();break;case`rejected`:(!r||S.error!==o.reason)&&a();break}}return S}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!S(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){F.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function _e(e,t){return m(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&m(t.retryOnMount,e)===!1)}function ve(e,t){return _e(e,t)||e.state.data!==void 0&&ye(e,t,t.refetchOnMount)}function ye(e,t,n){if(m(t.enabled,e)!==!1&&p(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&xe(e,t)}return!1}function be(e,t,n,r){return(e!==t||m(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&xe(e,n)}function xe(e,t){return m(t.enabled,e)!==!1&&e.isStaleByTime(p(t.staleTime,e))}function Se(e,t){return!S(e.getCurrentResult(),t)}var Ce=class extends ce{#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||we(),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=se({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){let t=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=t(this.state),F.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function we(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Te=class extends r{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),S(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&v(t.mutationKey)!==v(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??we();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){F.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},Ee=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function ee(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function j(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function M(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,M(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ee(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),M(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ee(a,u),c+=M(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ee(a,u++),c+=M(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return M(j(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function N(e,t,n){if(e==null)return e;var r=[],i=0;return M(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function te(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var P=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},ne={map:N,forEach:function(e,t,n){N(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return N(e,function(){t++}),t},toArray:function(e){return N(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ne,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:te}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,P)}catch(e){P(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),De=n(((e,t)=>{t.exports=Ee()})),Oe=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),ke=n(((e,t)=>{t.exports=Oe()})),I=e(De(),1),L=ke(),Ae=I.createContext(void 0),je=e=>{let t=I.useContext(Ae);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Me=({client:e,children:t})=>(I.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,L.jsx)(Ae.Provider,{value:e,children:t})),Ne=I.createContext(!1),Pe=()=>I.useContext(Ne);Ne.Provider;function Fe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ie=I.createContext(Fe()),Le=()=>I.useContext(Ie),Re=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?j(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ze=e=>{I.useEffect(()=>{e.clearReset()},[e])},Be=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||j(n,[e.error,r])),Ve=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},He=(e,t)=>e.isLoading&&e.isFetching&&!t,Ue=(e,t)=>e?.suspense&&t.isPending,We=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Ge(e,t,n){let r=Pe(),i=Le(),a=je(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,Ve(o),Re(o,i,s),ze(i);let u=!a.getQueryCache().get(o.queryHash),[d]=I.useState(()=>new t(a,o)),f=d.getOptimisticResult(o),p=!r&&c;if(I.useSyncExternalStore(I.useCallback(e=>{let t=p?d.subscribe(F.batchCalls(e)):l;return d.updateResult(),t},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),I.useEffect(()=>{d.setOptions(o)},[o,d]),Ue(o,f))throw We(o,d,i);if(Be({result:f,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw f.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,f),o.experimental_prefetchInRender&&!N.isServer()&&He(f,r)&&(u?We(o,d,i):s?.promise)?.catch(l).finally(()=>{d.updateResult()}),o.notifyOnChangeProps?f:d.trackResult(f)}function Ke(e,t){return Ge(e,ge,t)}function qe(e,t){let n=je(t),[r]=I.useState(()=>new Te(n,e));I.useEffect(()=>{r.setOptions(e)},[r,e]);let i=I.useSyncExternalStore(I.useCallback(e=>r.subscribe(F.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=I.useCallback((e,t)=>{r.mutate(e,t).catch(l)},[r]);if(i.error&&j(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var Je=I.use,Ye=typeof window<`u`?I.useLayoutEffect:I.useEffect;function Xe(e){let t=I.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function Ze(e,t,n={},r={}){I.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function Qe(e){let t=I.useRef(null);return I.useImperativeHandle(e,()=>t.current,[]),t}function $e(e){return e[e.length-1]}function et(e){return typeof e==`function`}function tt(e,t){return et(e)?e(t):e}var nt=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;function it(e){for(let t in e)if(nt.call(e,t))return!0;return!1}var at=()=>Object.create(null),ot=(e,t)=>st(e,t,at);function st(e,t,n=()=>({}),r=0){if(e===t)return e;if(r>500)return t;let i=t,a=dt(e)&&dt(i);if(!a&&!(lt(e)&&lt(i)))return i;let o=a?e:ct(e);if(!o)return i;let s=a?i:ct(i);if(!s)return i;let c=o.length,l=s.length,u=a?Array(l):n(),d=0;for(let t=0;t<l;t++){let o=a?t:s[t],l=e[o],f=i[o];if(l===f){u[o]=l,(a?t<c:nt.call(e,o))&&d++;continue}if(l===null||f===null||typeof l!=`object`||typeof f!=`object`){u[o]=f;continue}let p=st(l,f,n,r+1);u[o]=p,p===l&&d++}return c===l&&d===c?e:u}function ct(e){let t=Object.getOwnPropertyNames(e);for(let n of t)if(!rt.call(e,n))return!1;let n=Object.getOwnPropertySymbols(e);if(n.length===0)return t;let r=t;for(let t of n){if(!rt.call(e,t))return!1;r.push(t)}return r}function lt(e){if(!ut(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ut(n)||!n.hasOwnProperty(`isPrototypeOf`))}function ut(e){return Object.prototype.toString.call(e)===`[object Object]`}function dt(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ft(e,t,n){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0,i=e.length;r<i;r++)if(!ft(e[r],t[r],n))return!1;return!0}if(lt(e)&&lt(t)){let r=n?.ignoreUndefined??!0;if(n?.partial){for(let i in t)if((!r||t[i]!==void 0)&&!ft(e[i],t[i],n))return!1;return!0}let i=0;if(!r)i=Object.keys(e).length;else for(let t in e)e[t]!==void 0&&i++;let a=0;for(let o in t)if((!r||t[o]!==void 0)&&(a++,a>i||!ft(e[o],t[o],n)))return!1;return i===a}return!1}function pt(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});return r.status=`pending`,r.resolve=n=>{r.status=`resolved`,r.value=n,t(n),e?.(n)},r.reject=e=>{r.status=`rejected`,n(e)},r}function mt(e){return typeof e?.message==`string`?e.message.startsWith(`Failed to fetch dynamically imported module`)||e.message.startsWith(`error loading dynamically imported module`)||e.message.startsWith(`Importing a module script failed`):!1}function ht(e){return!!(e&&typeof e==`object`&&typeof e.then==`function`)}var gt=/[\x00-\x1f\x7f"<>`{}]/g;function _t(e){return e.replace(gt,e=>`%`+e.charCodeAt(0).toString(16).toUpperCase().padStart(2,`0`))}function vt(e){let t;try{t=decodeURI(e)}catch{t=e.replaceAll(/%[0-9A-F]{2}/gi,e=>{try{return decodeURI(e)}catch{return e}})}return _t(t)}var yt=[`http:`,`https:`,`mailto:`,`tel:`];function bt(e,t){if(!e)return!1;try{let n=new URL(e);return!t.has(n.protocol)}catch{return!1}}function xt(e){if(!e||!/[%\\\x00-\x1f\x7f]/.test(e)&&!e.startsWith(`//`))return{path:e,handledProtocolRelativeURL:!1};let t=/%25|%5C/gi,n=0,r=``,i;for(;(i=t.exec(e))!==null;)r+=vt(e.slice(n,i.index))+i[0],n=t.lastIndex;r+=vt(n?e.slice(n):e);let a=!1;return r.startsWith(`//`)&&(a=!0,r=`/`+r.replace(/^\/+/,``)),{path:r,handledProtocolRelativeURL:a}}function St(e){return/\s|[^\u0000-\u007F]/.test(e)?e.replace(/\s|[^\u0000-\u007F]/gu,encodeURIComponent):e}function Ct(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function wt(){throw Error(`Invariant failed`)}var Tt=I.createContext(null);function Et(e){return I.useContext(Tt)}var Dt=I.createContext(void 0),Ot=I.createContext(void 0),kt=n((e=>{var t=De();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),At=n(((e,t)=>{t.exports=kt()})),jt=n((e=>{var t=De(),n=At();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),Mt=n(((e,t)=>{t.exports=jt()}))();function Nt(e,t){return e===t}function Pt(e,t,n=Nt){let r=(0,I.useCallback)(t=>{if(!e)return()=>{};let{unsubscribe:n}=e.subscribe(t);return n},[e]),i=(0,I.useCallback)(()=>e?.get(),[e]);return(0,Mt.useSyncExternalStoreWithSelector)(r,i,i,t,n)}var Ft={get(){},subscribe(){return{unsubscribe(){}}}};function It(e,t){let n=I.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=st(n.current,i):i}}function Lt(e){let t=Et(),n=I.useContext(e.from?Ot:Dt),r=e.from?t.stores.getRouteMatchStore(e.from):t.stores.matchStores.get(n),i=It(e,t),a=Pt(r??Ft,e=>e?i(e):Ft);if(a!==Ft)return a;(e.shouldThrow??!0)&&wt()}function Rt(e){return Lt({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function zt(e){let t=Et();return I.useCallback(n=>t.navigate({...n,from:n.from??e?.from}),[e?.from,t])}var Bt;function R(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Vt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Ht=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Bt=globalThis).__zod_globalConfig??(Bt.__zod_globalConfig={});var Ut=globalThis.__zod_globalConfig;function Wt(e){return e&&Object.assign(Ut,e),Ut}function Gt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Kt(e,t){return typeof t==`bigint`?t.toString():t}function qt(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Jt(e){return e==null}function Yt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Xt(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var Zt=Symbol(`evaluating`);function z(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Zt)return r===void 0&&(r=Zt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Qt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function B(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function $t(e){return JSON.stringify(e)}function en(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var tn=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var rn=qt(()=>{if(Ut.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function an(e){if(nn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(nn(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function on(e){return an(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var sn=new Set([`string`,`number`,`symbol`]);function cn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function V(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function H(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ln(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var un={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function dn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return V(e,B(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Qt(this,`shape`,e),e},checks:[]}))}function fn(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return V(e,B(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Qt(this,`shape`,r),r},checks:[]}))}function pn(e,t){if(!an(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return V(e,B(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Qt(this,`shape`,n),n}}))}function mn(e,t){if(!an(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return V(e,B(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Qt(this,`shape`,n),n}}))}function hn(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return V(e,B(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Qt(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function gn(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return V(t,B(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Qt(this,`shape`,i),i},checks:[]}))}function _n(e,t,n){return V(t,B(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Qt(this,`shape`,i),i}}))}function vn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function yn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function bn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function xn(e){return typeof e==`string`?e:e?.message}function Sn(e,t,n){let r=e.message?e.message:xn(e.inst?._zod.def?.error?.(e))??xn(t?.error?.(e))??xn(n.customError?.(e))??xn(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function Cn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function wn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Tn=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Kt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},En=R(`$ZodError`,Tn),Dn=R(`$ZodError`,Tn,{Parent:Error});function On(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function kn(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var An=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Vt;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Sn(e,a,Wt())));throw tn(t,i?.callee),t}return o.value},jn=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Sn(e,a,Wt())));throw tn(t,i?.callee),t}return o.value},Mn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Vt;return a.issues.length?{success:!1,error:new(e??En)(a.issues.map(e=>Sn(e,i,Wt())))}:{success:!0,data:a.value}},Nn=Mn(Dn),Pn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Sn(e,i,Wt())))}:{success:!0,data:a.value}},Fn=Pn(Dn),In=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return An(e)(t,n,i)},Ln=e=>(t,n,r)=>An(e)(t,n,r),Rn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return jn(e)(t,n,i)},zn=e=>async(t,n,r)=>jn(e)(t,n,r),Bn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Mn(e)(t,n,i)},Vn=e=>(t,n,r)=>Mn(e)(t,n,r),Hn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Pn(e)(t,n,i)},Un=e=>async(t,n,r)=>Pn(e)(t,n,r),Wn=/^[cC][0-9a-z]{6,}$/,Gn=/^[0-9a-z]+$/,Kn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,qn=/^[0-9a-vA-V]{20}$/,Jn=/^[A-Za-z0-9]{27}$/,Yn=/^[a-zA-Z0-9_-]{21}$/,Xn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Zn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Qn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,$n=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,er=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function tr(){return new RegExp(er,`u`)}var nr=/^(?:(?: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])$/,rr=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,ir=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,ar=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,or=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,sr=/^[A-Za-z0-9_-]*$/,cr=/^https?$/,lr=/^\+[1-9]\d{6,14}$/,ur=`(?:(?:\\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])))`,dr=RegExp(`^${ur}$`);function fr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function pr(e){return RegExp(`^${fr(e)}$`)}function mr(e){let t=fr({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${ur}T(?:${r})$`)}var hr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},gr=/^-?\d+$/,_r=/^-?\d+(?:\.\d+)?$/,vr=/^(?:true|false)$/i,yr=/^[^A-Z]*$/,br=/^[^a-z]*$/,U=R(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),xr={number:`number`,bigint:`bigint`,object:`date`},Sr=R(`$ZodCheckLessThan`,(e,t)=>{U.init(e,t);let n=xr[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Cr=R(`$ZodCheckGreaterThan`,(e,t)=>{U.init(e,t);let n=xr[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wr=R(`$ZodCheckMultipleOf`,(e,t)=>{U.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Xt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Tr=R(`$ZodCheckNumberFormat`,(e,t)=>{U.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=un[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=gr)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Er=R(`$ZodCheckMaxLength`,(e,t)=>{var n;U.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Jt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Cn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Dr=R(`$ZodCheckMinLength`,(e,t)=>{var n;U.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Jt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Cn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Or=R(`$ZodCheckLengthEquals`,(e,t)=>{var n;U.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Jt(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Cn(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),kr=R(`$ZodCheckStringFormat`,(e,t)=>{var n,r;U.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ar=R(`$ZodCheckRegex`,(e,t)=>{kr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),jr=R(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=yr,kr.init(e,t)}),Mr=R(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=br,kr.init(e,t)}),Nr=R(`$ZodCheckIncludes`,(e,t)=>{U.init(e,t);let n=cn(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Pr=R(`$ZodCheckStartsWith`,(e,t)=>{U.init(e,t);let n=RegExp(`^${cn(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Fr=R(`$ZodCheckEndsWith`,(e,t)=>{U.init(e,t);let n=RegExp(`.*${cn(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ir=R(`$ZodCheckOverwrite`,(e,t)=>{U.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Lr=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
2
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
3
+ `))}},Rr={major:4,minor:4,patch:3},W=R(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Rr;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=vn(e),i;for(let a of t){if(a._zod.def.when){if(yn(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Vt;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=vn(e,t))});else{if(e.issues.length===t)continue;r||=vn(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(vn(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Vt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Vt;return o.then(e=>t(e,r,a))}return t(o,r,a)}}z(e,`~standard`,()=>({validate:t=>{try{let n=Nn(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Fn(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),zr=R(`$ZodString`,(e,t)=>{W.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??hr(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),G=R(`$ZodStringFormat`,(e,t)=>{kr.init(e,t),zr.init(e,t)}),Br=R(`$ZodGUID`,(e,t)=>{t.pattern??=Zn,G.init(e,t)}),Vr=R(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Qn(e)}else t.pattern??=Qn();G.init(e,t)}),Hr=R(`$ZodEmail`,(e,t)=>{t.pattern??=$n,G.init(e,t)}),Ur=R(`$ZodURL`,(e,t)=>{G.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===cr.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Wr=R(`$ZodEmoji`,(e,t)=>{t.pattern??=tr(),G.init(e,t)}),Gr=R(`$ZodNanoID`,(e,t)=>{t.pattern??=Yn,G.init(e,t)}),Kr=R(`$ZodCUID`,(e,t)=>{t.pattern??=Wn,G.init(e,t)}),qr=R(`$ZodCUID2`,(e,t)=>{t.pattern??=Gn,G.init(e,t)}),Jr=R(`$ZodULID`,(e,t)=>{t.pattern??=Kn,G.init(e,t)}),Yr=R(`$ZodXID`,(e,t)=>{t.pattern??=qn,G.init(e,t)}),Xr=R(`$ZodKSUID`,(e,t)=>{t.pattern??=Jn,G.init(e,t)}),Zr=R(`$ZodISODateTime`,(e,t)=>{t.pattern??=mr(t),G.init(e,t)}),Qr=R(`$ZodISODate`,(e,t)=>{t.pattern??=dr,G.init(e,t)}),$r=R(`$ZodISOTime`,(e,t)=>{t.pattern??=pr(t),G.init(e,t)}),ei=R(`$ZodISODuration`,(e,t)=>{t.pattern??=Xn,G.init(e,t)}),ti=R(`$ZodIPv4`,(e,t)=>{t.pattern??=nr,G.init(e,t),e._zod.bag.format=`ipv4`}),ni=R(`$ZodIPv6`,(e,t)=>{t.pattern??=rr,G.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),ri=R(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ir,G.init(e,t)}),ii=R(`$ZodCIDRv6`,(e,t)=>{t.pattern??=ar,G.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function ai(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var oi=R(`$ZodBase64`,(e,t)=>{t.pattern??=or,G.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{ai(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function si(e){if(!sr.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ai(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var ci=R(`$ZodBase64URL`,(e,t)=>{t.pattern??=sr,G.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{si(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),li=R(`$ZodE164`,(e,t)=>{t.pattern??=lr,G.init(e,t)});function ui(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var di=R(`$ZodJWT`,(e,t)=>{G.init(e,t),e._zod.check=n=>{ui(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),fi=R(`$ZodNumber`,(e,t)=>{W.init(e,t),e._zod.pattern=e._zod.bag.pattern??_r,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),pi=R(`$ZodNumberFormat`,(e,t)=>{Tr.init(e,t),fi.init(e,t)}),mi=R(`$ZodBoolean`,(e,t)=>{W.init(e,t),e._zod.pattern=vr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),hi=R(`$ZodUnknown`,(e,t)=>{W.init(e,t),e._zod.parse=e=>e}),gi=R(`$ZodNever`,(e,t)=>{W.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function _i(e,t,n){e.issues.length&&t.issues.push(...bn(n,e.issues)),t.value[n]=e.value}var vi=R(`$ZodArray`,(e,t)=>{W.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>_i(t,n,e))):_i(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function yi(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...bn(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function bi(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=ln(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function xi(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>yi(e,n,i,t,u,d))):yi(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Si=R(`$ZodObject`,(e,t)=>{if(W.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=qt(()=>bi(t));z(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=nn,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>yi(n,t,e,s,r,i))):yi(a,t,e,s,r,i)}return i?xi(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Ci=R(`$ZodObjectJIT`,(e,t)=>{Si.init(e,t);let n=e._zod.parse,r=qt(()=>bi(t)),i=e=>{let t=new Lr([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=$t(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=$t(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
4
+ if (${n}.issues.length) {
5
+ if (${o} in input) {
6
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
7
+ ...iss,
8
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
9
+ })));
10
+ }
11
+ }
12
+
13
+ if (${n}.value === undefined) {
14
+ if (${o} in input) {
15
+ newResult[${o}] = undefined;
16
+ }
17
+ } else {
18
+ newResult[${o}] = ${n}.value;
19
+ }
20
+
21
+ `):c?t.write(`
22
+ if (${n}.issues.length) {
23
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
24
+ ...iss,
25
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
26
+ })));
27
+ }
28
+
29
+ if (${n}.value === undefined) {
30
+ if (${o} in input) {
31
+ newResult[${o}] = undefined;
32
+ }
33
+ } else {
34
+ newResult[${o}] = ${n}.value;
35
+ }
36
+
37
+ `):t.write(`
38
+ const ${n}_present = ${o} in input;
39
+ if (${n}.issues.length) {
40
+ payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
41
+ ...iss,
42
+ path: iss.path ? [${o}, ...iss.path] : [${o}]
43
+ })));
44
+ }
45
+ if (!${n}_present && !${n}.issues.length) {
46
+ payload.issues.push({
47
+ code: "invalid_type",
48
+ expected: "nonoptional",
49
+ input: undefined,
50
+ path: [${o}]
51
+ });
52
+ }
53
+
54
+ if (${n}_present) {
55
+ if (${n}.value === undefined) {
56
+ newResult[${o}] = undefined;
57
+ } else {
58
+ newResult[${o}] = ${n}.value;
59
+ }
60
+ }
61
+
62
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=nn,s=!Ut.jitless,c=s&&rn.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?xi([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function wi(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!vn(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Sn(e,r,Wt())))}),t)}var Ti=R(`$ZodUnion`,(e,t)=>{W.init(e,t),z(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),z(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),z(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),z(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Yt(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>wi(t,r,e,i)):wi(o,r,e,i)}}),Ei=R(`$ZodIntersection`,(e,t)=>{W.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Oi(e,t,n)):Oi(e,i,a)}});function Di(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(an(e)&&an(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Di(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Di(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Oi(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),vn(e))return e;let o=Di(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var ki=R(`$ZodEnum`,(e,t)=>{W.init(e,t);let n=Gt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>sn.has(typeof e)).map(e=>typeof e==`string`?cn(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ai=R(`$ZodLiteral`,(e,t)=>{if(W.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?cn(e):e?cn(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ji=R(`$ZodTransform`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ht(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Vt;return n.value=i,n.fallback=!0,n}});function Mi(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Ni=R(`$ZodOptional`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,z(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),z(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Yt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>Mi(e,r)):Mi(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Pi=R(`$ZodExactOptional`,(e,t)=>{Ni.init(e,t),z(e._zod,`values`,()=>t.innerType._zod.values),z(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Fi=R(`$ZodNullable`,(e,t)=>{W.init(e,t),z(e._zod,`optin`,()=>t.innerType._zod.optin),z(e._zod,`optout`,()=>t.innerType._zod.optout),z(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Yt(e.source)}|null)$`):void 0}),z(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ii=R(`$ZodDefault`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,z(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Li(e,t)):Li(r,t)}});function Li(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ri=R(`$ZodPrefault`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,z(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),zi=R(`$ZodNonOptional`,(e,t)=>{W.init(e,t),z(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Bi(t,e)):Bi(i,e)}});function Bi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Vi=R(`$ZodCatch`,(e,t)=>{W.init(e,t),e._zod.optin=`optional`,z(e._zod,`optout`,()=>t.innerType._zod.optout),z(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Sn(e,n,Wt()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Sn(e,n,Wt()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Hi=R(`$ZodPipe`,(e,t)=>{W.init(e,t),z(e._zod,`values`,()=>t.in._zod.values),z(e._zod,`optin`,()=>t.in._zod.optin),z(e._zod,`optout`,()=>t.out._zod.optout),z(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ui(e,t.in,n)):Ui(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ui(e,t.out,n)):Ui(r,t.out,n)}});function Ui(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Wi=R(`$ZodReadonly`,(e,t)=>{W.init(e,t),z(e._zod,`propValues`,()=>t.innerType._zod.propValues),z(e._zod,`values`,()=>t.innerType._zod.values),z(e._zod,`optin`,()=>t.innerType?._zod?.optin),z(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Gi):Gi(r)}});function Gi(e){return e.value=Object.freeze(e.value),e}var Ki=R(`$ZodCustom`,(e,t)=>{U.init(e,t),W.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>qi(t,n,r,e));qi(i,n,r,e)}});function qi(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(wn(e))}}var Ji,Yi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Xi(){return new Yi}(Ji=globalThis).__zod_globalRegistry??(Ji.__zod_globalRegistry=Xi());var Zi=globalThis.__zod_globalRegistry;function Qi(e,t){return new e({type:`string`,...H(t)})}function $i(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...H(t)})}function ea(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...H(t)})}function ta(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...H(t)})}function na(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...H(t)})}function ra(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...H(t)})}function ia(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...H(t)})}function aa(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...H(t)})}function oa(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...H(t)})}function sa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...H(t)})}function ca(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...H(t)})}function la(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...H(t)})}function ua(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...H(t)})}function da(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...H(t)})}function fa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...H(t)})}function pa(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...H(t)})}function ma(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...H(t)})}function ha(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...H(t)})}function ga(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...H(t)})}function _a(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...H(t)})}function va(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...H(t)})}function ya(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...H(t)})}function ba(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...H(t)})}function xa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...H(t)})}function Sa(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...H(t)})}function Ca(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...H(t)})}function wa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...H(t)})}function Ta(e,t){return new e({type:`number`,coerce:!0,checks:[],...H(t)})}function Ea(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...H(t)})}function Da(e,t){return new e({type:`boolean`,...H(t)})}function Oa(e){return new e({type:`unknown`})}function ka(e,t){return new e({type:`never`,...H(t)})}function Aa(e,t){return new Sr({check:`less_than`,...H(t),value:e,inclusive:!1})}function ja(e,t){return new Sr({check:`less_than`,...H(t),value:e,inclusive:!0})}function Ma(e,t){return new Cr({check:`greater_than`,...H(t),value:e,inclusive:!1})}function Na(e,t){return new Cr({check:`greater_than`,...H(t),value:e,inclusive:!0})}function Pa(e,t){return new wr({check:`multiple_of`,...H(t),value:e})}function Fa(e,t){return new Er({check:`max_length`,...H(t),maximum:e})}function Ia(e,t){return new Dr({check:`min_length`,...H(t),minimum:e})}function La(e,t){return new Or({check:`length_equals`,...H(t),length:e})}function Ra(e,t){return new Ar({check:`string_format`,format:`regex`,...H(t),pattern:e})}function za(e){return new jr({check:`string_format`,format:`lowercase`,...H(e)})}function Ba(e){return new Mr({check:`string_format`,format:`uppercase`,...H(e)})}function Va(e,t){return new Nr({check:`string_format`,format:`includes`,...H(t),includes:e})}function Ha(e,t){return new Pr({check:`string_format`,format:`starts_with`,...H(t),prefix:e})}function Ua(e,t){return new Fr({check:`string_format`,format:`ends_with`,...H(t),suffix:e})}function Wa(e){return new Ir({check:`overwrite`,tx:e})}function Ga(e){return Wa(t=>t.normalize(e))}function Ka(){return Wa(e=>e.trim())}function qa(){return Wa(e=>e.toLowerCase())}function Ja(){return Wa(e=>e.toUpperCase())}function Ya(){return Wa(e=>en(e))}function Xa(e,t,n){return new e({type:`array`,element:t,...H(n)})}function Za(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...H(n)})}function Qa(e,t){let n=$a(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(wn(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(wn(r))}},e(t.value,t)),t);return n}function $a(e,t){let n=new U({check:`custom`,...H(t)});return n._zod.check=e,n}function eo(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Zi,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function K(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,K(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&q(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function to(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
63
+
64
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function no(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:io(t,`input`,e.processors),output:io(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function q(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return q(r.element,n);if(r.type===`set`)return q(r.valueType,n);if(r.type===`lazy`)return q(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return q(r.innerType,n);if(r.type===`intersection`)return q(r.left,n)||q(r.right,n);if(r.type===`record`||r.type===`map`)return q(r.keyType,n)||q(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:q(r.in,n)||q(r.out,n);if(r.type===`object`){for(let e in r.shape)if(q(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(q(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(q(e,n))return!0;return!!(r.rest&&q(r.rest,n))}return!1}var ro=(e,t={})=>n=>{let r=eo({...n,processors:t});return K(e,r),to(r,e),no(r,e)},io=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=eo({...i??{},target:a,io:t,processors:n});return K(e,o),to(o,e),no(o,e)},ao={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},oo=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ao[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},so=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},co=(e,t,n,r)=>{n.type=`boolean`},lo=(e,t,n,r)=>{n.not={}},uo=(e,t,n,r)=>{let i=e._zod.def,a=Gt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},fo=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},po=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},mo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ho=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=K(a.element,t,{...r,path:[...r.path,`items`]})},go=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=K(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=K(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},_o=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>K(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},vo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=K(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},yo=(e,t,n,r)=>{let i=e._zod.def,a=K(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},bo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},So=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Co=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},wo=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;K(o,t,r);let s=t.seen.get(e);s.ref=o},To=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Eo=(e,t,n,r)=>{let i=e._zod.def;K(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Do=R(`ZodISODateTime`,(e,t)=>{Zr.init(e,t),X.init(e,t)});function Oo(e){return xa(Do,e)}var ko=R(`ZodISODate`,(e,t)=>{Qr.init(e,t),X.init(e,t)});function Ao(e){return Sa(ko,e)}var jo=R(`ZodISOTime`,(e,t)=>{$r.init(e,t),X.init(e,t)});function Mo(e){return Ca(jo,e)}var No=R(`ZodISODuration`,(e,t)=>{ei.init(e,t),X.init(e,t)});function Po(e){return wa(No,e)}var J=R(`ZodError`,(e,t)=>{En.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>kn(e,t)},flatten:{value:t=>On(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Kt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Kt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Fo=An(J),Io=jn(J),Lo=Mn(J),Ro=Pn(J),zo=In(J),Bo=Ln(J),Vo=Rn(J),Ho=zn(J),Uo=Bn(J),Wo=Vn(J),Go=Hn(J),Ko=Un(J),qo=new WeakMap;function Jo(e,t,n){let r=Object.getPrototypeOf(e),i=qo.get(r);if(i||(i=new Set,qo.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Y=R(`ZodType`,(e,t)=>(W.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:io(e,`input`),output:io(e,`output`)}}),e.toJSONSchema=ro(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Fo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Lo(e,t,n),e.parseAsync=async(t,n)=>Io(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ro(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>zo(e,t,n),e.decode=(t,n)=>Bo(e,t,n),e.encodeAsync=async(t,n)=>Vo(e,t,n),e.decodeAsync=async(t,n)=>Ho(e,t,n),e.safeEncode=(t,n)=>Uo(e,t,n),e.safeDecode=(t,n)=>Wo(e,t,n),e.safeEncodeAsync=async(t,n)=>Go(e,t,n),e.safeDecodeAsync=async(t,n)=>Ko(e,t,n),Jo(e,`ZodType`,{check(...e){let t=this.def;return this.clone(B(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return V(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ac(e,t))},superRefine(e,t){return this.check(oc(e,t))},overwrite(e){return this.check(Wa(e))},optional(){return Vs(this)},exactOptional(){return Us(this)},nullable(){return Gs(this)},nullish(){return Vs(Gs(this))},nonoptional(e){return Zs(this,e)},array(){return Ds(this)},or(e){return js([this,e])},and(e){return Ns(this,e)},transform(e){return tc(this,zs(e))},default(e){return qs(this,e)},prefault(e){return Ys(this,e)},catch(e){return $s(this,e)},pipe(e){return tc(this,e)},readonly(){return rc(this)},describe(e){let t=this.clone();return Zi.add(t,{description:e}),t},meta(...e){if(e.length===0)return Zi.get(this);let t=this.clone();return Zi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Zi.get(e)?.description},configurable:!0}),e)),Yo=R(`_ZodString`,(e,t)=>{zr.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Jo(e,`_ZodString`,{regex(...e){return this.check(Ra(...e))},includes(...e){return this.check(Va(...e))},startsWith(...e){return this.check(Ha(...e))},endsWith(...e){return this.check(Ua(...e))},min(...e){return this.check(Ia(...e))},max(...e){return this.check(Fa(...e))},length(...e){return this.check(La(...e))},nonempty(...e){return this.check(Ia(1,...e))},lowercase(e){return this.check(za(e))},uppercase(e){return this.check(Ba(e))},trim(){return this.check(Ka())},normalize(...e){return this.check(Ga(...e))},toLowerCase(){return this.check(qa())},toUpperCase(){return this.check(Ja())},slugify(){return this.check(Ya())}})}),Xo=R(`ZodString`,(e,t)=>{zr.init(e,t),Yo.init(e,t),e.email=t=>e.check($i(Qo,t)),e.url=t=>e.check(aa(ts,t)),e.jwt=t=>e.check(ba(gs,t)),e.emoji=t=>e.check(oa(ns,t)),e.guid=t=>e.check(ea($o,t)),e.uuid=t=>e.check(ta(es,t)),e.uuidv4=t=>e.check(na(es,t)),e.uuidv6=t=>e.check(ra(es,t)),e.uuidv7=t=>e.check(ia(es,t)),e.nanoid=t=>e.check(sa(rs,t)),e.guid=t=>e.check(ea($o,t)),e.cuid=t=>e.check(ca(is,t)),e.cuid2=t=>e.check(la(as,t)),e.ulid=t=>e.check(ua(os,t)),e.base64=t=>e.check(_a(ps,t)),e.base64url=t=>e.check(va(ms,t)),e.xid=t=>e.check(da(ss,t)),e.ksuid=t=>e.check(fa(cs,t)),e.ipv4=t=>e.check(pa(ls,t)),e.ipv6=t=>e.check(ma(us,t)),e.cidrv4=t=>e.check(ha(ds,t)),e.cidrv6=t=>e.check(ga(fs,t)),e.e164=t=>e.check(ya(hs,t)),e.datetime=t=>e.check(Oo(t)),e.date=t=>e.check(Ao(t)),e.time=t=>e.check(Mo(t)),e.duration=t=>e.check(Po(t))});function Zo(e){return Qi(Xo,e)}var X=R(`ZodStringFormat`,(e,t)=>{G.init(e,t),Yo.init(e,t)}),Qo=R(`ZodEmail`,(e,t)=>{Hr.init(e,t),X.init(e,t)}),$o=R(`ZodGUID`,(e,t)=>{Br.init(e,t),X.init(e,t)}),es=R(`ZodUUID`,(e,t)=>{Vr.init(e,t),X.init(e,t)}),ts=R(`ZodURL`,(e,t)=>{Ur.init(e,t),X.init(e,t)}),ns=R(`ZodEmoji`,(e,t)=>{Wr.init(e,t),X.init(e,t)}),rs=R(`ZodNanoID`,(e,t)=>{Gr.init(e,t),X.init(e,t)}),is=R(`ZodCUID`,(e,t)=>{Kr.init(e,t),X.init(e,t)}),as=R(`ZodCUID2`,(e,t)=>{qr.init(e,t),X.init(e,t)}),os=R(`ZodULID`,(e,t)=>{Jr.init(e,t),X.init(e,t)}),ss=R(`ZodXID`,(e,t)=>{Yr.init(e,t),X.init(e,t)}),cs=R(`ZodKSUID`,(e,t)=>{Xr.init(e,t),X.init(e,t)}),ls=R(`ZodIPv4`,(e,t)=>{ti.init(e,t),X.init(e,t)}),us=R(`ZodIPv6`,(e,t)=>{ni.init(e,t),X.init(e,t)}),ds=R(`ZodCIDRv4`,(e,t)=>{ri.init(e,t),X.init(e,t)}),fs=R(`ZodCIDRv6`,(e,t)=>{ii.init(e,t),X.init(e,t)}),ps=R(`ZodBase64`,(e,t)=>{oi.init(e,t),X.init(e,t)}),ms=R(`ZodBase64URL`,(e,t)=>{ci.init(e,t),X.init(e,t)}),hs=R(`ZodE164`,(e,t)=>{li.init(e,t),X.init(e,t)}),gs=R(`ZodJWT`,(e,t)=>{di.init(e,t),X.init(e,t)}),_s=R(`ZodNumber`,(e,t)=>{fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>so(e,t,n,r),Jo(e,`ZodNumber`,{gt(e,t){return this.check(Ma(e,t))},gte(e,t){return this.check(Na(e,t))},min(e,t){return this.check(Na(e,t))},lt(e,t){return this.check(Aa(e,t))},lte(e,t){return this.check(ja(e,t))},max(e,t){return this.check(ja(e,t))},int(e){return this.check(ys(e))},safe(e){return this.check(ys(e))},positive(e){return this.check(Ma(0,e))},nonnegative(e){return this.check(Na(0,e))},negative(e){return this.check(Aa(0,e))},nonpositive(e){return this.check(ja(0,e))},multipleOf(e,t){return this.check(Pa(e,t))},step(e,t){return this.check(Pa(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),vs=R(`ZodNumberFormat`,(e,t)=>{pi.init(e,t),_s.init(e,t)});function ys(e){return Ea(vs,e)}var bs=R(`ZodBoolean`,(e,t)=>{mi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r)});function xs(e){return Da(bs,e)}var Ss=R(`ZodUnknown`,(e,t)=>{hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Cs(){return Oa(Ss)}var ws=R(`ZodNever`,(e,t)=>{gi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lo(e,t,n,r)});function Ts(e){return ka(ws,e)}var Es=R(`ZodArray`,(e,t)=>{vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r),e.element=t.element,Jo(e,`ZodArray`,{min(e,t){return this.check(Ia(e,t))},nonempty(e){return this.check(Ia(1,e))},max(e,t){return this.check(Fa(e,t))},length(e,t){return this.check(La(e,t))},unwrap(){return this.element}})});function Ds(e,t){return Xa(Es,e,t)}var Os=R(`ZodObject`,(e,t)=>{Ci.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>go(e,t,n,r),z(e,`shape`,()=>t.shape),Jo(e,`ZodObject`,{keyof(){return Fs(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Cs()})},loose(){return this.clone({...this._zod.def,catchall:Cs()})},strict(){return this.clone({...this._zod.def,catchall:Ts()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return pn(this,e)},safeExtend(e){return mn(this,e)},merge(e){return hn(this,e)},pick(e){return dn(this,e)},omit(e){return fn(this,e)},partial(...e){return gn(Bs,this,e[0])},required(...e){return _n(Xs,this,e[0])}})});function ks(e,t){return new Os({type:`object`,shape:e??{},...H(t)})}var As=R(`ZodUnion`,(e,t)=>{Ti.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r),e.options=t.options});function js(e,t){return new As({type:`union`,options:e,...H(t)})}var Ms=R(`ZodIntersection`,(e,t)=>{Ei.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r)});function Ns(e,t){return new Ms({type:`intersection`,left:e,right:t})}var Ps=R(`ZodEnum`,(e,t)=>{ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ps({...t,checks:[],...H(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ps({...t,checks:[],...H(r),entries:i})}});function Fs(e,t){return new Ps({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...H(t)})}var Is=R(`ZodLiteral`,(e,t)=>{Ai.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ls(e,t){return new Is({type:`literal`,values:Array.isArray(e)?e:[e],...H(t)})}var Rs=R(`ZodTransform`,(e,t)=>{ji.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ht(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(wn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(wn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function zs(e){return new Rs({type:`transform`,transform:e})}var Bs=R(`ZodOptional`,(e,t)=>{Ni.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Vs(e){return new Bs({type:`optional`,innerType:e})}var Hs=R(`ZodExactOptional`,(e,t)=>{Pi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Us(e){return new Hs({type:`optional`,innerType:e})}var Ws=R(`ZodNullable`,(e,t)=>{Fi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gs(e){return new Ws({type:`nullable`,innerType:e})}var Ks=R(`ZodDefault`,(e,t)=>{Ii.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function qs(e,t){return new Ks({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():on(t)}})}var Js=R(`ZodPrefault`,(e,t)=>{Ri.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ys(e,t){return new Js({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():on(t)}})}var Xs=R(`ZodNonOptional`,(e,t)=>{zi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zs(e,t){return new Xs({type:`nonoptional`,innerType:e,...H(t)})}var Qs=R(`ZodCatch`,(e,t)=>{Vi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $s(e,t){return new Qs({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var ec=R(`ZodPipe`,(e,t)=>{Hi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.in=t.in,e.out=t.out});function tc(e,t){return new ec({type:`pipe`,in:e,out:t})}var nc=R(`ZodReadonly`,(e,t)=>{Wi.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>To(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rc(e){return new nc({type:`readonly`,innerType:e})}var ic=R(`ZodCustom`,(e,t)=>{Ki.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r)});function ac(e,t={}){return Za(ic,e,t)}function oc(e,t){return Qa(e,t)}var sc=ks({q:Zo().optional(),plane:Fs([`operator`,`user`]).optional(),kind:Fs([`operator`,`user`,`role`,`key`,`invite`]).optional(),id:Zo().optional(),view:Fs([`detail`,`effective`,`create-key`,`grant-role`]).optional()});function cc(e){let t=sc.safeParse(e);return t.success?t.data:{}}function lc(e){let t={};return e.q&&(t.q=e.q),e.plane&&(t.plane=e.plane),e.kind&&(t.kind=e.kind),e.id&&(t.id=e.id),e.view&&(t.view=e.view),t}function uc(e,t,n,r){return{...e,plane:t,kind:n,id:r,view:`detail`}}function dc(e,t={}){let n=t.fetch??globalThis.fetch.bind(globalThis),r=t.retry?.retries??0,i=t.retry?.delay??50,a=t.retry?.backoff??2;return{async call(o,s){let c=!1,l=0,u=i;for(;;)try{let r=await fc(e,o,s,t,n);if(r.status===401&&t.auth?.refresh&&!c){c=!0,await t.auth.refresh();continue}return hc(r)}catch(e){if(!gc(e)||l>=r)return{data:null,error:{code:`TransportError`,data:{message:e instanceof Error?e.message:String(e)}}};await _c(u),u*=a,l+=1}}}}async function fc(e,t,n,r,i){let a=r.routes?.[t.replace(`/`,`.`)],{url:o,method:s,body:c}=a?mc(e,a.method,a.path,n):pc(e,t,n),l=new Headers,u=typeof r.headers==`function`?await r.headers():r.headers;if(Array.isArray(u))for(let[e,t]of u)l.set(e,t);else if(u)for(let[e,t]of Object.entries(u))l.set(e,t);c!==void 0&&!l.has(`content-type`)&&l.set(`content-type`,`application/json`);let d=r.auth?await r.auth.getToken():void 0;d&&!l.has(`authorization`)&&l.set(`authorization`,`Bearer ${d}`);let f=r.timeout===void 0?void 0:new AbortController,p=f&&r.timeout!==void 0?setTimeout(()=>f.abort(),r.timeout):void 0;try{let e=await i(o,{method:s,headers:l,body:c,signal:f?.signal});if(e.status>=500)throw Error(`HTTP ${e.status}`);return e}finally{p!==void 0&&clearTimeout(p)}}function pc(e,t,n){return{url:`${e}/_oke/${t}`,method:`POST`,body:n===void 0?void 0:JSON.stringify(n??{})}}function mc(e,t,n,r){let i=typeof r==`object`&&r?r:{},a=n,o=[],s={};for(let[e,t]of Object.entries(i)){let n=`:${e}`;a.includes(n)?a=a.replaceAll(n,encodeURIComponent(String(t))):s[e]=t}let c=t.toUpperCase(),l;if(c===`GET`||c===`HEAD`)for(let[e,t]of Object.entries(s))t!==void 0&&o.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(t))}`);else(Object.keys(s).length>0||n===a)&&(l=JSON.stringify(Object.keys(s).length>0?s:r??{}));let u=o.length?`?${o.join(`&`)}`:``;return{url:`${e}${a}${u}`,method:c,body:l}}async function hc(e){if(e.status===204)return{data:void 0,error:null};let t=await e.text();if(!t)return e.ok?{data:void 0,error:null}:{data:null,error:{code:`TransportError`,data:{message:`HTTP ${e.status}`,status:e.status}}};let n;try{n=JSON.parse(t)}catch{return{data:null,error:{code:`TransportError`,data:{message:`Invalid JSON (${e.status})`,status:e.status}}}}return typeof n==`object`&&n&&`data`in n&&`error`in n?n:e.ok?{data:n,error:null}:{data:null,error:{code:`TransportError`,data:{message:`HTTP ${e.status}`,status:e.status}}}}function gc(e){return!(!(e instanceof Error)||e.name===`AbortError`)}function _c(e){return new Promise(t=>setTimeout(t,e))}function vc(e,t,n){if(typeof e==`string`)return yc(e,t);let r=typeof t==`string`?t:``,i=typeof t==`string`?n:t;return yc(r,{...i,$routes:i?.$routes??e.$routes})}function yc(e,t={}){let n=e.replace(/\/+$/,``),r=t.routes??bc(t.$routes);return xc(dc(n,{...t,routes:r}),[])}function bc(e){if(!e)return;let t={};for(let[n,r]of Object.entries(e))if(!(!r||typeof r!=`object`))for(let[e,i]of Object.entries(r)){if(!i||typeof i!=`object`)continue;let r=`method`in i?i.method:void 0,a=`path`in i?i.path:void 0;typeof r==`string`&&typeof a==`string`&&(t[`${n}.${e}`]={method:r,path:a})}return Object.keys(t).length>0?t:void 0}function xc(e,t){return new Proxy(n=>{if(t.length<2)return Promise.resolve({data:null,error:{code:`TransportError`,data:{message:`Incomplete path: api.${t.join(`.`)||`?`}(…)`}}});let r=t[0],i=t.slice(1).join(`.`);return e.call(`${r}/${i}`,n)},{get(n,r,i){if(typeof r==`symbol`)return Reflect.get(n,r,i);if(r!==`then`)return xc(e,[...t,r])}})}var Sc=null;function Cc(e){Sc=e,e?sessionStorage.setItem(`oke_console_at`,e):sessionStorage.removeItem(`oke_console_at`)}function wc(){Sc=sessionStorage.getItem(`oke_console_at`)}var Z=vc(globalThis.location===void 0?`http://127.0.0.1:6533`:globalThis.location.origin,{headers:()=>Sc?{Authorization:`Bearer ${Sc}`}:{},routes:{"console.setupStatus":{method:`GET`,path:`/console/setup/status`},"console.setupClaim":{method:`POST`,path:`/console/setup/claim`},"console.sessionLogin":{method:`POST`,path:`/console/session/login`},"console.sessionMe":{method:`GET`,path:`/console/session/me`},"console.sessionLogout":{method:`POST`,path:`/console/session/logout`},"console.manifestGet":{method:`GET`,path:`/console/manifest`},"console.runsList":{method:`GET`,path:`/console/runs`},"console.actionPing":{method:`POST`,path:`/console/action/ping`},"console.structuralPropose":{method:`POST`,path:`/console/structural/propose`},"console.flowsIdentities":{method:`GET`,path:`/console/flows/identities`},"console.flowsInvoke":{method:`POST`,path:`/console/flows/invoke`},"console.tracesReplay":{method:`POST`,path:`/console/traces/replay`},"console.signalsList":{method:`GET`,path:`/console/signals`},"console.signalsReplay":{method:`POST`,path:`/console/signals/replay`},"console.signalsDryRunReplay":{method:`POST`,path:`/console/signals/dry-run-replay`},"console.signalsDiscard":{method:`POST`,path:`/console/signals/discard`},"console.storeList":{method:`GET`,path:`/console/store`},"console.storeQuery":{method:`POST`,path:`/console/store/query`},"console.storeReveal":{method:`POST`,path:`/console/store/reveal`},"console.storeEdit":{method:`POST`,path:`/console/store/edit`},"console.storeDelete":{method:`POST`,path:`/console/store/delete`},"console.storePurgeCache":{method:`POST`,path:`/console/store/purge-cache`},"console.storeSql":{method:`POST`,path:`/console/store/sql`},"console.storePreview":{method:`POST`,path:`/console/store/preview`},"console.vaultList":{method:`GET`,path:`/console/vault`},"console.vaultSet":{method:`POST`,path:`/console/vault/set`},"console.vaultRotate":{method:`POST`,path:`/console/vault/rotate`},"console.aiList":{method:`GET`,path:`/console/ai`},"console.clockList":{method:`GET`,path:`/console/clock`},"console.clockRunNow":{method:`POST`,path:`/console/clock/run-now`},"console.clockPause":{method:`POST`,path:`/console/clock/pause`},"console.clockEditSchedule":{method:`POST`,path:`/console/clock/edit-schedule`},"console.clockWakeEarly":{method:`POST`,path:`/console/clock/wake-early`},"console.channelsList":{method:`GET`,path:`/console/channels`},"console.channelPreview":{method:`POST`,path:`/console/channels/preview`},"console.channelVerifyAuth":{method:`POST`,path:`/console/channels/verify-auth`},"console.channelReveal":{method:`POST`,path:`/console/channels/reveal`},"console.channelSendTest":{method:`POST`,path:`/console/channels/send-test`},"console.gatesList":{method:`GET`,path:`/console/gates`},"console.gatesSimulate":{method:`POST`,path:`/console/gates/simulate`},"console.gatesPowers":{method:`POST`,path:`/console/gates/powers`},"console.accessList":{method:`GET`,path:`/console/access`},"console.accessEffective":{method:`POST`,path:`/console/access/effective`},"console.accessKeyBlast":{method:`POST`,path:`/console/access/key-blast`},"console.accessCreateKey":{method:`POST`,path:`/console/access/keys`},"console.accessRevokeKey":{method:`POST`,path:`/console/access/keys/revoke`},"console.accessRotateKey":{method:`POST`,path:`/console/access/keys/rotate`},"console.accessSetRoleGrants":{method:`POST`,path:`/console/access/roles/grants`},"console.diffList":{method:`GET`,path:`/console/diff`},"console.pluginsList":{method:`GET`,path:`/console/plugins`}}}),Tc={async setupStatus(){return Z.console.setupStatus({})},async setupClaim(e){return Z.console.setupClaim(e)},async sessionLogin(e){return Z.console.sessionLogin(e)},async sessionMe(){return Z.console.sessionMe({})},async actionPing(e){return Z.console.actionPing({note:e})},async runsList(){return Z.console.runsList({})},async manifestGet(){return Z.console.manifestGet({})},async flowsIdentities(){return Z.console.flowsIdentities({})},async flowsInvoke(e){return Z.console.flowsInvoke(e)},async tracesReplay(e){return Z.console.tracesReplay(e)},async signalsList(){return Z.console.signalsList({})},async signalsReplay(e){return Z.console.signalsReplay(e)},async signalsDryRunReplay(e){return Z.console.signalsDryRunReplay(e)},async signalsDiscard(e){return Z.console.signalsDiscard(e)},async storeList(){return Z.console.storeList({})},async storeQuery(e){return Z.console.storeQuery(e)},async storeReveal(e){return Z.console.storeReveal(e)},async storeEdit(e){return Z.console.storeEdit(e)},async storeDelete(e){return Z.console.storeDelete(e)},async storePurgeCache(e){return Z.console.storePurgeCache(e)},async storeSql(e){return Z.console.storeSql(e)},async storePreview(e){return Z.console.storePreview(e)},async vaultList(){return Z.console.vaultList({})},async vaultSet(e){return Z.console.vaultSet(e)},async vaultRotate(e){return Z.console.vaultRotate(e)},async aiList(){return Z.console.aiList({})},async clockList(){return Z.console.clockList({})},async clockRunNow(e){return Z.console.clockRunNow(e)},async clockPause(e){return Z.console.clockPause(e)},async clockEditSchedule(e){return Z.console.clockEditSchedule(e)},async clockWakeEarly(e){return Z.console.clockWakeEarly(e)},async channelsList(){return Z.console.channelsList({})},async channelPreview(e){return Z.console.channelPreview(e)},async channelVerifyAuth(e){return Z.console.channelVerifyAuth(e)},async channelReveal(e){return Z.console.channelReveal(e)},async channelSendTest(e){return Z.console.channelSendTest(e)},async gatesList(){return Z.console.gatesList({})},async gatesSimulate(e){return Z.console.gatesSimulate(e)},async gatesPowers(e){return Z.console.gatesPowers(e)},async accessList(){return Z.console.accessList({})},async accessEffective(e){return Z.console.accessEffective(e)},async accessKeyBlast(e){return Z.console.accessKeyBlast(e)},async accessCreateKey(e){return Z.console.accessCreateKey(e)},async accessRevokeKey(e){return Z.console.accessRevokeKey(e)},async accessRotateKey(e){return Z.console.accessRotateKey(e)},async accessSetRoleGrants(e){return Z.console.accessSetRoleGrants(e)},async diffList(){return Z.console.diffList({})},async pluginsList(){return Z.console.pluginsList({})}};function Ec(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ec(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Dc(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ec(e))&&(r&&(r+=` `),r+=t);return r}function Oc(){return typeof window<`u`}function kc(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ac(e){return Oc()?e instanceof Element||e instanceof kc(e).Element:!1}function jc(e){return Oc()?e instanceof HTMLElement||e instanceof kc(e).HTMLElement:!1}var Mc={...I},Nc={};function Pc(e,t){let n=I.useRef(Nc);return n.current===Nc&&(n.current=e(t)),n}var Fc=Mc.useInsertionEffect,Ic=Fc&&Fc!==Mc.useLayoutEffect?Fc:e=>e();function Lc(e){let t=Pc(Rc).current;return t.next=e,Ic(t.effect),t.trampoline}function Rc(){let e={next:void 0,callback:zc,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function zc(){}var Bc=typeof document<`u`?I.useLayoutEffect:()=>{};function Vc(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}var Hc={};function Uc(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Gc(t);let a=Gc(e);return t&&(a=Kc(a,t)),n&&(a=Kc(a,n)),r&&(a=Kc(a,r)),i&&(a=Kc(a,i)),a}function Wc(e){if(e.length===0)return Hc;if(e.length===1)return Gc(e[0]);let t=Gc(e[0]);for(let n=1;n<e.length;n+=1)t=Kc(t,e[n]);return t}function Gc(e){return Xc(e)?{...Zc(e,Hc)}:qc(e)}function Kc(e,t){return Xc(t)?Zc(t,e):Jc(e,t)}function qc(e){let t={...e};for(let e in t){let n=t[e];Yc(e,n)&&(t[e]=$c(n))}return t}function Jc(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Vc(e.style,r);break;case`className`:e[n]=tl(e.className,r);break;default:Yc(n,r)?e[n]=Qc(e[n],r):e[n]=r}}return e}function Yc(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Xc(e){return typeof e==`function`}function Zc(e,t){return Xc(e)?e(t):e??Hc}function Qc(e,t){return t?e?(...n)=>{let r=n[0];if(nl(r)){let i=r;el(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:$c(t):e}function $c(e){return e&&((...t)=>{let n=t[0];return nl(n)&&el(n),e(...t)})}function el(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function tl(e,t){return t?e?t+` `+e:t:e}function nl(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function rl(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var il=rl(`https://base-ui.com/production-error`,`Base UI`),al=I.createContext(void 0);function ol(e=!1){let t=I.useContext(al);if(t===void 0&&!e)throw Error(il(16));return t}function sl(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:I.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function cl(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=I.useRef(null),s=ol(!0),c=a??s!==void 0,{props:l}=sl({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=I.useCallback(()=>{let e=o.current;ll(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return Bc(u,[u]),{getButtonProps:I.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return Uc({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(el(e),o?.(e),e.baseUIHandlerPrevented))return;let r=e.target===e.currentTarget,a=e.currentTarget,s=ll(a),l=!i&&ul(a),u=r&&(i?s:!l),d=e.key===`Enter`,f=e.key===` `,p=a.getAttribute(`role`),m=p?.startsWith(`menuitem`)||p===`option`||p===`gridcell`;if(r&&c&&f){if(e.defaultPrevented&&m)return;e.preventDefault(),l||i&&s?(a.click(),e.preventBaseUIHandler()):u&&(n?.(e),e.preventBaseUIHandler());return}u&&(!i&&(f||d)&&e.preventDefault(),!i&&d&&n?.(e))},onKeyUp(e){if(!t){if(el(e),a?.(e),e.target===e.currentTarget&&i&&c&&ll(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&e.key===` `&&n?.(e)}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},l,u)},[t,l,c,i]),buttonRef:Lc(e=>{o.current=e,u()})}}function ll(e){return jc(e)&&e.tagName===`BUTTON`}function ul(e){return!!(e?.tagName===`A`&&e?.href)}function dl(e,t,n,r){let i=Pc(pl).current;return ml(i,e,t,n,r)&&gl(i,[e,t,n,r]),i.callback}function fl(e){let t=Pc(pl).current;return hl(t,e)&&gl(t,e),t.callback}function pl(){return{callback:null,cleanup:null,refs:[]}}function ml(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function hl(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function gl(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var _l=19;function vl(e){return _l>=e}function yl(e){if(!I.isValidElement(e))return null;let t=e,n=t.props;return(vl(19)?n?.ref:t.ref)??null}function Q(){}Object.freeze([]);var bl=Object.freeze({});function xl(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Sl(e,t){return typeof e==`function`?e(t):e}function Cl(e,t){return typeof e==`function`?e(t):e}function wl(e,t,n={}){let r=t.render,i=Tl(t,n);return n.enabled===!1?null:Ol(e,r,i,n.state??bl)}function Tl(e,t={}){let{className:n,style:r,render:i}=e,{state:a=bl,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Sl(n,a):void 0,d=l?Cl(r,a):void 0,f=l?xl(a,c):bl,p=l&&s?El(s):void 0,m=l?Vc(f,p)??{}:bl;return typeof document<`u`&&(l?Array.isArray(o)?m.ref=fl([m.ref,yl(i),...o]):m.ref=dl(m.ref,yl(i),o):dl(null,null)),l?(u!==void 0&&(m.className=tl(m.className,u)),d!==void 0&&(m.style=Vc(m.style,d)),m):bl}function El(e){return Array.isArray(e)?Wc(e):Uc(void 0,e)}var Dl=Symbol.for(`react.lazy`);function Ol(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Uc(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===Dl&&(i=I.Children.toArray(t)[0]),I.cloneElement(i,e)}if(e&&typeof e==`string`)return kl(e,n);throw Error(il(8))}function kl(e,t){return e===`button`?(0,I.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,I.createElement)(`img`,{alt:``,...t,key:t.key}):I.createElement(e,t)}var Al=I.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=cl({disabled:i,focusableWhenDisabled:a,native:o});return wl(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),jl=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Ml={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Nl={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Pl={disabled:!1,...Nl},Fl={valid(e){return e===null?null:e?{[jl.valid]:``}:{[jl.invalid]:``}}},Il={invalid:void 0,name:void 0,validityData:{state:Ml,errors:[],error:``,value:``,initialValue:null},setValidityData:Q,disabled:void 0,touched:Nl.touched,setTouched:Q,dirty:Nl.dirty,setDirty:Q,filled:Nl.filled,setFilled:Q,focused:Nl.focused,setFocused:Q,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:Pl,markedDirtyRef:{current:!1},registerFieldControl:Q,validation:{getValidationProps:(e,t=bl)=>t,inputRef:{current:null},registerInput:Q,commit:async()=>{},change:Q}},Ll=I.createContext(Il);function Rl(e=!0){let t=I.useContext(Ll);if(t.setValidityData===Q&&!e)throw Error(il(28));return t}var zl=I.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Q,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function Bl(){return I.useContext(zl)}var Vl=0;function Hl(e,t=`mui`){let[n,r]=I.useState(e),i=e||n;return I.useEffect(()=>{n??(Vl+=1,r(`${t}-${Vl}`))},[n,t]),i}var Ul=Mc.useId;function Wl(e,t){if(Ul!==void 0){let n=Ul();return e??(t?`${t}-${n}`:n)}return Hl(e,t)}function Gl(e){return Wl(e,`base-ui`)}var Kl=I.createContext({controlId:void 0,registerControlId:Q,labelId:void 0,setLabelId:Q,messageIds:[],setMessageIds:Q,getDescriptionProps:e=>e});function ql(){return I.useContext(Kl)}function Jl(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=ql(),o=Gl(t),s=n?i:void 0,c=Pc(()=>Symbol(`labelable-control`)),l=I.useRef(!1),u=I.useRef(t!=null),d=Lc(()=>{!l.current||a===Q||(l.current=!1,a(c.current,void 0))});return Bc(()=>{if(a===Q)return;let e;if(n){let n=r?.current;e=Ac(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),I.useEffect(()=>d,[d]),i??o}function Yl(e){return e?.ownerDocument||document}function Xl(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function Zl({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=I.useRef(e!==void 0),[a,o]=I.useState(t);return[i?e:a,I.useCallback(e=>{i||o(e)},[])]}function Ql(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Rl(),s=I.useRef(null);s.current||=Symbol(),Bc(()=>{let c=s.current;if(!(!c||!i))return o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}),()=>{o(c,void 0)}},[e,i,r,t,a,o,n])}var $l=`none`;function eu(e,t,n,r){let i=!1,a=!1,o=r??bl;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}var tu=I.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFocused:y,setFilled:b,validationMode:x,validation:S}=Rl(),{clearErrors:C}=Bl(),w=h||s,T=m??a,E={...p,disabled:w},{labelId:D}=ql(),O=Jl({id:i});Bc(()=>{let e=o!=null;S.inputRef.current?.value||e&&o!==``?b(!0):e&&o===``&&b(!1)},[S.inputRef,b,o]);let k=I.useRef(null);Bc(()=>{u&&k.current===Xl(Yl(k.current))&&y(!0)},[u,y]);let[A]=Zl({controlled:o,default:l,name:`FieldControl`,state:`value`}),ee=o!==void 0,j=ee?A:void 0,M=Lc(()=>S.inputRef.current?.value);return Ql(S.inputRef,O,j,M,!w,a),wl(`input`,e,{ref:[t,k],state:E,props:[{id:O,disabled:w,name:T,ref:S.inputRef,"aria-labelledby":D,autoFocus:u,...ee?{value:j}:{defaultValue:l},onChange(e){let t=e.currentTarget.value;c?.(t,eu($l,e.nativeEvent)),_(t!==v.initialValue),b(t!==``),e.nativeEvent.defaultPrevented||(C(T),S.change(t))},onFocus(){y(!0)},onBlur(e){g(!0),y(!1),x===`onBlur`&&S.commit(e.currentTarget.value)},onKeyDown(e){e.currentTarget.tagName===`INPUT`&&e.key===`Enter`&&(g(!0),S.commit(e.currentTarget.value))}},f,e=>S.getValidationProps(w,e)],stateAttributesMapping:Fl})}),nu=I.forwardRef(function(e,t){return(0,L.jsx)(tu,{ref:t,...e})});function $({variant:e=`primary`,className:t,...n}){return(0,L.jsx)(Al,{className:Dc(`inline-flex min-h-8 min-w-8 items-center justify-center px-3 text-sm font-medium transition-opacity duration-150`,`disabled:opacity-40`,e===`primary`&&`bg-[var(--oke-accent)] text-black`,e===`ghost`&&`bg-transparent text-[var(--oke-fg)] border border-[var(--oke-line)]`,e===`danger`&&`bg-[var(--oke-danger)] text-white`,e===`external`&&`bg-[var(--oke-external)] text-black`,t),...n})}function ru({className:e,...t}){return(0,L.jsx)(nu,{className:Dc(`min-h-8 w-full border border-[var(--oke-line)] bg-transparent px-3 text-sm text-[var(--oke-fg)]`,`placeholder:text-[var(--oke-muted)]`,e),...t})}function iu({label:e,error:t,children:n}){return(0,L.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:e}),n,t?(0,L.jsx)(`span`,{role:`alert`,className:`text-xs text-[var(--oke-danger)]`,children:t}):null]})}function au({count:e,onFlush:t}){return e<=0?null:(0,L.jsxs)(`button`,{type:`button`,className:`min-h-8 rounded-sm border border-[var(--oke-line)] px-3 text-xs text-[var(--oke-fg)]`,onClick:t,children:[e,` new`]})}var ou=15e3;function su(e,t={production:!0}){return e===`external`&&t.production?{kind:`typed`,phrase:`INVOKE`,requireReason:!0}:{kind:`undo`,windowMs:ou}}function cu(e){let t={};return e.typed.trim()!==e.phrase&&(t.typed=`Type ${e.phrase} to confirm`),e.reason.trim().length<3&&(t.reason=`Reason is required (min 3 characters)`),Object.keys(t).length>0?t:null}function lu(e={production:!0}){return{kind:`typed`,phrase:`REVOKE`,requireReason:!0}}function uu(e={production:!0}){return{kind:`typed`,phrase:`ROTATE`,requireReason:!0}}function du(e){return e.acknowledged===!0}var fu=`I have copied this secret and understand it will not be shown again`,pu=`This secret is shown exactly once. Store it now — dismissal is permanent.`;function mu(e){return{volume:e.callVolume===0?`No recorded calls from Runs`:`${e.callVolume} call${e.callVolume===1?``:`s`} in Runs`,lastUsed:e.lastUsedAt==null?`Never used`:`Last used ${new Date(e.lastUsedAt).toISOString()}`,sources:e.sourceAddresses.length===0?`No source addresses recorded`:`Source addresses: ${e.sourceAddresses.join(`, `)}`,residual:e.residualAccessNote,warn:e.callVolume>0}}function hu(e){let t=[];return e.unusedKeys.length>0&&t.push({code:`unused-keys`,message:`${e.unusedKeys.length} key${e.unusedKeys.length===1?``:`s`} unused 90d+`}),e.neverSignedInOperators.length>0&&t.push({code:`never-signed-in`,message:`${e.neverSignedInOperators.length} operator${e.neverSignedInOperators.length===1?``:`s`} never signed in`}),e.expiredInvitations.length>0&&t.push({code:`expired-invites`,message:`${e.expiredInvitations.length} expired invitation${e.expiredInvitations.length===1?``:`s`}`}),t}function gu(e){return e.scopes.map(e=>({scope:e.scope,sources:e.sources.map(e=>e.kind===`direct`?`direct (${e.name})`:`role ${e.name}`).join(`, `)}))}function _u(){let e=Rt({from:`/access`}),t=zt({from:`/access`}),n=je(),r=e.plane??`operator`,[i,a]=(0,I.useState)([]),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(null),v=e=>{t({search:lc(e),replace:!0})},y=Ke({queryKey:[`console.access.list`],queryFn:async()=>{let e=await Tc.accessList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}).data,b=r===`operator`?y?.operatorPlane:y?.userPlane,x=b?.grantableScopes??[],S=y?.hygiene,C=(0,I.useMemo)(()=>S?hu(S):[],[S]),w=b?.keys.find(t=>e.kind===`key`&&t.id===e.id),T=b?.roles.find(t=>e.kind===`role`&&t.id===e.id),E=b?.operators?.find(t=>e.kind===`operator`&&t.id===e.id),D=b?.users?.find(t=>e.kind===`user`&&t.id===e.id),O=(e.q??``).toLowerCase(),k=e=>O.length===0||e.toLowerCase().includes(O),A=qe({mutationFn:async()=>{if(!o.trim())throw Error(`Name required`);let e=await Tc.accessCreateKey({plane:r,name:o.trim(),scopes:i});if(e.error)throw Error(e.error.code);return e.data},onSuccess:e=>{p({secret:e.secret,keyId:e.key.id,keyName:e.key.name,acknowledged:!1}),s(``),a([]),n.invalidateQueries({queryKey:[`console.access.list`]})}}),ee=qe({mutationFn:async e=>{let t=await Tc.accessKeyBlast({keyId:e});if(t.error)throw Error(t.error.code);return t.data},onSuccess:h}),j=qe({mutationFn:async()=>{if(!w)throw Error(`Select a key`);let e=lu();if(e.kind===`typed`){let t=cu({typed:c,reason:u,phrase:e.phrase});if(t)throw Error(t.typed??t.reason??`confirm`)}let t=await Tc.accessRevokeKey({keyId:w.id,confirmation:c,reason:u});if(t.error)throw Error(t.error.code);return t.data},onSuccess:e=>{h(e.blastRadius),l(``),d(``),n.invalidateQueries({queryKey:[`console.access.list`]})}}),M=qe({mutationFn:async()=>{if(!w)throw Error(`Select a key`);let e=uu();if(e.kind===`typed`){let t=cu({typed:c,reason:u,phrase:e.phrase});if(t)throw Error(t.typed??t.reason??`confirm`)}let t=await Tc.accessRotateKey({keyId:w.id,confirmation:c,reason:u});if(t.error)throw Error(t.error.code);return t.data},onSuccess:e=>{h(e.blastRadius),p({secret:e.secret,keyId:e.key.id,keyName:e.key.name,acknowledged:!1}),l(``),d(``),n.invalidateQueries({queryKey:[`console.access.list`]})}}),N=qe({mutationFn:async()=>{let t=e.kind===`invite`||!e.kind||!e.id?null:e.kind;if(!t||!e.id)throw Error(`Select a principal`);let n=await Tc.accessEffective({kind:t,id:e.id});if(n.error)throw Error(n.error.code);return n.data},onSuccess:_}),te=qe({mutationFn:async()=>{if(!T)throw Error(`Select a role`);let e=await Tc.accessSetRoleGrants({roleId:T.id,scopes:i});if(e.error)throw Error(e.error.code);return e.data},onSuccess:()=>{n.invalidateQueries({queryKey:[`console.access.list`]})}}),P=m?mu(m):null,ne=g?gu(g):[],F=e=>{a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-3 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-lg font-medium text-[var(--oke-fg)]`,children:`Access`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Identities, roles, API keys — planes never merge`})]}),(0,L.jsxs)(`div`,{role:`group`,"aria-label":`Plane`,className:`flex gap-1`,children:[(0,L.jsx)($,{type:`button`,variant:r===`operator`?`primary`:`ghost`,"aria-pressed":r===`operator`,onClick:()=>v({...e,plane:`operator`,kind:void 0,id:void 0,view:void 0}),children:`Operator plane`}),(0,L.jsx)($,{type:`button`,variant:r===`user`?`primary`:`ghost`,"aria-pressed":r===`user`,onClick:()=>v({...e,plane:`user`,kind:void 0,id:void 0,view:void 0}),children:`User plane`})]}),(0,L.jsxs)(`label`,{className:`ml-auto flex min-w-[12rem] flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter access`}),(0,L.jsx)(ru,{"aria-label":`Filter access`,value:e.q??``,onChange:t=>v({...e,q:t.currentTarget.value||void 0})})]})]}),C.length>0?(0,L.jsxs)(`section`,{"aria-label":`Access hygiene`,className:`border-b border-[var(--oke-line)] px-4 py-2`,role:`status`,children:[(0,L.jsx)(`h2`,{className:`sr-only`,children:`Hygiene`}),(0,L.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-[var(--oke-warn,var(--oke-muted))]`,children:C.map(e=>(0,L.jsx)(`li`,{children:e.message},e.code))})]}):null,(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,L.jsxs)(`section`,{"aria-label":`${r} plane list`,className:`w-80 shrink-0 overflow-y-auto border-r border-[var(--oke-line)]`,children:[(0,L.jsx)(`h2`,{className:`px-4 py-2 text-sm font-medium`,children:r===`operator`?`Operator plane`:`User plane`}),b?.operators?(0,L.jsx)(vu,{label:`Operators`,children:b.operators.filter(e=>k(`${e.name} ${e.email}`)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`operator`&&e.id===t.id,onClick:()=>v(uc(e,`operator`,`operator`,t.id)),children:[t.name,t.neverSignedIn?(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · never`}):null]},t.id))}):null,b?.users?(0,L.jsx)(vu,{label:`Users`,children:b.users.filter(e=>k(`${e.name} ${e.email}`)).map(t=>(0,L.jsx)(yu,{selected:e.kind===`user`&&e.id===t.id,onClick:()=>v(uc(e,`user`,`user`,t.id)),children:t.name},t.id))}):null,(0,L.jsx)(vu,{label:`Roles`,children:(b?.roles??[]).filter(e=>k(e.name)).map(t=>(0,L.jsx)(yu,{selected:e.kind===`role`&&e.id===t.id,onClick:()=>{a([...t.scopes]),v(uc(e,r,`role`,t.id))},children:t.name},t.id))}),(0,L.jsx)(vu,{label:`API keys`,children:(b?.keys??[]).filter(e=>k(e.name)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`key`&&e.id===t.id,onClick:()=>{h(null),v(uc(e,r,`key`,t.id)),ee.mutate(t.id)},children:[t.name,t.unused90d?(0,L.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · 90d+`}):null,t.revokedAt==null?null:(0,L.jsx)(`span`,{className:`text-[var(--oke-danger)]`,children:` · revoked`})]},t.id))}),b?.invites&&b.invites.length>0?(0,L.jsx)(vu,{label:`Invitations`,children:b.invites.filter(e=>k(e.email)).map(t=>(0,L.jsxs)(yu,{selected:e.kind===`invite`&&e.id===t.id,onClick:()=>v(uc(e,`operator`,`invite`,t.id)),children:[t.email,t.expired?(0,L.jsx)(`span`,{className:`text-[var(--oke-danger)]`,children:` · expired`}):null]},t.id))}):null,(0,L.jsx)(`div`,{className:`border-t border-[var(--oke-line)] p-3`,children:(0,L.jsx)($,{type:`button`,variant:`ghost`,className:`w-full`,onClick:()=>{a([]),s(``),v({...e,plane:r,view:`create-key`,kind:void 0,id:void 0})},children:`Create API key`})})]}),(0,L.jsxs)(`section`,{"aria-label":`Access detail`,className:`min-w-0 flex-1 overflow-y-auto px-4 py-3`,"aria-live":`polite`,children:[e.view===`create-key`?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:`Create API key`}),(0,L.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[`Only scopes you hold on the `,r,` plane are shown — impossibility taught by absence. No preview.`]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Name`}),(0,L.jsx)(ru,{"aria-label":`API key name`,value:o,onChange:e=>s(e.currentTarget.value)})]}),(0,L.jsx)(bu,{grantable:x,selected:i,onToggle:F}),(0,L.jsx)($,{type:`button`,disabled:A.isPending||!o.trim(),onClick:()=>A.mutate(),children:`Create key`}),A.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:A.error.message}):null]}):w?(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:w.name}),(0,L.jsx)(`p`,{className:`font-mono text-sm text-[var(--oke-muted)]`,children:w.id}),(0,L.jsx)(`ul`,{className:`mt-2 font-mono text-sm`,children:w.scopes.map(e=>(0,L.jsx)(`li`,{children:e},e))})]}),(0,L.jsxs)(`section`,{"aria-label":`Revocation blast radius`,className:`space-y-1`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Revocation blast radius`}),P?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-sm`,role:P.warn?`alert`:`status`,children:P.volume}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:P.lastUsed}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:P.sources}),(0,L.jsx)(`p`,{className:`text-sm`,role:`status`,children:P.residual})]}):(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`})]}),w.revokedAt==null?(0,L.jsxs)(`section`,{"aria-label":`Revoke or rotate`,className:`space-y-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Revoke / rotate`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Irreversible. Type the phrase and a reason. No dry-run.`}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Type REVOKE or ROTATE`}),(0,L.jsx)(ru,{"aria-label":`Type REVOKE or ROTATE to confirm`,value:c,onChange:e=>l(e.currentTarget.value),autoComplete:`off`})]}),(0,L.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,L.jsx)(`span`,{children:`Reason`}),(0,L.jsx)(ru,{"aria-label":`Reason`,value:u,onChange:e=>d(e.currentTarget.value)})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)($,{type:`button`,variant:`danger`,disabled:j.isPending,onClick:()=>j.mutate(),children:`Revoke key`}),(0,L.jsx)($,{type:`button`,variant:`danger`,disabled:M.isPending,onClick:()=>M.mutate(),children:`Rotate key`})]}),j.error||M.error?(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:(j.error??M.error).message}):null]}):(0,L.jsxs)(`p`,{role:`status`,className:`text-sm text-[var(--oke-danger)]`,children:[`Revoked`,` `,w.revokedAt?new Date(w.revokedAt).toISOString():``]}),(0,L.jsx)($,{type:`button`,variant:`ghost`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):T?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:T.name}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:T.description}),(0,L.jsx)(bu,{grantable:x,selected:i,onToggle:F}),(0,L.jsx)($,{type:`button`,disabled:te.isPending,onClick:()=>te.mutate(),children:`Save role grants`}),(0,L.jsx)($,{type:`button`,variant:`ghost`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):E||D?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`h2`,{className:`text-lg font-medium`,children:E?.name??D?.name}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:E?.email??D?.email}),(0,L.jsx)($,{type:`button`,onClick:()=>{v({...e,view:`effective`}),N.mutate()},children:`Effective permissions`})]}):e.view===`effective`&&ne.length>0?(0,L.jsx)(xu,{provenance:ne}):(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Choose an identity, role, or key. Planes stay separate; scopes you cannot grant do not appear.`}),e.view===`effective`&&ne.length>0&&(w||T||E||D)?(0,L.jsx)(`div`,{className:`mt-6`,children:(0,L.jsx)(xu,{provenance:ne})}):null]})]}),f?(0,L.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,role:`presentation`,children:(0,L.jsxs)(`section`,{"aria-label":`New API key secret`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`once-secret-title`,className:`max-w-lg space-y-4 border border-[var(--oke-line)] bg-[var(--oke-bg)] p-6`,children:[(0,L.jsx)(`h2`,{id:`once-secret-title`,className:`text-lg font-medium`,children:`New API key secret`}),(0,L.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:pu}),(0,L.jsx)(`p`,{className:`break-all font-mono text-sm`,children:f.secret}),(0,L.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:f.acknowledged,onChange:e=>p({...f,acknowledged:e.currentTarget.checked})}),(0,L.jsx)(`span`,{children:fu})]}),(0,L.jsx)($,{type:`button`,disabled:!du(f),onClick:()=>p(null),children:`Dismiss secret`})]})}):null]})}function vu({label:e,children:t}){return(0,L.jsxs)(`section`,{"aria-label":e,className:`border-t border-[var(--oke-line)]`,children:[(0,L.jsx)(`h3`,{className:`px-4 py-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:e}),(0,L.jsx)(`ul`,{className:`pb-2`,children:t})]})}function yu({selected:e,onClick:t,children:n}){return(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:Dc(`flex min-h-8 w-full items-center px-4 text-left text-sm`,e?`bg-[var(--oke-accent)]/15 text-[var(--oke-fg)]`:`text-[var(--oke-fg)]`),children:n})})}function bu({grantable:e,selected:t,onToggle:n}){return(0,L.jsxs)(`section`,{"aria-label":`Grantable scopes`,className:`space-y-2`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium`,children:`Grantable scopes`}),(0,L.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Only scopes you hold appear`}),e.length===0?(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-[var(--oke-muted)]`,children:`No grantable scopes on this plane`}):(0,L.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`label`,{className:`flex min-h-8 items-center gap-2 font-mono text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:t.includes(e),onChange:()=>n(e)}),e]})},e))})]})}function xu({provenance:e}){return(0,L.jsxs)(`section`,{"aria-label":`Effective permissions`,children:[(0,L.jsx)(`h2`,{className:`mb-2 text-lg font-medium`,children:`Effective permissions`}),(0,L.jsx)(`p`,{className:`mb-3 text-sm text-[var(--oke-muted)]`,children:`Every permission with provenance — inverse of the Gates simulator`}),(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`caption`,{className:`sr-only`,children:`Effective permissions with provenance`}),(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b border-[var(--oke-line)]`,children:[(0,L.jsx)(`th`,{scope:`col`,className:`py-2 pr-4 font-medium`,children:`Scope`}),(0,L.jsx)(`th`,{scope:`col`,className:`py-2 font-medium`,children:`Granted by`})]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{className:`border-b border-[var(--oke-line)]`,children:[(0,L.jsx)(`td`,{className:`py-2 pr-4 font-mono`,children:e.scope}),(0,L.jsx)(`td`,{className:`py-2 text-[var(--oke-muted)]`,children:e.sources})]},e.scope))})]})]})}var Su=t({default:()=>_u});export{Me as $,Tt as A,bt as B,zt as C,Pt as D,It as E,xt as F,st as G,ht as H,ft as I,Ze as J,Je as K,St as L,yt as M,Ct as N,Dt as O,pt as P,Ke as Q,tt as R,Ta as S,Lt as T,$e as U,mt as V,ot as W,Xe as X,Ye as Y,qe as Z,xs as _,r as _t,cu as a,re as at,Zo as b,ru as c,v as ct,Tc as d,h as dt,je as et,wc as f,l as ft,Fs as g,i as gt,_s as h,A as ht,su as i,fe as it,wt as j,Et as k,au as l,_ as lt,cc as m,p as mt,hu as n,De as nt,$ as o,F as ot,Cc as p,y as pt,Qe as q,ou as r,Ce as rt,iu as s,u as st,Su as t,ke as tt,Dc as u,g as ut,Ls as v,Rt as w,js as x,ks as y,it as z};
@@ -0,0 +1 @@
1
+ import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,S as i,b as a,d as o,h as s,nt as c,tt as l,u,w as d,y as f}from"./panel-access-Dd37LU2c.js";function p(e){return i(s,e)}var m=f({prompt:a().optional(),version:p().int().optional(),agent:a().optional(),run:a().optional(),q:a().optional()});function h(e){let t=m.safeParse(e);return t.success?t.data:{}}function g(e){let t={};return e.prompt&&(t.prompt=e.prompt),e.version!==void 0&&(t.version=e.version),e.agent&&(t.agent=e.agent),e.run&&(t.run=e.run),e.q&&(t.q=e.q),t}function _(e,t,n){return{...e,prompt:t,version:n,agent:void 0,run:void 0}}function v(e,t,n){return{...e,agent:t,run:n}}function y(e){return`/manifest-diff?${new URLSearchParams({path:e}).toString()}`}function b(e,t){if(e.prompt!==t.prompt)throw Error(`promotionDecision: prompt mismatch (${e.prompt} vs ${t.prompt})`);let n={fromEvalMean:e.evalScore.mean,toEvalMean:t.evalScore.mean,fromSchemaInvalidRate:e.schemaInvalidRate,toSchemaInvalidRate:t.schemaInvalidRate,fromOverBudgetRate:e.overBudgetRate,toOverBudgetRate:t.overBudgetRate,fromP95Cost:e.cost.p95,toP95Cost:t.cost.p95,budgetMaxCostPerCall:t.budgetMaxCostPerCall??e.budgetMaxCostPerCall},r=[];t.schemaInvalidRate>e.schemaInvalidRate+1e-12&&r.push(`schema_validity`);let i=n.budgetMaxCostPerCall;(t.overBudgetRate>e.overBudgetRate+1e-12||i!==null&&t.cost.p95>i&&e.cost.p95<=i)&&r.push(`budget`);let a=t.evalScore.mean>e.evalScore.mean+1e-12;return r.length>0?{allowed:!1,from:e,to:t,blockers:r,evalImproved:a,numbers:n}:{allowed:!0,from:e,to:t,evalImproved:a,numbers:n}}function x(e){let t=[],n=e.numbers;if(e.blockers.includes(`schema_validity`)&&t.push(`schema-invalid ${(n.fromSchemaInvalidRate*100).toFixed(1)}% → ${(n.toSchemaInvalidRate*100).toFixed(1)}%`),e.blockers.includes(`budget`)){let e=n.budgetMaxCostPerCall===null?`budget`:`budget $${n.budgetMaxCostPerCall.toFixed(4)}`;t.push(`over-budget ${(n.fromOverBudgetRate*100).toFixed(1)}% → ${(n.toOverBudgetRate*100).toFixed(1)}% · p95 $${n.fromP95Cost.toFixed(4)} → $${n.toP95Cost.toFixed(4)} (${e})`)}return e.evalImproved&&t.push(`eval mean ${(n.fromEvalMean*100).toFixed(1)}% → ${(n.toEvalMean*100).toFixed(1)}% (improved — still blocked)`),t}function S(e,t){let n=t?.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||(e.model?.toLowerCase().includes(n)??!1)):e}function C(e,t){let n=t?.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||e.tools.some(e=>e.toLowerCase().includes(n))):e}function w(e,t){return e.filter(e=>e.prompt===t).sort((e,t)=>e.version-t.version)}function T(e,t){return e.filter(e=>e.agent===t)}function E(e){return e.filter(e=>e.allowPii)}function D(e){return`${(e*100).toFixed(1)}%`}function O(e){return`$${e.toFixed(4)}`}function k(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${Math.round(e)}ms`}function A(e){return`${(e*100).toFixed(1)}%`}function j(e,t,n,r,i){return`${e}: mean ${i(t)}, p50 ${i(n)}, p95 ${i(r)}`}function M(e){return e.reduce((e,t)=>Math.max(e,t.count),0)}function N(e){return e===`denied`?`DENIED`:`ok`}function P(e){return e.filter(e=>e.overBudgetRate>0).map(e=>({prompt:e.prompt,version:e.version,overBudgetRate:e.overBudgetRate,budgetMaxCostPerCall:e.budgetMaxCostPerCall,p95Cost:e.cost.p95})).sort((e,t)=>t.overBudgetRate-e.overBudgetRate||e.prompt.localeCompare(t.prompt)||t.version-e.version)}var F=e(c(),1),I=l();function L(){let e=d({from:`/ai`}),t=n({from:`/ai`}),i=e=>{t({search:g(e),replace:!0})},a=r({queryKey:[`console.ai.list`],queryFn:async()=>{let e=await o.aiList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),s=a.data,c=(0,F.useMemo)(()=>S(s?.prompts??[],e.q),[s?.prompts,e.q]),l=(0,F.useMemo)(()=>C(s?.agents??[],e.q),[s?.agents,e.q]),f=e.prompt??c[0]?.name,p=(0,F.useMemo)(()=>f?w(s?.versions??[],f):[],[s?.versions,f]),m=p.find(t=>t.version===e.version)??p[p.length-1],h=p.length>=2?p[p.length-2]:p[0],x=h&&m&&h.version!==m.version?b(h,m):null,D=e.agent??l[0]?.name,k=(0,F.useMemo)(()=>D?T(s?.agentRuns??[],D):[],[s?.agentRuns,D]),A=k.find(t=>t.id===e.run)??k[0],j=E(s?.allowPii??[]),M=c.find(e=>e.name===f);return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,I.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,I.jsx)(`h1`,{className:`text-base font-medium text-[var(--oke-fg)]`,children:`AI`}),(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Distributions per prompt version — cost, latency, eval score. Schema-invalid is its own class.`}),(0,I.jsxs)(`label`,{className:`mt-2 flex max-w-sm flex-col gap-1 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter`}),(0,I.jsx)(`input`,{"aria-label":`Filter prompts and agents`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:e.q??``,onChange:t=>i({...e,q:t.target.value||void 0})})]})]}),(0,I.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 lg:grid-cols-[14rem_1fr_18rem]`,children:[(0,I.jsxs)(`aside`,{"aria-label":`Prompts and agents`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] lg:border-b-0 lg:border-r`,children:[(0,I.jsxs)(`section`,{"aria-label":`Prompts`,className:`p-3`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`Prompts`}),(0,I.jsx)(`ul`,{className:`space-y-1`,children:c.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===f,className:u(`flex min-h-8 w-full items-center px-2 text-left text-sm`,t.name===f?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>i(_(e,t.name,t.version??0)),children:[t.name,t.version===void 0?null:(0,I.jsxs)(`span`,{className:`ml-1 font-mono text-xs`,children:[`@`,t.version]})]})},t.name))})]}),(0,I.jsxs)(`section`,{"aria-label":`Agents`,className:`p-3`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`Agents`}),(0,I.jsx)(`ul`,{className:`space-y-1`,children:l.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.name===D,className:u(`flex min-h-8 w-full items-center px-2 text-left text-sm`,t.name===D?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>i({...e,agent:t.name,run:void 0}),children:t.name})},t.name))})]})]}),(0,I.jsxs)(`main`,{id:`ai-main`,className:`min-h-0 overflow-y-auto p-4`,children:[a.isLoading?(0,I.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`Loading…`}):null,a.isError?(0,I.jsx)(`p`,{role:`alert`,children:`Failed to load AI projection`}):null,m?(0,I.jsx)(R,{metrics:m,versions:p,onSelectVersion:t=>i(_(e,m.prompt,t)),catalogueHref:M?y(M.manifestDiffPath):null,decision:x}):(0,I.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`No prompt versions with samples yet.`}),A?(0,I.jsxs)(`section`,{"aria-label":`Agent run trail`,className:`mt-8`,children:[(0,I.jsxs)(`h2`,{className:`mb-2 text-sm font-medium`,children:[`Agent run · `,A.agent]}),(0,I.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:k.map(t=>(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t.id===A.id,className:u(`min-h-8 px-2 text-xs font-mono`,t.id===A.id?`bg-[var(--oke-line)]`:`text-[var(--oke-muted)]`),onClick:()=>i(v(e,t.agent,t.id)),children:t.id},t.id))}),(0,I.jsx)(`ol`,{className:`space-y-3 border-l border-[var(--oke-line)] pl-4`,children:A.trail.map((e,t)=>(0,I.jsxs)(`li`,{className:`text-sm`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,I.jsx)(`span`,{className:u(`font-mono text-xs tracking-wide`,e.status===`denied`?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),children:N(e.status)}),(0,I.jsx)(`span`,{className:`font-mono`,children:e.tool})]}),e.status===`denied`&&e.denial?(0,I.jsxs)(`p`,{role:`status`,className:`mt-1 text-[var(--oke-muted)]`,children:[`DENIED by gate`,` `,(0,I.jsx)(`span`,{className:`font-mono text-[var(--oke-fg)]`,children:e.denial.gate}),`: `,e.denial.reason]}):null,(0,I.jsxs)(`ul`,{className:`mt-1 space-y-0.5 text-xs text-[var(--oke-muted)]`,children:[e.effects.map(e=>(0,I.jsxs)(`li`,{children:[(0,I.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,e.resource]},`${e.kind}:${e.resource}`)),e.effects.length===0?(0,I.jsx)(`li`,{children:`no declared effects`}):null]})]},`${e.tool}-${t}`))})]}):null,(0,I.jsxs)(`section`,{"aria-label":`Fallback chains`,className:`mt-8`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Fallback chains`}),(s?.fallbackChains.length??0)===0?(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`No multi-model chains recorded.`}):(0,I.jsx)(`ul`,{className:`space-y-2 text-sm`,children:(s?.fallbackChains??[]).map((e,t)=>(0,I.jsxs)(`li`,{className:`border border-[var(--oke-line)] px-3 py-2`,children:[(0,I.jsxs)(`div`,{className:`font-mono text-xs`,children:[e.prompt,e.version===void 0?``:`@${e.version}`]}),(0,I.jsx)(`div`,{className:`mt-1`,children:e.attempts.map((e,t)=>(0,I.jsxs)(`span`,{children:[t>0?` → `:``,(0,I.jsx)(`span`,{className:e.ok?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)] line-through`,children:e.model}),e.cost===void 0?``:` (${O(e.cost)})`]},`${e.model}-${t}`))}),(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:[`actual `,O(e.actualCost),e.costConsequence===null?``:` · cost consequence ${O(e.costConsequence)}`]})]},`${e.prompt}-${e.at}-${t}`))})]})]}),(0,I.jsxs)(`aside`,{"aria-label":`allowPii security review`,className:`min-h-0 overflow-y-auto border-t border-[var(--oke-line)] p-4 lg:border-l lg:border-t-0`,children:[(0,I.jsx)(`h2`,{className:`mb-2 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:`allowPii`}),(0,I.jsx)(`p`,{className:`mb-3 text-xs text-[var(--oke-muted)]`,children:`Standing security review — flows that acknowledge PII egress to a model.`}),j.length===0?(0,I.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`None declared.`}):(0,I.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,I.jsx)(`caption`,{className:`sr-only`,children:`Standing security review — PII egress acknowledgements`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Flow`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Asks`})]})}),(0,I.jsx)(`tbody`,{children:j.map(e=>(0,I.jsxs)(`tr`,{className:`align-top`,children:[(0,I.jsx)(`td`,{className:`py-1 pr-2 font-mono text-[var(--oke-fg)]`,children:e.flowId}),(0,I.jsx)(`td`,{className:`py-1 font-mono text-[var(--oke-muted)]`,children:e.asks.join(`, `)||`—`})]},e.flowId))})]})]})]})]})}function R(e){let t=e.metrics;return(0,I.jsxs)(`section`,{"aria-label":`Version distributions`,"aria-live":`polite`,children:[(0,I.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-baseline gap-3`,children:[(0,I.jsxs)(`h2`,{className:`text-sm font-medium`,children:[t.prompt,` `,(0,I.jsxs)(`span`,{className:`font-mono text-[var(--oke-muted)]`,children:[`@`,t.version]})]}),e.catalogueHref?(0,I.jsx)(`a`,{href:e.catalogueHref,className:`text-xs text-[var(--oke-muted)] underline`,children:`Manifest Diff — version bump is a deploy`}):null]}),(0,I.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-2`,role:`group`,"aria-label":`Versions`,children:e.versions.map(n=>(0,I.jsxs)(`button`,{type:`button`,"aria-pressed":n.version===t.version,className:u(`min-h-8 px-2 font-mono text-xs`,n.version===t.version?`bg-[var(--oke-line)]`:`text-[var(--oke-muted)]`),onClick:()=>e.onSelectVersion(n.version),children:[`v`,n.version]},n.version))}),(0,I.jsx)(z,{label:`Cost`,summary:j(`Cost`,t.cost.mean,t.cost.p50,t.cost.p95,O),buckets:t.cost.buckets,formatTick:O}),(0,I.jsx)(z,{label:`Latency`,summary:j(`Latency`,t.latencyMs.mean,t.latencyMs.p50,t.latencyMs.p95,k),buckets:t.latencyMs.buckets,formatTick:k}),(0,I.jsx)(z,{label:`Eval score`,summary:j(`Eval score`,t.evalScore.mean,t.evalScore.p50,t.evalScore.p95,A),buckets:t.evalScore.buckets,formatTick:A}),(0,I.jsxs)(`table`,{className:`mt-4 w-full max-w-md text-left text-sm`,children:[(0,I.jsx)(`caption`,{className:`mb-2 text-left text-xs text-[var(--oke-muted)]`,children:`Outcome classes — schema-invalid ≠ provider-error`}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Class`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Rate`}),(0,I.jsx)(`th`,{scope:`col`,className:`pb-1 font-normal`,children:`Count`})]})}),(0,I.jsxs)(`tbody`,{children:[(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`schema-invalid`}),(0,I.jsx)(`td`,{children:D(t.schemaInvalidRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.schema_invalid})]}),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`provider-error`}),(0,I.jsx)(`td`,{children:D(t.providerErrorRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.provider_error})]}),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:`ok`}),(0,I.jsx)(`td`,{children:D(t.okRate)}),(0,I.jsx)(`td`,{className:`font-mono`,children:t.outcomeCounts.ok})]})]})]}),e.decision&&!e.decision.allowed?(0,I.jsxs)(`div`,{className:`mt-4 border border-[var(--oke-line)] px-3 py-2`,role:`status`,"aria-label":`Promotion gate`,children:[(0,I.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Promotion v`,e.decision.from.version,` → v`,e.decision.to.version,` blocked`]}),(0,I.jsx)(`ul`,{className:`mt-1 list-disc pl-5 text-sm text-[var(--oke-muted)]`,children:x(e.decision).map(e=>(0,I.jsx)(`li`,{children:e},e))})]}):e.decision?.allowed?(0,I.jsxs)(`p`,{className:`mt-4 text-sm text-[var(--oke-muted)]`,role:`status`,children:[`Promotion v`,e.decision.from.version,` → v`,e.decision.to.version,` allowed`,e.decision.evalImproved?` (eval improved)`:``,`.`]}):null]})}function z(e){let t=M(e.buckets);return(0,I.jsxs)(`div`,{className:`mb-4`,children:[(0,I.jsxs)(`h3`,{className:`text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:[e.label,` distribution`]}),(0,I.jsx)(`p`,{className:`mb-2 text-sm`,children:e.summary}),(0,I.jsx)(`div`,{role:`img`,"aria-label":e.summary,className:`flex h-16 items-end gap-px`,children:e.buckets.map((n,r)=>(0,I.jsx)(`div`,{title:`${e.formatTick(n.min)}–${e.formatTick(n.max)}: ${n.count}`,className:`min-w-[4px] flex-1 bg-[var(--oke-fg)] opacity-70`,style:{height:`${t===0?0:Math.max(4,n.count/t*100)}%`}},r))})]})}var B=t({default:()=>L});export{p as i,P as n,h as r,B as t};
@@ -0,0 +1 @@
1
+ import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,_ as i,b as a,d as o,nt as s,o as c,tt as l,u,v as d,w as f,x as p,y as m}from"./panel-access-Dd37LU2c.js";var h=[`data`,`messaging`,`time`,`external`],g={data:`Data`,messaging:`Messaging`,time:`Time`,external:`External`},_={data:!0,messaging:!0,time:!0,external:!0},v=p([i(),d(`true`),d(`false`)]).transform(e=>e===!0||e===`true`),ee=m({focus:a().optional(),depth:p([d(1),d(2),d(`1`),d(`2`)]).transform(e=>Number(e)===2?2:1).default(1),data:v.optional(),messaging:v.optional(),time:v.optional(),external:v.optional()});function te(e){let t=ee.safeParse(e);return t.success?t.data:{depth:1}}function ne(e){let t={};e.focus&&(t.focus=e.focus),e.depth===2&&(t.depth=`2`);for(let n of h)e[n]===!1&&(t[n]=`false`);return t}function y(e){return{data:e.data??_.data,messaging:e.messaging??_.messaging,time:e.time??_.time,external:e.external??_.external}}function b(e,t){return{...e,focus:t}}function re(e){let{focus:t,...n}=e;return{...n,depth:e.depth}}function ie(e,t){return{...e,depth:t}}function x(e,t,n){return{...e,[t]:n}}function S(e){return e.startsWith(`sql:`)||e.startsWith(`kv:`)||e.startsWith(`files:`)||e.startsWith(`index:`)?`data`:e.startsWith(`signal:`)?`messaging`:e.startsWith(`channel:`)||e.startsWith(`ai:`)?`external`:null}function ae(e){return e.kind===`signal`?`messaging`:e.kind===`cron`||e.kind===`every`?`time`:null}function C(e){return e.startsWith(`channel:`)||e.startsWith(`ai:`)}function w(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(t+1)}function oe(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return t.size}function se(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return[...t].sort()}function ce(e,t){switch(e){case`emit`:return t.startsWith(`signal:`)?t:`signal:${t}`;case`send`:return t.startsWith(`channel:`)?t:`channel:${t}`;case`ask`:return t.startsWith(`ai:`)?t:`ai:${t}`;case`secret`:return t.startsWith(`secret:`)?t:`secret:${t}`;case`call`:return t.startsWith(`flow:`)?t:`flow:${t}`;default:return t}}function T(e,t){return`${e}\0${t}`}function le(e){let t=new Map;for(let n of e){for(let e of n.effects){let r=ce(e.kind,e.resource),i=T(n.flow,r);t.set(i,(t.get(i)??0)+1)}n.parentId}return t}function E(e,t,n){return e.get(T(t,n))??0}function ue(e,t){if(e<=0)return 1;if(t<=1)return 2;let n=e/t;return Math.max(1,Math.min(8,Math.ceil(n*8)))}function D(e){let t=[],n=pe(e);for(let r of e.flows){for(let n of r.causeIds){let i=e.causeById.get(n);if(!i)continue;let a=ae(i);a&&t.push({from:`cause:${i.id}`,to:`flow:${r.id}`,flowId:r.id,layer:a,fromUnit:r.unit,toUnit:r.unit})}for(let i of r.effectRefs){if(i.startsWith(`flow:`)){let e=i.slice(5),n=O(e);t.push({from:`flow:${r.id}`,to:`flow:${e}`,flowId:r.id,ref:i,layer:`call`,fromUnit:r.unit,toUnit:n});continue}let a=S(i);if(!a)continue;let o=C(i)?`external`:de(i,e);if(t.push({from:`flow:${r.id}`,to:i,flowId:r.id,ref:i,layer:a,fromUnit:r.unit,toUnit:o}),a===`messaging`&&i.startsWith(`signal:`)){let a=i.slice(7);for(let o of n.get(a)??[]){let n=e.flowById.get(o);!n||n.id===r.id||t.push({from:`flow:${r.id}`,to:`flow:${n.id}`,flowId:r.id,ref:i,layer:`messaging`,fromUnit:r.unit,toUnit:n.unit})}}}}return t}function de(e,t){let n=t.effectByRef.get(e);if(!n||n.flowIds.length===0)return`shared`;let r=n.flowIds.filter(n=>{let r=t.flowById.get(n);return r?fe(r,e):!1})[0]??n.flowIds[0];return r?O(r):`shared`}function fe(e,t){let n=e.raw.effects;if(!n)return!1;if(t.startsWith(`signal:`)){let e=t.slice(7);return(n.emits??[]).includes(e)}return!!(n.writes??[]).includes(t)}function pe(e){let t=new Map;for(let n of e.flows){let e=n.raw.trigger?.signal;if(!e)continue;let r=t.get(e)??[];r.push(n.id),t.set(e,r)}return t}function O(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function k(e){let t=[];return t.push(...A(e)),t.push(...j(e)),t.push(...M(e)),t.push(...N(e)),t}function A(e){let t=new Map,n=e=>{let n=t.get(e);return n||(n=new Set,t.set(e,n)),n};for(let t of D(e)){if(!t.from.startsWith(`flow:`)||!t.to.startsWith(`flow:`))continue;let e=t.from.slice(5),r=t.to.slice(5);n(e).add(r)}let r=[],i=new Set,a=[],o=new Set,s=e=>{i.add(e),a.push(e),o.add(e);for(let n of t.get(e)??[])if(!i.has(n))s(n);else if(o.has(n)){let e=a.indexOf(n);e!==-1&&r.push([...a.slice(e),n])}a.pop(),o.delete(e)};for(let t of e.flows.map(e=>e.id))i.has(t)||s(t);let c=new Set,l=[];for(let e of r){let t=P(e.slice(0,-1)),n=t.join(`→`);c.has(n)||(c.add(n),l.push({kind:`cycle`,severity:`critical`,title:`Cycle`,detail:`Causal cycle: ${t.join(` → `)}`,nodeIds:t.map(e=>`flow:${e}`)}))}return l}function j(e){if(e.effects.length===0)return[];let t=[...e.effects].filter(e=>e.touchCount>0).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref)),n=t[0];if(!n||n.touchCount<2)return[];let r=t[1]?.touchCount??0;return n.touchCount===r&&t.filter(e=>e.touchCount===n.touchCount).length>1?t.filter(e=>e.touchCount===n.touchCount).map(e=>({kind:`god-node`,severity:`warning`,title:`God node`,detail:`${e.ref} is touched by ${e.touchCount} flows — the most in the system`,nodeIds:[e.ref]})):[{kind:`god-node`,severity:`warning`,title:`God node`,detail:`${n.ref} is touched by ${n.touchCount} flows — the most in the system`,nodeIds:[n.ref]}]}function M(e){let t=[],n=new Set;for(let t of e.effects)t.ref.startsWith(`signal:`)&&n.add(t.ref.slice(7));for(let t of e.flows){for(let e of t.raw.effects?.emits??[])n.add(e);let e=t.raw.trigger?.signal;e&&n.add(e)}for(let r of[...n].sort()){let n=`signal:${r}`,i=e.flows.filter(e=>(e.raw.effects?.emits??[]).includes(r)),a=e.flows.filter(e=>e.raw.trigger?.signal===r);if(i.length===0&&a.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is declared but has no producers and no consumers`,nodeIds:[n]});continue}if(i.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} has consumers but no producer`,nodeIds:[n,...a.map(e=>`flow:${e.id}`)]});continue}a.length===0&&t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is emitted but has no consumers`,nodeIds:[n,...i.map(e=>`flow:${e.id}`)]})}return t}function N(e){let t=[];for(let n of e.effects){if(n.touchCount<2||n.ref.startsWith(`secret:`)||n.ref.startsWith(`channel:`)||n.ref.startsWith(`ai:`))continue;let r=n.flowIds.filter(t=>{let r=e.flowById.get(t);if(!r?.raw.effects)return!1;if(n.ref.startsWith(`signal:`)){let e=n.ref.slice(7);return(r.raw.effects.emits??[]).includes(e)}return(r.raw.effects.writes??[]).includes(n.ref)});if(r.length!==1)continue;let i=r[0];t.push({kind:`spof`,severity:`critical`,title:`Single point of failure`,detail:`${n.ref} is touched by ${n.touchCount} flows but written/emitted by only ${i}`,nodeIds:[n.ref,`flow:${i}`]})}return t}function P(e){if(e.length===0)return[];let t=[...e],n=t.join(`\0`);for(let r=1;r<e.length;r++){let i=[...e.slice(r),...e.slice(0,r)],a=i.join(`\0`);a<n&&(t=i,n=a)}return t}function F(e,t={}){let n=t.focus??null,r=t.depth===2?2:1,i=t.layers??_,a=le(t.runs??[]),o=D(e),s=k(e),c=oe(e);return n?L({graph:e,declared:o,traffic:a,focus:n,depth:r,layers:i,findings:s,crossings:c}):I({graph:e,declared:o,traffic:a,layers:i,findings:s,crossings:c})}function I(e){let{graph:t,declared:n,traffic:r,layers:i,findings:a,crossings:o}=e,s=[...new Set(t.flows.map(e=>e.unit))].sort().map(e=>({id:`unit:${e}`,kind:`unit`,label:e,unit:e,insideBoundary:!0,flowCount:t.flows.filter(t=>t.unit===e).length}));for(let e of se(t))s.push({id:e,kind:`external`,label:w(e),layer:`external`,insideBoundary:!1});let c=new Map;for(let e of n){if(!V(e.layer,i))continue;let t=`unit:${e.fromUnit}`,n=null;if(e.toUnit===`external`||C(e.to))n=e.ref??e.to;else if(e.fromUnit!==e.toUnit)n=`unit:${e.toUnit}`;else continue;if(t===n)continue;let a=`${t}\0${n}\0${e.layer}`,o=e.ref?E(r,e.flowId,e.ref):0,s=c.get(a);s?s.traversals+=o:c.set(a,{from:t,to:n,layer:e.layer,traversals:o,declared:!0})}let l=H(c,!0);return{nodes:U(s),edges:l,boundaryCrossingCount:o,findings:a,focus:null,depth:1,layers:i}}function L(e){let{graph:t,declared:n,traffic:r,focus:i,depth:a,layers:o,findings:s,crossings:c}=e,l=z(t,n,i,a),u=[];for(let e of l){let r=B(t,n,i,e,a);if(e.startsWith(`unit:`)){let n=e.slice(5);u.push({id:e,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:t.flows.filter(e=>e.unit===n).length,focused:e===i,depth:r});continue}if(e.startsWith(`flow:`)){let n=e.slice(5),a=t.flowById.get(n);u.push({id:e,kind:`flow`,label:n,unit:a?.unit??O(n),insideBoundary:!0,focused:e===i,depth:r});continue}if(e.startsWith(`cause:`)){let n=e.slice(6),a=t.causeById.get(n),s=a?.kind===`cron`||a?.kind===`every`?`time`:a?.kind===`signal`?`messaging`:void 0;if(!s||!o[s])continue;u.push({id:e,kind:`resource`,label:a?.label??n,layer:s,insideBoundary:!0,focused:e===i,depth:r});continue}u.push({id:e,kind:C(e)?`external`:`resource`,label:w(e),layer:C(e)?`external`:e.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(e),focused:e===i,depth:r})}u.some(e=>e.id===i)||u.push(...R(t,i));let d=new Map,f=new Set(u.map(e=>e.id));for(let e of n){if(!V(e.layer,o))continue;let t=e.from,n=e.to;if(!f.has(t)||!f.has(n))continue;let i=`${t}\0${n}\0${e.layer}`,a=e.ref?E(r,e.flowId,e.ref):0,s=d.get(i);s?s.traversals+=a:d.set(i,{from:t,to:n,layer:e.layer,traversals:a,declared:!0})}return{nodes:U(u),edges:H(d,!1),boundaryCrossingCount:c,findings:s,focus:i,depth:a,layers:o}}function R(e,t){if(t.startsWith(`unit:`)){let n=t.slice(5);return[{id:t,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:e.flows.filter(e=>e.unit===n).length,focused:!0,depth:0}]}if(t.startsWith(`flow:`)){let n=t.slice(5);return[{id:t,kind:`flow`,label:n,unit:e.flowById.get(n)?.unit??O(n),insideBoundary:!0,focused:!0,depth:0}]}return[{id:t,kind:C(t)?`external`:`resource`,label:w(t),layer:C(t)?`external`:t.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(t),focused:!0,depth:0}]}function z(e,t,n,r){let i=new Set([n]);if(n.startsWith(`unit:`)){let t=n.slice(5);for(let n of e.flows)n.unit===t&&i.add(`flow:${n.id}`)}let a=new Set(i);for(let e=0;e<r;e++){let e=new Set;for(let n of t){let t=n.from,r=n.to;a.has(t)&&e.add(r),a.has(r)&&e.add(t);for(let n of[t,r]){if(!n.startsWith(`flow:`))continue;let t=`unit:${O(n.slice(5))}`;a.has(n)&&e.add(t),a.has(t)&&e.add(n)}}for(let t of e)i.add(t);a=e}return i}function B(e,t,n,r,i){if(n===r)return 0;let a=new Set([n]),o=new Set([n]);for(let n=1;n<=i;n++){let i=new Set;for(let e of t){let t=e.from,s=e.to;for(let[e,c]of[[t,s],[s,t]])if(o.has(e)){if(c===r)return n;a.has(c)||(a.add(c),i.add(c))}}for(let t of o){if(t.startsWith(`flow:`)){let e=`unit:${O(t.slice(5))}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}if(t.startsWith(`unit:`)){let o=t.slice(5);for(let t of e.flows){if(t.unit!==o)continue;let e=`flow:${t.id}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}}}o=i}return i}function V(e,t){return e===`call`||t[e]}function H(e,t){let n=Math.max(0,...[...e.values()].map(e=>e.traversals));return[...e.values()].map(e=>({id:`${e.from}->${e.to}:${e.layer}`,from:e.from,to:e.to,layer:e.layer,declared:e.declared,traversals:e.traversals,dashed:e.declared&&e.traversals===0,thickness:ue(e.traversals,n),aggregated:t})).sort((e,t)=>e.id.localeCompare(t.id))}function U(e){let t=new Map;for(let n of e)t.has(n.id)||t.set(n.id,n);return[...t.values()].sort((e,t)=>e.id.localeCompare(t.id))}function W(e){let t={...e.dimensions??{}};return t.flow===void 0&&(t.flow=e.flow),t.unit===void 0&&(t.unit=e.unit??null),t.trigger===void 0&&(t.trigger=e.trigger),t.plane===void 0&&(t.plane=e.plane),t.tenant===void 0&&(t.tenant=e.tenant??null),t.principal===void 0&&(t.principal=e.principal??null),t.cache===void 0&&(t.cache=e.cache??`none`),t.duration_ms===void 0&&(t.duration_ms=e.durationMs),t.error_code===void 0&&e.error&&(t.error_code=e.error),{id:e.id,parentId:e.parentId??null,flow:e.flow,unit:e.unit??null,trigger:e.trigger,plane:e.plane,tenant:e.tenant??null,principal:e.principal??null,gates:e.gates??[],cache:e.cache??`none`,replica:e.replica??null,replicaLagMs:e.replicaLagMs??null,cost:e.cost??null,promptVersion:e.promptVersion??null,buildVersion:e.buildVersion??null,startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs,error:e.error??null,effects:e.effects??[],logs:e.logs??[],dimensions:t}}function me(e){return{id:e.id,...e.parentId?{parentId:e.parentId}:{},flow:e.flow,...e.unit?{unit:e.unit}:{},trigger:e.trigger,plane:e.plane,tenant:e.tenant,principal:e.principal,gates:e.gates,cache:e.cache,...e.replica?{replica:e.replica}:{},...e.replicaLagMs==null?{}:{replicaLagMs:e.replicaLagMs},...e.cost==null?{}:{cost:e.cost},...e.promptVersion==null?{}:{promptVersion:e.promptVersion},...e.buildVersion?{buildVersion:e.buildVersion}:{},error:e.error?{code:e.error}:null,effects:e.effects,logs:e.logs,durationMs:e.durationMs,startedAt:e.startedAt,endedAt:e.endedAt,dimensions:{...e.dimensions}}}var G=e(s(),1),K={x:32,y:40,width:440,height:300};function he(e){let t=e.filter(e=>e.insideBoundary),n=e.filter(e=>!e.insideBoundary),r=new Map,i=Math.max(1,Math.ceil(Math.sqrt(t.length))),a=K.width/(i+1),o=Math.max(1,Math.ceil(t.length/i)),s=K.height/(o+1);return t.forEach((e,t)=>{let n=t%i,o=Math.floor(t/i);r.set(e.id,{id:e.id,x:K.x+a*(n+1),y:K.y+s*(o+1)})}),n.forEach((e,t)=>{r.set(e.id,{id:e.id,x:K.x+K.width+96,y:K.y+48+t*56})}),r}var q={read:`none`,write:`reversible`,emit:`deferred`,send:`irreversible`,ask:`irreversible`,secret:`capability`,call:`portal`};function ge(e){return q[e]}Object.entries(q).map(([e,t])=>({kind:e,reversibility:t}));function _e(e,t={}){if(!e)return[];let n=t.touchCounts,r=t.emitFanOut,i=[],a=(e,a,o)=>{for(let s of o??[])i.push({tier:e,kind:a,ref:s,reversibility:ge(a),touchCount:n?.get(s)??1,fanOut:a===`emit`?r?.get(s)??0:void 0,transitive:t.transitive})};return a(`reads`,`read`,e.reads),a(`writes`,`write`,e.writes),a(`emits`,`emit`,e.emits),a(`external`,`send`,e.sends),a(`external`,`ask`,e.asks),a(`capabilities`,`secret`,e.secrets),i}function J(e){return e?(e.sends?.length??0)>0||(e.asks?.length??0)>0?`external`:(e.secrets?.length??0)>0?`capabilities`:(e.emits?.length??0)>0?`emits`:(e.writes?.length??0)>0?`writes`:(e.reads?.length??0)>0?`reads`:`none`:`none`}function Y(e){return ve(J(e))}function ve(e){return e===`external`}var ye=[`reads`,`writes`,`emits`,`external`,`capabilities`],be={reads:`Reads`,writes:`Writes`,emits:`Emits`,external:`External`,capabilities:`Capabilities`};function xe(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function Se(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(t+1)}function Ce(e,t,n){let r=[];if(e?.http){let n=`http:${e.http.method}:${e.http.path}`;r.push({id:n,kind:`http`,label:`${e.http.method} ${e.http.path}`,flowIds:[t]})}if(e?.signal&&r.push({id:`signal:${e.signal}`,kind:`signal`,label:e.signal,flowIds:[t]}),e?.cron&&r.push({id:`cron:${e.cron}`,kind:`cron`,label:e.cron,flowIds:[t]}),e?.every&&r.push({id:`every:${e.every}`,kind:`every`,label:`every ${e.every}`,flowIds:[t]}),e?.cdc){let n=e.cdc.column?`.${e.cdc.column}`:``,i=`cdc:${e.cdc.table}${n}`;r.push({id:i,kind:`cdc`,label:`cdc ${e.cdc.table}${n}`,flowIds:[t]})}if(r.length===0)for(let e of n)r.push({id:`caller:${e}`,kind:`caller`,label:e,flowIds:[t]});return r}function X(e){if(!e)return[];let t=[];for(let n of e.reads??[])t.push(n);for(let n of e.writes??[])t.push(n);for(let n of e.emits??[])t.push(`signal:${n}`);for(let n of e.sends??[])t.push(`channel:${n}`);for(let n of e.asks??[])t.push(`ai:${n}`);for(let n of e.secrets??[])t.push(`secret:${n}`);for(let n of e.calls??[])t.push(`flow:${n}`);return t}function Z(e){return!e||typeof e==`string`?null:e}function we(e){return e.errors?Array.isArray(e.errors)?[...e.errors]:Object.keys(e.errors):[]}function Q(e){let t=e?.flows??{},n=Object.keys(t).sort(),r=new Map;for(let e of n){let n=t[e]?.effects?.calls??[];for(let t of n){let n=r.get(t)??[];n.push(e),r.set(t,n)}}let i=new Map;for(let e of n){let n=t[e]?.trigger?.signal;if(!n)continue;let r=i.get(n)??[];r.push(e),i.set(n,r)}let a=new Map,o=new Map,s=[];for(let e of n){let n=t[e];if(!n)continue;let c=r.get(e)??[],l=Ce(n.trigger,e,c);for(let t of l){let n=a.get(t.id);n?a.set(t.id,{...n,flowIds:[...new Set([...n.flowIds,e])]}):a.set(t.id,t)}let u=new Map,d=new Map;for(let e of n.effects?.emits??[])d.set(e,i.get(e)?.length??0);let f=_e(n.effects,{touchCounts:u,emitFanOut:d}),p=X(n.effects);for(let t of f){let n=t.kind===`emit`?`signal:${t.ref}`:t.kind===`send`?`channel:${t.ref}`:t.kind===`ask`?`ai:${t.ref}`:t.kind===`secret`?`secret:${t.ref}`:t.kind===`call`?`flow:${t.ref}`:t.ref,r=o.get(n);r?(r.flowIds.push(e),r.fanOut=Math.max(r.fanOut,t.fanOut??0)):o.set(n,{tier:t.tier,flowIds:[e],fanOut:t.fanOut??0})}s.push({id:e,unit:xe(e),action:Se(e),plane:n.plane??`user`,causeIds:l.map(e=>e.id),effectRefs:p,effects:f,peakTier:J(n.effects),external:Y(n.effects),flags:{durable:n.durable===!0,live:n.live===!0,cached:n.cache!==void 0&&n.cache!==!1,costsMoney:(n.cost?.estimatePerCall??0)>0,readsSecret:(n.effects?.secrets?.length??0)>0,touchesPii:n.pii!==void 0||n.allowPii===!0,external:Y(n.effects)},inSchema:Z(n.in),outSchema:Z(n.out),errorNames:we(n),source:n.source,deprecated:!!n.deprecated,raw:n})}if(e?.stores){for(let t of Object.values(e.stores))if(t.facet===`sql`&&t.tables)for(let e of Object.keys(t.tables)){let t=`sql:${e}`;o.has(t)||o.set(t,{tier:`reads`,flowIds:[],fanOut:0})}}if(e?.signals)for(let t of Object.keys(e.signals)){let e=`signal:${t}`;o.has(e)||o.set(e,{tier:`emits`,flowIds:[],fanOut:0})}if(e?.channels)for(let t of Object.keys(e.channels)){let e=`channel:${t}`;o.has(e)||o.set(e,{tier:`external`,flowIds:[],fanOut:0})}if(e?.vault)for(let t of Object.keys(e.vault)){let e=`secret:${t}`;o.has(e)||o.set(e,{tier:`capabilities`,flowIds:[],fanOut:0})}let c=[...a.values()].sort((e,t)=>e.label.localeCompare(t.label)),l=[...o.entries()].map(([e,t])=>({ref:e,tier:t.tier,flowIds:[...new Set(t.flowIds)].sort(),touchCount:new Set(t.flowIds).size,fanOut:t.fanOut})).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref));return{causes:c,flows:s,effects:l,causeById:new Map(c.map(e=>[e.id,e])),flowById:new Map(s.map(e=>[e.id,e])),effectByRef:new Map(l.map(e=>[e.ref,e]))}}function Te(e,t){let n=null;if(t.sel===`cause`&&t.cause){let r=e.causeById.get(t.cause);n=new Set(r?.flowIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect);n=new Set(r?.flowIds??[])}else t.sel===`flow`&&t.flow&&(n=new Set([t.flow]));return e.flows.map(e=>{let r=n===null||n.has(e.id),i=Oe(e,t.q),a=!t.unit||e.unit===t.unit,o=r&&i&&a;return{...e,match:o,related:r}})}function Ee(e,t){let n=null;if(t.sel===`flow`&&t.flow){let r=e.flowById.get(t.flow);n=new Set(r?.causeIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect),i=new Set;for(let t of r?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.causeIds??[])i.add(e)}n=i}return e.causes.map(e=>{let r=n===null||n.has(e.id),i=!t.q||e.label.toLowerCase().includes(t.q.toLowerCase())||e.id.toLowerCase().includes(t.q.toLowerCase());return{...e,match:r&&i,related:r}})}function De(e,t,n={}){let r=null;if(t.sel===`flow`&&t.flow){let n=e.flowById.get(t.flow);r=new Set(n?.effectRefs??[])}else if(t.sel===`cause`&&t.cause){let n=e.causeById.get(t.cause),i=new Set;for(let t of n?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.effectRefs??[])i.add(e)}r=i}let i=n.ubiquitousThreshold??8;return e.effects.map(e=>{let a=r===null||r.has(e.ref),o=!t.q||e.ref.toLowerCase().includes(t.q.toLowerCase()),s=!n.hideUbiquitous||e.touchCount<i||r!==null;return{...e,match:a&&o&&s,related:a}})}function Oe(e,t){if(!t?.trim())return!0;let n=t.toLowerCase();return e.id.toLowerCase().includes(n)||e.unit.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)}var $=l();function ke(){let e=f({from:`/architecture`}),t=n({from:`/architecture`}),i=e=>{t({search:ne(e),replace:!0})},a=r({queryKey:[`console.manifest.get`],queryFn:async()=>{let e=await o.manifestGet();if(e.error)throw Error(e.error.code);return e.data.manifest}}),s=r({queryKey:[`console.runs.list`],queryFn:async()=>{let e=await o.runsList();if(e.error)throw Error(e.error.code);return e.data.runs.map(W)},refetchInterval:1e4}),l=(0,G.useMemo)(()=>Q(a.data),[a.data]),d=y(e),p=(0,G.useMemo)(()=>F(l,{focus:e.focus??null,depth:e.depth,layers:y(e),runs:s.data??[]}),[l,e.focus,e.depth,e.data,e.messaging,e.time,e.external,s.data]),m=(0,G.useMemo)(()=>he(p.nodes),[p.nodes]);return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-4 border-b border-[var(--oke-line)] px-6 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`text-xs uppercase tracking-[0.2em] text-[var(--oke-muted)]`,children:`Architecture`}),(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`System shape`}),(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Clustered by unit · typed layers · traffic from Runs`})]}),(0,$.jsxs)(`p`,{className:`ml-auto font-mono text-sm`,role:`status`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Boundary crossings`}),` `,(0,$.jsx)(`span`,{className:`text-lg font-semibold tabular-nums`,children:p.boundaryCrossingCount})]})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0 lg:flex-row`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-4 border-b border-[var(--oke-line)] px-6 py-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Element layers`}),(0,$.jsx)(`span`,{className:`text-xs uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:`Layers`}),h.map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:d[t],onChange:n=>i(x(e,t,n.target.checked)),"aria-label":`${g[t]} layer`}),g[t]]},t))]}),e.focus?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Focus depth`}),(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:`Depth`}),[1,2].map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-1.5 text-sm`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`arch-depth`,checked:e.depth===t,onChange:()=>i(ie(e,t))}),t]},t))]}),(0,$.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>i(re(e)),children:`Clear focus`})]}):(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a unit to focus at depth 1–2`})]}),(0,$.jsxs)(`section`,{"aria-label":`System diagram`,className:`min-h-0 flex-1 overflow-auto px-4 py-4`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`mb-4 overflow-x-auto`,children:(0,$.jsxs)(`svg`,{className:`h-auto w-full max-w-5xl text-[var(--oke-fg)]`,viewBox:`0 0 640 380`,children:[(0,$.jsx)(`rect`,{x:K.x,y:K.y,width:K.width,height:K.height,fill:`color-mix(in oklab, var(--oke-fg) 3%, transparent)`,stroke:`var(--oke-muted)`,strokeDasharray:`8 5`,strokeWidth:1.5,rx:4}),(0,$.jsxs)(`text`,{x:K.x+12,y:K.y+18,className:`fill-[var(--oke-muted)]`,fontSize:11,fontFamily:`var(--oke-mono)`,children:[`System boundary · `,p.boundaryCrossingCount,` crossings`]}),p.edges.map(e=>{let t=m.get(e.from),n=m.get(e.to);return!t||!n?null:(0,$.jsx)(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:e.layer===`external`?`var(--oke-external)`:`var(--oke-muted)`,strokeWidth:e.thickness,strokeDasharray:e.dashed?`6 4`:void 0,opacity:e.dashed?.55:.9},e.id)}),p.nodes.map(e=>{let t=m.get(e.id);if(!t)return null;let n=e.kind===`unit`?28:22;return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`circle`,{cx:t.x,cy:t.y,r:n,fill:e.focused?`var(--oke-accent)`:e.insideBoundary?`var(--oke-bg)`:`color-mix(in oklab, var(--oke-external) 25%, var(--oke-bg))`,stroke:e.insideBoundary?`var(--oke-fg)`:`var(--oke-external)`,strokeWidth:e.focused?2.5:1.25}),(0,$.jsx)(`text`,{x:t.x,y:t.y+4,textAnchor:`middle`,fontSize:10,fontFamily:`var(--oke-mono)`,className:`fill-[var(--oke-fg)]`,children:Ae(e.label,12)})]},e.id)})]})}),(0,$.jsx)(`ul`,{"aria-label":`Nodes`,className:`flex flex-wrap gap-2 border-t border-[var(--oke-line)] pt-4`,children:p.nodes.map(t=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t.focused===!0,className:u(`inline-flex min-h-8 items-center gap-2 border px-3 text-sm`,t.focused?`border-[var(--oke-accent)] text-[var(--oke-fg)]`:`border-[var(--oke-line)] text-[var(--oke-muted)]`),onClick:()=>i(b(e,t.id)),children:[(0,$.jsx)(`span`,{children:t.label}),t.kind===`unit`&&t.flowCount!==void 0?(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:t.flowCount}):null,t.insideBoundary?null:(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-external)]`,children:`external`})]})},t.id))}),(0,$.jsx)(`ul`,{className:`sr-only`,"aria-label":`Edges`,children:p.edges.map(e=>(0,$.jsxs)(`li`,{children:[e.from,` → `,e.to,e.dashed?` (declared, never traversed)`:` · ${e.traversals} traversals`,` · ${e.layer}`]},e.id))})]})]}),(0,$.jsxs)(`aside`,{"aria-label":`Findings`,className:`w-full shrink-0 overflow-auto border-t border-[var(--oke-line)] lg:w-80 lg:border-l lg:border-t-0`,children:[(0,$.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium`,children:`Findings`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:`Pathologies from the graph as data`})]}),p.findings.length===0?(0,$.jsx)(`p`,{className:`px-5 pb-4 text-sm text-[var(--oke-muted)]`,children:`No pathologies detected.`}):(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--oke-line)] border-t border-[var(--oke-line)]`,children:p.findings.map((t,n)=>(0,$.jsxs)(`li`,{className:`px-5 py-3`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(`span`,{className:u(`inline-block size-1.5 rounded-full`,t.severity===`critical`?`bg-[var(--oke-danger)]`:`bg-[var(--oke-external)]`),"aria-hidden":!0}),t.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:t.detail}),t.nodeIds[0]?(0,$.jsx)(`button`,{type:`button`,className:`mt-2 min-h-8 text-sm text-[var(--oke-accent)] underline-offset-2 hover:underline`,onClick:()=>i(b(e,t.nodeIds[0])),children:`Focus`}):null]},`${t.kind}-${n}`))})]})]})]})}function Ae(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}var je=t({default:()=>ke});export{De as a,W as c,te as d,Ee as i,me as l,Q as n,be as o,Te as r,ye as s,je as t,A as u};
@@ -0,0 +1 @@
1
+ import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,Z as i,a,b as o,d as s,et as c,g as l,nt as u,o as d,r as f,tt as p,u as m,w as h,y as g}from"./panel-access-Dd37LU2c.js";var _=g({q:o().optional(),template:o().optional(),locale:o().optional(),view:l([`inbox`,`outcomes`,`receipts`,`suppression`,`preview`]).optional()});function v(e){let t=_.safeParse(e);return t.success?t.data:{}}function y(e){let t={};return e.q&&(t.q=e.q),e.template&&(t.template=e.template),e.locale&&(t.locale=e.locale),e.view&&(t.view=e.view),t}function b(e,t){return{...e,template:t}}var x={"suppressed/opted-out":`Suppressed · opted out`,"suppressed/prior-bounce":`Suppressed · prior hard bounce`,"blocked/invalid-address":`Blocked · invalid address`,"soft-bounce":`Soft bounce`,"hard-bounce":`Hard bounce`,"provider-error":`Provider error`,"delivered-then-complained":`Delivered then complained`},S={correct:`correct`,retry:`retry`,suppress:`suppress`,review:`review`};function C(e){return[...e].sort((e,t)=>t.weight===e.weight?t.count-e.count:t.weight-e.weight)}function w(e){return e.weight>=10&&e.count>0}function T(e){return e.filter(e=>e.state===`delivered-then-complained`&&w(e)).map(e=>({state:`delivered-then-complained`,count:e.count,verdict:e.verdict,weight:e.weight}))}function E(e){return e.totalCount===0?`No sends in the last week`:e.chainExample?`${e.chainExample} · ${e.summary}`:e.summary}function D(e){return e.length===0?`default`:e.join(` → `)}function O(e={production:!0}){return e.production?{kind:`typed`,phrase:`SEND`,requireReason:!0}:{kind:`undo`,windowMs:f}}function k(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||e.medium.toLowerCase().includes(n)||e.locales.some(e=>e.toLowerCase().includes(n))):e}var A=e(u(),1),j=p();function M(){let e=h({from:`/channels`}),t=n({from:`/channels`}),o=c(),[l,u]=(0,A.useState)(``),[f,p]=(0,A.useState)(``),[g,_]=(0,A.useState)(`test@example.com`),[v,T]=(0,A.useState)(e.locale??``),[M,N]=(0,A.useState)(null),P=e=>{t({search:y(e),replace:!0})},F=r({queryKey:[`console.channel.list`],queryFn:async()=>{let e=await s.channelsList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),I=F.data,L=(0,A.useMemo)(()=>k(I?.templates??[],e.q??``),[I?.templates,e.q]),R=L.find(t=>t.name===e.template)??I?.templates.find(t=>t.name===e.template),z=C(I?.outcomes??[]),B=O({production:I?.production??!0}),V=r({queryKey:[`console.channel.preview`,R?.name,v||e.locale],enabled:!!R,queryFn:async()=>{if(!R)return null;let t=await s.channelPreview({template:R.name,locale:v||e.locale||R.locales[0]});if(t.error)throw Error(t.error.code);return t.data}}),H=r({queryKey:[`console.channel.verifyAuth`,R?.from],enabled:!!R?.from,queryFn:async()=>{if(!R?.from)return null;let e=await s.channelVerifyAuth({from:R.from});if(e.error)throw Error(e.error.code);return e.data}});(0,A.useEffect)(()=>{u(``),p(``),N(null),R?.locales[0]&&!v&&T(R.locales[0])},[R?.name]);let U=i({mutationFn:async()=>{if(!R)throw Error(`No template selected`);if(B.kind===`typed`){let e=a({typed:l,reason:f,phrase:B.phrase});if(e)throw Error(e.typed??e.reason??`Confirm required`)}let e=await s.channelSendTest({template:R.name,to:g,locale:v||R.locales[0],confirmation:B.kind===`typed`?B.phrase:void 0,reason:B.kind===`typed`?f:void 0});if(e.error)throw Error(e.error.code);return e.data},onSuccess:e=>{N(e.ok?`Sent · ${e.messageId}${e.chain?` · ${e.chain}`:``}`:`Failed · ${e.status}`),o.invalidateQueries({queryKey:[`console.channel.list`]}),u(``),p(``)},onError:e=>{N(e instanceof Error?e.message:String(e))}});return(0,j.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,j.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,j.jsx)(`h1`,{className:`text-lg text-[var(--oke-fg)]`,children:`Channels`}),(0,j.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:I?.face===`inbox`?`Dev inbox — all media land here instead of sending`:`Deliverability — seven states of did not arrive`}),(0,j.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Filter templates`,(0,j.jsx)(`input`,{"aria-label":`Filter templates`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:e.q??``,onChange:t=>P({...e,q:t.target.value})})]})]}),(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,j.jsxs)(`section`,{"aria-label":`Templates`,className:`w-64 shrink-0 overflow-y-auto border-r border-[var(--oke-line)] p-3`,children:[(0,j.jsx)(`h2`,{className:`mb-2 text-xs tracking-wide text-[var(--oke-muted)]`,children:`Templates`}),F.isLoading?(0,j.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`}):(0,j.jsx)(`ul`,{className:`space-y-1`,children:L.map(t=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===e.template,className:m(`flex min-h-8 w-full items-center justify-between px-2 text-left text-sm`,t.name===e.template?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>P(b(e,t.name)),children:[(0,j.jsx)(`span`,{children:t.name}),(0,j.jsx)(`span`,{className:`font-mono text-xs`,children:t.medium})]})},t.name))})]}),(0,j.jsxs)(`main`,{id:`channels-main`,className:`min-w-0 flex-1 overflow-y-auto p-4`,children:[I?.face===`inbox`?(0,j.jsxs)(`section`,{"aria-label":`Inbox`,className:`mb-8`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Inbox`}),(0,j.jsxs)(`ul`,{className:`mt-3 space-y-2`,children:[(I.inbox??[]).map(e=>(0,j.jsxs)(`li`,{className:`border-b border-[var(--oke-line)] pb-2 text-sm`,children:[(0,j.jsxs)(`div`,{className:`flex gap-2 text-[var(--oke-muted)]`,children:[(0,j.jsx)(`span`,{children:e.medium}),(0,j.jsx)(`span`,{children:e.toMasked}),e.template?(0,j.jsx)(`span`,{children:e.template}):null]}),(0,j.jsx)(`p`,{className:`mt-1 text-[var(--oke-fg)]`,children:e.subject??e.text??`(empty)`})]},e.id)),(I.inbox??[]).length===0?(0,j.jsx)(`li`,{className:`text-sm text-[var(--oke-muted)]`,children:`No messages yet`}):null]})]}):null,(0,j.jsxs)(`section`,{"aria-label":`Did not arrive`,className:`mb-8`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Did not arrive`}),(0,j.jsxs)(`table`,{className:`mt-3 w-full text-left text-sm`,children:[(0,j.jsx)(`caption`,{className:`sr-only`,children:`Seven-state taxonomy with verdicts`}),(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,j.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`State`}),(0,j.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Count`}),(0,j.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Verdict`})]})}),(0,j.jsx)(`tbody`,{children:z.map(e=>(0,j.jsxs)(`tr`,{className:m(`border-t border-[var(--oke-line)]`,w(e)&&`text-[var(--oke-fg)]`),children:[(0,j.jsx)(`th`,{scope:`row`,className:`py-2 font-normal`,children:x[e.state]}),(0,j.jsx)(`td`,{className:`py-2`,children:e.count}),(0,j.jsx)(`td`,{className:`py-2`,children:S[e.verdict]})]},e.state))})]})]}),(0,j.jsxs)(`section`,{"aria-label":`Fallback chains`,className:`mb-8`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Fallback`}),(0,j.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,role:`status`,children:I?E(I.fallback):`—`})]}),R?(0,j.jsxs)(`section`,{"aria-label":`Template detail`,className:`mb-8`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:R.name}),(0,j.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:[`From `,R.from??`unset`,` · Locales`,` `,R.locales.join(`, `)||`none`]}),R.from?(0,j.jsxs)(`section`,{"aria-label":`Email authentication`,className:`mt-4`,children:[(0,j.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`SPF / DKIM / DMARC`}),H.data?(0,j.jsxs)(`ul`,{className:`mt-2 space-y-1 text-sm text-[var(--oke-muted)]`,children:[(0,j.jsxs)(`li`,{children:[`SPF: `,H.data.spf]}),(0,j.jsxs)(`li`,{children:[`DKIM: `,H.data.dkim]}),(0,j.jsxs)(`li`,{children:[`DMARC: `,H.data.dmarc]}),(0,j.jsx)(`li`,{className:`font-mono text-xs`,children:H.data.domain})]}):(0,j.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,children:`Checking…`})]}):null,(0,j.jsxs)(`section`,{"aria-label":`Locale preview`,className:`mt-4`,children:[(0,j.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Preview`}),(0,j.jsxs)(`label`,{className:`mt-2 block text-sm text-[var(--oke-muted)]`,children:[`Locale`,(0,j.jsx)(`select`,{"aria-label":`Preview locale`,className:`mt-1 block border border-[var(--oke-line)] bg-transparent px-2 py-1`,value:v||R.locales[0]||`en`,onChange:e=>T(e.target.value),children:(R.locales.length>0?R.locales:[`en`]).map(e=>(0,j.jsx)(`option`,{value:e,children:e},e))})]}),V.data?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`p`,{className:`mt-2 text-xs text-[var(--oke-muted)]`,children:[`Locale chain:`,` `,D(V.data.localeChain)]}),(0,j.jsxs)(`div`,{className:`mt-2 max-w-prose border border-[var(--oke-line)] p-3 text-sm text-[var(--oke-fg)]`,dir:V.data.dir,lang:V.data.locale,children:[V.data.subject?(0,j.jsx)(`p`,{className:`mb-2 font-medium`,children:V.data.subject}):null,(0,j.jsx)(`p`,{children:V.data.text??V.data.html})]})]}):null]}),(0,j.jsxs)(`section`,{"aria-label":`Send test`,className:`mt-6`,children:[(0,j.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Send test`}),(0,j.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,role:`status`,children:`Real send to a designated recipient — not a dry run`}),(0,j.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Recipient`,(0,j.jsx)(`input`,{"aria-label":`Test recipient`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:g,onChange:e=>_(e.target.value)})]}),B.kind===`typed`?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Type `,B.phrase,` to confirm`,(0,j.jsx)(`input`,{"aria-label":`Type ${B.phrase} to confirm`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:l,onChange:e=>u(e.target.value),autoComplete:`off`})]}),(0,j.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Reason`,(0,j.jsx)(`input`,{"aria-label":`Reason for send test`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:f,onChange:e=>p(e.target.value)})]})]}):null,(0,j.jsx)(`div`,{className:`mt-3`,children:(0,j.jsx)(d,{type:`button`,onClick:()=>U.mutate(),disabled:U.isPending||!g.trim(),children:`Send test`})}),M?(0,j.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,role:`status`,children:M}):null]})]}):(0,j.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a template to preview and send a test.`}),(0,j.jsxs)(`section`,{"aria-label":`Suppression list`,className:`mb-8`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Suppression`}),(0,j.jsxs)(`ul`,{className:`mt-3 space-y-1 text-sm text-[var(--oke-muted)]`,children:[(I?.suppression??[]).map(e=>(0,j.jsxs)(`li`,{children:[e.subjectMasked,` · `,e.reason,` · `,e.medium]},`${e.subjectMasked}-${e.reason}-${e.at}`)),(I?.suppression??[]).length===0?(0,j.jsx)(`li`,{children:`Empty`}):null]})]}),(0,j.jsxs)(`section`,{"aria-label":`Recent receipts`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Receipts`}),(0,j.jsxs)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:[(I?.receipts??[]).map(e=>(0,j.jsxs)(`li`,{className:`border-b border-[var(--oke-line)] pb-2 text-[var(--oke-muted)]`,children:[(0,j.jsx)(`span`,{className:`text-[var(--oke-fg)]`,children:e.template}),` → `,e.toMasked,` · `,e.status,e.chain?` · ${e.chain}`:``,e.localeChain.length>0?(0,j.jsxs)(`span`,{className:`block text-xs`,children:[`Locale: `,D(e.localeChain)]}):null]},e.id)),(I?.receipts??[]).length===0?(0,j.jsx)(`li`,{children:`No receipts yet`}):null]})]})]})]})]})}var N=t({default:()=>M});export{T as n,v as r,N as t};
@@ -0,0 +1 @@
1
+ import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,Z as i,a,b as o,c as s,d as c,et as l,g as u,nt as d,o as f,r as p,tt as m,u as h,w as g,y as _}from"./panel-access-Dd37LU2c.js";var v=_({q:o().optional(),cron:o().optional(),wake:o().optional(),action:u([`run`,`edit`]).optional()});function y(e){let t=v.safeParse(e);return t.success?t.data:{}}function b(e){let t={};return e.q&&(t.q=e.q),e.cron&&(t.cron=e.cron),e.wake&&(t.wake=e.wake),e.action&&(t.action=e.action),t}function x(e,t){return{...e,cron:t,wake:void 0,action:void 0}}function S(e,t){return{...e,wake:t,cron:void 0,action:void 0}}function C(e,t){let n=t+1440*60*1e3;return e.filter(e=>e.at>=t&&e.at<n).slice().sort((e,t)=>e.at-t.at||e.name.localeCompare(t.name))}function w(e,t){let n=e-t;if(n<0)return`past`;if(n<6e4)return`in ${Math.round(n/1e3)}s`;if(n<36e5)return`in ${Math.round(n/6e4)}m`;if(n<864e5){let e=Math.floor(n/36e5),t=Math.round(n%36e5/6e4);return t>0?`in ${e}h ${t}m`:`in ${e}h`}return new Date(e).toISOString()}function ee(e,t){return e===0?`Nothing waiting`:`${e} sleeping — ${t.slice(0,4).map(e=>`${e.count} ${e.label}`).join(`, `)}`}function T(e){if(e<=0)return`due`;if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<48){let e=n%60;return e>0?`${r}h ${e}m`:`${r}h`}return`${Math.floor(r/24)}d`}function E(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.label.toLowerCase().includes(n)||e.flow.toLowerCase().includes(n)||e.runId.toLowerCase().includes(n)||(e.step?.toLowerCase().includes(n)??!1)):e}function D(e){return{drift:e.driftMs==null?`drift unknown`:`drift ${k(e.driftMs)}`,overdue:e.overdue?`overdue`:`on time`,missedWithPolicy:`${e.missedRuns} missed · catch-up ${e.catchUp}`,lease:e.leaderInstanceId?`lease ${e.leaderInstanceId}`:`no lease`}}function O(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||(e.effectiveCron?.toLowerCase().includes(n)??!1)||(e.effectiveEvery?.toLowerCase().includes(n)??!1)||e.flowIds.some(e=>e.toLowerCase().includes(n))):e}function k(e){let t=e>=0?`+`:`-`,n=Math.abs(e);return n<1e3?`${t}${n}ms`:n<6e4?`${t}${Math.round(n/1e3)}s`:`${t}${Math.round(n/6e4)}m`}function A(e){return e.filter(e=>e.health.overdue).map(e=>({name:e.name,driftMs:e.health.driftMs,missedRuns:e.health.missedRuns,...e.nextRunAt===void 0?{}:{nextRunAt:e.nextRunAt},flowIds:e.flowIds})).sort((e,t)=>t.missedRuns-e.missedRuns||e.name.localeCompare(t.name))}function j(e,t={production:!0}){return t.production&&e.external?{kind:`typed`,phrase:`RUN`,requireReason:!0}:{kind:`undo`,windowMs:p}}var M=e(d(),1),N=m();function P(){let e=g({from:`/clock`}),t=n({from:`/clock`}),o=l(),[u,d]=(0,M.useState)(``),[p,m]=(0,M.useState)(``),[_,v]=(0,M.useState)(``),[y,k]=(0,M.useState)(``),[A,P]=(0,M.useState)(null),F=e=>{t({search:b(e),replace:!0})},I=r({queryKey:[`console.clock.list`],queryFn:async()=>{let e=await c.clockList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:5e3}),L=I.data,R=L?.now??Date.now(),z=e.q??``,B=(0,M.useMemo)(()=>O(L?.crons??[],z),[L?.crons,z]),V=(0,M.useMemo)(()=>E(L?.waitingOn??[],z),[L?.waitingOn,z]),H=(0,M.useMemo)(()=>C(L?.timeline??[],R),[L?.timeline,R]),U=L?.waitingOnCounts??[],W=ee(V.length,U),G=B.find(t=>t.name===e.cron),K=V.find(t=>t.runId===e.wake),q=G?j(G,{production:!0}):null,J=G?D(G.health):null;(0,M.useEffect)(()=>{d(``),m(``),P(null),G&&(v(G.effectiveCron??``),k(G.effectiveEvery??``))},[G?.name,e.action,K?.runId]);let Y=()=>o.invalidateQueries({queryKey:[`console.clock.list`]}),X=i({mutationFn:async()=>{if(!G||!q)throw Error(`no cron`);if(q.kind===`typed`){let e=a({typed:u,reason:p,phrase:q.phrase});if(e)throw Error(e.typed??e.reason??`confirm`)}let e=await c.clockRunNow({name:G.name,confirmation:q.kind===`typed`?u:void 0,reason:q.kind===`typed`?p:void 0});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async e=>{P(e?.ran?`Ran now`:`Did not acquire lease`),d(``),m(``),await Y()},onError:e=>{P(e instanceof Error?e.message:`Run failed`)}}),Z=i({mutationFn:async()=>{if(!G)throw Error(`no cron`);let e=await c.clockPause({name:G.name});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async()=>{P(`Paused`),await Y()}}),Q=i({mutationFn:async()=>{if(!G?.overridable)throw Error(`not overridable`);let e=await c.clockEditSchedule({name:G.name,cron:_||void 0,every:y||void 0});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async()=>{P(`Schedule updated`),F({...e,action:void 0}),await Y()},onError:e=>{P(e instanceof Error?e.message:`Edit failed`)}}),$=i({mutationFn:async()=>{if(!K)throw Error(`no wake`);let e=await c.clockWakeEarly({runId:K.runId});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async()=>{P(`Woke early`),F({...e,wake:void 0}),await Y()}});return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,N.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,N.jsx)(`h1`,{className:`text-lg font-medium`,children:`Clock`}),(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Forward timeline, waiting-on, cron health`}),(0,N.jsxs)(`label`,{className:`mt-2 block max-w-sm text-sm`,children:[(0,N.jsx)(`span`,{className:`sr-only`,children:`Filter clock`}),(0,N.jsx)(s,{"aria-label":`Filter clock`,placeholder:`Filter…`,value:z,onChange:t=>F({...e,q:t.currentTarget.value||void 0})})]})]}),(0,N.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-0 overflow-hidden lg:grid-cols-[1fr_1fr_1.2fr]`,children:[(0,N.jsxs)(`section`,{"aria-label":`Forward timeline`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] p-4 lg:border-b-0 lg:border-r`,children:[(0,N.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Next 24 hours`}),I.isLoading?(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`}):H.length===0?(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Nothing in the next 24h`}):(0,N.jsx)(`ol`,{className:`space-y-1`,children:H.map(e=>(0,N.jsxs)(`li`,{className:`flex min-h-8 items-baseline gap-2 text-sm`,children:[(0,N.jsx)(`span`,{className:`w-24 shrink-0 text-[var(--oke-muted)]`,children:w(e.at,R)}),(0,N.jsxs)(`span`,{children:[e.kind===`cron`?`cron`:`wake`,` · `,e.name]})]},`${e.kind}-${e.name}-${e.at}`))})]}),(0,N.jsxs)(`section`,{"aria-label":`Waiting on`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] p-4 lg:border-b-0 lg:border-r`,children:[(0,N.jsx)(`h2`,{className:`mb-1 text-sm font-medium`,children:`Waiting on`}),(0,N.jsx)(`p`,{className:`mb-2 text-sm text-[var(--oke-muted)]`,role:`status`,children:W}),(0,N.jsx)(`ul`,{className:`space-y-1`,children:V.map(t=>{let n=U.find(e=>e.label===(t.label||`(unlabelled)`))?.count??1;return(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":t.runId===e.wake,className:h(`flex min-h-8 w-full flex-col items-start px-2 py-1 text-left text-sm`,t.runId===e.wake?`bg-[var(--oke-line)]`:`hover:bg-[var(--oke-line)]/40`),onClick:()=>F(S(e,t.runId)),children:[(0,N.jsx)(`span`,{children:t.label||t.flow}),(0,N.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[`wake-in `,T(t.wakeInMs),t.step?` · step ${t.step}`:``,` · ${n} run${n===1?``:`s`}`]})]})},t.runId)})})]}),(0,N.jsxs)(`section`,{"aria-label":`Cron schedules`,className:`min-h-0 overflow-y-auto p-4`,children:[(0,N.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Schedules`}),(0,N.jsx)(`ul`,{className:`mb-4 space-y-1`,children:B.map(t=>{let n=D(t.health);return(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===e.cron,className:h(`flex min-h-8 w-full flex-col items-start px-2 py-1 text-left text-sm`,t.name===e.cron?`bg-[var(--oke-line)]`:`hover:bg-[var(--oke-line)]/40`),onClick:()=>F(x(e,t.name)),children:[(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t.name,t.external?(0,N.jsx)(`span`,{"aria-label":`external effect`,children:`↗`}):null,t.health.overdue?(0,N.jsx)(`span`,{role:`status`,className:`text-[var(--oke-danger)]`,children:`overdue`}):null,t.dstAmbiguity?(0,N.jsxs)(`span`,{role:`status`,children:[`DST `,t.dstAmbiguity.kind]}):null]}),(0,N.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[n.drift,` · `,n.missedWithPolicy,` · `,n.lease]})]})},t.name)})}),G&&J?(0,N.jsxs)(`section`,{"aria-label":`Cron detail`,"aria-live":`polite`,className:`space-y-3 border-t border-[var(--oke-line)] pt-3`,children:[(0,N.jsx)(`h3`,{className:`text-base font-medium`,children:G.name}),(0,N.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[G.effectiveCron??G.effectiveEvery,` ·`,` `,G.timezone,G.status===`active`?``:` · ${G.status}`]}),(0,N.jsxs)(`dl`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Drift`}),(0,N.jsx)(`dd`,{children:J.drift})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Overdue`}),(0,N.jsx)(`dd`,{children:J.overdue})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Missed + catch-up`}),(0,N.jsx)(`dd`,{children:J.missedWithPolicy})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Lease`}),(0,N.jsx)(`dd`,{children:J.lease})]})]}),G.dstAmbiguity?(0,N.jsx)(`p`,{role:`alert`,className:`text-sm`,children:G.dstAmbiguity.reason}):null,(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,N.jsx)(f,{type:`button`,variant:G.external?`external`:`primary`,disabled:X.isPending,onClick:()=>{if(q?.kind===`typed`&&e.action!==`run`){F({...e,action:`run`});return}X.mutate()},children:`Run now`}),(0,N.jsx)(f,{type:`button`,variant:`ghost`,disabled:Z.isPending||G.status===`paused`,onClick:()=>Z.mutate(),children:`Pause`}),G.overridable?(0,N.jsx)(f,{type:`button`,variant:`ghost`,onClick:()=>F({...e,action:e.action===`edit`?void 0:`edit`}),children:`Edit schedule`}):null]}),e.action===`run`&&q?.kind===`typed`?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`p`,{className:`text-sm`,children:[`This cron has an external effect. Type`,` `,(0,N.jsx)(`strong`,{children:`RUN`}),` and a reason.`]}),(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Type RUN to confirm`,(0,N.jsx)(s,{"aria-label":`Type RUN to confirm`,value:u,onChange:e=>d(e.currentTarget.value)})]}),(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Reason`,(0,N.jsx)(s,{"aria-label":`Reason`,value:p,onChange:e=>m(e.currentTarget.value)})]}),(0,N.jsx)(f,{type:`button`,variant:`external`,disabled:X.isPending,onClick:()=>X.mutate(),children:`Confirm run now`})]}):null,e.action===`edit`&&G.overridable?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Cron expression`,(0,N.jsx)(s,{"aria-label":`Cron expression`,value:_,onChange:e=>v(e.currentTarget.value)})]}),(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Every interval`,(0,N.jsx)(s,{"aria-label":`Every interval`,value:y,onChange:e=>k(e.currentTarget.value)})]}),(0,N.jsx)(f,{type:`button`,disabled:Q.isPending,onClick:()=>Q.mutate(),children:`Save schedule`})]}):null]}):null,K?(0,N.jsxs)(`section`,{"aria-label":`Wake detail`,"aria-live":`polite`,className:`mt-4 space-y-2 border-t border-[var(--oke-line)] pt-3`,children:[(0,N.jsx)(`h3`,{className:`text-base font-medium`,children:K.label||K.flow}),(0,N.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[K.flow,` · wake in`,` `,T(K.wakeInMs),K.step?` · step ${K.step}`:``]}),(0,N.jsx)(f,{type:`button`,disabled:$.isPending,onClick:()=>$.mutate(),children:`Wake early`})]}):null,A?(0,N.jsx)(`p`,{className:`mt-3 text-sm`,role:`status`,children:A}):null]})]})]})}var F=t({default:()=>P});export{A as n,y as r,F as t};