@usine/server 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -1
- package/dist/backend.d.ts +12 -9
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +6 -2
- package/dist/backend.js.map +1 -1
- package/dist/backup.d.ts +4 -0
- package/dist/backup.d.ts.map +1 -0
- package/dist/backup.js +13 -0
- package/dist/backup.js.map +1 -0
- package/dist/cli.d.ts +36 -7
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +115 -28
- package/dist/cli.js.map +1 -1
- package/dist/export-run.d.ts +22 -0
- package/dist/export-run.d.ts.map +1 -0
- package/dist/export-run.js +85 -0
- package/dist/export-run.js.map +1 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +94 -138
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +1 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -7
- package/dist/index.js.map +1 -1
- package/dist/main.js +18 -8
- package/dist/main.js.map +1 -1
- package/dist/shutdown.d.ts +7 -0
- package/dist/shutdown.d.ts.map +1 -0
- package/dist/shutdown.js +49 -0
- package/dist/shutdown.js.map +1 -0
- package/dist/up.d.ts +2 -2
- package/dist/up.d.ts.map +1 -1
- package/dist/up.js +48 -25
- package/dist/up.js.map +1 -1
- package/dist/web/assets/_name-BHFMXhWe.js +1 -0
- package/dist/web/assets/_name-Cz2YmpSb.js +1 -0
- package/dist/web/assets/_name-D1NH8oUE.js +6 -0
- package/dist/web/assets/badge-BQobsECb.js +142 -0
- package/dist/web/assets/bash-CLZ0U2zV.js +1 -0
- package/dist/web/assets/button-BoOukj77.js +1 -0
- package/dist/web/assets/core-Cg4Mi2IQ.js +12 -0
- package/dist/web/assets/diff-woXpYk--.js +1 -0
- package/dist/web/assets/empty-DbVYU7bi.js +1 -0
- package/dist/web/assets/engine-javascript-h-x4hGa4.js +141 -0
- package/dist/web/assets/index-CJ-Nk5DM.js +10 -0
- package/dist/web/assets/index-DxGXwXIP.css +2 -0
- package/dist/web/assets/json-qhed-kSA.js +1 -0
- package/dist/web/assets/loops-huxrr83I.js +1 -0
- package/dist/web/assets/operator-copy-BDZ_fazz.js +1 -0
- package/dist/web/assets/overview-DTxvvQ4b.js +1 -0
- package/dist/web/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/dist/web/assets/routes-CbvAb2gn.js +1 -0
- package/dist/web/assets/run-drawer-3blrdBMZ.js +157 -0
- package/dist/web/assets/status-badge-BTkHx8qb.js +1 -0
- package/dist/web/assets/table-B8cLYNvq.js +1 -0
- package/dist/web/assets/typescript-bsJCZSQ-.js +1 -0
- package/dist/web/assets/useCompositeItem-CuLyiETJ.js +1 -0
- package/dist/web/assets/with-selector-N6m4X0X_.js +1 -0
- package/dist/web/index.html +9 -2
- package/package.json +9 -9
- package/dist/web/assets/index-CjRDHHWF.css +0 -2
- package/dist/web/assets/index-DmN0SkGf.js +0 -295
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,H as n,O as r,V as i,k as a,z as o}from"./button-BoOukj77.js";var s=e(n(),1),c=i(),l=s.createContext(void 0),u=e=>{let t=s.useContext(l);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},d=({client:e,children:t})=>(s.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,c.jsx)(l.Provider,{value:e,children:t})),f={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},p=new class{#e=f;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 m(e){setTimeout(e,0)}var h=typeof window>`u`||`Deno`in globalThis;function g(){}function _(e,t){return typeof e==`function`?e(t):e}function v(e){return typeof e==`number`&&e>=0&&e!==1/0}function y(e,t){return Math.max(e+(t||0)-Date.now(),0)}function b(e,t){return typeof e==`function`?e(t):e}function x(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==te(o,t.options))return!1}else if(!re(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 ee(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ne(t.options.mutationKey)!==ne(a))return!1}else if(!re(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function te(e,t){return(t?.queryKeyHashFn||ne)(e)}function ne(e){return JSON.stringify(e,(e,t)=>ce(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function re(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(!re(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!re(e[r],t[r]))return!1;return!0}return!1}var ie=Object.prototype.hasOwnProperty;function ae(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=se(e)&&se(t);if(!r&&!(ce(e)&&ce(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:ie.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=ae(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function oe(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 se(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ce(e){if(!le(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!le(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function le(e){return Object.prototype.toString.call(e)===`[object Object]`}function ue(e){return new Promise(t=>{p.setTimeout(t,e)})}function de(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:ae(e,t)}function fe(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function pe(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var me=Symbol();function he(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===me?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ge(e,t){return typeof e==`function`?e(...t):!!e}function _e(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 ve=()=>h,ye=()=>ve(),be=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(){}},xe=new class extends be{#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`}},Se=m;function Ce(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Se,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 we=Ce(),Te=new class extends be{#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 Ee(e){return Math.min(1e3*2**e,3e4)}function De(e){return(e??`online`)!==`online`||Te.isOnline()}var Oe=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function ke(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(g);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new Oe(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>xe.isFocused()&&(e.networkMode===`always`||Te.isOnline())&&e.canRun(),p=()=>De(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},_=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),v=()=>{if(c())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(m).catch(r=>{if(c())return;let i=e.retry??(ye()?0:3),a=e.retryDelay??Ee,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),ue(o).then(()=>f()?void 0:_()).then(()=>{t?h(r):v()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?v():_().then(v),s)}}var Ae=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),v(this.gcTime)&&(this.#e=p.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ye()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(p.clearTimeout(this.#e),this.#e=void 0)}};function je(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=>{_e(e,()=>t.signal,()=>n=!0)},u=he(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?pe:fe;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?Ne:Me,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:Me(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Me(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 Ne(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Pe=class extends Ae{#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=Le(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=Le(this.options);e.data!==void 0&&(this.setState(Ie(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=de(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(g).catch(g):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=>b(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===me||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>b(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:!y(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){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({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=he(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`?je(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=ke({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.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.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.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(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,...Fe(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Ie(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),we.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function Fe(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:De(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Ie(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Le(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 Re=class extends be{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Be(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ve(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ve(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 b(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&&!oe(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&He(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||b(this.options.staleTime,this.#t)!==b(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||b(this.options.enabled,this.#t)!==b(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return oe(this.getCurrentResult(),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),Reflect.get(e,n))})}trackProp(e){this.#p.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),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(g)),t}#h(e){return!ye()&&b(this.options.enabled,this.#t)!==!1&&v(e)}#g(){this.#b();let e=b(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=y(this.#r.dataUpdatedAt,e)+1;this.#u=p.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.#f=e,!(this.#f===0||!this.#h(this.#f))&&(this.#d=p.setInterval(()=>{(this.options.refetchIntervalInBackground||xe.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(p.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(p.clearInterval(this.#d),this.#d=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&&Be(e,t),o=i&&He(e,n,t,r);(a||o)&&(l={...l,...Fe(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=de(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=de(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,x=d!==void 0;return{status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,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:g,isRefetching:g&&!_,isLoadingError:v&&!x,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&x,isStale:Ue(e,t),refetch:this.refetch,isEnabled:b(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),oe(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);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)})})();we.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#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()}};function ze(e,t){return b(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||b(t.retryOnMount,e)!==!1)}function Be(e,t){return ze(e,t)||e.state.data!==void 0&&Ve(e,t,t.refetchOnMount)}function Ve(e,t,n){if(b(t.enabled,e)!==!1&&b(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Ue(e,t)}return!1}function He(e,t,n,r){return(e!==t||b(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Ue(e,n)}function Ue(e,t){return b(t.enabled,e)!==!1&&e.isStaleByTime(b(t.staleTime,e))}var We=s.createContext(!1),Ge=()=>s.useContext(We);We.Provider;function Ke(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var qe=s.createContext(Ke()),Je=()=>s.useContext(qe),Ye=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?ge(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},Xe=e=>{s.useEffect(()=>{e.clearReset()},[e])},Ze=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ge(n,[e.error,r])),Qe=(e,t)=>t.state.data===void 0,$e=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))}},et=(e,t)=>e?.suspense&&t.isPending,tt=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function nt(e,t,n){let r=Ge(),i=Je(),a=u(n),o=a.defaultQueryOptions(e),c=a.getQueryCache().get(o.queryHash),l=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:l?`optimistic`:void 0,$e(o),Ye(o,i,c),Xe(i);let[d]=s.useState(()=>new t(a,o)),f=d.getOptimisticResult(o),p=!r&&l;if(s.useSyncExternalStore(s.useCallback(e=>{let t=p?d.subscribe(we.batchCalls(e)):g;return d.updateResult(),t},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),s.useEffect(()=>{d.setOptions(o)},[o,d]),et(o,f))throw tt(o,d,i);if(Ze({result:f,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw f.error;return o.notifyOnChangeProps?f:d.trackResult(f)}var rt=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},it={pipe(){return rt(this,arguments)}},at=function(){function e(){}return e.prototype=it,e}(),S=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},C=e=>e,ot=e=>()=>e,st=ot(!0),ct=ot(!1),lt=ot(null),ut=ot(void 0),dt=ut;function ft(e,...t){return rt(e,t)}function pt(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i}}function mt(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),t.set(i,i),i}}var ht=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},gt=new WeakSet;function _t(e){return typeof e==`string`}function vt(e){return typeof e==`number`}function yt(e){return typeof e==`boolean`}function bt(e){return typeof e==`bigint`}function xt(e){return typeof e==`symbol`}function St(e){return _t(e)||vt(e)||xt(e)}function Ct(e){return typeof e==`function`}function wt(e){return e!==void 0}function Tt(e){return e!=null}function Et(e){return!1}function Dt(e){return!0}function Ot(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kt(e){return typeof e==`object`&&!!e||Ct(e)}var At=S(2,(e,t)=>kt(e)&&t in e);function jt(e){return e instanceof Error}function Mt(e){return At(e,Symbol.iterator)||_t(e)}var Nt=`~effect/interfaces/Hash`,Pt=e=>{switch(typeof e){case`number`:return zt(e);case`bigint`:return Bt(e.toString(10));case`boolean`:return Bt(String(e));case`symbol`:return Bt(String(e));case`string`:return Bt(e);case`undefined`:return Bt(`undefined`);case`function`:case`object`:if(e===null)return Bt(`null`);if(e instanceof Date)return Number.isNaN(e.getTime())?Bt(`Invalid Date`):Bt(e.toISOString());if(e instanceof RegExp)return Bt(e.toString());{if(gt.has(e))return Ft(e);if(Jt.has(e))return Jt.get(e);let t=Xt(e,()=>Rt(e)?e[Nt]():typeof e==`function`?Ft(e):e instanceof DataView?Wt(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):Array.isArray(e)||ArrayBuffer.isView(e)?Wt(e):e instanceof Map?Gt(e):e instanceof Set?Kt(e):Ht(e));return Jt.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Ft=e=>(qt.has(e)||qt.set(e,zt(Math.floor(Math.random()*(2**53-1)))),qt.get(e)),It=S(2,(e,t)=>e*53^t),Lt=e=>e&3221225471|e>>>1&1073741824,Rt=e=>At(e,Nt),zt=e=>{if(e!==e)return Bt(`NaN`);if(e===1/0)return Bt(`Infinity`);if(e===-1/0)return Bt(`-Infinity`);let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Lt(t)},Bt=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Lt(t)},Vt=(e,t)=>{let n=12289;for(let r of t)n^=It(Pt(r),Pt(e[r]));return Lt(n)},Ht=e=>Vt(e,ht(e)),Ut=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return Lt(r)},Wt=Ut(6151,Pt),Gt=Ut(Bt(`Map`),([e,t])=>It(Pt(e),Pt(t))),Kt=Ut(Bt(`Set`),Pt),qt=new WeakMap,Jt=new WeakMap,Yt=new WeakSet;function Xt(e,t){if(Yt.has(e))return Bt(`[Circular]`);Yt.add(e);let n=t();return Yt.delete(e),n}var Zt=`~effect/interfaces/Equal`;function Qt(){return arguments.length===1?e=>$t(e,arguments[0]):$t(arguments[0],arguments[1])}function $t(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||gt.has(e)||gt.has(t)?!1:an(e,t,rn):!1}function en(e,t,n){let r=tn.has(e),i=nn.has(t);if(r&&i)return!0;if(r||i)return!1;tn.add(e),nn.add(t);let a=n();return tn.delete(e),nn.delete(t),a}var tn=new WeakSet,nn=new WeakSet;function rn(e,t){if(Pt(e)!==Pt(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),r=t.getTime();return n===r||Number.isNaN(n)&&Number.isNaN(r)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let n=mn(e),r=mn(t);if(n!==r)return!1;let i=n&&r;return typeof e==`function`&&!i?!1:en(e,t,()=>{if(i)return e[Zt](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:sn(e,t);if(ArrayBuffer.isView(e)){let n=e instanceof DataView;if(!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView)return!1;if(n){let n=t;return cn(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(n.buffer,n.byteOffset,n.byteLength))}return cn(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:dn(e,t):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:pn(e,t):ln(e,t)})}function an(e,t,n){let r=on.get(e);if(!r)r=new WeakMap,on.set(e,r);else if(r.has(t))return r.get(t);let i=n(e,t);r.set(t,i);let a=on.get(t);return a||(a=new WeakMap,on.set(t,a)),a.set(e,i),i}var on=new WeakMap;function sn(e,t){for(let n=0;n<e.length;n++)if(!$t(e[n],t[n]))return!1;return!0}function cn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ln(e,t){let n=ht(e),r=ht(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!$t(e[i],t[i]))return!1;return!0}function un(e,t){return function(n,r){let i=Array.from(r);for(let[r,a]of n){let n=!1;for(let o=0;o<i.length;o++){let[s,c]=i[o];if(e(r,s)&&t(a,c)){i[o]=i[i.length-1],i.pop(),n=!0;break}}if(!n)return!1}return!0}}var dn=un($t,$t);function fn(e){return function(t,n){let r=Array.from(n);for(let n of t){let t=!1;for(let i=0;i<r.length;i++){let a=r[i];if(e(n,a)){r[i]=r[r.length-1],r.pop(),t=!0;break}}if(!t)return!1}return!0}}var pn=fn($t),mn=e=>At(e,Zt),hn=e=>(t,n)=>t===n||e(t,n),gn=(e,t)=>e===t,_n=()=>gn;function vn(e){return hn((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e[r](t[r],n[r]))return!1;return!0})}function yn(e){return hn((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var bn=e=>e.length>0;function xn(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function Sn(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&xn(e,n,t[n])}var Cn=Symbol.for(`~effect/Redactable`),wn=e=>At(e,Cn);function Tn(e){return wn(e)?En(e):e}function En(e){return e[Cn](globalThis[`~effect/Fiber/currentFiber`]?.context??kn)}var Dn=`~effect/Fiber/currentFiber`,On=new Map,kn={"~effect/Context":{},base:On,depth:0,mapUnsafe:On,pipe(){return rt(this,arguments)}};function An(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,n=0){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return jn;r.add(e);let l;if(Cn in e)l=c(En(e),n);else if(Array.isArray(e))l=!i||e.length<=1?`[${e.map(e=>c(e,n)).join(`,`)}]`:`[\n${a(n+1)}${e.map(e=>c(e,n+1)).join(`,
|
|
2
|
+
`+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=Pn(e);else if(!t?.ignoreToString&&At(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=Fn(e);l=e instanceof Error&&e.cause?`${t} (cause: ${c(e.cause,n)})`:t}else if(Symbol.iterator in e)l=`${e.constructor.name}(${c(Array.from(e),n)})`;else{let t=s(e);if(!i||t.length<=1){let r=`{${t.map(t=>`${Mn(t)}:${c(e[t],n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${Mn(t)}: ${c(e[t],n+1)}`).join(`,
|
|
3
|
+
`)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}var jn=`[Circular]`;function Mn(e){return typeof e==`string`?JSON.stringify(e):String(e)}function Nn(e){return e.map(e=>`[${Mn(e)}]`).join(``)}function Pn(e){try{return e.toISOString()}catch{return`Invalid Date`}}function Fn(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function In(e,t){let n=[];return JSON.stringify(e,function(e,t){let r=Object.getOwnPropertyDescriptor(this,e)?.value,i=At(r,Cn)?Tn(r):Tn(t);if(typeof i==`bigint`)return An(i);if(typeof i!=`object`||!i)return i;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(!n.includes(i))return n.push(i),i},t?.space)??`null`}var Ln=Symbol.for(`nodejs.util.inspect.custom`),Rn=e=>{try{return e=Tn(e),At(e,`toJSON`)&&Ct(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(Rn):e}catch{return`[toJSON threw]`}},zn=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?In(e,{space:t}):An(e,{space:t})}catch{return String(e)}},Bn={toJSON(){return Rn(this)},[Ln](){return this.toJSON()},toString(){return An(this.toJSON())}},Vn=class{[Ln](){return this.toJSON()}toString(){return An(this.toJSON())}},Hn=class e{called=!1;self;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new e(this.self)}},Un=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}};return t[e](()=>Error().stack)?.includes(e)===!0?t[e]:n[e]})(),Wn=`~effect/Effect`,Gn=`~effect/Exit`,Kn={_A:C,_E:C,_R:C},qn=`${Wn}/identifier`,w=`${Wn}/args`,Jn=`${Wn}/evaluate`,Yn=`${Wn}/successCont`,Xn=`${Wn}/failureCont`,Zn=`${Wn}/ensureCont`,Qn=Symbol.for(`effect/Effect/Yield`),$n={pipe(){return rt(this,arguments)},toJSON(){return{...this}},toString(){return An(this.toJSON(),{ignoreToString:!0,space:2})},[Ln](){return this.toJSON()}},er={[Wn]:Kn,...$n,[Symbol.iterator](){return new Hn(this)},toJSON(){return{_id:`Effect`,op:this[qn],...w in this?{args:this[w]}:void 0}}},tr=e=>At(e,Wn),nr=e=>At(e,Gn),rr=`~effect/Cause`,ir=`~effect/Cause/Reason`,ar=e=>At(e,rr),or=e=>At(e,ir),sr=class{[rr];reasons;constructor(e){this[rr]=rr,this.reasons=e}pipe(){return rt(this,arguments)}toJSON(){return{_id:`Cause`,failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${An(this.reasons)})`}[Ln](){return this.toJSON()}[Zt](e){return ar(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>Qt(t,e.reasons[n]))}[Nt](){return Wt(this.reasons)}},cr=new WeakMap,lr=class{[ir];annotations;_tag;constructor(e,t,n){if(this[ir]=ir,this._tag=e,t!==ur&&typeof n==`object`&&n&&t.size>0){let e=cr.get(n);e&&(t=new Map([...e,...t])),cr.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)});let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return rt(this,arguments)}toString(){return An(this)}[Ln](){return this.toString()}},ur=new Map,dr=class extends lr{error;constructor(e,t=ur){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${An(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[Zt](e){return vr(e)&&Qt(this.error,e.error)&&Qt(this.annotations,e.annotations)}[Nt](){return It(Bt(this._tag))(It(Pt(this.error))(Pt(this.annotations)))}},fr=e=>new sr(e),pr=new sr([]),mr=e=>new sr([new dr(e)]),hr=class extends lr{defect;constructor(e,t=ur){super(`Die`,t,e),this.defect=e}toString(){return`Die(${An(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[Zt](e){return yr(e)&&Qt(this.defect,e.defect)&&Qt(this.annotations,e.annotations)}[Nt](){return It(Bt(this._tag))(It(Pt(this.defect))(Pt(this.annotations)))}},gr=e=>new sr([new hr(e)]),_r=S(e=>ar(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new sr(e.reasons.map(e=>e.annotate(t,n)))),vr=e=>e._tag===`Fail`,yr=e=>e._tag===`Die`,br=e=>e._tag===`Interrupt`;function xr(e){return Ar(`Effect.evaluate: Not implemented`)}var Sr=e=>({...er,[qn]:e.op,[Jn]:e[Jn]??xr,[Yn]:e[Yn],[Xn]:e[Xn],[Zn]:e[Zn]}),Cr=e=>{let t=Sr(e);return function(){let n=Object.create(t);return n[w]=e.single===!1?arguments:arguments[0],n}},wr=e=>{let t={[Gn]:Gn,_tag:e.op,get[e.prop](){return this[w]},...Sr(e),toString(){return`${e.op}(${An(this[w])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[w]}},[Zt](e){return nr(e)&&e._tag===this._tag&&Qt(this[w],e[w])},[Nt](){return It(Bt(e.op),Pt(this[w]))}};return function(e){let n=Object.create(t);return n[w]=e,n}},Tr=wr({op:`Success`,prop:`value`,[Jn](e){let t=e.getCont(Yn);return t?t[Yn](this[w],e,this):e.yieldWith(this)}}),Er={key:`effect/Cause/StackTrace`},Dr={key:`effect/Cause/InterruptorStackTrace`},Or=wr({op:`Failure`,prop:`cause`,[Jn](e){let t=this[w],n=!1;e.currentStackFrame&&(t=_r(t,{mapUnsafe:new Map([[Er.key,e.currentStackFrame]])}),n=!0);let r=e.getCont(Xn);for(;e.interruptible&&e._interruptedCause&&r;)r=e.getCont(Xn);return r?r[Xn](t,e,n?void 0:this):e.yieldWith(n?Or(t):this)}}),kr=e=>Or(mr(e)),Ar=e=>Or(gr(e)),jr=Cr({op:`WithFiber`,[Jn](e){return this[w](e)}}),Mr=function(){class e extends globalThis.Error{}let t=Sr({op:`YieldableError`,[Jn](){return kr(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Nr=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends Mr{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(Sn(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),Pr=e=>{class t extends Nr{_tag=e}return t.prototype.name=e,t};Pr(`NoSuchElementError`);var Fr=`~effect/Cause/Done`,Ir=e=>At(e,Fr),Lr={[Fr]:Fr,_tag:`Done`,value:void 0},Rr=e=>e===void 0?Lr:{[Fr]:Fr,_tag:`Done`,value:e},zr=kr(Lr),Br=e=>e===void 0?zr:kr(Rr(e)),Vr=`~effect/data/Option`,Hr={[Vr]:{_A:e=>e},...$n,[Symbol.iterator](){return new Hn(this)}},Ur=Object.defineProperty(Object.assign(Object.create(Hr),{_tag:`Some`,_op:`Some`,[Zt](e){return Kr(e)&&Jr(e)&&Qt(this.value,e.value)},[Nt](){return It(Pt(this._tag))(Pt(this.value))},toString(){return`some(${An(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:Rn(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),Wr=Pt(`None`),Gr=Object.assign(Object.create(Hr),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[Zt](e){return Kr(e)&&qr(e)},[Nt](){return Wr},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),Kr=e=>At(e,Vr),qr=e=>e._tag===`None`,Jr=e=>e._tag===`Some`,Yr=Object.create(Gr),Xr=e=>{let t=Object.create(Ur);return t.value=e,t},Zr=`~effect/data/Result`,Qr={[Zr]:{_A:e=>e,_E:e=>e},...$n,[Symbol.iterator](){return new Hn(this)}},$r=Object.assign(Object.create(Qr),{_tag:`Success`,_op:`Success`,[Zt](e){return ti(e)&&ri(e)&&Qt(this.success,e.success)},[Nt](){return It(Pt(this._tag))(Pt(this.success))},toString(){return`success(${An(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:Rn(this.success)}}}),ei=Object.assign(Object.create(Qr),{_tag:`Failure`,_op:`Failure`,[Zt](e){return ti(e)&&ni(e)&&Qt(this.failure,e.failure)},[Nt](){return It(Pt(this._tag))(Pt(this.failure))},toString(){return`failure(${An(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:Rn(this.failure)}}}),ti=e=>At(e,Zr),ni=e=>e._tag===`Failure`,ri=e=>e._tag===`Success`,ii=e=>{let t=Object.create(ei);return t.failure=e,t},ai=e=>{let t=Object.create($r);return t.success=e,t},oi=S(2,(e,t)=>qr(e)?ii(t()):ai(e.value));function si(e){return(t,n)=>t===n?0:e(t,n)}var ci=si((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),li=S(2,(e,t)=>si((n,r)=>e(t(n),t(r)))),ui=e=>S(2,(t,n)=>e(t,n)===-1),di=e=>S(2,(t,n)=>e(t,n)===1),fi=e=>S(2,(t,n)=>e(t,n)!==1),pi=e=>S(2,(t,n)=>e(t,n)!==-1),T=()=>Yr,E=Xr,mi=Kr,hi=qr,D=Jr,gi=S(2,(e,{onNone:t,onSome:n})=>hi(e)?t():n(e.value)),_i=S(2,(e,t)=>hi(e)?t():e.value),vi=e=>{let t=T();for(t of e)if(D(t))return t;return t},yi=e=>e==null?T():E(e),bi=e=>e===void 0?T():E(e),xi=e=>e===null?T():E(e),Si=_i(lt),Ci=_i(ut),wi=e=>(...t)=>{try{return E(e(...t))}catch{return T()}},Ti=S(2,(e,t)=>hi(e)?T():E(t(e.value))),Ei=S(2,(e,t)=>hi(e)?T():t(e.value)),Di=Ei(C),Oi=e=>hi(e)?[]:[e.value],ki=S(2,(e,t)=>hi(e)?T():t(e.value)?E(e.value):T()),Ai=e=>hn((t,n)=>hi(t)?hi(n):!hi(n)&&e(t.value,n.value)),ji=ai,Mi=ii,Ni=oi,Pi=e=>{if(Ct(e))try{return ji(e())}catch(e){return Mi(e)}try{return ji(e.try())}catch(t){return Mi(e.catch(t))}},Fi=ti,Ii=ni,Li=ri,Ri=S(2,(e,t)=>Li(e)?ji(t(e.success)):e),zi=S(2,(e,{onFailure:t,onSuccess:n})=>Ii(e)?t(e.failure):n(e.success)),Bi=S(2,(e,t)=>{if(Li(e))return e.success;throw t(e.failure)})(C),Vi=e=>{if(Symbol.iterator in e){let t=[];for(let n of e){if(Ii(n))return n;t.push(n.success)}return ji(t)}let t={};for(let n of Object.keys(e)){let r=e[n];if(Ii(r))return r;xn(t,n,r.success)}return ji(t)},Hi=vn,Ui=S(2,(e,t)=>Object.hasOwn(e,t)),Wi=S(2,(e,t)=>{let n={...e};for(let r of Gi(e))xn(n,r,t(e[r],r));return n}),Gi=e=>Object.keys(e),Ki=e=>S(2,(t,n)=>{for(let r of Gi(t))if(!Ui(n,r)||!e(t[r],n[r]))return!1;return!0}),qi=e=>{let t=Ki(e);return(e,n)=>t(e,n)&&t(n,e)},Ji=globalThis.Array,Yi=e=>Ji.isArray(e)?e:Ji.from(e),Xi=e=>Ji.isArray(e)?e:[e],Zi=S(2,(e,t)=>[t,...e]),Qi=S(2,(e,t)=>[...e,t]),$i=S(2,(e,t)=>Yi(e).concat(Yi(t)));Ji.isArray;var ea=bn,ta=bn;function na(e,t){return!Number.isFinite(e)||e<0||e>=t.length}var ra=S(2,(e,t)=>{let n=Math.floor(t);if(na(n,e))throw Error(`Index out of bounds: ${n}`);return e[n]})(0),ia=S(2,(e,t)=>{let n=Ji.from(e);return n.sort(t),n}),aa=S(2,(e,t)=>{let n=Yi(e);if(ta(n)){let[e,r]=t(n),i=[e],a=r;for(;bn(a);){let[e,n]=t(a);i.push(e),a=n}return i}return[]}),oa=S(2,(e,t)=>{let n=Math.max(1,Math.floor(t));return n>=e.length?[sa(e),[]]:[Zi(e.slice(1,n),ra(e)),e.slice(n)]}),sa=e=>e.slice(),ca=S(2,(e,t)=>{let n=Yi(e);return ta(n)?aa(n,oa(t)):[]}),la=S(2,(e,t)=>{let n={};for(let r of e){let e=t(r);Object.hasOwn(n,e)?n[e].push(r):xn(n,e,[r])}return n}),ua=(e,t)=>{let n=Pt(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let e of r)if(Qt(e,t))return!1;return r.push(t),!0},da=S(2,(e,t)=>{let n=Yi(e),r=Yi(t);return ta(n)?ta(r)?ga($i(n,r)):n:r}),fa=()=>[],pa=e=>[e],ma=S(2,(e,t)=>e.map(t)),ha=yn,ga=e=>{let t=Yi(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let e of t)ua(n,e)&&r.push(e);return r},_a=`~effect/BigDecimal`,va={[_a]:_a,[Nt](){let e=Ta(this);return It(Pt(e.value),zt(e.scale))},[Zt](e){return ya(e)&&ka(this,e)},toString(){return`BigDecimal(${Aa(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[Ln](){return this.toJSON()},pipe(){return rt(this,arguments)}},ya=e=>At(e,_a),ba=(e,t)=>{let n=Object.create(va);return n.value=e,n.scale=t,n},xa=(e,t)=>{if(e!==Sa&&e%Ca===Sa)throw RangeError(`Value must be normalized`);let n=ba(e,t);return n.normalized=n,n},Sa=BigInt(0),Ca=BigInt(10),wa=xa(Sa,0),Ta=e=>{if(e.normalized===void 0){if(e.value===Sa)e.normalized=wa;else{let t=`${e.value}`,n=0;for(let e=t.length-1;e>=0&&t[e]===`0`;e--)n++;n===0&&(e.normalized=e),e.normalized=xa(BigInt(t.substring(0,t.length-n)),e.scale-n)}}return e.normalized},Ea=S(2,(e,t)=>t>e.scale?ba(e.value*Ca**BigInt(t-e.scale),t):t<e.scale?ba(e.value/Ca**BigInt(e.scale-t),t):e),Da=e=>e.value<Sa?ba(-e.value,e.scale):e,Oa=hn((e,t)=>e.scale>t.scale?Ea(t,e.scale).value===e.value:e.scale<t.scale?Ea(e,t.scale).value===t.value:e.value===t.value),ka=S(2,(e,t)=>Oa(e,t)),Aa=e=>{let t=Ta(e);if(Math.abs(t.scale)>=16)return ja(t);let n=t.value<Sa,r=n?`${t.value}`.substring(1):`${t.value}`,i,a;if(t.scale>=r.length)i=`0`,a=`0`.repeat(t.scale-r.length)+r;else{let e=r.length-t.scale;if(e>r.length){let t=e-r.length;i=`${r}${`0`.repeat(t)}`,a=``}else a=r.slice(e),i=r.slice(0,e)}let o=a===``?i:`${i}.${a}`;return n?`-${o}`:o},ja=e=>{if(Ma(e))return`0e+0`;let t=Ta(e),n=`${Da(t).value}`,r=n.slice(0,1),i=n.slice(1),a=`${Na(t)?`-`:``}${r}`;i!==``&&(a+=`.${i}`);let o=i.length-t.scale;return`${a}e${o>=0?`+`:``}${o}`},Ma=e=>e.value===Sa,Na=e=>e.value<Sa,Pa=e=>Sr({op:e.label,[Jn]:e.evaluate}),Fa=`~effect/Context/Service`,O=function(){function e(){}let t=e;Object.setPrototypeOf(t,Ia);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[Ra]=Ra,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&La.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},Ia={[Fa]:Fa,...Pa({label:`Service`,evaluate(e){return Tr(so(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return to(this,e)},use(e){return jr(t=>e(so(t.context,this)))},useSync(e){return jr(t=>Tr(e(so(t.context,this))))}},La=new Set,Ra=`~effect/Context/Reference`,za=`~effect/Context`,Ba=8,Va=8,Ha=(e,t,n,r)=>{let i=Object.create(Ya);return i.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void 0,i.baseHits=0,i},Ua=(e,t)=>{t&&(Ua(e,t.parent),e.set(t.key,t.value))},Wa=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return Ua(t,e.overlay),e._flat=t},Ga=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),Ja(n)},Ka=Symbol(),qa=(e,t)=>{let n=e;for(let e=n.overlay;e;e=e.parent)if(e.key===t)return e.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Ka:(n.overlay&&++n.baseHits>=Va&&(n.base=Wa(n),n.overlay=void 0,n.depth=0),r)},Ja=e=>Ha(void 0,e,void 0,0),Ya={get mapUnsafe(){return Wa(this)},...$n,[za]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[Zt](e){if(!Za(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[e,r]of t)if(!n.has(e)||!Qt(r,n.get(e)))return!1;return!0},[Nt](){return zt(this.mapUnsafe.size)}},Xa=(e,t)=>e.cacheRoot===t.cacheRoot,Za=e=>At(e,za),Qa=e=>!!e[Ra],$a=()=>eo,eo=Ja(new Map),to=(e,t)=>Ja(new Map([[e.key,t]])),no=S(3,(e,t,n)=>ro(e,t.key,n)),ro=(e,t,n)=>{let r=e,i=La.has(t)?void 0:r.cacheRoot;if(r.depth>=Ba){let e=new Map(r.mapUnsafe);return e.set(t,n),Ha(i,e,void 0,0)}return Ha(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},io=S(2,(e,t)=>ao(e,t.key)),ao=(e,t)=>{let n=qa(e,t);return n===Ka?void 0:n},oo=S(2,(e,t)=>{let n=qa(e,t.key);if(n===Ka){if(Qa(t))return lo(t);throw uo(t)}return n}),so=oo,co=`~effect/Context/defaultValue`,lo=e=>co in e?e[co]:e[co]=e.defaultValue(),uo=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
|
|
4
|
+
`);e.splice(1,3),t.stack=e.join(`
|
|
5
|
+
`)}return t},fo=S(2,(e,t)=>{let n=qa(e,t.key);return n===Ka?Qa(t)?E(lo(t)):T():E(n)}),po=S(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:Ga(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),mo=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return Ja(t)},ho=O,go=`~effect/time/Duration`,_o=BigInt(0),vo=BigInt(1),yo=BigInt(2),bo=BigInt(10),xo=BigInt(1e3),So=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),Co=e=>So(e*1e6),wo=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=bo**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t,s=o/a+(o%a*yo>=a?vo:_o);return r?-s:s},To=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,Eo=e=>{switch(typeof e){case`number`:return Ro(e);case`bigint`:return Lo(e);case`string`:{if(e===`Infinity`)return Fo;if(e===`-Infinity`)return Io;let t=To.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return Lo(wo(r,vo));if(i===`micro`||i===`micros`)return Lo(wo(r,xo));let a=Number(r);switch(i){case`milli`:case`millis`:return Ro(a);case`second`:case`seconds`:return zo(a);case`minute`:case`minutes`:return Bo(a);case`hour`:case`hours`:return Vo(a);case`day`:case`days`:return Ho(a);case`week`:case`weeks`:return Uo(a)}break}case`object`:{if(e===null)break;if(go in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(vt)?Do(e):Number.isNaN(e[0])||Number.isNaN(e[1])?Po:e[0]===-1/0||e[1]===-1/0?Io:e[0]===1/0||e[1]===1/0?Fo:Mo(So(e[0]*1e9+e[1]));let t=e,n=0;return t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds?Mo(n):Mo(So(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return Do(e)},Do=e=>{throw Error(`Invalid Input: ${e}`)},Oo={_tag:`Millis`,millis:0},ko={_tag:`Infinity`},Ao={_tag:`NegativeInfinity`},jo={[go]:go,[Nt](){switch(this.value._tag){case`Millis`:{let e=this.value.millis*1e6;return Number.isFinite(e)?Pt(So(e)):zt(this.value.millis)}case`Nanos`:return Pt(this.value.nanos);default:return Ht(this.value)}},[Zt](e){return No(e)&&Yo(this,e)},toString(){switch(this.value._tag){case`Infinity`:return`Infinity`;case`NegativeInfinity`:return`-Infinity`;case`Nanos`:return`${this.value.nanos} nanos`;case`Millis`:return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,nanos:String(this.value.nanos)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`};case`NegativeInfinity`:return{_id:`Duration`,_tag:`NegativeInfinity`}}},[Ln](){return this.toJSON()},pipe(){return rt(this,arguments)}},Mo=e=>{let t=Object.create(jo);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?Oo:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:Co(e)}:e>0?ko:Ao:e===_o?Oo:{_tag:`Nanos`,nanos:e},t},No=e=>At(e,go),Po=Mo(0),Fo=Mo(1/0),Io=Mo(-1/0),Lo=e=>Mo(e),Ro=e=>Mo(e),zo=e=>Mo(e*1e3),Bo=e=>Mo(e*6e4),Vo=e=>Mo(e*36e5),Ho=e=>Mo(e*864e5),Uo=e=>Mo(e*6048e5),Wo=e=>Ko(Eo(e),{onMillis:C,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Go=e=>{let t=Eo(e);switch(t.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return Co(t.value.millis)}},Ko=S(2,(e,t)=>{switch(e.value._tag){case`Millis`:return t.onMillis(e.value.millis);case`Nanos`:return t.onNanos(e.value.nanos);case`Infinity`:return t.onInfinity();case`NegativeInfinity`:return(t.onNegativeInfinity??t.onInfinity)()}}),qo=S(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(Go(e),t.value.nanos):n.onNanos(e.value.nanos,Go(t))),Jo=(e,t)=>qo(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),Yo=S(2,(e,t)=>Jo(e,t)),Xo=e=>t=>{let n=e(t);return Ii(n)?T():E(n.success)},Zo=ho(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new ts}),Qo=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},$o=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},es=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},ts=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?$o:Qo)}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new ns(this.setImmediate)}},ns=class{tasks=new es;running=void 0;setImmediate;constructor(e=Qo){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},rs=ho(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),is=ho(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),as=class extends at{constructor(e){super(),e&&Sn(this,e)}},os=e=>class extends as{_tag=e},ss=Pr,cs=`~effect/encoding/EncodingError`,ls=class extends ss(`EncodingError`){[cs]=cs},us=e=>ys(typeof e==`string`?gs.encode(e):e),ds=e=>{let t=vs(e),n=t.length;if(n%4!=0)return Mi(new ls({kind:`Decode`,module:`Base64`,input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf(`=`);if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!==`=`))return Mi(new ls({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));try{let e=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(n/4*3-e);for(let e=0,i=0;e<n;e+=4,i+=3){let n=bs(t.charCodeAt(e))<<18|bs(t.charCodeAt(e+1))<<12|bs(t.charCodeAt(e+2))<<6|bs(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return ji(r)}catch(e){return Mi(new ls({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},fs=e=>Cs(typeof e==`string`?gs.encode(e):e),ps=e=>{let t=vs(e),n=t.length;if(n%4==1)return Mi(new ls({module:`Base64Url`,kind:`Decode`,input:t,message:`Length should be a multiple of 4, but is ${n}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return Mi(new ls({module:`Base64Url`,kind:`Decode`,input:t,message:`Invalid input`}));let r=n%4==2?`${t}==`:n%4==3?`${t}=`:t;return r=r.replace(/-/g,`+`).replace(/_/g,`/`),ds(r)},ms=e=>Ri(ps(e),e=>_s.decode(e)),hs=e=>{let t=``;for(let n=e>>>3;n>0;n--){let e=Math.random()*4294967296>>>0;t+=ws[e>>>24]+ws[e>>>16&255]+ws[e>>>8&255]+ws[e&255]}return t},gs=new TextEncoder,_s=new TextDecoder,vs=e=>e.replace(/[\n\r]/g,``),ys=e=>{let t=e.length,n=``,r;for(r=2;r<t;r+=3)n+=xs[e[r-2]>>2],n+=xs[(e[r-2]&3)<<4|e[r-1]>>4],n+=xs[(e[r-1]&15)<<2|e[r]>>6],n+=xs[e[r]&63];return r===t+1&&(n+=xs[e[r-2]>>2],n+=xs[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=xs[e[r-2]>>2],n+=xs[(e[r-2]&3)<<4|e[r-1]>>4],n+=xs[(e[r-1]&15)<<2],n+=`=`),n};function bs(e){if(e>=Ss.length)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=Ss[e];if(t===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}var xs=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),Ss=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],Cs=e=>ys(e).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`),ws=[];for(let e=0;e<256;e++)ws.push(e.toString(16).padStart(2,`0`));var Ts=`effect/Tracer/ParentSpan`,Es=class extends O()(Ts,{fiberCached:!0}){},Ds=e=>e,Os=ho(`effect/Tracer/DisablePropagation`,{defaultValue:ct}),ks=ho(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),As=ho(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),js=`effect/Tracer`,Ms=ho(js,{fiberCached:!0,defaultValue:()=>Ds({span:e=>new Ns(e)})}),Ns=class{_tag=`Span`;spanId;traceId=`native`;sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:`Started`,startTime:e.startTime},this.attributes=new Map,this.traceId=Ci(e.parent)?.traceId??hs(32),this.spanId=hs(16)}end(e,t){this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,n){this.events.push([e,t,n??{}])}addLinks(e){this.links.push(...e)}},Ps=`effect/observability/Metric/FiberRuntimeMetricsKey`,Fs=ho(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:ut}),Is=ho(`effect/References/TracerEnabled`,{defaultValue:st}),Ls=ho(`effect/References/TracerTimingEnabled`,{defaultValue:st}),Rs=ho(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),zs=ho(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),Bs=ho(`effect/References/CurrentLogAnnotations`,{defaultValue:()=>({})}),Vs=ho(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),Hs=ho(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),Us=ho(`effect/References/CurrentLogSpans`,{defaultValue:()=>[]}),Ws=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),Gs=()=>Error.stackTraceLimit,Ks=e=>{Ws&&(Error.stackTraceLimit=e)},qs=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=Gs();Ks(3);let n=Error();return Ks(t),{...e,captureStackTrace:Ys(()=>n.stack)}},Js=e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
|
|
6
|
+
`);if(i[e]!==void 0)return n=i[e].trim(),n}},Ys=Js(3),Xs=class extends lr{fiberId;constructor(e,t=ur){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[Zt](e){return br(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[Nt](){return It(Bt(`${this._tag}:${this.fiberId}`))(Ft(this.annotations))}},Zs=e=>new Xs(e),Qs=e=>new sr([new Xs(e)]),$s=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return ji(n.error)}return Mi(e)},ec=Xo($s),tc=e=>{let t=e.reasons.find(yr);return t?ji(t.defect):Mi(e)},nc=e=>e.reasons.some(br),rc=e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag===`Interrupt`&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?ji(t):Mi(e)},ic=S(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new sr(da(e.reasons,t.reasons));return Qt(e,n)?e:n}),ac=S(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>vr(e)?(n=!0,new dr(t(e.error),e.annotations)):e);return n?fr(r):e}),oc=e=>{let t={Fail:[],Die:[],Interrupt:[]};for(let n=0;n<e.reasons.length;n++)t[e.reasons[n]._tag].push(e.reasons[n]);return t},sc=e=>{let t=oc(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`)},cc=(e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let i=Gs();Ks(1);for(let i of e.reasons){if(i._tag===`Interrupt`){r.push(i);continue}n.push(lc(i._tag===`Die`?i.defect:i.error,i.annotations,t))}if(n.length===0){let e=Error(`The fiber was interrupted by:`);e.name=`InterruptCause`,e.stack=mc(e,r);let i=new globalThis.Error(`All fibers interrupted without error`,{cause:e});i.name=`InterruptError`,i.stack=`${i.name}: ${i.message}`,n.push(lc(i,r[0].annotations,t))}return Ks(i),n},lc=(e,t,n)=>{let r=typeof e,i;if(e&&r===`object`){if(i=new globalThis.Error(uc(e),{cause:e.cause?lc(e.cause):void 0}),typeof e.name==`string`&&(i.name=e.name),typeof e.stack==`string`)i.stack=fc(e.stack,i,t);else{let e=`${i.name}: ${i.message}`;i.stack=t?pc(e,t):e}n?.includeCauseInStack&&(i.stack=_c(i));for(let t of Object.keys(e))t in i||(i[t]=e[t])}else i=new globalThis.Error(e?r===`string`?e:In(e):`Unknown error: ${e}`);return i},uc=e=>{if(typeof e.message==`string`)return e.message;if(typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return In(e)},dc=/\((.*)\)/g,fc=(e,t,n)=>{let r=`${t.name}: ${t.message}`,i=(e.startsWith(r)?e.slice(r.length):e).split(`
|
|
7
|
+
`),a=[r];for(let e=1;e<i.length&&!/(?:Generator\.next|~effect\/Effect)/.test(i[e]);e++)a.push(i[e]);return n?pc(a.join(`
|
|
8
|
+
`),n):a.join(`
|
|
9
|
+
`)},pc=(e,t)=>{let n=t?.get(Er.key);return n&&(e=`${e}\n${hc(n)}`),e},mc=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let e of t){let t=e.fiberId===void 0?`unknown`:`#${e.fiberId}`,r=e.annotations.get(Dr.key);n.push(` at fiber (${t})`),r&&n.push(hc(r))}return n.join(`
|
|
10
|
+
`)},hc=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(dc),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
|
|
11
|
+
`)},gc=e=>cc(e).map(_c).join(`
|
|
12
|
+
`),_c=e=>e.cause?`${e.stack} {\n${vc(e.cause,` `)}\n}`:e.stack,vc=(e,t)=>{let n=e.stack.split(`
|
|
13
|
+
`),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${vc(e.cause,`${t} `)}\n${t}}`),r},yc=`~effect/Fiber`,bc={_A:C,_E:C},xc={id:0},Sc=()=>globalThis[Dn],Cc=class{constructor(e,t=!0){this[yc]=bc,this.setContext(e),this.id=++xc.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this.runtimeMetrics?.recordFiberStart(this.context)}[yc];id;interruptible;currentOpCount;_stack;_observers;_exit;_children;_interruptedCause;_yielded;_running;_deferredInterrupt;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(e){return so(this.context,e)}addObserver(e){return this._exit?(e(this._exit),dt):(this._observers.push(e),()=>{if(this._exit)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}interruptUnsafe(e,t){if(this._exit)return;let n=Qs(e);this.currentStackFrame&&(n=_r(n,to(Er,this.currentStackFrame))),t&&(n=_r(n,t)),this._interruptedCause=this._interruptedCause?ic(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Nc(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Qn)return;let n=Tc.interruptChildren&&Tc.interruptChildren(this);if(n!==void 0)return this.evaluate(dl(n,()=>t));this._exit=t,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let e=0;e<this._observers.length;e++)this._observers[e](t);this._observers.length=0,this._stack.length=0,this._children=void 0,this.context=$a()}runLoop(e){let t=globalThis[Dn];globalThis[Dn]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;){if(this._deferredInterrupt&&(this._deferredInterrupt=!1,i=Nc(this._interruptedCause)),this.currentOpCount++,!r&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){r=!0;let e=i;i=dl(Rc,()=>e)}if(i=this.currentTracerContext?this.currentTracerContext(i,this):i[Jn](this),i===Qn){let e=this._yielded;if(Gn in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return Qn}}}catch(e){return At(i,Jn)?this.runLoop(Ar(e)):Ar(`Fiber.runLoop: Not a valid effect: ${String(i)}`)}finally{this._running=n,globalThis[Dn]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,wc;for(;;){let t=this._stack.pop();if(!t)return;let n=t[Zn]&&t[Zn](this);if(n)return n[e]=n,n;if(t[e])return t}}yieldWith(e){return this._yielded=e,Qn}children(){return this._children??=new Set}pipe(){return rt(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&Xa(t,e))return;let n=this.getRef(Zo);n!==this.currentScheduler&&(this.currentScheduler=n,this._dispatcher=void 0),this.currentSpan=ao(e,Ts),this.currentLogLevel=this.getRef(Vs),this.minimumLogLevel=this.getRef(Hs),this.currentStackFrame=this.getRef(Fs),this.maxOpsBeforeYield=this.getRef(rs),this.currentPreventYield=this.getRef(is),this.runtimeMetrics=ao(e,Ps);let r=ao(e,js);this.currentTracerContext=r?r.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag===`Span`?this.currentSpan:void 0}},wc={[Yn](e,t){return Nc(t._interruptedCause)},[Xn](e,t){return Nc(t._interruptedCause)}},Tc={interruptChildren:void 0},Ec=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(Dr.key,e.currentStackFrame),Ja(t)},Dc=e=>{let t=e;return t._exit?Mc(t._exit):Yc(n=>t._exit?n(Mc(t._exit)):Fc(e.addObserver(e=>n(Mc(e)))))},Oc=e=>Yc(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(Mc(r))}return a(),Fc(()=>i?.())}),kc=e=>jr(t=>Ac(e,t.id)),Ac=S(e=>At(e[0],yc),(e,t,n)=>jr(r=>{let i=Ec(r);return i=i&&n?po(i,n):i??n,e.interruptUnsafe(t,i),ul(Dc(e))})),jc=e=>jr(t=>{let n=Ec(t),r=fa();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return ul(Oc(r))}),Mc=Tr,Nc=Or,Pc=kr,Fc=Cr({op:`Sync`,[Jn](e){let t=this[w](),n=e.getCont(Yn);return n?n[Yn](t,e):e.yieldWith(Tr(t))}}),Ic=Cr({op:`Suspend`,[Jn](e){return this[w]()}}),Lc=zi({onFailure:Pc,onSuccess:Mc}),Rc=Cr({op:`Yield`,[Jn](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(xl)},this[w]??0),e.yieldWith(()=>{t=!0})}})(0),zc=Mc(T()),Bc=e=>Ic(()=>Nc(Un(e))),Vc=e=>Ar(e),Hc=e=>Ic(()=>Pc(Un(e))),Uc=Mc(void 0),Wc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Td(e,`An error occurred in Effect.try`):e.catch;return Ic(()=>{try{return Mc(Un(t))}catch(e){return Pc(Un(()=>n(e)))}})},Gc=e=>qc(function(t,n){Un(()=>e(n)).then(e=>t(Mc(e)),e=>t(Vc(e)))},e.length!==0),Kc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Td(e,`An error occurred in Effect.tryPromise`):e.catch;return qc(function(e,r){let i=t=>{try{e(Pc(Un(()=>n(t))))}catch(t){e(Vc(t))}};try{Un(()=>t(r)).then(t=>e(Mc(t)),i)}catch(e){i(e)}},t.length!==0)},qc=Cr({op:`Async`,single:!1,[Jn](e){let t=Un(()=>this[w][0].bind(e.currentScheduler)),n=!1,r=!1,i=this[w][1]?new AbortController:void 0,a=t(t=>{n||(n=!0,r?e.evaluate(t):r=t)},i?.signal);return r===!1?(r=!0,e._yielded=()=>{n=!0},i===void 0&&a===void 0||e._stack.push(Jc(()=>(n=!0,i?.abort(),a??xl))),Qn):r}}),Jc=Cr({op:`AsyncFinalizer`,[Zn](e){e.interruptible&&(e.interruptible=!1,e._stack.push(ku))},[Xn](e,t){return nc(e)?dl(this[w](),()=>Nc(e)):Nc(e)}}),Yc=e=>qc(e,e.length>=2),Xc=Yc(dt),Zc=(...e)=>Ic(()=>al(e.length===1?e[0]():e[1].call(e[0].self))),Qc=(e,...t)=>{let n=t.length===0?function(){return Ic(()=>al(e.apply(this,arguments)))}:function(){let n=Ic(()=>al(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return $c(e.length,n)},$c=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),el=Js(2),tl=function(){let e=typeof arguments[0]==`string`,t=e?arguments[0]:`Effect.fn`,n=e?arguments[1]:void 0,r=Gs();Ks(2);let i=new globalThis.Error;return Ks(r),e?(r,...a)=>nl(t,r,i,a,e,n):nl(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,n)},nl=(e,t,n,r,i,a)=>{let o=typeof t==`function`?t:r.shift().bind(t.self);return $c(o.length,function(...t){let s=Ic(()=>{let e=o.apply(this,arguments);return tr(e)?e:al(e)});for(let e=0;e<r.length;e++)s=r[e](s,...t);if(!tr(s))return s;let c=Gs();Ks(2);let l=new globalThis.Error;return Ks(c),Ol(i?od(e,a,e=>sd(s,e)):s,Fs,t=>({name:e,stack:el(()=>l.stack),parent:{name:`${e} (definition)`,stack:el(()=>n.stack),parent:t}}))})},rl=(e,...t)=>$c(e.length,t.length===0?function(){return il(()=>e.apply(this,arguments))}:function(){let n=il(()=>e.apply(this,arguments));for(let e of t)n=e(n);return n}),il=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return Mc(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}if(i&&i._tag===`Failure`)return r.value;{let n=!0;return Ic(()=>n?(n=!1,dl(r.value,e=>al(t,e))):Ic(()=>al(e())))}}}catch(e){return Vc(e)}},al=Cr({op:`Iterator`,single:!1,[Yn](e,t){let n=this[w][0];for(;;){let r=n.next(e);if(r.done)return Mc(r.value);if(!pl(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[Jn](e){return this[Yn](this[w][1],e)}}),ol=S(2,(e,t)=>{let n=Mc(t);return dl(e,e=>n)}),sl=e=>hl(e,E),cl=S(2,(e,t)=>dl(e,e=>tr(t)?t:Un(()=>t(e)))),ll=S(2,(e,t)=>dl(e,e=>ol(tr(t)?t:Un(()=>t(e)),e))),ul=e=>dl(e,e=>xl),dl=S(2,(e,t)=>{let n=Object.create(fl);return n[w]=e,n[Yn]=t.length===1?t:e=>t(e),n}),fl=Sr({op:`OnSuccess`,[Jn](e){return e._stack.push(this),this[w]}}),pl=e=>Gn in e,ml=S(2,(e,t)=>pl(e)?e._tag===`Success`?t(e.value):e:dl(e,t)),hl=S(2,(e,t)=>dl(e,e=>Mc(Un(()=>t(e))))),gl=S(2,(e,t)=>pl(e)?Sl(e,t):hl(e,t)),_l=S(2,(e,t)=>pl(e)?Cl(e,t):Ul(e,t)),vl=S(2,(e,t)=>pl(e)?wl(e,t):Wl(e,t)),yl=e=>e._tag===`Success`,bl=e=>e._tag===`Failure`?ji(e.cause):Mi(e),xl=Tr(void 0),Sl=S(2,(e,t)=>e._tag===`Success`?Tr(t(e.value)):e),Cl=S(2,(e,t)=>{if(e._tag===`Success`)return e;let n=$s(e.cause);return Ii(n)?e:kr(t(n.success))}),wl=S(2,(e,t)=>{if(e._tag===`Success`)return Tr(t.onSuccess(e.value));let n=$s(e.cause);return Ii(n)?e:kr(t.onFailure(n.success))}),Tl=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?xl:Or(fr(t))},El=e=>jr(t=>Mc(fo(t.context,e))),Dl=S(2,(e,t)=>jr(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),gu(e,()=>{n.setContext(r)}))})),Ol=S(3,(e,t,n)=>Dl(e,e=>{let r=oo(e,t),i=n(r);return r===i?e:no(e,t,i)})),kl=()=>Al,Al=jr(e=>Mc(e.context)),jl=e=>jr(t=>e(t.context)),Ml=S(2,(e,t)=>pl(e)?e:Dl(e,po(t))),Nl=function(){return arguments.length===1?S(2,(e,t)=>Pl(e,arguments[0],t)):S(3,(e,t,n)=>Pl(e,t,n)).apply(this,arguments)},Pl=(e,t,n)=>Dl(e,no(t,n)),Fl=S(e=>tr(e[0]),(e,t)=>Fu({while:st,body:ot(t?.disableYield?e:dl(e,e=>Rc)),step:dt})),Il=S(2,(e,t)=>{let n=Object.create(Ll);return n[w]=e,n[Xn]=t.length===1?t:e=>t(e),n}),Ll=Sr({op:`OnFailure`,[Jn](e){return e._stack.push(this),this[w]}}),Rl=S(3,(e,t,n)=>Il(e,e=>{let r=t(e);return Ii(r)?Nc(r.failure):Un(()=>n(r.success,e))})),zl=S(2,(e,t)=>Rl(e,$s,e=>t(e))),Bl=S(2,(e,t)=>Rl(e,tc,t)),Vl=S(e=>tr(e[0]),(e,t,n,r)=>Il(e,e=>{let i=$s(e);if(Ii(i))return Nc(i.failure);let a=t(i.success);return Ii(a)?r?Un(()=>r(a.failure)):Nc(e):Un(()=>n(a.success))})),Hl=S(e=>tr(e[0]),(e,t,n)=>{let r;return Vl(e,e=>(r??=Object.keys(t),At(e,`_tag`)&&_t(e._tag)&&r.includes(e._tag)?ji(e):Mi(e)),e=>Un(()=>t[e._tag](e)),n)}),Ul=S(2,(e,t)=>zl(e,e=>Hc(()=>t(e)))),Wl=S(2,(e,t)=>Yl(e,{onFailure:e=>Hc(()=>t.onFailure(e)),onSuccess:e=>Fc(()=>t.onSuccess(e))})),Gl=e=>zl(e,Vc),Kl=e=>Zl(e,{onFailure:Mi,onSuccess:ji}),ql=S(2,(e,t)=>{let n=Object.create(Jl);return n[w]=e,n[Yn]=t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),n[Xn]=t.onFailure.length===1?t.onFailure:e=>t.onFailure(e),n}),Jl=Sr({op:`OnSuccessAndFailure`,[Jn](e){return e._stack.push(this),this[w]}}),Yl=S(2,(e,t)=>ql(e,{onFailure:e=>{let n=e.reasons.find(vr);return n?Un(()=>t.onFailure(n.error)):Nc(e)},onSuccess:t.onSuccess})),Xl=S(2,(e,t)=>Yl(e,{onFailure:e=>Fc(()=>t.onFailure(e)),onSuccess:e=>Fc(()=>t.onSuccess(e))})),Zl=S(2,(e,t)=>{if(pl(e)){if(e._tag===`Success`)return Tr(t.onSuccess(e.value));let n=$s(e.cause);return Ii(n)?e:Tr(t.onFailure(n.success))}return Xl(e,t)}),Ql=e=>pl(e)?Tr(e):$l(e),$l=Cr({op:`Exit`,[Jn](e){return e._stack.push(this),this[w]},[Yn](e,t,n){return Mc(n??Tr(e))},[Xn](e,t,n){return Mc(n??Or(e))}}),eu=`~effect/Scope`,tu=`~effect/Scope/Closeable`,nu=O(`effect/Scope`),ru=(e,t)=>Ic(()=>iu(e,t)??Uc),iu=(e,t)=>{if(e.state._tag===`Closed`)return;let n={_tag:`Closed`,exit:t};if(e.state._tag===`Empty`){e.state=n;return}let{finalizers:r}=e.state;if(e.state=n,r.size!==0)return r.size===1?r.values().next().value(t):ou(e,r,t)},au=(e,t)=>yl(e)?t:Il(t,t=>Nc(ic(e.cause,t))),ou=Qc(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=Sc();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*Ql(s(n))):i.push(Vu(o,s(n),!0,!0,`inherit`))}return i.length>0&&(r=yield*Oc(i)),yield*Tl(r)}),su=(e,t)=>{let n=fu(t);if(e.state._tag===`Closed`)return n.state=e.state,n;let r={};return uu(e,r,e=>ru(n,e)),uu(n,r,t=>Fc(()=>du(e,r))),n},cu=(e,t)=>Ic(()=>e.state._tag===`Closed`?t(e.state.exit):(uu(e,{},t),Uc)),lu=(e,t)=>cu(e,ot(t)),uu=(e,t,n)=>{e.state._tag===`Empty`?e.state={_tag:`Open`,finalizers:new Map([[t,n]])}:e.state._tag===`Open`&&e.state.finalizers.set(t,n)},du=(e,t)=>{e.state._tag===`Open`&&e.state.finalizers.delete(t)},fu=(e=`sequential`)=>({[tu]:tu,[eu]:eu,strategy:e,state:pu}),pu={_tag:`Empty`},mu=Nl(nu),hu=e=>Ic(()=>{let t=fu();return _u(e(t),e=>Ic(()=>iu(t,e)??Uc))}),gu=Cr({op:`OnExit`,single:!1,[Jn](e){return e._stack.push(this),this[w][0]},[Zn](e){e.interruptible&&this[w][2]!==!0&&(e._stack.push(ku),e.interruptible=!1)},[Yn](e,t,n){n??=Tr(e);let r=this[w][1](n);return r?dl(r,e=>n):n},[Xn](e,t,n){n??=Or(e);let r=this[w][1](n);return r?dl(au(n,r),e=>n):n}}),_u=S(2,gu),vu=S(2,(e,t)=>_u(e,e=>t)),yu=S(3,(e,t,n)=>_u(e,e=>{let r=t(e);return Ii(r)?Uc:n(r.success,e)})),bu=S(2,(e,t)=>yu(e,bl,t)),xu=S(3,(e,t,n)=>_u(e,e=>{if(e._tag!==`Failure`)return Uc;let r=t(e.cause);return Ii(r)?Uc:n(r.success,e.cause)})),Su=S(2,(e,t)=>xu(rc,t)(e)),Cu=(e,t,n)=>Nu(r=>dl(e,e=>gu(r(t(e)),t=>n(e,t),!0))),wu=S(2,(e,t)=>Fc(()=>{let n=Wo(Eo(t)),r=Number.isFinite(n),i=Qu(!1),a=0,o=!1,s,c=dl(i.await,()=>s);return[jr(t=>{let l=t.getRef(dd),u=r?l.currentTimeMillisUnsafe():0;return o||u<a?s??c:(o=!0,i.closeUnsafe(),s=void 0,_u(e,e=>Fc(()=>{o=!1,a=l.currentTimeMillisUnsafe()+n,s=e,i.openUnsafe()})))}),Fc(()=>{a=0,i.closeUnsafe(),s=void 0})]})),Tu=S(2,(e,t)=>hl(wu(e,t),e=>e[0])),Eu=e=>Tu(e,Fo),Du=e=>jr(t=>t.interruptible?(t.interruptible=!1,t._stack.push(ku),e):e),Ou=Cr({op:`SetInterruptible`,[Zn](e){if(e.interruptible=this[w],e._interruptedCause&&e.interruptible)return()=>Nc(e._interruptedCause)}}),ku=Ou(!0),Au=Ou(!1),ju=e=>{if(e.interruptible=!0,e._stack.push(Au),e._interruptedCause)return Nc(e._interruptedCause)},Mu=e=>jr(t=>t.interruptible?e:ju(t)??e),Nu=e=>jr(t=>t.interruptible?(t.interruptible=!1,t._stack.push(ku),e(Mu)):e(C)),Pu=(e,t)=>Mt(e)?t?.mode===`result`?Iu(e,Kl,t):Iu(e,C,t):t?.discard?t.mode===`result`?Iu(Object.values(e),Kl,t):Iu(Object.values(e),C,t):Ic(()=>{let n={};return ol(Iu(Object.entries(e),([e,r])=>hl(t?.mode===`result`?Kl(r):r,t=>{xn(n,e,t)}),{discard:!0,concurrency:t?.concurrency}),n)}),Fu=Cr({op:`While`,[Yn](e,t){return this[w].step(e),this[w].while()?(t._stack.push(this),this[w].body()):xl},[Jn](e){return this[w].while()?(e._stack.push(this),this[w].body()):xl}}),Iu=S(e=>typeof e[1]==`function`,(e,t,n)=>Ic(()=>{let r=n?.concurrency??1,i=r===`unbounded`?1/0:Math.max(1,r);if(i===1)return Lu(e,t,n);let a=Yi(e),o=a.length;if(o===0)return n?.discard?Uc:Mc([]);let s=n?.discard?void 0:Array(o),c=Bu({f:t,out:s},a,{concurrency:i});return c?ol(c,s):Mc(s)})),Lu=(e,t,n)=>Ic(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return ol(Fu({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Ru=e=>{let t=e.onItem,n=e.step,r=(e,i,a,o)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!pl(c))return dl(Ql(c),t=>n(e,s,t,a)??r(e,i,a+1,o)??Uc);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return(e,i,a)=>{let o=0,s=a?.end??i.length,c=a?.concurrency??1;if(c===1)return r(e,i,0,s);let l=a?.orderedStep===!0&&c>1,u=!1,d,f,p,m=!1,h,g,_=o,v=l?Array(s):void 0,y=e=>{let t=Ar(e);return h=t,u=!0,m=!0,f&&f.size>0?dl(Du(jc(Array.from(f))),()=>t):t},b=(t,r,a)=>{if(!l)return n(e,t,r,a);if(h)return h;for(v[a]=r;_<s;){let t=v[_];if(t===void 0)return;v[_]=void 0;let r=_++,a=n(e,i[r],t,r);if(a)return a}},x=()=>{let n=!1;for(;!h&&o<s;o++){let r=i[o],a=g??t(e,r,o);if(pl(a)){if(h=b(r,a,o),h)break}else if(d){g=void 0;let e=Vu(d,a,!0,!0,`inherit`);if(e._exit){if(h=b(r,e._exit,o),h)break;continue}f.add(e);let t=o;if(e.addObserver(i=>{f.delete(e);try{if(h){if(!m&&i._tag===`Failure`)for(let e of i.cause.reasons)if(e._tag===`Interrupt`)continue;else h._tag===`Failure`?h.cause.reasons.push(e):h=Or(fr([e]))}else{let e=b(r,i,t);e&&(h=e._tag===`Failure`?Or(fr(e.cause.reasons.slice())):e,x())}if(n){let e=x();e&&p(e)}else u&&f.size===0&&p(h??Uc)}catch(e){p(y(e))}}),f.size<c)continue;n=!0,o++;return}else return Yc(e=>{d=Sc(),f=new Set,g=a,p=e;let t;try{t=x()}catch(t){return e(y(t))}return t?e(t):Ic(()=>(h=xl,m=!0,f?jc(f):Uc))})}if(u=!0,h){if(f&&f.size>0){let e=Ec(d);f.forEach(t=>t.interruptUnsafe(d.id,e));return}if(p||h._tag===`Failure`)return h}else if(p){if(f)f.size===0&&p(Uc);else return xl}};return x()}},zu=()=>Ru,Bu=Ru({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),Vu=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Cc(a.context,o);return n?s.evaluate(t):a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),!r&&!s._exit&&(a.children().add(s),s.addObserver(()=>a._children.delete(s))),s},Hu=e=>(t,n)=>{let r=new Cc(n?.scheduler?no(e,Zo,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Uu=Hu($a()),Wu=e=>{let t=Hu(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},Gu=(e=>{let t=Wu(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw sc(e.cause);return e.value})})($a()),Ku=e=>{let t=Hu(e);return e=>{if(pl(e))return e;let n=new ts(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??Ar(new Cd(r))}},qu=Ku($a()),Ju=(e=>{let t=Ku(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw sc(n.cause);return n.value}})($a()),Yu=Mc(!0),Xu=Mc(!1),Zu=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return Yu;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],Yu}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](xl)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](xl)}open=jr(e=>this._isOpen?Xu:(this._isOpen=!0,this.scheduleUnsafe(e)));release=jr(e=>this._isOpen?Xu:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=Yc(e=>this._isOpen?e(Uc):(this.waiters.push(e),Fc(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=Fc(()=>this.closeUnsafe());whenOpen=e=>dl(this.await,()=>e);isOpen(){return this._isOpen}},Qu=e=>new Zu(e??!1),$u=BigInt(0),ed={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:$u,endTime:$u,exit:xl},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},td=e=>Object.assign(Object.create(ed),e),nd=e=>e?so(e.annotations,Os)?e._tag===`Span`?nd(Ci(e.parent)):T():E(e):T(),rd=(e,t,n)=>{let r=!e.getRef(Is)||n?.annotations&&so(n.annotations,Os),i=n?.parent===void 0?n?.root?T():nd(e.currentSpan):E(n.parent),a;if(r)a=td({name:t,parent:i,annotations:no(n?.annotations??$a(),Os,!0)});else{let r=e.getRef(Ms),o=e.getRef(dd),s=e.getRef(Ls),c=e.getRef(Rs),l=e.getRef(zs),u=n?.level??e.getRef(ks),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??$a(),links:d,startTime:s?o.currentTimeNanosUnsafe():BigInt(0),kind:n?.kind??`internal`,root:n?.root??hi(i),sampled:n?.sampled??(D(i)&&i.value.sampled===!1?!1:!Dd(e.getRef(As),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},id=(e,t)=>(t=typeof t==`function`?t:ut,Ol(Fs,n=>({name:e,stack:t,parent:n}))),ad=(e,t,n,r)=>Fc(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():$u,t)}),od=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return jr(t=>{let i=rd(t,e,n),a=t.getRef(dd),o=t.getRef(Ls);return _u(Un(()=>r(i)),e=>ad(i,e,a,o))})},sd=Nl(Es),cd=function(){let e=tr(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=C;return t._tag===`Span`&&(n=qs(n),r=id(t.name,n?.captureStackTrace)),e?sd(r(arguments[0]),t):e=>sd(r(e),t)},ld=function(){let e=typeof arguments[0]!=`string`,t=e?arguments[1]:arguments[0],n=qs(arguments[2]);if(e){let e=arguments[0];return od(t,arguments[2],t=>cd(e,t,n))}let r=typeof arguments[1]==`function`?arguments[1]:void 0,i=r?void 0:arguments[1];return(e,...a)=>od(t,r?r(...a):i,t=>cd(e,t,n))},ud=(...e)=>jr(t=>{let n=t.currentSpanLocal;if(n){if(e.length===1)for(let[t,r]of Object.entries(e[0]))n.attribute(t,r);else n.attribute(e[0],e[1])}return Uc}),dd=ho(`effect/Clock`,{defaultValue:()=>new pd}),fd=2**31-1,pd=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=Fc(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return gd()}currentTimeNanos=Fc(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return hd()}monotonicTimeNanos=Fc(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(Wo(e))}sleepMillis(e){return e<=0?Rc:Number.isFinite(e)?Yc(t=>{let n=e>fd?this.sleepMillis(e-fd):Uc,r=setTimeout(()=>t(n),Math.min(e,fd));return Fc(()=>clearTimeout(r))}):Xc}},md=BigInt(1e6),hd=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*md;return e>t&&(t=e),t}}(),gd=function(){let e=BigInt(1e9),t;return()=>{let n=hd(),r=BigInt(Date.now())*md;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),_d=e=>jr(t=>e(t.getRef(dd))),vd=e=>_d(t=>t.sleep(Eo(e))),yd=_d(e=>e.currentTimeMillis);Pr(`TimeoutError`);var bd=`~effect/Cause/IllegalArgumentError`,xd=class extends Pr(`IllegalArgumentError`){[bd]=bd;constructor(e){super({message:e})}};Pr(`ExceededCapacityError`);var Sd=`~effect/Cause/AsyncFiberError`,Cd=class extends Pr(`AsyncFiberError`){[Sd]=Sd;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},wd=`~effect/Cause/UnknownError`,Td=class extends Pr(`UnknownError`){[wd]=wd;constructor(e,t){super({message:t,cause:e})}},Ed=ho(`effect/Console/CurrentConsole`,{defaultValue:()=>globalThis.console}),Dd=di(li(ci,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),Od=ho(`effect/Loggers/CurrentLoggers`,{defaultValue:()=>new Set([Ld,Rd])}),kd=ho(`effect/Logger/LogToStderr`,{defaultValue:ct}),Ad={"~effect/Logger":{_Message:C,_Output:C},pipe(){return rt(this,arguments)}},jd=e=>{let t=Object.create(Ad);return t.log=e,t},Md=e=>e.replace(/[\s="]/g,`_`),Nd=(e,t)=>`${Md(e[0])}=${t-e[1]}ms`,Pd=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];ar(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?fr(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=pr),jr(r=>{let i=e??r.currentLogLevel;if(Dd(r.minimumLogLevel,i))return Uc;let a=r.getRef(dd),o=r.getRef(Od);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return Uc})},Fd={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Fd.gray,Fd.blue,Fd.green,Fd.yellow,Fd.red,Fd.bgBrightRed,Fd.black;var Id=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,Ld=jd(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(gc(e));let o=t.getTime(),s=n.getRef(Us),c=``;for(let e of s)c+=` ${Nd(e,o)}`;let l=n.getRef(Bs);Object.keys(l).length>0&&a.push(l);let u=n.getRef(Ed);(n.getRef(kd)?u.error:u.log)(`[${Id(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),Rd=jd(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(dd),a=t.getRef(Bs),o=t.currentSpan;if(o===void 0||o._tag===`ExternalSpan`)return;let s={};for(let[e,t]of Object.entries(a))xn(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=gc(e)),o.event(zn(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)}),zd=ar,Bd=or,Vd=vr,Hd=fr,Ud=pr,Wd=mr,Gd=e=>new dr(e),Kd=e=>new hr(e),qd=Zs,Jd=ac,Yd=ic,Xd=sc,Zd=ec,Qd=nc,$d=gc,ef=Ir,tf=Br,nf=xd;O()(`effect/Cause/StackTrace`),O()(`effect/Cause/InterruptorStackTrace`);var rf=nr,af=Tr,of=Or,sf=kr,cf=xl,lf=yl,uf={"~effect/Deferred":{_A:C,_E:C},pipe(){return rt(this,arguments)}},df=()=>{let e=Object.create(uf);return e.resumes=void 0,e.effect=void 0,e},ff=()=>Fc(()=>df()),pf=e=>Yc(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),Fc(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),mf=S(2,(e,t)=>Fc(()=>vf(e,t))),hf=e=>Fc(()=>gf(e)),gf=e=>e.effect!==void 0,_f=S(2,(e,t)=>mf(e,Tr(t))),vf=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},yf=nu,bf=fu,xf=mu,Sf=cu,Cf=lu,wf=su,Tf=ru,Ef=`~effect/Layer`,Df=`~effect/Layer/MemoMap`,Of=(e,t)=>(e.observers++,cl(cu(t,t=>e.finalizer(t)),e.effect)),kf={[Ef]:{_ROut:C,_E:C,_RIn:C},pipe(){return rt(this,arguments)}},Af=e=>{let t=Object.create(kf);return t.build=e,t},jf=e=>Af((t,n)=>{let r=wf(n);return _u(e(t,r),e=>e._tag===`Failure`?Tf(r,e):Uc)}),Mf=e=>{let t=jf((n,r)=>n.getOrElseMemoize(t,r,e));return t},Nf=(e,t,n,r)=>{let i=bf(),a=df(),o={observers:1,effect:pf(a),finalizer:n=>Ic(()=>(o.observers--,o.observers===0?(e.map.delete(t),Tf(i,n)):Uc))};return e.map.set(t,o),cu(n,o.finalizer).pipe(dl(()=>r(e,i)),_u(e=>(o.effect=e,mf(a,e))))},Pf=class{get[Df](){return Df}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?Of(n,t):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return Ic(()=>this.get(e,t)||Nf(this,e,t,n))}},Ff=()=>new Pf,If=e=>new Pf(e),Lf=class e extends O()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=io(t,e);return n?If(n):Ff()}},Rf=S(3,(e,t,n)=>Nl(hl(e.build(t,n),no(Lf,t)),Lf,t)),zf=S(2,(e,t)=>jr(n=>Rf(e,Lf.forkOrCreate(n.context),t))),Bf=function(){return arguments.length===1?e=>Vf(to(arguments[0],e)):Vf(to(arguments[0],arguments[1]))},Vf=e=>Af(ot(Mc(e))),Hf=function(){return arguments.length===1?e=>Uf(arguments[0],e):Uf(arguments[0],arguments[1])},Uf=(e,t)=>Wf(hl(t,t=>to(e,t))),Wf=e=>Mf((t,n)=>xf(e,n)),Gf=e=>Wf(ol(e,$a())),Kf=(e,t,n)=>{let r=wf(n,`parallel`);return Iu(e,e=>e.build(t,wf(r,`sequential`)),{concurrency:e.length}).pipe(hl(e=>mo(...e)))},qf=(...e)=>jf((t,n)=>Kf(e,t,n)),Jf=(e,t,n)=>jf((r,i)=>dl(Array.isArray(t)?Kf(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(Ml(t),hl(e=>n(e,t))))),Yf=S(2,(e,t)=>Jf(e,t,C)),Xf=S(2,(e,t)=>Jf(e,t,(e,t)=>po(t,e))),Zf=yd,Qf=`~effect/time/DateTime`,$f=`~effect/time/DateTime/TimeZone`,ep={[Qf]:Qf,pipe(){return rt(this,arguments)},[Ln](){return this.toString()},toJSON(){return Fp(this).toJSON()}},tp={...ep,_tag:`Utc`,[Nt](){return zt(this.epochMilliseconds)},[Zt](e){return sp(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Fp(this).toJSON()})`}},np={...ep,_tag:`Zoned`,[Nt](){return It(zt(this.epochMilliseconds))(Pt(this.zone))},[Zt](e){return sp(e)&&e._tag===`Zoned`&&this.epochMilliseconds===e.epochMilliseconds&&Qt(this.zone,e.zone)},toString(){return`DateTime.Zoned(${tm(this)})`}},rp={[$f]:$f,[Ln](){return this.toString()}},ip={...rp,_tag:`Named`,[Nt](){return Bt(`Named:${this.id}`)},[Zt](e){return lp(e)&&e._tag===`Named`&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:`TimeZone`,_tag:`Named`,id:this.id}}},ap={...rp,_tag:`Offset`,[Nt](){return Bt(`Offset:${this.offset}`)},[Zt](e){return lp(e)&&e._tag===`Offset`&&this.offset===e.offset},toString(){return`TimeZone.Offset(${Rp(this.offset)})`},toJSON(){return{_id:`TimeZone`,_tag:`Offset`,offset:this.offset}}},op=(e,t,n)=>{let r=Object.create(np);return r.epochMilliseconds=e,r.zone=t,Object.defineProperty(r,"partsUtc",{value:n,enumerable:!1,writable:!0}),Object.defineProperty(r,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(r,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),r},sp=e=>At(e,Qf),cp=e=>sp(e[0]),lp=e=>At(e,$f),up=e=>lp(e)&&e._tag===`Named`,dp=e=>e._tag===`Utc`,fp=e=>e._tag===`Zoned`,pp=hn((e,t)=>e.epochMilliseconds===t.epochMilliseconds),mp=si((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:+(e.epochMilliseconds>t.epochMilliseconds)),hp=e=>{let t=Object.create(tp);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},gp=e=>{let t=e.getTime();if(Number.isNaN(t))throw new nf(`Invalid date`);return hp(t)},_p=e=>{if(sp(e))return e;if(e instanceof Date)return gp(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return gp(new Date(e.epochMilliseconds));let t=new Date(0);return Wp(t,e),gp(t)}return typeof e==`string`&&!vp(e)?gp(new Date(e+`Z`)):gp(new Date(e))},vp=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),yp=-864e13+432e5,bp=864e13-504e5,xp=(e,t)=>{let n=t?.timeZone;if(n===void 0&&sp(e)&&fp(e))return e;let r=_p(e);if(r.epochMilliseconds<yp||r.epochMilliseconds>bp)throw RangeError(`Epoch millis out of range: ${r.epochMilliseconds}`);n===void 0&&typeof e==`object`&&`timeZoneId`in e&&(n=e.timeZoneId);let i;if(n===void 0)i=Ap(new Date(r.epochMilliseconds).getTimezoneOffset()*-60*1e3);else if(lp(n))i=n;else if(typeof n==`number`)i=Ap(n);else{let e=Np(n);if(hi(e))throw new nf(`Invalid time zone: ${n}`);i=e.value}return t?.adjustForTimeZone===!0?Kp(r.epochMilliseconds,i,t?.disambiguation??`compatible`):op(r.epochMilliseconds,i,r.partsUtc)},Sp=wi(_p),Cp=hl(Zf,hp),wp=e=>hp(e.epochMilliseconds),Tp=S(cp,(e,t,n)=>n?.adjustForTimeZone===!0?Kp(e.epochMilliseconds,t,n?.disambiguation??`compatible`):op(e.epochMilliseconds,t,e.partsUtc)),Ep=new Map,Dp={day:`numeric`,month:`numeric`,year:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`,timeZoneName:`longOffset`,fractionalSecondDigits:3,hourCycle:`h23`},Op=e=>{let t=e.resolvedOptions().timeZone;if(Ep.has(t))return Ep.get(t);let n=Object.create(ip);return n.id=t,n.format=e,Ep.set(t,n),n},kp=e=>{if(Ep.has(e))return Ep.get(e);try{return Op(new Intl.DateTimeFormat(`en-US`,{...Dp,timeZone:e}))}catch{throw new nf(`Invalid time zone: ${e}`)}},Ap=e=>{let t=Object.create(ap);return t.offset=e,t},jp=wi(kp),Mp=/^(?:GMT|[+-])/,Np=e=>{if(Mp.test(e)){let t=Jp(e);return t===null?T():E(Ap(t))}return jp(e)},Pp=S(cp,(e,t,n)=>Ti(jp(t),t=>Tp(e,t,n))),Fp=e=>new Date(e.epochMilliseconds),Ip=e=>{if(e._tag===`Utc`)return new Date(e.epochMilliseconds);if(e.zone._tag===`Offset`)return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>e.type!==`literal`),n=new Date(0);return n.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),n.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMilliseconds=n.getTime(),n},Lp=e=>Ip(e).getTime()-Bp(e),Rp=e=>{let t=Math.abs(e),n=Math.floor(t/36e5),r=Math.round(t%36e5/6e4);return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},zp=e=>Rp(Lp(e)),Bp=e=>e.epochMilliseconds,Vp=e=>({millisecond:e.getUTCMilliseconds(),second:e.getUTCSeconds(),minute:e.getUTCMinutes(),hour:e.getUTCHours(),day:e.getUTCDate(),weekDay:e.getUTCDay(),month:e.getUTCMonth()+1,year:e.getUTCFullYear()}),Hp=e=>e._tag===`Utc`?Up(e):(e.partsAdjusted===void 0&&(e.partsAdjusted=Zp(e,Vp)),e.partsAdjusted),Up=e=>(e.partsUtc===void 0&&(e.partsUtc=Qp(e,Vp)),e.partsUtc),Wp=(e,t)=>{if(t.year!==void 0&&e.setUTCFullYear(t.year),t.month!==void 0&&e.setUTCMonth(t.month-1),t.day!==void 0&&e.setUTCDate(t.day),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)},Gp=864e5,Kp=(e,t,n)=>{if(t._tag===`Offset`)return op(e-t.offset,t);let r=Yp(e-Gp,e,t),i=Yp(e+Gp,e,t);if(r===i)return op(e-r,t);let a=r<i,o=r-i;if(a){if(Yp(e-i,e,t)===i)return op(e-i,t);let a=op(e-r,t);if(e!==Ip(a).getTime())switch(n){case`reject`:{let n=new Date(e).toISOString();throw RangeError(`Gap time: ${n} does not exist in time zone ${t.id}`)}case`earlier`:return op(e-i,t);case`compatible`:case`later`:return a}return a}if(Yp(e-r,e,t)===r){if(n===`earlier`||n===`compatible`||Yp(e-r+o,e+o,t)===r)return op(e-r,t);if(n===`reject`){let n=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${n} occurs twice in time zone ${t.id}`)}}return op(e-i,t)},qp=/([+-])(\d{2}):(\d{2})$/,Jp=e=>{let t=qp.exec(e);if(t===null)return null;let[,n,r,i]=t;return(n===`+`?1:-1)*(Number(r)*60+Number(i))*60*1e3},Yp=(e,t,n)=>{let r=n.format.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??``;if(r===`GMT`)return 0;let i=Jp(r);return i===null?Lp(op(t,n)):i},Xp=S(cp,(e,t,n)=>{if(e._tag===`Utc`){let n=Fp(e);return t(n),hp(n.getTime())}let r=Ip(e),i=new Date(r.getTime());return t(i),Kp(i.getTime(),e.zone,n?.disambiguation??`compatible`)}),Zp=S(2,(e,t)=>t(Ip(e))),Qp=S(2,(e,t)=>t(Fp(e))),$p=e=>Fp(e).toISOString(),em=e=>{let t=Ip(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${zp(e)}`},tm=e=>e.zone._tag===`Offset`?em(e):`${em(e)}[${e.zone.id}]`;globalThis.Number;var nm=ci;globalThis.String;var rm=e=>e.toLowerCase(),im=e=>e.length>0,am=`~effect/time/Cron`;function om(e){return{tz:e.tz,and:e.and,seconds:Yi(e.seconds),minutes:Yi(e.minutes),hours:Yi(e.hours),days:Yi(e.days),months:Yi(e.months),weekdays:Yi(e.weekdays)}}var sm={[am]:am,[Zt](e){return cm(e)&&Em(this,e)},[Nt](){return ft(Pt(this.tz),It(Pt(this.and)),It(Wt(Yi(this.seconds))),It(Wt(Yi(this.minutes))),It(Wt(Yi(this.hours))),It(Wt(Yi(this.days))),It(Wt(Yi(this.months))),It(Wt(Yi(this.weekdays))))},toObject(){return om(this)},toString(){return`Cron(${An(om(this))})`},toJSON(){let e=om(this);return e._id=`Cron`,e},[Ln](){return this.toJSON()},pipe(){return rt(this,arguments)}},cm=e=>At(e,am),lm=e=>{let t=Object.create(sm);t.seconds=dm.seconds(e.seconds??[0]),t.minutes=dm.minutes(e.minutes),t.hours=dm.hours(e.hours),t.days=dm.days(e.days),t.months=dm.months(e.months),t.weekdays=dm.weekdays(e.weekdays),t.and=e.and===!0,t.tz=bi(e.tz);let n=Array.from(t.seconds),r=Array.from(t.minutes),i=Array.from(t.hours),a=Array.from(t.days),o=Array.from(t.months),s=Array.from(t.weekdays);return t.first={second:n[0]??0,minute:r[0]??0,hour:i[0]??0,day:a[0]??1,month:(o[0]??1)-1,weekday:s[0]??0},t.last={second:n[n.length-1]??59,minute:r[r.length-1]??59,hour:i[i.length-1]??23,day:a[a.length-1]??31,month:(o[o.length-1]??12)-1,weekday:s[s.length-1]??6},t.next={second:pm.next.second(n),minute:pm.next.minute(r),hour:pm.next.hour(i),day:pm.next.day(a),month:pm.next.month(o),weekday:pm.next.weekday(s)},t.prev={second:pm.prev.second(n),minute:pm.prev.minute(r),hour:pm.prev.hour(i),day:pm.prev.day(a),month:pm.prev.month(o),weekday:pm.prev.weekday(s)},t},um=(e,t,n,r=e=>e)=>i=>{let a=[];for(let o of i){if(!Number.isInteger(o)||o<t||o>n)throw RangeError(`${e} must contain only integers between ${t} and ${n}`);a.push(r(o))}return new Set(ia(a,nm))},dm={seconds:um(`seconds`,0,59),minutes:um(`minutes`,0,59),hours:um(`hours`,0,23),days:um(`days`,1,31),months:um(`months`,1,12),weekdays:um(`weekdays`,0,7,e=>e===7?0:e)},fm=(e,t)=>n=>{let r=Array(e).fill(void 0);if(n.length===0)return r;let i;if(t===`next`){let t=n.length-1;for(let a=e-1;a>=0;a--){for(;t>=0&&n[t]>=a;)i=n[t--];r[a]=i}}else{let t=0;for(let a=0;a<e;a++){for(;t<n.length&&n[t]<=a;)i=n[t++];r[a]=i}}return r},pm={prev:{second:fm(60,`prev`),minute:fm(60,`prev`),hour:fm(24,`prev`),day:fm(32,`prev`),month:fm(13,`prev`),weekday:fm(7,`prev`)},next:{second:fm(60,`next`),minute:fm(60,`next`),hour:fm(24,`next`),day:fm(32,`next`),month:fm(13,`next`),weekday:fm(7,`next`)}},mm=`~effect/time/Cron/CronParseError`,hm=class extends ss(`CronParseError`){[mm]=mm},gm=(e,t)=>{let n=e.trim().split(/\s+/).filter(im);if(n.length!==5&&n.length!==6)return Mi(new hm({message:`Invalid number of segments in cron expression`,input:e}));n.length===5&&n.unshift(`0`);let[r,i,a,o,s,c]=n;return Vi({tz:t===void 0||lp(t)?ji(t):Ni(Np(t),()=>new hm({message:`Invalid time zone in cron expression`,input:t})),seconds:Nm(r,Dm),minutes:Nm(i,Om),hours:Nm(a,km),days:Nm(o,Am),months:Nm(s,jm),weekdays:Nm(c,Mm)}).pipe(Ri(({tz:e,seconds:t,minutes:n,hours:r,days:i,months:a,weekdays:o})=>lm({tz:e,seconds:t.values,minutes:n.values,hours:r.values,days:i.values,months:a.values,weekdays:o.values,and:(i.wildcard||o.wildcard)&&i.values.size!==0&&o.values.size!==0})))},_m=(e,t)=>Bi(gm(e,t)),vm=(e,t)=>{let n=xp(t,{timeZone:Ci(e.tz)}).pipe(Hp);return e.seconds.size!==0&&!e.seconds.has(n.second)||e.minutes.size!==0&&!e.minutes.has(n.minute)||e.hours.size!==0&&!e.hours.has(n.hour)||e.months.size!==0&&!e.months.has(n.month)?!1:e.days.size===0&&e.weekdays.size===0?!0:e.and?(e.days.size===0||e.days.has(n.day))&&(e.weekdays.size===0||e.weekdays.has(n.weekDay)):e.weekdays.size===0?e.days.has(n.day):e.days.size===0?e.weekdays.has(n.weekDay):e.days.has(n.day)||e.weekdays.has(n.weekDay)},ym=e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+1,0)).getUTCDate(),bm=(e,t)=>Sm(e,t,`next`),xm=(e,t)=>Sm(e,t,`prev`),Sm=(e,t,n)=>{let r=Ci(e.tz),i=xp(t??new Date,{timeZone:r}),a=n===`prev`,o=a?-1:1,s=e[n],c=a?e.last:e.first,l=a?(e,t)=>e<t:(e,t)=>e>t,u=r!==void 0&&up(r)&&r.id===`UTC`?dt:e=>{let t=xp(e,{timeZone:i.zone,adjustForTimeZone:!0,disambiguation:a?`later`:void 0}).pipe(Ip),n=e.getTime()-t.getTime();(a?n!==0:n>0)&&e.setTime(a?t.getTime():e.getTime()+n)};return Fp(Xp(i,t=>{t.setUTCSeconds(t.getUTCSeconds()+o,0);for(let n=0;n<1e4;n++){if(e.seconds.size!==0){let e=t.getUTCSeconds(),n=s.second[e];if(n===void 0){t.setUTCMinutes(t.getUTCMinutes()+o,c.second),u(t);continue}if(l(n,e)){t.setUTCSeconds(n),u(t);continue}}if(e.minutes.size!==0){let e=t.getUTCMinutes(),n=s.minute[e];if(n===void 0){t.setUTCHours(t.getUTCHours()+o,c.minute,c.second),u(t);continue}if(l(n,e)){t.setUTCMinutes(n,c.second),u(t);continue}}if(e.hours.size!==0){let e=t.getUTCHours(),n=s.hour[e];if(n===void 0){t.setUTCDate(t.getUTCDate()+o),t.setUTCHours(c.hour,c.minute,c.second),u(t);continue}if(l(n,e)){t.setUTCHours(n,c.minute,c.second),u(t);continue}}if(e.weekdays.size!==0||e.days.size!==0){if(e.and){let n=e.days.size===0||e.days.has(t.getUTCDate()),r=e.weekdays.size===0||e.weekdays.has(t.getUTCDay());if(!n||!r){t.setUTCDate(t.getUTCDate()+o),t.setUTCHours(c.hour,c.minute,c.second),u(t);continue}}else{let n=a?-1/0:1/0,r=a?-1/0:1/0;if(e.weekdays.size!==0){let e=t.getUTCDay(),r=s.weekday[e];n=r===void 0?a?c.weekday-7-e:7-e+c.weekday:r-e}if(e.days.size!==0&&n!==0){let e=t.getUTCDate(),n=s.day[e];if(n===void 0){if(a){let e=new Date(t);e.setUTCDate(0);let n=s.day[e.getUTCDate()];if(n===void 0&&(e.setUTCDate(0),n=s.day[e.getUTCDate()]),n===void 0)throw Error(`Unable to find cron date`);e.setUTCDate(n),r=(e.getTime()-t.getTime())/864e5}else r=ym(t)-e+c.day}else r=!a&&n>ym(t)?ym(t)-e+c.day:n-e}let i=a?Math.max(n,r):Math.min(n,r);if(i!==0){t.setUTCDate(t.getUTCDate()+i),t.setUTCHours(c.hour,c.minute,c.second),u(t);continue}}}if(e.months.size!==0){let n=t.getUTCMonth()+1,r=s.month[n],i=n=>{let r=ym(new Date(Date.UTC(t.getUTCFullYear(),n+1,0)));return e.days.size!==0&&e.weekdays.size===0?a?s.day[r]??r:c.day:a?r:1};if(r===void 0){t.setUTCFullYear(t.getUTCFullYear()+o),t.setUTCMonth(c.month,i(c.month)),t.setUTCHours(c.hour,c.minute,c.second),u(t);continue}if(l(r,n)){let e=r-1;t.setUTCMonth(e,i(e)),t.setUTCHours(c.hour,c.minute,c.second),u(t);continue}}return}throw Error(`Unable to find cron date`)}))},Cm=hn((e,t)=>Qt(e.tz,t.tz)&&e.and===t.and&&Tm(e.seconds,t.seconds)&&Tm(e.minutes,t.minutes)&&Tm(e.hours,t.hours)&&Tm(e.days,t.days)&&Tm(e.months,t.months)&&Tm(e.weekdays,t.weekdays)),wm=yn(_n()),Tm=(e,t)=>wm(Yi(e),Yi(t)),Em=S(2,(e,t)=>Cm(e,t)),Dm={min:0,max:59},Om={min:0,max:59},km={min:0,max:23},Am={min:1,max:31},jm={min:1,max:12,aliases:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12}},Mm={min:0,max:7,normalize:e=>e===7?0:e,aliases:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}},Nm=(e,t)=>{let n=new Set,r=e.split(`,`),i=Pm(r[0]),a=i[0]===`*`,o=t.normalize??(e=>e),s=a&&(i[1]===void 0||i[1]===1)?dt:e=>{n.add(o(e))};for(let n=0;n<r.length;n++){let a=r[n],[o,c]=n===0?i:Pm(a);if(c!==void 0){if(!Number.isInteger(c))return Mi(new hm({message:`Expected step value to be a positive integer`,input:e}));if(c<1)return Mi(new hm({message:`Expected step value to be greater than 0`,input:e}));if(c>t.max)return Mi(new hm({message:`Expected step value to be less than or equal to ${t.max}`,input:e}))}if(o===`*`){if(n===0&&(c===void 0||c===1))continue;for(let e=t.min;e<=t.max;e+=c??1)s(e)}else{let[n,r]=Fm(o,t.aliases);if(!Number.isInteger(n))return Mi(new hm({message:`Expected a positive integer`,input:e}));if(n<t.min||n>t.max)return Mi(new hm({message:`Expected a value between ${t.min} and ${t.max}`,input:e}));if(r===void 0)for(let e=n;e<=(c===void 0?n:t.max);e+=c??1)s(e);else{if(!Number.isInteger(r))return Mi(new hm({message:`Expected a positive integer`,input:e}));if(r<t.min||r>t.max)return Mi(new hm({message:`Expected a value between ${t.min} and ${t.max}`,input:e}));if(n>r)return Mi(new hm({message:`Invalid value range`,input:e}));for(let e=n;e<=r;e+=c??1)s(e)}}}return ji({values:n,wildcard:a})},Pm=e=>{let t=e.indexOf(`/`);if(t!==-1){let n=e.slice(t+1);return[e.slice(0,t),Lm.test(n)?Number(n):NaN]}return[e,void 0]},Fm=(e,t)=>{let n=e.indexOf(`-`);return n===-1?[Im(e,t),void 0]:[Im(e.slice(0,n),t),Im(e.slice(n+1),t)]};function Im(e,t){return t?.[rm(e)]??(Lm.test(e)?Number(e):NaN)}var Lm=/^\d+$/,Rm=S(2,(e,t)=>Rl(e,Vm,e=>t(e))),zm=e=>e._tag===`Fail`&&ef(e.error),Bm=e=>{let t,n=!1;for(let r of e.reasons)zm(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Mi(e):n?Mi(Hd(e.reasons.filter(e=>!zm(e)))):ji(t)},Vm=e=>{let t=Bm(e);return Ii(t)?t:ji(t.success.value)},Hm=e=>{let t=Bm(e);return Ii(t)?of(t.failure):af(t.success.value)},Um=(e,t,n)=>hu(r=>dl(n?.local?Rf(t,Ff(),r):zf(t,r),t=>Ml(e,t))),Wm=S(e=>tr(e[0]),(e,t,n)=>Za(t)?Ml(e,t):Um(e,Array.isArray(t)?qf(...t):t,n)),Gm=tr,Km=Pu,qm=Iu,Jm=Gc,Ym=Kc,k=Mc,Xm=zc,Zm=Ic,Qm=Fc,$m=Uc,eh=Yc,th=Xc,A=Zc,j=Pc,nh=Nc,rh=Bc,ih=Vc,ah=Wc,oh=Rc,sh=jr,ch=Lc,M=dl,lh=cl,uh=ll,dh=Kl,fh=Ql,ph=hl,mh=ol,hh=ul,gh=zl,_h=Hl,vh=Il,yh=Bl,bh=Ul,xh=Gl,Sh=vd,Ch=Xl,wh=ql,Th=kl,Eh=jl,Dh=Wm,Oh=Ml,kh=El,Ah=Dl,jh=Nl,Mh=Cu,Nh=vu,Ph=bu,Fh=_u,Ih=Eu,Lh=Mu,Rh=Su,zh=Nu,Bh=Fl,Vh=ud,Hh=od,Uh=ld,Wh=cd,Gh=Uu,Kh=Gu,qh=Ju,Jh=qu,Yh=Qc,N=tl,Xh=Pd(`Warn`),Zh=Pd(`Error`),Qh=Pd(`Info`),$h=Pd(`Debug`);O()(`effect/Effect/Transaction`);var eg=gl,tg=_l,ng=vl,rg=ml,ig=rl;function ag(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function og(e){return t=>ag(t)?.[e]}var sg=`~structural`,cg=`~sentinels`,lg=`~constructor`,ug=og(`brands`),dg=pt(e=>{let t=ag(e)?.identifier;return typeof t==`string`?t:e.getExpected(dg)}),fg=Symbol(),pg=af,mg=pg(fg),hg=pg(fg),gg=e=>e===fg?T():E(e),_g=e=>e._tag===`None`?mg:pg(e.value),vg=`~effect/SchemaIssue/Issue`;function yg(e){return At(e,vg)&&e[vg]===vg}function bg(e){return Object.hasOwn(e,`input`)}var xg=class{[vg]=vg;constructor(e,t){t?.reportInput===!0&&e!==fg&&(this.input=e)}},Sg=class extends xg{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},Cg=class extends xg{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},wg=class extends xg{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},Tg=class extends xg{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},Eg=class extends xg{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Dg=class extends xg{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Og=class extends xg{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},kg=class extends xg{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function Ag(e,t,n,r,i){return new Dg(e,[new wg([t],n)],r,i)}var jg=class extends xg{_tag=`Forbidden`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},Mg=class extends xg{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Ng=class extends xg{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function Pg(e,t,n){if(yg(e))return e;if(typeof e==`string`)return new kg({message:e},t,n);let r=typeof e.issue==`string`?new kg({message:e.issue},t,n):e.issue;return new wg(e.path,r)}function Fg(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new kg(void 0,t,n):Pg(e,t,n)}function Ig(e,t,n,r){return Array.isArray(t)?ta(t)?t.length===1?Pg(t[0],n,r):new Dg(e,ma(t,e=>Pg(e,n,r)),n,r):void 0:Fg(t,n,r)}var Lg=e=>{let t=Jg(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return Hg(dg(e.ast),e);case`InvalidValue`:{let t=Vg(e);if(t!==void 0)return Hg(t,e);let n=Bg(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=Bg(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=Bg(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},Rg=e=>Jg(e.issue)??Jg(e);function zg(e){return t=>({issues:Ug(t,[],e?.leafHook??Lg,e?.checkHook??Rg)})}function Bg(e){return bg(e)?An(e.input):void 0}function Vg(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function Hg(e,t){let n=Bg(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function Ug(e,t,n,r){switch(e._tag){case`Filter`:{let i=r(e);if(i!==void 0)return[{path:t,message:i}];if(e.issue._tag!==`InvalidValue`)return Ug(e.issue,t,n,r);let a=Vg(e.issue);return[{path:t,message:a===void 0?Hg(Wg(e.filter),e):Hg(a,e.issue)}]}case`Encoding`:return Ug(e.issue,t,n,r);case`Pointer`:return Ug(e.issue,[...t,...e.path],n,r);case`Composite`:return e.issues.flatMap(e=>Ug(e,t,n,r));case`AnyOf`:return e.issues.length===0?[{path:t,message:Jg(e)??Hg(dg(e.ast),e)}]:e.issues.flatMap(e=>Ug(e,t,n,r));default:return[{path:t,message:n(e)}]}}function Wg(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>Wg(e)).join(` & `)}}function Gg(){return e=>qg(e,``)}var Kg=Gg();function qg(e,t){let n;switch(e._tag){case`Filter`:{let r=Rg(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return qg(e.issue,t);let r=Vg(e.issue);n=r===void 0?Hg(Wg(e.filter),e):Hg(r,e.issue)}break}case`Encoding`:return qg(e.issue,t);case`Pointer`:return qg(e.issue,t+Nn(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>qg(e,t)).join(`
|
|
14
|
+
`);n=Jg(e)??Hg(dg(e.ast),e);break;default:n=Lg(e)}return t?`${n}\n at ${t}`:n}function Jg(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return Jg(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function Yg(e){let t;for(let n of e.reasons){if(!Vd(n)||!yg(n.error))return;t??=n.error}return t}function Xg(e,t){let n=Yg(e);if(n===void 0)throw Error(t,{cause:e});return n}var Zg=sp,Qg=dp,$g=pp,e_=mp,t_=gp,n_=_p,r_=Sp,i_=Cp,a_=wp,o_=jp,s_=Pp,c_=Fp,l_=Bp;O()(`effect/DateTime/CurrentTimeZone`);var u_=$p,d_=tm,f_=class e extends at{run;constructor(e){super(),this.run=e}map(t){return new e((e,n)=>this.run(e,n).pipe(eg(Ti(t))))}compose(t){return g_(this)?t:g_(t)?this:new e((e,n)=>this.run(e,n).pipe(rg(e=>t.run(e,n))))}};function p_(e){return new f_((t,n)=>j(e(t,n)))}function m_(e){return p_((t,n)=>{let r={message:e(t)};return D(t)?new jg(r,t.value,n):new jg(r)})}var h_=new f_(k);function g_(e){return e.run===h_.run}function __(){return h_}function v_(e){return new f_((t,n)=>hi(t)?Xm:e(t.value,n))}function y_(e){return x_(Ti(e))}function b_(e){return v_((t,n)=>e(t,n).pipe(eg(E)))}function x_(e){return new f_(t=>k(e(t)))}function S_(){return new f_(()=>Xm)}function C_(e){return new f_(t=>{let n=ki(t,wt);return D(n)?k(n):eg(e,E)})}function w_(){return y_(globalThis.String)}function T_(){return y_(globalThis.Number)}function E_(){return y_(globalThis.BigInt)}function D_(e){return v_((t,n)=>ah({try:()=>E(JSON.parse(t,e?.reviver)),catch:()=>new kg({expected:`a valid JSON string`},t,n)}))}function O_(e){return v_((t,n)=>ah({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return E(n)},catch:()=>new kg({expected:`a JSON-serializable value`},t,n)}))}function k_(){return y_(us)}function A_(){return y_(fs)}function j_(){return b_((e,t)=>tg(ch(ds(e)),()=>new kg({expected:`a valid Base64 string`},e,t)))}function M_(){return b_((e,t)=>zi(ms(e),{onFailure:()=>j(new kg({expected:`a valid Base64Url string`},e,t)),onSuccess:k}))}var N_=`~effect/SchemaTransformation/Transformation`,P_=class e{[N_]=N_;_tag=`Transformation`;decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new e(this.encode,this.decode)}compose(t){return new e(this.decode.compose(t.decode),t.encode.compose(this.encode))}};function F_(e){return At(e,N_)&&e[N_]===N_}var I_=e=>F_(e)?e:new P_(e.decode,e.encode);function L_(e){return new P_(b_(e.decode),b_(e.encode))}function R_(e){return new P_(y_(e.decode),y_(e.encode))}function z_(e){return new P_(x_(e.decode),x_(e.encode))}var B_=new P_(__(),__());function V_(){return B_}var H_=new P_(T_(),w_()),U_=new P_(E_(),w_()),W_=e=>Ot(e)&&typeof e.message==`string`,G_=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:Y_(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},K_=e=>{try{let t=In(e);return t===void 0?An(e):JSON.parse(t)}catch{return An(e)}},q_=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},J_=e=>{let t=new WeakSet,n=r=>{if(jt(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=q_(r,e,n);return t.delete(r),i}return K_(r)};return n},Y_=e=>W_(e)?G_(e):e,X_=e=>R_({decode:Y_,encode:J_(e)});function Z_(){return R_({decode:xi,encode:Si})}function Q_(){return z_({decode:E,encode:Di})}var $_=L_({decode:(e,t)=>URL.canParse(e)?k(new URL(e)):j(new kg({expected:`a valid URL string`},e,t)),encode:e=>k(e.href)}),ev=new P_(j_(),k_());function tv(e){return new P_(D_(e??{}),O_(e))}var nv=L_({decode:(e,t)=>gi(r_(e),{onNone:()=>j(new kg({expected:`a valid UTC DateTime string`},e,t)),onSome:e=>k(a_(e))}),encode:e=>k(u_(e))});function rv(e){return t=>t._tag===e}var iv=rv(`Declaration`),av=rv(`Null`),ov=rv(`Void`),sv=rv(`Never`),cv=rv(`Literal`),lv=rv(`UniqueSymbol`),uv=rv(`Arrays`),dv=rv(`Objects`),fv=rv(`Union`),pv=rv(`Suspend`),mv=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},hv={},gv=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},_v=`~effect/Schema`,vv=class{[_v]=_v;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},yv=class e extends vv{_tag=`Declaration`;typeParameters;run;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o}getParser(){let e;return(t,n)=>t===fg?mg:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(t,n,r){let i=Py(this.typeParameters,t);return i===this.typeParameters&&n===this.checks&&r===this.encodingChecks?this:new e(i,this.run,this.annotations,n,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},bv=new class extends vv{_tag=`Null`;getParser(){return Zy(this,null)}getExpected(){return`null`}},xv=class extends vv{_tag=`Undefined`;getParser(){return Zy(this,void 0)}toCodecJson(){return Sy(this,[Sv])}getExpected(){return`undefined`}},Sv=new mv(bv,new P_(y_(()=>void 0),y_(()=>null))),Cv=new xv,wv=new class extends vv{_tag=`Void`;getParser(){let e=pg(void 0);return t=>t===fg?mg:e}toCodecJson(){return Sy(this,[Sv])}getExpected(){return`void`}},Tv=new class extends vv{_tag=`Never`;getParser(){return Qy(this,Et)}getExpected(){return`never`}},Ev=new class extends vv{_tag=`Unknown`;getParser(){return Qy(this,Dt)}getExpected(){return`unknown`}},Dv=class extends vv{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${An(e)}`);this.literal=e}getParser(){return Zy(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Ov(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Ov(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Ov(e){let t=globalThis.String(e.literal);return Sy(e,[new mv(new Dv(t),new P_(y_(()=>e.literal),y_(()=>t)))])}var kv=new class extends vv{_tag=`String`;getParser(){return Qy(this,_t)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&ub(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},Av=class extends vv{_tag=`Number`;getParser(){return Qy(this,vt)}matchKey(e,t){return this._match(nb,e,t)}matchPart(e,t){return this._match(tb,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:ub(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(jv(this.checks,`effect/schema/isFinite`)||jv(this.checks,`effect/schema/isInt`))?this:Sy(this,[_y])}toCodecStringTree(){return this.toCodecJson()===this?Sy(this,[ab]):Sy(this,[ob])}getExpected(){return`number`}};function jv(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&jv(e.checks,t))}var Mv=new Av,Nv=new class extends vv{_tag=`Boolean`;getParser(){return Qy(this,yt)}getExpected(){return`boolean`}},Pv=new class extends vv{_tag=`BigInt`;getParser(){return Qy(this,bt)}matchPart(e,t){if(!sb.test(e))return;let n=globalThis.BigInt(e);return t.disableChecks||!this.checks?n:ub(this.checks,n,void 0,this,t)?void 0:n}toCodecStringTree(){return Sy(this,[lb])}getExpected(){return`bigint`}},Fv=class e extends vv{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(Uy(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(Uy(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}return ig(function*(e,c){if(e===fg)return fg;if(!Array.isArray(e))return yield*j(new Og(n,e,c));r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)})));let l=e.length,u={ast:n,getParser:s,input:e,len:l,tailThreshold:Math.max(a,l-o),output:new globalThis.Array(l),issues:void 0,options:c},d=Iv(u,e,{concurrency:Lv(c?.concurrency)?.concurrency,end:n.rest.length===0?a:Math.max(l,a+o)});if(d&&(yield*d),n.rest.length===0&&l>a)for(let t=a;t<=l-1;t++){let r=new Eg(n,e[t],c),i=new wg([t],r);if(c.errors===`all`)u.issues?u.issues.push(i):u.issues=[i];else return yield*j(new Dg(n,[i],e,c))}return u.issues?yield*j(new Dg(n,u.issues,e,c)):u.output})}_rebuild(t,n,r){let i=Py(this.elements,t),a=Py(this.rest,t);return i===this.elements&&a===this.rest&&n===this.checks&&r===this.encodingChecks?this:new e(this.isMutable,i,a,this.annotations,n,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}},Iv=zu()({onItem(e,t,n){let r=n<e.len?t:fg;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step(e,t,n,r){if(n._tag===`Failure`)return Rv(e,e.ast,r,n);let i=n===hg?t:n[w];if(i!==fg)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(Uy(t.ast))return;let n=new wg([r],new Tg(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return sf(new Dg(e.ast,[n],e.input,e.options))}}}),Lv=e=>(e=e===`unbounded`?1/0:e??1,e>1?{concurrency:e}:void 0),Rv=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Yg(r.cause);if(i===void 0)return of(Jd(r.cause,r=>new Dg(t,[new wg([n],r)],e.input,e.options)));let a=new wg([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return sf(new Dg(t,[a],e.input,e.options))},zv=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function Bv(e,t,n=hv){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a($y(qy(t)))}var Vv=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Hv(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Hv);default:return!1}}function Uv(e){return Hv(e)&&Hv(qy(e))}var Wv=class{parameter;type;constructor(e,t){if(!Uv(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Uy(t)&&!Xy(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Gv=class e extends vv{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o;let s=e.map(e=>e.name).filter((e,t,n)=>n.indexOf(e)!==t);if(s.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(s)}. ts(2300)`)}getParser(e,t=e){let n=this,r=[];for(let e of n.propertySignatures)r.push(e.name);let i=r.length,a=n.indexSignatures.length,o=i&&a?new Set(r):void 0;if(!i&&!a)return Qy(n,Tt);let s,c,l=(e,t,r,a,s)=>{if(s._tag===`Failure`)return Rv(e,n,t,s)??cf;let c=s===hg?a:s[w];if(r!==fg&&c!==fg){if(i&&(o.has(t)||o.has(r)))return cf;xn(e.out,r,c)}return cf},u=(e,t,r,i)=>{if(!i){let n=r.parserKey(t,e.options);if(!pl(n))return M(fh(n),n=>u(e,t,r,n));i=n}if(i._tag===`Failure`)return Rv(e,n,t,i)??cf;let a=i===hg?t:i[w],o=e.input[t],s=r.parserValue(o,e.options);return pl(s)?l(e,t,a,o,s):M(fh(s),n=>l(e,t,a,o,n))},d=(e,t,n)=>{let r=e.input[t],i=n.parserValue(r,e.options);return pl(i)?l(e,t,t,r,i):M(fh(i),n=>l(e,t,t,r,n))},f=a?zu()({onItem:(e,[t,n])=>u(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return ig(function*(l,p){if(l===fg)return fg;if(!(typeof l==`object`&&l&&!Array.isArray(l)))return yield*j(new Og(n,l,p));s||(s=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),c=a?n.indexSignatures.map(n=>({is:n,parserKey:e($y(n.parameter)),parserValue:t(n.type)})):void 0);let m=l,h={},g={ast:n,input:m,out:h,issues:void 0,options:p},_=p.errors===`all`,v=p.onExcessProperty===`error`,y=p.onExcessProperty===`preserve`,b;if(!a&&(v||y)){o??=new Set(r),b=Reflect.ownKeys(m);for(let e=0;e<b.length;e++){let t=b[e];if(!o.has(t)){if(v){let e=new Eg(n,m[t],p),r=new wg([t],e);if(_){g.issues?g.issues.push(r):g.issues=[r];continue}return yield*j(new Dg(n,[r],l,p))}xn(h,t,m[t])}}}let x=Lv(p?.concurrency);if(i){let e=Kv(g,s,x);e&&(yield*e)}if(a&&!x)for(let e=0;e<a;e++){let t=c[e],n=t.is.parameter===kv?d:u,r=t.is.parameter===kv?Object.keys(m):Bv(m,t.is.parameter,p);for(let e=0;e<r.length;e++){let i=n(g,r[e],t);if(!pl(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(f){let e=fa();for(let t=0;t<a;t++){let n=c[t],r=Bv(m,n.is.parameter,p);for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=f(g,e,x);t&&(yield*t)}if(g.issues)return yield*j(new Dg(n,g.issues,l,p));if(p.propertyOrder===`original`){let e=(b??Reflect.ownKeys(m)).concat(r),t={};for(let n of e)Object.hasOwn(h,n)&&xn(t,n,h[n]);return t}return h})}_rebuild(t,n,r,i){let a=Py(this.propertySignatures,e=>{let n=t(e.type);return n===e.type?e:new Vv(e.name,n)}),o=Py(this.indexSignatures,e=>{let r=n(e.parameter),i=t(e.type);return r===e.parameter&&i===e.type?e:new Wv(r,i)});return a===this.propertySignatures&&o===this.indexSignatures&&r===this.checks&&i===this.encodingChecks?this:new e(a,o,this.annotations,r,void 0,this.context,i)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}},Kv=zu()({onItem(e,t){if(!Object.hasOwn(e.input,t.name))return t.parser(fg,e.options);let n=e.input[t.name];return xn(e.out,t.name,n),t.parser(n,e.options)},step(e,t,n){if(n._tag===`Failure`)return Rv(e,e.ast,t.name,n);if(n===hg)return;let r=n[w];if(r!==fg){xn(e.out,t.name,r);return}if(delete e.out[t.name],!Uy(t.type)){let n=new wg([t.name],new Tg(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return sf(new Dg(e.ast,[n],e.input,e.options))}}});function qv(e,t){return e?t?[...e,...t]:e:t}function Jv(e,t,n){return new Gv(Reflect.ownKeys(e).map(t=>new Vv(t,e[t].ast)),[],n,t)}function Yv(e){return e.ast}function Xv(e,t=void 0){return new Fv(!1,e.map(e=>e.ast),[],void 0,t)}function Zv(e,t,n){return new oy(e.map(Yv),t,void 0,n)}var Qv=mt(e=>{for(;;){if(pv(e))return Ev;let t=e.encoding;if(!t)return e.recur?.(Qv,C)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==C))return Ev;e=t[t.length-1].to}});function $v(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap($v)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function ey(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[cg];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!Uy(t)){if(cv(t))return[{key:e.name,literal:t.literal}];if(lv(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!Uy(e)){if(cv(e))return[{key:t,literal:e.literal}];if(lv(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>ey(Qv(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return ey(e.thunk())}}var ty=new WeakMap,ny=Object.freeze([]);function ry(e){let t=ty.get(e);if(t)return t;let n,r=0,i,a,o=!0;for(let t=0;t<e.length;t++){let s=e[t],c=Qv(s);if(sv(c))continue;if(o){if(cv(c)||lv(c)){a??=new Map;let e=cv(c)?c.literal:c.symbol,t=a.get(e);t||a.set(e,t=[]),t.push(s)}else o=!1}let l=ey(c);if(l.length){n??=new Map,r++;for(let{key:e,literal:r}of l){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=$v(c);for(let n of e)(i[n]??=[]).push(t)}}if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??ny;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=i;for(let[t,n]of i)a.set(t,Object.freeze(Array.from(n,t=>e[t])));t=(t,n)=>{if(kt(t)){let i=Object.hasOwn(t,r)?t[r]:void 0;if(i!==void 0)return a.get(i)??ny;if(n)return e}return ny}}else if(n){let a;for(let e of n)(!a||e[1][0].size>a[1][0].size)&&e[1][1].size===r&&(a=e);t=(t,r)=>{let o=i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??ny;if(!kt(t))return o.map(t=>e[t]);let s=new Set(o),c;if(a){let[n,[i]]=a,l=Object.hasOwn(t,n),u=l?t[n]:void 0;if(l&&(!r||u!==void 0)){let t=i.get(u);if(!t)return o.map(t=>e[t]);for(let e of t)s.add(e);c=n}}if(c===void 0)for(let[e,[i,a]]of n){let n=Object.hasOwn(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);if(e)for(let t of e)s.add(t)}else if(r)for(let e of a)s.add(e)}for(let[e,[i,a]]of n){if(e===c)continue;let n=Object.hasOwn(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);for(let t of s)a.has(t)&&!e?.has(t)&&s.delete(t)}}return Array.from(s).sort((e,t)=>e-t).map(t=>e[t])}}else t=t=>(i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??ny).map(t=>e[t]).filter(iy(t));return ty.set(e,t),t}function iy(e){return t=>{let n=Qv(t);return n._tag===`Literal`?n.literal===e:n._tag!==`UniqueSymbol`||n.symbol===e}}function ay(e,t,n=!1){return ry(t)(e,n)}var oy=class e extends vv{_tag=`Union`;types;mode;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.mode=t,this.encodingChecks=o}getParser(e,t){let n=this;return(r,i)=>{if(r===fg)return mg;let a=ay(r,n.types,t!==void 0);if(a.length===1){let t=e(a[0])(r,i);return t._tag===`Success`?t:pl(t)?sy(n,t.cause,r,i):vh(t,e=>sy(n,e,r,i))}let o={ast:n,compile:e,input:r,out:void 0,successes:n.mode===`oneOf`?[]:void 0,issues:void 0,options:i},s=Lv(i?.concurrency),c=cy(o,a,s?{...s,orderedStep:!0}:void 0);return c?rg(c,e=>o.out===hg?k(r):o.out?o.out:j(new Mg(n,o.issues??[],r,i))):o.out?o.out:j(new Mg(n,o.issues??[],r,i))}}_rebuild(t,n,r){let i=Py(this.types,t);return i===this.types&&n===this.checks&&r===this.encodingChecks?this:new e(i,this.mode,this.annotations,n,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=qy(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(cv);if(t.length>0)return`${uy(n.isMutable)}[ ${t.map(t=>e(t)+dy(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>cv(e.type));if(t.length>0)return`{ ${t.map(t=>`${uy(t.type.context?.isMutable)}${Mn(t.name)}${dy(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function sy(e,t,n,r){let i=Yg(t);return i?sf(new Mg(e,[i],n,r)):of(t)}var cy=zu()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Yg(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(t),sf(new Ng(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return cf}}}),ly=new oy([new Dv(`Infinity`),new Dv(`-Infinity`),new Dv(`NaN`)],`anyOf`);function uy(e){return e?``:`readonly `}function dy(e){return e?`?`:``}var fy=class e extends at{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(t){return new e(this.run,{...this.annotations,...t},this.aborted)}abort(){return new e(this.run,this.annotations,!0)}and(e,t){return new py([this,e],t)}},py=class e extends at{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(t){return new e(this.checks,{...this.annotations,...t})}and(t,n){return new e([this,t],n)}};function my(e,t,n=!1){return new fy((t,n,r)=>Ig(n,e(t,n,r),t,r),t,n)}function hy(e){return my(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}var gy=Ey(Mv,[hy()]),_y=new mv(new oy([gy,ly],`anyOf`),new P_(T_(),y_(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function vy(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return my(e=>(r.lastIndex=0,r.test(e)),{expected:`a string matching the RegExp ${n}`,representation:{id:`effect/schema/isPattern`,payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitrary:{constraint:{patterns:[e.source]}},...t})}function yy(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}var by=new WeakMap;function xy(e){return by.get(e)??e}function Sy(e,t){return e.encoding===t?e:yy(e,e=>{e.encoding.value=t})}function Cy(e,t){if(e.context===t)return e;let n=xy(e);if(n.context===t)return n;let r=yy(e,e=>{e.context.value=t});return by.set(r,n),r}function wy(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Ty(e,Qi(e.checks.slice(0,-1),n.annotate(t)))}return yy(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function Ty(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:yy(e,e=>{e.checks.value=t})}function Ey(e,t){return Ty(e,qv(e.checks,t))}function Dy(e,t){let n=t(e.to);return n===e.to?e:new mv(n,e.transformation)}function Oy(e,t){let n=e,r=n[n.length-1],i=Dy(r,t);return i===r?e:Qi(e.slice(0,e.length-1),i)}function ky(e){return t=>t.encoding?Sy(t,Oy(t.encoding,e)):t}function Ay(e,t){return ky(e=>Cy(e,t))(e)}function jy(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:Sy(r,Oy(r.encoding,n))}return e(r)}return mt(n)}function My(e,t,n){let r=new mv(e,t);return Sy(n,n.encoding?[...n.encoding,r]:[r])}function Ny(e,t){let n=ug(e);return wy(e,{brands:n?[...n,t]:[t]})}function Py(e,t){let n=!1,r=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}function Fy(e,t){return Cy(e,e.context?new gv(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new gv(!1,!1,void 0,t))}var Iy=mt(e=>Ly(Cy(e,e.context?e.context.isOptional===!1?new gv(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new gv(!0,!1)))),Ly=ky(Iy),Ry=pt(e=>Iy(new oy([e,Cv],`anyOf`)));function zy(e,t){let n=new mv(Ev,new P_(C_(t),__()));return Cy(e,e.context?new gv(e.context.isOptional,e.context.isMutable,n,e.context.annotations):new gv(!1,!1,n))}function By(e,t,n){return My(e,n,t)}function Vy(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:St(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function Hy(e,t){let{literals:n,parameters:r}=Vy(e);return new Gv(n.map(e=>new Vv(e,t)),r.map(e=>new Wv(e,t)))}function Uy(e){return e.context?.isOptional??!1}function Wy(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(Wy)}function Gy(e){function t(e){return Wy(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return ea(n)?n:void 0}var Ky=mt(e=>{if(e.encoding)return Ky(Sy(e,void 0));let t=e,n=t.recur?.(Ky)??t,r=n.encodingChecks;if(r){let t=n===e?r:uv(n)||dv(n)||iv(n)&&n.typeParameters.length>0?Gy(r):void 0;return yy(n,e=>{e.encodingChecks.value=void 0,e.checks.value=qv(n.checks,t)})}return n}),qy=mt(e=>Ky(Yy(e)));function Jy(e,t){let n=t,r=n.length,i=n[r-1],a=[new mv(Yy(Sy(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new mv(Yy(n[e-1].to),n[e].transformation.flip()));let o=Yy(i.to);return o.encoding?Sy(o,[...o.encoding,...a]):Sy(o,a)}var Yy=pt(e=>{if(e.encoding)return Jy(e,e.encoding);let t=e;return t.flip?.(Yy)??t.recur?.(Yy)??t});function Xy(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(Xy);default:return!1}}function Zy(e,t){let n=pg(t);return(r,i)=>r===fg?mg:r===t?n:j(new Og(e,r,i))}function Qy(e,t){return(n,r)=>n===fg?mg:t(n)?hg:j(new Og(e,n,r))}var $y=jy(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur($y)}}),eb=jy(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(eb)}}),tb=new globalThis.RegExp(`^${zv}$`),nb=new globalThis.RegExp(`^(?:${zv}|Infinity|-Infinity|NaN)$`);function rb(e){return vy(tb,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:tb.source}),...e})}var ib=Ey(kv,[rb()]),ab=new mv(ib,H_),ob=new mv(new oy([ib,ly],`anyOf`),H_),sb=new globalThis.RegExp(`^-?\\d+$`);function cb(e){return vy(sb,{expected:`a string representing a bigint`,representation:{id:`effect/schema/isStringBigInt`,payload:null},toJsonSchema:()=>({pattern:sb.source}),...e})}var lb=new mv(Ey(kv,[cb({expected:`a string representing a bigint`})]),U_);function ub(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=ub(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new Sg(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function db(e){if(!iv(e))return;let t=e.annotations?.[lg];return Ct(t)?t(e.typeParameters):void 0}var fb=og;function pb(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function mb(e){return e===void 0||typeof e==`string`}function hb(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function gb(e){return hb(e,pb)}var _b=new yv([],()=>(e,t,n)=>gb(e)?hg:j(new Og(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>xb,toArbitrary:()=>e=>e.jsonValue()}),vb=new mv(_b,V_()),yb=new mv(new oy([new Fv(!1,[],[_b]),new Gv([],[new Wv(kv,_b)])],`anyOf`),V_());function bb(e){return hb(e,mb)}var xb=new mv(new yv([],()=>(e,t,n)=>bb(e)?hg:j(new Og(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),V_()),Sb=kc,Cb=Sc,wb=Qu,Tb=`~effect/MutableRef`,Eb={[Tb]:Tb,...$n,toJSON(){return{_id:`MutableRef`,current:Rn(this.current)}}},Db=e=>{let t=Object.create(Eb);return t.current=e,t},Ob=S(2,(e,t)=>(e.current=t,e)),kb=e=>new jb(e),Ab=(e,t,n)=>Yc(r=>{if(e.free>=t)return r(n);let i=()=>{e.free<t||(e.waiters.delete(i),r(n))};return e.waiters.add(i),Fc(()=>{e.waiters.delete(i)})}),jb=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=Ic(()=>this.free<e?Ab(this,e,t):(this.taken+=e,Mc(e)));return t}takeIfAvailable(e){return Ic(()=>this.free<e?Mc(!1):(this.taken+=e,Mc(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{for(let e of this.waiters){if(this.free<=0)break;e()}},0),this.free}resize(e){return jr(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),Uc))}release(e){return jr(t=>Mc(this.releaseUnsafe(t,e)))}get releaseAll(){return jr(e=>Mc(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>Nu(n=>{let r=Ic(()=>this.free<e?dl(n(Ab(this,e,Uc)),()=>r):(this.taken+=e,gu(n(t),()=>{this.releaseUnsafe(Sc(),e)},!0)));return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>Nu(n=>this.free<e?zc:(this.taken+=e,gu(n(sl(t)),()=>{this.releaseUnsafe(Sc(),e)},!0)))}},Mb={"~effect/Channel":{_Env:C,_InErr:C,_InElem:C,_OutErr:C,_OutElem:C},pipe(){return rt(this,arguments)}},Nb=e=>{let t=Object.create(Mb);return t.transform=(t,n)=>vh(e(t,n),e=>k(nh(e))),t},Pb=(e,t)=>Nb((n,r)=>M(Lb(e)(n,r),e=>t(e,r))),Fb=e=>Nb((t,n)=>e),Ib=e=>Nb(Yh(function*(t,n){let r=wf(n),i=e=>Tf(r,Hm(e));return Ph(yield*Ph(e(t,n,r),i),i)})),Lb=e=>e.transform,Rb=e=>Nb((t,n)=>Zm(()=>Lb(e())(t,n))),zb=e=>Fb(k(j(e))),Bb=e=>Nb((t,n)=>Vb({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Vb=e=>{let t=e.readable.getReader(),n=e.exit??Db(void 0),r=Zm(()=>n.current?n.current:wh(Ym({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??nh(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?tf():k(pa(t))}));return mh(Cf(e.scope,e.releaseLockOnEnd?Qm(()=>t.releaseLock()):Jm(()=>t.cancel().catch(dt))),r)},Hb=S(2,(e,t)=>Pb(e,e=>Qm(()=>{let n=0;return ph(e,e=>t(e,n++))}))),Ub=S(2,(e,t)=>Nb((n,r)=>M(Lb(e)(n,r),e=>Lb(t)(e,r)))),Wb=S(2,(e,t)=>Ib((n,r,i)=>Sf(i,t).pipe(lh(Lb(e)(n,r))))),Gb=S(2,(e,t)=>Wb(e,e=>t)),Kb=(e,t,n)=>Zm(()=>{let r=bf();return Rm(M(Lb(e)(tf(),r),t),n||k).pipe(Fh(e=>Tf(r,e)))}),qb=S(2,(e,t)=>Nb((n,r)=>ph(Oh(Lb(e)(n,r),t),Oh(t)))),Jb=S(2,(e,t)=>Kb(e,e=>Bh(M(e,t),{disableYield:!0}))),Yb=(e,t)=>Lb(e)(tf(),t);function Xb(e){let t=cx(fx,Ky(e.ast));return(e,n)=>t(e,n?.disableChecks?n?.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions)}function Zb(e){let t=Xb(e);return(e,n)=>{let r=Jh(t(e,n));return lf(r)?E(r.value):(Xg(r.cause,`Option adapter can only return none for schema issues`),T())}}function Qb(e){let t=Xb(e);return(e,n)=>{let r=Jh(t(e,n));if(lf(r))return r.value;let i=Xg(r.cause,`Constructor adapter can only throw schema issues`);throw Error(`Schema validation failed`,{cause:i})}}function $b(e){return ex(e.ast)}function ex(e){let t=lx(sx(Ky(e)));return e=>{let n=t(e,hv);return lf(n)?!0:(Xg(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}function tx(e,t){let n=sx(e.ast);return t===void 0?n:(e,r)=>n(e,ax(t,r))}function nx(e,t){return ux(tx(e,t))}var rx=nx;function ix(e,t){let n=sx(Yy(e.ast));return t===void 0?n:(e,r)=>n(e,ax(t,r))}var ax=(e,t)=>t?{...e,...t}:e,ox=e=>e===fg?j(new kg):k(e);function sx(e){return cx(dx,e)}function cx(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??hv);return a===hg?k(r):pl(a)?a[w]===fg?ox(fg):a:rg(a,ox)}}function lx(e){return(t,n)=>Jh(e(t,n))}function ux(e){let t=lx(e);return(e,n)=>{let r=t(e,n);return lf(r)?E(r.value):(Xg(r.cause,`Option adapter can only return none for schema issues`),T())}}var dx=pt(e=>_x(e,dx)),fx=pt(e=>_x(e,fx,mx)),px=pt(e=>_x(e,fx,mx,e.context?.constructorDefault));function mx(e){return e.context?.constructorDefault?px(e):fx(e)}function hx(e,t,n,r){let i;if(pl(e)&&e._tag===`Success`){let a=gg(e===hg?t:e[w]);i=n._tag===`Transformation`?n.decode.run(a,r):n.decode(pg(a),r)}else i=n._tag===`Transformation`?rg(e,e=>n.decode.run(gg(e),r)):n.decode(eg(e,gg),r);return pl(i)&&i._tag===`Success`?_g(i[w]):rg(i,_g)}function gx(e,t){let n;return(r,i)=>r===fg?mg:e.isConstructed(r)?hg:hx((n??=t(e.link.to))(r,i),r,e.link.transformation,i)}function _x(e,t,n,r){let i=n?db(e):void 0,a=i?gx(i,t):e.getParser(t,n),o=e.checks,s=r?e.encoding?[...e.encoding,r]:[r]:e.encoding,c=e.encodingChecks,l=(o?o[o.length-1].annotations:e.annotations)?.parseOptions;if(!s&&!o&&!c)return l?(e,t)=>a(e,ax(t,l)):a;let u,d=(t,n)=>{let r=a(t,n);if(c&&!n.disableChecks){if(pl(r)){if(r._tag===`Success`){let i=r===hg?t:r[w];if(t!==fg&&i!==fg){let i=ub(c,t,void 0,e,n);i&&(r=j(new Dg(e,i,t,n)))}}}else r=M(r,r=>{if(t!==fg&&r!==fg){let r=ub(c,t,void 0,e,n);if(r)return j(new Dg(e,r,t,n))}return k(r)})}if(o&&!n.disableChecks){if(pl(r)){if(r._tag===`Success`){let i=r===hg?t:r[w];if(i===fg)return r;let a=ub(o,i,void 0,e,n);a&&(r=j(new Dg(e,a,i,n)))}}else r=M(r,t=>{if(t!==fg){let r=ub(o,t,void 0,e,n);if(r)return j(new Dg(e,r,t,n))}return k(t)})}return r};return s?(n,r)=>{l&&(r=ax(r,l));let i=u??=s.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=s.length-1;e>=0;e--)if(o=hx(o,a,s[e].transformation,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[w],o=t(a,r)):o=rg(o,e=>{let n=t(e,r);return n===hg?pg(e):n})}if(o._tag===`Success`){let e=o[w],t=d(e,r);return t===hg?o:t}return o=vh(o,t=>rh(()=>Jd(t,t=>new Cg(e,t,n,r)))),rg(o,e=>{let t=d(e,r);return t===hg?pg(e):t})}:l?(e,t)=>d(e,ax(t,l)):d}var vx=`~effect/Schema/Schema`,yx={[vx]:vx,pipe(){return rt(this,arguments)},annotate(e){return this.rebuild(wy(this.ast,e))},annotateKey(e){return this.rebuild(Fy(this.ast,e))},check(...e){return this.rebuild(Ey(this.ast,e))}};function bx(e,t){function n(){}let r=Object.defineProperties(Object.setPrototypeOf(n,yx),Object.getOwnPropertyDescriptors({...t}));return r.ast=e,r.rebuild=e=>bx(e,t),r.makeEffect=Xb(r),r.make=Qb(r),r.makeOption=Zb(r),r}var xx=S(2,(e,t)=>Cx(e,(e,n)=>[Object.hasOwn(t,e)?t[e]:e,n])),Sx=e=>e;function Cx(e,t){let n={};for(let r of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,r))continue;let i=t(r,e[r]);if(i){let[e,t]=i;xn(n,e,t)}}return n}var wx=S(2,(e,t)=>e===void 0?void 0:t(e)),Tx=new WeakMap,Ex=e=>{if(Tx.has(e))return Tx.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},Dx=`~effect/data/Redacted`,Ox=e=>At(e,Dx),kx=(e,t)=>{let n=Object.create(Ax);return t?.label&&(n.label=t.label),Tx.set(n,e),n},Ax={[Dx]:{_A:e=>e},label:void 0,...$n,toJSON(){return this.toString()},toString(){return`<redacted${_t(this.label)?`:`+this.label:``}>`},[Nt](){return Pt(Tx.get(this))},[Zt](e){return Ox(e)&&Qt(Tx.get(this),Tx.get(e))}},jx=Ex,Mx=e=>hn((t,n)=>e(jx(t),jx(n))),Nx=vx;function Px(){return(e,t,n)=>P(new yv(e.map(Yv),e=>t(e.map(e=>P(e))),n))}function Fx(e,t){return Px()([],()=>(t,n,r)=>e(t)?k(t):j(new Og(n,t,r)),t)}var Ix=`~effect/SchemaError/SchemaError`,Lx=class extends ss(`SchemaError`){[Ix]=Ix;constructor(e){super({issue:e})}get message(){return Kg(this.issue)}toString(){return`SchemaError(${this.message})`}};function Rx(e){return At(e,Ix)&&e[Ix]===Ix}function zx(e){return lf(e)?e.value:{issues:[{message:$d(e.cause)}]}}function Bx(e,t){let n=tx(e),r={errors:`all`,...t?.parseOptions},i=zg(t),a=e=>{let t=new ts(`sync`),a=Gh(Ch(n(e,r),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});a.currentDispatcher?.flush();let o=a.pollUnsafe();return o?zx(o):new Promise(e=>{a.addObserver(t=>{e(zx(t))})})};if(`~standard`in e){let t=e;return`validate`in t[`~standard`]||Object.assign(t[`~standard`],{validate:a}),t}return Object.assign(e,{"~standard":{version:1,vendor:`effect`,validate:a}})}var Vx=$b;function Hx(e,t){let n=tx(e,t);return(e,t)=>Ux(n(e,t))}function Ux(e){return vh(e,e=>rh(()=>Jd(e,e=>new Lx(e))))}var Wx=Hx;function Gx(e,t){let n;for(let r of e.reasons){if(!Vd(r)||!Rx(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function Kx(e){let t=Jh(e);if(lf(t))return t.value;throw Gx(t.cause,`Sync adapter can only throw schema errors`)}var qx=nx,Jx=rx;function Yx(e,t){let n=Hx(e,t);return(e,t)=>Kx(n(e,t))}var Xx=Yx;function Zx(e,t){let n=ix(e,t);return(e,t)=>Ux(n(e,t))}function Qx(e,t){let n=Zx(e,t);return(e,t)=>Kx(n(e,t))}var $x=Qx,P=bx;function eS(e){return At(e,Nx)&&e[Nx]===Nx}var tS=Sx(e=>P(Iy(e.ast),{schema:e})),nS=Sx(e=>{let t=wS(e);return P(Ry(e.ast),{schema:t})}),rS=Sx(e=>P(Ky(e.ast),{schema:e})),iS=Sx(e=>P(qy(e.ast),{schema:e}));function aS(e){let t=P(new Dv(e),{literal:e,transform(n){return t.pipe(B(aS(n),{decode:y_(()=>n),encode:y_(()=>e)}))}});return t}var oS=P(Tv),sS=P(Ev),cS=P(bv),lS=P(Cv),F=P(kv),uS=P(Mv),dS=P(Nv),fS=P(Pv),pS=P(wv);function mS(e,t){return P(e,{fields:t,mapFields(e,t){let n=e(this.fields);return mS(Jv(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function I(e){return mS(Jv(e,void 0),e)}var hS=e=>typeof e==`symbol`?e:globalThis.String(e);function gS(e){return function(t){let n={},r=Object.create(null),i=Object.create(null),a=new Set;for(let o of Reflect.ownKeys(t.fields)){let s=iS(t.fields[o]),c=Object.hasOwn(e,o),l=c?e[o]:o,u=hS(l);if(a.has(u))throw new globalThis.Error(`Duplicate encoded keys: ${Mn(l)}`);a.add(u),xn(n,l,s),c&&(r[o]=l,i[l]=o)}return I(n).pipe(B(t,R_({decode:xx(i),encode:xx(r)})))}}function _S(e,t){return P(Hy(e.ast,t.ast),{key:e,value:t})}function vS(e,t){return P(e,{elements:t,mapElements(e,t){let n=e(this.elements);return vS(Xv(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function yS(e){return vS(Xv(e),e)}var L=Sx(e=>P(new Fv(!1,[],[e.ast]),{value:e})),bS=Sx(e=>P(new Fv(!1,[e.ast],[e.ast]),{value:e}));function xS(e,t){return P(e,{members:t,mapMembers(e,t){let n=e(this.members);return xS(Zv(n,this.ast.mode,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function R(e,t){return xS(Zv(e,t?.mode??`anyOf`,void 0),e)}function SS(e){let t=e.map(aS);return P(Zv(t,`anyOf`,void 0),{literals:e,members:t,mapMembers(e){return R(e(this.members))},pick(e){return SS(e)},transform(e){return R(t.map((t,n)=>t.transform(e[n])))}})}var CS=Sx(e=>R([e,cS])),wS=Sx(e=>R([e,lS]));function z(e){return t=>P(Ny(t.ast,e),{schema:t,identifier:e})}function B(e,t){return n=>P(By(n.ast,e.ast,t?I_(t):V_()),{from:n,to:e})}function TS(e,t){return n=>t?B(n,t)(e):B(n)(e)}function ES(e){return t=>P(zy(t.ast,e),{schema:t})}function DS(e){return vh(e,e=>rh(()=>Jd(e,e=>e.issue)))}function OS(e,t){let n=t?.encodingStrategy===`omit`?S_():__();return t=>tS(iS(t)).pipe(B(t,{decode:C_(DS(e)),encode:n}))}function kS(e,t){return n=>rS(n).pipe(OS(e,t),TS(tS(n)))}function AS(e){return aS(e).pipe(ES(k(e)))}function jS(e,t){return I({_tag:AS(e),...t})}function MS(e,t){return Fx(t=>t instanceof e,t)}function NS(){return(e,t)=>new mv(e.ast,I_(t))}var PS=my;function FS(e,t){let n=e.source,r=e.flags,i=r===``?`new RegExp(${An(n)})`:`new RegExp(${An(n)}, ${An(r)})`;return vy(e,{toCode:()=>({runtime:`Schema.isPattern(${i})`}),...t})}var IS=P(gy),LS=hy;function RS(e){let t=pi(e.order),n=e.formatter??An;return(r,i)=>PS(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r}}},...e.annotate?.(r),...i})}function zS(e){let t=pi(e.order),n=di(e.order),r=fi(e.order),i=ui(e.order),a=e.formatter??An;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return PS(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}}}},...e.annotate?.(o),...s})}}function BS(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${An(e)}`);return e}var VS=RS({order:ci,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:BS(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${An(e)})`})})}),HS=zS({order:ci,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:BS(e.minimum),maximum:BS(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${An(e.minimum)}, maximum: ${An(e.maximum)}, exclusiveMinimum: ${An(t)}, exclusiveMaximum: ${An(n)} })`})}}});function US(e){return PS(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`}),toCode:()=>({runtime:`Schema.isInt()`}),arbitrary:{constraint:{integer:!0}},...e})}var WS=uS.check(US());function GS(e,t){return e=Math.max(0,Math.floor(e)),PS(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:t})=>t===`array`?{minItems:e}:{minLength:e},toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[sg]:!0,arbitrary:{constraint:{minLength:e}},...t})}function KS(e){return GS(1,e)}function qS(e,t){return e=Math.max(0,Math.floor(e)),PS(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`array`?{maxItems:e}:{maxLength:e},toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[sg]:!0,arbitrary:{constraint:{maxLength:e}},...t})}function JS(e){return PS(e=>ga(e).length===e.length,{expected:`an array with unique items`,representation:{id:`effect/schema/isUnique`,payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:`Schema.isUnique()`}),arbitrary:{constraint:{unique:!0}},...e})}var V=F.check(KS());function YS(e){return P(Px()([e],([e])=>(t,n,r)=>mi(t)?hi(t)?Xm:ng(tx(e)(t.value,r),{onSuccess:E,onFailure:e=>Ag(n,`value`,e,t,r)}):j(new Og(n,t,r)),{representation:{id:`effect/schema/Option`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Option(${e[0].runtime})`,Type:`Option.Option<${e[0].Type}>`,importDeclarations:[`import * as Option from "effect/Option"`]}),expected:`Option`,toCodec:([e])=>NS()(R([I({_tag:aS(`Some`),value:e}),I({_tag:aS(`None`)})]),R_({decode:e=>e._tag===`None`?T():E(e.value),encode:e=>D(e)?{_tag:`Some`,value:e.value}:{_tag:`None`}})),toArbitrary:([e])=>(t,n)=>{let r=t.constant(T());return mC(t,n,r,t.oneof(r,e.arbitrary.map(E)))},toEquivalence:([e])=>Ai(e),toFormatter:([e])=>gi({onNone:()=>`none()`,onSome:t=>`some(${e(t)})`})}).ast,{value:e})}function XS(e){return CS(e).pipe(B(YS(rS(e)),Z_()))}function ZS(e){return tS(e).pipe(B(YS(rS(e)),Q_()))}function QS(e,t){let n=typeof t?.label==`string`?t.label:void 0,r=t?.disallowJsonEncode===!0,i=n===void 0?r?{disallowJsonEncode:!0}:void 0:r?{label:n,disallowJsonEncode:!0}:{label:n},a=n===void 0?void 0:tx(aS(n));return P(Px()([e],([e])=>(t,n,r)=>Ox(t)?rg(a===void 0?$m:tg(a(t.label,r),e=>new wg([`label`],e)),()=>ng(tx(e)(jx(t),r),{onSuccess:()=>t,onFailure:()=>new Dg(n,[new wg([`value`],new kg(void 0,t,r))],t,r)})):j(new Og(n,t,r)),{representation:{id:`effect/schema/Redacted`,payload:i??null},toCode:({typeParameters:e})=>({runtime:i===void 0?`Schema.Redacted(${e[0].runtime})`:`Schema.Redacted(${e[0].runtime}, ${An(i)})`,Type:`Redacted.Redacted<${e[0].Type}>`,importDeclarations:[`import * as Redacted from "effect/Redacted"`]}),expected:`Redacted`,toCodecJson:([e])=>NS()(e,{decode:y_(e=>kx(e,{label:n})),encode:r?m_(e=>`Cannot serialize Redacted`+(D(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):y_(jx)}),toArbitrary:([e])=>()=>({arbitrary:e.arbitrary.map(e=>kx(e,{label:n})),terminal:e.terminal?.map(e=>kx(e,{label:n}))}),toFormatter:()=>globalThis.String,toEquivalence:([e])=>Mx(e)}).ast,{value:e})}function $S(e,t){return B(QS(rS(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:y_(e=>kx(e,{label:t?.label})),encode:t?.disallowEncode?m_(e=>`Cannot encode Redacted`+(D(e)&&typeof e.value.label==`string`?` with label: "${e.value.label}"`:``)):y_(jx)})(e)}function eC(e,t){return P(Px()([e,t],([e,t])=>(n,r,i)=>{if(!Bd(n))return j(new Og(r,n,i));switch(n._tag){case`Fail`:return ng(tx(e)(n.error,i),{onSuccess:Gd,onFailure:e=>Ag(r,`error`,e,n,i)});case`Die`:return ng(tx(t)(n.defect,i),{onSuccess:Kd,onFailure:e=>Ag(r,`defect`,e,n,i)});case`Interrupt`:return k(n)}},{representation:{id:`effect/schema/CauseReason`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.CauseReason(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Failure<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause.Failure`,toCodec:([e,t])=>NS()(R([I({_tag:aS(`Fail`),error:e}),I({_tag:aS(`Die`),defect:t}),I({_tag:aS(`Interrupt`),fiberId:wS(IS)})]),R_({decode:e=>{switch(e._tag){case`Fail`:return Gd(e.error);case`Die`:return Kd(e.defect);case`Interrupt`:return qd(e.fiberId)}},encode:C})),toArbitrary:([e,t])=>tC(e,t),toEquivalence:([e,t])=>nC(e,t),toFormatter:([e,t])=>rC(e,t)}).ast,{error:e,defect:t})}function tC(e,t){return(n,r)=>{let i=n.constant(qd());return mC(n,r,i,n.oneof(i,n.integer({min:1}).map(qd),e.arbitrary.map(e=>Gd(e)),t.arbitrary.map(e=>Kd(e))))}}function nC(e,t){return(n,r)=>{if(n._tag!==r._tag)return!1;switch(n._tag){case`Fail`:return e(n.error,r.error);case`Die`:return t(n.defect,r.defect);case`Interrupt`:return n.fiberId===r.fiberId}}}function rC(e,t){return n=>{switch(n._tag){case`Fail`:return`Fail(${e(n.error)})`;case`Die`:return`Die(${t(n.defect)})`;case`Interrupt`:return`Interrupt`}}}function iC(e,t){return P(Px()([e,t],([e,t])=>{let n=L(eC(e,t));return(e,t,r)=>zd(e)?ng(tx(n)(e.reasons,r),{onSuccess:Hd,onFailure:n=>Ag(t,`failures`,n,e,r)}):j(new Og(t,e,r))},{representation:{id:`effect/schema/Cause`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Cause(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Cause<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause`,toCodec:([e,t])=>NS()(L(eC(e,t)),R_({decode:Hd,encode:({reasons:e})=>e})),toArbitrary:([e,t])=>aC(e,t),toEquivalence:([e,t])=>oC(e,t),toFormatter:([e,t])=>sC(e,t)}).ast,{error:e,defect:t})}function aC(e,t){return(n,r)=>{let i=tC(e,t)(n,r);return mC(n,r,n.constant(Ud),n.array(i.arbitrary).map(Hd))}}function oC(e,t){let n=yn(nC(e,t));return(e,t)=>n(e.reasons,t.reasons)}function sC(e,t){let n=rC(e,t);return e=>`Cause([${e.reasons.map(n).join(`, `)}])`}var cC=e=>e?.includeStack===!0|(e?.excludeCause===!0?2:0),lC=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},uC=[];function dC(e){let t=cC(e),n=uC[t];if(n!==void 0)return n;let r=XC.pipe(B(sS,X_(lC(t))));return uC[t]=r,r}function fC(e,t,n){return P(Px()([e,t,n],([e,t,n])=>{let r=iC(t,n);return(t,n,i)=>{if(!rf(t))return j(new Og(n,t,i));switch(t._tag){case`Success`:return ng(tx(e)(t.value,i),{onSuccess:af,onFailure:e=>Ag(n,`value`,e,t,i)});case`Failure`:return ng(tx(r)(t.cause,i),{onSuccess:of,onFailure:e=>Ag(n,`cause`,e,t,i)})}}},{representation:{id:`effect/schema/Exit`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Exit(${e[0].runtime}, ${e[1].runtime}, ${e[2].runtime})`,Type:`Exit.Exit<${e[0].Type}, ${e[1].Type}, ${e[2].Type}>`,importDeclarations:[`import * as Exit from "effect/Exit"`]}),expected:`Exit`,toCodec:([e,t,n])=>NS()(R([I({_tag:aS(`Success`),value:e}),I({_tag:aS(`Failure`),cause:iC(t,n)})]),R_({decode:e=>e._tag===`Success`?af(e.value):of(e.cause),encode:e=>lf(e)?{_tag:`Success`,value:e.value}:{_tag:`Failure`,cause:e.cause}})),toArbitrary:([e,t,n])=>(r,i)=>{let a=aC(t,n)(r,i);return mC(r,i,pC(r,e.terminal?.map(e=>af(e)),a.terminal?.map(e=>of(e))),r.oneof(e.arbitrary.map(e=>af(e)),a.arbitrary.map(e=>of(e))))},toEquivalence:([e,t,n])=>{let r=oC(t,n);return(t,n)=>{if(t._tag!==n._tag)return!1;switch(t._tag){case`Success`:return e(t.value,n.value);case`Failure`:return r(t.cause,n.cause)}}},toFormatter:([e,t,n])=>{let r=sC(t,n);return t=>{switch(t._tag){case`Success`:return`Exit.Success(${e(t.value)})`;case`Failure`:return`Exit.Failure(${r(t.cause)})`}}}}).ast,{value:e,error:t,defect:n})}function pC(e,t,n){return t===void 0?n:n===void 0?t:e.oneof(t,n)}function mC(e,t,n,r){return{arbitrary:n===void 0||t.recursion===void 0?r:e.oneof(t.recursion,n,r),terminal:n}}globalThis.RegExp;var hC=F.annotate({expected:`a string that will be decoded as a URL`}),gC=MS(globalThis.URL,{representation:{id:`effect/schema/URL`,payload:null},toCode:()=>({runtime:`Schema.URL`,Type:`globalThis.URL`}),expected:`URL`,toCodecJson:()=>NS()(hC,$_),toArbitrary:()=>e=>e.webUrl().map(e=>new globalThis.URL(e)),toEquivalence:()=>(e,t)=>e.toString()===t.toString()}),_C=hC.pipe(B(gC,$_));function vC(e,t,n){let r={...t};if(e?.minimum!==void 0){let t=n===void 0?e.minimum:n(e.minimum),i=e.exclusiveMinimum?new globalThis.Date(t.getTime()+1):t;(r.min===void 0||i.getTime()>r.min.getTime())&&(r.min=i)}if(e?.maximum!==void 0){let t=n===void 0?e.maximum:n(e.maximum),i=e.exclusiveMaximum?new globalThis.Date(t.getTime()-1):t;(r.max===void 0||i.getTime()<r.max.getTime())&&(r.max=i)}return r}var yC=F.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function bC(e,t){return yC.pipe(B(e,tv(t)))}var xC=bC(sS);globalThis.File,globalThis.FormData,globalThis.URLSearchParams;var SC=F.annotate({expected:`a string that will be decoded as a finite number`}).pipe(B(IS,H_)),CC=F.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),wC=MS(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>NS()(CC,ev),toArbitrary:()=>e=>e.uint8Array()}),TC=Fx(e=>Zg(e)&&Qg(e),{representation:{id:`effect/schema/DateTimeUtc`,payload:null},toCode:()=>({runtime:`Schema.DateTimeUtc`,Type:`DateTime.Utc`,importDeclarations:[`import * as DateTime from "effect/DateTime"`]}),expected:`DateTime.Utc`,toCodecJson:()=>NS()(F,nv),toArbitrary:()=>(e,t)=>e.date(vC(t?.constraint?.ordered?.order===e_?t.constraint.ordered:void 0,{noInvalidDate:!0},c_)).map(e=>t_(e)),toFormatter:()=>e=>e.toString(),toEquivalence:()=>$g}),EC=F.annotate({expected:`a string that will be decoded as a DateTime.Utc`}).pipe(B(TC,nv)),DC=globalThis.Symbol.for(`immer-draftable`),OC={};function kC(e,t,n,r,i){let a=MC(n,t,r),o=jC(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===OC?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:OC,value:i}})}static[Nx]=Nx;get[o](){return o}static[DC]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return rt(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return new this(e,t)}static makeOption(e,t){return Zb(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(wy(this.ast,e))}static annotateKey(e){return this.rebuild(Fy(this.ast,e))}static check(...e){return this.rebuild(Ey(this.ast,e))}static extend(e){return(t,r)=>{let a=NC(t)?t:I(t),o={...n.fields,...a.fields},s=Jv(o,n.ast.checks,{identifier:e});return kC(this,e,mS(Ey(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function AC(e){return new P_(y_(t=>new e(t,{"~payload":{token:OC,value:t}})),__())}function jC(e){return`~effect/Schema/Class/${e}`}function MC(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=jC(t),o=e=>e instanceof i||At(e,a),s=AC(i);return r=B(P(new yv([e.ast],()=>(e,t,n)=>o(e)?k(e):j(new Og(t,e,n)),{identifier:t,[lg]:([e])=>({isConstructed:o,link:new mv(e,s)}),toCodec:([e])=>new mv(e.ast,s),toArbitrary:([e])=>()=>({arbitrary:e.arbitrary.map(e=>new i(e)),terminal:e.terminal?.map(e=>new i(e))}),toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[cg]:ey(e.ast),...n})),s)(e)}}function NC(e){return eS(e)}var H=e=>(t,n)=>kC(as,e,NC(t)?t:I(t),n,e=>({toString(){return`${e}(${An({...this})})`}})),U=e=>(t,n,r)=>{let i=NC(n)?n.mapFields(e=>({_tag:AS(t),...e}),{unsafePreserveChecks:!0}):jS(t,n);return H(e??t)(i,r)},PC=e=>(t,n)=>kC(Nr,e,NC(t)?t:I(t),n,e=>({name:e})),FC=e=>(t,n,r)=>{let i=NC(n)?n.mapFields(e=>({_tag:AS(t),...e}),{unsafePreserveChecks:!0}):jS(t,n);return PC(e??t)(i,r)};function IC(e){return P(LC(e.ast),{schema:e})}var LC=jy(e=>{let t=HC(e,LC),n=e.context;return t===e||n===void 0?t:Ay(t,RC(n))});function RC(e){return e.constructorDefault===void 0?e:new gv(e.isOptional,e.isMutable,void 0,e.annotations)}function zC(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function BC(e){return t=>{let n=new Map;for(let e=0;e<t.length;e++)n.set(qy(t[e]),e);let r=[...t].sort((t,r)=>{t=qy(t),r=qy(r);let i=e(t),a=e(r);return i===a?n.get(t)-n.get(r):i-a});return r.some((e,n)=>e!==t[n])?r:t}}var VC=BC(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function HC(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Ct(n))return Sy(e,[vb]);let r=n(e.typeParameters.map(e=>bx(qy(e))));return r===void 0?e:Sy(e,[Dy(r,t)])}case`Unknown`:return Sy(e,[vb]);case`ObjectKeyword`:return Sy(e,[yb]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return zC(e),e.recur(t,eb);case`Union`:{let n=VC(e.types);return n===e.types?e.recur(t):new oy(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}function UC(e){return P(YC(e.ast),{schema:e})}var WC=BC(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function GC(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>P(t(qy(e)))),i=e.annotations?.toCodecStringTree;if(Ct(i)){let n=i(r);return n===void 0?e:Sy(e,[Dy(n,t)])}let a=e.annotations?.toCodecJson,o=Ct(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(Ct(s)?s(r):void 0);return c===void 0?n(e):Sy(e,[Dy(c,t)])}case`Null`:return Sy(e,[KC]);case`Boolean`:return Sy(e,[qC]);case`Unknown`:case`ObjectKeyword`:return Sy(e,[xb]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return zC(e),e.recur(t,eb);case`Union`:{let n=WC(e.types);return n===e.types?e.recur(t):new oy(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var KC=new mv(new Dv(`null`),new P_(y_(()=>null),y_(()=>`null`))),qC=new mv(new oy([new Dv(`true`),new Dv(`false`)],`anyOf`),new P_(y_(e=>e===`true`),w_())),JC=new P_(y_(e=>typeof e==`string`?[e]:e),__()),YC=jy(e=>{let t=GC(e,YC,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})});return t!==e&&e.context!==void 0?Ay(t,RC(e.context)):t},{stopAt:e=>e.transformation===JC}),XC=P(wy(_b,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),ZC=_S(F,XC),QC=e=>()=>{let t=Wx(bS(e));return Nb((e,n)=>k(M(e,e=>t(e))))},$C=`~effect/Stream`,ew={_R:C,_E:C,_A:C},tw={[$C]:ew,pipe(){return rt(this,arguments)}},nw=e=>{let t=Object.create(tw);return t.channel=e,t},rw=`~effect/Stream`,iw=e=>At(e,rw),aw=nw,ow=(e,t)=>aw(Nb((n,r)=>M(Yb(e.channel,r),e=>t(e,r)))),sw=e=>aw(Rb(()=>e().channel)),cw=e=>aw(zb(e)),lw=e=>aw(Bb(e)),uw=S(2,(e,t)=>sw(()=>{let n=0;return aw(Hb(e.channel,ma(e=>t(e,n++))))})),dw=S(2,(e,t)=>aw(Ub(e.channel,t))),fw=S(e=>iw(e[0]),(e,t)=>sw(()=>{let n=new TextDecoder(t?.encoding);return uw(e,e=>n.decode(e,{stream:!0}))})),pw=S(2,(e,t)=>aw(Gb(e.channel,t))),mw=S(2,(e,t)=>aw(qb(e.channel,t))),hw=S(2,(e,t)=>Jb(e.channel,t)),gw=S(e=>iw(e[0]),(e,t,n)=>{let r,i,a=wb(!1);return new ReadableStream({start(n){i=Gh(Oh(hw(e,e=>a.whenOpen(Qm(()=>{a.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0}))),t)),i.addObserver(e=>{e._tag===`Failure`?n.error(Xd(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return Kh(hh(Sb(i)))}},n?.strategy)}),_w=S(e=>iw(e[0]),(e,t)=>ph(Th(),n=>gw(e,n,t))),vw=BigInt(1024);vw*vw*vw*vw*vw,O()(`effect/platform/FileSystem/WatchBackend`);var yw={"~effect/match/Match/Matcher":{_input:C,_filters:C,_remaining:C,_result:C,_return:C,_args:C},_tag:`TypeMatcher`,add(e){return bw(this.select,[...this.cases,e])},pipe(){return rt(this,arguments)}};function bw(e,t){let n=Object.create(yw);return n.select=e,n.cases=t,n}var xw=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),Sw=S(2,(e,t)=>ww(t)(bw(C,[]))(e)),Cw=e=>t=>{let n=xw(n=>n!=null&&Object.hasOwn(t,n[e]),n=>t[n[e]](n));return e=>e.add(n)},ww=(e=>t=>{let n=Cw(e)(t);return e=>Dw(n(e))})(`_tag`),Tw=e=>{if(e._tag===`ValueMatcher`)return e.value;let t=e.cases.length;if(t===1){let t=e.cases[0];return(...n)=>{let r=e.select(...n);return t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1?ji(t.evaluate(r,...n)):Mi(r)}}return(...n)=>{let r=e.select(...n);for(let i=0;i<t;i++){let t=e.cases[i];if(t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1)return ji(t.evaluate(r,...n))}return Mi(r)}},Ew=`effect/match/Match/exhaustive: absurd`,Dw=e=>{let t=Tw(e);if(Fi(t)){if(Li(t))return t.success;throw Error(Ew)}return(...e)=>{let n=t(...e);if(Li(n))return n.success;throw Error(Ew)}},Ow=Sw,kw={"~effect/Ref":{_A:C},...$n,toJSON(){return{_id:`Ref`,ref:this.ref}}},Aw=e=>{let t=Object.create(kw);return t.ref=Db(e),t},jw=e=>Qm(()=>Aw(e)),Mw=e=>Qm(()=>e.ref.current),Nw=S(2,(e,t)=>Qm(()=>Ob(e.ref,t))),Pw=S(2,(e,t)=>Qm(()=>{let[n,r]=t(e.ref.current);return e.ref.current=r,n})),Fw=S(2,(e,t)=>Qm(()=>{e.ref.current=t(e.ref.current)})),Iw=S(2,(e,t)=>Qm(()=>e.ref.current=t(e.ref.current))),Lw=`~effect/SynchronizedRef`,Rw={...$n,[Lw]:Lw,toJSON(){return{_id:`SynchronizedRef`,value:this.backing.ref.current}}},zw=e=>{let t=Object.create(Rw);return t.semaphore=kb(1),t.backing=Aw(e),t},Bw=e=>Qm(()=>zw(e)),Vw=e=>e.backing.ref.current,Hw=S(2,(e,t)=>e.semaphore.withPermit(Zm(()=>ph(t(Vw(e)),([t,n])=>(e.backing.ref.current=n,t))))),Uw=F.check(FS(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u,{message:`Expected a full GitHub repo name (owner/name)`})).pipe(z(`RepositoryName`)),Ww=F.check(FS(/^[^\s-]\S*$/u,{message:`Expected a git revision without whitespace or a leading dash`})).pipe(z(`RepositoryRevision`)),Gw=F.check(FS(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/u,{message:`Expected a 40- or 64-character lowercase git object id`})).pipe(z(`CommitSha`)),Kw=e=>{let t=e.indexOf(`/`);return{owner:e.slice(0,t),name:e.slice(t+1)}},qw=e=>e.toLowerCase(),Jw=V.pipe(z(`EventId`)),Yw=V.pipe(z(`DedupKey`)),Xw=class extends H(`Event`)({id:Jw,dedupKey:Yw,payload:XC,receivedAt:TC}){},Zw=V.pipe(z(`LoopName`)),Qw=[`none`,`required`],$w=SS(Qw),eT=class extends U(`CancelReason/OperatorCanceled`)(`OperatorCanceled`,{}){},tT=class extends U(`CancelReason/Superseded`)(`Superseded`,{by:Jw}){},nT=class extends U(`CancelReason/Revoked`)(`Revoked`,{}){},rT=R([eT,tT,nT]),iT=class extends U(`RunState/Pending`)(`Pending`,{}){},aT=class extends U(`RunState/Waiting`)(`Waiting`,{}){},oT=class extends U(`RunState/Queued`)(`Queued`,{}){},sT=class extends U(`RunState/Running`)(`Running`,{}){},cT=class extends U(`RunState/Succeeded`)(`Succeeded`,{}){},lT=class extends U(`RunState/Failed`)(`Failed`,{}){},uT=class extends U(`RunState/Canceled`)(`Canceled`,{reason:rT}){},dT=R([iT,aT,oT,sT]),fT=R([...dT.members,cT,lT,uT]),pT=R([iT,aT,oT]),mT=R([iT,oT]),hT=Vx(dT),gT=Vx(pT),_T=Vx(mT),vT=()=>(...e)=>e,yT=vT()(`Pending`,`Waiting`,`Queued`,`Running`),bT=vT()(`Pending`,`Waiting`,`Queued`,`Running`,`Succeeded`,`Failed`,`Canceled`),xT=vT()(`Pending`,`Waiting`,`Queued`),ST=e=>new aT,CT=e=>new oT,wT=e=>new sT,TT=e=>new cT,ET=e=>new lT,DT=e=>new sT,OT=e=>new uT({reason:new eT}),kT=(e,t)=>new uT({reason:new tT({by:t})}),AT=e=>new uT({reason:new nT}),jT=V.pipe(z(`RunId`)),MT=class extends H(`Run`)({id:jT,eventId:Jw,loop:Zw,state:fT,openedAt:TC}){};function NT(e){return t(e.defaultTagName??`div`,e,e)}var PT=F.check(FS(/\S/u,{message:`Expected a non-blank model id`})).pipe(z(`ModelId`)),FT=SS([`claude`,`codex`,`pi`]),IT=SS([`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),LT=class extends H(`Agent/BrainSpec`)({harness:FT,model:PT,effort:IT}){},RT=R([class extends U(`StepResult/Commit`)(`Commit`,{sha:Gw,summary:V}){},class extends U(`StepResult/PullRequest`)(`PullRequest`,{number:WS.check(VS(1)),url:_C}){},class extends U(`StepResult/Comment`)(`Comment`,{url:_C}){}]),zT=class extends H(`StepResult`)({message:V,facts:L(RT)}){},BT=V.pipe(z(`StepName`)),VT=class extends H(`Step`)({runId:jT,name:BT,result:YS(zT)}){},HT=F.check(FS(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,{message:`Expected a kebab-case Worker name`})).pipe(z(`WorkerName`)),UT=SS([`local`,`exe.dev`]),WT=F.check(FS(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,{message:`Expected a kebab-case Agent name`})).pipe(z(`AgentName`)),GT=F.check(FS(/\S/u,{message:`Expected a non-blank Agent persona`})).pipe(z(`AgentPersona`)),KT=class extends H(`Agent`)({name:WT,brain:LT,parentModel:XS(PT),parentEffort:ZS(IT),persona:GT}){},qT=(e,t)=>vi([e.parentModel,t]),JT=V.pipe(z(`AgentSessionId`)),YT=WS.check(VS(1)),XT=YT.pipe(z(`ChildSessionBudget`)),ZT=YT.pipe(z(`ChildSessionCount`)),QT=R([class extends U(`Agent/ParentSession`)(`ParentSession`,{id:JT,agent:WT,brain:LT}){},class extends U(`Agent/ChildSession`)(`ChildSession`,{id:JT,parentId:JT,agent:WT,brain:LT}){}]),$T=class extends U(`Agent/SessionStarted`)(`SessionStarted`,{session:QT}){},eE=class extends U(`Agent/TextOutput`)(`TextOutput`,{session:QT,text:V}){},tE=class extends U(`Agent/ToolStarted`)(`ToolStarted`,{session:QT,callId:V,tool:V,input:XC}){},nE=class extends U(`Agent/ToolFinished`)(`ToolFinished`,{session:QT,callId:V,tool:V,output:XC,isError:dS}){},rE=class extends U(`Agent/SessionFinished`)(`SessionFinished`,{session:QT}){},iE=SS([`apiKeys`,`claudePlan`,`chatgptPlan`]),aE=class extends H(`Agent/RateLimitWindow`)({usedPercent:uS,windowDurationMinutes:XS(uS),resetsAt:XS(EC)}){},oE=class extends H(`Agent/RateLimitsSnapshot`)({limitId:XS(F),limitName:XS(F),primary:XS(aE),secondary:XS(aE)}){},sE=R([$T,eE,tE,nE,class extends U(`Agent/PoolRateLimitsUpdated`)(`PoolRateLimitsUpdated`,{session:QT,pool:iE,rateLimits:oE}){},rE]),cE=class extends FC(`AttemptFailure/InfraFailure`)(`InfraFailure`,{message:F,cause:dC()}){},lE=class extends FC(`AttemptFailure/DefectFailure`)(`DefectFailure`,{message:F,cause:dC()}){},uE=class extends FC(`AttemptFailure/AgentFailure`)(`AgentFailure`,{message:F}){},dE=SS([`wall-clock`,`tokens`]),fE=R([cE,lE,uE,class extends FC(`AttemptFailure/RunawayFailure`)(`RunawayFailure`,{ceiling:dE}){},class extends FC(`AttemptFailure/ChildSessionBudgetFailure`)(`ChildSessionBudgetFailure`,{maxChildren:XT,attemptedChildren:ZT}){}]),pE=Vx(cE),mE=class extends U(`AttemptOutcome/Succeeded`)(`Succeeded`,{}){},hE=class extends U(`AttemptOutcome/Failed`)(`Failed`,{failure:fE}){},gE=class extends U(`AttemptOutcome/Canceled`)(`Canceled`,{}){},_E=R([mE,hE,gE]),vE=V.pipe(z(`AttemptId`)),yE=WS.check(VS(1)).pipe(z(`AttemptNumber`)),bE=F.check(FS(/\S/u,{message:`Expected non-blank task text`})).pipe(z(`AttemptTask`)),xE=class extends H(`Attempt`)({id:vE,runId:jT,stepName:BT,worker:HT,number:yE,brain:LT,parentModel:XS(PT),startedAt:TC,outcome:YS(_E)}){},SE=e=>pE(e.failure)&&e.number<e.maxAutoAttempts,CE=V.pipe(z(`ItemKey`)),wE=WS.check(VS(1)).pipe(z(`ItemNumber`)),TE=WS.check(VS(1)).pipe(z(`CycleLimit`)),EE=WS.check(VS(0)).pipe(z(`CycleGeneration`)),DE=TE.make(3),OE=WS.check(VS(0)).pipe(z(`CycleCount`)),kE=class extends H(`LoopCycleCount`)(I({loop:Zw,admitted:OE,completed:OE}).check(PS(({admitted:e,completed:t})=>t<=e,{message:`Completed Runs cannot exceed admitted Runs`})).annotate({parseOptions:{onExcessProperty:`error`}})){},AE=Jw.pipe(z(`CycleBudgetAskId`)),jE=class extends H(`CycleBudgetAsk`)(I({id:AE,itemKey:CE,repository:Uw,loop:Zw,limit:TE,counts:bS(kE)}).check(PS(({loop:e,limit:t,counts:n})=>new Set(n.map(e=>e.loop)).size===n.length&&n.some(n=>n.loop===e&&n.admitted>=t),{message:`Expected unique participating Loops including the exhausted Loop at its limit`})).annotate({parseOptions:{onExcessProperty:`error`}})){get completedCycles(){return OE.make(Math.max(...this.counts.map(({completed:e})=>e)))}},ME=WS.check(VS(1)).pipe(z(`AttemptChannelSequence`)),NE=[`inbound`,`outbound`],PE=SS(NE),FE=class extends H(`AttemptChannel/RunSpec`)({attemptId:vE,repository:Uw,revision:Ww,baseCommit:Gw,payload:XC,task:bE,agent:KT,parentModel:XS(PT),maxChildren:XT,parentEffort:IT}){},IE=class extends U(`AttemptChannel/Started`)(`Started`,{parentModel:PT}){},LE=class extends U(`AttemptChannel/SessionEvent`)(`SessionEvent`,{event:sE}){},RE=class extends U(`AttemptChannel/Final`)(`Final`,{result:zT}){},zE=class extends U(`AttemptChannel/Failed`)(`Failed`,{failure:fE}){},BE=class extends U(`AttemptChannel/Interrupted`)(`Interrupted`,{}){},VE=R([IE,LE,RE,zE,BE]),HE=class extends U(`AttemptChannel/Steer`)(`Steer`,{message:V}){},UE=class extends U(`AttemptChannel/Interrupt`)(`Interrupt`,{}){},WE=R([HE,UE]),GE={version:aS(4),attemptId:vE,sequence:ME,sentAt:EC},KE=class extends U(`AttemptChannel/OutboundEnvelope`)(`OutboundEnvelope`,{...GE,payload:VE}){},qE=class extends U(`AttemptChannel/InboundEnvelope`)(`InboundEnvelope`,{...GE,payload:WE}){},JE=R([KE,qE]),YE=R([class extends U(`AttemptChannel/Start`)(`Start`,{version:aS(4),spec:FE}){},qE]);bC(JE),bC(YE),bC(KE);var XE=WS.check(VS(1)).pipe(z(`TranscriptSequence`)),ZE=3,QE=R([JE,R([I({...KE.fields,version:aS(ZE)}),I({...qE.fields,version:aS(ZE)})])]),$E=class extends H(`@usine/engine/TranscriptEntry`)({sequence:XE,attemptId:vE,direction:PE,envelope:QE,receivedAt:TC}){};R([class extends U(`@usine/engine/TranscriptAllQuery`)(`TranscriptAllQuery`,{attemptId:vE}){},class extends U(`@usine/engine/TranscriptTailQuery`)(`TranscriptTailQuery`,{attemptId:vE,after:XE,limit:WS.check(VS(1))}){},class extends U(`@usine/engine/TranscriptPageQuery`)(`TranscriptPageQuery`,{attemptId:vE,before:YS(XE),limit:WS.check(VS(1))}){}]);var eD=`~effect/http/UrlParams`,tD=e=>At(e,eD),nD={...$n,[eD]:eD,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[Zt](e){return oD(this,e)},[Nt](){return Wt(this.params.flat())}},rD=e=>{let t=Object.create(nD);return t.params=e,t},iD=e=>{if(tD(e))return e;let t=aD(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return rD(n)},aD=e=>{let t=typeof e[Symbol.iterator]==`function`?Yi(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,String(r[t])]);else if(typeof r==`object`){let t=aD(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,String(r)]);return n},oD=hn((e,t)=>sD(e.params,t.params)),sD=ha(Hi([_n(),_n()])),cD=Fx(tD,{representation:{id:`effect/http/UrlParams`,payload:null},toCode:()=>({runtime:`UrlParams.UrlParamsSchema`,Type:`UrlParams.UrlParams`,importDeclarations:[`import * as UrlParams from "effect/unstable/http/UrlParams"`]}),expected:`UrlParams`,toEquivalence:()=>oD,toCodec:()=>NS()(L(yS([F,F])),R_({decode:rD,encode:e=>e.params}))}),lD=rD([]),uD=S(2,(e,t)=>rD(t(e.params))),dD=S(2,(e,t)=>{let n=iD(t),r=n.params,i=new Set;for(let e=0;e<r.length;e++)i.add(r[e][0]);for(let t=0;t<e.params.length;t++)i.has(e.params[t][0])||r.push(e.params[t]);return n}),fD=S(2,(e,t)=>uD(e,$i(iD(t).params))),pD=e=>new URLSearchParams(iD(e).params).toString(),mD=cD.pipe(B(_S(F,R([F,bS(F)])),R_({decode:e=>{let t={};for(let[n,r]of e.params)if(!Object.hasOwn(t,n))xn(t,n,r);else{let e=t[n];typeof e==`string`?xn(t,n,[e,r]):e.push(r)}return t},encode:iD}))),hD=`~effect/http/HttpBody`,gD=e=>At(e,hD);ss(`HttpBodyError`);var _D=class{[hD];constructor(){this[hD]=hD}[Ln](){return this.toJSON()}toString(){return An(this,{ignoreToString:!0})}},vD=new class extends _D{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},yD=class extends _D{_tag=`Uint8Array`;body;contentType;contentLength;constructor(e,t,n){super(),this.body=e,this.contentType=t,this.contentLength=n}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},bD=(e,t)=>new yD(e,t??`application/octet-stream`,e.length),xD=new TextEncoder,SD=(e,t)=>bD(xD.encode(e),t??`text/plain`),CD=(e,t)=>SD(JSON.stringify(e),t??`application/json`),wD=(e,t)=>SD(pD(iD(e)),t??`application/x-www-form-urlencoded`),TD=class extends _D{_tag=`FormData`;contentType=void 0;contentLength=void 0;formData;constructor(e){super(),this.formData=e}toJSON(){return{_id:`effect/HttpBody`,_tag:`FormData`,formData:this.formData}}},ED=e=>new TD(e),DD=Symbol.for(`~effect/http/Headers`),OD=Object.defineProperties(Object.create(null),{[DD]:{value:DD},[Cn]:{value(e){return RD(this,so(e,BD))}},toJSON:{value(){return Tn(this)}},[Zt]:{value(e){return AD(this,e)}},[Nt]:{value(){return Ht(this)}},toString:{value:Bn.toString},[Ln]:{value:Bn[Ln]}}),kD=e=>Object.assign(Object.create(OD),e),AD=qi(_n()),jD=Object.create(OD),MD=e=>{if(e===void 0)return jD;if(Symbol.iterator in e){let t=Object.create(OD);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(OD);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},ND=e=>Object.setPrototypeOf(e,OD),PD=S(3,(e,t,n)=>{let r=kD(e);return r[t.toLowerCase()]=n,r}),FD=S(2,(e,t)=>kD({...e,...MD(t)})),ID=S(2,(e,t)=>{let n=kD(e);return Object.assign(n,t),n}),LD=S(2,(e,t)=>{let n=kD(e);return delete n[t.toLowerCase()],n}),RD=S(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=kx(e[r]))}else for(let r in e)t.test(r)&&(n[r]=kx(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),zD=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r==`string`){if(r.toLowerCase()===e)return!0}else if(r.test(e))return!0}return!1},BD=ho(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),VD=`~effect/http/Cookies`,HD=`~effect/http/Cookies/Cookie`;ss(`CookieError`);var UD={[VD]:VD,...Bn,toJSON(){return{_id:`effect/Cookies`,cookies:Wi(this.cookies,e=>e.toJSON())}},pipe(){return rt(this,arguments)}},WD=e=>{let t=Object.create(UD);return t.cookies=e,t},GD=e=>{let t={};for(let n of e)xn(t,n.name,n);return WD(t)},KD=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=qD(e.trim());t&&n.push(t)}return GD(n)};function qD(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n);if(!JD.test(r))return;let i=t[0].slice(n+1),a=XD(i);if(t.length===1)return Object.assign(Object.create(YD),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:{if(a===void 0)break;let e=parseInt(a,10);isNaN(e)||(o.maxAge=zo(e));break}case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`}}}return Object.assign(Object.create(YD),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var JD=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,YD={[HD]:HD,...Bn,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},XD=e=>{try{return decodeURIComponent(e)}catch{return e}},ZD=`~effect/http/HttpClientError`,QD=class extends ss(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[ZD]=ZD;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},$D=e=>e.endsWith(`Error`)?e.slice(0,-5):e,eO=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,tO=class extends ss(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return eO($D(this._tag),this.description,this.methodAndUrl)}};ss(`EncodeError`);var nO=class extends ss(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return eO($D(this._tag),this.description,this.methodAndUrl)}},rO=class extends ss(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return eO($D(this._tag),this.description,e)}},iO=class extends ss(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return eO($D(this._tag),this.description,e)}},aO=class extends ss(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return eO($D(this._tag),this.description,e)}};PC(ZD)({_tag:AS(`HttpError`),kind:SS([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:nS(dC())});var oO=e=>e!==`GET`&&e!==`HEAD`&&e!==`OPTIONS`&&e!==`TRACE`,sO=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],cO=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?LD(LD(e,`content-type`),`content-length`):(e=t.contentType===void 0?LD(e,`content-type`):PD(e,`content-type`,t.contentType),t.contentLength===void 0?LD(e,`content-length`):PD(e,`content-length`,t.contentLength.toString())),lO=class extends ss(`UrlError`){},uO=(e,t,n)=>Pi({try:()=>{let r=new URL(e,dO());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),r},catch:e=>new lO({cause:e})}),dO=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},fO=`~effect/http/HttpClientRequest`,pO={[fO]:fO,...Bn,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Tn(this.headers),body:this.body.toJSON()}},pipe(){return rt(this,arguments)}};function mO(e,t,n,r,i,a){let o=Object.create(pO);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var hO=mO(`GET`,``,lD,T(),jD,vD),gO=e=>(t,n)=>yO(hO,{method:e,url:t,...n??void 0}),_O=gO(`GET`),vO=gO(`POST`),yO=S(2,(e,t)=>{let n=e;return t.method&&(n=bO(n,t.method)),t.url&&(n=TO(n,t.url)),t.headers&&(n=SO(n,t.headers)),t.urlParams&&(n=OO(n,t.urlParams)),t.hash&&(n=AO(n,t.hash)),t.body&&(n=jO(n,t.body)),t.accept&&(n=CO(n,t.accept)),t.acceptJson&&(n=wO(n)),n}),bO=S(2,(e,t)=>mO(t,e.url,e.urlParams,e.hash,e.headers,e.body)),xO=S(3,(e,t,n)=>mO(e.method,e.url,e.urlParams,e.hash,PD(e.headers,t,n),e.body)),SO=S(2,(e,t)=>mO(e.method,e.url,e.urlParams,e.hash,FD(e.headers,t),e.body)),CO=S(2,(e,t)=>xO(e,`Accept`,t)),wO=CO(`application/json`),TO=S(2,(e,t)=>{if(typeof t==`string`)return mO(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=iD(n.searchParams),i=yi(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,mO(e.method,n.toString(),r,i,e.headers,e.body)}),EO=S(2,(e,t)=>t===``?e:mO(e.method,DO(t,e.url),e.urlParams,e.hash,e.headers,e.body)),DO=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},OO=S(2,(e,t)=>mO(e.method,e.url,dD(e.urlParams,t),e.hash,e.headers,e.body)),kO=S(2,(e,t)=>mO(e.method,e.url,fD(e.urlParams,t),e.hash,e.headers,e.body)),AO=S(2,(e,t)=>mO(e.method,e.url,e.urlParams,E(t),e.headers,e.body)),jO=S(2,(e,t)=>mO(e.method,e.url,e.urlParams,e.hash,cO(e.headers,t),t)),MO=S(2,(e,t)=>jO(e,CD(t))),NO=S(2,(e,t)=>jO(e,ED(t))),PO=`~effect/http/HttpIncomingMessage`,FO=(e,t)=>{let n=Wx(IC(e)),r=t?.reviver===void 0?void 0:Wx(bC(IC(e),t));return e=>r===void 0?M(e.json,e=>n(e,t)):M(e.text,i=>i===``?M(e.json,e=>n(e,t)):r(i,t))},IO=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=qh(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=qh(e.text)}catch{}let i={...t,headers:Tn(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},LO=`~effect/http/HttpClientResponse`,RO=(e,t)=>new BO(e,t),zO=S(2,(e,t)=>{let n=e.status;return t[n]?t[n](e):n>=200&&n<300&&t[`2xx`]?t[`2xx`](e):n>=300&&n<400&&t[`3xx`]?t[`3xx`](e):n>=400&&n<500&&t[`4xx`]?t[`4xx`](e):n>=500&&n<600&&t[`5xx`]?t[`5xx`](e):t.orElse(e)}),BO=class extends Vn{[PO];[LO];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[PO]=PO,this[LO]=LO}toJSON(){return IO(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return MD(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=KD(this.source.headers.getSetCookie())}get remoteAddress(){return T()}get stream(){return this.source.body?lw({evaluate:()=>this.source.body,onError:e=>new QD({reason:new iO({request:this.request,response:this,cause:e})})}):cw(new QD({reason:new aO({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return M(this.text,e=>ah({try:()=>e===``?null:JSON.parse(e),catch:e=>new QD({reason:new iO({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=ph(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return M(this.text,e=>ah({try:()=>iD(new URLSearchParams(e)),catch:e=>new QD({reason:new iO({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=Ym({try:()=>this.source.formData(),catch:e=>new QD({reason:new iO({request:this.request,response:this,cause:e})})}).pipe(Ih,qh)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=Ym({try:()=>this.source.arrayBuffer(),catch:e=>new QD({reason:new iO({request:this.request,response:this,cause:e})})}).pipe(Ih,qh),this.arrayBufferBody}pipe(){return rt(this,arguments)}};({...$n}),ss(`HttpServerError`),ss(`RequestParseError`),ss(`RouteNotFound`),ss(`InternalError`),ss(`ResponseError`),ss(`ServeError`),O()(`effect/http/HttpServerError/ClientAbort`);var VO=new Uint8Array(256);for(let e of"!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")VO[e.charCodeAt(0)]=1;var HO=new Uint8Array(256);HO[9]=1;for(let e=32;e<=126;e++)HO[e]=1;for(let e=128;e<=255;e++)HO[e]=1;ss(`MultipartError`);var UO=O(`effect/http/HttpServerRequest`);O()(`effect/http/ParsedSearchParams`);var WO=e=>ND({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${gi(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),GO=new WeakSet,KO=e=>sh(t=>{let n=oo(t.context,UO);return GO.add(n.source),e}),qO=`~effect/http/HttpClient`,JO=O(`effect/HttpClient`),YO=S(2,(e,t)=>XO(n=>t(e.postprocess(n)),e.preprocess)),XO=(e,t)=>{let n=Object.create(ZO);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},ZO={[qO]:qO,pipe(){return rt(this,arguments)},...Bn,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(sO.map(([e,t])=>[t,function(t,n){return this.execute(gO(e)(t,n))}]))},QO=e=>XO(t=>M(t,t=>sh(n=>{let r=ok.get(t),i=r??new AbortController,a=uO(t.url,t.urlParams,Ci(t.hash));if(Ii(a))return j(new QD({reason:new nO({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(Os)||n.getRef(ek)(t)){let a=e(t,o,i.signal,n);return r?a:zh(e=>wh(e(a),{onSuccess(e){return ak.register(e,i),k(new sk(e,i))},onFailure(e){return Qd(e)&&i.abort(),nh(e)}}))}return Hh(n.getRef(rk)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(BD),l=n.getRef(tk);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,zD(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(nk)?SO(t,WO(a)):t,zh(s=>s(e(t,o,i.signal,n)).pipe(Wh(a,{captureStackTrace:!1}),wh({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,zD(t,c)?`<redacted>`:e.headers[t]);return r?k(e):(ak.register(e,i),k(new sk(e,i)))},onFailure(e){return!r&&Qd(e)&&i.abort(),nh(e)}})))})})),k),$O=S(2,(e,t)=>XO(e.postprocess,n=>ph(e.preprocess(n),t))),ek=ho(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>ct}),tk=ho(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>st}),nk=ho(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:st}),rk=ho(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),ik=e=>Hf(JO)(Eh(t=>ph(e,e=>YO(e,Ah(e=>po(t,e)))))),ak=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),ok=new WeakMap,sk=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[LO]=LO;[PO]=PO;applyInterrupt(e){return Zm(()=>(ak.unregister(this.original),Rh(e,()=>Qm(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return sw(()=>(ak.unregister(this.original),pw(this.original.stream,Qm(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Ln](){return this.original[Ln]()}pipe(){return rt(this,arguments)}},ck=O(`effect/http/HttpRouter`);O()(`effect/http/HttpRouter/RouteContext`);var lk=e=>e.endsWith(`/`)?e.slice(0,-1):e,uk=S(2,(e,t)=>(t=lk(t),e===`*`?`${t}/*`:e===`/`?t:t+e)),dk=`~effect/http/HttpRouter/Middleware`,fk=function(){return arguments.length===0?pk:pk(arguments[0],arguments[1])},pk=(e,t)=>t?.global?Gf(A(function*(){let t=yield*ck,n=Gm(e)?yield*e:e;yield*t.addGlobalMiddleware(n)})):new gk(Gm(e)?Wf(ph(e,e=>Ja(new Map([[hk,e]])))):Vf(Ja(new Map([[hk,e]])))),mk=0,hk=`effect/http/HttpRouter/MiddlewareFn`,gk=class e{[dk]={};layerFn;dependencies;constructor(e,t){this.layerFn=e,this.dependencies=t;let n=`effect/http/HttpRouter/Middleware-${++mk}`;this.layer=Wf(A({self:this},function*(){let e=yield*Th(),t=[ao(e,hk)];if(this.dependencies){let n=yield*Lf,r=so(e,yf),i=yield*Rf(this.dependencies,n,r);t.push(...vk(i))}return Ja(new Map([[n,t]]))})).pipe(Yf(this.layerFn))}layer;combine(t){return new e(this.layerFn,this.dependencies?Xf(this.dependencies,t.layer):t.layer)}},_k=new WeakMap,vk=e=>{let t=_k.get(e);if(t)return t;let n=fa(),r=0;for(let[t,i]of e.mapUnsafe)t.startsWith(`effect/http/HttpRouter/Middleware-`)&&(n.push(i),i.length>r&&(r=i.length));if(n.length===0)t=[];else{let e=new Set;for(let t=r-1;t>=0;t--)for(let r of n)t<r.length&&e.add(r[t]);t=Yi(e).reverse()}return _k.set(e,t),t};fk(KO).layer;var yk={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,OK:200,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511},bk=e=>yk[e],xk=`~effect/httpapi/HttpApiSchema/Stream`;function Sk(e){let t=typeof e==`string`?bk(e):e;return e=>e.annotate({httpApiStatus:t})}var Ck=(e=>pS.pipe(Sk(e)))(204),wk=e=>eS(e)&&At(e,xk),Tk=e=>wk(e)&&e._tag===`StreamSse`,Ek=e=>wk(e)&&e._tag===`StreamUint8Array`,Dk=`~effect/httpapi/HttpApiSchema/WithHeaders`,Ok=`~effect/httpapi/HttpApiSchema/WithHeadersValue`,kk=e=>({[Ok]:Ok,body:e.body,headers:e.headers}),Ak=e=>eS(e)&&At(e,`~effect/httpapi/HttpApiSchema/WithHeaders`);function jk(e,t,n){return P(e.ast,{[Dk]:Dk,schema:t,headers:n})}function Mk(e,t){return e.annotate({"~httpApiEncoding":{_tag:t._tag,contentType:t.contentType??Nk(t._tag)}})}function Nk(e){switch(e){case`Multipart`:return`multipart/form-data`;case`Json`:return`application/json`;case`FormUrlEncoded`:return`application/x-www-form-urlencoded`;case`Uint8Array`:return`application/octet-stream`;case`Text`:return`text/plain`}}function Pk(e){return t=>Mk(t,{_tag:`FormUrlEncoded`,...e})}var Fk=e=>{if(ov(e)||ov(qy(e)))return!0;let t=e.encoding?.[0].to;return t!==void 0&&ov(t)},Ik=fb(`~httpApiEncoding`),Lk=fb(`~httpApiWithHeaders`),Rk=fb(`httpApiStatus`),zk={_tag:`Json`,contentType:`application/json`},Bk={_tag:`FormUrlEncoded`,contentType:`application/x-www-form-urlencoded`};function Vk(e){return Ik(e)??zk}function Hk(e,t){return Ik(e)||(oO(t)?zk:Bk)}function Uk(e){let t=Vk(e);if(t._tag===`Multipart`)throw Error(`Multipart is not supported in response`);return t}function Wk(e){return Rk(e)??200}function Gk(e){return Ak(e)?Rk(e.ast)??Wk(e.schema.ast):Wk(e.ast)}function Kk(e){return Ak(e)&&Ik(e.ast)===void 0?Uk(e.schema.ast):Uk(e.ast)}function qk(e){return Rk(e)??500}function Jk(e){return Ak(e)?Rk(e.ast)??qk(e.schema.ast):qk(e.ast)}function Yk(e){let t=e.toLowerCase().trim(),n=t.indexOf(`;`);return n===-1?t:t.slice(0,n).trim()}var Xk=`~effect/httpapi/HttpApiEndpoint`;function Zk(e){let t=[];for(let{schemas:n}of e.payload.values())t.push(...n);return t}function Qk(e){let t=Array.from(e.success);return ea(t)?t:[Ck]}function $k(e){let t=new Set(e.error);for(let n of e.middlewares){let e=n;for(let n of e.error)t.add(n)}return Array.from(t)}var eA={[Xk]:Xk,pipe(){return rt(this,arguments)},prefix(e){return nA({...tA(this),path:uk(this.path,e)})},middleware(e){return nA({...tA(this),middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return nA({...tA(this),annotations:no(this.annotations,e,t)})},annotateMerge(e){return nA({...tA(this),annotations:po(this.annotations,e)})}},tA=e=>({identifier:e.identifier,path:e.path,method:e.method,params:e.params,query:e.query,headers:e.headers,payload:e.payload,success:e.success,error:e.error,annotations:e.annotations,middlewares:e.middlewares});function nA(e){function t(){}return Object.setPrototypeOf(t,eA),Object.assign(t,e)}var rA=e=>(t,n,r)=>{let i=r?.disableCodecs??!1,a=i?C:UC;return nA({identifier:t,path:n,method:e,params:iA(r?.params,a),query:iA(r?.query,a),headers:iA(r?.headers,a),payload:aA(r?.payload,e,i),success:sA(r?.success,e,i),error:lA(r?.error,i),annotations:$a(),middlewares:new Set})};function iA(e,t){if(e!==void 0)return eS(e)?t(e):t(I(e))}function aA(e,t,n){let r=new Map;if(e===void 0)return r;let i=Array.isArray(e)?e:eS(e)?[e]:[I(e).pipe(Pk())],a=n?C:yA;for(let e of i){let n=Hk(e.ast,t),i=Yk(n.contentType),o=r.get(i);if(o){if(o.encoding._tag!==n._tag)throw Error(`Multiple payload encodings for content-type: ${n.contentType}`);if(o.encoding._tag===`Multipart`)throw Error(`Multiple multipart payloads for content-type: ${n.contentType}`);o.schemas.push(a(e,t))}else r.set(i,{encoding:n,schemas:[a(e,t)]})}return r}var oA=`effect/httpapi/stream/failure`;function sA(e,t,n){if(e===void 0)return new Set;let r=Xi(e);return uA(r,t),new Set(n?r:r.map(cA))}function cA(e){return wk(e)?e:Ak(e)?jk(e,wk(e.schema)?e.schema:vA(e.schema,Kk(e)),UC(e.headers)):_A(e)}function lA(e,t){if(e===void 0)return new Set;let n=Xi(e);for(let e of n)if(wk(Ak(e)?e.schema:e))throw Error(`Streaming schemas are not supported in error responses`);return fA(n,Jk),new Set(t?n:n.map(cA))}function uA(e,t){let n=!1,r=new Map;for(let i of e){let e=Ak(i)?i.schema:i,a=Gk(i);if(wk(e)){if(pA(e,t),n)throw Error(`Multiple streaming success responses are not supported`);n=!0;let i=dA(r,a);if(i.noContent)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);if(i.bufferedContentTypes.has(Yk(e.contentType)))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`);r.set(a,{...i,stream:e})}else{let t=dA(r,a),n=Fk(e.ast);if(t.stream!==void 0){if(n)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);let e=Kk(i);if(Yk(e.contentType)===Yk(t.stream.contentType))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`)}n||t.bufferedContentTypes.add(Yk(Kk(i).contentType)),t.noContent=t.noContent||n}}fA(e,Gk)}function dA(e,t){let n=e.get(t);return n===void 0&&(n={bufferedContentTypes:new Set,noContent:!1},e.set(t,n)),n}function fA(e,t){let n=new Map;for(let r of e){let e=t(r),i=Lk(r.ast),a=Ak(r)?r.schema:i?.body??r,o=Fk(a.ast)?``:Yk(wk(a)?a.contentType:Kk(r).contentType),s=n.get(e);s===void 0&&(s={headerContentType:void 0,plainContentTypes:new Set},n.set(e,s));let c=()=>Error(`Cannot combine a response with headers with another response for status ${e} and content-type: ${o||`<no content>`}`);if(Ak(r)||i!==void 0){if(s.headerContentType!==void 0)throw Error(`Cannot declare multiple responses with headers for status ${e}`);if(s.plainContentTypes.has(o))throw c();s.headerContentType=o}else{if(s.headerContentType===o)throw c();s.plainContentTypes.add(o)}}}function pA(e,t){if(t===`HEAD`)throw Error(`HEAD endpoints cannot declare streaming success responses`);if(Tk(e)&&mA(e.events.ast))throw Error(`SSE event name is reserved: ${oA}`)}function mA(e){return hA(qy(e),new Set)}function hA(e,t){if(t.has(e))return!1;if(t.add(e),fv(e))return e.types.some(e=>hA(e,t));if(pv(e))return hA(e.thunk(),t);if(!dv(e))return!1;let n=e.propertySignatures.find(e=>e.name===`event`);return n!==void 0&&gA(n.type,t)}function gA(e,t){if(t.has(e))return!1;t.add(e);let n=qy(e);return n===e?cv(e)?e.literal===oA:fv(e)?e.types.some(e=>gA(e,t)):pv(e)?gA(e.thunk(),t):!1:gA(n,t)}function _A(e){let t=Uk(e.ast),n=Lk(e.ast);if(n===void 0)return vA(e,t);let r=iS(n.headers);return I({body:vA(iS(n.body),t),headers:r}).pipe(B(e)).annotate({"~httpApiWithHeaders":{...n,headersCodec:UC(r)}})}function vA(e,t){switch(t._tag){case`Json`:return IC(e);case`FormUrlEncoded`:return UC(e);case`Text`:case`Uint8Array`:return e}}function yA(e,t){switch(Hk(e.ast,t)._tag){case`Json`:return IC(e);case`FormUrlEncoded`:return UC(e);case`Text`:case`Uint8Array`:case`Multipart`:return e}}var bA=rA(`GET`),xA=rA(`POST`),SA=`~effect/httpapi/HttpApi`,CA={[SA]:SA,pipe(){return rt(this,arguments)},add(...e){let t={...this.groups};for(let n of e)xn(t,n.identifier,n);return TA({...wA(this),groups:t})},addHttpApi(e){let t={...this.groups};for(let n of Object.keys(e.groups)){let r=e.groups[n];xn(t,n,r.annotateMerge(po(e.annotations,r.annotations)))}return TA({...wA(this),groups:t})},prefix(e){return TA({...wA(this),groups:Wi(this.groups,t=>t.prefix(e))})},middleware(e){return TA({...wA(this),groups:Wi(this.groups,t=>t.middleware(e))})},annotate(e,t){return TA({...wA(this),annotations:no(this.annotations,e,t)})},annotateMerge(e){return TA({...wA(this),annotations:po(this.annotations,e)})}},wA=e=>({identifier:e.identifier,groups:e.groups,annotations:e.annotations}),TA=e=>{function t(){}return Object.setPrototypeOf(t,CA),Object.assign(t,e)},EA=e=>TA({identifier:e,groups:{},annotations:$a()}),DA=(e,t)=>{let n=Object.values(e.groups);for(let r of n){let n=po(e.annotations,r.annotations);t.onGroup({group:r,mergedAnnotations:n});let i=Object.values(r.endpoints);for(let e of i)t.predicate&&!t.predicate({endpoint:e,group:r})||t.onEndpoint({group:r,endpoint:e,middleware:e.middlewares,mergedAnnotations:po(n,e.annotations),successes:OA(Qk(e),Gk),errors:OA($k(e),Jk)})}},OA=(e,t)=>{let n=new Map;return e.forEach(r),n;function r(e){if(wk(Ak(e)?e.schema:e))return;let r=t(e),i=n.get(r);i===void 0?n.set(r,[e]):i.push(e)}};O()(`effect/httpapi/HttpApi/AdditionalSchemas`);var kA=`~effect/encoding/Sse/SseError`,AA=class extends ss(`EventTooLarge`){get message(){return`Pending SSE event exceeded the maximum size of ${this.maxEventSize}`}},jA=class extends ss(`SseError`){[kA]=kA;get message(){return this.reason.message}},MA=10485760,NA=e=>Nb((t,n)=>Qm(()=>{let n=[],r,i=FA(e=>{e._tag===`Retry`?r=e:n.push(e)},e),a=M(t,e=>{for(let t=0;t<e.length;t++){let n=i.feed(e[t]);if(n!==void 0)return j(n)}return $m});return Zm(function e(){if(ea(n)){let e=n;return n=[],k(e)}return r?j(r):M(a,e)})})),PA=(e,t)=>Ub(NA(t),QC(LA.pipe(B(e)))());function FA(e,t){let n=t?.maxEventSize??MA,r,i,a,o,s,c,l,u;return d(),{feed:f,reset:d};function d(){r=!0,i=``,a=0,o=-1,s=!1,c=void 0,l=void 0,u=``}function f(e){i=i?i+e:e,r&&i.startsWith(IA)&&(i=i.slice(IA.length)),r=!1;let t=i.length,c=0;for(;c<t;){s&&=(i[c]===`
|
|
15
|
+
`&&++c,!1);let e=-1,n=o,r;for(let o=a;e<0&&o<t;++o)r=i[o],r===`:`&&n<0?n=o-c:r===`\r`?(s=!0,e=o-c):r===`
|
|
16
|
+
`&&(e=o-c);if(e<0){a=t-c,o=n;break}a=0,o=-1,p(i,c,n,e),c+=e+1}if(c===t?i=``:c>0&&(i=i.slice(c)),i.length+u.length>n){let e=new jA({reason:new AA({maxEventSize:n})});return d(),e}}function p(t,n,r,i){if(i===0){u.length>0&&(e({_tag:`Event`,id:c,event:l||`message`,data:u.slice(0,-1)}),u=``),l=void 0;return}let a=r<0,o=t.slice(n,n+(a?i:r)),s=0;s=a?i:t[n+r+1]===` `?r+2:r+1;let d=n+s,f=i-s,p=t.slice(d,d+f).toString();o===`data`?u+=p?`${p}\n`:`
|
|
17
|
+
`:o===`event`?l=p:o===`id`&&!p.includes(`\0`)?c=p:o===`retry`&&/^\d+$/.test(p)&&e(new zA({duration:Ro(parseInt(p,10)),lastEventId:c}))}}var IA=``,LA=I({id:nS(F),event:F,data:F}),RA=`~effect/encoding/Sse/Retry`,zA=class e extends os(`Retry`){[RA]=RA;static is(e){return At(e,RA)}static filter(t){return e.is(t)?ji(t):Mi(t)}},BA=`~effect/httpapi/HttpApiMiddleware`,VA=`~effect/httpapi/HttpApiMiddleware/Security`,HA=()=>(e,t)=>{let n=globalThis.Error,r=Gs();Ks(2);let i=new n;Ks(r);class a extends O()(e){}let o=a;if(Object.defineProperty(a,"stack",{get(){return i.stack}}),o[BA]=BA,o.error=UA(t?.error),o.requiredForClient=t?.requiredForClient??!1,t?.security!==void 0){if(Object.keys(t.security).length===0)throw Error(`HttpApiMiddleware.Service: security object must not be empty`);o[VA]=VA,o.security=t.security}return o};function UA(e){return e===void 0?new Set:new Set(Array.isArray(e)?e:[e])}var WA=(e,t)=>A(function*(){let n=yield*Th(),r=t.httpClient.pipe(t?.baseUrl===void 0?C:$O(EO(t.baseUrl.toString())));function i(e,t,a,o,s){if(s===-1)return r.execute(a);let c=n.mapUnsafe.get(o[s]);return c===void 0?i(e,t,a,o,s-1):c({endpoint:t,group:e,request:a,next(n){return i(e,t,n,o,s-1)}})}DA(e,{predicate:t?.predicate,onGroup(e){t.onGroup?.(e)},onEndpoint(e){let{group:n,endpoint:r,errors:a,successes:o}=e,s=JA(r.path),c={orElse:pj},l=zO(c),u=new Map;for(let[e,t]of a.entries()){let n=$A(t);for(let[t,r]of n.entries())ZA(u,e,t,YA(r))}for(let[e,t]of u.entries()){let n=QA(t);c[e]=e=>M(vh(n(e),t=>nh(Yd(Wd(new QD({reason:new rO({request:e.request,response:e})})),t))),j)}let d=new Map;for(let[e,t]of o.entries()){let n=$A(t);for(let[t,r]of n.entries())ZA(d,e,t,YA(r))}for(let e of rj(r)){let t=nj(e)?e.schema:e;ZA(d,Gk(e),t.contentType,ij(e))}for(let[e,t]of d.entries())c[e]=QA(t);let f=wx(r.params,Zx),p=Zk(r),m=ea(p)?oO(r.method)?Zx(hj(p,r.method)):Zx(R(p)):void 0,h=wx(r.headers,Zx),g=wx(r.query,Zx),_=Array.from(e.middleware,e=>`${e.key}/Client`),v=Yh(function*(e){let a=gO(r.method)(r.path);if(e!==void 0){if(f!==void 0){let t=yield*f(e.params);a=TO(a,s(t))}if(m!==void 0){if(oO(r.method)){if(e.payload instanceof FormData)a=NO(a,e.payload);else{let t=yield*m(e.payload);a=jO(a,t)}}else{let t=yield*m(e.payload);a=kO(a,t)}}if(h!==void 0){let t=yield*h(e.headers);a=SO(a,t)}if(g!==void 0){let t=yield*g(e.query);a=kO(a,t)}}let o=yield*i(n,r,a,_,_.length-1);if(e?.responseMode===`response-only`)return o;let c=yield*t.transformResponse===void 0?l(o):t.transformResponse(l(o));return e?.responseMode===`decoded-and-response`?[c,o]:c});t.onEndpoint({...e,endpointFn:v})}})}),GA=(e,t)=>M(JO,n=>KA(e,{...t,httpClient:t?.transformClient?t.transformClient(n):n})),KA=(e,t)=>{let n={};return WA(e,{...t,onGroup({group:e}){e.topLevel||xn(n,e.identifier,{})},onEndpoint({endpoint:e,endpointFn:t,group:r}){xn(r.topLevel?n:n[r.identifier],e.identifier,t)}}).pipe(mh(n))},qA=/(\/?):(\w+)(\?)?/g,JA=e=>qA.test(e)?(qA.lastIndex=0,t=>(qA.lastIndex=0,e.replace(qA,(e,n,r,i)=>{let a=t[r];if(a===void 0){if(i!==void 0)return``;throw Error(`Missing path parameter: ${r}`)}return`${n}${encodeURIComponent(a)}`}))):t=>e;function YA(e){let t=e.some(e=>Ak(e)||Lk(e.ast)!==void 0),n=Wx(t?R(e.map(XA)):dj(e));return e=>M(e.arrayBuffer,t?t=>n({body:t,headers:e.headers}):n)}function XA(e){let t=Ak(e),n=Lk(e.ast);if(n!==void 0)return I({body:fj(n.body),headers:n.headersCodec}).pipe(B(e));let r=t?e.schema:e;return I({body:fj(r).pipe(B(r)),headers:t?e.headers:sS}).pipe(B(t?e:rS(e),R_({decode:e=>t?kk(e):e.body,encode:e=>t?e:{body:e,headers:void 0}})))}function ZA(e,t,n,r){let i=Yk(n),a=e.get(t);a===void 0?e.set(t,[{contentType:i,decode:r}]):a.push({contentType:i,decode:r})}function QA(e){let t=e[0];return e.length===1&&t!==void 0?t.decode:t=>{let n=Yk(t.headers[`content-type`]??``),r=e.find(e=>e.contentType===n);return r===void 0?ej(t,n,e):r.decode(t)}}function $A(e){let t=new Map;for(let n of e){let e=Fk((Ak(n)?n.schema:n).ast)?``:Yk(Kk(n).contentType),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return t}function ej(e,t,n){let r=Array.from(new Set(n.map(e=>e.contentType))).join(`, `);return j(new QD({reason:new iO({request:e.request,response:e,description:`Unsupported response content-type for status ${e.status}: ${t||`<missing>`}. Expected one of: ${r}`})}))}var tj=`effect/httpapi/stream/failure`,nj=e=>Ak(e);function rj(e){let t=[];for(let n of e.success)wk(Ak(n)?n.schema:n)&&t.push(n);return t}function ij(e){let t=nj(e),n=t?e.schema:e,r=Ek(n)?void 0:{declaration:n,decoder:aj(n)},i=e=>ph(Th(),t=>mw(r===void 0?e.stream:oj(e.stream,r.declaration,r.decoder),t));if(!t)return i;let a=Hx(e.headers);return e=>M(a(e.headers),t=>ph(i(e),e=>kk({body:e,headers:t})))}function aj(e){return PA(R([I({event:aS(tj),data:bC(IC(iC(e.error,dC())))}),e.events]))}function oj(e,t,n){let r=ow(e.pipe(fw,dw(n)),e=>Qm(()=>{let t;return Zm(()=>t===void 0?M(e,e=>{for(let n=0;n<e.length;n++){let r=e[n];if(r.event===tj&&zd(r.data)){if(n===0)return nh(r.data);t=r.data,e=e.slice(0,n);break}}return k(e)}):nh(t))}));return t.sseMode===`data`?uw(r,e=>e.data):r}var sj=MS(globalThis.ArrayBuffer,{expected:`ArrayBuffer`}),cj=sj.pipe(B(wC,R_({decode(e){return new Uint8Array(e)},encode(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}}))),lj=sj.pipe(B(F,R_({decode(e){return new TextDecoder().decode(e)},encode(e){let t=new TextEncoder().encode(e);return t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}}))),uj=lj.pipe(B(R([aS(``).pipe(B(lS,R_({decode:()=>void 0,encode:()=>``}))),xC])));function dj(e){return R(e.map(t));function t(e){return fj(e).pipe(B(e))}}function fj(e){switch(Uk(e.ast)._tag){case`Json`:return av(qy(e.ast))?uj.pipe(B(sS,R_({decode:e=>e===void 0?null:e,encode:e=>e===null?void 0:e}))):uj;case`FormUrlEncoded`:return lj.pipe(B(mD));case`Uint8Array`:return cj;case`Text`:return lj}}var pj=e=>j(new QD({reason:new iO({request:e.request,response:e})})),mj=Fx(gD);function hj(e,t){return R(e.map(e=>_j(e,t)))}var gj=new WeakMap;function _j(e,t){let n=e.ast,r=gj.get(n);if(r!==void 0)return r;let i=Hk(n,t),a=mj.pipe(B(e,L_({decode(e,t){return j(new jg({message:`Encode only schema`},e,t))},encode(e,t){switch(i._tag){case`Multipart`:return j(new jg({message:`Payload must be a FormData`},e,t));case`Json`:try{return k(SD(JSON.stringify(e),i.contentType))}catch{return j(new kg({expected:`a JSON-serializable request body`},e,t))}case`Text`:return typeof e==`string`?k(SD(e,i.contentType)):j(new kg({message:`Expected a string`},e,t));case`FormUrlEncoded`:return Ot(e)?k(wD(iD(e),i.contentType)):j(new kg({message:`Expected a record`},e,t));case`Uint8Array`:return e instanceof Uint8Array?k(bD(e,i.contentType)):j(new kg({message:`Expected a Uint8Array`},e,t))}}})));return gj.set(n,a),a}var vj=`~effect/httpapi/HttpApiGroup`,yj={[vj]:vj,add(...e){let t={...this.endpoints};for(let n of e)xn(t,n.identifier,n);return xj({...bj(this),endpoints:t})},prefix(e){return xj({...bj(this),endpoints:Wi(this.endpoints,t=>t.prefix(e))})},middleware(e){return xj({...bj(this),endpoints:Wi(this.endpoints,t=>t.middleware(e))})},annotateMerge(e){return xj({...bj(this),annotations:po(this.annotations,e)})},annotate(e,t){return xj({...bj(this),annotations:no(this.annotations,e,t)})},annotateEndpointsMerge(e){return xj({...bj(this),endpoints:Wi(this.endpoints,t=>t.annotateMerge(e))})},annotateEndpoints(e,t){return xj({...bj(this),endpoints:Wi(this.endpoints,n=>n.annotate(e,t))})},pipe(){return rt(this,arguments)}},bj=e=>({identifier:e.identifier,topLevel:e.topLevel,endpoints:e.endpoints,annotations:e.annotations}),xj=e=>{function t(){}return Object.setPrototypeOf(t,yj),t.key=`effect/httpapi/HttpApiGroup/${e.identifier}`,Object.assign(t,e)},Sj=(e,t)=>xj({identifier:e,topLevel:t?.topLevel??!1,endpoints:{},annotations:$a()}),Cj=F.check(FS(/^\S(?:.*\S)?$/u,{message:`Expected a GitHub label name without surrounding whitespace`}),qS(50,{message:`Expected a GitHub label name of at most 50 characters`})).pipe(z(`GitHubLabelName`)),wj=e=>e.toLowerCase(),Tj=F.check(FS(/^[0-9a-fA-F]{6}$/u,{message:`Expected a six-digit hex GitHub label color without #`})).pipe(z(`GitHubLabelColor`)),Ej=F.check(qS(100,{message:`Expected a GitHub label description of at most 100 characters`})),Dj=class extends H(`@usine/config/DeclaredLabel`)({name:Cj,color:ZS(Tj),description:ZS(Ej)}){},Oj=e=>F.check(FS(/\S/u,{message:e})),kj=Oj(`Expected a non-blank lane name`).pipe(z(`LaneName`)),Aj=SS([`issue-open`,`issue-closed`,`pr-open`,`pr-closed`,`pr-merged`]),jj=R([class extends H(`@usine/config/LabelLaneSource`)({label:Cj}){},class extends H(`@usine/config/StateLaneSource`)({state:Aj}){}]),Mj=class extends H(`@usine/config/Lane`)({name:kj,sources:L(jj).check(KS())}){},Nj=R([class extends U(`@usine/orchestrator/InfraFailureView`)(`InfraFailure`,{message:F}){},class extends U(`@usine/orchestrator/DefectFailureView`)(`DefectFailure`,{message:F}){},class extends U(`@usine/orchestrator/AgentFailureView`)(`AgentFailure`,{message:F}){},class extends U(`@usine/orchestrator/RunawayFailureView`)(`RunawayFailure`,{ceiling:dE}){},class extends U(`@usine/orchestrator/ChildSessionBudgetFailureView`)(`ChildSessionBudgetFailure`,{maxChildren:XT,attemptedChildren:ZT}){}]),Pj=R([class extends U(`@usine/orchestrator/SucceededAttemptView`)(`Succeeded`,{}){},class extends U(`@usine/orchestrator/FailedAttemptView`)(`Failed`,{failure:Nj}){},class extends U(`@usine/orchestrator/CanceledAttemptView`)(`Canceled`,{}){}]),Fj=class extends H(`@usine/orchestrator/AttemptView`)({id:vE,number:yE,worker:HT,brain:LT,startedAt:F,outcome:CS(Pj)}){},Ij=R([IE,LE,RE,class extends U(`@usine/orchestrator/FailedTranscriptView`)(`Failed`,{failure:Nj}){},BE,HE,UE]),Lj=class extends H(`@usine/orchestrator/TranscriptEventView`)({sequence:XE,attemptId:vE,receivedAt:F,direction:PE,payload:Ij}){},Rj=class extends H(`@usine/orchestrator/TranscriptPageCursor`)({attemptId:vE,before:XE}){},zj=class extends U(`@usine/orchestrator/ColdTranscriptRequest`)(`ColdTranscriptRequest`,{}){},Bj=class extends U(`@usine/orchestrator/TailTranscriptRequest`)(`TailTranscriptRequest`,{after:XE}){},Vj=class extends U(`@usine/orchestrator/EarlierTranscriptRequest`)(`EarlierTranscriptRequest`,{attemptId:vE,before:XE}){};R([zj,Bj,Vj]),FC(`@usine/orchestrator/TranscriptAttemptNotFoundError`)(`TranscriptAttemptNotFoundError`,{runId:jT,attemptId:vE});var Hj=SS(bT),Uj=CS(F),Wj=class extends H(`@usine/orchestrator/RunView`)({id:jT,itemKey:CE,loop:Zw,repository:Uw,agent:WT,state:Hj,loopPaused:dS,openedAt:F,task:F,attempts:L(Fj),resultMessage:Uj,pullRequestUrl:Uj,canApprove:dS,canRetry:dS,canCancel:dS}){},Gj=class extends H(`@usine/orchestrator/RunDetailView`)({run:Wj,eventDedupKey:F,eventPayload:XC,transcript:L(Lj),earlierTranscript:L(Rj)}){},Kj=V.pipe(z(`BoardLaneId`)),qj=SS([`authored`,`proposed`,`fallback`]),Jj=class extends H(`@usine/orchestrator/BoardItemLink`)({itemKey:CE,kind:SS([`issue`,`pr`]),number:wE,title:F,url:V}){},Yj=class extends H(`@usine/orchestrator/BoardTaskView`)({...Jj.fields,state:Aj,labels:L(Cj),items:L(Jj).check(KS()),runs:L(Wj),run:CS(Wj),needsYou:dS}){},Xj={id:Kj,name:kj,sources:L(jj),origin:qj,items:L(Yj)},Zj=R([class extends U(`@usine/orchestrator/WritableBoardLaneView`)(`WritableBoardLane`,{...Xj,origin:aS(`authored`),labels:L(Cj).check(KS())}){},class extends U(`@usine/orchestrator/ReadOnlyBoardLaneView`)(`ReadOnlyBoardLane`,Xj){}]),Qj=class extends FC(`@usine/orchestrator/BoardProjectionError`)(`BoardProjectionError`,{repository:Uw,itemKey:CE,message:V}){},$j=class extends H(`@usine/orchestrator/BoardView`)({lanes:L(Zj),failures:L(Qj)}){},eM=class extends H(`@usine/orchestrator/LabelView`)({name:Cj,color:CS(F),description:CS(F)}){};H(`@usine/orchestrator/BoardMove`)({repository:Uw,item:wE,toLane:Kj}),FC(`@usine/orchestrator/BoardProjectNotFoundError`)(`BoardProjectNotFoundError`,{repository:Uw}),FC(`@usine/orchestrator/BoardItemNotFoundError`)(`BoardItemNotFoundError`,{repository:Uw,item:wE}),FC(`@usine/orchestrator/BoardLaneNotFoundError`)(`BoardLaneNotFoundError`,{repository:Uw,lane:Kj}),FC(`@usine/orchestrator/BoardLaneReadOnlyError`)(`BoardLaneReadOnlyError`,{repository:Uw,lane:Kj});var W=Symbol.for(`drizzle:entityKind`);function G(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,W))throw Error(`Class "${t.name??`<unknown>`}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e)?.constructor;if(n)for(;n;){if(W in n&&n[W]===t[W])return!0;n=Object.getPrototypeOf(n)}return!1}var tM=Symbol.for(`drizzle:OriginalColumn`),nM=e=>e;nM.isNoop=!0;var rM=class{static[W]=`Column`;codec;name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;length;isLengthExact;isAlias;config;table;onInit(){}constructor(e,t){this.config=t,this.onInit(),this.table=e,this.name=t.name,this.isAlias=!1,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity,this.length=t.length,this.isLengthExact=t.isLengthExact}mapFromDriverValue=nM;mapToDriverValue=nM;postBuild(){return this}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}[tM](){return this}},iM=Symbol.for(`drizzle:Name`),aM=Symbol.for(`drizzle:Schema`),oM=Symbol.for(`drizzle:Columns`),sM=Symbol.for(`drizzle:ExtraConfigColumns`),cM=Symbol.for(`drizzle:OriginalName`),lM=Symbol.for(`drizzle:BaseName`),uM=Symbol.for(`drizzle:IsAlias`),dM=Symbol.for(`drizzle:ExtraConfigBuilder`),fM=Symbol.for(`drizzle:IsDrizzleTable`),K=class{static[W]=`Table`;static Symbol={Name:iM,Schema:aM,OriginalName:cM,Columns:oM,ExtraConfigColumns:sM,BaseName:lM,IsAlias:uM,ExtraConfigBuilder:dM};[iM];[cM];[aM];[oM];[sM];[lM];[uM]=!1;[fM]=!0;[dM]=void 0;constructor(e,t,n){this[iM]=this[cM]=e,this[aM]=t,this[lM]=n}};function pM(e){return e[iM]}var mM=class{static[W]=`Subquery`;constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},hM=class extends mM{static[W]=`WithSubquery`},gM={startActiveSpan(e,t){return t()}},_M=Symbol.for(`drizzle:ViewBaseConfig`);function vM(e){return e!=null&&typeof e.getSQL==`function`}function yM(e){let t={sql:``,params:[]};for(let n of e)t.sql+=n.sql,t.params.push(...n.params);return t}function bM(e){let t={sql:``,params:[]},n=[];for(let r of e)n.push(r.sql),t.params.push(...r.params);return t._sql=Object.assign(n,{raw:n}),t}var xM=class{static[W]=`StringChunk`;value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new q([this])}},q=class e{static[W]=`SQL`;decoder=wM;shouldInlineParams=!1;usedTables=[];constructor(e){this.queryChunks=e;for(let t of e)if(G(t,K)){let e=t[K.Symbol.Schema];this.usedTables.push(e===void 0?t[K.Symbol.Name]:e+`.`+t[K.Symbol.Name])}}append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return gM.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(t,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{escapeName:i,escapeParam:a,codecs:o,inlineParams:s,paramStartIndex:c,invokeSource:l}=r,u=t.map(t=>{if(G(t,xM))return{sql:t.value.join(``),params:[]};if(G(t,SM))return{sql:i(t.value),params:[]};if(t===void 0)return{sql:``,params:[]};if(Array.isArray(t)){let e=[new xM(`(`)];for(let[n,r]of t.entries())e.push(r),n<t.length-1&&e.push(new xM(`, `));return e.push(new xM(`)`)),this.buildQueryFromSourceParams(e,r)}if(G(t,e))return this.buildQueryFromSourceParams(t.queryChunks,{...r,inlineParams:s||t.shouldInlineParams});if(G(t,K)){let e=t[K.Symbol.Schema],n=t[K.Symbol.Name];return l===`mssql-view-with-schemabinding`?{sql:i(e===void 0?`dbo`:e)+`.`+i(n),params:[]}:{sql:e===void 0||t[uM]?i(n):i(e)+`.`+i(n),params:[]}}if(G(t,rM)){let e=t.name;if(n.invokeSource===`indexes`)return{sql:i(e),params:[]};let r=l===`mssql-check`?void 0:t.table[K.Symbol.Schema];return{sql:t.isAlias?i(t.name):t.table[uM]||r===void 0?i(t.table[K.Symbol.Name])+`.`+i(e):i(r)+`.`+i(t.table[K.Symbol.Name])+`.`+i(e),params:[]}}if(G(t,AM)){let e=t[_M].schema,n=t[_M].name;return{sql:e===void 0||t[_M].isAlias?i(n):i(e)+`.`+i(n),params:[]}}if(G(t,EM)){if(G(t.value,e))return this.buildQueryFromSourceParams([t.value],r);let n=o&&G(t.encoder,rM);if(G(t.value,OM)){let e=a(c.value++,t);return t.codec=n?e=>o.apply(t.encoder,`normalizeParam`,e):void 0,{sql:n?o.apply(t.encoder,`castParam`,e):e,params:[t]}}let i;if(t.value===null)i=t.value;else{if(i=t.encoder.mapToDriverValue.isNoop?t.value:t.encoder.mapToDriverValue(t.value),G(i,e))return this.buildQueryFromSourceParams([i],r);n&&(i=o.apply(t.encoder,`normalizeParam`,i))}if(s)return{sql:this.mapInlineParam(i,r),params:[]};let l=a(c.value++,i);return{sql:n?o.apply(t.encoder,`castParam`,l):l,params:[i]}}return G(t,OM)?{sql:a(c.value++,t),params:[t]}:G(t,e.Aliased)&&t.fieldAlias!==void 0?{sql:(t.origin===void 0?``:i(t.origin)+`.`)+i(t.fieldAlias),params:[]}:G(t,mM)?t._.isWith?{sql:i(t._.alias),params:[]}:this.buildQueryFromSourceParams([new xM(`(`),t._.sql,new xM(`) `),new SM(t._.alias)],r):typeof t==`function`&&`enumName`in t?`schema`in t&&t.schema?{sql:i(t.schema)+`.`+i(t.enumName),params:[]}:{sql:i(t.enumName),params:[]}:vM(t)?t.shouldOmitSQLParens?.()?this.buildQueryFromSourceParams([t.getSQL()],r):this.buildQueryFromSourceParams([new xM(`(`),t.getSQL(),new xM(`)`)],r):s?{sql:this.mapInlineParam(t,r),params:[]}:{sql:a(c.value++,t),params:[t]}});return n.tagged?bM(u):yM(u)}mapInlineParam(e,{escapeString:t}){if(e===null)return`null`;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(typeof e==`string`)return t(e);if(typeof e==`object`){let n=e.toString();return t(n===`[object Object]`?JSON.stringify(e):n)}throw Error(`Unexpected param value: `+e)}getSQL(){return this}as(t){return t===void 0?this:new e.Aliased(this,t)}mapWith(e){return this.decoder=typeof e==`function`?{mapFromDriverValue:e}:e,this}nullable(){return this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}},SM=class{static[W]=`Name`;brand;constructor(e){this.value=e}getSQL(){return new q([this])}};function CM(e){return typeof e==`object`&&!!e&&`mapToDriverValue`in e&&typeof e.mapToDriverValue==`function`}var wM={mapFromDriverValue:e=>e};wM.mapFromDriverValue.isNoop=!0;var TM={mapToDriverValue:e=>e};TM.mapToDriverValue.isNoop=!0,{...wM,...TM};var EM=class{static[W]=`Param`;brand;constructor(e,t=TM,n){this.value=e,this.encoder=t,this.codec=n}getSQL(){return new q([this])}};function J(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new xM(e[0]));for(let[r,i]of t.entries())n.push(i,new xM(e[r+1]));return new q(n)}(function(e){function t(){return new q([])}e.empty=t;function n(e){return new q(e)}e.fromList=n;function r(e){return new q([new xM(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new q(n)}e.join=i;function a(e){return new SM(e)}e.identifier=a;function o(e){return new OM(e)}e.placeholder=o;function s(e,t){return new EM(e,t)}e.param=s;function c(e){let t=DM(e);if(t.length)return J.raw(t)}e.comment=c})(J||={});function DM(e){let t=DM.encodeInput(e);return t.length?`/*${t}*/`:``}(function(e){function t(e,t){let r;if(typeof e==`object`&&typeof t==`object`)r=n({...e,...t});else if(e&&t)r=[n(e),n(t)].filter(e=>e.length).join(`,`);else if(t)r=n(t);else if(e)r=n(e);else return``;return r.length?`/*${r}*/`:``}e.merge=t;function n(e){if(typeof e==`string`)return e.length?i(e):e;let t=[];for(let[n,i]of Object.entries(e)){if(i==null||i===``)continue;let e=r(n),a=r(String(i));t.push(`${e}='${a}'`)}return t.length?t.sort().join(`,`):``}e.encodeInput=n;function r(e){return encodeURIComponent(e).replace(/'/g,`\\'`)}e.sanitizeObjectElement=r;function i(e){return e.replace(/\/\*/g,`/ *`).replace(/\*\//g,`* /`)}e.sanitizeStringInput=i})(DM||={}),(function(e){class t{static[W]=`SQL.Aliased`;isSelectionField=!1;origin;constructor(e,t){this.sql=e,this.fieldAlias=t}getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(q||={});var OM=class{static[W]=`Placeholder`;constructor(e){this.name=e}getSQL(){return new q([this])}},kM=Symbol.for(`drizzle:IsDrizzleView`),AM=class{static[W]=`View`;[_M];[kM]=!0;get[iM](){return this[_M].name}get[aM](){return this[_M].schema}get[uM](){return this[_M].isAlias}get[cM](){return this[_M].originalName}get[oM](){return this[_M].selectedFields}constructor({name:e,schema:t,selectedFields:n,query:r}){this[_M]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}};rM.prototype.getSQL=function(){return new q([this])},mM.prototype.getSQL=function(){return new q([this])};var jM=class extends Error{static[W]=`DrizzleError`;constructor({message:e,cause:t}){super(e),this.name=`DrizzleError`,this.cause=t}};function MM(e,t){return CM(t)&&!vM(e)&&!G(e,EM)&&!G(e,OM)&&!G(e,rM)&&!G(e,K)&&!G(e,AM)?new EM(e,t):e}var Y=(e,t)=>J`${e} = ${MM(t,e)}`,NM=(e,t)=>J`${e} <> ${MM(t,e)}`;function PM(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new q(t):new q([new xM(`(`),J.join(t.map(e=>J`(${e})`),new xM(` and `)),new xM(`)`)])}function FM(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new q(t):new q([new xM(`(`),J.join(t.map(e=>J`(${e})`),new xM(` or `)),new xM(`)`)])}function IM(e){return G(e,q)?J`not (${e})`:J`not ${e}`}var LM=(e,t)=>J`${e} > ${MM(t,e)}`,RM=(e,t)=>J`${e} >= ${MM(t,e)}`,zM=(e,t)=>J`${e} < ${MM(t,e)}`,BM=(e,t)=>J`${e} <= ${MM(t,e)}`;function VM(e,t){return Array.isArray(t)?t.length===0?J`false`:J`${e} in ${t.map(t=>MM(t,e))}`:J`${e} in ${MM(t,e)}`}function HM(e,t){return Array.isArray(t)?t.length===0?J`true`:J`${e} not in ${t.map(t=>MM(t,e))}`:J`${e} not in ${MM(t,e)}`}function UM(e){return J`(${e} is null)`}function WM(e){return J`(${e} is not null)`}function GM(e){return J`exists ${e}`}function KM(e){return J`not exists ${e}`}function qM(e,t,n){return J`${e} between ${MM(t,e)} and ${MM(n,e)}`}function JM(e,t,n){return J`${e} not between ${MM(t,e)} and ${MM(n,e)}`}function YM(e,t){return J`${e} like ${t}`}function XM(e,t){return J`${e} not like ${t}`}function ZM(e,t){return J`${e} ilike ${t}`}function QM(e,t){return J`${e} not ilike ${t}`}function $M(e,t){if(Array.isArray(t)){if(t.length===0)throw Error(`arrayContains requires at least one value`);let n=MM(t,e);return J`${e} @> ${J`${Array.isArray(n)?new EM(n):n}`}`}return J`${e} @> ${MM(t,e)}`}function eN(e,t){if(Array.isArray(t)){if(t.length===0)throw Error(`arrayContained requires at least one value`);let n=MM(t,e);return J`${e} <@ ${J`${Array.isArray(n)?new EM(n):n}`}`}return J`${e} <@ ${MM(t,e)}`}function tN(e,t){if(Array.isArray(t)){if(t.length===0)throw Error(`arrayOverlaps requires at least one value`);let n=MM(t,e);return J`${e} && ${J`${Array.isArray(n)?new EM(n):n}`}`}return J`${e} && ${MM(t,e)}`}function nN(e){return J`${e} asc`}function rN(e){return J`${e} desc`}var iN=class{static[W]=`ColumnTableAliasProxyHandler`;constructor(e,t){this.table=e,this.ignoreColumnAlias=t}get(e,t){return t===`table`?this.table:t===`isAlias`&&this.ignoreColumnAlias?!1:e[t]}},aN=class{static[W]=`ViewSelectionAliasProxyHandler`;constructor(e,t,n){this.view=e,this.selection=t,this.ignoreColumnAlias=n}get(e,t){let n=e[t];return G(n,rM)?new Proxy(n,new iN(this.view,this.ignoreColumnAlias)):G(n,mM)||G(n,q)||G(n,q.Aliased)||vM(n)||typeof n!=`object`||!n?n:new Proxy(n,this)}},oN=class{static[W]=`TableAliasProxyHandler`;constructor(e,t,n){this.alias=e,this.replaceOriginalName=t,this.ignoreColumnAlias=n}get(e,t){if(t===K.Symbol.IsAlias)return!0;if(t===K.Symbol.Name||this.replaceOriginalName&&t===K.Symbol.OriginalName)return this.alias;if(t===_M)return{...e[_M],name:this.alias,isAlias:!0,selectedFields:new Proxy(e[_M].selectedFields,new aN(new Proxy(e,this),e[_M].selectedFields,this.ignoreColumnAlias))};if(t===K.Symbol.Columns){let t=e[K.Symbol.Columns];if(!t)return t;if(G(e,AM))return new Proxy(e[K.Symbol.Columns],new aN(new Proxy(e,this),e[K.Symbol.Columns],this.ignoreColumnAlias));let n={};return Object.keys(t).map(r=>{n[r]=new Proxy(t[r],new iN(new Proxy(e,this),this.ignoreColumnAlias))}),n}let n=e[t];return G(n,rM)?new Proxy(n,new iN(new Proxy(e,this),this.ignoreColumnAlias)):n}},sN=class{static[W]=`ColumnAliasProxyHandler`;constructor(e){this.alias=e}get(e,t){return t===`isAlias`?!0:t===`name`?this.alias:t===`keyAsName`?!1:t===tM?()=>e:e[t]}};function cN(e,t){return new Proxy(e,new oN(t,!1,!1))}function lN(e,t){return new Proxy(e,new sN(t))}rM.prototype.as=function(e){return lN(this,e)};function uN(e){return e[tM]()}var dN=Object.getPrototypeOf(()=>null).constructor;function fN(e,t={}){let n=[],r=[];r.push(`const [ ${e.map((e,t)=>`c${t}`).join(`, `)} ] = rows[i];`);let i={},a={},o=Array.from({length:e.length});for(let r=0;r<e.length;++r){let{field:s,path:c,codec:l,arrayDimensions:u}=e[r],d,f,p,m=!1;G(s,rM)?(m=!0,d=s,p=`field: decoder${r}`):G(s,q)?(d=s.decoder,p=`field: { decoder: decoder${r} }`):G(s,mM)?(d=s._.sql.decoder,p=`field: { _: { sql: { decoder: decoder${r} } } }`):(d=s.sql.decoder,p=`field: { sql: { decoder: decoder${r} } }`),f=`decoder${r}.mapFromDriverValue`,d.mapFromDriverValue.isNoop&&(f=``),f?n.push(`const { ${p}${l?`, codec: codec${r}`:``} } = columns[${r}];`):l&&n.push(`const { codec: codec${r} } = columns[${r}];`);let h=`c${r}`,g=h;if(l&&(g=`codec${r}(${g}, ${u})`),f&&(g=`${f}(${g})`),o[r]=h===g?`${h}`:`${h} === null ? ${h} : ${g}`,c.length!==2||!m)continue;a[c[0]]===void 0?a[c[0]]=[`c${r}`]:a[c[0]]?.push(`c${r}`);let[_]=c,v=pM(s.table);i[_]=t[v]?!1:typeof i[_]==`string`?i[_]===v&&v:v}r.push(`mapped[i] = {`);let s=[];for(let t=0;t<e.length;++t){let{path:n}=e[t],c=n.map(e=>JSON.stringify(e)),l=o[t],u=n.slice(0,-1),d=0;for(;d<s.length&&d<u.length&&s[d]===u[d];)d++;for(let e=s.length-1;e>=d;--e)r.push(`${` `.repeat(e+1)}},`);for(let e=d;e<u.length;++e)r.push(`${` `.repeat(e+1)}${c[e]}: ${e===0&&u.length===1&&typeof i[n[0]]==`string`?`${a[n[0]]?.map(e=>`${e} === null`).join(` && `)} ? null : {`:`{`}`);s=u,r.push(`${` `.repeat(n.length)}${c[n.length-1]}: ${l},`)}for(let e=s.length-1;e>=0;--e)r.push(`${` `.repeat(e+1)}},`);return r.push(`};`),`${n.length?`${n.join(`
|
|
18
|
+
`)}\n\t`:``}for (let i = 0; i < length; ++i) {
|
|
19
|
+
${r.join(`
|
|
20
|
+
`)}
|
|
21
|
+
}`}function pN(e,t){let n=`\t"use strict";
|
|
22
|
+
const { columns } = this;
|
|
23
|
+
const { length } = rows;
|
|
24
|
+
const mapped = Array.from({ length });
|
|
25
|
+
${fN(e,t)}
|
|
26
|
+
return mapped;
|
|
27
|
+
//# sourceURL=drizzle:jit-query-mapper`;return Object.assign(new dN(`rows`,n).bind({columns:e}),{body:`function jitQueryMapper (rows) {\n${n}\n}`})}function mN(e,t){let n=e.map(({field:e,codec:n,arrayDimensions:r,path:i})=>{let a,o;if(G(e,rM)){if(o=e,t&&i.length===2){let t=i[0];a=(n,r)=>{t in n?typeof n[t]==`string`&&n[t]!==pM(e.table)&&(n[t]=!1):n[t]=r===null&&pM(e.table)}}}else o=G(e,q)?e.decoder:G(e,mM)?e._.sql.decoder:e.sql.decoder;let s;return s=o.mapFromDriverValue.isNoop?n?e=>n(e,r):void 0:n?e=>o.mapFromDriverValue(n(e,r)):e=>o.mapFromDriverValue(e),[s,a]});return(r=>r.map(r=>{let i={},a=e.reduce((e,{path:t},a)=>{let o=e;for(let[e,s]of t.entries())if(e<t.length-1)s in o||(o[s]={}),o=o[s];else{let[e,t]=n[a],c=r[a],l=o[s]=c===null?null:e?e(c):c;t?.(i,l)}return e},{});if(t&&Object.keys(i).length>0)for(let[e,n]of Object.entries(i))typeof n==`string`&&!t[n]&&(a[e]=null);return a}))}function hN(e,t,n){return Object.entries(e).reduce((e,[r,i])=>{if(typeof r!=`string`)return e;let a=t?[...t,r]:[r];if(G(i,rM))e.push({path:a,field:i,codec:n?.get(i,`normalize`),arrayDimensions:i.dimensions,column:i});else if(G(i,q)||G(i,q.Aliased)){let t=gN(i);e.push(t?{path:a,field:i,codec:n?.get(t,`normalize`),arrayDimensions:t.dimensions,column:t}:{path:a,field:i})}else if(G(i,mM)){let t,r=Object.values(i._.selectedFields)[0],o;G(r,rM)?(t=r,o=r):G(r,q)?(t=gN(r),o=r.decoder):(t=gN(r),o=r.sql.decoder),o&&(i._.sql.decoder=o),e.push(t?{path:a,field:i,codec:n?.get(t,`normalize`),arrayDimensions:t.dimensions,column:t}:{path:a,field:i})}else G(i,K)?e.push(...hN(i[K.Symbol.Columns],a,n)):e.push(...hN(i,a,n));return e},[])}function gN(e){let t=e.getSQL();if(G(t.decoder,rM))return t.decoder}function _N(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let[e,t]of n.entries())if(t!==r[e])return!1;return!0}function vN(e){return e[K.Symbol.Columns]}function yN(e){return G(e,mM)?e._.alias:G(e,AM)?e[_M].name:G(e,q)?void 0:e[K.Symbol.IsAlias]?e[K.Symbol.Name]:e[K.Symbol.BaseName]}function bN(e,t){return{name:typeof e==`string`&&e.length>0?e:``,config:typeof e==`object`?e:t}}var xN=typeof TextDecoder>`u`?null:new TextDecoder,SN=class{static[W]=`RelationV2`;fieldName;sourceColumns;targetColumns;alias;where;sourceTable;targetTable;through;throughTable;isReversed;sourceColumnTableNames=[];targetColumnTableNames=[];constructor(e,t){this.targetTableName=t,this.targetTable=e}},CN=class extends SN{static[W]=`OneV2`;relationType=`one`;optional;constructor(e,t,n,r){super(t,n),this.alias=r?.alias,this.where=r?.where,r?.from&&(this.sourceColumns=(Array.isArray(r.from)?r.from:[r.from]).map(t=>(this.throughTable??=t._.through?e[t._.through._.tableName]:void 0,this.sourceColumnTableNames.push(t._.tableName),t._.column))),r?.to&&(this.targetColumns=(Array.isArray(r.to)?r.to:[r.to]).map(t=>(this.throughTable??=t._.through?e[t._.through._.tableName]:void 0,this.targetColumnTableNames.push(t._.tableName),t._.column))),this.throughTable&&(this.through={source:(Array.isArray(r?.from)?r.from:r?.from?[r.from]:[]).map(e=>e._.through),target:(Array.isArray(r?.to)?r.to:r?.to?[r.to]:[]).map(e=>e._.through)}),this.optional=r?.optional??!0}},wN={and:PM,between:qM,eq:Y,exists:GM,gt:LM,gte:RM,ilike:ZM,inArray:VM,arrayContains:$M,arrayContained:eN,arrayOverlaps:tN,isNull:UM,isNotNull:WM,like:YM,lt:zM,lte:BM,ne:NM,not:IM,notBetween:JM,notExists:KM,notLike:XM,notIlike:QM,notInArray:HM,or:FM,sql:J},TN={sql:J,asc:nN,desc:rN};function EN(e,t,n,r=!1,i=!1,a=!0){let o=t?1:e.length,s=n.map(({field:e,codec:t,arrayDimensions:n})=>{let r;return r=G(e,rM)?e:G(e,q)?e.decoder:G(e,q.Aliased)?e.sql.decoder:G(e,K)||G(e,AM)?wM:e.getSQL().decoder,a&&e.mapFromJsonValue?t=>e.mapFromJsonValue(t):r.mapFromDriverValue.isNoop?t?e=>t(e,n):void 0:t?e=>r.mapFromDriverValue(t(e,n)):e=>r.mapFromDriverValue(e)});for(let a=0;a<o;++a){let o=t?e:e[a];for(let e=0;e<n.length;++e){let t=n[e];if(t.selection){if(o[t.key]===null)continue;if(r){if(o[t.key]=JSON.parse(o[t.key]),o[t.key]===null)continue}else i&&typeof o[t.key]==`string`&&(o[t.key]=JSON.parse(o[t.key]));if(t.isArray){EN(o[t.key],!1,t.selection,!1,i);continue}EN(o[t.key],!0,t.selection,!1,i);continue}if(o[t.key]===null)continue;let a=s[e];a&&(o[t.key]=a(o[t.key]))}}return e}function DN(e,t,n,r=!1,i=!1){let a=t?1:e.length,o=n.map(({field:e,codec:t,arrayDimensions:n})=>{let r;return r=G(e,rM)?e:G(e,q)?e.decoder:G(e,q.Aliased)?e.sql.decoder:G(e,K)||G(e,AM)?wM:e.getSQL().decoder,r.mapFromDriverValue.isNoop?t?e=>t(e,n):void 0:t?e=>r.mapFromDriverValue(t(e,n)):e=>r.mapFromDriverValue(e)}),s=Array.from({length:a});for(let c=0;c<a;++c){let a=t?e:e[c],l={};for(let e=0;e<n.length;++e){let t=n[e],s=a[e];if(t.selection){if(s===null){l[t.key]=null;continue}if(r){if(s=JSON.parse(s),s===null){l[t.key]=null;continue}}else i&&typeof s==`string`&&(s=JSON.parse(s));t.isArray?EN(s,!1,t.selection,!1,i):EN(s,!0,t.selection,!1,i),l[t.key]=s;continue}if(s===null){l[t.key]=null;continue}let c=o[e];l[t.key]=c?c(s):s}s[c]=l}return t?s[0]:s}function ON({selection:e,isFirst:t,parseJson:n,parseJsonIfString:r,rootJsonMappers:i,arrayModeRoot:a}){return(o=>t&&!o[0]?o[0]:a?DN(t?o[0]:o,t,e,n,r):EN(t?o[0]:o,t,e,n,r,i))}function kN(e,t,n,r,i,a,o,s,c){let l=[],u=[],d=!1,f=e.map(()=>`c${s.n++}`),p=e.map((e,t)=>c?f[t]:`${JSON.stringify(e.key)}: ${f[t]}`);l.push(c?`let [ ${p.join(`, `)} ] = ${t};`:`let { ${p.join(`, `)} } = ${t};`);for(let[t,{field:c,key:p,codec:m,isArray:h,selection:g,arrayDimensions:_}]of e.entries()){let e=`${n}[${t}]`,v=JSON.stringify(p),y=f[t];if(g){r?(l.push(`if (${y} !== null) ${y} = JSON.parse(${y});`),d=!0):i&&(l.push(`if (typeof ${y} === 'string') ${y} = JSON.parse(${y});`),d=!0);let t=`s${s.n++}`,n=o.length;if(o.push(`const { selection: ${t} } = ${e};`),h){let e=`j${s.n++}`,r=kN(g,`${y}[${e}]`,t,!1,i,!0,o,s,!1);if(r.hasWork){d=!0,l.push(`if (${y} !== null) {`),l.push(`\tfor (let ${e} = 0; ${e} < ${y}.length; ++${e}) {`);for(let e of r.bodyStmts)l.push(`\t\t${e}`);l.push(`\t\t${y}[${e}] = ${r.literal};`),l.push(` }`),l.push(`}`)}else o.splice(n,1)}else{let e=kN(g,y,t,!1,i,!0,o,s,!1);if(e.hasWork){d=!0,l.push(`if (${y} !== null) {`);for(let t of e.bodyStmts)l.push(`\t${t}`);l.push(`\t${y} = ${e.literal};`),l.push(`}`)}else o.splice(n,1)}u.push(`${v}: ${y}`);continue}let b=``,x=``,ee=!1;if(G(c,rM)){if(a&&c.mapFromJsonValue){ee=!0;let e=s.n++;x=`field: dec${e}`,b=`dec${e}.mapFromJsonValue`}else if(!c.mapFromDriverValue.isNoop){let e=s.n++;x=`field: dec${e}`,b=`dec${e}.mapFromDriverValue`}}else if(G(c,q)){if(a&&c.decoder.mapFromJsonValue){ee=!0;let e=s.n++;x=`field: { decoder: dec${e} }`,b=`dec${e}.mapFromJsonValue`}else if(!c.decoder.mapFromDriverValue.isNoop){let e=s.n++;x=`field: { decoder: dec${e} }`,b=`dec${e}.mapFromDriverValue`}}else if(G(c,q.Aliased)){if(a&&c.sql.decoder.mapFromJsonValue){ee=!0;let e=s.n++;x=`field: { sql: { decoder: dec${e} } }`,b=`dec${e}.mapFromJsonValue`}else if(!c.sql.decoder.mapFromDriverValue.isNoop){let e=s.n++;x=`field: { sql: { decoder: dec${e} } }`,b=`dec${e}.mapFromDriverValue`}}else if(!(G(c,K)||G(c,AM))){let t=c.getSQL();if(a&&t.decoder.mapFromJsonValue){ee=!0;let t=s.n++;o.push(`const dec${t} = ${e}.field.getSQL().decoder;`),b=`dec${t}.mapFromJsonValue`}else if(!t.decoder.mapFromDriverValue.isNoop){let t=s.n++;o.push(`const dec${t} = ${e}.field.getSQL().decoder;`),b=`dec${t}.mapFromDriverValue`}}let te=``;if(!ee&&m&&(te=`codec${s.n++}`),x||te){let t=[];x&&t.push(x),te&&t.push(`codec: ${te}`),o.push(`const { ${t.join(`, `)} } = ${e};`)}if(b||te){d=!0;let e=y;te&&(e=`${te}(${e}, ${_})`),b&&(e=`${b}(${e})`),u.push(`${v}: ${y} === null ? null : ${e}`)}else u.push(`${v}: ${y}`)}return{bodyStmts:l,literal:`{ ${u.join(`, `)} }`,hasWork:d}}function AN({selection:e,isFirst:t,parseJson:n,parseJsonIfString:r,rootJsonMappers:i,arrayModeRoot:a}){let o=[],s=kN(e,`row`,`selection`,n,r,!a&&i,o,{n:0},!!a),c=[];c.push(` "use strict";
|
|
28
|
+
const { selection } = this;`);for(let e of o)c.push(`\t${e}`);if(a){if(t){c.push(` const row = rows[0];`),c.push(` if (!row) return undefined;`);for(let e of s.bodyStmts)c.push(`\t${e}`);c.push(`\treturn ${s.literal};`)}else{c.push(` const { length } = rows;`),c.push(` const mapped = Array.from({ length });`),c.push(` for (let i = 0; i < length; ++i) {`),c.push(` const row = rows[i];`);for(let e of s.bodyStmts)c.push(`\t\t${e}`);c.push(`\t\tmapped[i] = ${s.literal};`),c.push(` }`),c.push(` return mapped;`)}}else if(!s.hasWork)c.push(t?` return rows[0];`:` return rows;`);else if(t){c.push(` const row = rows[0];`),c.push(` if (!row) return undefined;`);for(let e of s.bodyStmts)c.push(`\t${e}`);c.push(`\trows[0] = ${s.literal};`),c.push(` return rows[0];`)}else{c.push(` for (let i = 0; i < rows.length; ++i) {`),c.push(` const row = rows[i];`);for(let e of s.bodyStmts)c.push(`\t\t${e}`);c.push(`\t\trows[i] = ${s.literal};`),c.push(` }`),c.push(` return rows;`)}c.push(` //# sourceURL=drizzle:jit-relational-query-mapper`);let l=c.join(`
|
|
29
|
+
`);return Object.assign(new dN(`rows`,l).bind({selection:e}),{body:`function jitRqbMapper (rows) {\n${l}\n}`})}function jN(e,t){let n=e[oM][t];return n?G(n,rM)?n:G(n,q.Aliased)?J`${e}.${J.identifier(n.fieldAlias)}`:J`${e}.${J.identifier(t)}`:J`${e}.${J.identifier(t)}`}function MN(e,t){if(typeof t!=`object`||G(t,OM))return Y(e,t);let n=Object.entries(t);if(!n.length)return;let r=[];for(let[t,i]of n)if(i!==void 0)switch(t){case`NOT`:{let t=MN(e,i);if(!t)continue;r.push(IM(t));continue}case`OR`:if(!i.length)continue;r.push(FM(...i.map(t=>MN(e,t))));continue;case`AND`:if(!i.length)continue;r.push(PM(...i.map(t=>MN(e,t))));continue;case`isNotNull`:case`isNull`:if(!i)continue;r.push(wN[t](e));continue;case`in`:r.push(wN.inArray(e,i));continue;case`notIn`:r.push(wN.notInArray(e,i));continue;default:r.push(wN[t](e,i));continue}if(r.length)return PM(...r)}function NN(e,t,n={},r={},i=0){let a=Object.entries(t);if(!a.length)return;let o=[];for(let[t,s]of a)if(s!==void 0)switch(t){case`RAW`:{let t=typeof s==`function`?s(e,wN):s.getSQL();o.push(t);continue}case`OR`:if(!s?.length)continue;o.push(FM(...s.map(t=>NN(e,t,n,r,i))));continue;case`AND`:if(!s?.length)continue;o.push(PM(...s.map(t=>NN(e,t,n,r,i))));continue;case`NOT`:{if(s===void 0)continue;let t=NN(e,s,n,r,i);if(!t)continue;o.push(IM(t));continue}default:{if(e[oM][t]){let n=MN(jN(e,t),s);n&&o.push(n);continue}let a=n[t];if(!a)throw new jM({message:`Unknown relational filter field: "${t}"`});let c=cN(a.targetTable,`f${i}`),l=a.throughTable?cN(a.throughTable,`ft${i}`):void 0,u=r[a.targetTableName],{filter:d,joinCondition:f}=IN(a,e,c,l),p=PM(d,typeof s==`boolean`?void 0:NN(c,s,u.relations,r,i+1)),m=l?J`(select * from ${LN(c)} inner join ${LN(l)} on ${f}${J` where ${p}`.if(p)} limit 1)`:J`(select * from ${LN(c)}${J` where ${p}`.if(p)} limit 1)`;p&&o.push((s?GM:KM)(m))}}return PM(...o)}function PN(e,t){if(typeof t==`function`){let n=t(e,TN);return G(n,q)?n:Array.isArray(n)?n.length?J.join(n.map(e=>G(e,q)?e:nN(e)),J`, `):void 0:G(n,rM)?nN(n):void 0}let n=Object.entries(t).filter(([e,t])=>t);if(n.length)return J.join(n.map(([t,n])=>(n===`asc`?nN:rN)(jN(e,t))),J`, `)}function FN(e,t,n,r){let i=[],a=[];for(let[o,s]of Object.entries(t)){if(!s)continue;let t=(typeof s==`function`?s(e,{sql:wN.sql}):s).getSQL(),c=n?gN(t):void 0,l=c&&(!r||!c.jsonSelectIdentifier)?J`${n.apply(c,r?`castInJson`:`cast`,J`(${t})`)} as ${J.identifier(o)}`:J`(${t}) as ${J.identifier(o)}`;l.decoder=t.decoder,i.push(l),a.push(c&&(!r||!c.mapFromJsonValue)?{key:o,field:l,codec:n.get(c,r?`normalizeInJson`:`normalize`),arrayDimensions:c.dimensions}:{key:o,field:l})}return{sql:i.length?J.join(i,J`, `):void 0,selection:a}}function IN(e,t,n,r){if(e.through){let i=e.sourceColumns.map((n,i)=>{let a=e.through.source[i];return Y(J`${t}.${J.identifier(n.name)}`,J`${r}.${J.identifier(G(a._.column,rM)?a._.column.name:a._.key)}`)}),a=e.targetColumns.map((t,i)=>{let a=e.through.target[i];return Y(J`${r}.${J.identifier(G(a._.column,rM)?a._.column.name:a._.key)}`,J`${n}.${J.identifier(t.name)}`)});return{filter:PM(e.where?NN(e.isReversed?t:n,e.where):void 0,...i),joinCondition:PM(...a)}}return{filter:PM(...e.sourceColumns.map((r,i)=>{let a=e.targetColumns[i];return Y(J`${t}.${J.identifier(r.name)}`,J`${n}.${J.identifier(a.name)}`)}),e.where?NN(e.isReversed?t:n,e.where):void 0)}}function LN(e){return J`${e[uM]?J`${J`${J.identifier(e[aM]??``)}.`.if(e[aM])}${J.identifier(e[cM])} as ${e}`:e}`}var RN=class{static[W]=`ColumnBuilder`;config;constructor(e,t,n){this.config={name:e,keyAsName:e===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e,t){this.config.name===``&&(this.config.name=t(e))}},zN=class e extends O()(`@usine/engine/internal/RunDatabase`){static layer=t=>Bf(e)(t)},BN=class{static[W]=`SQLiteForeignKeyBuilder`;reference;_onUpdate;_onDelete;constructor(e,t){this.reference=()=>{let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignTable:r[0].table,foreignColumns:r}},t&&(this._onUpdate=t.onUpdate,this._onDelete=t.onDelete)}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new VN(e,this)}},VN=class{static[W]=`SQLiteForeignKey`;reference;onUpdate;onDelete;constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[iM],...r,n[0].table[iM],...i];return e??`${a.join(`_`)}_fk`}isNameExplicit(){return!!this.reference().name}};function HN(e){function t(){if(typeof e==`function`){let{name:t,columns:n,foreignColumns:r}=e();return{name:t,columns:n,foreignColumns:r}}return e}return new BN(t)}var UN=class extends RN{static[W]=`SQLiteColumnBuilder`;foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:`always`,mode:t?.mode??`virtual`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((n,r)=>{let i=new BN(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)})(n,r))}},WN=class extends rM{static[W]=`SQLiteColumn`;table;constructor(e,t){super(e,t),this.table=e}};function GN(e){let t=``;for(let n=0;n<e.length;n+=2){let r=e.slice(n,n+2),i=Number.parseInt(r,16);t+=String.fromCodePoint(i)}return t}var KN=class extends UN{static[W]=`SQLiteBigIntBuilder`;constructor(e){super(e,`bigint int64`,`SQLiteBigInt`)}build(e){return new qN(e,this.config)}},qN=class extends WN{static[W]=`SQLiteBigInt`;getSQLType(){return`blob`}mapFromDriverValue=e=>{if(typeof e==`string`)return BigInt(GN(e));if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString(`utf8`))}return BigInt(xN.decode(e))};mapToDriverValue=e=>Buffer.from(e.toString())},JN=class extends UN{static[W]=`SQLiteBlobJsonBuilder`;constructor(e){super(e,`object json`,`SQLiteBlobJson`)}build(e){return new YN(e,this.config)}},YN=class extends WN{static[W]=`SQLiteBlobJson`;getSQLType(){return`blob`}mapFromDriverValue=e=>{if(typeof e==`string`)return JSON.parse(GN(e));if(typeof Buffer<`u`&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString(`utf8`))}return JSON.parse(xN.decode(e))};mapToDriverValue=e=>Buffer.from(JSON.stringify(e))},XN=class extends UN{static[W]=`SQLiteBlobBufferBuilder`;constructor(e){super(e,`object buffer`,`SQLiteBlobBuffer`)}build(e){return new ZN(e,this.config)}},ZN=class extends WN{static[W]=`SQLiteBlobBuffer`;mapFromDriverValue=e=>Buffer.isBuffer(e)?e:typeof e==`string`?Buffer.from(e,`hex`):Buffer.from(e);getSQLType(){return`blob`}};function QN(e,t){let{name:n,config:r}=bN(e,t);return r?.mode===`bigint`?new KN(n):r?.mode===`buffer`?new XN(n):new JN(n)}var $N=class extends UN{static[W]=`SQLiteCustomColumnBuilder`;constructor(e,t,n){super(e,`custom`,`SQLiteCustomColumn`),this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new eP(e,this.config)}},eP=class extends WN{static[W]=`SQLiteCustomColumn`;sqlName;mapTo;mapFrom;mapJson;forJsonSelect;constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver,this.mapJson=t.customTypeParams.fromJson,this.forJsonSelect=t.customTypeParams.forJsonSelect}getSQLType(){return this.sqlName}mapFromDriverValue=e=>typeof this.mapFrom==`function`?this.mapFrom(e):e;mapFromJsonValue(e){return typeof this.mapJson==`function`?this.mapJson(e):this.mapFromDriverValue(e)}jsonSelectIdentifier(e,t){if(typeof this.forJsonSelect==`function`)return this.forJsonSelect(e,t);let n=this.getSQLType().toLowerCase(),r=n.indexOf(`(`);switch(r+1?n.slice(0,r):n){case`numeric`:case`decimal`:case`bigint`:return t`cast(${e} as text)`;case`blob`:return t`hex(${e})`;default:return e}}mapToDriverValue=e=>typeof this.mapTo==`function`?this.mapTo(e):e};function tP(e){return(t,n)=>{let{name:r,config:i}=bN(t,n);return new $N(r,i,e)}}var nP=class extends UN{static[W]=`SQLiteBaseIntegerBuilder`;constructor(e,t,n){super(e,t,n),this.config.autoIncrement=!1}primaryKey(e){return e?.autoIncrement&&(this.config.autoIncrement=!0),this.config.hasDefault=!0,super.primaryKey()}},rP=class extends WN{static[W]=`SQLiteBaseInteger`;autoIncrement=this.config.autoIncrement;getSQLType(){return`integer`}},iP=class extends nP{static[W]=`SQLiteIntegerBuilder`;constructor(e){super(e,`number int53`,`SQLiteInteger`)}build(e){return new aP(e,this.config)}},aP=class extends rP{static[W]=`SQLiteInteger`},oP=class extends nP{static[W]=`SQLiteTimestampBuilder`;constructor(e,t){super(e,`object date`,`SQLiteTimestamp`),this.config.mode=t}defaultNow(){return this.default(J`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new sP(e,this.config)}},sP=class extends rP{static[W]=`SQLiteTimestamp`;mode=this.config.mode;mapFromDriverValue=e=>typeof e==`string`?new Date(e.replaceAll(`"`,``)):this.config.mode===`timestamp`?new Date(e*1e3):new Date(e);mapToDriverValue=e=>{if(typeof e==`number`)return e;let t=e.getTime();return this.config.mode===`timestamp`?Math.floor(t/1e3):t}},cP=class extends nP{static[W]=`SQLiteBooleanBuilder`;constructor(e,t){super(e,`boolean`,`SQLiteBoolean`),this.config.mode=t}build(e){return new lP(e,this.config)}},lP=class extends rP{static[W]=`SQLiteBoolean`;mode=this.config.mode;mapFromDriverValue=e=>Number(e)===1;mapToDriverValue=e=>+!!e};function uP(e,t){let{name:n,config:r}=bN(e,t);return r?.mode===`timestamp`||r?.mode===`timestamp_ms`?new oP(n,r.mode):r?.mode===`boolean`?new cP(n,r.mode):new iP(n)}var dP=class extends UN{static[W]=`SQLiteNumericBuilder`;constructor(e){super(e,`string numeric`,`SQLiteNumeric`)}build(e){return new fP(e,this.config)}},fP=class extends WN{static[W]=`SQLiteNumeric`;mapFromDriverValue=e=>typeof e==`string`?e:String(e);getSQLType(){return`numeric`}},pP=class extends UN{static[W]=`SQLiteNumericNumberBuilder`;constructor(e){super(e,`number`,`SQLiteNumericNumber`)}build(e){return new mP(e,this.config)}},mP=class extends WN{static[W]=`SQLiteNumericNumber`;mapFromDriverValue=e=>typeof e==`number`?e:Number(e);mapToDriverValue=String;getSQLType(){return`numeric`}},hP=class extends UN{static[W]=`SQLiteNumericBigIntBuilder`;constructor(e){super(e,`bigint int64`,`SQLiteNumericBigInt`)}build(e){return new gP(e,this.config)}},gP=class extends WN{static[W]=`SQLiteNumericBigInt`;mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return`numeric`}};function _P(e,t){let{name:n,config:r}=bN(e,t),i=r?.mode;return i===`number`?new pP(n):i===`bigint`?new hP(n):new dP(n)}var vP=class extends UN{static[W]=`SQLiteRealBuilder`;constructor(e){super(e,`number double`,`SQLiteReal`)}build(e){return new yP(e,this.config)}},yP=class extends WN{static[W]=`SQLiteReal`;getSQLType(){return`real`}};function bP(e){return new vP(e??``)}var xP=class extends UN{static[W]=`SQLiteTextBuilder`;constructor(e,t){super(e,t.enum?.length?`string enum`:`string`,`SQLiteText`),this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new SP(e,this.config)}},SP=class extends WN{static[W]=`SQLiteText`;enumValues=this.config.enumValues;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:``}`}},CP=class extends UN{static[W]=`SQLiteTextJsonBuilder`;constructor(e){super(e,`object json`,`SQLiteTextJson`)}build(e){return new wP(e,this.config)}},wP=class extends WN{static[W]=`SQLiteTextJson`;getSQLType(){return`text`}mapFromDriverValue=e=>JSON.parse(e);mapToDriverValue=e=>JSON.stringify(e)};function X(e,t={}){let{name:n,config:r}=bN(e,t);return r.mode===`json`?new CP(n):new xP(n,r)}function TP(){return{blob:QN,customType:tP,integer:uP,numeric:_P,real:bP,text:X}}function EP(e){return(e.replace(/['\u2019]/g,``).match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join(`_`)}function DP(e){return(e.replace(/['\u2019]/g,``).match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,n)=>e+(n===0?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`),``)}function OP(e){return e===`snake_case`?EP:e===`camelCase`?DP:e=>e}var kP=Symbol.for(`drizzle:SQLiteInlineForeignKeys`),AP=class extends K{static[W]=`SQLiteTable`;static Symbol=Object.assign({},K.Symbol,{InlineForeignKeys:kP});[K.Symbol.Columns];[kP]=[];[K.Symbol.ExtraConfigBuilder]=void 0};function jP(e,t,n,r,i,a=e){let o=OP(i),s=new AP(e,r,a),c=typeof t==`function`?t(TP()):t,l=Object.fromEntries(Object.entries(c).map(([e,t])=>{let n=t;n.setName(e,o);let r=n.build(s).postBuild();return s[kP].push(...n.buildForeignKeys(r,s)),[e,r]})),u=Object.assign(s,l);return u[K.Symbol.Columns]=l,u[K.Symbol.ExtraConfigColumns]=l,n&&(u[AP.Symbol.ExtraConfigBuilder]=n),u}function MP(e){return(t,n,r)=>jP(t,n,r,void 0,e)}var NP=class{static[W]=`SQLiteCheckBuilder`;brand;constructor(e,t){this.name=e,this.value=t}build(e){return new PP(e,this)}},PP=class{static[W]=`SQLiteCheck`;name;value;constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}};function FP(e,t){return new NP(e,t)}var IP=class{static[W]=`SQLiteIndexBuilderOn`;constructor(e,t){this.name=e,this.unique=t}on(...e){return new LP(this.name,e,this.unique)}},LP=class{static[W]=`SQLiteIndexBuilder`;config;constructor(e,t,n){this.config={name:e,columns:t,unique:n,where:void 0}}where(e){return this.config.where=e,this}build(e){return new RP(this.config,e)}},RP=class{static[W]=`SQLiteIndex`;config;isNameExplicit;constructor(e,t){this.config={...e,table:t},this.isNameExplicit=!!e.name}};function zP(e){return new IP(e,!1)}function BP(e){return new IP(e,!0)}function VP(...e){return e[0].columns?new HP(e[0].columns,e[0].name):new HP(e)}var HP=class{static[W]=`SQLitePrimaryKeyBuilder`;columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new UP(e,this.columns,this.name)}},UP=class{static[W]=`SQLitePrimaryKey`;columns;name;isNameExplicit;constructor(e,t,n){this.table=e,this.columns=t,this.name=n,this.isNameExplicit=!!n}getName(){return this.name??`${this.table[AP.Symbol.Name]}_${this.columns.map(e=>e.name).join(`_`)}_pk`}};function WP(e){return G(e,AP)?[`${e[K.Symbol.BaseName]}`]:G(e,mM)?e._.usedTables??[]:G(e,q)?e.usedTables??[]:[]}var GP=class extends AM{static[W]=`SQLiteViewBase`},KP=class e{static[W]=`SelectionProxyHandler`;config;constructor(e){this.config={...e}}get(t,n){if(n===`_`)return{...t._,selectedFields:new Proxy(t._.selectedFields,this)};if(n===_M)return{...t[_M],selectedFields:new Proxy(t[_M].selectedFields,this)};if(typeof n==`symbol`)return t[n];let r=(G(t,mM)?t._.selectedFields:G(t,AM)?t[_M].selectedFields:t)[n];if(G(r,q.Aliased)){if(this.config.sqlAliasedBehavior===`sql`&&!r.isSelectionField)return r.sql;let e=r.clone();return e.isSelectionField=!0,e.origin=this.config.alias,e}if(G(r,q)){if(this.config.sqlBehavior===`sql`)return r;throw Error(`You tried to reference "${n}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return G(r,rM)?this.config.alias?new Proxy(r,new iN(new Proxy(r.table,new oN(this.config.alias,this.config.replaceOriginalName??!1,!0)),!0)):r:typeof r!=`object`||!r?r:new Proxy(r,new e(this.config))}},qP=class{static[W]=`TypedQueryBuilder`;getSelectedFields(){return this._.selectedFields}withoutSelectionCastCodecs(){return this}},JP=class{static[W]=`SQLiteSelectBuilder`;fields;session;dialect;withList;distinct;constructor(e,t=YP){this.builder=t,this.fields=e.fields,this.session=e.session,this.dialect=e.dialect,this.withList=e.withList,this.distinct=e.distinct}from(e){let t=!!this.fields,n;return n=this.fields?this.fields:G(e,mM)?Object.fromEntries(Object.keys(e._.selectedFields).map(t=>[t,e[t]])):G(e,GP)?e[_M].selectedFields:G(e,q)?{}:vN(e),new this.builder({table:e,fields:n,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList??[],distinct:this.distinct})}},YP=class extends qP{static[W]=`SQLiteSelectQueryBuilder`;_;config;joinsNotNullableMap;tableName;isPartialSelect;session;dialect;cacheConfig=void 0;usedTables=new Set;constructor({table:e,fields:t,isPartialSelect:n,session:r,dialect:i,withList:a,distinct:o}){super(),this.config={withList:a,table:e,fields:{...t},distinct:o,setOperators:[]},this.isPartialSelect=n,this.session=r,this.dialect=i,this._={selectedFields:t,config:this.config},this.tableName=yN(e),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{};for(let t of WP(e))this.usedTables.add(t)}getUsedTables(){return[...this.usedTables]}createJoin(e){return(t,n)=>{let r=this.tableName,i=yN(t);for(let e of WP(t))this.usedTables.add(e);if(typeof i==`string`&&this.config.joins?.some(e=>e.alias===i))throw Error(`Alias "${i}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof r==`string`&&(this.config.fields={[r]:this.config.fields}),typeof i==`string`&&!G(t,q))){let e=G(t,mM)?t._.selectedFields:G(t,AM)?t[_M].selectedFields:t[K.Symbol.Columns];this.config.fields[i]=e}if(typeof n==`function`&&(n=n(new Proxy(this.config.fields,new KP({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:n,table:t,joinType:e,alias:i}),typeof i==`string`)switch(e){case`left`:this.joinsNotNullableMap[i]=!1;break;case`right`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[i]=!0;break;case`cross`:case`inner`:this.joinsNotNullableMap[i]=!0;break;case`full`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[i]=!1;break}return this}}leftJoin=this.createJoin(`left`);rightJoin=this.createJoin(`right`);innerJoin=this.createJoin(`inner`);fullJoin=this.createJoin(`full`);crossJoin=this.createJoin(`cross`);createSetOperator(e,t){return n=>{let r=typeof n==`function`?n(ZP()):n;if(!_N(this.getSelectedFields(),r.getSelectedFields()))throw Error(`Set operator error (union / intersect / except): selected fields are not the same or are in a different order`);return this.config.setOperators.push({type:e,isAll:t,rightSelect:r}),this}}union=this.createSetOperator(`union`,!1);unionAll=this.createSetOperator(`union`,!0);intersect=this.createSetOperator(`intersect`,!1);except=this.createSetOperator(`except`,!1);addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return typeof e==`function`&&(e=e(new Proxy(this.config.fields,new KP({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.where=e,this}having(e){return typeof e==`function`&&(e=e(new Proxy(this.config.fields,new KP({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.having=e,this}groupBy(...e){if(typeof e[0]==`function`){let t=e[0](new Proxy(this.config.fields,new KP({sqlAliasedBehavior:`alias`,sqlBehavior:`sql`})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]==`function`){let t=e[0](new Proxy(this.config.fields,new KP({sqlAliasedBehavior:`alias`,sqlBehavior:`sql`}))),n=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=n:this.config.orderBy=n}else{let t=e;this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=t:this.config.orderBy=t}return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}$withCache(e){return this.cacheConfig=e===void 0?{config:{},enabled:!0,autoInvalidate:!0}:e===!1?{enabled:!1}:{enabled:!0,autoInvalidate:!0,...e},this}getSQL(){return this.config.fieldsFlat=hN(this.config.fields),this.dialect.buildSelectQuery(this.config)}toSQL(){return this.dialect.sqlToQuery(this.getSQL())}as(e){let t=[];if(t.push(...WP(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...WP(e.table));return new Proxy(new mM(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new KP({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`}))}getSelectedFields(){return new Proxy(this.config.fields,new KP({alias:this.tableName,sqlAliasedBehavior:`alias`,sqlBehavior:`error`}))}withoutSelectionCastCodecs(){return this}$dynamic(){return this}};function XP(e,t){return(n,r,...i)=>{let a=[r,...i].map(n=>({type:e,isAll:t,rightSelect:n}));for(let e of a)if(!_N(n.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error(`Set operator error (union / intersect / except): selected fields are not the same or are in a different order`);return n.addSetOperators(a)}}var ZP=()=>({union:QP,unionAll:$P,intersect:eF,except:tF}),QP=XP(`union`,!1),$P=XP(`union`,!0),eF=XP(`intersect`,!1),tF=XP(`except`,!1),nF=class{static[W]=`SQLiteDialect`;mapperGenerators;constructor(e){this.mapperGenerators=e?.useJitMappers?{rows:pN,relationalRows:AN}:{rows:mN,relationalRows:ON}}escapeName(e){return`"${e.replace(/"/g,`""`)}"`}escapeParam(e){return`?`}escapeString(e){return`'${e.replace(/'/g,`''`)}'`}buildWithCTE(e){if(!e?.length)return;let t=[J`with `];for(let[n,r]of e.entries())t.push(J`${J.identifier(r._.alias)} as (${r._.sql})`),n<e.length-1&&t.push(J`, `);return t.push(J` `),J.join(t)}buildDeleteQuery({table:e,where:t,returning:n,withList:r,limit:i,orderBy:a}){let o=this.buildWithCTE(r),s=n?J` returning ${this.buildSelection(n,{isSingleTable:!0})}`:void 0;return J`${o}delete from ${e}${t?J` where ${t}`:void 0}${s}${this.buildOrderBy(a)}${this.buildLimit(i)}`}buildUpdateSet(e,t){let n=e[K.Symbol.Columns],r=Object.keys(n).filter(e=>t[e]!==void 0||n[e]?.onUpdateFn!==void 0),i=r.length;return J.join(r.flatMap((e,r)=>{let a=n[e],o=a.onUpdateFn?.(),s=t[e]??(G(o,q)?o:J.param(o,a)),c=J`${J.identifier(a.name)} = ${s}`;return r<i-1?[c,J.raw(`, `)]:[c]}))}buildUpdateQuery({table:e,set:t,where:n,returning:r,withList:i,joins:a,from:o,limit:s,orderBy:c}){let l=this.buildWithCTE(i),u=this.buildUpdateSet(e,t),d=o&&J.join([J.raw(` from `),this.buildFromTable(o)]),f=this.buildJoins(a),p=r?J` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0;return J`${l}update ${e} set ${u}${d}${f}${n?J` where ${n}`:void 0}${p}${this.buildOrderBy(c)}${this.buildLimit(s)}`}buildSelection(e,{isSingleTable:t=!1}={}){let n=e.length,r=e.flatMap(({field:e},r)=>{let i=[];if(G(e,q.Aliased)){if(e.isSelectionField)!t&&e.origin!==void 0&&i.push(J.identifier(e.origin),J.raw(`.`)),i.push(J.identifier(e.fieldAlias));else{let n=e.sql;if(t){let e=new q(n.queryChunks.map(e=>G(e,rM)?J.identifier(e.name):e));i.push(n.shouldInlineParams?e.inlineParams():e)}else i.push(n);i.push(J` as ${J.identifier(e.fieldAlias)}`)}}else if(G(e,q)){let n=e;if(t){let e=new q(n.queryChunks.map(e=>G(e,rM)?J.identifier(e.name):e));i.push(n.shouldInlineParams?e.inlineParams():e)}else i.push(n)}else G(e,rM)?e.columnType===`SQLiteNumericBigInt`||e.columnType===`SQLiteNumeric`?t?i.push(e.isAlias?J`cast(${J.identifier(uN(e).name)} as text) as ${e}`:J`cast(${J.identifier(e.name)} as text)`):i.push(e.isAlias?J`cast(${uN(e)} as text) as ${e}`:J`cast(${e} as text)`):t?i.push(e.isAlias?J`${J.identifier(uN(e).name)} as ${e}`:J.identifier(e.name)):i.push(e.isAlias?J`${uN(e)} as ${e}`:e):G(e,mM)&&(e._.isWith?i.push(e):i.push(J`(${e._.sql}) ${J.identifier(e._.alias)}`));return r<n-1&&i.push(J`, `),i});return J.join(r)}buildJoins(e){if(!e||e.length===0)return;let t=[];if(e)for(let[n,r]of e.entries()){n===0&&t.push(J` `);let i=r.table,a=r.on?J` on ${r.on}`:void 0;if(G(i,AP)){let e=i[AP.Symbol.Name],n=i[AP.Symbol.Schema],o=i[AP.Symbol.OriginalName],s=e===o?void 0:r.alias;t.push(J`${J.raw(r.joinType)} join ${n?J`${J.identifier(n)}.`:void 0}${J.identifier(o)}${s&&J` ${J.identifier(s)}`}${a}`)}else t.push(J`${J.raw(r.joinType)} join ${i}${a}`);n<e.length-1&&t.push(J` `)}return J.join(t)}buildLimit(e){return typeof e==`object`||typeof e==`number`&&e>=0?J` limit ${e}`:void 0}buildOrderBy(e){let t=[];if(e)for(let[n,r]of e.entries())t.push(r),n<e.length-1&&t.push(J`, `);return t.length>0?J` order by ${J.join(t)}`:void 0}buildFromTable(e){if(G(e,K)&&e[K.Symbol.IsAlias])return J`${J`${J.identifier(e[K.Symbol.Schema]??``)}.`.if(e[K.Symbol.Schema])}${J.identifier(e[K.Symbol.OriginalName])} ${J.identifier(e[K.Symbol.Name])}`;if(G(e,AM)&&e[_M].isAlias){let t=J`${J.identifier(e[_M].originalName)}`;return e[_M].schema&&(t=J`${J.identifier(e[_M].schema)}.${t}`),J`${t} ${J.identifier(e[_M].name)}`}return e}buildSelectQuery({withList:e,fields:t,fieldsFlat:n,where:r,having:i,table:a,joins:o,orderBy:s,groupBy:c,limit:l,offset:u,distinct:d,setOperators:f}){let p=n??hN(t);for(let e of p)if(G(e.field,rM)&&pM(e.field.table)!==(G(a,mM)?a._.alias:G(a,GP)?a[_M].name:G(a,q)?void 0:pM(a))&&!(e=>o?.some(({alias:t})=>t===(e[K.Symbol.IsAlias]?pM(e):e[K.Symbol.BaseName])))(e.field.table)){let t=pM(e.field.table);throw Error(`Your "${e.path.join(`->`)}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}let m=!o||o.length===0,h=this.buildWithCTE(e),g=d?J` distinct`:void 0,_=this.buildSelection(p,{isSingleTable:m}),v=this.buildFromTable(a),y=this.buildJoins(o),b=r?J` where ${r}`:void 0,x=i?J` having ${i}`:void 0,ee=[];if(c)for(let[e,t]of c.entries())ee.push(t),e<c.length-1&&ee.push(J`, `);let te=J`${h}select${g} ${_} from ${v}${y}${b}${ee.length>0?J` group by ${J.join(ee)}`:void 0}${x}${this.buildOrderBy(s)}${this.buildLimit(l)}${u?J` offset ${u}`:void 0}`;return f.length>0?this.buildSetOperations(te,f):te}buildSetOperations(e,t){let[n,...r]=t;if(!n)throw Error(`Cannot pass undefined values to any set operator`);return r.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:n}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:n}),r)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:n,rightSelect:r,limit:i,orderBy:a,offset:o}}){let s=J`${e.getSQL()} `,c=J`${r.getSQL()}`,l;if(a&&a.length>0){let e=[];for(let t of a)if(G(t,WN))e.push(J.identifier(t.name));else if(G(t,q)){for(let e=0;e<t.queryChunks.length;e++){let n=t.queryChunks[e];G(n,WN)&&(t.queryChunks[e]=J.identifier(n.name))}e.push(J`${t}`)}else e.push(J`${t}`);l=J` order by ${J.join(e,J`, `)}`}let u=typeof i==`object`||typeof i==`number`&&i>=0?J` limit ${i}`:void 0,d=J.raw(`${t} ${n?`all `:``}`),f=o?J` offset ${o}`:void 0;return J`${s}${d}${c}${l}${u}${f}`}buildInsertQuery({table:e,values:t,onConflict:n,returning:r,withList:i,select:a}){let o=[],s=e[K.Symbol.Columns],c=Object.entries(s),l=a&&!G(t,q)?Object.keys(t.getSelectedFields()).map(e=>[e,s[e]]):c.filter(([e,t])=>!t.shouldDisableInsert()),u=l.map(([,e])=>J.identifier(e.name));if(a){let e=t;G(e,q)?o.push(e):o.push(e.getSQL())}else{let e=t;o.push(J.raw(`values `));for(let[t,n]of e.entries()){let r=[];for(let[e,t]of l){let i=n[e];if(i===void 0||G(i,EM)&&i.value===void 0){let e;if(t.default!==null&&t.default!==void 0)e=G(t.default,q)?t.default:J.param(t.default,t);else if(t.defaultFn!==void 0){let n=t.defaultFn();e=G(n,q)?n:J.param(n,t)}else if(!t.default&&t.onUpdateFn!==void 0){let n=t.onUpdateFn();e=G(n,q)?n:J.param(n,t)}else e=J`null`;r.push(e)}else r.push(i)}o.push(r),t<e.length-1&&o.push(J`, `)}}let d=this.buildWithCTE(i),f=J.join(o),p=r?J` returning ${this.buildSelection(r,{isSingleTable:!0})}`:void 0;return J`${d}insert into ${e} ${u} ${f}${n?.length?J.join(n):void 0}${p}`}sqlToQuery(e,t){return e.toQuery({escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}nestedSelectionerror(){throw new jM({message:`Views with nested selections are not supported by the relational query builder`})}buildRqbColumn(e,t,n,r){if(G(t,rM)){let i=J`${e}.${J.identifier(t.name)}`;switch(t.columnType){case`SQLiteBigInt`:case`SQLiteBlobJson`:case`SQLiteBlobBuffer`:return r?J`hex(${i}) as ${J.identifier(n)}`:J`${i} as ${J.identifier(n)}`;case`SQLiteNumeric`:case`SQLiteNumericNumber`:case`SQLiteNumericBigInt`:return J`cast(${i} as text) as ${J.identifier(n)}`;case`SQLiteCustomColumn`:return r?J`${t.jsonSelectIdentifier(i,J)} as ${J.identifier(n)}`:J`${i} as ${J.identifier(n)}`;default:return J`${i} as ${J.identifier(n)}`}}return J`${e}.${G(t,q.Aliased)?J.identifier(t.fieldAlias):vM(t)?J.identifier(n):this.nestedSelectionerror()} as ${J.identifier(n)}`}unwrapAllColumns=(e,t,n)=>J.join(Object.entries(e[oM]).map(([r,i])=>(t.push({key:r,field:i}),this.buildRqbColumn(e,i,r,n))),J`, `);getSelectedTableColumns=(e,t)=>{let n=[],r=e[oM],i=Object.entries(t),a;for(let[e,t]of i)if(t!==void 0&&(a||=t,t)){let t=r[e];n.push({column:t,tsName:e})}if(a===!1)for(let[e,i]of Object.entries(r))t[e]!==!1&&n.push({column:i,tsName:e});return n};buildColumns=(e,t,n,r)=>r?.columns?(()=>{let i=[],a=this.getSelectedTableColumns(e,r?.columns);for(let{column:r,tsName:o}of a)i.push(this.buildRqbColumn(e,r,o,n)),t.push({key:o,field:r});return i.length?J.join(i,J`, `):void 0})():this.unwrapAllColumns(e,t,n);buildRelationalQuery({schema:e,table:t,tableConfig:n,queryConfig:r,relationWhere:i,mode:a,isNested:o,errorPath:s,depth:c,throughJoin:l,jsonb:u}){let d=[],f=a===`first`,p=r===!0?void 0:r,m=s??``,h=c??0;h||(t=cN(t,`d${h}`));let g=f?1:p?.limit,_=p?.offset,v=this.buildColumns(t,d,!!o,p),y=p?.where&&i?PM(NN(t,p.where,n.relations,e),i):p?.where?NN(t,p.where,n.relations,e):i,b=p?.orderBy?PN(t,p.orderBy):void 0,x=p?.extras?FN(t,p.extras):void 0;x&&d.push(...x.selection);let ee=p?(()=>{let{with:r}=p;if(!r)return;let i=Object.entries(r).filter(([e,t])=>t);if(i.length)return J.join(i.map(([r,i])=>{let a=n.relations[r],s=G(a,CN),c=cN(a.targetTable,`d${h+1}`),l=a.throughTable?cN(a.throughTable,`tr${h}`):void 0,{filter:f,joinCondition:p}=IN(a,t,c,l),g=l?J` inner join ${LN(l)} on ${p}`:void 0,_=this.buildRelationalQuery({table:c,mode:s?`first`:`many`,schema:e,queryConfig:i,tableConfig:e[a.targetTableName],relationWhere:f,isNested:!0,errorPath:`${m.length?`${m}.`:``}${r}`,depth:h+1,throughJoin:g,jsonb:u});d.push({field:c,key:r,selection:_.selection,isArray:!s,isOptional:(a.optional??!1)||i!==!0&&!!i.where});let v=J.join(_.selection.map(e=>J`${J.raw(this.escapeString(e.key))}, ${e.selection?J`${u}(${J.identifier(e.key)})`:J.identifier(e.key)}`),J`, `),y=o?u:J`json`;return s?J`(select ${y}_object(${v}) as ${J.identifier(`r`)} from (${_.sql}) as ${J.identifier(`t`)}) as ${J.identifier(r)}`:J`coalesce((select ${y}_group_array(json_object(${v})) as ${J.identifier(`r`)} from (${_.sql}) as ${J.identifier(`t`)}), ${u}_array()) as ${J.identifier(r)}`}),J`, `)})():void 0,te=[v,x?.sql,ee].filter(e=>e!==void 0);if(!te.length)throw new jM({message:`No fields selected for table "${n.name}"${m?` ("${m}")`:``}`});return{sql:J`select ${J.join(te,J`, `)} from ${LN(t)}${l}${J` where ${y}`.if(y)}${J` order by ${b}`.if(b)}${J` limit ${g}`.if(g!==void 0)}${J` offset ${_}`.if(_!==void 0)}`,selection:d}}},rF=class{static[W]=`SQLiteQueryBuilder`;dialect;dialectConfig;constructor(e){this.dialect=G(e,nF)?e:void 0,this.dialectConfig=G(e,nF)?void 0:e}$with=(e,t)=>{let n=this;return{as:r=>(typeof r==`function`&&(r=r(n)),new Proxy(new hM(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new KP({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})))}};with(...e){let t=this;function n(n){return new JP({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function r(n){return new JP({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e,distinct:!0})}return{select:n,selectDistinct:r}}select(e){return new JP({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new JP({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}getDialect(){return this.dialect||=new nF(this.dialectConfig),this.dialect}},iF=class{static[W]=`SQLiteViewBuilderCore`;constructor(e){this.name=e}config={}},aF=class extends iF{static[W]=`SQLiteViewBuilder`;as(e){typeof e==`function`&&(e=e(new rF));let t=new KP({alias:this.name,sqlBehavior:`error`,sqlAliasedBehavior:`alias`,replaceOriginalName:!0}),n=e.getSelectedFields();return new Proxy(new sF({config:{name:this.name,schema:void 0,selectedFields:n,query:e.getSQL().inlineParams()}}),t)}},oF=class extends iF{static[W]=`SQLiteManualViewBuilder`;columns;constructor(e,t,n){super(e),this.columns=vN(jP(e,t,void 0,void 0,n))}existing(){return new Proxy(new sF({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:void 0}}),new KP({alias:this.name,sqlBehavior:`error`,sqlAliasedBehavior:`alias`,replaceOriginalName:!0}))}as(e){return new Proxy(new sF({config:{name:this.name,schema:void 0,selectedFields:this.columns,query:e.inlineParams()}}),new KP({alias:this.name,sqlBehavior:`error`,sqlAliasedBehavior:`alias`,replaceOriginalName:!0}))}},sF=class extends GP{static[W]=`SQLiteView`;constructor({config:e}){super(e)}};function cF(e){return((t,n)=>n?new oF(t,n,e):new aF(t))}var lF={table:MP(`snake_case`),view:cF(`snake_case`)};function uF(e,t){return new Proxy(e,new oN(t,!1))}var dF=class extends H(`@usine/engine/Submission`)({event:Xw,itemKey:CE,loop:Zw,step:BT,approval:$w,cycleLimit:YS(TE).pipe(kS(k(E(DE))),ES(k(E(DE)))),cycleGeneration:EE.pipe(OS(k(EE.make(0))),ES(k(EE.make(0)))),repository:Uw,revision:Ww,task:bE,agent:KT,parentModel:YS(PT)}){},fF=class extends U(`@usine/engine/Claimed`)(`Claimed`,{eventId:Jw,runId:jT}){},pF=class extends U(`@usine/engine/Queued`)(`Queued`,{eventId:Jw}){},mF=[`superseded`,`revoked`],hF=SS(mF),gF=class extends U(`@usine/engine/Ignored`)(`Ignored`,{eventId:Jw,reason:hF}){},_F=class extends U(`@usine/engine/CycleBlocked`)(`CycleBlocked`,{eventId:Jw,ask:jE}){},vF=R([fF,pF,gF,_F]),yF=[`Approve`,`Continue`,`Interrupt`,`Resume`],bF=SS(yF),xF=[`Resume`,`Interrupt`,`Continue`,`Approve`],SF=lF.table(`usine_events`,{eventId:X().$type().primaryKey(),dedupKey:X().$type().notNull().unique(),payloadJson:X({mode:`json`}).$type().notNull(),receivedAt:X().notNull()},e=>[FP(`usine_events_payload_json_valid`,J`json_valid(${e.payloadJson})`)]),Z=lF.table(`usine_trigger_events`,{eventId:X().$type().primaryKey().references(()=>SF.eventId),itemKey:X().$type().notNull(),loopName:X().$type().notNull(),stepName:X().$type().notNull(),approval:X({enum:Qw}).$type().notNull(),cycleLimit:uP().$type(),cycleGeneration:uP().notNull().default(0),repository:X().$type().notNull(),revision:X().$type().notNull(),task:X().$type().notNull(),agentJson:X({mode:`json`}).$type().notNull(),parentModel:X().$type()},e=>[FP(`usine_trigger_events_approval`,J`${e.approval} in ('none', 'required')`),FP(`usine_trigger_events_cycle_limit`,J`${e.cycleLimit} is null or ${e.cycleLimit} >= 1`),FP(`usine_trigger_events_agent_json_valid`,J`json_valid(${e.agentJson})`),zP(`usine_trigger_events_item`).on(e.loopName,e.itemKey),zP(`usine_trigger_events_item_history`).on(e.itemKey)]),CF=lF.table(`usine_item_cycle_budgets`,{itemKey:X().$type().primaryKey(),repository:X().$type().notNull(),generation:uP().notNull().default(0),askJson:X({mode:`json`}).$type(),resetPending:uP({mode:`boolean`}).notNull().default(!1)},e=>[FP(`usine_item_cycle_generation`,J`${e.generation} >= 0`),FP(`usine_item_cycle_ask_json`,J`${e.askJson} is null or json_valid(${e.askJson})`)]),wF=lF.table(`usine_cycle_reservations`,{runId:X().$type().primaryKey().references(()=>Q.runId),itemKey:X().$type().notNull().references(()=>CF.itemKey),generation:uP().notNull(),loop:X().$type().notNull()},e=>[zP(`usine_cycle_reservations_item`).on(e.itemKey,e.generation,e.loop),FP(`usine_cycle_reservations_generation`,J`${e.generation} >= 0`)]),TF=lF.table(`usine_cycle_resets`,{askId:X().$type().primaryKey(),eventId:X().$type().notNull().unique().references(()=>SF.eventId),itemKey:X().$type().notNull().references(()=>CF.itemKey)}),Q=lF.table(`usine_runs`,{runId:X().$type().primaryKey(),eventId:X().$type().notNull().unique().references(()=>Z.eventId),loopName:X().$type().notNull(),stateJson:X({mode:`json`}).$type().notNull(),openedAt:X().notNull(),repository:X().$type().notNull(),revision:X().$type().notNull(),task:X().$type().notNull(),agentJson:X({mode:`json`}).$type().notNull(),parentModel:X().$type()},e=>[FP(`usine_runs_state_json_valid`,J`json_valid(${e.stateJson})`),FP(`usine_runs_agent_json_valid`,J`json_valid(${e.agentJson})`)]),EF=lF.table(`usine_steps`,{runId:X().$type().notNull().references(()=>Q.runId),stepName:X().$type().notNull(),result:X({mode:`json`}).$type()},e=>[VP({columns:[e.runId,e.stepName]}),FP(`usine_steps_result_json_valid`,J`${e.result} is null or json_valid(${e.result})`)]),DF=lF.table(`usine_attempts`,{attemptId:X().$type().primaryKey(),runId:X().$type().notNull(),stepName:X().$type().notNull(),workerName:X().$type().notNull(),attemptNumber:uP({mode:`number`}).$type().notNull(),brainJson:X({mode:`json`}).$type().notNull(),parentModel:X().$type(),startedAt:X().notNull(),outcomeJson:X({mode:`json`}).$type()},e=>[FP(`usine_attempts_number`,J`${e.attemptNumber} >= 1`),FP(`usine_attempts_brain_json_valid`,J`json_valid(${e.brainJson})`),FP(`usine_attempts_outcome_json_valid`,J`${e.outcomeJson} is null or json_valid(${e.outcomeJson})`),BP(`usine_attempt_number`).on(e.runId,e.stepName,e.attemptNumber),BP(`usine_one_in_flight_attempt`).on(e.runId).where(J`${e.outcomeJson} is null`),HN({columns:[e.runId,e.stepName],foreignColumns:[EF.runId,EF.stepName]})]),OF=lF.table(`usine_attempt_transcripts`,{sequence:uP({mode:`number`}).primaryKey({autoIncrement:!0}),attemptId:X().$type().notNull().references(()=>DF.attemptId),direction:X({enum:NE}).notNull(),channelSequence:uP({mode:`number`}).$type().notNull(),envelope:X({mode:`json`}).$type().notNull(),receivedAt:X().notNull()},e=>[FP(`usine_attempt_transcripts_direction`,J`${e.direction} in ('inbound', 'outbound')`),FP(`usine_attempt_transcripts_sequence`,J`${e.channelSequence} >= 1`),FP(`usine_attempt_transcripts_envelope_json_valid`,J`json_valid(${e.envelope})`),BP(`usine_attempt_transcript_envelope`).on(e.attemptId,e.direction,e.channelSequence),zP(`usine_attempt_transcript_tail`).on(e.attemptId,e.sequence)]),kF=lF.table(`usine_approvals`,{runId:X().$type().primaryKey().references(()=>Q.runId),eventId:X().$type().notNull().unique().references(()=>SF.eventId)}),AF=lF.table(`usine_ignored_events`,{eventId:X().$type().primaryKey().references(()=>Z.eventId),reason:X({enum:mF}).$type().notNull()},e=>[FP(`usine_ignored_events_reason`,J`${e.reason} in ('superseded', 'revoked')`)]),jF=lF.table(`usine_workflow_commands`,{runId:X().$type().notNull().references(()=>Q.runId),command:X({enum:yF}).$type().notNull()},e=>[FP(`usine_workflow_commands_command`,J`${e.command} in ('Approve', 'Continue', 'Interrupt', 'Resume')`),VP({columns:[e.runId,e.command]})]);lF.table(`usine_cursors`,{cursorKey:X().primaryKey(),valueJson:X({mode:`json`}).$type().notNull()},e=>[FP(`usine_cursors_value_json_valid`,J`json_valid(${e.valueJson})`)]);var MF=lF.table(`usine_item_projections`,{itemKey:X().$type().primaryKey(),repository:X().$type().notNull(),source:X().notNull(),itemNumber:uP({mode:`number`}).notNull(),contentHash:X().notNull(),payloadJson:X({mode:`json`}).$type().notNull()},e=>[FP(`usine_item_projections_number`,J`${e.itemNumber} >= 1`),FP(`usine_item_projections_payload_json_valid`,J`json_valid(${e.payloadJson})`),BP(`usine_item_projection_number`).on(e.repository,e.itemNumber),zP(`usine_item_projection_repository`).on(e.repository,e.itemNumber)]),NF=lF.table(`usine_repository_label_projections`,{repository:X().$type().primaryKey(),labelsJson:X({mode:`json`}).$type().notNull()},e=>[FP(`usine_repository_label_projections_labels_json_valid`,J`json_valid(${e.labelsJson})`)]),PF=lF.table(`usine_loop_runtime`,{loopName:X().$type().primaryKey(),paused:uP({mode:`boolean`}).notNull()}),FF=lF.table(`usine_projection_revision`,{singleton:uP({mode:`number`}).primaryKey().default(1),revision:uP({mode:`number`}).notNull().default(0)},e=>[FP(`usine_projection_revision_singleton`,J`${e.singleton} = 1`)]),IF=class extends FC(`@usine/engine/RunNotFoundError`)(`RunNotFoundError`,{runId:jT}){},LF=class extends FC(`@usine/engine/RunOperationRejectedError`)(`RunOperationRejectedError`,{runId:jT,operation:SS([`approve`,`retry`]),state:F}){},RF=class extends FC(`@usine/engine/EnginePersistenceError`)(`EnginePersistenceError`,{operation:F,cause:dC()}){},zF=class extends FC(`@usine/engine/AttemptCancellationError`)(`AttemptCancellationError`,{attemptId:vE,cause:dC()}){},BF=R([IF,LF,RF]);R([IF,LF,RF,zF]);var VF=F.check(FS(/\S/u,{message:`Expected a non-blank repository label`})),HF=F.check(FS(/^[0-9a-fA-F]{6}$/u,{message:`Expected a six-digit hex label color`})),UF=class extends H(`@usine/engine/RepositoryLabel`)({name:VF,color:XS(HF),description:XS(F)}){},WF=PS(e=>new Set(e.map(({name:e})=>e)).size===e.length,{message:`Expected unique label names`}),GF=L(UF).check(WF),KF=class extends H(`@usine/engine/RepositoryLabelProjection`)({repository:Uw,labels:GF}){},qF=ho(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),JF=class extends O()(`effect/http/FetchHttpClient/RequestInit`){},YF=ik(k(QO((e,t,n,r)=>{let i=r.getRef(qF),a=io(r.context,JF)??{},o=a.headers?ID(MD(a.headers),e.headers):e.headers;o[`content-length`]&&(o=LD(o,`content-length`));let s=r=>ph(Ym({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:e.body._tag===`Stream`?`half`:void 0,signal:n}),catch:t=>new QD({reason:new tO({request:e,cause:t})})}),t=>RO(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return M(_w(e.body.stream),s)}return s(void 0)}))),XF=WS.check(VS(1)).pipe(z(`GitHubAppId`)),ZF=$S(V.check(FS(/^-----BEGIN (?:RSA )?PRIVATE KEY-----[\s\S]+-----END (?:RSA )?PRIVATE KEY-----\s*$/u,{message:`Expected a PEM-encoded RSA private key`})).pipe(z(`GitHubAppPrivateKey`)),{disallowEncode:!0});H(`@usine/github/AppCredentials`)({appId:XF,privateKey:ZF});var QF=class extends O()(`@usine/github/GitHubCredentials`){},$F=class extends FC(`@usine/github/AppAuthenticationError`)(`AppAuthenticationError`,{message:V}){},eI=new TextEncoder,tI=new Uint8Array([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]),nI=(...e)=>{let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t},rI=e=>{if(e<128)return new Uint8Array([e]);let t=[];for(let n=e;n>0;n>>>=8)t.unshift(n&255);return new Uint8Array([128|t.length,...t])},iI=(e,t)=>nI(new Uint8Array([e]),rI(t.length),t),aI=e=>iI(48,nI(new Uint8Array([2,1,0]),tI,iI(4,e))),oI=e=>{let t=e.includes(`-----BEGIN RSA PRIVATE KEY-----`),n=e.replace(/-----BEGIN (?:RSA )?PRIVATE KEY-----/gu,``).replace(/-----END (?:RSA )?PRIVATE KEY-----/gu,``).replace(/\s/gu,``),r=atob(n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return t?aI(i):i},sI=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/=/gu,``).replace(/\+/gu,`-`).replace(/\//gu,`_`)},cI=e=>sI(eI.encode(JSON.stringify(e))),lI=e=>{let t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(e),t},uI=N(`AppJwt.import`)(function*(e){let t=yield*Ym({try:async()=>crypto.subtle.importKey(`pkcs8`,lI(oI(jx(e.privateKey))),{name:`RSASSA-PKCS1-v1_5`,hash:`SHA-256`},!1,[`sign`]),catch:()=>new $F({message:`The GitHub App private key is not an RSA private key WebCrypto can import`})});return N(`AppJwt.sign`)(function*(){let n=Math.floor((yield*Zf)/1e3),r=`${cI({alg:`RS256`,typ:`JWT`})}.${cI({iat:n-60,exp:n+540,iss:e.appId})}`,i=yield*Jm(()=>crypto.subtle.sign(`RSASSA-PKCS1-v1_5`,t,lI(eI.encode(r))));return kx(`${r}.${sI(new Uint8Array(i))}`)})}),dI=WS.check(VS(1)),fI=dI.pipe(z(`GitHubInstallationId`)),pI=dI.pipe(z(`GitHubRepositoryId`)),mI=class extends H(`@usine/github/Installation`)({id:fI,accountLogin:V}){},hI=class extends U(`@usine/github/TokenScope/InstallationWide`)(`InstallationWide`,{}){},gI=class extends U(`@usine/github/TokenScope/SingleRepository`)(`SingleRepository`,{repository:Uw,repositoryId:pI}){},_I=R([hI,gI]),vI=class extends H(`@usine/github/InstallationToken`)({value:QS(V,{disallowJsonEncode:!0}),expiresAt:TC,scope:_I}){},yI=SS([`missing`,`multiple`,`suspended`]),bI=class extends FC(`@usine/github/InstallationDiscoveryError`)(`InstallationDiscoveryError`,{reason:yI,message:V}){},xI={checks:`read`,contents:`write`,issues:`write`,metadata:`read`,pull_requests:`write`},SI=(e,t)=>e===t||t===`read`&&e===`write`,CI=e=>Object.entries(xI).flatMap(([t,n])=>SI(e[t],n)?[]:[`${t}:${n}`]),wI=class extends U(`@usine/github/ProjectAccess/CoveredProject`)(`CoveredProject`,{installationId:fI,repository:Uw,repositoryId:pI}){},TI=class extends FC(`@usine/github/ProjectNotInstalledError`)(`ProjectNotInstalledError`,{repository:Uw,message:V}){};R([wI,TI]);var EI=(e,t,n)=>{let r=new Map(n.map(e=>[e.name.toLowerCase(),e]));return t.map(t=>{let n=r.get(t.toLowerCase());return n===void 0?new TI({repository:t,message:`The GitHub App installation does not cover ${t}`}):new wI({installationId:e.id,repository:t,repositoryId:n.id})})},DI=class extends FC(`@usine/github/AppPermissionError`)(`AppPermissionError`,{missing:L(V).check(KS()),message:V}){},OI=SS([`create-repository-label`,`discover-installation`,`fetch-item-labels`,`fetch-issue-snapshot`,`fetch-pull-request-snapshot`,`list-installation-repositories`,`list-repository-labels`,`mint-installation-token`,`mint-worker-token`,`poll-repository-changes`,`update-item-labels`]),kI=class extends FC(`@usine/github/GitHubApiError`)(`GitHubApiError`,{operation:OI,status:YS(WS),message:V}){},AI=class extends FC(`@usine/github/GitHubRateLimitError`)(`GitHubRateLimitError`,{operation:OI,retryAt:TC,message:V}){},jI=class extends FC(`@usine/github/InvalidGitHubResponseError`)(`InvalidGitHubResponseError`,{operation:OI,message:V,detail:V}){};R([bI,DI,kI,AI,jI]);var MI=`https://api.github.com`,NI=`2026-03-10`,PI=e=>SO({accept:`application/vnd.github+json`,authorization:`Bearer ${jx(e)}`,"user-agent":`usine`,"x-github-api-version":NI}),FI=(e,t)=>new kI({operation:e,status:t.response===void 0?T():E(t.response.status),message:t.response===void 0?`The request to GitHub could not be sent`:`GitHub rejected the request with status ${t.response.status}`}),II=(e,t)=>new jI({operation:e,message:`GitHub returned a response that does not match its API contract`,detail:t}),LI=e=>{if(e===void 0||!/^\d+$/u.test(e))return T();let t=Number(e);return Number.isSafeInteger(t)?E(t):T()},RI=(e,t)=>{let n=LI(e);if(D(n))return E(t+n.value*1e3);if(e===void 0)return T();let r=Date.parse(e);return Number.isFinite(r)?E(r):T()},zI=(e,t)=>{let n=LI(e[`x-ratelimit-remaining`]),r=LI(e[`x-ratelimit-reset`]);return D(n)&&n.value<=t&&D(r)?E(r.value*1e3):T()},BI=(e,t)=>Ti(LI(e[`x-poll-interval`]),e=>t+e*1e3),VI=e=>{let t=e.flatMap(e=>gi(e,{onNone:()=>[],onSome:e=>[e]}));return t.length===0?T():E(Math.max(...t))},HI=(e,t)=>VI([RI(e[`retry-after`],t),zI(e,0)]),UI=(e,t,n)=>{let r=Ei(HI(t.headers,n),r_);return(t.status===403||t.status===429)&&D(r)?new AI({operation:e,retryAt:r.value,message:`GitHub asked the poller to wait before retrying`}):new kI({operation:e,status:E(t.status),message:`GitHub rejected the request with status ${t.status}`})},WI=36e5,GI=3e5,KI=L(I({id:fI,account:I({login:V}),permissions:_S(F,F),suspendedAt:CS(F)}).pipe(gS({suspendedAt:`suspended_at`}))),qI=I({id:pI,name:Uw}).pipe(gS({name:`full_name`})),JI=I({totalCount:WS.check(VS(0)),repositories:L(qI)}).pipe(gS({totalCount:`total_count`})),YI=I({token:V,expiresAt:EC,repositories:ZS(L(qI))}).pipe(gS({expiresAt:`expires_at`})),XI=e=>e._tag===`InstallationWide`?{operation:`mint-installation-token`,body:{permissions:xI}}:{operation:`mint-worker-token`,body:{permissions:xI,repository_ids:[e.repositoryId]}},ZI=class e extends O()(`@usine/github/GitHubApp`){static layer=Hf(e,A(function*(){let e=yield*uI(yield*QF),t=yield*JO,n=(e,n,r)=>A(function*(){let i=yield*t.execute(n).pipe(bh(t=>FI(e,t)));return i.status<200||i.status>=300?yield*UI(e,i,yield*Zf):yield*FO(r)(i).pipe(bh(t=>II(e,t.message)))}),r=N(`GitHubApp.discoverInstallation`)(function*(){let t=yield*e(),[r,...i]=yield*n(`discover-installation`,_O(`${MI}/app/installations?per_page=2`).pipe(PI(t)),KI);if(r===void 0)return yield*new bI({reason:`missing`,message:`The GitHub App is not installed on an account`});if(i.length>0)return yield*new bI({reason:`multiple`,message:`The GitHub App must have exactly one installation for this factory`});if(r.suspendedAt!==null)return yield*new bI({reason:`suspended`,message:`The GitHub App installation is suspended`});let a=CI(r.permissions);return a.length>0?yield*new DI({missing:a,message:`The GitHub App installation is missing permissions: ${a.join(`, `)}`}):new mI({id:r.id,accountLogin:r.account.login})}),i=N(`GitHubApp.mintToken`)(function*(t,r){let{operation:i,body:a}=XI(r);yield*Vh({installationId:t,operation:i,scope:r._tag});let o=yield*e(),s=yield*n(i,vO(`${MI}/app/installations/${t}/access_tokens`).pipe(MO(a),PI(o)),YI),c=yield*Zf,l=l_(s.expiresAt)-c;if(l<=0||l>378e4)return yield*new jI({operation:i,message:`GitHub returned an installation token outside the one-hour lifetime bound`,detail:`expires_at ${u_(s.expiresAt)} leaves ${l}ms to live`});l>WI&&(yield*Qh(`Accepted GitHub token clock skew; capped the local lease`,{installationId:t,operation:i,skewMillis:l-WI}));let u=_i(s.repositories,()=>[]);return r._tag===`SingleRepository`&&!(u.length===1&&u.every(e=>e.id===r.repositoryId))?yield*new jI({operation:i,message:`GitHub did not confirm that the worker token is scoped to exactly one repo`,detail:`expected repository id ${r.repositoryId}, confirmed [${u.map(e=>e.id).join(`, `)}]`}):new vI({value:kx(s.token),expiresAt:n_(c+Math.min(l,WI)),scope:r})}),a=N(`GitHubApp.installedRepositories`)(function*(e){let t=[];for(let r=1;;r+=1){let i=yield*n(`list-installation-repositories`,_O(`${MI}/installation/repositories?per_page=100&page=${r}`).pipe(PI(e.value)),JI);if(t.push(...i.repositories),t.length>=i.totalCount)return t;if(i.repositories.length===0)return yield*new jI({operation:`list-installation-repositories`,message:`GitHub pagination ended before total_count repositories were returned`,detail:`page ${r} was empty after ${t.length} of ${i.totalCount} repositories`})}}),o=yield*Bw(T()),s=N(`GitHubApp.lease`)(()=>Hw(o,e=>A(function*(){let t=yield*Zf;if(D(e)&&l_(e.value.token.expiresAt)-t>GI)return[e.value,e];let n=yield*r(),a={installation:n,token:yield*i(n.id,new hI)};return[a,E(a)]})));return{installation:N(`GitHubApp.installation`)(()=>ph(s(),e=>e.installation)),installationToken:N(`GitHubApp.installationToken`)(()=>ph(s(),e=>e.token)),projectAccess:N(`GitHubApp.projectAccess`)(function*(e){let{installation:t,token:n}=yield*s();return EI(t,e,yield*a(n))}),workerToken:N(`GitHubApp.workerToken`)(e=>i(e.installationId,new gI({repository:e.repository,repositoryId:e.repositoryId})))}}))},QI=V.pipe(z(`GitHubEntityTag`)),$I=class e extends H(`@usine/github/PollCursor`)({entityTag:XS(QI),watermark:XS(EC)}){static empty=new e({entityTag:T(),watermark:T()})},eL=class extends U(`@usine/github/ChangedIssue`)(`ChangedIssue`,{number:WS.check(VS(1)),updatedAt:TC}){},tL=class extends U(`@usine/github/ChangedPullRequest`)(`ChangedPullRequest`,{number:WS.check(VS(1)),updatedAt:TC}){},nL=R([eL,tL]),rL=class extends U(`@usine/github/RepositoryNotModified`)(`RepositoryNotModified`,{cursor:$I,nextPollAt:YS(TC),backoffUntil:YS(TC).pipe(ES(k(T())))}){},iL=class extends U(`@usine/github/RepositoryChanges`)(`RepositoryChanges`,{cursor:$I,items:L(nL),backlog:dS,nextPollAt:YS(TC),backoffUntil:YS(TC).pipe(ES(k(T())))}){};R([rL,iL]);var aL=V.pipe(z(`GitHubRepositoryLabelName`)),oL=F.check(FS(/^[0-9a-fA-F]{6}$/u,{message:`Expected a six-digit hex label color`})).pipe(z(`GitHubRepositoryLabelColor`)),sL=class extends H(`@usine/github/RepositoryLabel`)({name:aL,color:oL,description:XS(F)}){},cL=PS(e=>new Set(e.map(({name:e})=>e)).size===e.length,{message:`Expected unique label names`}),lL=class extends H(`@usine/github/RepositoryLabelCatalog`)({entityTag:XS(QI),labels:L(sL).check(cL)}){},uL=class extends U(`@usine/github/RepositoryLabelsNotModified`)(`RepositoryLabelsNotModified`,{}){};R([lL,uL]);var dL=class extends H(`@usine/github/NewRepositoryLabel`)({name:aL,color:YS(oL),description:YS(F)}){},fL=I({name:aL,color:oL,description:CS(F)}),pL=e=>{let{name:t,owner:n}=Kw(e);return`${MI}/repos/${encodeURIComponent(n)}/${encodeURIComponent(t)}/labels`},mL=class e extends O()(`@usine/github/GitHubLabelWriter`){static layer=Hf(e,A(function*(){let e=yield*ZI,t=yield*JO;return{create:N(`GitHubLabelWriter.create`)(function*(n,r){yield*Vh({repository:n,label:r.name});let i=yield*e.installationToken(),a={name:r.name};D(r.color)&&(a.color=r.color.value),D(r.description)&&(a.description=r.description.value);let o=vO(pL(n)).pipe(MO(a),PI(i.value)),s=yield*t.execute(o).pipe(bh(e=>FI(`create-repository-label`,e)));if(s.status<200||s.status>=300)return yield*UI(`create-repository-label`,s,yield*Zf);let c=yield*FO(fL)(s).pipe(bh(e=>II(`create-repository-label`,e.message)));return new sL({name:c.name,color:c.color,description:yi(c.description)})})}}))},hL=class extends H(`@usine/orchestrator/LabelPreflightFinding`)({repository:Uw,label:Cj,errorTag:V,message:V}){},gL=(e,t)=>{let n=[];if(D(e.color)){let r=e.color.value.toLowerCase();gi(t.color,{onNone:()=>!0,onSome:e=>e.toLowerCase()!==r})&&n.push(`color`)}if(D(e.description)){let r=e.description.value;gi(t.description,{onNone:()=>!0,onSome:e=>e!==r})&&n.push(`description`)}return n},_L=e=>new dL({name:aL.make(e.name),color:Ti(e.color,oL.make),description:e.description}),vL=class e extends O()(`@usine/orchestrator/LabelReconciler`){static layer=Hf(e,A(function*(){let e=yield*mL;return{reconcile:N(`LabelReconciler.reconcile`)(function*(t,n,r){yield*Vh({repository:t});let i=[...r],a=new Map(r.map(e=>[wj(e.name),e])),o=[],s=!1,c=T();for(let r of n){let n=a.get(wj(r.name));if(n!==void 0){let e=gL(r,n);e.length>0?yield*Xh(`Declared GitHub label differs from the existing repository label; left unchanged`,{repository:t,label:r.name,drift:e.join(`, `)}):yield*$h(`Declared GitHub label already exists`,{repository:t,label:r.name});continue}let l=yield*dh(e.create(t,_L(r)));if(Ii(l)){let e=l.failure;if(o.push(new hL({repository:t,label:r.name,errorTag:e._tag,message:e.message})),e._tag===`GitHubRateLimitError`){c=E(e.retryAt),yield*Xh(`Label creation rate-limited; remaining declarations deferred and trigger evaluation continues`,{repository:t,label:r.name,errorTag:e._tag,message:e.message,retryAt:u_(e.retryAt)});break}yield*Zh(`Declared GitHub label could not be created; trigger evaluation continues`,{repository:t,label:r.name,errorTag:e._tag,message:e.message});continue}let u=new UF({name:l.success.name,color:E(l.success.color),description:l.success.description});i.push(u),a.set(wj(u.name),u),s=!0,yield*Qh(`Created declared GitHub label`,{repository:t,label:u.name})}return i.sort((e,t)=>e.name.localeCompare(t.name)),{labels:i,findings:o,catalogChanged:s,nextPollAt:c}})}}))},yL=F.check(FS(/^(?:[A-Za-z_][A-Za-z0-9_.]*|list<[A-Za-z_][A-Za-z0-9_.]*>|map<[A-Za-z_][A-Za-z0-9_.]*,[A-Za-z_][A-Za-z0-9_.]*>)$/u,{message:`Expected a CEL type reference`})).pipe(z(`CelTypeReference`)),bL=F.check(FS(/^[A-Za-z_][A-Za-z0-9_]*$/u,{message:`Expected a CEL identifier`})),xL=F.check(FS(/^[A-Za-z_][A-Za-z0-9_.]*$/u,{message:`Expected a CEL object-type name`})),SL=e=>PS(e=>new Set(e.map(({name:e})=>e)).size===e.length,{message:e}),CL=class extends H(`@usine/expression/ObjectField`)({name:bL,type:yL}){},wL=class extends H(`@usine/expression/ObjectType`)({name:xL,fields:L(CL).check(SL(`Expected unique CEL object-field names`))}){},TL=class extends H(`@usine/expression/Variable`)({name:bL,type:yL}){},EL=class extends H(`@usine/expression/Environment`)({types:L(wL).check(SL(`Expected unique CEL object-type names`)),variables:L(TL).check(SL(`Expected unique CEL variable names`))}){},DL=F.check(FS(/\S/u,{message:`Expected a non-blank CEL expression`})).pipe(z(`ExpressionSource`)),OL=WS.check(VS(0)),kL=SS([`check_failed`,`parse_error`,`type_error`,`unexpected_result_type`]);R([class extends FC(`@usine/expression/ExpressionCheckError`)(`ExpressionCheckError`,{source:DL,code:kL,message:V,position:YS(OL)}){},class extends FC(`@usine/expression/ExpressionEvaluationError`)(`ExpressionEvaluationError`,{source:DL,message:V}){}]),R([F,uS,fS,dS,cS]);var AL=class extends O()(`@usine/expression/ExpressionEngine`){},jL=V.pipe(z(`InstancePath`)),ML=SS([`expression`,`frontmatter`,`read`,`reference`,`schema`,`yaml`]),NL=class extends FC(`@usine/config/ConfigFileError`)(`ConfigFileError`,{file:jL,stage:ML,expression:ZS(DL),message:V}){};R([NL,class extends FC(`@usine/config/FactoryConfigError`)(`FactoryConfigError`,{file:jL,stage:ML,message:V}){}]);var PL=(e,t,n)=>{let r=`${t}---`,i=e.indexOf(r,n);for(;i>=0;){let n=i+r.length;if(n===e.length||e.startsWith(t,n))return i;i=e.indexOf(r,n)}return-1},FL=(e,t)=>{let n=t.startsWith(`---\r
|
|
30
|
+
`)?`\r
|
|
31
|
+
`:t.startsWith(`---
|
|
32
|
+
`)?`
|
|
33
|
+
`:void 0;if(n===void 0)return new NL({file:e,stage:`frontmatter`,expression:T(),message:`Expected the file to start with a YAML frontmatter delimiter (---)`});let r=3+n.length,i=`${n}---`,a=PL(t,n,r);if(a<0)return new NL({file:e,stage:`frontmatter`,expression:T(),message:`Expected a closing YAML frontmatter delimiter (---)`});let o=a+i.length,s=t.startsWith(n,o)?o+n.length:o;return k({yaml:t.slice(r,a),body:t.slice(s),newline:n})},IL=class extends H(`@usine/config/AgentFile`)({name:WT,harness:FT,model:PT,effort:IT,parentModel:YS(PT),parentEffort:YS(IT),persona:GT}){};H(`@usine/config/InvalidAgent`)({file:jL,error:NL});var LL=Oj(`Expected a non-blank registry tag`).pipe(z(`RegistryTag`)),RL=F.check(FS(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u,{message:`Expected a GitHub login`})).pipe(z(`OperatorLogin`)),zL=WS.check(VS(1)),BL=PS(e=>new Set(e.map(({name:e})=>e)).size===e.length,{message:`Expected unique names`}),VL=e=>`label`in e?`label:${e.label}`:`state:${e.state}`,HL=PS(e=>{let t=e.flatMap(({sources:e})=>e.map(VL));return new Set(t).size===t.length},{message:`Expected every lane source to be mapped once`}),UL=L(Mj).check(BL,HL),WL=PS(e=>new Set(e.map(({name:e})=>wj(e))).size===e.length,{message:`Expected unique GitHub label names`}),GL=L(Dj).check(WL),KL=class extends H(`@usine/config/ManagedRepo`)({name:Uw,tags:L(LL).check(JS()).pipe(OS(k([]))),lanes:UL.pipe(OS(k([])))}){},qL=class extends H(`@usine/config/Worker`)({name:HT,kind:UT,maxConcurrentAttempts:zL.pipe(OS(k(1)))}){},JL=class extends H(`@usine/config/Settings`)({pollInterval:zL.pipe(OS(k(60))),maxChildren:XT.pipe(OS(k(4))),maxAttemptMinutes:zL.pipe(OS(k(60))),maxAttemptTokens:zL.pipe(OS(k(1e7))),parentModel:ZS(PT),parentEffort:ZS(IT)}){},YL=R([I({mode:aS(`off`)}),I({mode:aS(`deliveries`)}),I({mode:aS(`endpoint`),publicUrl:_C}).pipe(gS({publicUrl:`public_url`}))]),XL=JL.pipe(gS({pollInterval:`poll_interval`,maxChildren:`max_children`,maxAttemptMinutes:`max_attempt_minutes`,maxAttemptTokens:`max_attempt_tokens`,parentModel:`parent_model`,parentEffort:`parent_effort`})),ZL=qL.pipe(gS({maxConcurrentAttempts:`max_concurrent_attempts`})),QL=L(KL).check(BL),$L=L(ZL).check(KS(),BL),eR=class extends H(`@usine/config/UsineConfig`)({version:aS(1),labels:GL.pipe(OS(k([]))),repos:QL,settings:XL.pipe(OS(k({}))),workers:$L.pipe(OS(k([{name:`local`,kind:`local`}]))),webhooks:YL.pipe(OS(k({mode:`off`}))),operator:ZS(RL)}){},tR=class extends H(`@usine/config/Selector`)({repos:ZS(L(Uw).check(KS(),JS())),tags:ZS(L(LL).check(KS(),JS()))}){}.check(PS(e=>D(e.repos)||D(e.tags),{message:`Expected selector.repos, selector.tags, or both`})),nR=(e,t)=>gi(e,{onNone:()=>!0,onSome:e=>{let n=gi(e.repos,{onNone:()=>!0,onSome:e=>e.includes(t.name)}),r=gi(e.tags,{onNone:()=>!0,onSome:e=>e.some(e=>t.tags.includes(e))});return n&&r}}),rR=F.check(PS(e=>e.trim().split(/\s+/u).length===5&&Li(gm(e)),{message:`Expected a valid five-field cron expression`})).pipe(z(`Cron`)),iR=F.check(PS(e=>D(o_(e)),{message:`Expected an IANA time-zone name`})).pipe(z(`TimeZone`)),aR=R([class extends H(`@usine/config/IssueTrigger`)({on:aS(`issue`),if:DL}){},class extends H(`@usine/config/PullRequestTrigger`)({on:aS(`pr`),if:DL}){},class extends H(`@usine/config/ScheduleTrigger`)({on:aS(`schedule`),if:DL,cron:rR,tz:iR.pipe(OS(k(`UTC`)))}){}]),oR=FS(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,{message:`Expected a kebab-case filename identity`}),sR=Zw.check(oR),cR=Oj(`Expected a non-blank Markdown prompt`).pipe(z(`PromptTemplate`)),lR=class extends H(`@usine/config/LoopFile`)({name:sR,trigger:aR,selector:YS(tR),approval:$w,maxCycles:TE.pipe(OS(k(DE)),ES(k(DE))),step:BT,agent:WT,body:cR}){};H(`@usine/config/QuarantinedLoop`)({file:jL,error:NL});var uR=e=>jL.make(`loops/${e}.md`),dR=class extends U(`@usine/config/UndeclaredLaneLabelWarning`)(`UndeclaredLaneLabelWarning`,{repository:Uw,lane:kj,label:Cj}){},fR=class extends U(`@usine/config/UndeclaredTriggerLabelWarning`)(`UndeclaredTriggerLabelWarning`,{loop:lR.fields.name,label:Cj}){};R([dR,fR]);var pR=Yx(yL),mR=(e,t)=>new wL({name:e,fields:t.map(([e,t])=>new CL({name:e,type:pR(t)}))}),hR=mR(`Actor`,[[`login`,`string`]]),gR=mR(`Label`,[[`name`,`string`]]),_R=mR(`Milestone`,[[`title`,`string`]]),vR=mR(`IssueType`,[[`name`,`string`]]),yR=mR(`Commit`,[[`oid`,`string`]]),bR=mR(`RepoContext`,[[`name`,`string`],[`owner`,`string`],[`url`,`string`]]),xR=mR(`Labels`,[[`totalCount`,`int`],[`nodes`,`list<Label>`]]),SR=mR(`Assignees`,[[`totalCount`,`int`],[`nodes`,`list<Actor>`]]),CR=mR(`IssueComment`,[[`author`,`Actor`],[`body`,`string`],[`createdAt`,`string`]]),wR=mR(`IssueComments`,[[`totalCount`,`int`],[`nodes`,`list<IssueComment>`]]),TR=mR(`PullRequestReference`,[[`number`,`int`],[`state`,`string`],[`isDraft`,`bool`],[`url`,`string`]]),ER=mR(`PullRequestReferences`,[[`totalCount`,`int`],[`nodes`,`list<PullRequestReference>`]]),DR=mR(`IssuePayload`,[[`number`,`int`],[`title`,`string`],[`body`,`string`],[`url`,`string`],[`state`,`string`],[`stateReason`,`string`],[`createdAt`,`string`],[`updatedAt`,`string`],[`closedAt`,`string`],[`author`,`Actor`],[`issueType`,`IssueType`],[`milestone`,`Milestone`],[`labels`,`Labels`],[`assignees`,`Assignees`],[`comments`,`IssueComments`],[`closedByPullRequestsReferences`,`PullRequestReferences`]]),OR=mR(`RequestedReviewer`,[[`login`,`string`]]),kR=mR(`ReviewRequest`,[[`requestedReviewer`,`RequestedReviewer`]]),AR=mR(`ReviewRequests`,[[`totalCount`,`int`],[`nodes`,`list<ReviewRequest>`]]),jR=mR(`Review`,[[`author`,`Actor`],[`state`,`string`],[`body`,`string`],[`submittedAt`,`string`],[`commit`,`Commit`]]),MR=mR(`Reviews`,[[`totalCount`,`int`],[`nodes`,`list<Review>`]]),NR=mR(`ReviewThreadComment`,[[`author`,`Actor`],[`body`,`string`]]),PR=mR(`ReviewThreadComments`,[[`totalCount`,`int`],[`nodes`,`list<ReviewThreadComment>`]]),FR=mR(`ReviewThread`,[[`isResolved`,`bool`],[`isOutdated`,`bool`],[`path`,`string`],[`comments`,`ReviewThreadComments`]]),IR=mR(`ReviewThreads`,[[`totalCount`,`int`],[`nodes`,`list<ReviewThread>`]]),LR=mR(`PullRequestComment`,[[`author`,`Actor`],[`body`,`string`],[`createdAt`,`string`]]),RR=mR(`PullRequestComments`,[[`totalCount`,`int`],[`nodes`,`list<PullRequestComment>`]]),zR=mR(`ClosingIssueReference`,[[`number`,`int`],[`state`,`string`]]),BR=mR(`ClosingIssueReferences`,[[`totalCount`,`int`],[`nodes`,`list<ClosingIssueReference>`]]),VR=mR(`StatusCheckRollup`,[[`state`,`string`]]),HR=mR(`PullRequestPayload`,[[`number`,`int`],[`title`,`string`],[`body`,`string`],[`url`,`string`],[`state`,`string`],[`isDraft`,`bool`],[`merged`,`bool`],[`createdAt`,`string`],[`updatedAt`,`string`],[`mergedAt`,`string`],[`author`,`Actor`],[`baseRefName`,`string`],[`headRefName`,`string`],[`headRefOid`,`string`],[`additions`,`int`],[`deletions`,`int`],[`changedFiles`,`int`],[`reviewDecision`,`string`],[`statusCheckRollup`,`StatusCheckRollup`],[`labels`,`Labels`],[`reviewRequests`,`ReviewRequests`],[`reviews`,`Reviews`],[`reviewThreads`,`ReviewThreads`],[`comments`,`PullRequestComments`],[`closingIssuesReferences`,`ClosingIssueReferences`]]),UR=mR(`Tick`,[[`scheduledAt`,`string`],[`scheduledAtLocal`,`string`],[`cron`,`string`],[`tz`,`string`]]),WR=mR(`SchedulePayload`,[[`tick`,`Tick`]]),GR=(e,t)=>new EL({types:[bR,...e],variables:[new TL({name:`repo`,type:pR(`RepoContext`)}),new TL({name:`item`,type:pR(t)})]}),KR=GR([hR,gR,_R,vR,xR,SR,CR,wR,TR,ER,DR],`IssuePayload`),qR=GR([hR,gR,yR,xR,OR,kR,AR,jR,MR,NR,PR,FR,IR,LR,RR,zR,BR,VR,HR],`PullRequestPayload`),JR=GR([UR,WR],`SchedulePayload`),YR=e=>{switch(e){case`issue`:return KR;case`pr`:return qR;case`schedule`:return JR}},XR=e=>{let{owner:t}=Kw(e.name);return{name:e.name,owner:t,url:`https://github.com/${e.name}`}},ZR=Symbol.for(`yaml.alias`),QR=Symbol.for(`yaml.document`),$R=Symbol.for(`yaml.map`),ez=Symbol.for(`yaml.pair`),tz=Symbol.for(`yaml.scalar`),nz=Symbol.for(`yaml.seq`),rz=Symbol.for(`yaml.node.type`),iz=e=>!!e&&typeof e==`object`&&e[rz]===ZR,az=e=>!!e&&typeof e==`object`&&e[rz]===QR,oz=e=>!!e&&typeof e==`object`&&e[rz]===$R,sz=e=>!!e&&typeof e==`object`&&e[rz]===ez,cz=e=>!!e&&typeof e==`object`&&e[rz]===tz,lz=e=>!!e&&typeof e==`object`&&e[rz]===nz;function uz(e){if(e&&typeof e==`object`)switch(e[rz]){case $R:case nz:return!0}return!1}function dz(e){if(e&&typeof e==`object`)switch(e[rz]){case ZR:case $R:case tz:case nz:return!0}return!1}var fz=e=>(cz(e)||uz(e))&&!!e.anchor,pz=Symbol(`break visit`),mz=Symbol(`skip children`),hz=Symbol(`remove node`);function gz(e,t){let n=vz(t);az(e)?_z(null,e.contents,n,Object.freeze([e]))===hz&&(e.contents=null):_z(null,e,n,Object.freeze([]))}gz.BREAK=pz,gz.SKIP=mz,gz.REMOVE=hz;function _z(e,t,n,r){let i=yz(e,t,n,r);if(dz(i)||sz(i))return bz(e,r,i),_z(e,i,n,r);if(typeof i!=`symbol`){if(uz(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=_z(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===pz)return pz;else i===hz&&(t.items.splice(e,1),--e)}}else if(sz(t)){r=Object.freeze(r.concat(t));let e=_z(`key`,t.key,n,r);if(e===pz)return pz;e===hz&&(t.key=null);let i=_z(`value`,t.value,n,r);if(i===pz)return pz;i===hz&&(t.value=null)}}return i}function vz(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function yz(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(oz(t))return n.Map?.(e,t,r);if(lz(t))return n.Seq?.(e,t,r);if(sz(t))return n.Pair?.(e,t,r);if(cz(t))return n.Scalar?.(e,t,r);if(iz(t))return n.Alias?.(e,t,r)}function bz(e,t,n){let r=t[t.length-1];if(uz(r))r.items[e]=n;else if(sz(r))e===`key`?r.key=n:r.value=n;else if(az(r))r.contents=n;else{let e=iz(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var xz={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},Sz=e=>e.replace(/[!,[\]{}]/g,e=>xz[e]),Cz=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+Sz(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&dz(e.contents)){let t={};gz(e.contents,(e,n)=>{dz(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)(i!==`!!`||a!==`tag:yaml.org,2002:`)&&(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(`
|
|
34
|
+
`)}};Cz.defaultYaml={explicit:!1,version:`1.2`},Cz.defaultTags={"!!":`tag:yaml.org,2002:`};function wz(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Tz(e){let t=new Set;return gz(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function Ez(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function Dz(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=Tz(e);let a=Ez(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(cz(t.node)||uz(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function Oz(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=Oz(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=Oz(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=Oz(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=Oz(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function kz(e,t,n){if(Array.isArray(e))return e.map((e,t)=>kz(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!fz(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var Az=class{constructor(e){Object.defineProperty(this,rz,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!az(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=kz(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?Oz(i,{"":o},``,o):o}},jz=class extends Az{constructor(e){super(ZR),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],gz(e,{Node:(e,t)=>{(iz(t)||fz(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}return r}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:r,maxAliasCount:i}=t,a=this.resolve(r,t);if(!a){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}let o=n.get(a);if(o||=(kz(a,null,t),n.get(a)),!o||o.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(o.count+=1,o.aliasCount===0&&(o.aliasCount=Mz(r,a,n)),o.count*o.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`);return o.res}toString(e,t,n){let r=`*${this.source}`;if(e){if(wz(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function Mz(e,t,n){if(iz(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(uz(t)){let r=0;for(let i of t.items){let t=Mz(e,i,n);t>r&&(r=t)}return r}if(sz(t)){let r=Mz(e,t.key,n),i=Mz(e,t.value,n);return Math.max(r,i)}return 1}var Nz=e=>!e||typeof e!=`function`&&typeof e!=`object`,$=class extends Az{constructor(e){super(tz),this.value=e}toJSON(e,t){return t?.keep?this.value:kz(this.value,e,t)}toString(){return String(this.value)}};$.BLOCK_FOLDED=`BLOCK_FOLDED`,$.BLOCK_LITERAL=`BLOCK_LITERAL`,$.PLAIN=`PLAIN`,$.QUOTE_DOUBLE=`QUOTE_DOUBLE`,$.QUOTE_SINGLE=`QUOTE_SINGLE`;var Pz=`tag:yaml.org,2002:`;function Fz(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Iz(e,t,n){if(az(e)&&(e=e.contents),dz(e))return e;if(sz(e)){let t=n.schema[$R].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new jz(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=Pz+t.slice(2));let l=Fz(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new $(e);return c&&(c.node=t),t}l=e instanceof Map?o[$R]:Symbol.iterator in Object(e)?o[nz]:o[$R]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new $(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function Lz(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return Iz(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var Rz=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,zz=class extends Az{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>dz(t)||sz(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Rz(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(uz(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Lz(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(uz(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&cz(i)?i.value:i:uz(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!sz(t))return!1;let n=t.value;return n==null||e&&cz(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return uz(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(uz(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,Lz(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},Bz=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function Vz(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Hz=(e,t,n)=>e.endsWith(`
|
|
35
|
+
`)?Vz(n,t):n.includes(`
|
|
36
|
+
`)?`
|
|
37
|
+
`+Vz(n,t):(e.endsWith(` `)?``:` `)+n,Uz=`flow`,Wz=`block`,Gz=`quoted`;function Kz(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=qz(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
|
|
38
|
+
`)n===`block`&&(h=qz(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
|
|
39
|
+
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
|
|
40
|
+
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function qz(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
41
|
+
`);r=t,i=t+1,a=e[i]}return r}var Jz=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Yz=e=>/^(%|---|\.\.\.)/m.test(e);function Xz(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
|
|
42
|
+
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function Zz(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(Yz(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
|
|
43
|
+
|
|
44
|
+
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
|
|
45
|
+
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:Kz(o,a,Gz,Jz(t,!1))}function Qz(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
46
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return Zz(e,t);let n=t.indent||(Yz(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:Kz(r,n,Uz,Jz(t,!1))}function $z(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=Zz;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?Qz:i&&!t?Zz:n?Qz:Zz}return r(e,t)}var eB;try{eB=RegExp(`(^|(?<!
|
|
47
|
+
))
|
|
48
|
+
+(?!
|
|
49
|
+
|$)`,`g`)}catch{eB=/\n+(?!\n|$)/g}function tB({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return $z(n,r);let l=r.indent||(r.forceBlockIndent||Yz(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===$.BLOCK_FOLDED?!1:t===$.BLOCK_LITERAL||!Xz(n,c,l.length);if(!n)return u?`|
|
|
50
|
+
`:`>
|
|
51
|
+
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
|
|
52
|
+
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
|
|
53
|
+
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
|
|
54
|
+
`&&(p=p.slice(0,-1)),p.replace(eB,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
|
|
55
|
+
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
|
|
56
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=Jz(r,!0);o!==`folded`&&t!==$.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=Kz(`${v}${e}${p}`,l,Wz,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function nB(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
|
|
57
|
+
`)||u&&/[[\]{},]/.test(a))return $z(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
|
|
58
|
+
`)?$z(a,t):tB(e,t,n,r);if(!s&&!u&&i!==$.PLAIN&&a.includes(`
|
|
59
|
+
`))return tB(e,t,n,r);if(Yz(a)){if(c===``)return t.forceBlockIndent=!0,tB(e,t,n,r);if(s&&c===l)return $z(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return $z(a,t)}return s?d:Kz(d,c,Uz,Jz(t,!1))}function rB(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==$.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=$.QUOTE_DOUBLE);let c=e=>{switch(e){case $.BLOCK_FOLDED:case $.BLOCK_LITERAL:return i||a?$z(o.value,t):tB(o,t,n,r);case $.QUOTE_DOUBLE:return Zz(o.value,t);case $.QUOTE_SINGLE:return Qz(o.value,t);case $.PLAIN:return nB(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function iB(e,t){let n=Object.assign({blockQuote:!0,commentString:Bz,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function aB(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(cz(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function oB(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(cz(e)||uz(e))&&e.anchor;a&&wz(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function sB(e,t,n,r){if(sz(e))return e.toString(t,n,r);if(iz(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=dz(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=aB(t.doc.schema.tags,a);let o=oB(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):cz(a)?rB(a,t,n,r):a.toString(t,n,r);return o?cz(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function cB({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=dz(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(uz(e)||!dz(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||uz(e)||(cz(e)?e.type===$.BLOCK_FOLDED||e.type===$.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=sB(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=Hz(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=Hz(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=Hz(g,n.indent,l(f))));let _,v,y;dz(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&cz(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&lz(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=sB(t,n,()=>b=!0,()=>h=!0),ee=` `;if(f||_||v){if(ee=_?`
|
|
60
|
+
`:``,v){let e=l(v);ee+=`\n${Vz(e,n.indent)}`}x===``&&!n.inFlow?ee===`
|
|
61
|
+
`&&(ee=`
|
|
62
|
+
|
|
63
|
+
`):ee+=`\n${n.indent}`}else if(!p&&uz(t)){let e=x[0],r=x.indexOf(`
|
|
64
|
+
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(ee=`\n${n.indent}`)}}else(x===``||x[0]===`
|
|
65
|
+
`)&&(ee=``);return g+=ee+x,n.inFlow?b&&r&&r():y&&!b?g+=Hz(g,n.indent,l(y)):h&&i&&i(),g}function lB(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var uB=`<<`,dB={identify:e=>e===uB||typeof e==`symbol`&&e.description===uB,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new $(Symbol(uB)),{addToJSMap:pB}),stringify:()=>uB},fB=(e,t)=>(dB.identify(t)||cz(t)&&(!t.type||t.type===$.PLAIN)&&dB.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===dB.tag&&e.default);function pB(e,t,n){if(n=e&&iz(n)?n.resolve(e.doc):n,lz(n))for(let r of n.items)mB(e,t,r);else if(Array.isArray(n))for(let r of n)mB(e,t,r);else mB(e,t,n)}function mB(e,t,n){let r=e&&iz(n)?n.resolve(e.doc):n;if(!oz(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function hB(e,t,{key:n,value:r}){if(dz(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(fB(e,n))pB(e,t,r);else{let i=kz(n,``,e);if(t instanceof Map)t.set(i,kz(r,i,e));else if(t instanceof Set)t.add(i);else{let a=gB(n,i,e),o=kz(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function gB(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(dz(e)&&n?.doc){let t=iB(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),lB(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function _B(e,t,n){return new vB(Iz(e,void 0,n),Iz(t,void 0,n))}var vB=class e{constructor(e,t=null){Object.defineProperty(this,rz,{value:ez}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return dz(n)&&(n=n.clone(t)),dz(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return hB(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?cB(this,e,t,n):JSON.stringify(this)}};function yB(e,t,n){return(t.inFlow??e.flow?xB:bB)(e,t,n)}function bB({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(dz(i))!d&&i.spaceBefore&&f.push(``),SB(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(sz(i)){let e=dz(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),SB(n,f,e.commentBefore,d))}d=!1;let s=sB(i,u,()=>o=null,()=>d=!0);o&&(s+=Hz(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
|
|
66
|
+
`}}return e?(p+=`
|
|
67
|
+
`+Vz(l(e),c),s&&s()):d&&o&&o(),p}function xB({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(dz(i))i.spaceBefore&&d.push(``),SB(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(sz(i)){let e=dz(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),SB(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=dz(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=sB(i,c,()=>a=null);n<e.length-1&&(o+=`,`),a&&(o+=Hz(o,r,s(a))),!l&&(d.length>u||o.includes(`
|
|
68
|
+
`))&&(l=!0),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
|
|
69
|
+
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function SB({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=Vz(t(r),e);n.push(i.trimStart())}}function CB(e,t){let n=cz(t)?t.value:t;for(let r of e)if(sz(r)&&(r.key===t||r.key===n||cz(r.key)&&r.key.value===n))return r}var wB=class extends zz{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super($R,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(_B(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=sz(e)?e:!e||typeof e!=`object`||!(`key`in e)?new vB(e,e?.value):new vB(e.key,e.value);let r=CB(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);cz(r.value)&&Nz(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=CB(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=CB(this.items,e)?.value;return(!t&&cz(n)?n.value:n)??void 0}has(e){return!!CB(this.items,e)}set(e,t){this.add(new vB(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)hB(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!sz(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),yB(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},TB={collection:`map`,default:!0,nodeClass:wB,tag:`tag:yaml.org,2002:map`,resolve(e,t){return oz(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>wB.from(e,t,n)},EB=class extends zz{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(nz,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=DB(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=DB(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&cz(r)?r.value:r}has(e){let t=DB(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=DB(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];cz(r)&&Nz(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(kz(e,String(r++),t));return n}toString(e,t,n){return e?yB(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(Iz(a,void 0,n))}}return i}};function DB(e){let t=cz(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var OB={collection:`seq`,default:!0,nodeClass:EB,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return lz(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>EB.from(e,t,n)},kB={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),rB(e,t,n,r)}},AB={identify:e=>e==null,createNode:()=>new $(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new $(null),stringify:({source:e},t)=>typeof e==`string`&&AB.test.test(e)?e:t.options.nullStr},jB={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new $(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&jB.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function MB({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^\d/.test(a)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var NB={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:MB},PB={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():MB(e)}},FB={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new $(parseFloat(e)),n=e.indexOf(`.`);return n!==-1&&e[e.length-1]===`0`&&(t.minFractionDigits=e.length-n-1),t},stringify:MB},IB=e=>typeof e==`bigint`||Number.isInteger(e),LB=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function RB(e,t,n){let{value:r}=e;return IB(r)&&r>=0?n+r.toString(t):MB(e)}var zB={identify:e=>IB(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>LB(e,2,8,n),stringify:e=>RB(e,8,`0o`)},BB={identify:IB,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>LB(e,0,10,n),stringify:MB},VB={identify:e=>IB(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>LB(e,2,16,n),stringify:e=>RB(e,16,`0x`)},HB=[TB,OB,kB,AB,jB,zB,BB,VB,NB,PB,FB];function UB(e){return typeof e==`bigint`||Number.isInteger(e)}var WB=({value:e})=>JSON.stringify(e),GB=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:WB},{identify:e=>e==null,createNode:()=>new $(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:WB},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:WB},{identify:UB,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>UB(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:WB}],KB=[TB,OB].concat(GB,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),qB={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,t){if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return t(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:t,value:n},r,i,a){if(!n)return``;let o=n,s;if(typeof btoa==`function`){let e=``;for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);s=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(t??=$.BLOCK_LITERAL,t!==$.QUOTE_DOUBLE){let e=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),n=Math.ceil(s.length/e),i=Array(n);for(let t=0,r=0;t<n;++t,r+=e)i[t]=s.substr(r,e);s=i.join(t===$.BLOCK_LITERAL?`
|
|
70
|
+
`:` `)}return rB({comment:e,type:t,value:s},r,i,a)}};function JB(e,t){if(lz(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!sz(r)){if(oz(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new vB(new $(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=sz(r)?r:new vB(r)}}else t(`Expected a sequence for this tag`);return e}function YB(e,t,n){let{replacer:r}=n,i=new EB(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(_B(o,s,n))}return i}var XB={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:JB,createNode:YB},ZB=class e extends EB{constructor(){super(),this.add=wB.prototype.add.bind(this),this.delete=wB.prototype.delete.bind(this),this.get=wB.prototype.get.bind(this),this.has=wB.prototype.has.bind(this),this.set=wB.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(sz(e)?(r=kz(e.key,``,t),i=kz(e.value,r,t)):r=kz(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=YB(e,t,n),i=new this;return i.items=r.items,i}};ZB.tag=`tag:yaml.org,2002:omap`;var QB={collection:`seq`,identify:e=>e instanceof Map,nodeClass:ZB,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=JB(e,t),r=[];for(let{key:e}of n.items)cz(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new ZB,n)},createNode:(e,t,n)=>ZB.from(e,t,n)};function $B({value:e,source:t},n){return t&&(e?eV:tV).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var eV={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new $(!0),stringify:$B},tV={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new $(!1),stringify:$B},nV={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:MB},rV={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():MB(e)}},iV={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new $(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:MB},aV=e=>typeof e==`bigint`||Number.isInteger(e);function oV(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function sV(e,t,n){let{value:r}=e;if(aV(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return MB(e)}var cV={identify:aV,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>oV(e,2,2,n),stringify:e=>sV(e,2,`0b`)},lV={identify:aV,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>oV(e,1,8,n),stringify:e=>sV(e,8,`0`)},uV={identify:aV,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>oV(e,0,10,n),stringify:MB},dV={identify:aV,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>oV(e,2,16,n),stringify:e=>sV(e,16,`0x`)},fV=class e extends wB{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=sz(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new vB(e.key,null):new vB(e,null),CB(this.items,t.key)||this.items.push(t)}get(e,t){let n=CB(this.items,e);return!t&&sz(n)?cz(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=CB(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new vB(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(_B(e,null,n));return i}};fV.tag=`tag:yaml.org,2002:set`;var pV={collection:`map`,identify:e=>e instanceof Set,nodeClass:fV,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>fV.from(e,t,n),resolve(e,t){if(oz(e)){if(e.hasAllNullValues(!0))return Object.assign(new fV,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function mV(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function hV(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return MB(e);let r=``;t<0&&(r=`-`,t*=n(-1));let i=n(60),a=[t%i];return t<60?a.unshift(0):(t=(t-a[0])/i,a.unshift(t%i),t>=60&&(t=(t-a[0])/i,a.unshift(t))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}var gV={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>mV(e,n),stringify:hV},_V={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>mV(e,!1),stringify:hV},vV={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(vV.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,i,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+`00`).substr(1,3)):0,l=Date.UTC(n,r-1,i,a||0,o||0,s||0,c),u=t[8];if(u&&u!==`Z`){let e=mV(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``},yV=[TB,OB,kB,AB,eV,tV,cV,lV,uV,dV,nV,rV,iV,qB,dB,QB,XB,pV,gV,_V,vV],bV=new Map([[`core`,HB],[`failsafe`,[TB,OB,kB]],[`json`,KB],[`yaml11`,yV],[`yaml-1.1`,yV]]),xV={binary:qB,bool:jB,float:FB,floatExp:PB,floatNaN:NB,floatTime:_V,int:BB,intHex:VB,intOct:zB,intTime:gV,map:TB,merge:dB,null:AB,omap:QB,pairs:XB,seq:OB,set:pV,timestamp:vV},SV={"tag:yaml.org,2002:binary":qB,"tag:yaml.org,2002:merge":dB,"tag:yaml.org,2002:omap":QB,"tag:yaml.org,2002:pairs":XB,"tag:yaml.org,2002:set":pV,"tag:yaml.org,2002:timestamp":vV};function CV(e,t,n){let r=bV.get(t);if(r&&!e)return n&&!r.includes(dB)?r.concat(dB):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(bV.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(dB)),i.reduce((e,t)=>{let n=typeof t==`string`?xV[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(xV).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}var wV=(e,t)=>e.key<t.key?-1:+(e.key>t.key),TV=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?CV(e,`compat`):e?CV(null,e):null,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?SV:{},this.tags=CV(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,$R,{value:TB}),Object.defineProperty(this,tz,{value:kB}),Object.defineProperty(this,nz,{value:OB}),this.sortMapEntries=typeof a==`function`?a:a===!0?wV:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function EV(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(n.push(t),r=!0):e.directives.docStart&&(r=!0)}r&&n.push(`---`);let i=iB(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(Vz(t,``))}let o=!1,s=null;if(e.contents){if(dz(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(Vz(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=sB(e.contents,i,()=>s=null,t);s&&(c+=Hz(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(sB(e.contents,i));if(e.directives?.docEnd){if(e.comment){let t=a(e.comment);t.includes(`
|
|
71
|
+
`)?(n.push(`...`),n.push(Vz(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(Vz(a(t),``)))}return n.join(`
|
|
72
|
+
`)+`
|
|
73
|
+
`}var DV=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,rz,{value:QR});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new Cz({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[rz]:{value:QR}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=dz(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){OV(this.contents)&&this.contents.add(e)}addIn(e,t){OV(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=Tz(this);e.anchor=!t||n.has(t)?Ez(t||`a`,n):t}return new jz(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=Dz(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=Iz(e,l,p);return o&&uz(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new vB(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return OV(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Rz(e)?this.contents!=null&&(this.contents=null,!0):OV(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return uz(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Rz(e)?!t&&cz(this.contents)?this.contents.value:this.contents:uz(this.contents)?this.contents.getIn(e,t):void 0}has(e){return uz(this.contents)?this.contents.has(e):!1}hasIn(e){return Rz(e)?this.contents!==void 0:uz(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Lz(this.schema,[e],t):OV(this.contents)&&this.contents.set(e,t)}setIn(e,t){Rz(e)?this.contents=t:this.contents==null?this.contents=Lz(this.schema,Array.from(e),t):OV(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new Cz({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new Cz({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new TV(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=kz(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?Oz(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return EV(this,e)}};function OV(e){if(uz(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var kV=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},AV=class extends kV{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},jV=class extends kV{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},MV=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
|
|
74
|
+
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t&&t.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function NV(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let ee=e[e.length-1],te=ee?ee.offset+ee.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:te,start:x??te}}function PV(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
|
|
75
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(PV(t.key)||PV(t.value))return!0}return!1;default:return!0}}function FV(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&PV(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function IV(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||cz(e)&&cz(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var LV=`All mapping items must start at the same column`;function RV({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??wB)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=NV(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,LV)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
|
|
76
|
+
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||PV(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,LV);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&FV(r.indent,u,i),n.atKey=!1,IV(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=NV(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&FV(r.indent,f,i),s=c.range[2];let l=new vB(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
|
|
77
|
+
`+_.comment:g.comment=_.comment);let e=new vB(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function zV({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??EB)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=NV(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l&&l.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&FV(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function BV(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var VV=`Block collections are not allowed within flow collections`,HV=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function UV({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?wB:EB))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=NV(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
|
|
78
|
+
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&PV(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];sz(t)&&(t=t.value??t.key),t.comment?t.comment+=`
|
|
79
|
+
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],HV(m)&&i(r.range,`BLOCK_IN_FLOW`,VV)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);HV(f)&&i(g.range,`BLOCK_IN_FLOW`,VV),n.atKey=!1;let _=NV(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source&&m.source[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?HV(m)&&i(v.range,`BLOCK_IN_FLOW`,VV):_.comment&&(g.comment?g.comment+=`
|
|
80
|
+
`+_.comment:g.comment=_.comment);let y=new vB(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;IV(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new wB(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f&&f.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=BV(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
|
|
81
|
+
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function WV(e,t,n,r,i,a){let o=n.type===`block-map`?RV(e,t,n,r,a):n.type===`block-seq`?zV(e,t,n,r,a):UV(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function GV(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===wB.tagName&&s===`map`||o===EB.tagName&&s===`seq`)return WV(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r&&r.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),WV(e,t,n,i,o)}let l=WV(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=dz(u)?u:new $(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function KV(e,t,n){let r=t.offset,i=qV(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?$.BLOCK_FOLDED:$.BLOCK_LITERAL,o=t.source?JV(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
|
|
82
|
+
`.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
|
|
83
|
+
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===$.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
|
|
84
|
+
`):t.length>c||r[0]===` `?(f===` `?f=`
|
|
85
|
+
`:!p&&f===`
|
|
86
|
+
`&&(f=`
|
|
87
|
+
|
|
88
|
+
`),d+=f+t.slice(c)+r,f=`
|
|
89
|
+
`,p=!0):r===``?f===`
|
|
90
|
+
`?d+=`
|
|
91
|
+
`:f=`
|
|
92
|
+
`:(d+=f+r,f=` `,p=!1)}switch(i.chomp){case`-`:break;case`+`:for(let e=s;e<o.length;++e)d+=`
|
|
93
|
+
`+o[e][0].slice(c);d[d.length-1]!==`
|
|
94
|
+
`&&(d+=`
|
|
95
|
+
`);break;default:d+=`
|
|
96
|
+
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function qV({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function JV(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function YV(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=$.PLAIN,c=XV(a,l);break;case`single-quoted-scalar`:s=$.QUOTE_SINGLE,c=ZV(a,l);break;case`double-quoted-scalar`:s=$.QUOTE_DOUBLE,c=$V(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=BV(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function XV(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),QV(e)}function ZV(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),QV(e.slice(1,-1)).replace(/''/g,`'`)}function QV(e){let t,n;try{t=RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
97
|
+
`,`sy`),n=RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
98
|
+
`,`sy`)}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let i=r[1],a=` `,o=t.lastIndex;for(n.lastIndex=o;r=n.exec(e);)r[1]===``?a===`
|
|
99
|
+
`?i+=a:a=`
|
|
100
|
+
`:(i+=a+r[1],a=` `),o=n.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),i+a+(r?.[1]??``)}function $V(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
|
|
101
|
+
`){if(i===`
|
|
102
|
+
`){let{fold:t,offset:i}=eH(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=tH[i];if(a)n+=a;else if(i===`
|
|
103
|
+
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
|
|
104
|
+
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a={x:2,u:4,U:8}[i];n+=nH(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
|
|
105
|
+
`&&(a!==`\r`||e[r+2]!==`
|
|
106
|
+
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function eH(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
|
|
107
|
+
`||r===`\r`)&&(r!==`\r`||e[t+2]===`
|
|
108
|
+
`);)r===`
|
|
109
|
+
`&&(n+=`
|
|
110
|
+
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var tH={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
|
|
111
|
+
`,r:`\r`,t:` `,v:`\v`,N:`
`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function nH(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(a)){let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}return String.fromCodePoint(a)}function rH(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?KV(e,t,r):YV(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[tz]:c?iH(e.schema,i,c,n,r):t.type===`scalar`?aH(e,i,t,r):e.schema[tz];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=cz(a)?a:new $(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new $(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function iH(e,t,n,r,i){if(n===`!`)return e[tz];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[tz])}function aH({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[tz];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[tz];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function oH(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var sH={composeNode:cH,composeEmptyNode:lH};function cH(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=uH(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=rH(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:l=GV(sH,e,t,n,r),s&&(l.anchor=s.source.substring(1));break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),l=lH(e,t.offset,void 0,null,n,r),u=!1}return s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!cz(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function lH(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=rH(e,{type:`scalar`,offset:oH(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function uH({options:e},{offset:t,source:n,end:r},i){let a=new jz(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=BV(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function dH(e,t,{offset:n,start:r,value:i,end:a},o){let s=new DV(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=NV(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?cH(c,i,l,o):lH(c,l.end,r,null,l,o);let u=s.contents.range[2],d=BV(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function fH(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function pH(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
|
|
112
|
+
|
|
113
|
+
`:`
|
|
114
|
+
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var mH=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=fH(e);r?this.warnings.push(new jV(i,t,n)):this.errors.push(new AV(i,t,n))},this.directives=new Cz({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=pH(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(uz(i)&&!i.flow&&i.items.length>0){let e=i.items[0];sz(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:pH(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=fH(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=dH(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new AV(fH(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new AV(fH(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=BV(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new AV(fH(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new DV(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},hH=Symbol(`break visit`),gH=Symbol(`skip children`),_H=Symbol(`remove item`);function vH(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),yH(Object.freeze([]),e,t)}vH.BREAK=hH,vH.SKIP=gH,vH.REMOVE=_H,vH.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},vH.parentCollection=(e,t)=>{let n=vH.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function yH(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=yH(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===hH)return hH;else r===_H&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function bH(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
|
|
115
|
+
`:case`\r
|
|
116
|
+
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function xH(e){switch(e){case void 0:case` `:case`
|
|
117
|
+
`:case`\r`:case` `:return!0;default:return!1}}var SH=new Set(`0123456789ABCDEFabcdef`),CH=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),wH=new Set(`,[]{}`),TH=new Set(` ,[]{}
|
|
118
|
+
\r `),EH=e=>!e||TH.has(e),DH=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
|
|
119
|
+
`||t===`\r`&&this.buffer[e+1]===`
|
|
120
|
+
`}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
|
|
121
|
+
`||!t&&!this.atEnd)return e+n+1}return t===`
|
|
122
|
+
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&xH(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
123
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&xH(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!xH(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&xH(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,yield*this.parseBlockStart()}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(EH),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&xH(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(EH),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||xH(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
|
|
124
|
+
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
|
|
125
|
+
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>xH(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
|
|
126
|
+
`:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
|
|
127
|
+
`)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?t:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
|
|
128
|
+
`,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
|
|
129
|
+
`;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
|
|
130
|
+
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(!0);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(xH(r)||e&&wH.has(r))break;t=n}else if(xH(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
|
|
131
|
+
`?(n+=1,r=`
|
|
132
|
+
`,i=this.buffer[n+1]):t=n),i===`#`||e&&wH.has(i))break;if(r===`
|
|
133
|
+
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&wH.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){switch(this.charAt(0)){case`!`:return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`&`:return(yield*this.pushUntil(EH))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case`-`:case`?`:case`:`:{let e=this.flowLevel>0,t=this.charAt(1);if(xH(t)||e&&wH.has(t))return e?this.flowKey&&=!1:this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!xH(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(CH.has(t))t=this.buffer[++e];else if(t===`%`&&SH.has(this.buffer[e+1])&&SH.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
134
|
+
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
135
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},OH=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function kH(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function AH(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function jH(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function MH(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function NH(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function PH(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!kH(t.start,`explicit-key-ind`)&&!kH(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,jH(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}var FH=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new DH,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=bH(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&(!e||e.type!==`doc-end`)){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&PH(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&AH(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:AH(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=NH(MH(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
|
|
136
|
+
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
137
|
+
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(kH(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=NH(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(kH(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(jH(t.key)&&!kH(t.sep,`newline`)){let e=NH(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):kH(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!kH(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||kH(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e&&e.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=NH(MH(t));PH(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
|
|
138
|
+
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
139
|
+
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=NH(MH(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=NH(MH(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function IH(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new OH||null,prettyErrors:t}}function LH(e,t={}){let{lineCounter:n,prettyErrors:r}=IH(t),i=new FH(n?.addNewLine),a=new mH(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new AV(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(MV(e,n)),o.warnings.forEach(MV(e,n))),o}var RH=e=>gi(qx(I({message:V}))(e),{onNone:()=>`Unknown YAML parsing failure`,onSome:({message:e})=>e}),zH=(e,t)=>A(function*(){let n=yield*ah({try:()=>LH(t,{keepSourceTokens:!0,prettyErrors:!0,strict:!0,uniqueKeys:!0}),catch:t=>new NL({file:e,stage:`yaml`,expression:T(),message:RH(t)})}),r=n.errors[0]??n.warnings[0];return r===void 0?n:yield*new NL({file:e,stage:`yaml`,expression:T(),message:r.message})}),BH=Gg(),VH=class extends H(`@usine/config/LoopFrontmatter`)({trigger:aR,selector:ZS(tR),approval:$w.pipe(OS(k(`none`))),step:BT.pipe(OS(k(`run`))),agent:WT,maxCycles:lR.fields.maxCycles}){}.pipe(gS({maxCycles:`max_cycles`})),HH=class extends H(`@usine/config/AgentFrontmatter`)({harness:FT,model:PT,effort:IT,parent_model:ZS(PT),parent_effort:ZS(IT)}){},UH=(e,t)=>new NL({file:e,stage:`schema`,expression:T(),message:BH(t.issue)}),WH=Hx(XC),GH=(e,t)=>A(function*(){return yield*WH((yield*zH(e,t)).toJS()).pipe(bh(t=>new NL({file:e,stage:`yaml`,expression:T(),message:BH(t.issue)})))}),KH=(e,t)=>new NL({file:e,stage:`expression`,expression:E(t.source),message:t.message}),qH=e=>{let t=e.slice(e.lastIndexOf(`/`)+1);return t.endsWith(`.md`)?k(t.slice(0,-3)):new NL({file:e,stage:`schema`,expression:T(),message:`Expected a .md filename`})},JH=e=>qH(e).pipe(M(t=>Hx(lR.fields.name)(t).pipe(bh(t=>UH(e,t))))),YH=e=>qH(e).pipe(M(t=>Hx(WT)(t).pipe(bh(t=>UH(e,t))))),XH=(e,t)=>A(function*(){let n=[],r=0;for(;r<t.length;){let i=t.indexOf(`{{`,r);if(i<0)break;let a=t.indexOf(`}}`,i+2);if(a<0)return yield*new NL({file:e,stage:`expression`,expression:T(),message:`Unclosed prompt interpolation at character ${i}`});let o=t.slice(i+2,a).trim(),s=yield*Hx(DL)(o).pipe(bh(t=>UH(e,t)));n.push({source:s,start:i,end:a+2}),r=a+2}return n}),ZH=(e,t,n)=>{let r=uR(t.name),i=YR(t.trigger.on);return A(function*(){let a=yield*qm(yield*XH(r,t.body),t=>e.evaluateScalar(t.source,i,n).pipe(bh(e=>KH(r,e)),ph(e=>({expression:t,value:e})))),o=``,s=0;for(let{expression:e,value:n}of a)o+=t.body.slice(s,e.start),o+=String(n),s=e.end;return o+t.body.slice(s)})},QH=N(`ConfigParser.parseUsineYaml`)((e,t)=>A(function*(){let n=yield*GH(e,t);return yield*Hx(eR)(n,{onExcessProperty:`error`}).pipe(bh(t=>UH(e,t)))})),$H=N(`ConfigParser.parseAgentFile`)((e,t)=>A(function*(){let n=yield*YH(e),r=yield*FL(e,t),i=yield*GH(e,r.yaml),a=yield*Hx(HH)(i,{onExcessProperty:`error`}).pipe(bh(t=>UH(e,t))),o=yield*Hx(GT)(r.body).pipe(bh(t=>UH(e,t)));return new IL({name:n,harness:a.harness,model:a.model,effort:a.effort,parentModel:a.parent_model,parentEffort:a.parent_effort,persona:o})})),eU=e=>N(`ConfigParser.parseLoopFile`)((t,n)=>A(function*(){let r=yield*JH(t),i=yield*FL(t,n),a=yield*GH(t,i.yaml),o=yield*Hx(VH)(a,{onExcessProperty:`error`}).pipe(bh(e=>UH(t,e))),s=yield*Hx(cR)(i.body).pipe(bh(e=>UH(t,e))),c=YR(o.trigger.on);return yield*e.checkBoolean(o.trigger.if,c).pipe(bh(e=>KH(t,e))),yield*qm(yield*XH(t,s),({source:n})=>e.checkScalar(n,c).pipe(bh(e=>KH(t,e))),{discard:!0}),new lR({name:r,trigger:o.trigger,selector:o.selector,approval:o.approval,maxCycles:o.maxCycles,step:o.step,agent:o.agent,body:s})})),tU=qx(Cj),nU=e=>N(`ConfigParser.configWarnings`)(function*(t,n){let r=new Set(t.labels.map(({name:e})=>wj(e))),i=[];for(let e of t.repos)for(let t of e.lanes)for(let n of t.sources)`label`in n&&!r.has(wj(n.label))&&i.push(new dR({repository:e.name,lane:t.name,label:n.label}));for(let t of n){let n=yield*e.relatedStringLiterals(t.trigger.if,[`item`,`labels`]);for(let e of n){let n=tU(e);D(n)&&!r.has(wj(n.value))&&i.push(new fR({loop:t.name,label:n.value}))}}return i}),rU=class e extends O()(`@usine/config/ConfigParser`){static layer=Hf(e,A(function*(){let e=yield*AL;return{configWarnings:nU(e),parseUsineYaml:QH,parseAgentFile:$H,parseLoopFile:eU(e),renderPrompt:N(`ConfigParser.renderPrompt`)((t,n)=>ZH(e,t,n))}}))},iU=class extends H(`@usine/engine/RunSnapshot`)({event:Xw,itemKey:CE,run:MT,step:VT,attempts:L(xE),repository:Uw,revision:Ww,task:bE,agent:KT,parentModel:YS(PT)}){};H(`@usine/engine/RunEvidence`)({snapshot:iU,transcript:L($E)});var aU=class extends H(`@usine/engine/RunSummary`)({itemKey:CE,run:MT,step:VT,attempts:L(xE),repository:Uw,task:bE,agent:KT}){},oU=WS.check(VS(0)).pipe(z(`ProjectionRevision`)),sU=I({eventId:Jw,dedupKey:Yw,payload:XC,receivedAt:EC,itemKey:CE,loop:Zw,step:BT,approval:$w,cycleLimit:CS(TE),cycleGeneration:EE,repository:Uw,revision:Ww,task:bE,agent:KT,parentModel:CS(PT)}),cU=I({itemKey:CE,repository:Uw,revision:Ww,task:bE,agent:KT,parentModel:CS(PT),runId:jT,eventId:Jw,loop:Zw,state:fT,openedAt:EC,stepName:BT,result:CS(zT)}),lU=I({attemptId:vE,runId:jT,stepName:BT,worker:HT,number:yE,brain:LT,parentModel:CS(PT),startedAt:EC,outcome:CS(_E)}),uU=I({sequence:XE,attemptId:vE,direction:PE,envelope:$E.fields.envelope,receivedAt:EC}),dU=I({...sU.fields,runId:jT,state:fT}),fU=I({runId:jT}),pU=I({reason:hF}),mU=I({runId:jT,command:bF}),hU=I({revision:oU}),gU=Hx(L(sU)),_U=Hx(L(cU)),vU=Hx(L(lU)),yU=Hx(L(dU)),bU=Hx(L(fU)),xU=Hx(L(pU)),SU=Hx(L(mU)),CU=Hx(L(hU)),wU=Hx(L(uU)),TU=$x(XC),EU=$x(EC),DU=$x(fT),OU=$x(_E),kU=$x(zT),AU=$x(JE),jU=$x(KT),MU=$x(LT),NU=Vx(BF),PU=e=>t=>bh(t,t=>NU(t)?t:new RF({operation:e,cause:t})),FU=e=>new Xw({id:e.eventId,dedupKey:e.dedupKey,payload:e.payload,receivedAt:e.receivedAt}),IU=e=>new dF({event:FU(e),itemKey:e.itemKey,loop:e.loop,step:e.step,approval:e.approval,cycleLimit:yi(e.cycleLimit),cycleGeneration:e.cycleGeneration,repository:e.repository,revision:e.revision,task:e.task,agent:e.agent,parentModel:yi(e.parentModel)}),LU=e=>new MT({id:e.runId,eventId:e.eventId,loop:e.loop,state:e.state,openedAt:e.openedAt}),RU=e=>new VT({runId:e.runId,name:e.stepName,result:yi(e.result)}),zU=e=>new xE({id:e.attemptId,runId:e.runId,stepName:e.stepName,worker:e.worker,number:e.number,brain:e.brain,parentModel:yi(e.parentModel),startedAt:e.startedAt,outcome:yi(e.outcome)}),BU=(e,t)=>new aU({itemKey:e.itemKey,run:LU(e),step:RU(e),attempts:t.map(zU),repository:e.repository,task:e.task,agent:e.agent}),VU=e=>new $E({sequence:e.sequence,attemptId:e.attemptId,direction:e.direction,envelope:e.envelope,receivedAt:e.receivedAt}),HU=class extends H(`CycleBudgetReset`)({itemKey:CE,repository:Uw,generation:EE}){},UU=class extends FC(`CycleBudgetResetRejectedError`)(`CycleBudgetResetRejectedError`,{askId:AE}){},WU=I({...HU.fields,ask:XS(jE),resetPending:dS}),GU={itemKey:CF.itemKey,repository:CF.repository,generation:CF.generation,ask:CF.askJson,resetPending:CF.resetPending},KU=Hx(L(WU),{onExcessProperty:`error`}),qU=e=>{let t=Y(Z.cycleGeneration,J`coalesce((
|
|
140
|
+
select ${CF.generation} from ${CF}
|
|
141
|
+
where ${CF.itemKey} = ${Z.itemKey}
|
|
142
|
+
), 0)`),n=N(`CycleBudget.get`)(function*(t){return yield*Vh({itemKey:t}),yi((yield*e.select(GU).from(CF).where(Y(CF.itemKey,t)).execute().pipe(M(KU)))[0])}),r=N(`CycleBudget.counts`)(function*(t){yield*Vh({itemKey:t.itemKey,generation:t.generation});let n=GM(e.select({id:DF.attemptId}).from(DF).where(Y(DF.runId,Q.runId))),r=J`json_extract(${Q.stateJson}, '$._tag')`,i=yield*e.select({loop:wF.loop,admitted:J`count(*)`,completed:J`sum(case when ${HM(r,[...yT])} and ${n} then 1 else 0 end)`}).from(wF).innerJoin(Q,Y(Q.runId,wF.runId)).where(PM(Y(wF.itemKey,t.itemKey),Y(wF.generation,t.generation),FM(NM(r,`Canceled`),n))).groupBy(wF.loop).orderBy(nN(wF.loop)).execute();return yield*Hx(L(kE))(i,{onExcessProperty:`error`})});return{admit:N(`CycleBudget.admit`)(function*(t){yield*Vh({itemKey:t.itemKey,loop:t.loop});let i=yield*n(t.itemKey);if(D(i)&&D(i.value.ask))return yield*Qh(`Item cycle budget remains exhausted`,{itemKey:t.itemKey,askId:i.value.ask.value.id,loop:t.loop}),i.value.ask;if(hi(t.cycleLimit))return T();yield*e.insert(CF).values({itemKey:t.itemKey,repository:t.repository}).onConflictDoNothing().execute();let a=yield*n(t.itemKey);if(hi(a))return yield*ih(Error(`Cycle budget missing after insertion`));let o=yield*r(a.value),s=o.find(({loop:e})=>e===t.loop);if(s===void 0||s.admitted<t.cycleLimit.value)return T();let c=new jE({id:AE.make(Jw.make(JSON.stringify([t.event.id,a.value.generation]))),itemKey:t.itemKey,repository:t.repository,loop:t.loop,limit:t.cycleLimit.value,counts:[s,...o.filter(({loop:e})=>e!==t.loop)]});return yield*e.update(CF).set({askJson:$x(jE)(c)}).where(Y(CF.itemKey,t.itemKey)).execute(),yield*Xh(`Item cycle budget exhausted; operator reset required`,{itemKey:t.itemKey,repository:t.repository,askId:c.id,loop:c.loop,limit:c.limit,completedCycles:c.completedCycles,counts:c.counts}),E(c)}),reserve:N(`CycleBudget.reserve`)(function*(t,i){if(hi(t.cycleLimit))return;yield*Vh({runId:i,itemKey:t.itemKey,loop:t.loop});let a=yield*n(t.itemKey);if(hi(a))return yield*ih(Error(`Run admitted without its cycle budget`));yield*e.insert(wF).values({runId:i,itemKey:t.itemKey,loop:t.loop,generation:a.value.generation}).onConflictDoNothing().execute(),yield*Qh(`Item cycle reserved`,{runId:i,itemKey:t.itemKey,loop:t.loop,generation:a.value.generation,counts:yield*r(a.value)})}),get:n,asks:N(`CycleBudget.asks`)(function*(){return(yield*e.select(GU).from(CF).where(WM(CF.askJson)).execute().pipe(M(KU))).flatMap(({ask:e})=>Oi(e))}),pendingResets:N(`CycleBudget.pendingResets`)(function*(){return yield*e.select(GU).from(CF).where(Y(CF.resetPending,!0)).execute().pipe(M(KU))}),isCurrentEvent:N(`CycleBudget.isCurrentEvent`)(function*(e){yield*Vh({eventId:e.event.id,itemKey:e.itemKey});let t=gi(yield*n(e.itemKey),{onNone:()=>0,onSome:e=>e.generation}),r=e.cycleGeneration===t;return r||(yield*Qh(`Event observation was superseded by a cycle reset`,{eventId:e.event.id,itemKey:e.itemKey,observedGeneration:e.cycleGeneration,generation:t})),r}),currentEvent:t}},JU=e=>ph(Jm(()=>crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e))),e=>{let t=new Uint8Array(e),n=``;for(let e=0;e<16;e++)n+=t[e].toString(16).padStart(2,`0`);return n}),YU=`~effect/workflow/Workflow`,XU=O(`effect/workflow/WorkflowEngine`),ZU=O(`effect/workflow/WorkflowEngine/WorkflowInstance`),QU=(e,t)=>JU(`${e._tag}-${e.idempotencyKey(t)}`),$U={[YU]:YU,annotate(e,t){return eW({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,annotations:no(this.annotations,e,t),idempotencyKey:this.idempotencyKey,suspendedRetrySchedule:this.suspendedRetrySchedule})},annotateMerge(e){return eW({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,annotations:po(this.annotations,e),idempotencyKey:this.idempotencyKey,suspendedRetrySchedule:this.suspendedRetrySchedule})},execute(e,t){return Zm(()=>{let n=this.payloadSchema.make(e);return M(XU,e=>M(QU(this,n),r=>lh(Vh({executionId:r}),e.execute(this,{executionId:r,payload:n,discard:t?.discard,suspendedRetrySchedule:this.suspendedRetrySchedule}))))}).pipe(Uh(`${this._tag}.execute`,{},{captureStackTrace:!1}))},poll(e){return M(XU,t=>t.poll(this,e)).pipe(Uh(`${this._tag}.poll`,{attributes:{executionId:e}},{captureStackTrace:!1}))},interrupt(e){return M(XU,t=>t.interrupt(this,e)).pipe(Uh(`${this._tag}.interrupt`,{attributes:{executionId:e}},{captureStackTrace:!1}))},resume(e){return M(XU,t=>t.resume(this,e)).pipe(Uh(`${this._tag}.resume`,{attributes:{executionId:e}},{captureStackTrace:!1}))},toLayer(e){return Gf(M(XU,t=>t.register(this,e)))},executionId(e){return M(xh(this.payloadSchema.makeEffect(e)),e=>QU(this,e))},withCompensation:(...e)=>sW(...e)},eW=e=>{function t(){}return Object.setPrototypeOf(t,$U),Object.assign(t,e),t},tW=(e,t)=>eW({_tag:e,payloadSchema:eS(t.payload)?t.payload:I(t.payload),successSchema:t.success??pS,errorSchema:t.error??oS,annotations:t.annotations??$a(),idempotencyKey:t.idempotencyKey,suspendedRetrySchedule:t.suspendedRetrySchedule}),nW=`~effect/workflow/Workflow/Result`,rW=e=>At(e,nW);H(`effect/workflow/Workflow/Suspended`)({_tag:AS(`Suspended`),cause:nS(iC(oS,dC()))});var iW=(e,t)=>Eh(n=>{let r=so(n,ZU),i=r.activityState;return i.count===0&&i.latch.closeUnsafe(),i.count++,Fh(e,e=>{i.count--;let n=lf(e)&&t(e.value);return lf(e)&&rW(e.value)&&e.value._tag===`Suspended`&&e.value.cause&&(r.cause=r.cause?Yd(r.cause,e.value.cause):e.value.cause),i.count===0?i.latch.open:n?aW(r):$m})}),aW=Yh(function*(e){let t=e.activityState;for(;;){if(t.count>0){yield*t.latch.await,yield*oh;continue}if(yield*oh,t.count===0)return}}),oW=Yh(function*(e){let t=(yield*ZU).scope,n=yield*Th();yield*Sf(t,t=>Oh(e(t),n))}),sW=S(2,(e,t)=>zh(n=>uh(n(e),e=>oW(n=>lf(n)?$m:t(e,n.cause))))),cW=e=>Lh(eh(()=>{e.suspended=!0;let t=Cb();t.interruptUnsafe(t.id)})),lW=ho(`effect/workflow/Workflow/SuspendOnFailure`,{defaultValue:ct}),uW=`~effect/workflow/DurableDeferred`,dW=(e,t)=>{let n=t?.success??pS,r=t?.error??oS;return{[uW]:uW,name:e,successSchema:n,errorSchema:r,exitSchema:fC(IC(n),IC(r),IC(dC())),withActivityAttempt:A(function*(){return dW(`${e}/${yield*mW}`,{success:n,error:r})})}},fW=O(`effect/workflow/WorkflowEngine`),pW=O(`effect/workflow/WorkflowEngine/WorkflowInstance`),mW=ho(`effect/workflow/Activity/CurrentAttempt`,{defaultValue:()=>1}),hW=Yh(function*(e){let t=yield*fW,n=yield*pW;n.awaitedDeferreds.add(e.name);let r=yield*iW(t.deferredResult(e),hi);return hi(r)?yield*cW(n):yield*r.value}),gW=class e extends H(`effect/workflow/DurableDeferred/TokenParsed`)({workflowName:F,executionId:F,deferredName:F}){get asToken(){return fs(JSON.stringify([this.workflowName,this.executionId,this.deferredName]))}static FromString=F.pipe(B(bC(yS([F,F,F])),{decode:M_(),encode:A_()}),B(e,{decode:y_(([t,n,r])=>new e({workflowName:t,executionId:n,deferredName:r})),encode:y_(e=>[e.workflowName,e.executionId,e.deferredName])}));static fromString=Xx(e.FromString);static encode=$x(e.FromString)},_W=S(2,(e,t)=>new gW({workflowName:t.workflow._tag,executionId:t.executionId,deferredName:e.name}).asToken),vW=S(2,Yh(function*(e,t){let n=yield*fW,r=gW.fromString(t.token);yield*n.deferredDone(e,{workflowName:r.workflowName,executionId:r.executionId,deferredName:r.deferredName,exit:t.exit})})),yW=S(2,(e,t)=>vW(e,{token:t.token,exit:af(t.value)})),bW=class extends O()(`effect/workflow/WorkflowEngine`){};O()(`effect/workflow/WorkflowEngine/WorkflowInstance`);var xW=class extends H(`@usine/engine/StepExecution`)({attempt:xE,event:Xw,run:MT,step:VT,repository:Uw,revision:Ww,task:bE,agent:KT,parentModel:YS(PT)}){},SW=class extends O()(`@usine/engine/StepExecutor`){},CW=(e,t)=>l_(t.openedAt)-l_(e.openedAt)||t.runId.localeCompare(e.runId),wW={eventId:SF.eventId,dedupKey:SF.dedupKey,payload:SF.payloadJson,receivedAt:SF.receivedAt,itemKey:Z.itemKey,loop:Z.loopName,step:Z.stepName,approval:Z.approval,cycleLimit:Z.cycleLimit,cycleGeneration:Z.cycleGeneration,repository:Z.repository,revision:Z.revision,task:Z.task,agent:Z.agentJson,parentModel:Z.parentModel},TW={itemKey:Z.itemKey,runId:Q.runId,eventId:Q.eventId,loop:Q.loopName,state:Q.stateJson,openedAt:Q.openedAt,repository:Q.repository,revision:Q.revision,task:Q.task,agent:Q.agentJson,parentModel:Q.parentModel,stepName:EF.stepName,result:EF.result},EW={attemptId:DF.attemptId,runId:DF.runId,stepName:DF.stepName,worker:DF.workerName,number:DF.attemptNumber,brain:DF.brainJson,parentModel:DF.parentModel,startedAt:DF.startedAt,outcome:DF.outcomeJson},DW=J`json_extract(${Q.stateJson}, '$._tag')`,OW=VM(DW,[...yT]),kW=VM(DW,[...xT]),AW=e=>Yx(XC)(jU(e)),jW=e=>{let t=N(`RunStoreQueries.eventRouteByDedup`)(function*(t){return yield*gU(yield*e.select(wW).from(SF).innerJoin(Z,Y(Z.eventId,SF.eventId)).where(Y(SF.dedupKey,t)).execute())}),n=N(`RunStoreQueries.eventRouteByRun`)(function*(t){return yield*gU(yield*e.select(wW).from(Q).innerJoin(SF,Y(SF.eventId,Q.eventId)).innerJoin(Z,Y(Z.eventId,SF.eventId)).where(Y(Q.runId,t)).execute())}),r=N(`RunStoreQueries.runRows`)(function*(t){return yield*_U(yield*e.select(TW).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).innerJoin(EF,Y(EF.runId,Q.runId)).where(Y(Q.runId,t)).execute())}),i=N(`RunStoreQueries.attemptRows`)(function*(t){return yield*vU(yield*e.select(EW).from(DF).where(Y(DF.runId,t)).orderBy(DF.attemptNumber).execute())}),a=N(`RunStoreQueries.snapshot`)(function*(e){let[t,a,o]=yield*Km([r(e),i(e),n(e)]),s=t[0],c=o[0];return s===void 0||c===void 0?yield*new IF({runId:e}):new iU({event:FU(c),itemKey:c.itemKey,run:LU(s),step:RU(s),attempts:a.map(zU),repository:s.repository,revision:s.revision,task:s.task,agent:s.agent,parentModel:yi(s.parentModel)})}),o=N(`RunStoreQueries.summariesWithAttempts`)(function*(t){let n=la((yield*qm(ca(t.map(({runId:e})=>e),100),t=>e.select(EW).from(DF).where(VM(DF.runId,t)).orderBy(nN(DF.runId),nN(DF.attemptNumber)).execute().pipe(M(vU)))).flat(),({runId:e})=>e);return t.map(e=>BU(e,n[e.runId]??[]))}),s=N(`RunStoreQueries.itemRunSummaries`)(function*(t){if(t.length===0)return[];let n=(yield*qm(ca([...new Set(t)],100),t=>e.select(TW).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).innerJoin(EF,Y(EF.runId,Q.runId)).where(VM(Z.itemKey,t)).execute().pipe(M(_U)))).flat().sort(CW);return yield*o(n)}),c=N(`RunStoreQueries.runSummaries`)(function*(t){let[n,r]=yield*Km([e.select(TW).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).innerJoin(EF,Y(EF.runId,Q.runId)).where(OW).orderBy(rN(Q.openedAt),rN(Q.runId)).execute().pipe(M(_U)),e.select(TW).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).innerJoin(EF,Y(EF.runId,Q.runId)).where(HM(DW,[...yT])).orderBy(rN(Q.openedAt),rN(Q.runId)).limit(t).execute().pipe(M(_U))]),i=[...n,...r].sort(CW);return yield*o(i)}),l=N(`RunStoreQueries.projectionRevision`)(function*(){return yi((yield*CU(yield*e.select({revision:FF.revision}).from(FF).where(Y(FF.singleton,1)).limit(1).execute()))[0]?.revision)}),u=N(`RunStoreQueries.updateState`)(function*(t,n){if((yield*e.update(Q).set({stateJson:DU(n)}).where(Y(Q.runId,t)).returning({runId:Q.runId}).execute()).length===0)return yield*new IF({runId:t})}),d=N(`RunStoreQueries.addAttempt`)(function*(t){yield*e.insert(DF).values({attemptId:t.id,runId:t.runId,stepName:t.stepName,workerName:t.worker,attemptNumber:t.number,brainJson:MU(t.brain),parentModel:Si(t.parentModel),startedAt:EU(t.startedAt),outcomeJson:null}).execute()}),f=N(`RunStoreQueries.closeAttempt`)(function*(t,n){yield*e.update(DF).set({outcomeJson:OU(n)}).where(PM(Y(DF.attemptId,t),UM(DF.outcomeJson))).execute()}),p=N(`RunStoreQueries.updateAttemptParentModel`)(function*(t,n){yield*e.update(DF).set({parentModel:n}).where(Y(DF.attemptId,t)).execute()}),m=N(`RunStoreQueries.updateStepResult`)(function*(t,n,r){yield*e.update(EF).set({result:kU(r)}).where(PM(Y(EF.runId,t),Y(EF.stepName,n))).execute()}),h=N(`RunStoreQueries.approvalExists`)(function*(t){return(yield*e.$count(kF,Y(kF.runId,t)).execute())>0}),g=N(`RunStoreQueries.recordApproval`)(function*(t,n){yield*e.insert(SF).values({eventId:n.id,dedupKey:n.dedupKey,payloadJson:TU(n.payload),receivedAt:EU(n.receivedAt)}).onConflictDoNothing().execute(),yield*e.insert(kF).values({runId:t,eventId:n.id}).execute()}),_=N(`RunStoreQueries.requestWorkflowCommand`)(function*(t,n){yield*e.insert(jF).values({runId:t,command:n}).onConflictDoNothing().execute()}),v=N(`RunStoreQueries.requestInterrupt`)(function*(t){yield*e.delete(jF).where(PM(Y(jF.runId,t),VM(jF.command,[`Approve`,`Resume`]))).execute(),yield*_(t,`Interrupt`)}),y=N(`RunStoreQueries.workflowCommandsFor`)(function*(t){return yield*Vh({runId:t}),(yield*SU(yield*e.select({runId:jF.runId,command:jF.command}).from(jF).where(Y(jF.runId,t)).execute())).map(({command:e})=>e)}),b=N(`RunStoreQueries.createRun`)(function*(t,n,r){let i=uF(Z,`candidate`),a=uF(Q,`candidate_run`),o=uF(AF,`ignored`);yield*e.insert(AF).select(e.select({eventId:i.eventId,reason:J`'superseded'`.as(`reason`)}).from(i).leftJoin(a,Y(a.eventId,i.eventId)).leftJoin(o,Y(o.eventId,i.eventId)).where(PM(Y(i.loopName,t.loop),Y(i.itemKey,t.itemKey),NM(i.eventId,n),UM(a.runId),UM(o.eventId)))).onConflictDoNothing().execute(),yield*e.insert(Q).values({runId:r,eventId:n,loopName:t.loop,stateJson:DU(new iT),openedAt:EU(t.event.receivedAt),repository:t.repository,revision:t.revision,task:t.task,agentJson:AW(t.agent),parentModel:Si(t.parentModel)}).onConflictDoNothing().execute(),yield*e.insert(EF).values({runId:r,stepName:t.step,result:null}).onConflictDoNothing().execute()}),x=N(`RunStoreQueries.runForEvent`)(function*(t){return yield*bU(yield*e.select({runId:Q.runId}).from(Q).where(Y(Q.eventId,t)).execute())}),ee=N(`RunStoreQueries.ignoredEvent`)(function*(t){return yield*xU(yield*e.select({reason:AF.reason}).from(AF).where(Y(AF.eventId,t)).execute())}),te=N(`RunStoreQueries.blockingRun`)(function*(t,n){return yield*bU(yield*e.select({runId:Q.runId}).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).where(PM(Y(Z.loopName,t),Y(Z.itemKey,n),OW)).orderBy(rN(Q.openedAt)).limit(1).execute())}),ne=N(`RunStoreQueries.recordTriggerEvent`)(function*(n){yield*e.insert(SF).values({eventId:n.event.id,dedupKey:n.event.dedupKey,payloadJson:TU(n.event.payload),receivedAt:EU(n.event.receivedAt)}).onConflictDoNothing().execute();let r=(yield*t(n.event.dedupKey))[0];return r===void 0?(yield*e.insert(Z).values({eventId:n.event.id,itemKey:n.itemKey,loopName:n.loop,stepName:n.step,approval:n.approval,cycleLimit:Si(n.cycleLimit),cycleGeneration:n.cycleGeneration,repository:n.repository,revision:n.revision,task:n.task,agentJson:AW(n.agent),parentModel:Si(n.parentModel)}).execute(),n):IU(r)}),re=N(`RunStoreQueries.nextQueued`)(function*(t){let r=(yield*n(t))[0];return r===void 0?T():yi((yield*gU(yield*e.select(wW).from(SF).innerJoin(Z,Y(Z.eventId,SF.eventId)).leftJoin(Q,Y(Q.eventId,SF.eventId)).leftJoin(AF,Y(AF.eventId,SF.eventId)).where(PM(Y(Z.loopName,r.loop),Y(Z.itemKey,r.itemKey),qU(e).currentEvent,UM(Q.runId),UM(AF.eventId))).orderBy(rN(SF.receivedAt)).limit(1).execute()))[0]).pipe(Ti(IU))}),ie=N(`RunStoreQueries.appendTranscript`)(function*(t,n,r){yield*e.insert(OF).values({attemptId:n.attemptId,direction:t,channelSequence:n.sequence,envelope:AU(n),receivedAt:EU(r)}).onConflictDoNothing().execute()}),ae=N(`RunStoreQueries.transcript`)(function*(t){yield*Vh({attemptId:t.attemptId,query:t._tag});let n=Ow(t,{TranscriptAllQuery:({attemptId:e})=>Y(OF.attemptId,e),TranscriptTailQuery:({attemptId:e,after:t})=>PM(Y(OF.attemptId,e),LM(OF.sequence,t)),TranscriptPageQuery:({attemptId:e,before:t})=>gi(t,{onNone:()=>Y(OF.attemptId,e),onSome:t=>PM(Y(OF.attemptId,e),zM(OF.sequence,t))})}),r=e.select({sequence:OF.sequence,attemptId:OF.attemptId,direction:OF.direction,envelope:OF.envelope,receivedAt:OF.receivedAt}).from(OF).where(n);return(yield*wU(yield*Ow(t,{TranscriptAllQuery:()=>r.orderBy(nN(OF.sequence)).execute(),TranscriptTailQuery:({limit:e})=>r.orderBy(nN(OF.sequence)).limit(e).execute(),TranscriptPageQuery:({limit:e})=>r.orderBy(rN(OF.sequence)).limit(e).execute()}),{onExcessProperty:`error`})).map(VU).sort((e,t)=>e.sequence-t.sequence)}),oe=N(`RunStoreQueries.recoverable`)(function*(){return yield*yU(yield*e.select({...wW,runId:Q.runId,state:Q.stateJson}).from(Q).innerJoin(SF,Y(SF.eventId,Q.eventId)).innerJoin(Z,Y(Z.eventId,SF.eventId)).where(OW).execute())}),se=N(`RunStoreQueries.pendingWorkflowCommands`)(function*(){let t=yield*SU(yield*e.select({runId:jF.runId,command:jF.command}).from(jF).execute()),n=e=>xF.indexOf(e);return[...t].sort((e,t)=>e.runId===t.runId?n(e.command)-n(t.command):e.runId<t.runId?-1:1)}),ce=N(`RunStoreQueries.completeWorkflowCommand`)(function*(t,n){yield*e.delete(jF).where(PM(Y(jF.runId,t),Y(jF.command,n))).execute()}),le=N(`RunStoreQueries.revokeUnstarted`)(function*(t,n){let r=yield*bU(yield*e.select({runId:Q.runId}).from(Q).innerJoin(Z,Y(Z.eventId,Q.eventId)).where(PM(Y(Z.loopName,t),Y(Z.itemKey,n),kW)).execute()),i=uF(Z,`candidate`),a=uF(Q,`candidate_run`);return yield*e.insert(AF).select(e.select({eventId:i.eventId,reason:J`'revoked'`.as(`reason`)}).from(i).leftJoin(a,Y(a.eventId,i.eventId)).where(PM(Y(i.loopName,t),Y(i.itemKey,n),UM(a.runId)))).onConflictDoNothing().execute(),r});return{cycles:qU(e),addAttempt:d,appendTranscript:ie,approvalExists:h,blockingRun:te,closeAttempt:f,completeWorkflowCommand:ce,createRun:b,eventRouteByRun:n,workflowCommandsFor:y,ignoredEvent:ee,nextQueued:re,pendingWorkflowCommands:se,recordTriggerEvent:ne,recoverable:oe,recordApproval:g,requestInterrupt:v,requestWorkflowCommand:_,revision:l,revokeUnstarted:le,runSummaries:c,itemRunSummaries:s,runForEvent:x,snapshot:a,transcript:ae,updateStepResult:m,updateAttemptParentModel:p,updateState:u}},MW=yE.make(3),NW=e=>yi(e.attempts.at(-1)).pipe(ki(e=>hi(e.outcome))),PW=(e,t,n,r)=>{let i=new hE({failure:n});return r===`Execution`&&SE({failure:n,number:t.number,maxAutoAttempts:MW})?{_tag:`RetryAttempt`,attempt:t,outcome:i}:{_tag:`RunFailed`,attempt:t,outcome:i,state:ET(e)}},FW=(e,t,n,r)=>{if(e.run.state._tag!==`Running`)return{_tag:`Unchanged`,reason:`RunNotRunning`};let i=NW(e);return hi(i)?{_tag:`Unchanged`,reason:`NoOpenAttempt`}:i.value.id===t?Ii(n)?PW(e.run.state,i.value,n.failure,r):{_tag:`RunSucceeded`,attempt:i.value,outcome:new mE,state:TT(e.run.state),result:n.success}:{_tag:`Unchanged`,reason:`AttemptReplaced`}},IW=(e,t,n)=>FW(e,t,n,`Execution`),LW=(e,t)=>{let n=NW(e);return hi(n)?{_tag:`Unchanged`,reason:`NoOpenAttempt`}:FW(e,n.value.id,t,`FinalReconciliation`)},RW=(e,t)=>{let n=e.run.state;if(!_T(n)&&n._tag!==`Running`)return{_tag:`RunClosed`,state:n};let r=T(),i=NW(e);if(n._tag===`Running`&&D(i)){let e=PW(n,i.value,t,`Execution`);if(e._tag===`RunFailed`)return e;r=E(e)}return{_tag:`StartAttempt`,state:n._tag===`Running`?n:wT(n),number:yE.make((e.attempts.at(-1)?.number??0)+1),interrupted:r}},zW=e=>hT(e.run.state)?{_tag:`Canceled`,state:OT(e.run.state),attempt:e.run.state._tag===`Running`?Ti(NW(e),e=>({id:e.id,outcome:new gE})):T()}:{_tag:`AlreadyClosed`},BW=(e,t)=>e._tag===`Failed`?{_tag:`Resume`,state:DT(e)}:e._tag===`Running`&&t.includes(`Resume`)?{_tag:`ResumePending`}:{_tag:`RetryRejected`},VW=(e,t)=>{if(hi(e))return{_tag:`OpenRun`};let n=e.value;return n.state._tag===`Running`?{_tag:`QueueEvent`}:gT(n.state)?{_tag:`SupersedeRun`,runId:n.id,state:kT(n.state,t)}:{_tag:`OpenRun`}},HW=class extends H(`@usine/engine/internal/StoredSubmission`)({submission:dF,runId:jT}){},UW=class extends H(`@usine/engine/internal/RecoverableRun`)({submission:dF,runId:jT,state:fT}){},WW=class extends H(`@usine/engine/internal/Claim`)({submission:dF,result:vF,supersededRun:YS(jT)}){},GW=class extends U(`@usine/engine/internal/AttemptStarted`)(`AttemptStarted`,{execution:xW}){},KW=class extends U(`@usine/engine/internal/AttemptRecoveryFailed`)(`AttemptRecoveryFailed`,{failure:cE}){},qW=class extends U(`@usine/engine/internal/RunClosed`)(`RunClosed`,{state:F}){},JW=A(function*(){let e=yield*zN,t=jW(e),n=(e,t,n=T())=>new WW({submission:e,result:new fF({eventId:e.event.id,runId:t}),supersededRun:n}),r=N(`RunStore.openRun`)(function*(e,t,r,i=T()){let a=yield*e.cycles.admit(t);return D(a)?new WW({submission:t,supersededRun:i,result:new _F({eventId:t.event.id,ask:a.value})}):(yield*e.createRun(t,t.event.id,r),yield*e.cycles.reserve(t,r),n(t,r,i))}),i=N(`RunStore.recordAndClaim`)(function*(t,i){return yield*Vh({eventId:t.event.id,runId:i,loop:t.loop,itemKey:t.itemKey}),yield*e.transaction(e=>A(function*(){let a=jW(e),o=yield*a.recordTriggerEvent(t),s=yield*a.runForEvent(o.event.id);if(s[0]!==void 0)return yield*Qh(`Event joined its existing Run`,{eventId:o.event.id,runId:s[0].runId}),n(o,s[0].runId);let c=yield*a.ignoredEvent(o.event.id);if(c[0]!==void 0)return yield*Qh(`Event remains ignored`,{eventId:o.event.id,reason:c[0].reason}),new WW({submission:o,result:new gF({eventId:o.event.id,reason:c[0].reason}),supersededRun:T()});if(!(yield*a.cycles.isCurrentEvent(o)))return new WW({submission:o,supersededRun:T(),result:new gF({eventId:o.event.id,reason:`superseded`})});let l=(yield*a.blockingRun(o.loop,o.itemKey))[0],u=VW(l===void 0?T():E((yield*a.snapshot(l.runId)).run),o.event.id);switch(yield*Qh(`Event claim decided`,{eventId:o.event.id,decision:u._tag}),u._tag){case`QueueEvent`:return new WW({submission:o,result:new pF({eventId:o.event.id}),supersededRun:T()});case`SupersedeRun`:return yield*a.updateState(u.runId,u.state),yield*a.requestInterrupt(u.runId),yield*r(a,o,i,E(u.runId));case`OpenRun`:return yield*r(a,o,i)}}))},PU(`submit Event`)),a=N(`RunStore.parkForApproval`)(function*(t){yield*e.transaction(e=>A(function*(){let n=jW(e),r=yield*n.snapshot(t);r.run.state._tag===`Pending`&&(yield*n.updateState(t,ST(r.run.state)))}))},PU(`park run for approval`)),o=N(`RunStore.applyFinish`)(function*(e,t,n){if(yield*Vh({runId:t}),n._tag===`Unchanged`){yield*Qh(`Attempt completion ignored`,{runId:t,reason:n.reason});return}let{attempt:r,outcome:i}=n;yield*Vh({attemptId:r.id});let a={runId:t,attemptId:r.id,number:r.number,decision:n._tag};yield*Qh(`Attempt completion decided`,Ow(i,{Failed:({failure:e})=>({...a,failure:e._tag}),Succeeded:()=>a})),yield*e.closeAttempt(r.id,i),n._tag!==`RetryAttempt`&&(n._tag===`RunSucceeded`&&(yield*e.updateStepResult(t,r.stepName,n.result)),yield*e.updateState(t,n.state),yield*e.requestWorkflowCommand(t,`Continue`))}),s=N(`RunStore.beginAttempt`)(function*(t,n){return yield*Vh({runId:t}),yield*e.transaction(e=>A(function*(){let r=jW(e),i=yield*r.snapshot(t),a=new cE({message:`The orchestrator stopped during the attempt`,cause:Error(`attempt interrupted by orchestrator restart`)}),s=RW(i,a);if(s._tag===`RunClosed`)return yield*Qh(`Attempt start skipped`,{runId:t,state:s.state._tag}),new qW({state:s.state._tag});if(s._tag===`RunFailed`)return yield*o(r,t,s),new KW({failure:a});D(s.interrupted)&&(yield*o(r,t,s.interrupted.value)),i.run.state._tag!==s.state._tag&&(yield*r.updateState(t,s.state));let c=vE.make(`${t}/${i.step.name}/${s.number}`),l=yield*i_,u=new xE({id:c,runId:t,stepName:i.step.name,worker:n,number:s.number,brain:i.agent.brain,parentModel:i.parentModel,startedAt:l,outcome:T()});return yield*r.addAttempt(u),yield*Qh(`Attempt started`,{runId:t,attemptId:c,number:s.number,worker:n}),new GW({execution:new xW({attempt:u,event:i.event,run:new MT({id:i.run.id,eventId:i.run.eventId,loop:i.run.loop,state:s.state,openedAt:i.run.openedAt}),step:i.step,repository:i.repository,revision:i.revision,task:i.task,agent:i.agent,parentModel:i.parentModel})})}))},PU(`begin attempt`)),c=N(`RunStore.finishAttempt`)(function*(t,n){return yield*Vh({runId:t.runId,attemptId:t.id}),yield*e.transaction(e=>A(function*(){let r=jW(e),i=IW(yield*r.snapshot(t.runId),t.id,n);return yield*o(r,t.runId,i),i}))},PU(`finish attempt`)),l=N(`RunStore.approve`)(function*(t,n){yield*e.transaction(e=>A(function*(){let r=jW(e);if(yield*r.approvalExists(t))return;let i=yield*r.snapshot(t);if(i.run.state._tag!==`Waiting`)return yield*new LF({runId:t,operation:`approve`,state:i.run.state._tag});yield*r.recordApproval(t,n),yield*r.updateState(t,CT(i.run.state)),yield*r.requestWorkflowCommand(t,`Approve`)}))},PU(`approve run`)),u=N(`RunStore.retry`)(function*(t){yield*Vh({runId:t}),yield*e.transaction(e=>A(function*(){let n=jW(e),r=yield*n.snapshot(t),i=BW(r.run.state,yield*n.workflowCommandsFor(t));if(yield*Qh(`Operator retry decided`,{runId:t,state:r.run.state._tag,decision:i._tag}),i._tag===`Resume`){yield*n.updateState(t,i.state),yield*n.requestWorkflowCommand(t,`Resume`);return}if(i._tag!==`ResumePending`)return yield*new LF({runId:t,operation:`retry`,state:r.run.state._tag})}))},PU(`retry run`)),d=N(`RunStore.cancel`)(function*(t){return yield*Vh({runId:t}),yield*e.transaction(e=>A(function*(){let n=jW(e),r=yield*n.snapshot(t),i=zW(r);return yield*Qh(`Operator cancellation decided`,{runId:t,state:r.run.state._tag,decision:i._tag}),i._tag===`AlreadyClosed`?i:(D(i.attempt)&&(yield*n.closeAttempt(i.attempt.value.id,i.attempt.value.outcome)),yield*n.updateState(t,i.state),yield*n.requestInterrupt(t),yield*n.requestWorkflowCommand(t,`Continue`),{_tag:`Canceled`,openAttempt:Ti(i.attempt,({id:e})=>e)})}))},PU(`cancel run`)),f=N(`RunStore.revoke`)(function*(t,n){return yield*e.transaction(e=>A(function*(){let r=jW(e),i=yield*r.revokeUnstarted(t,n);for(let e of i){let t=yield*r.snapshot(e.runId);gT(t.run.state)&&(yield*r.updateState(e.runId,AT(t.run.state)),yield*r.requestInterrupt(e.runId))}return i.map(e=>e.runId)}))},PU(`revoke run`)),p=N(`RunStore.claimQueued`)(function*(t,n){return yield*e.transaction(e=>A(function*(){let i=jW(e),a=yield*i.runForEvent(t.event.id);return a[0]===void 0?(yield*i.ignoredEvent(t.event.id)).length>0||(yield*i.blockingRun(t.loop,t.itemKey)).length>0||!(yield*i.cycles.isCurrentEvent(t))?T():(yield*r(i,t,n)).result._tag===`Claimed`?E(new HW({submission:t,runId:n})):T():E(new HW({submission:t,runId:a[0].runId}))}))},PU(`claim queued Event`)),m=N(`RunStore.recoverable`)(function*(){return(yield*t.recoverable()).map(e=>new UW({submission:IU(e),runId:e.runId,state:e.state}))},PU(`list recoverable runs`)),h=N(`RunStore.appendTranscript`)(function*(t,n){let r=yield*i_;yield*e.transaction(e=>A(function*(){let i=jW(e);t===`outbound`&&n.payload._tag===`Started`&&(yield*i.updateAttemptParentModel(n.attemptId,n.payload.parentModel)),yield*i.appendTranscript(t,n,r)}))},PU(`append Attempt transcript`)),g=N(`RunStore.transcript`)(function*(e){return yield*t.transcript(e)},PU(`read Attempt transcript`)),_=N(`RunStore.reconcileCompletion`)(function*(t,n){if(yield*Vh({runId:t}),n._tag!==`Complete`){yield*$h(`Workflow reconciliation skipped`,{runId:t,reason:`Suspended`});return}yield*e.transaction(e=>A(function*(){let r=jW(e),i=yield*r.snapshot(t),a=lf(n.exit)?E(ji(n.exit.value)):Ti(Zd(n.exit.cause),Mi);if(hi(a)){yield*Qh(`Workflow reconciliation skipped`,{runId:t,reason:`NoTypedOutcome`});return}yield*o(r,t,LW(i,a.value))}))},PU(`reconcile workflow completion`));return{approve:l,appendTranscript:h,beginAttempt:s,cancel:d,claimQueued:p,completeWorkflowCommand:(e,n)=>t.completeWorkflowCommand(e,n).pipe(PU(`complete workflow command`)),finishAttempt:c,nextQueued:e=>t.nextQueued(e).pipe(PU(`find queued Event`)),parkForApproval:a,pendingWorkflowCommands:t.pendingWorkflowCommands().pipe(PU(`list pending workflow commands`)),recordAndClaim:i,reconcileCompletion:_,recoverable:m(),retry:u,revoke:f,snapshot:e=>t.snapshot(e).pipe(PU(`read run`)),transcript:g}}),YW=class e extends O()(`@usine/engine/internal/RunStore`){static layer=Hf(e,JW)},XW=class extends O()(`@usine/engine/RunEngineShutdown`){},ZW=class e extends O()(`@usine/engine/AttemptAdmission`){static layer=Hf(e,A(function*(){let e=yield*kh(XW),t=D(e)?e.value:yield*ff(),n=yield*jw(new Set),r=yield*ff(),i=N(`AttemptAdmission.enter`)(function*(e){yield*Vh({runId:e});let r=yield*Pw(n,n=>gf(t)?[!1,n]:[!0,new Set([...n,e])]);return r||(yield*Qh(`Attempt deferred until restart; the engine is draining`,{runId:e})),r}),a=N(`AttemptAdmission.leave`)(function*(e){yield*Vh({runId:e});let i=yield*Iw(n,t=>new Set([...t].filter(t=>t!==e)));(yield*hf(t))&&(yield*Qh(`Attempt settled during drain`,{runId:e,remainingRunIds:[...i]}),i.size===0&&(yield*_f(r,void 0)))});return{withAttempt:N(`AttemptAdmission.withAttempt`)(function*(e,t){return yield*Vh({runId:e}),yield*Mh(i(e),e=>e?t:th,t=>t?a(e):$m)}),drain:N(`AttemptAdmission.drain`)(function*(){yield*_f(t,void 0);let e=yield*Mw(n);yield*Qh(`Engine drain started; no further Attempts will be admitted`,{activeRunIds:[...e]}),e.size===0&&(yield*_f(r,void 0)),yield*pf(r),yield*Qh(`Engine drain completed; all admitted Attempts settled`)})}}))},QW=tW(`@usine/engine/DurableRun`,{payload:I({submission:dF}),success:zT,error:fE,idempotencyKey:({submission:e})=>e.event.dedupKey}).annotate(lW,!0),$W=dW(`@usine/engine/ApprovalGate`),eG=e=>_h(e,{EnginePersistenceError:e=>new cE({message:`Engine persistence failed during ${e.operation}`,cause:e}),RunNotFoundError:e=>ih(e),RunOperationRejectedError:e=>ih(e)}),tG=e=>QW.executionId({submission:e}),nG=N(`DurableRun.continueWithNewest`)(function*(e,t){let n=yield*e.nextQueued(t);if(D(n)){let t=yield*tG(n.value),r=jT.make(t),i=yield*e.claimQueued(n.value,r);D(i)&&(yield*QW.execute({submission:i.value.submission},{discard:!0}))}yield*e.completeWorkflowCommand(t,`Continue`)}),rG=N(`DurableRun.attempt`)(function*(e,t){yield*Vh({runId:e,worker:t});let n=yield*YW,r=yield*SW,i=yield*n.beginAttempt(e,t).pipe(eG);if(i instanceof KW||i._tag===`RunClosed`)return i;let a=yield*r.execute(i.execution,{append:(e,t)=>n.appendTranscript(e,t).pipe(eG)}).pipe(yh(t=>Zh(`Step executor defect; operator intervention required`,{runId:e}).pipe(lh(new lE({message:`The step executor crashed outside its typed failure channel`,cause:t})))),dh);return{_tag:`AttemptExecuted`,result:a,decision:yield*n.finishAttempt(i.execution.attempt,a).pipe(eG)}}),iG=N(`DurableRun.execute`)(function*({submission:e},t){let n=jT.make(t),r=yield*YW,i=yield*SW,a=yield*ZW;for(e.approval===`required`&&(yield*r.parkForApproval(n).pipe(eG),yield*hW($W));;){let t=yield*zh(t=>t(i.reserve(e)).pipe(M(e=>t(a.withAttempt(n,rG(n,e.worker))).pipe(Nh(e.release)))));if(t._tag===`RunClosed`)return yield*Qh(`Run closed while it waited for a worker`,{runId:n,state:t.state}),yield*nG(r,n).pipe(eG),yield*new uE({message:`The run closed (${t.state}) before an attempt started`});if(t instanceof KW)return yield*nG(r,n).pipe(eG),yield*t.failure;let{result:o,decision:s}=t;if(s._tag!==`RetryAttempt`)return yield*nG(r,n).pipe(eG),Li(o)?o.success:yield*o.failure}});QW.toLayer(iG);var aG=N(`DurableRun.runIdFor`)(function*(e){return jT.make(yield*tG(e))}),oG=class extends H(`@usine/engine/LoopRuntimeState`)({loop:Zw,paused:dS}){},sG=e=>t=>t.pipe(bh(t=>new RF({operation:e,cause:t}))),cG=A(function*(){let e=yield*zN,t=N(`LoopControl.stateFor`)(function*(t){yield*Vh({loop:t});let n=(yield*e.select({loop:PF.loopName,paused:PF.paused}).from(PF).where(Y(PF.loopName,t)).limit(1).execute())[0];return n===void 0?new oG({loop:t,paused:!1}):new oG(n)},sG(`read Loop runtime state`)),n=N(`LoopControl.states`)(function*(){return(yield*e.select({loop:PF.loopName,paused:PF.paused}).from(PF).orderBy(nN(PF.loopName)).execute()).map(e=>new oG(e))},sG(`list Loop runtime states`)),r=N(`LoopControl.write`)(function*(n){yield*Vh({loop:n.loop});let r=yield*t(n.loop);return r.paused===n.paused?(yield*$h(`Loop runtime state was already set`,{loop:n.loop,paused:n.paused}),r):(yield*e.insert(PF).values({loopName:n.loop,paused:n.paused}).onConflictDoUpdate({target:PF.loopName,set:{paused:n.paused}}).execute().pipe(sG(`write Loop runtime state`)),yield*Qh(n.paused?`Loop paused`:`Loop unpaused`,{loop:n.loop,paused:n.paused}),n)});return{isPaused:N(`LoopControl.isPaused`)(function*(e){return(yield*t(e)).paused}),pause:N(`LoopControl.pause`)(e=>r(new oG({loop:e,paused:!0}))),states:n(),unpause:N(`LoopControl.unpause`)(e=>r(new oG({loop:e,paused:!1})))}}),lG=class e extends O()(`@usine/engine/LoopControl`){static layer=Hf(e,cG)},uG=500;A(function*(){let e=yield*YW,t=yield*ZW,n=yield*SW,r=yield*bW,i=e=>jh(e,bW,r),a=N(`RunEngine.launch`)(function*(e){yield*QW.execute({submission:e},{discard:!0}).pipe(i)}),o=N(`RunEngine.deliverInterrupt`)(function*(t){yield*QW.interrupt(t).pipe(i),yield*e.completeWorkflowCommand(t,`Interrupt`)}),s=N(`RunEngine.deliverApproval`)(function*(t){yield*yW($W,{token:_W($W,{workflow:QW,executionId:t}),value:void 0}).pipe(i),yield*e.completeWorkflowCommand(t,`Approve`)}),c=N(`RunEngine.deliverContinuation`)(function*(t){yield*nG(e,t).pipe(i)}),l=N(`RunEngine.awaitWorkflowSettlement`)(function*(e){for(let t=0;t<uG;t+=1){let t=yield*QW.poll(e).pipe(i);if(D(t))return t.value;yield*Sh(`10 millis`)}return yield*ih(Error(`Run ${e} has no durable workflow execution to settle`))}),u=N(`RunEngine.deliverResume`)(function*(t){let n=yield*l(t);if(n._tag===`Complete`){yield*e.reconcileCompletion(t,n),yield*e.completeWorkflowCommand(t,`Resume`),yield*c(t);return}yield*QW.resume(t).pipe(i),yield*e.completeWorkflowCommand(t,`Resume`)}),d={Approve:s,Continue:c,Interrupt:o,Resume:u},f=N(`RunEngine.submit`)(function*(t){let n=yield*aG(t),r=yield*e.recordAndClaim(t,n);return D(r.supersededRun)&&(yield*o(r.supersededRun.value)),r.result._tag===`Claimed`&&(yield*a(r.submission)),r.result}),p=N(`RunEngine.approve`)(function*(t,n){yield*e.approve(t,n),yield*s(t)}),m=N(`RunEngine.retry`)(function*(t){yield*e.retry(t),yield*u(t)}),h=N(`RunEngine.cancel`)(function*(t){let r=yield*e.cancel(t);if(r._tag===`AlreadyClosed`){yield*$h(`Cancel was a no-op; the run was already closed`,{runId:t});return}yield*Qh(`Run canceled`,{runId:t,openAttempt:_i(r.openAttempt,()=>`none`)});let i=D(r.openAttempt)?yield*n.interrupt(r.openAttempt.value).pipe(dh):ji(void 0);if(yield*o(t),yield*c(t),D(r.openAttempt)&&Ii(i))return yield*new zF({attemptId:r.openAttempt.value,cause:i.failure})}),g=N(`RunEngine.revoke`)(function*(t,n){let r=yield*e.revoke(t,n);return yield*qm(r,o,{concurrency:`unbounded`,discard:!0}),r}),_=N(`RunEngine.inspect`)(function*(t){return yield*e.snapshot(t)}),v=N(`RunEngine.transcript`)(function*(t){return yield*e.transcript(t)}),y=N(`RunEngine.reconcile`)(function*(){yield*qm(yield*e.pendingWorkflowCommands,({command:e,runId:t})=>d[e](t),{discard:!0}),yield*qm(yield*e.recoverable,({runId:t,state:n,submission:r})=>A(function*(){let o=yield*QW.poll(t).pipe(i);if(D(o)&&o.value._tag===`Complete`){yield*e.reconcileCompletion(t,o.value),yield*c(t);return}if(D(o)&&o.value._tag===`Suspended`){n._tag===`Running`&&(yield*u(t));return}yield*a(r)}),{concurrency:`unbounded`,discard:!0})});return yield*y(),{approve:p,cancel:h,drain:t.drain,inspect:_,reconcile:y,retry:m,revoke:g,submit:f,transcript:v}});var dG=class extends O()(`@usine/engine/RunEngine`){},fG=Ww.make(`HEAD`),pG=class extends FC(`@usine/orchestrator/LoopAgentResolutionError`)(`LoopAgentResolutionError`,{loop:Zw,agent:WT,message:V}){},mG=N(`TriggerRouting.resolveLoop`)(function*(e,t){yield*Vh({loop:t.name,agent:t.agent});let n=new Map(e.agents.map(e=>[e.name,e])).get(t.agent);if(n===void 0)return yield*new pG({loop:t.name,agent:t.agent,message:`Loop ${t.name} references missing Agent ${t.agent}`});let r=new KT({name:n.name,brain:new LT({harness:n.harness,model:n.model,effort:n.effort}),parentModel:n.parentModel,parentEffort:n.parentEffort,persona:n.persona});return{agent:r,loop:t,parentModel:qT(r,e.config.settings.parentModel)}});N(`TriggerRouting.resolveLoops`)(function*(e){let t=[];for(let n of e.loops){let r=yield*dh(mG(e,n));if(Li(r)){t.push(r.success);continue}yield*Zh(`Loaded loop lost its rostered Agent; skipping the loop`,{loop:r.failure.loop,agent:r.failure.agent,errorTag:r.failure._tag,message:r.failure.message})}return t});var hG=e=>new dF({event:new Xw({id:Jw.make(e.dedupKey),dedupKey:e.dedupKey,payload:e.payload,receivedAt:e.receivedAt}),itemKey:e.itemKey,cycleGeneration:e.cycleGeneration,loop:e.loop.name,step:e.loop.step,approval:e.loop.approval,cycleLimit:e.loop.trigger.on===`schedule`?T():E(e.loop.maxCycles),repository:e.repository.name,revision:e.revision,task:e.task,agent:e.agent,parentModel:e.parentModel}),gG=e=>Ow(e,{Claimed:({runId:e})=>({runId:e}),Queued:()=>({}),Ignored:({reason:e})=>({reason:e}),CycleBlocked:({ask:e})=>({askId:e.id,reason:`cycle-budget-exhausted`})}),_G=e=>gi(e.expression,{onNone:()=>({configFile:e.file,configStage:e.stage}),onSome:t=>({configFile:e.file,configStage:e.stage,expression:t})}),vG=class extends H(`@usine/orchestrator/RepositoryPollFailure`)({repository:Uw,errorTag:V,message:F}){};H(`@usine/orchestrator/PollCycle`)({repositories:WS.check(VS(0)),changedItems:WS.check(VS(0)),submissions:L(vF),revokedRuns:WS.check(VS(0)),failures:L(vG),preflightFindings:L(hL),nextPollAt:YS(TC)});var yG=e=>{let t={errorTag:e._tag,message:e.message};return e._tag===`ConfigFileError`?{...t,..._G(e)}:e._tag===`ExpressionCheckError`||e._tag===`ExpressionEvaluationError`?{...t,expression:e.source}:t},bG=e=>{let t=e.flatMap(e=>gi(e,{onNone:()=>[],onSome:e=>[l_(e)]}));return t.length===0?T():r_(Math.max(...t))},xG=4,SG=6e4,CG=e=>{let t={errorTag:e._tag,message:e.message};return e._tag===`ConfigFileError`?{...t,..._G(e)}:e._tag===`ExpressionCheckError`||e._tag===`ExpressionEvaluationError`?{...t,expression:e.source}:t},wG=class extends U(`@usine/orchestrator/ScheduleAgentFailure`)(`ScheduleAgentFailure`,{loop:Zw,agent:WT,message:F}){},TG=class extends U(`@usine/orchestrator/ScheduleTickFailure`)(`ScheduleTickFailure`,{loop:Zw,repository:Uw,scheduledAt:TC,errorTag:V,message:F}){},EG=class extends U(`@usine/orchestrator/ScheduleCronFailure`)(`ScheduleCronFailure`,{loop:Zw,cron:F,tz:F,message:F}){},DG=R([wG,EG,TG]),OG=class extends H(`@usine/orchestrator/ScheduleCycle`)({loops:WS.check(VS(0)),fanout:WS.check(VS(0)),submissions:L(vF),skipped:WS.check(VS(0)),alreadyFired:WS.check(VS(0)),failures:L(DG),nextTickAt:YS(TC)}){},kG=e=>e.loops.flatMap(t=>{let n=t.trigger;return n.on===`schedule`?[{loop:t,repositories:e.config.repos.filter(e=>nR(t.selector,e)),trigger:n}]:[]}),AG=(e,t)=>{let n=c_(t);return n.setUTCSeconds(0,0),t_(vm(e,n)?n:xm(e,n))},jG=(e,t)=>t_(bm(e,c_(t))),MG=(e,t)=>gi(s_(e,t),{onNone:()=>u_(e),onSome:d_}),NG=e=>e.length===0?T():r_(Math.min(...e.map(l_))),PG=e=>CE.make(JSON.stringify([`github`,qw(e.name)])),FG=(e,t,n)=>Yw.make(JSON.stringify([e.name,qw(t.name),u_(n)])),IG=e=>({tick:{scheduledAt:u_(e.scheduledAt),scheduledAtLocal:e.scheduledAtLocal,cron:e.trigger.cron,tz:e.trigger.tz}});(class e extends O()(`@usine/orchestrator/ScheduleTriggers`){static layer=Hf(e,A(function*(){let e=yield*rU,t=yield*AL,n=yield*dG,r=yield*lG,i=yield*jw(T()),a=yield*jw(new Map),o=new WeakMap,s=e=>{let t=o.get(e);if(t!==void 0)return t;let n=_m(e.cron,e.tz);return o.set(e,n),n},c=N(`ScheduleTriggers.submitTick`)(function*(r,i){yield*Vh({loop:r.loop.name,repository:r.repository.name,agent:r.agent.name,scheduledAt:u_(r.scheduledAt)});let a=IG(r),o={repo:XR(r.repository),item:a};if(!(yield*t.evaluateBoolean(r.trigger.if,YR(`schedule`),o)))return yield*$h(`Scheduled Tick did not match its expression`,{loop:r.loop.name,repository:r.repository.name,agent:r.agent.name,scheduledAt:u_(r.scheduledAt)}),T();let s=FG(r.loop,r.repository,r.scheduledAt),c=yield*e.renderPrompt(r.loop,o),l=yield*n.submit(hG({cycleGeneration:EE.make(0),agent:r.agent,dedupKey:s,itemKey:PG(r.repository),loop:r.loop,payload:a,receivedAt:i,repository:r.repository,revision:fG,task:bE.make(c),parentModel:r.parentModel}));return yield*Qh(`Submitted scheduled Tick`,{loop:r.loop.name,repository:r.repository.name,agent:r.agent.name,scheduledAt:u_(r.scheduledAt),scheduledAtLocal:r.scheduledAtLocal,result:l._tag,...gG(l)}),E(l)}),l=N(`ScheduleTriggers.tick`)(function*(e){let t=yield*i_,n=new Set((yield*r.states).filter(e=>e.paused).map(e=>e.loop));for(let t of e.loops)t.trigger.on===`schedule`&&n.has(t.name)&&(yield*$h(`Paused Loop skipped during schedule evaluation`,{loop:t.name}));let o=kG(e).filter(({loop:e})=>!n.has(e.name)),l=yield*Mw(a),u=[],d=[],f=[],p=new Map,m=[],h=0;for(let n of o){n.repositories.length===0&&(yield*Xh(`Schedule loop selected no repositories`,{loop:n.loop.name}));let r=yield*ah({try:()=>{let e=s(n.trigger),r=AG(e,t);return{latest:r,latestLocal:MG(r,n.trigger.tz),next:jG(e,t)}},catch:e=>e}).pipe(dh);if(Ii(r)){yield*Zh(`Schedule cron boundaries could not be computed`,{loop:n.loop.name,cron:n.trigger.cron,tz:n.trigger.tz,message:String(r.failure)}),f.push(new EG({loop:n.loop.name,cron:n.trigger.cron,tz:n.trigger.tz,message:String(r.failure)}));continue}let i=r.success;m.push(i.next);let a=l_(i.latest),o=l.get(n.loop.name);if(o!==void 0&&o>=a){h+=1,yield*$h(`Tick already fired`,{loop:n.loop.name,scheduledAt:u_(i.latest)});continue}let c=yield*dh(mG(e,n.loop));if(Ii(c)){let e=c.failure;yield*Zh(`Schedule loop could not resolve its Agent`,{loop:e.loop,agent:e.agent,errorTag:e._tag,message:e.message}),d.push(new wG({loop:e.loop,agent:e.agent,message:e.message}));continue}if(n.repositories.length!==0){p.set(n.loop.name,a),yield*Qh(`Schedule tick due`,{loop:n.loop.name,agent:c.success.agent.name,cron:n.trigger.cron,tz:n.trigger.tz,scheduledAt:u_(i.latest),scheduledAtLocal:i.latestLocal,repositories:n.repositories.length,nextTickAt:u_(i.next)});for(let e of n.repositories)u.push({agent:c.success.agent,loop:n.loop,parentModel:c.success.parentModel,repository:e,scheduledAt:i.latest,scheduledAtLocal:i.latestLocal,trigger:n.trigger})}}yield*Vh({schedules:o.length,fanout:u.length});let g=yield*qm(u,e=>dh(c(e,t)).pipe(ph(t=>({candidate:e,result:t}))),{concurrency:xG}),_=[],v=[],y=new Set,b=new Set,x=0;for(let{candidate:e,result:t}of g){if(Li(t)){D(t.success)?(_.push(t.success.value),y.add(e.loop.name)):x+=1;continue}let n=t.failure;b.add(e.loop.name),yield*Zh(`Scheduled Tick failed; sibling fanout was unaffected`,{loop:e.loop.name,repository:e.repository.name,agent:e.agent.name,scheduledAt:u_(e.scheduledAt),...CG(n)}),v.push(new TG({loop:e.loop.name,repository:e.repository.name,scheduledAt:e.scheduledAt,errorTag:n._tag,message:n.message}))}yield*Fw(a,e=>{let t=new Map(e);for(let[e,n]of p)y.has(e)&&!b.has(e)&&t.set(e,n);return t});let ee=new OG({loops:o.length,fanout:u.length,submissions:_,skipped:x,alreadyFired:h,failures:[...d,...f,...v],nextTickAt:NG(m)});return yield*Nw(i,E(ee)),ee});return{latest:Mw(i),run:e=>A(function*(){let t=yield*dh(l(e));if(Ii(t)){yield*Zh(`Schedule cycle could not read Loop runtime state; retrying`,{errorTag:t.failure._tag,message:t.failure.message,operation:t.failure.operation,sleepMs:SG}),yield*Sh(Ro(SG));return}let n=t.success,r=yield*Zf,i=gi(n.nextTickAt,{onNone:()=>r+SG,onSome:l_}),a=Math.min(SG,Math.max(0,i-r)),o={loops:n.loops,fanout:n.fanout,submissions:n.submissions.length,skipped:n.skipped,alreadyFired:n.alreadyFired,failures:n.failures.length,nextTickAt:gi(n.nextTickAt,{onNone:()=>`none`,onSome:u_}),sleepMs:a};n.fanout===0&&n.failures.length===0?yield*$h(`Schedule cycle complete`,o):yield*Qh(`Schedule cycle complete`,o),yield*Sh(Ro(a))}).pipe(Bh),tick:l}}))});var LG=class extends U(`@usine/orchestrator/ApprovalNeed`)(`ApprovalNeed`,{id:F,repository:Uw,runId:jT,loop:Zw}){},RG=class extends U(`@usine/orchestrator/RunFailureNeed`)(`RunFailureNeed`,{id:F,repository:Uw,runId:jT,loop:Zw,failure:Nj}){},zG=class extends U(`@usine/orchestrator/PollFailureNeed`)(`PollFailureNeed`,{id:F,failure:vG}){},BG=class extends U(`@usine/orchestrator/PreflightFindingNeed`)(`PreflightFindingNeed`,{id:F,finding:hL}){},VG=class extends U(`@usine/orchestrator/BoardProjectionNeed`)(`BoardProjectionNeed`,{id:F,failure:Qj}){},HG=class extends U(`@usine/orchestrator/ScheduleFailureNeed`)(`ScheduleFailureNeed`,{id:F,failure:DG}){},UG=R([class extends U(`CycleBudgetNeed`)(`CycleBudgetNeed`,{id:F,ask:jE,itemLabel:F,itemUrl:CS(F)}){},LG,VG,RG,zG,BG,HG]),WG=SS([`clear`,`active`,`needs-you`]),GG=class extends H(`@usine/orchestrator/ProjectView`)({repository:Uw,status:WG,runs:L(Wj),board:$j,labels:L(eM),preflightFindings:L(hL)}){},KG=class extends H(`@usine/orchestrator/LoopView`)({name:Zw,trigger:F,agent:WT,paused:dS}){},qG=R([class extends U(`@usine/orchestrator/ReadyOverview`)(`Ready`,{projects:L(GG),loops:L(KG),needsYou:L(UG)}){},class extends U(`@usine/orchestrator/NeedsSetupOverview`)(`NeedsSetup`,{errorTag:V,projects:L(GG),loops:L(KG),needsYou:L(UG)}){}]),JG={SchemaError:400,InvalidRequestError:400,CrossSiteRequestError:403,RunNotFoundError:404,TranscriptAttemptNotFoundError:404,BoardProjectNotFoundError:404,BoardItemNotFoundError:404,BoardLaneNotFoundError:404,RunOperationRejectedError:409,CycleBudgetResetRejectedError:409,BoardLaneReadOnlyError:409,EnginePersistenceError:500,AttemptCancellationError:500,HttpBodyError:500,GitHubApiError:502,InvalidGitHubResponseError:502,BackendUnavailableError:503,InstallationDiscoveryError:503,AppPermissionError:503,GitHubRateLimitError:503},YG=class extends PC(`@usine/orchestrator/OperatorHttpError`)({error:SS(Gi(JG)),message:F}){get status(){return JG[this.error]}},XG=[...new Set(Object.values(JG))].map(e=>YG.check(PS(t=>t.status===e)).annotate({httpApiStatus:e})),ZG=class extends HA()(`@usine/orchestrator/OperatorHttpPolicy`,{error:XG}){},QG=tS(oS),$G=R([F,bS(F).pipe(B(F,R_({decode:e=>e[0],encode:e=>[e]})))]),eK=$G.pipe(B(SC),B(XE)),tK=R([I({after:QG,before:QG,attempt:QG}).pipe(B(rS(zj),R_({decode:()=>new zj,encode:()=>({})}))),I({after:eK,before:QG,attempt:QG}).pipe(B(rS(Bj),R_({decode:({after:e})=>new Bj({after:e}),encode:({after:e})=>({after:e})}))),I({after:QG,before:eK,attempt:$G.pipe(B(vE))}).pipe(B(rS(Vj),R_({decode:({before:e,attempt:t})=>new Vj({before:e,attemptId:t}),encode:({before:e,attemptId:t})=>({before:e,attempt:t})})))]),nK=F.check(FS(/^[A-Za-z0-9_.-]+$/u,{message:`Expected a repository path segment`})),rK=I({ok:aS(!0)}),iK={runId:jT},aK={loop:Zw},oK=EA(`OperatorApi`).add(Sj(`operator`).add(bA(`overview`,`/api/overview`,{success:qG}),xA(`resetCycleBudget`,`/api/cycle-budgets/reset`,{payload:I({askId:AE}).annotate({parseOptions:{onExcessProperty:`error`}}),success:rK}),bA(`detail`,`/api/runs/:runId`,{params:iK,query:tK,success:Gj}),xA(`approve`,`/api/runs/:runId/approve`,{params:iK,success:rK}),xA(`retry`,`/api/runs/:runId/retry`,{params:iK,success:rK}),xA(`cancel`,`/api/runs/:runId/cancel`,{params:iK,success:rK}),xA(`moveBoardItem`,`/api/projects/:owner/:repository/items/:item/lane`,{params:{owner:nK,repository:nK,item:SC.pipe(B(wE))},payload:I({toLane:Kj}).annotate({parseOptions:{onExcessProperty:`error`}}),success:rK}),xA(`pause`,`/api/loops/:loop/pause`,{params:aK,success:rK}),xA(`unpause`,`/api/loops/:loop/unpause`,{params:aK,success:rK})).middleware(ZG)),sK=()=>GA(oK,{baseUrl:globalThis.location.origin}),cK=e=>Kh(M(sK(),t=>e(t.operator)).pipe(Dh(YF))),lK=a(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-2.5!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border bg-input/20 text-foreground dark:bg-input/30 [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function uK({className:e,variant:t=`default`,render:n,...i}){return NT({defaultTagName:`span`,props:o({className:r(lK({variant:t}),e)},i),render:n,state:{slot:`badge`,variant:t}})}export{Vj as $,x as $n,nS as $t,RI as A,Ei as An,XS as At,CF as B,Qe as Bn,B as Bt,ZI as C,k as Cn,XC as Ct,BI as D,Hf as Dn,V as Dt,II as E,Zf as En,SS as Et,KF as F,Ti as Fn,yS as Ft,rN as G,Te as Gn,bC as Gt,NF as H,Pe as Hn,qx as Ht,RF as I,gi as In,R as It,VM as J,be as Jn,LS as Jt,PM as K,we as Kn,Vx as Kt,wF as L,T as Ln,sS as Lt,FI as M,_i as Mn,F as Mt,AI as N,hi as Nn,I as Nt,zI as O,O as On,CS as Ot,UF as P,D as Pn,U as Pt,zj as Q,ee as Qn,FS as Qt,TF as R,E as Rn,z as Rt,rL as S,qh as Sn,WS as St,PI as T,Uh as Tn,aS as Tt,Q as U,Ae as Un,gS as Ut,MF as V,Re as Vn,Hx as Vt,zN as W,ke as Wn,$x as Wt,J as X,ne as Xn,qS as Xt,NM as Y,_ as Yn,VS as Yt,Gj as Z,te as Zn,GS as Zt,eL as _,Xh as _n,Ow as _t,yG as a,r_ as an,me as ar,vO as at,$I as b,xh as bn,H as bt,UU as c,Vh as cn,EE as ct,vL as d,ih as dn,NT as dt,tS as en,g as er,Bj as et,sL as f,N as fn,jT as ft,uL as g,Qh as gn,Kw as gt,aL as h,Zh as hn,qw as ht,bG as i,u_ as in,ge as ir,_O as it,UI as j,yi as jn,_S as jt,HI as k,Ii as kn,uS as kt,EU as l,mh as ln,CE as lt,oL as m,$h as mn,Uw as mt,cK as n,rS as nn,b as nr,FO as nt,qU as o,n_ as on,d as or,xO as ot,lL as p,A as pn,xT as pt,Y as q,xe as qn,HS as qt,vG as r,y_ as rn,oe as rr,MO as rt,HU as s,l_ as sn,u as sr,XE as st,uK as t,Bx as tn,re as tr,JO as tt,TU as u,gh as un,wE as ut,tL as v,ph as vn,L as vt,MI as w,ah as wn,ZC as wt,iL as x,dh as xn,EC as xt,QI as y,bh as yn,dS as yt,SF as z,nt as zn,Jx as zt};
|