@reddb-io/red-skills 2.53.1 → 2.55.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.
@@ -19,13 +19,13 @@ ${n}
19
19
  `)}function Cxe(e,t){let r=am(e),n=Gmt(t);return Mmt(n.replacer?Wmt(r,n.replacer):r,n,0)}function Gmt(e){return{indent:e?.indent??2,delimiter:e?.delimiter??nw,keyFolding:e?.keyFolding??"off",flattenDepth:e?.flattenDepth??Number.POSITIVE_INFINITY,replacer:e?.replacer}}var Cmt,Axe,nw,vmt,Rmt,Nbr,gJ=h(()=>{Cmt="null",Axe={comma:",",tab:" ",pipe:"|"},nw=Axe.comma;vmt=/^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,Rmt=/^0\d+$/;Nbr=Symbol("quotedKey")});function zmt(e){return Object.entries(e).filter(([t])=>t!=="summary")}function _M(e,t,r){return ji(Object.fromEntries([...zmt(e),["summary",t]]),r)}var Ng=h(()=>{"use strict";gJ();gJ()});function wxe(e){if(e===void 0||e.trim()==="")return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}function Vmt(e,t){if(t===void 0||t<=0)return;let r=Math.max(0,e),n=r/t;return{tier:n>=1?"HARD_STOP":n>=.9?"CRITICAL":n>=.75?"WARNING":"OK",spentUsd:r,limitUsd:t,percent:n}}function ow(e=process.env,t=()=>""){let r=(n,o)=>{let i=e[n];return i!==void 0&&/^[0-9]+$/.test(i)?Number(i):o};return{target:r("RED_AFK_TARGET",Lr.target),fastDeathThresholdS:r("RED_AFK_FAST_DEATH_S",Lr.fastDeathThresholdS),circuitK:r("RED_AFK_CIRCUIT_K",Lr.circuitK),circuitWindowS:r("RED_AFK_CIRCUIT_WINDOW_S",Lr.circuitWindowS),stallThresholdS:r("RED_AFK_STALL_THRESHOLD_S",Lr.stallThresholdS),stallKillThresholdS:r("RED_AFK_STALL_KILL_THRESHOLD_S",Lr.stallKillThresholdS),runner:e.RED_AFK_RUNNER&&e.RED_AFK_RUNNER.length>0?e.RED_AFK_RUNNER:Lr.runner,pollIntervalS:r("RED_AFK_POLL_S",Lr.pollIntervalS),eventFallbackS:r("RED_AFK_WAKE_FALLBACK_S",Lr.eventFallbackS)||Lr.eventFallbackS,tickTimeoutS:r("RED_AFK_TICK_TIMEOUT_S",Lr.tickTimeoutS)||Lr.tickTimeoutS,supervisorStaleS:r("RED_AFK_SUPERVISOR_STALE_S",Lr.supervisorStaleS)||Lr.supervisorStaleS,progressStaleS:r("RED_AFK_SUPERVISOR_PROGRESS_STALE_S",Lr.progressStaleS)||Lr.progressStaleS,halfOpenBaseS:r("RED_AFK_HALF_OPEN_BASE_S",Lr.halfOpenBaseS),halfOpenCapS:r("RED_AFK_HALF_OPEN_CAP_S",Lr.halfOpenCapS),unblockSweepIntervalS:r("RED_AFK_UNBLOCK_SWEEP_INTERVAL_S",Lr.unblockSweepIntervalS)||Lr.unblockSweepIntervalS,supervisorMaxRestarts:r("RED_AFK_SUPERVISOR_MAX_RESTARTS",Lr.supervisorMaxRestarts)||Lr.supervisorMaxRestarts,supervisorRestartWindowS:r("RED_AFK_SUPERVISOR_RESTART_WINDOW_S",Lr.supervisorRestartWindowS)||Lr.supervisorRestartWindowS,drainBudgetUsd:wxe(e.RED_AFK_DRAIN_MAX_COST_USD)??wxe(t("afk.drain.max_cost_usd")),reapContestWindowS:r("RED_AFK_REAP_CONTEST_WINDOW_S",Lr.reapContestWindowS)}}function xJ(e){if(e.stallKillThresholdS<=e.stallThresholdS)throw new Error(`RED_AFK_STALL_KILL_THRESHOLD_S (${e.stallKillThresholdS}) must be > RED_AFK_STALL_THRESHOLD_S (${e.stallThresholdS})`)}function Ymt(e){if(e.supervisorStaleS<=e.tickTimeoutS)throw new Error(`RED_AFK_SUPERVISOR_STALE_S (${e.supervisorStaleS}) must be > RED_AFK_TICK_TIMEOUT_S (${e.tickTimeoutS})`)}function Jmt(e){if(e.progressStaleS<=e.supervisorStaleS)throw new Error(`RED_AFK_SUPERVISOR_PROGRESS_STALE_S (${e.progressStaleS}) must be > RED_AFK_SUPERVISOR_STALE_S (${e.supervisorStaleS})`)}function BM(e,t,r,n){return e.pid===null||!e.pidAlive?"absent":e.lastHeartbeatEpoch===null?"healthy":t-e.lastHeartbeatEpoch>=r||e.lastProgressEpoch!==null&&t-e.lastProgressEpoch>=n&&e.slotsBusy>0?"quiescent":"healthy"}function Kmt(e,t,r,n){let o=r-t;if(!(t>0&&o<n.fastDeathThresholdS))return{deaths:[...e],count:e.length,fastDeath:!1,trip:!1};let s=[...e,r].filter(c=>r-c<=n.circuitWindowS),a=s.length;return{deaths:s,count:a,fastDeath:!0,trip:a>=n.circuitK}}function Zmt(){return{pid:null,spawnEpoch:0,deaths:[],parked:!1,tripEpoch:0,swept:!1,stalled:!1,stallSinceEpoch:0,reaped:!1,spawning:!1,idleParked:!1,backoffStep:0,halfOpen:!1,contest:null}}function vxe(e){return{slots:Array.from({length:e},()=>Zmt()),lastProgressEpoch:0,lastUnblockSweepEpoch:0,wakeStats:Xye(),drainBudgetHardStopped:!1}}function Xmt(e,t,r,n,o){let i=[`slot: ${t}`,`worker IDs: ${r}`,`fast deaths: ${n}`,`supervisor log: ${o}`].join(`
20
20
  `);return YC({status:"discarded",worker:e,duration:`runner-broken, slot parked after ${n} fast deaths`,diff:"discarded",attempt:1,sections:[{name:"summary",body:i}]})}function eht(e){return YC({status:"no-sentinel",worker:e.workerId.length>0?e.workerId:"unknown",duration:`${e.durationS}s \xB7 stall-reaped`,diff:"stall-reaped",attempt:e.attempt,sections:[{name:"notes",body:e.notes.length>0?e.notes:"(no agent notes recorded before stall-reap)"},{name:"log",body:e.logTail,fenced:!0}]})}function tht(e){return YC({status:"no-sentinel",worker:e.workerId.length>0?e.workerId:"unknown",duration:`${e.durationS}s \xB7 orchestrator died mid-attempt`,diff:"crashed",attempt:e.attempt,sections:[{name:"notes",body:e.notes.length>0?e.notes:"(no agent notes recorded before the orchestrator died)"},{name:"log",body:e.logTail,fenced:!0}]})}function rht(e){return e.issue!==null&&e.ghOk&&e.stillRunning}async function Ixe(e,t){if(e===null||e.issue===null||!t.gh.crashedClaimState)return null;let r;try{r=await t.gh.crashedClaimState(e.issue)}catch{return null}if(!rht({issue:e.issue,ghOk:r.ghOk,stillRunning:r.stillRunning}))return null;r.envelopePosted||await t.gh.comment(e.issue,tht(e));let n=af("no-sentinel",e.attempt,t.recoveryEnv??{});return n.decision==="retry"?await t.gh.editLabels(e.issue,n.addLabels,n.removeLabels):(n.typedLabel!==null&&await t.gh.ensureLabel(n.typedLabel),await t.gh.editLabels(e.issue,n.addLabels,[...n.removeLabels,Je]),n.escalationComment!==null&&await t.gh.comment(e.issue,n.escalationComment)),e.issue}function nht(e,t){let r=0,n=0,o=0;for(let i of e.slots)i.parked||i.idleParked?o+=1:i.pid===null?n+=1:t.proc.isAlive(i.pid)?r+=1:n+=1;return{slotsBusy:r,slotsFree:n,slotsTotal:e.slots.length,slotsParked:o}}function oht(e){return new Date(e*1e3).toISOString()}function iht(e,t){let r=[];for(let n=0;n<e.slots.length;n++){let o=e.slots[n];if(o.idleParked)r.push({index:n,status:"idle-parked"});else if(o.parked&&o.halfOpen)r.push({index:n,status:"half-open"});else if(o.parked){let i=o.tripEpoch>0?o.tripEpoch+KR(o.backoffStep,t):void 0;r.push({index:n,status:"open",...i!==void 0?{retryAt:i}:{}})}}return r}async function sht(e,t,r,n,o){let i=r.queueDepth,s=t.now(),a={ts:oht(s),epoch:s,lastProgressEpoch:e.lastProgressEpoch,runner:n,readyForAgent:i,...nht(e,t),spawnsThisTick:r.respawned.length,...r.drainBudget?{drainBudget:r.drainBudget}:{},slotDetails:iht(e,o)};try{await t.emitFleetHeartbeat?.(a)}catch{}return a}async function aht(e,t,r,n){if(t.swept)return;t.swept=!0;let o=r.fs.parkedSlotWork(e,t.pid),i=o.workers.map(c=>c.workerId).join(","),s=t.deaths.length;if(r.dispatchFleetHook)try{await r.dispatchFleetHook("on_circuit_trip",{event:"on_circuit_trip",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{},...i.length>0?{worker_ids:i}:{},death_count:s,supervisor_log:o.supervisorLogPath})}catch{}if(o.workers.length===0)return;o.workers.some(c=>c.pairs.some(u=>u.issue!==null))&&await r.gh.ensureRunnerErrorLabel();for(let c of o.workers)for(let u of c.pairs){if(u.issue!==null){let l=Xmt(n.runner,e,i,s,o.supervisorLogPath);await r.gh.comment(u.issue,l),await r.gh.editLabels(u.issue,[Je,dxe],[rt,ze])}await r.fs.removeDir(u.dir)}}async function cht(e,t,r,n=Lr){if(t.reaped)return;t.reaped=!0;let o=t.pid,i=r.fs.resolveIterDir(e),s=!0;if(o!==null&&r.proc.isAlive(o)&&(s=await r.proc.killTree(o)!==!1),t.pid=null,t.stalled=!1,t.stallSinceEpoch=0,i&&i.issue!==null){await r.gh.comment(i.issue,eht(i));let a=af("stalled",i.attempt,r.recoveryEnv??{});a.decision==="retry"?await uht(e,t,i,r,n.reapContestWindowS)||await r.gh.editLabels(i.issue,a.addLabels,a.removeLabels):(a.typedLabel!==null&&await r.gh.ensureLabel(a.typedLabel),await r.gh.editLabels(i.issue,a.addLabels,[...a.removeLabels,Je]),a.escalationComment!==null&&await r.gh.comment(i.issue,a.escalationComment))}i&&s&&await r.fs.teardownIterDir(i)}async function Rxe(e,t){try{return await e.attemptBranchHead?.(t)}catch{return}}function AJ(e,t,r){e.log?.(ji({schema_version:"red.afk.reap_contest.v1",event:t,...r}))}async function uht(e,t,r,n,o){if(r.issue===null||!r.branch||o<=0)return!1;let i=n.now(),s=i+o,a=await Rxe(n,r.branch);return sm({edge:"contest",fromLabels:[ze],removeLabels:[],addLabels:[Sa]}),await n.gh.editLabels(r.issue,[Sa],[]),t.contest={issue:r.issue,branch:r.branch,headAtReap:a,openedEpoch:i,deadlineEpoch:s},AJ(n,"opened",{slot:e,issue:r.issue,branch:r.branch,head_at_reap:a,deadline_epoch:s}),!0}async function lht(e,t,r,n=Lr){let o=t.contest;if(o===null)return null;let i=r.now(),s=await Rxe(r,o.branch);return i<=o.deadlineEpoch&&o.headAtReap!==void 0&&s!==void 0&&s!==o.headAtReap?(sm({edge:"contest-reclaimed",fromLabels:[ze,Sa],removeLabels:[Sa],addLabels:[]}),await r.gh.editLabels(o.issue,[],[Sa]),t.contest=null,AJ(r,"reclaimed",{slot:e,issue:o.issue,branch:o.branch,head_at_reap:o.headAtReap,head_at_resolution:s}),"reclaimed"):i<o.deadlineEpoch?"pending":(sm({edge:"contest-expired",fromLabels:[ze,Sa],removeLabels:[ze,Sa],addLabels:[Je]}),await r.gh.editLabels(o.issue,[Je],[ze,Sa]),t.contest=null,AJ(r,"expired",{slot:e,issue:o.issue,branch:o.branch,head_at_reap:o.headAtReap,head_at_resolution:s}),"expired")}async function dht(e,t,r){let n=t.now(),o=[];for(let i=0;i<e.slots.length;i+=1){let s=e.slots[i];if(s.parked||s.idleParked||!(s.spawnEpoch>0)||!(n-s.spawnEpoch>=r.stallThresholdS))continue;let a=t.fs.workerLivenessVerdict(i,r.stallThresholdS*1e3);if(a!==null&&a.status==="stalled"){if(!s.stalled){s.stalled=!0;let l=a.laneAgeMs!==void 0?n-Math.round(a.laneAgeMs/1e3):n;if(s.stallSinceEpoch=l,t.dispatchFleetHook)try{await t.dispatchFleetHook("on_stall_detected",{event:"on_stall_detected",runner:r.runner,slot:i,...s.pid!==null?{pid:s.pid}:{},stall_since:l,idle_seconds:a.laneAgeMs!==void 0?Math.round(a.laneAgeMs/1e3):0})}catch{}}let u=s.stallSinceEpoch;if(u>0&&n-u>=r.stallKillThresholdS&&!s.reaped){let l=s.pid,d=l!==null?VC(t.proc.inspectTree(l)):{activeDescendant:!1,cpuPct:0};if(xM({idleSeconds:n-u,idleThresholdSeconds:r.stallKillThresholdS,activeDescendant:d.activeDescendant,cpuPct:d.cpuPct})==="kill"){let p=!1;if(t.dispatchFleetHook)try{p=(await t.dispatchFleetHook("on_stall_reap",{event:"on_stall_reap",runner:r.runner,slot:i,...l!==null?{pid:l}:{},idle_seconds:n-u,stall_since:u})).vetoed}catch{}p||(await cht(i,s,t,r),o.push(i))}}}else s.stalled&&(s.stalled=!1,s.stallSinceEpoch=0)}return o}function _xe(e,t,r){if(r.drainBudgetUsd===void 0)return;let n=0;try{n=t.fs.fleetCostUsd?.()??0}catch{n=0}let o=Vmt(n,r.drainBudgetUsd);return o?.tier==="HARD_STOP"&&(e.drainBudgetHardStopped=!0),o}function Bxe(e,t,r,n){!r||e.lastDrainBudgetTier===r.tier||(e.lastDrainBudgetTier=r.tier,t.log?.(ji({schema_version:"red.afk.drain_budget.v1",tier:r.tier,spent_usd:Number(r.spentUsd.toFixed(4)),limit_usd:Number(r.limitUsd.toFixed(4)),percent:Number((r.percent*100).toFixed(2)),ready_for_agent:n,action:r.tier==="HARD_STOP"?"hard_stop_no_new_spawns_inflight_finish":r.tier==="CRITICAL"?"new_spawns_downgrade_one_model_tier":"observe"})))}function Txe(e,t){if(e.drainBudgetHardStopped||t?.tier==="HARD_STOP")return"hard-stop";if(t?.tier==="CRITICAL")return{taskTierDowngrade:!0}}async function yJ(e,t,r,n){let o=Txe(r,n);return o==="hard-stop"?null:o?t.proc.spawnSlot(e,o):t.proc.spawnSlot(e)}async function fht(e,t,r,n,o=0,i){let s=async()=>i==="hard-stop"?null:i?r.proc.spawnSlot(e,i):r.proc.spawnSlot(e);if(t.parked&&t.halfOpen){let d=r.now(),f=t.spawnEpoch>0?d-t.spawnEpoch:0,p=t.spawnEpoch>0&&f<n.fastDeathThresholdS;if(t.halfOpen=!1,t.pid=null,p)return t.backoffStep++,t.tripEpoch=d,r.log?.(`circuit re-parked: slot ${e} probe fast-death (${f}s), next backoff=${KR(t.backoffStep,n)}s step=${t.backoffStep}`),{parked:!0};t.parked=!1,t.backoffStep=0,t.tripEpoch=0,t.swept=!1,t.deaths=[],r.log?.(`circuit closed: slot ${e} probe succeeded (${f}s), backoff reset`),t.spawning=!0;try{let m=await s();if(m===null)return{parked:!0};t.pid=m.pid,t.spawnEpoch=m.spawnEpoch}finally{t.spawning=!1}if(t.stalled=!1,t.stallSinceEpoch=0,t.reaped=!1,r.dispatchFleetHook)try{await r.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{}})}catch{}return{parked:!1}}if((r.proc.lastExitCode?.(e)??null)===0){if(o===0)return t.pid=null,t.idleParked=!0,{parked:!0};t.spawning=!0;try{let d=await s();if(d===null)return t.pid=null,{parked:!0};t.pid=d.pid,t.spawnEpoch=d.spawnEpoch}finally{t.spawning=!1}if(t.stalled=!1,t.stallSinceEpoch=0,t.reaped=!1,r.dispatchFleetHook)try{await r.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{}}),await r.dispatchFleetHook("on_respawn",{event:"on_respawn",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{}})}catch{}return{parked:!1}}let u=r.now(),l=Kmt(t.deaths,t.spawnEpoch,u,n);if(t.deaths=l.deaths,l.trip)return t.parked=!0,t.tripEpoch=u,await aht(e,t,r,n),t.pid=null,{parked:!0};t.spawning=!0;try{let d=await s();if(d===null)return t.pid=null,{parked:!0};t.pid=d.pid,t.spawnEpoch=d.spawnEpoch}finally{t.spawning=!1}if(t.stalled=!1,t.stallSinceEpoch=0,t.reaped=!1,r.dispatchFleetHook)try{await r.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{}}),await r.dispatchFleetHook("on_respawn",{event:"on_respawn",runner:n.runner,slot:e,...t.pid!==null?{pid:t.pid}:{}})}catch{}return{parked:!1}}async function pht(e,t){if(!t.proc.spawnReconcileWorker||!t.gh.findReconcileCandidate)return null;let r=e.slots.findIndex(s=>!s.parked&&s.pid===null);if(r<0)return null;let n=null;try{n=await t.gh.findReconcileCandidate()}catch{return null}if(n===null)return null;let o=await t.proc.spawnReconcileWorker(r,n),i=e.slots[r];return i.pid=o.pid,i.spawnEpoch=o.spawnEpoch,i.stalled=!1,i.stallSinceEpoch=0,i.reaped=!1,r}async function mht(e,t,r,n){let o={respawned:[],deaths:[],parked:[],idleParked:[],halfOpened:[],reaped:[],crashReconciled:[],reconciledSlots:[],unblocked:[],stopped:!1,queueDepth:0,abandoned:!1};if(n())return await hht(e,t),o.stopped=!0,o;let i=0;try{i=await t.gh.readyQueueDepth?.()??0}catch{i=0}o.queueDepth=i;let s=_xe(e,t,r);o.drainBudget=s,Bxe(e,t,s,i);let a=Txe(e,s);for(let u=0;u<e.slots.length;u+=1)await lht(u,e.slots[u],t,r);for(let u=0;u<e.slots.length;u+=1){let l=e.slots[u];if(!(!l.idleParked||i===0)&&a!=="hard-stop"){l.idleParked=!1,l.spawning=!0;try{let d=await yJ(u,t,e,s);if(d===null)continue;l.pid=d.pid,l.spawnEpoch=d.spawnEpoch,l.stalled=!1,l.stallSinceEpoch=0,l.reaped=!1}finally{l.spawning=!1}if(o.respawned.push(u),t.dispatchFleetHook)try{await t.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:r.runner,slot:u,...l.pid!==null?{pid:l.pid}:{}})}catch{}}}{let u=t.now();for(let l=0;l<e.slots.length;l+=1){let d=e.slots[l];if(!(!d.parked||d.halfOpen||d.spawning)&&a!=="hard-stop"&&mxe(d.tripEpoch,d.backoffStep,u,r)){t.log?.(`circuit half-open: slot ${l} cooldown expired, spawning probe (backoff=${KR(d.backoffStep,r)}s step=${d.backoffStep})`),d.halfOpen=!0,d.spawning=!0;try{let f=await yJ(l,t,e,s);if(f===null)continue;d.pid=f.pid,d.spawnEpoch=f.spawnEpoch,d.stalled=!1,d.stallSinceEpoch=0,d.reaped=!1}finally{d.spawning=!1}if(o.halfOpened.push(l),t.dispatchFleetHook)try{await t.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:r.runner,slot:l,...d.pid!==null?{pid:d.pid}:{}})}catch{}}}}for(let u=0;u<e.slots.length;u+=1){let l=e.slots[u];if(l.parked&&!l.halfOpen||l.idleParked||l.spawning)continue;let d=l.pid;if(d===null||!t.proc.isAlive(d)){if(d!==null&&t.log?.(`dead slot reconciled: slot ${u} pid=${d}`),t.dispatchFleetHook)try{await t.dispatchFleetHook("on_slot_death",{event:"on_slot_death",runner:r.runner,slot:u,...d!==null?{pid:d}:{}})}catch{}let f=t.fs.resolveIterDir(u);if(o.deaths.push(u),a==="hard-stop"){l.pid=null,l.stalled=!1,l.stallSinceEpoch=0,l.reaped=!1;try{let m=await Ixe(f,t);m!==null&&o.crashReconciled.push(m)}catch{}continue}let{parked:p}=await fht(u,l,t,r,i,a);if(p)l.idleParked?o.idleParked.push(u):o.parked.push(u);else{o.respawned.push(u);try{let m=await Ixe(f,t);m!==null&&o.crashReconciled.push(m)}catch{}}}}let c=await dht(e,t,r);if(o.reaped=c,a!=="hard-stop"){let u=await pht(e,t);u!==null&&o.reconciledSlots.push(u)}if(t.unblockSweep){let u=t.now();if(e.lastUnblockSweepEpoch===0||u-e.lastUnblockSweepEpoch>=r.unblockSweepIntervalS){e.lastUnblockSweepEpoch=u;try{o.unblocked=await t.unblockSweep()}catch{}}}return o}async function hht(e,t){for(let r of e.slots){let n=r.pid;n!==null&&t.proc.isAlive(n)&&await t.proc.killTree(n)}}async function Dxe(e,t,r,n){if(xJ(r),Ymt(r),Jmt(r),t.bootSweeps)try{await t.bootSweeps()}catch(i){t.log?.(`boot sweeps failed: ${i instanceof Error?i.message:String(i)} \u2014 spawning workers anyway`)}if(t.dispatchFleetHook){let i=!1;try{i=(await t.dispatchFleetHook("pre_fleet",{event:"pre_fleet",runner:r.runner})).aborted}catch(s){t.log?.(`pre_fleet hook threw: ${s instanceof Error?s.message:String(s)} \u2014 spawning workers anyway`)}if(i){t.log?.("pre_fleet hook aborted boot \u2014 fleet will not spawn");return}}let o=_xe(e,t,r);Bxe(e,t,o,0);for(let i=0;i<e.slots.length;i+=1){let s=e.slots[i],a=await yJ(i,t,e,o);if(a!==null&&(s.pid=a.pid,s.spawnEpoch=a.spawnEpoch,t.dispatchFleetHook))try{await t.dispatchFleetHook("on_slot_spawn",{event:"on_slot_spawn",runner:r.runner,slot:i,...s.pid!==null?{pid:s.pid}:{}})}catch{}}for(;;){let i=await ght(()=>mht(e,t,r,n),r.tickTimeoutS*1e3,t.proc.sleep,t.log);i.abandoned||(e.lastProgressEpoch=t.now());let s=await sht(e,t,i,r.runner,r);if(t.log?.(`tick: slots=${e.slots.length} respawned=${i.respawned.length} deaths=${i.deaths.length} parked=${i.parked.length} idle-parked=${i.idleParked.length} half-opened=${i.halfOpened.length} reaped=${i.reaped.length} unblocked=${i.unblocked.length} crash-reconciled=${i.crashReconciled.length} ready=${s.readyForAgent} busy=${s.slotsBusy} free=${s.slotsFree}`),i.stopped){if(t.dispatchFleetHook)try{await t.dispatchFleetHook("post_fleet",{event:"post_fleet",runner:r.runner})}catch(u){t.log?.(`post_fleet hook threw: ${u instanceof Error?u.message:String(u)}`)}return}let a=t.wake?r.eventFallbackS:r.pollIntervalS,c=await Zye({fallbackMs:a*1e3,sleep:t.proc.sleep,wake:t.wake});exe(e.wakeStats,c),c==="event"&&t.log?.(`wake: event-driven (idle wakes reduced \u2014 ${e.wakeStats.event}/${e.wakeStats.total} wakes event-driven)`)}}function kxe(){return{respawned:[],deaths:[],parked:[],idleParked:[],halfOpened:[],reaped:[],crashReconciled:[],reconciledSlots:[],unblocked:[],stopped:!1,queueDepth:0,abandoned:!0}}async function ght(e,t,r,n){let o=Symbol("tick-timeout");try{let i=await Promise.race([e(),r(t).then(()=>o)]);return i===o?(n?.(`tick exceeded ${Math.round(t/1e3)}s \u2014 abandoning this pass, loop continues`),kxe()):i}catch(i){return n?.(`tick threw: ${i instanceof Error?i.message:String(i)} \u2014 loop continues`),kxe()}}var Lr,iw=h(()=>{"use strict";EM();txe();oJ();wM();un();kM();hxe();Ng();Lr={target:2,fastDeathThresholdS:30,circuitK:5,circuitWindowS:90,stallThresholdS:600,stallKillThresholdS:1800,runner:"claude",pollIntervalS:15,eventFallbackS:60,tickTimeoutS:120,supervisorStaleS:300,progressStaleS:900,halfOpenBaseS:pJ.halfOpenBaseS,halfOpenCapS:pJ.halfOpenCapS,unblockSweepIntervalS:60,supervisorMaxRestarts:5,supervisorRestartWindowS:300,reapContestWindowS:30}});import{createHash as xht}from"node:crypto";import{hostname as Eht}from"node:os";function Sht(e){return xht("md5").update(e).digest("hex").slice(0,bht)}function bJ(){return Sht(Eht())}function e_(){return`${bJ()}:`}function Oxe(e){return`${e_()}${e}`}var bht,TM=h(()=>{"use strict";bht=12});var rr,SJ,Be,uf,t_=h(()=>{(function(e){e.assertEqual=o=>{};function t(o){}e.assertIs=t;function r(o){throw new Error}e.assertNever=r,e.arrayToEnum=o=>{let i={};for(let s of o)i[s]=s;return i},e.getValidEnumValues=o=>{let i=e.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),s={};for(let a of i)s[a]=o[a];return e.objectValues(s)},e.objectValues=o=>e.objectKeys(o).map(function(i){return o[i]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let i=[];for(let s in o)Object.prototype.hasOwnProperty.call(o,s)&&i.push(s);return i},e.find=(o,i)=>{for(let s of o)if(i(s))return s},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,i=" | "){return o.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(rr||(rr={}));(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(SJ||(SJ={}));Be=rr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),uf=e=>{switch(typeof e){case"undefined":return Be.undefined;case"string":return Be.string;case"number":return Number.isNaN(e)?Be.nan:Be.number;case"boolean":return Be.boolean;case"function":return Be.function;case"bigint":return Be.bigint;case"symbol":return Be.symbol;case"object":return Array.isArray(e)?Be.array:e===null?Be.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Be.promise:typeof Map<"u"&&e instanceof Map?Be.map:typeof Set<"u"&&e instanceof Set?Be.set:typeof Date<"u"&&e instanceof Date?Be.date:Be.object;default:return Be.unknown}}});var pe,Cht,Ca,DM=h(()=>{t_();pe=rr.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Cht=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Ca=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(i){return i.message},n={_errors:[]},o=i=>{for(let s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(o);else if(s.code==="invalid_return_type")o(s.returnTypeError);else if(s.code==="invalid_arguments")o(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let a=n,c=0;for(;c<s.path.length;){let u=s.path[c];c===s.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(s))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,rr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let i=o.path[0];r[i]=r[i]||[],r[i].push(t(o))}else n.push(t(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Ca.create=e=>new Ca(e)});var wht,cm,CJ=h(()=>{DM();t_();wht=(e,t)=>{let r;switch(e.code){case pe.invalid_type:e.received===Be.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case pe.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,rr.jsonStringifyReplacer)}`;break;case pe.unrecognized_keys:r=`Unrecognized key(s) in object: ${rr.joinValues(e.keys,", ")}`;break;case pe.invalid_union:r="Invalid input";break;case pe.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${rr.joinValues(e.options)}`;break;case pe.invalid_enum_value:r=`Invalid enum value. Expected ${rr.joinValues(e.options)}, received '${e.received}'`;break;case pe.invalid_arguments:r="Invalid function arguments";break;case pe.invalid_return_type:r="Invalid function return type";break;case pe.invalid_date:r="Invalid date";break;case pe.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:rr.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case pe.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case pe.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case pe.custom:r="Invalid input";break;case pe.invalid_intersection_types:r="Intersection results could not be merged";break;case pe.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case pe.not_finite:r="Number must be finite";break;default:r=t.defaultError,rr.assertNever(e)}return{message:r}},cm=wht});function Iht(e){Nxe=e}function sw(){return Nxe}var Nxe,QM=h(()=>{CJ();Nxe=cm});function Ie(e,t){let r=sw(),n=r_({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===cm?void 0:cm].filter(o=>!!o)});e.common.issues.push(n)}var r_,kht,qi,ft,Jx,ms,OM,NM,Pg,aw,wJ=h(()=>{QM();CJ();r_=e=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,i=[...r,...o.path||[]],s={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(s,{data:t,defaultError:a}).message;return{...o,path:i,message:a}},kht=[];qi=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let o of r){if(o.status==="aborted")return ft;o.status==="dirty"&&t.dirty(),n.push(o.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let o of r){let i=await o.key,s=await o.value;n.push({key:i,value:s})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let o of r){let{key:i,value:s}=o;if(i.status==="aborted"||s.status==="aborted")return ft;i.status==="dirty"&&t.dirty(),s.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||o.alwaysSet)&&(n[i.value]=s.value)}return{status:t.value,value:n}}},ft=Object.freeze({status:"aborted"}),Jx=e=>({status:"dirty",value:e}),ms=e=>({status:"valid",value:e}),OM=e=>e.status==="aborted",NM=e=>e.status==="dirty",Pg=e=>e.status==="valid",aw=e=>typeof Promise<"u"&&e instanceof Promise});var Pxe=h(()=>{});var qe,Mxe=h(()=>{(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(qe||(qe={}))});function Ot(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(s,a)=>{let{message:c}=e;return s.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:o}}function $xe(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Wht(e){return new RegExp(`^${$xe(e)}$`)}function Hxe(e){let t=`${Uxe}T${$xe(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function jht(e,t){return!!((t==="v4"||!t)&&Pht.test(e)||(t==="v6"||!t)&&Fht.test(e))}function qht(e,t){if(!Dht.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function Ght(e,t){return!!((t==="v4"||!t)&&Mht.test(e)||(t==="v6"||!t)&&Lht.test(e))}function zht(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,i=Number.parseInt(e.toFixed(o).replace(".","")),s=Number.parseInt(t.toFixed(o).replace(".",""));return i%s/10**o}function cw(e){if(e instanceof wa){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=uu.create(cw(n))}return new wa({...e._def,shape:()=>t})}else return e instanceof dm?new dm({...e._def,type:cw(e.element)}):e instanceof uu?uu.create(cw(e.unwrap())):e instanceof df?df.create(cw(e.unwrap())):e instanceof lf?lf.create(e.items.map(t=>cw(t))):e}function kJ(e,t){let r=uf(e),n=uf(t);if(e===t)return{valid:!0,data:e};if(r===Be.object&&n===Be.object){let o=rr.objectKeys(t),i=rr.objectKeys(e).filter(a=>o.indexOf(a)!==-1),s={...e,...t};for(let a of i){let c=kJ(e[a],t[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(r===Be.array&&n===Be.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let i=0;i<e.length;i++){let s=e[i],a=t[i],c=kJ(s,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===Be.date&&n===Be.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}function Wxe(e,t){return new aE({values:e,typeName:gt.ZodEnum,...Ot(t)})}function Lxe(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function jxe(e,t={},r){return e?Fg.create().superRefine((n,o)=>{let i=e(n);if(i instanceof Promise)return i.then(s=>{if(!s){let a=Lxe(t,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!i){let s=Lxe(t,n),a=s.fatal??r??!0;o.addIssue({code:"custom",...s,fatal:a})}}):Fg.create()}var lu,Fxe,qt,vht,Rht,_ht,Bht,Tht,Dht,Qht,Oht,Nht,IJ,Pht,Mht,Fht,Lht,Uht,$ht,Uxe,Hht,Mg,Kx,Zx,Xx,eE,uw,tE,rE,Fg,lm,Pl,lw,dm,wa,nE,um,PM,oE,lf,MM,dw,fw,FM,iE,sE,aE,cE,Lg,du,uu,df,uE,lE,pw,Vht,n_,o_,dE,Yht,gt,Jht,qxe,Gxe,Kht,Zht,zxe,Xht,egt,tgt,rgt,ngt,ogt,igt,sgt,agt,cgt,ugt,lgt,dgt,fgt,pgt,mgt,hgt,ggt,Agt,ygt,xgt,Egt,bgt,Sgt,Cgt,wgt,Igt,kgt,vgt,Rgt,_gt,Bgt,Tgt,Dgt,Vxe=h(()=>{DM();QM();Mxe();wJ();t_();lu=class{constructor(t,r,n,o){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Fxe=(e,t)=>{if(Pg(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Ca(e.common.issues);return this._error=r,this._error}}};qt=class{get description(){return this._def.description}_getType(t){return uf(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:uf(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new qi,ctx:{common:t.parent.common,data:t.data,parsedType:uf(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(aw(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:uf(t)},o=this._parseSync({data:t,path:n.path,parent:n});return Fxe(n,o)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:uf(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return Pg(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>Pg(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:uf(t)},o=this._parse({data:t,path:n.path,parent:n}),i=await(aw(o)?o:Promise.resolve(o));return Fxe(n,i)}refine(t,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,i)=>{let s=t(o),a=()=>i.addIssue({code:pe.custom,...n(o)});return typeof Promise<"u"&&s instanceof Promise?s.then(c=>c?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(t,r){return this._refinement((n,o)=>t(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(t){return new du({schema:this,typeName:gt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return uu.create(this,this._def)}nullable(){return df.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dm.create(this)}promise(){return Lg.create(this,this._def)}or(t){return nE.create([this,t],this._def)}and(t){return oE.create(this,t,this._def)}transform(t){return new du({...Ot(this._def),schema:this,typeName:gt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new uE({...Ot(this._def),innerType:this,defaultValue:r,typeName:gt.ZodDefault})}brand(){return new n_({typeName:gt.ZodBranded,type:this,...Ot(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new lE({...Ot(this._def),innerType:this,catchValue:r,typeName:gt.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return o_.create(this,t)}readonly(){return dE.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},vht=/^c[^\s-]{8,}$/i,Rht=/^[0-9a-z]+$/,_ht=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Bht=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Tht=/^[a-z0-9_-]{21}$/i,Dht=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Qht=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Oht=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Nht="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Pht=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Mht=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Fht=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Lht=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Uht=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$ht=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Uxe="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Hht=new RegExp(`^${Uxe}$`);Mg=class e extends qt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Be.string){let i=this._getOrReturnCtx(t);return Ie(i,{code:pe.invalid_type,expected:Be.string,received:i.parsedType}),ft}let n=new qi,o;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(o=this._getOrReturnCtx(t,o),Ie(o,{code:pe.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")t.data.length>i.value&&(o=this._getOrReturnCtx(t,o),Ie(o,{code:pe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let s=t.data.length>i.value,a=t.data.length<i.value;(s||a)&&(o=this._getOrReturnCtx(t,o),s?Ie(o,{code:pe.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&Ie(o,{code:pe.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Oht.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"email",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")IJ||(IJ=new RegExp(Nht,"u")),IJ.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"emoji",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Bht.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"uuid",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Tht.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"nanoid",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")vht.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"cuid",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Rht.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"cuid2",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")_ht.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"ulid",code:pe.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),Ie(o,{validation:"url",code:pe.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"regex",code:pe.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(t,o),Ie(o,{code:pe.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(o=this._getOrReturnCtx(t,o),Ie(o,{code:pe.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(o=this._getOrReturnCtx(t,o),Ie(o,{code:pe.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Hxe(i).test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{code:pe.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Hht.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{code:pe.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Wht(i).test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{code:pe.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Qht.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"duration",code:pe.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?jht(t.data,i.version)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"ip",code:pe.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?qht(t.data,i.alg)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"jwt",code:pe.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Ght(t.data,i.version)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"cidr",code:pe.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Uht.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"base64",code:pe.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?$ht.test(t.data)||(o=this._getOrReturnCtx(t,o),Ie(o,{validation:"base64url",code:pe.invalid_string,message:i.message}),n.dirty()):rr.assertNever(i);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(o=>t.test(o),{validation:r,code:pe.invalid_string,...qe.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...qe.errToObj(t)})}url(t){return this._addCheck({kind:"url",...qe.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...qe.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...qe.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...qe.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...qe.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...qe.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...qe.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...qe.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...qe.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...qe.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...qe.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...qe.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...qe.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...qe.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...qe.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...qe.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...qe.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...qe.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...qe.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...qe.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...qe.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...qe.errToObj(r)})}nonempty(t){return this.min(1,qe.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Mg.create=e=>new Mg({checks:[],typeName:gt.ZodString,coerce:e?.coerce??!1,...Ot(e)});Kx=class e extends qt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Be.number){let i=this._getOrReturnCtx(t);return Ie(i,{code:pe.invalid_type,expected:Be.number,received:i.parsedType}),ft}let n,o=new qi;for(let i of this._def.checks)i.kind==="int"?rr.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),Ie(n,{code:pe.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),Ie(n,{code:pe.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),Ie(n,{code:pe.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?zht(t.data,i.value)!==0&&(n=this._getOrReturnCtx(t,n),Ie(n,{code:pe.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),Ie(n,{code:pe.not_finite,message:i.message}),o.dirty()):rr.assertNever(i);return{status:o.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,qe.toString(r))}gt(t,r){return this.setLimit("min",t,!1,qe.toString(r))}lte(t,r){return this.setLimit("max",t,!0,qe.toString(r))}lt(t,r){return this.setLimit("max",t,!1,qe.toString(r))}setLimit(t,r,n,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:qe.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:qe.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:qe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:qe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:qe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:qe.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:qe.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:qe.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:qe.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:qe.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&rr.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};Kx.create=e=>new Kx({checks:[],typeName:gt.ZodNumber,coerce:e?.coerce||!1,...Ot(e)});Zx=class e extends qt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Be.bigint)return this._getInvalidInput(t);let n,o=new qi;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),Ie(n,{code:pe.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),Ie(n,{code:pe.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),Ie(n,{code:pe.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):rr.assertNever(i);return{status:o.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return Ie(r,{code:pe.invalid_type,expected:Be.bigint,received:r.parsedType}),ft}gte(t,r){return this.setLimit("min",t,!0,qe.toString(r))}gt(t,r){return this.setLimit("min",t,!1,qe.toString(r))}lte(t,r){return this.setLimit("max",t,!0,qe.toString(r))}lt(t,r){return this.setLimit("max",t,!1,qe.toString(r))}setLimit(t,r,n,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:qe.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:qe.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:qe.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:qe.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:qe.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:qe.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Zx.create=e=>new Zx({checks:[],typeName:gt.ZodBigInt,coerce:e?.coerce??!1,...Ot(e)});Xx=class extends qt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Be.boolean){let n=this._getOrReturnCtx(t);return Ie(n,{code:pe.invalid_type,expected:Be.boolean,received:n.parsedType}),ft}return ms(t.data)}};Xx.create=e=>new Xx({typeName:gt.ZodBoolean,coerce:e?.coerce||!1,...Ot(e)});eE=class e extends qt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Be.date){let i=this._getOrReturnCtx(t);return Ie(i,{code:pe.invalid_type,expected:Be.date,received:i.parsedType}),ft}if(Number.isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return Ie(i,{code:pe.invalid_date}),ft}let n=new qi,o;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(o=this._getOrReturnCtx(t,o),Ie(o,{code:pe.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(o=this._getOrReturnCtx(t,o),Ie(o,{code:pe.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):rr.assertNever(i);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:qe.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:qe.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};eE.create=e=>new eE({checks:[],coerce:e?.coerce||!1,typeName:gt.ZodDate,...Ot(e)});uw=class extends qt{_parse(t){if(this._getType(t)!==Be.symbol){let n=this._getOrReturnCtx(t);return Ie(n,{code:pe.invalid_type,expected:Be.symbol,received:n.parsedType}),ft}return ms(t.data)}};uw.create=e=>new uw({typeName:gt.ZodSymbol,...Ot(e)});tE=class extends qt{_parse(t){if(this._getType(t)!==Be.undefined){let n=this._getOrReturnCtx(t);return Ie(n,{code:pe.invalid_type,expected:Be.undefined,received:n.parsedType}),ft}return ms(t.data)}};tE.create=e=>new tE({typeName:gt.ZodUndefined,...Ot(e)});rE=class extends qt{_parse(t){if(this._getType(t)!==Be.null){let n=this._getOrReturnCtx(t);return Ie(n,{code:pe.invalid_type,expected:Be.null,received:n.parsedType}),ft}return ms(t.data)}};rE.create=e=>new rE({typeName:gt.ZodNull,...Ot(e)});Fg=class extends qt{constructor(){super(...arguments),this._any=!0}_parse(t){return ms(t.data)}};Fg.create=e=>new Fg({typeName:gt.ZodAny,...Ot(e)});lm=class extends qt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ms(t.data)}};lm.create=e=>new lm({typeName:gt.ZodUnknown,...Ot(e)});Pl=class extends qt{_parse(t){let r=this._getOrReturnCtx(t);return Ie(r,{code:pe.invalid_type,expected:Be.never,received:r.parsedType}),ft}};Pl.create=e=>new Pl({typeName:gt.ZodNever,...Ot(e)});lw=class extends qt{_parse(t){if(this._getType(t)!==Be.undefined){let n=this._getOrReturnCtx(t);return Ie(n,{code:pe.invalid_type,expected:Be.void,received:n.parsedType}),ft}return ms(t.data)}};lw.create=e=>new lw({typeName:gt.ZodVoid,...Ot(e)});dm=class e extends qt{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),o=this._def;if(r.parsedType!==Be.array)return Ie(r,{code:pe.invalid_type,expected:Be.array,received:r.parsedType}),ft;if(o.exactLength!==null){let s=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(s||a)&&(Ie(r,{code:s?pe.too_big:pe.too_small,minimum:a?o.exactLength.value:void 0,maximum:s?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(Ie(r,{code:pe.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(Ie(r,{code:pe.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,a)=>o.type._parseAsync(new lu(r,s,r.path,a)))).then(s=>qi.mergeArray(n,s));let i=[...r.data].map((s,a)=>o.type._parseSync(new lu(r,s,r.path,a)));return qi.mergeArray(n,i)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:qe.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:qe.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:qe.toString(r)}})}nonempty(t){return this.min(1,t)}};dm.create=(e,t)=>new dm({type:e,minLength:null,maxLength:null,exactLength:null,typeName:gt.ZodArray,...Ot(t)});wa=class e extends qt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=rr.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Be.object){let u=this._getOrReturnCtx(t);return Ie(u,{code:pe.invalid_type,expected:Be.object,received:u.parsedType}),ft}let{status:n,ctx:o}=this._processInputParams(t),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Pl&&this._def.unknownKeys==="strip"))for(let u in o.data)s.includes(u)||a.push(u);let c=[];for(let u of s){let l=i[u],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new lu(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof Pl){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")a.length>0&&(Ie(o,{code:pe.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new lu(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,f=await l.value;u.push({key:d,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>qi.mergeObjectSync(n,u)):qi.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return qe.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:qe.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:gt.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of rr.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of rr.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return cw(this)}partial(t){let r={};for(let n of rr.objectKeys(this.shape)){let o=this.shape[n];t&&!t[n]?r[n]=o:r[n]=o.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of rr.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof uu;)i=i._def.innerType;r[n]=i}return new e({...this._def,shape:()=>r})}keyof(){return Wxe(rr.objectKeys(this.shape))}};wa.create=(e,t)=>new wa({shape:()=>e,unknownKeys:"strip",catchall:Pl.create(),typeName:gt.ZodObject,...Ot(t)});wa.strictCreate=(e,t)=>new wa({shape:()=>e,unknownKeys:"strict",catchall:Pl.create(),typeName:gt.ZodObject,...Ot(t)});wa.lazycreate=(e,t)=>new wa({shape:e,unknownKeys:"strip",catchall:Pl.create(),typeName:gt.ZodObject,...Ot(t)});nE=class extends qt{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function o(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let s=i.map(a=>new Ca(a.ctx.common.issues));return Ie(r,{code:pe.invalid_union,unionErrors:s}),ft}if(r.common.async)return Promise.all(n.map(async i=>{let s={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(o);{let i,s=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&s.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=s.map(c=>new Ca(c));return Ie(r,{code:pe.invalid_union,unionErrors:a}),ft}}get options(){return this._def.options}};nE.create=(e,t)=>new nE({options:e,typeName:gt.ZodUnion,...Ot(t)});um=e=>e instanceof iE?um(e.schema):e instanceof du?um(e.innerType()):e instanceof sE?[e.value]:e instanceof aE?e.options:e instanceof cE?rr.objectValues(e.enum):e instanceof uE?um(e._def.innerType):e instanceof tE?[void 0]:e instanceof rE?[null]:e instanceof uu?[void 0,...um(e.unwrap())]:e instanceof df?[null,...um(e.unwrap())]:e instanceof n_||e instanceof dE?um(e.unwrap()):e instanceof lE?um(e._def.innerType):[],PM=class e extends qt{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Be.object)return Ie(r,{code:pe.invalid_type,expected:Be.object,received:r.parsedType}),ft;let n=this.discriminator,o=r.data[n],i=this.optionsMap.get(o);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(Ie(r,{code:pe.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ft)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let o=new Map;for(let i of r){let s=um(i.shape[t]);if(!s.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of s){if(o.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);o.set(a,i)}}return new e({typeName:gt.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:o,...Ot(n)})}};oE=class extends qt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=(i,s)=>{if(OM(i)||OM(s))return ft;let a=kJ(i.value,s.value);return a.valid?((NM(i)||NM(s))&&r.dirty(),{status:r.value,value:a.data}):(Ie(n,{code:pe.invalid_intersection_types}),ft)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,s])=>o(i,s)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};oE.create=(e,t,r)=>new oE({left:e,right:t,typeName:gt.ZodIntersection,...Ot(r)});lf=class e extends qt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Be.array)return Ie(n,{code:pe.invalid_type,expected:Be.array,received:n.parsedType}),ft;if(n.data.length<this._def.items.length)return Ie(n,{code:pe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ft;!this._def.rest&&n.data.length>this._def.items.length&&(Ie(n,{code:pe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((s,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new lu(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>qi.mergeArray(r,s)):qi.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};lf.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new lf({items:e,typeName:gt.ZodTuple,rest:null,...Ot(t)})};MM=class e extends qt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Be.object)return Ie(n,{code:pe.invalid_type,expected:Be.object,received:n.parsedType}),ft;let o=[],i=this._def.keyType,s=this._def.valueType;for(let a in n.data)o.push({key:i._parse(new lu(n,a,n.path,a)),value:s._parse(new lu(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?qi.mergeObjectAsync(r,o):qi.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof qt?new e({keyType:t,valueType:r,typeName:gt.ZodRecord,...Ot(n)}):new e({keyType:Mg.create(),valueType:t,typeName:gt.ZodRecord,...Ot(r)})}},dw=class extends qt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Be.map)return Ie(n,{code:pe.invalid_type,expected:Be.map,received:n.parsedType}),ft;let o=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new lu(n,a,n.path,[u,"key"])),value:i._parse(new lu(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of s){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return ft;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of s){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return ft;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};dw.create=(e,t,r)=>new dw({valueType:t,keyType:e,typeName:gt.ZodMap,...Ot(r)});fw=class e extends qt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==Be.set)return Ie(n,{code:pe.invalid_type,expected:Be.set,received:n.parsedType}),ft;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(Ie(n,{code:pe.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(Ie(n,{code:pe.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let i=this._def.valueType;function s(c){let u=new Set;for(let l of c){if(l.status==="aborted")return ft;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>i._parse(new lu(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>s(c)):s(a)}min(t,r){return new e({...this._def,minSize:{value:t,message:qe.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:qe.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};fw.create=(e,t)=>new fw({valueType:e,minSize:null,maxSize:null,typeName:gt.ZodSet,...Ot(t)});FM=class e extends qt{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Be.function)return Ie(r,{code:pe.invalid_type,expected:Be.function,received:r.parsedType}),ft;function n(a,c){return r_({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,sw(),cm].filter(u=>!!u),issueData:{code:pe.invalid_arguments,argumentsError:c}})}function o(a,c){return r_({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,sw(),cm].filter(u=>!!u),issueData:{code:pe.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Lg){let a=this;return ms(async function(...c){let u=new Ca([]),l=await a._def.args.parseAsync(c,i).catch(p=>{throw u.addIssue(n(c,p)),u}),d=await Reflect.apply(s,this,l);return await a._def.returns._def.type.parseAsync(d,i).catch(p=>{throw u.addIssue(o(d,p)),u})})}else{let a=this;return ms(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new Ca([n(c,u.error)]);let l=Reflect.apply(s,this,u.data),d=a._def.returns.safeParse(l,i);if(!d.success)throw new Ca([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:lf.create(t).rest(lm.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||lf.create([]).rest(lm.create()),returns:r||lm.create(),typeName:gt.ZodFunction,...Ot(n)})}},iE=class extends qt{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};iE.create=(e,t)=>new iE({getter:e,typeName:gt.ZodLazy,...Ot(t)});sE=class extends qt{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return Ie(r,{received:r.data,code:pe.invalid_literal,expected:this._def.value}),ft}return{status:"valid",value:t.data}}get value(){return this._def.value}};sE.create=(e,t)=>new sE({value:e,typeName:gt.ZodLiteral,...Ot(t)});aE=class e extends qt{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return Ie(r,{expected:rr.joinValues(n),received:r.parsedType,code:pe.invalid_type}),ft}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return Ie(r,{received:r.data,code:pe.invalid_enum_value,options:n}),ft}return ms(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};aE.create=Wxe;cE=class extends qt{_parse(t){let r=rr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==Be.string&&n.parsedType!==Be.number){let o=rr.objectValues(r);return Ie(n,{expected:rr.joinValues(o),received:n.parsedType,code:pe.invalid_type}),ft}if(this._cache||(this._cache=new Set(rr.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let o=rr.objectValues(r);return Ie(n,{received:n.data,code:pe.invalid_enum_value,options:o}),ft}return ms(t.data)}get enum(){return this._def.values}};cE.create=(e,t)=>new cE({values:e,typeName:gt.ZodNativeEnum,...Ot(t)});Lg=class extends qt{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Be.promise&&r.common.async===!1)return Ie(r,{code:pe.invalid_type,expected:Be.promise,received:r.parsedType}),ft;let n=r.parsedType===Be.promise?r.data:Promise.resolve(r.data);return ms(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Lg.create=(e,t)=>new Lg({type:e,typeName:gt.ZodPromise,...Ot(t)});du=class extends qt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===gt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=this._def.effect||null,i={addIssue:s=>{Ie(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){let s=o.transform(n.data,i);if(n.common.async)return Promise.resolve(s).then(async a=>{if(r.value==="aborted")return ft;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?ft:c.status==="dirty"?Jx(c.value):r.value==="dirty"?Jx(c.value):c});{if(r.value==="aborted")return ft;let a=this._def.schema._parseSync({data:s,path:n.path,parent:n});return a.status==="aborted"?ft:a.status==="dirty"?Jx(a.value):r.value==="dirty"?Jx(a.value):a}}if(o.type==="refinement"){let s=a=>{let c=o.refinement(a,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?ft:(a.status==="dirty"&&r.dirty(),s(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?ft:(a.status==="dirty"&&r.dirty(),s(a.value).then(()=>({status:r.value,value:a.value}))))}if(o.type==="transform")if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Pg(s))return ft;let a=o.transform(s.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>Pg(s)?Promise.resolve(o.transform(s.value,i)).then(a=>({status:r.value,value:a})):ft);rr.assertNever(o)}};du.create=(e,t,r)=>new du({schema:e,typeName:gt.ZodEffects,effect:t,...Ot(r)});du.createWithPreprocess=(e,t,r)=>new du({schema:t,effect:{type:"preprocess",transform:e},typeName:gt.ZodEffects,...Ot(r)});uu=class extends qt{_parse(t){return this._getType(t)===Be.undefined?ms(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};uu.create=(e,t)=>new uu({innerType:e,typeName:gt.ZodOptional,...Ot(t)});df=class extends qt{_parse(t){return this._getType(t)===Be.null?ms(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};df.create=(e,t)=>new df({innerType:e,typeName:gt.ZodNullable,...Ot(t)});uE=class extends qt{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===Be.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};uE.create=(e,t)=>new uE({innerType:e,typeName:gt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ot(t)});lE=class extends qt{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return aw(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ca(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ca(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};lE.create=(e,t)=>new lE({innerType:e,typeName:gt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ot(t)});pw=class extends qt{_parse(t){if(this._getType(t)!==Be.nan){let n=this._getOrReturnCtx(t);return Ie(n,{code:pe.invalid_type,expected:Be.nan,received:n.parsedType}),ft}return{status:"valid",value:t.data}}};pw.create=e=>new pw({typeName:gt.ZodNaN,...Ot(e)});Vht=Symbol("zod_brand"),n_=class extends qt{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},o_=class e extends qt{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?ft:i.status==="dirty"?(r.dirty(),Jx(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ft:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:gt.ZodPipeline})}},dE=class extends qt{_parse(t){let r=this._def.innerType._parse(t),n=o=>(Pg(o)&&(o.value=Object.freeze(o.value)),o);return aw(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};dE.create=(e,t)=>new dE({innerType:e,typeName:gt.ZodReadonly,...Ot(t)});Yht={object:wa.lazycreate};(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(gt||(gt={}));Jht=(e,t={message:`Input not instance of ${e.name}`})=>jxe(r=>r instanceof e,t),qxe=Mg.create,Gxe=Kx.create,Kht=pw.create,Zht=Zx.create,zxe=Xx.create,Xht=eE.create,egt=uw.create,tgt=tE.create,rgt=rE.create,ngt=Fg.create,ogt=lm.create,igt=Pl.create,sgt=lw.create,agt=dm.create,cgt=wa.create,ugt=wa.strictCreate,lgt=nE.create,dgt=PM.create,fgt=oE.create,pgt=lf.create,mgt=MM.create,hgt=dw.create,ggt=fw.create,Agt=FM.create,ygt=iE.create,xgt=sE.create,Egt=aE.create,bgt=cE.create,Sgt=Lg.create,Cgt=du.create,wgt=uu.create,Igt=df.create,kgt=du.createWithPreprocess,vgt=o_.create,Rgt=()=>qxe().optional(),_gt=()=>Gxe().optional(),Bgt=()=>zxe().optional(),Tgt={string:e=>Mg.create({...e,coerce:!0}),number:e=>Kx.create({...e,coerce:!0}),boolean:e=>Xx.create({...e,coerce:!0}),bigint:e=>Zx.create({...e,coerce:!0}),date:e=>eE.create({...e,coerce:!0})},Dgt=ft});var Ae={};tr(Ae,{BRAND:()=>Vht,DIRTY:()=>Jx,EMPTY_PATH:()=>kht,INVALID:()=>ft,NEVER:()=>Dgt,OK:()=>ms,ParseStatus:()=>qi,Schema:()=>qt,ZodAny:()=>Fg,ZodArray:()=>dm,ZodBigInt:()=>Zx,ZodBoolean:()=>Xx,ZodBranded:()=>n_,ZodCatch:()=>lE,ZodDate:()=>eE,ZodDefault:()=>uE,ZodDiscriminatedUnion:()=>PM,ZodEffects:()=>du,ZodEnum:()=>aE,ZodError:()=>Ca,ZodFirstPartyTypeKind:()=>gt,ZodFunction:()=>FM,ZodIntersection:()=>oE,ZodIssueCode:()=>pe,ZodLazy:()=>iE,ZodLiteral:()=>sE,ZodMap:()=>dw,ZodNaN:()=>pw,ZodNativeEnum:()=>cE,ZodNever:()=>Pl,ZodNull:()=>rE,ZodNullable:()=>df,ZodNumber:()=>Kx,ZodObject:()=>wa,ZodOptional:()=>uu,ZodParsedType:()=>Be,ZodPipeline:()=>o_,ZodPromise:()=>Lg,ZodReadonly:()=>dE,ZodRecord:()=>MM,ZodSchema:()=>qt,ZodSet:()=>fw,ZodString:()=>Mg,ZodSymbol:()=>uw,ZodTransformer:()=>du,ZodTuple:()=>lf,ZodType:()=>qt,ZodUndefined:()=>tE,ZodUnion:()=>nE,ZodUnknown:()=>lm,ZodVoid:()=>lw,addIssueToContext:()=>Ie,any:()=>ngt,array:()=>agt,bigint:()=>Zht,boolean:()=>zxe,coerce:()=>Tgt,custom:()=>jxe,date:()=>Xht,datetimeRegex:()=>Hxe,defaultErrorMap:()=>cm,discriminatedUnion:()=>dgt,effect:()=>Cgt,enum:()=>Egt,function:()=>Agt,getErrorMap:()=>sw,getParsedType:()=>uf,instanceof:()=>Jht,intersection:()=>fgt,isAborted:()=>OM,isAsync:()=>aw,isDirty:()=>NM,isValid:()=>Pg,late:()=>Yht,lazy:()=>ygt,literal:()=>xgt,makeIssue:()=>r_,map:()=>hgt,nan:()=>Kht,nativeEnum:()=>bgt,never:()=>igt,null:()=>rgt,nullable:()=>Igt,number:()=>Gxe,object:()=>cgt,objectUtil:()=>SJ,oboolean:()=>Bgt,onumber:()=>_gt,optional:()=>wgt,ostring:()=>Rgt,pipeline:()=>vgt,preprocess:()=>kgt,promise:()=>Sgt,quotelessJson:()=>Cht,record:()=>mgt,set:()=>ggt,setErrorMap:()=>Iht,strictObject:()=>ugt,string:()=>qxe,symbol:()=>egt,transformer:()=>Cgt,tuple:()=>pgt,undefined:()=>tgt,union:()=>lgt,unknown:()=>ogt,util:()=>rr,void:()=>sgt});var vJ=h(()=>{QM();wJ();Pxe();t_();Vxe();DM()});var LM=h(()=>{vJ();vJ()});function Jxe(e){let t=e[Qgt];if(typeof t=="string"&&t.length>0)return{ANTHROPIC_API_KEY:t,ANTHROPIC_BASE_URL:Ogt,CLAUDE_CODE_SIMPLE:Ngt}}var Qgt,Ogt,Yxe,Ngt,Kxe=h(()=>{"use strict";Qgt="MINIMAX_API_KEY",Ogt="https://api.minimax.io/anthropic",Yxe="MiniMax-M3",Ngt="1"});function Zxe(e){for(let t of Pgt){let r=e[t];if(typeof r=="string"&&r.length>0)return{envVar:t,keyValue:r}}}function Xxe(e){return e?{[e.envVar]:e.keyValue}:void 0}var Pgt,eEe=h(()=>{"use strict";Pgt=["OPENAI_API_KEY","MINIMAX_API_KEY","OPENROUTER_API_KEY"]});function mw(e){return e==="codex"||e==="opencode"||e==="claude-minimax"?e:"claude"}function i_(e){return $M[e].structuredOutput===!0}var RJ,UM,_J,$M,s_=h(()=>{"use strict";Kxe();eEe();RJ=["low","medium","high","xhigh"],UM=["low","medium","high","xhigh","max"],_J=["low"],$M={claude:{efforts:UM,channel:"effort",factory:"claudeCode",structuredOutput:!0},codex:{efforts:RJ,channel:"effort",factory:"codex"},opencode:{efforts:UM,channel:"variant",factory:"opencode",resolveAuthEnv:e=>Xxe(Zxe(e))},"claude-minimax":{efforts:_J,channel:"effort",factory:"claudeCode",forcedModel:Yxe,defaultEffort:"low",resolveAuthEnv:Jxe}}});import{readFileSync as Mgt}from"node:fs";function Fgt(e){let t=tEe.indexOf(e);return t<=0?"validate":tEe[t-1]}function rEe(){return{...HM}}function Ugt(e){let t={},r=[],n=[],o={};for(let i of e.split(`
21
21
  `)){i=i.replace(/\r$/,"");let s=i;if(!/".*"/.test(s)&&!/'.*'/.test(s)){let m=s.indexOf("#");m>=0&&(s=s.slice(0,m))}if(s.replace(/\s/g,"")==="")continue;let c=(s.match(/^\s*/)?.[0]??"").length;if(c%2!==0)throw new ff;let u=s.slice(c).replace(/\s+$/,"");if(/^-(\s|$)/.test(u)){for(;n.length>0&&n[n.length-1]>=c;)r.pop(),n.pop();if(r.length===0)throw new ff;let m=u.slice(1).replace(/^\s+/,"");if(m==="")throw new ff;if(m[0]==='"'||m[0]==="'"){let E=m[0],y=m.indexOf(E,1);if(y>0){let b=m.slice(y+1).trimStart();(b===""||b.startsWith("#"))&&(m=m.slice(0,y+1))}}if(m.startsWith('"')){if(!m.endsWith('"')||m.length<2)throw new ff;m=m.slice(1,-1)}else if(m.startsWith("'")){if(!m.endsWith("'")||m.length<2)throw new ff;m=m.slice(1,-1)}let g=r.join("."),A=o[g]??0;o[g]=A+1,t[`${g}.${A}`]=m;continue}if(!/^[a-zA-Z_][a-zA-Z0-9_-]*:/.test(u))throw new ff;let l=u.indexOf(":"),d=u.slice(0,l),f=u.slice(l+1).replace(/^\s+/,"");if(f[0]==='"'||f[0]==="'"){let m=f[0],g=f.indexOf(m,1);if(g>0){let A=f.slice(g+1).trimStart();(A===""||A.startsWith("#"))&&(f=f.slice(0,g+1))}}if(f.startsWith('"')){if(!f.endsWith('"')||f.length<2)throw new ff;f=f.slice(1,-1)}else if(f.startsWith("'")){if(!f.endsWith("'")||f.length<2)throw new ff;f=f.slice(1,-1)}for(;n.length>0&&n[n.length-1]>=c;)r.pop(),n.pop();let p=r.length>0?`${r.join(".")}.${d}`:d;f===""?(r.push(d),n.push(c)):t[p]=f}return t}function Sr(e,t={}){let r=t.read??$gt,n=t.warn??Hgt,o=rEe(),i=r(e);if(i===void 0)return o;let s;try{s=Ugt(i)}catch{return n(`[afk:config] warn: malformed YAML in ${e} \u2014 using defaults`),rEe()}let a=new Set;for(let[c,u]of Object.entries(s))o[c]=u,a.add(c);for(let[c,u]of Object.entries(s)){let l=/^plugins\.dev\.(.+)$/.exec(c);if(!l)continue;let d=l[1],f=d==="afk"||d.startsWith("afk.")?d:`dev.${d}`;o[f]=u,a.add(f)}return a.size>0&&(o["\0explicit"]=Array.from(a).join("")),o}function Pe(e,t){return e[t]??""}function nEe(e,t,r){let n=`afk.models.${e}.${t}.${r}`;return Object.prototype.hasOwnProperty.call(HM,n)?n:void 0}function oEe(e,t){return Lgt.includes(e)?e:t}function Ia(e,t,r="think",n={}){let o=mw(t),i=WM.includes(r)?r:"think",s=n.RED_AFK_TASK_TIER_DOWNGRADE==="1"?Fgt(i):i,a=nEe(o,s,"model"),c=nEe(o,s,"effort"),u=HM[a],l=HM[c],d=Pe(e,a),f=Pe(e,`afk.models.${o}.base.model`),p=Pe(e,`afk.models.${o}.base.effort`),m=Pe(e,`afk.models.${o}`),g=Pe(e,"afk.model"),A=Pe(e,c),E=new Set((e["\0explicit"]??"").split("").filter(Boolean)),y=(n.RED_AFK_MODEL??"").trim(),b=(n.RED_AFK_EFFORT??"").trim(),w=d&&(d!==u||E.has(a))?d:f||m||g||u,I=A&&(A!==l||E.has(c))?A:p||l;return{model:y.length>0?y:w,effort:b.length>0?oEe(b,l):oEe(I,l)}}function jM(e){let t=[];for(let n=0;;n++){let o=e[`afk.backpressure.${n}`];if(o===void 0)break;o.trim()!==""&&t.push(o)}if(t.length>0)return t;let r=e["afk.backpressure"];return r&&r.trim()!==""?[r]:[]}function iEe(e){let t=[];for(let n=0;;n++){let o=e[`afk.post_attempt_format.${n}`];if(o===void 0)break;o.trim()!==""&&t.push(o)}if(t.length>0)return t;let r=e["afk.post_attempt_format"];return r&&r.trim()!==""?[r]:[]}function sEe(e=process.env){let t=(e.RED_AFK_MERGE_CI_TIMEOUT_S??"").trim(),r=Number.parseInt(t,10);return Number.isInteger(r)&&r>0?r:Wgt}var HM,WM,tEe,Lgt,LSr,ff,$gt,Hgt,Wgt,bo=h(()=>{"use strict";LM();s_();HM={"afk.default_runner":"claude","afk.fleet.target":"2","afk.models.claude.validate.model":"claude-haiku-4-5","afk.models.claude.validate.effort":"low","afk.models.claude.simple.model":"claude-sonnet-4-6","afk.models.claude.simple.effort":"high","afk.models.claude.complex.model":"claude-opus-4-8","afk.models.claude.complex.effort":"medium","afk.models.claude.think.model":"claude-opus-4-8","afk.models.claude.think.effort":"high","afk.models.codex.validate.model":"gpt-5.5","afk.models.codex.validate.effort":"low","afk.models.codex.simple.model":"gpt-5.5","afk.models.codex.simple.effort":"high","afk.models.codex.complex.model":"gpt-5.5","afk.models.codex.complex.effort":"medium","afk.models.codex.think.model":"gpt-5.5","afk.models.codex.think.effort":"high","afk.models.opencode.validate.model":"openrouter/anthropic/claude-3.5-haiku","afk.models.opencode.validate.effort":"low","afk.models.opencode.simple.model":"openrouter/anthropic/claude-sonnet-4","afk.models.opencode.simple.effort":"high","afk.models.opencode.complex.model":"openrouter/anthropic/claude-opus-4","afk.models.opencode.complex.effort":"medium","afk.models.opencode.think.model":"openrouter/anthropic/claude-opus-4","afk.models.opencode.think.effort":"high","afk.models.claude-minimax.validate.model":"MiniMax-M3","afk.models.claude-minimax.validate.effort":"low","afk.models.claude-minimax.simple.model":"MiniMax-M3","afk.models.claude-minimax.simple.effort":"low","afk.models.claude-minimax.complex.model":"MiniMax-M3","afk.models.claude-minimax.complex.effort":"low","afk.models.claude-minimax.think.model":"MiniMax-M3","afk.models.claude-minimax.think.effort":"low","afk.hooks.defaults.cargo":"true","afk.hooks.defaults.gradle":"true","afk.feedback.rebase_on_base":"false","afk.merge.wait_for_review":"false","afk.merge.review_check":"CodeRabbit","afk.merge.ci_aware":"false","afk.merge.native_queue":"false","afk.merge.land_lock":"true","afk.worktree_launches_pull_request":"true","afk.review_gate.enabled":"false","afk.review_gate.threshold":"complex","afk.release.channel":"stable","afk.claim_reaper.refresh_s":"300","afk.claim_reaper.stale_tolerance":"3","afk.claim_reaper.grace_s":"300","afk.claim_reaper.recent_commit_s":"2700","afk.worktree_pool.enabled":"false","afk.worktree_pool.max_size":"4","afk.worktree_pool.lease_ttl_s":"3600","afk.worktree_pool.min_idle_s":"1800","afk.companion.iteration_churn":"8","afk.companion.waiting_windows":"20","afk.companion.diff_drift_loc":"4000","afk.companion.min_progress_loc":"5","afk.notes_loop.enabled":"false","afk.notes_loop.max_iterations":"4","afk.notes_loop.inner_max_iterations":"0","afk.notes_loop.token_budget":"0","afk.notes_loop.wall_clock_s":"0","afk.output_shaping.terse_steering":"false","afk.landing.cascade_rebase":"true","dev.lock.primary-branch":"false","dev.triage.external_pr_surface.enabled":"false","dev.trunk":"main"},WM=["validate","simple","complex","think"],tEe=WM;Lgt=["low","medium","high","xhigh","max"],LSr=Ae.record(Ae.string()),ff=class extends Error{constructor(t="malformed YAML"){super(t),this.name="MalformedConfigError"}};$gt=e=>{try{return Mgt(e,"utf8")}catch{return}},Hgt=e=>{process.stderr.write(`${e}
22
- `)};Wgt=1800});function C(e,t,r,n,o,i,s,a,c){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return r(t(e));case 4:return n(r(t(e)));case 5:return o(n(r(t(e))));case 6:return i(o(n(r(t(e)))));case 7:return s(i(o(n(r(t(e))))));case 8:return a(s(i(o(n(r(t(e)))))));case 9:return c(a(s(i(o(n(r(t(e))))))));default:{let u=arguments[0];for(let l=1;l<arguments.length;l++)u=arguments[l](u);return u}}}var GM,x,be,fm,ka,Gi,DJ,hw,Ai,oe=h(()=>{GM=e=>typeof e=="function",x=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):r=>t(r,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(r,n){return arguments.length>=2?t(r,n):function(o){return t(o,r)}};case 3:return function(r,n,o){return arguments.length>=3?t(r,n,o):function(i){return t(i,r,n)}};case 4:return function(r,n,o,i){return arguments.length>=4?t(r,n,o,i):function(s){return t(s,r,n,o)}};case 5:return function(r,n,o,i,s){return arguments.length>=5?t(r,n,o,i,s):function(a){return t(a,r,n,o,i)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(n){return t(n,...r)}}}},be=e=>e,fm=e=>()=>e,ka=fm(!0),Gi=fm(!1),DJ=fm(null),hw=fm(void 0),Ai=hw});var Ml,zgt,Vgt,QJ,OJ,uEe,zM,mm=h(()=>{oe();Ml=e=>(t,r)=>t===r||e(t,r),zgt=(e,t)=>e===t,Vgt=()=>zgt,QJ=Vgt(),OJ=x(2,(e,t)=>Ml((r,n)=>e(t(r),t(n)))),uEe=OJ(QJ,e=>e.getTime()),zM=e=>Ml((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e(t[n],r[n]))return!1;return!0})});var VM,YM,JM,NJ=h(()=>{oe();VM=e=>x(3,(t,r,n)=>e(t,o=>({...o,[r]:n(o)}))),YM=e=>x(2,(t,r)=>e(t,n=>({[r]:n}))),JM=(e,t)=>x(3,(r,n,o)=>t(r,i=>e(o(i),s=>({...i,[n]:s}))))});var dEe,a_,Te,yn=h(()=>{dEe="effect/GlobalValue",Te=(e,t)=>(a_||(globalThis[dEe]??=new Map,a_=globalThis[dEe]),a_.has(e)||a_.set(e,t()),a_.get(e))});var Fo,Ls,hm,$g,fE,gm,fEe,pEe,c_,yi,se,mf,pE,mEe,KM,fu,PJ,MJ,ct=h(()=>{oe();Fo=e=>typeof e=="string",Ls=e=>typeof e=="number",hm=e=>typeof e=="boolean",$g=e=>typeof e=="bigint",fE=e=>typeof e=="symbol",gm=GM,fEe=e=>e===void 0,pEe=e=>!1,c_=e=>typeof e=="object"&&e!==null,yi=e=>c_(e)||gm(e),se=x(2,(e,t)=>yi(e)&&t in e),mf=x(2,(e,t)=>se(e,"_tag")&&e._tag===t),pE=e=>e==null,mEe=e=>e!=null,KM=e=>e instanceof Date,fu=e=>typeof e=="string"||se(e,Symbol.iterator),PJ=e=>c_(e)&&!Array.isArray(e),MJ=e=>se(e,"then")&&gm(e.then)});var Fl,gw=h(()=>{Fl=e=>`BUG: ${e} - please report an issue at https://github.com/Effect-TS/effect/issues`});function rAt(e,t,r,n,o){let i=(r>>>16)*(o&65535)>>>0,s=(r&65535)*(o>>>16)>>>0,a=(r&65535)*(o&65535)>>>0,c=(r>>>16)*(o>>>16)+((s>>>16)+(i>>>16))>>>0;s=s<<16>>>0,a=a+s>>>0,a>>>0<s>>>0&&(c=c+1>>>0),i=i<<16>>>0,a=a+i>>>0,a>>>0<i>>>0&&(c=c+1>>>0),c=c+Math.imul(r,n)>>>0,c=c+Math.imul(t,o)>>>0,e[0]=c,e[1]=a}function hEe(e,t,r,n,o){let i=t+n>>>0,s=r+o>>>0;s>>>0<r>>>0&&(i=i+1|0),e[0]=i,e[1]=s}function u_(e){if(typeof e=="object"&&e!==null&&UJ in e)return e[UJ]();throw new Error(Fl("yieldWrapGet"))}var FJ,gEe,LJ,mE,AEe,Jgt,Kgt,Zgt,Xgt,eAt,tAt,ZM,UJ,hf,va,yEe,nAt,oAt,qn,iAt,xEe,mu=h(()=>{oe();yn();gw();ct();FJ=Symbol.for("effect/Gen/GenKind"),gEe=e=>yi(e)&&FJ in e,LJ=class{value;constructor(t){this.value=t}get _F(){return be}get _R(){return t=>t}get _O(){return t=>t}get _E(){return t=>t}[FJ]=FJ;[Symbol.iterator](){return new mE(this)}},mE=class e{self;called=!1;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(t){return{value:t,done:!0}}throw(t){throw t}[Symbol.iterator](){return new e(this.self)}},AEe=()=>function(){let e=arguments[0];for(let t=1;t<arguments.length;t++)e=arguments[t](e);return new LJ(e)},Jgt=335903614,Kgt=4150755663,Zgt=1481765933,Xgt=1284865837,eAt=9007199254740992,tAt=134217728,ZM=class{_state;constructor(t,r,n,o){return pE(r)&&pE(t)?(r=Math.random()*4294967295>>>0,t=0):pE(r)&&(r=t,t=0),pE(o)&&pE(n)?(o=this._state?this._state[3]:Kgt,n=this._state?this._state[2]:Jgt):pE(o)&&(o=n,n=0),this._state=new Int32Array([0,0,n>>>0,((o||0)|1)>>>0]),this._next(),hEe(this._state,this._state[0],this._state[1],t>>>0,r>>>0),this._next(),this}getState(){return[this._state[0],this._state[1],this._state[2],this._state[3]]}setState(t){this._state[0]=t[0],this._state[1]=t[1],this._state[2]=t[2],this._state[3]=t[3]|1}integer(t){return Math.round(this.number()*Number.MAX_SAFE_INTEGER)%t}number(){let t=(this._next()&67108863)*1,r=(this._next()&134217727)*1;return(t*tAt+r)/eAt}_next(){let t=this._state[0]>>>0,r=this._state[1]>>>0;rAt(this._state,t,r,Zgt,Xgt),hEe(this._state,this._state[0],this._state[1],this._state[2],this._state[3]);let n=t>>>18,o=(r>>>18|t<<14)>>>0;n=(n^t)>>>0,o=(o^r)>>>0;let i=(o>>>27|n<<5)>>>0,s=t>>>27,a=(-s>>>0&31)>>>0;return(i>>>s|i<<a)>>>0}};UJ=Symbol.for("effect/Utils/YieldWrap"),hf=class{#e;constructor(t){this.#e=t}[UJ](){return this.#e}};va=Te("effect/Utils/isStructuralRegion",()=>({enabled:!1,tester:void 0})),yEe={effect_internal_function:e=>e()},nAt={effect_internal_function:e=>{try{return e()}finally{}}},oAt=yEe.effect_internal_function(()=>new Error().stack)?.includes("effect_internal_function")===!0,qn=oAt?yEe.effect_internal_function:nAt.effect_internal_function,iAt=function*(){}.constructor,xEe=e=>yi(e)&&e.constructor===iAt});var HJ,he,ae,Aw,we,XM,sAt,hu,Lt,aAt,eF,So,We,ir=h(()=>{oe();yn();ct();mu();HJ=Te(Symbol.for("effect/Hash/randomHashCache"),()=>new WeakMap),he=Symbol.for("effect/Hash"),ae=e=>{if(va.enabled===!0)return 0;switch(typeof e){case"number":return hu(e);case"bigint":return Lt(e.toString(10));case"boolean":return Lt(String(e));case"symbol":return Lt(String(e));case"string":return Lt(e);case"undefined":return Lt("undefined");case"function":case"object":return e===null?Lt("null"):e instanceof Date?Number.isNaN(e.getTime())?Lt("Invalid Date"):ae(e.toISOString()):e instanceof URL?ae(e.href):sAt(e)?e[he]():Aw(e);default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Aw=e=>(HJ.has(e)||HJ.set(e,hu(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),HJ.get(e)),we=e=>t=>t*53^e,XM=e=>e&3221225471|e>>>1&1073741824,sAt=e=>se(e,he),hu=e=>{if(e!==e||e===1/0)return 0;let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return XM(t)},Lt=e=>{let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return XM(t)},aAt=(e,t)=>{let r=12289;for(let n=0;n<t.length;n++)r^=C(Lt(t[n]),we(ae(e[t[n]])));return XM(r)},eF=e=>aAt(e,Object.keys(e)),So=e=>{let t=6151;for(let r=0;r<e.length;r++)t=C(t,we(ae(e[r])));return XM(t)},We=function(){if(arguments.length===1){let r=arguments[0];return function(n){return Object.defineProperty(r,he,{value(){return n},enumerable:!1}),n}}let e=arguments[0],t=arguments[1];return Object.defineProperty(e,he,{value(){return t},enumerable:!1}),t}});function ce(){return arguments.length===1?e=>tF(e,arguments[0]):tF(arguments[0],arguments[1])}function tF(e,t){if(e===t)return!0;let r=typeof e;if(r!==typeof t)return!1;if(r==="object"||r==="function"){if(e!==null&&t!==null){if(yw(e)&&yw(t))return ae(e)===ae(t)&&e[me](t)?!0:va.enabled&&va.tester?va.tester(e,t):!1;if(e instanceof Date&&t instanceof Date){let n=e.getTime(),o=t.getTime();return n===o||Number.isNaN(n)&&Number.isNaN(o)}else if(e instanceof URL&&t instanceof URL)return e.href===t.href}if(va.enabled){if(e===null||t===null)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,o)=>tF(n,t[o]));if(Object.getPrototypeOf(e)===Object.prototype&&Object.getPrototypeOf(t)===Object.prototype){let n=Object.keys(e),o=Object.keys(t);if(n.length===o.length){for(let i of n)if(!(i in t&&tF(e[i],t[i])))return va.tester?va.tester(e,t):!1;return!0}}return va.tester?va.tester(e,t):!1}}return va.enabled&&va.tester?va.tester(e,t):!1}var me,yw,l_,mt=h(()=>{ir();ct();mu();me=Symbol.for("effect/Equal");yw=e=>se(e,me),l_=()=>ce});function EEe(e){try{return e.toISOString()}catch{return"Invalid Date"}}function cAt(e){try{let t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}function Hg(e){return Fo(e)?JSON.stringify(e):String(e)}function uc(e,t){let r=t?.space??0,n=new WeakSet,o=r?Ls(r)?" ".repeat(r):r:"",i=u=>o.repeat(u),s=(u,l)=>{let d=u?.constructor;return d&&d!==Object.prototype.constructor&&d.name?`${d.name}(${l})`:l},a=u=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}};function c(u,l=0){if(Array.isArray(u)){if(n.has(u))return WJ;if(n.add(u),!o||u.length<=1)return`[${u.map(f=>c(f,l)).join(",")}]`;let d=u.map(f=>c(f,l+1)).join(`,
22
+ `)};Wgt=1800});function C(e,t,r,n,o,i,s,a,c){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return r(t(e));case 4:return n(r(t(e)));case 5:return o(n(r(t(e))));case 6:return i(o(n(r(t(e)))));case 7:return s(i(o(n(r(t(e))))));case 8:return a(s(i(o(n(r(t(e)))))));case 9:return c(a(s(i(o(n(r(t(e))))))));default:{let u=arguments[0];for(let l=1;l<arguments.length;l++)u=arguments[l](u);return u}}}var GM,x,be,fm,ka,Gi,DJ,hw,yi,oe=h(()=>{GM=e=>typeof e=="function",x=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):r=>t(r,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(r,n){return arguments.length>=2?t(r,n):function(o){return t(o,r)}};case 3:return function(r,n,o){return arguments.length>=3?t(r,n,o):function(i){return t(i,r,n)}};case 4:return function(r,n,o,i){return arguments.length>=4?t(r,n,o,i):function(s){return t(s,r,n,o)}};case 5:return function(r,n,o,i,s){return arguments.length>=5?t(r,n,o,i,s):function(a){return t(a,r,n,o,i)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(n){return t(n,...r)}}}},be=e=>e,fm=e=>()=>e,ka=fm(!0),Gi=fm(!1),DJ=fm(null),hw=fm(void 0),yi=hw});var Ml,zgt,Vgt,QJ,OJ,uEe,zM,mm=h(()=>{oe();Ml=e=>(t,r)=>t===r||e(t,r),zgt=(e,t)=>e===t,Vgt=()=>zgt,QJ=Vgt(),OJ=x(2,(e,t)=>Ml((r,n)=>e(t(r),t(n)))),uEe=OJ(QJ,e=>e.getTime()),zM=e=>Ml((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e(t[n],r[n]))return!1;return!0})});var VM,YM,JM,NJ=h(()=>{oe();VM=e=>x(3,(t,r,n)=>e(t,o=>({...o,[r]:n(o)}))),YM=e=>x(2,(t,r)=>e(t,n=>({[r]:n}))),JM=(e,t)=>x(3,(r,n,o)=>t(r,i=>e(o(i),s=>({...i,[n]:s}))))});var dEe,a_,Te,yn=h(()=>{dEe="effect/GlobalValue",Te=(e,t)=>(a_||(globalThis[dEe]??=new Map,a_=globalThis[dEe]),a_.has(e)||a_.set(e,t()),a_.get(e))});var Fo,Ls,hm,$g,fE,gm,fEe,pEe,c_,xi,se,mf,pE,mEe,KM,fu,PJ,MJ,ct=h(()=>{oe();Fo=e=>typeof e=="string",Ls=e=>typeof e=="number",hm=e=>typeof e=="boolean",$g=e=>typeof e=="bigint",fE=e=>typeof e=="symbol",gm=GM,fEe=e=>e===void 0,pEe=e=>!1,c_=e=>typeof e=="object"&&e!==null,xi=e=>c_(e)||gm(e),se=x(2,(e,t)=>xi(e)&&t in e),mf=x(2,(e,t)=>se(e,"_tag")&&e._tag===t),pE=e=>e==null,mEe=e=>e!=null,KM=e=>e instanceof Date,fu=e=>typeof e=="string"||se(e,Symbol.iterator),PJ=e=>c_(e)&&!Array.isArray(e),MJ=e=>se(e,"then")&&gm(e.then)});var Fl,gw=h(()=>{Fl=e=>`BUG: ${e} - please report an issue at https://github.com/Effect-TS/effect/issues`});function rAt(e,t,r,n,o){let i=(r>>>16)*(o&65535)>>>0,s=(r&65535)*(o>>>16)>>>0,a=(r&65535)*(o&65535)>>>0,c=(r>>>16)*(o>>>16)+((s>>>16)+(i>>>16))>>>0;s=s<<16>>>0,a=a+s>>>0,a>>>0<s>>>0&&(c=c+1>>>0),i=i<<16>>>0,a=a+i>>>0,a>>>0<i>>>0&&(c=c+1>>>0),c=c+Math.imul(r,n)>>>0,c=c+Math.imul(t,o)>>>0,e[0]=c,e[1]=a}function hEe(e,t,r,n,o){let i=t+n>>>0,s=r+o>>>0;s>>>0<r>>>0&&(i=i+1|0),e[0]=i,e[1]=s}function u_(e){if(typeof e=="object"&&e!==null&&UJ in e)return e[UJ]();throw new Error(Fl("yieldWrapGet"))}var FJ,gEe,LJ,mE,AEe,Jgt,Kgt,Zgt,Xgt,eAt,tAt,ZM,UJ,hf,va,yEe,nAt,oAt,qn,iAt,xEe,mu=h(()=>{oe();yn();gw();ct();FJ=Symbol.for("effect/Gen/GenKind"),gEe=e=>xi(e)&&FJ in e,LJ=class{value;constructor(t){this.value=t}get _F(){return be}get _R(){return t=>t}get _O(){return t=>t}get _E(){return t=>t}[FJ]=FJ;[Symbol.iterator](){return new mE(this)}},mE=class e{self;called=!1;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(t){return{value:t,done:!0}}throw(t){throw t}[Symbol.iterator](){return new e(this.self)}},AEe=()=>function(){let e=arguments[0];for(let t=1;t<arguments.length;t++)e=arguments[t](e);return new LJ(e)},Jgt=335903614,Kgt=4150755663,Zgt=1481765933,Xgt=1284865837,eAt=9007199254740992,tAt=134217728,ZM=class{_state;constructor(t,r,n,o){return pE(r)&&pE(t)?(r=Math.random()*4294967295>>>0,t=0):pE(r)&&(r=t,t=0),pE(o)&&pE(n)?(o=this._state?this._state[3]:Kgt,n=this._state?this._state[2]:Jgt):pE(o)&&(o=n,n=0),this._state=new Int32Array([0,0,n>>>0,((o||0)|1)>>>0]),this._next(),hEe(this._state,this._state[0],this._state[1],t>>>0,r>>>0),this._next(),this}getState(){return[this._state[0],this._state[1],this._state[2],this._state[3]]}setState(t){this._state[0]=t[0],this._state[1]=t[1],this._state[2]=t[2],this._state[3]=t[3]|1}integer(t){return Math.round(this.number()*Number.MAX_SAFE_INTEGER)%t}number(){let t=(this._next()&67108863)*1,r=(this._next()&134217727)*1;return(t*tAt+r)/eAt}_next(){let t=this._state[0]>>>0,r=this._state[1]>>>0;rAt(this._state,t,r,Zgt,Xgt),hEe(this._state,this._state[0],this._state[1],this._state[2],this._state[3]);let n=t>>>18,o=(r>>>18|t<<14)>>>0;n=(n^t)>>>0,o=(o^r)>>>0;let i=(o>>>27|n<<5)>>>0,s=t>>>27,a=(-s>>>0&31)>>>0;return(i>>>s|i<<a)>>>0}};UJ=Symbol.for("effect/Utils/YieldWrap"),hf=class{#e;constructor(t){this.#e=t}[UJ](){return this.#e}};va=Te("effect/Utils/isStructuralRegion",()=>({enabled:!1,tester:void 0})),yEe={effect_internal_function:e=>e()},nAt={effect_internal_function:e=>{try{return e()}finally{}}},oAt=yEe.effect_internal_function(()=>new Error().stack)?.includes("effect_internal_function")===!0,qn=oAt?yEe.effect_internal_function:nAt.effect_internal_function,iAt=function*(){}.constructor,xEe=e=>xi(e)&&e.constructor===iAt});var HJ,he,ae,Aw,we,XM,sAt,hu,Lt,aAt,eF,So,We,ir=h(()=>{oe();yn();ct();mu();HJ=Te(Symbol.for("effect/Hash/randomHashCache"),()=>new WeakMap),he=Symbol.for("effect/Hash"),ae=e=>{if(va.enabled===!0)return 0;switch(typeof e){case"number":return hu(e);case"bigint":return Lt(e.toString(10));case"boolean":return Lt(String(e));case"symbol":return Lt(String(e));case"string":return Lt(e);case"undefined":return Lt("undefined");case"function":case"object":return e===null?Lt("null"):e instanceof Date?Number.isNaN(e.getTime())?Lt("Invalid Date"):ae(e.toISOString()):e instanceof URL?ae(e.href):sAt(e)?e[he]():Aw(e);default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Aw=e=>(HJ.has(e)||HJ.set(e,hu(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),HJ.get(e)),we=e=>t=>t*53^e,XM=e=>e&3221225471|e>>>1&1073741824,sAt=e=>se(e,he),hu=e=>{if(e!==e||e===1/0)return 0;let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return XM(t)},Lt=e=>{let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return XM(t)},aAt=(e,t)=>{let r=12289;for(let n=0;n<t.length;n++)r^=C(Lt(t[n]),we(ae(e[t[n]])));return XM(r)},eF=e=>aAt(e,Object.keys(e)),So=e=>{let t=6151;for(let r=0;r<e.length;r++)t=C(t,we(ae(e[r])));return XM(t)},We=function(){if(arguments.length===1){let r=arguments[0];return function(n){return Object.defineProperty(r,he,{value(){return n},enumerable:!1}),n}}let e=arguments[0],t=arguments[1];return Object.defineProperty(e,he,{value(){return t},enumerable:!1}),t}});function ce(){return arguments.length===1?e=>tF(e,arguments[0]):tF(arguments[0],arguments[1])}function tF(e,t){if(e===t)return!0;let r=typeof e;if(r!==typeof t)return!1;if(r==="object"||r==="function"){if(e!==null&&t!==null){if(yw(e)&&yw(t))return ae(e)===ae(t)&&e[me](t)?!0:va.enabled&&va.tester?va.tester(e,t):!1;if(e instanceof Date&&t instanceof Date){let n=e.getTime(),o=t.getTime();return n===o||Number.isNaN(n)&&Number.isNaN(o)}else if(e instanceof URL&&t instanceof URL)return e.href===t.href}if(va.enabled){if(e===null||t===null)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,o)=>tF(n,t[o]));if(Object.getPrototypeOf(e)===Object.prototype&&Object.getPrototypeOf(t)===Object.prototype){let n=Object.keys(e),o=Object.keys(t);if(n.length===o.length){for(let i of n)if(!(i in t&&tF(e[i],t[i])))return va.tester?va.tester(e,t):!1;return!0}}return va.tester?va.tester(e,t):!1}}return va.enabled&&va.tester?va.tester(e,t):!1}var me,yw,l_,mt=h(()=>{ir();ct();mu();me=Symbol.for("effect/Equal");yw=e=>se(e,me),l_=()=>ce});function EEe(e){try{return e.toISOString()}catch{return"Invalid Date"}}function cAt(e){try{let t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}function Hg(e){return Fo(e)?JSON.stringify(e):String(e)}function uc(e,t){let r=t?.space??0,n=new WeakSet,o=r?Ls(r)?" ".repeat(r):r:"",i=u=>o.repeat(u),s=(u,l)=>{let d=u?.constructor;return d&&d!==Object.prototype.constructor&&d.name?`${d.name}(${l})`:l},a=u=>{try{return Reflect.ownKeys(u)}catch{return["[ownKeys threw]"]}};function c(u,l=0){if(Array.isArray(u)){if(n.has(u))return WJ;if(n.add(u),!o||u.length<=1)return`[${u.map(f=>c(f,l)).join(",")}]`;let d=u.map(f=>c(f,l+1)).join(`,
23
23
  `+i(l+1));return`[
24
24
  ${i(l+1)}${d}
25
- ${i(l)}]`}if(KM(u))return EEe(u);if(!t?.ignoreToString&&se(u,"toString")&&gm(u.toString)&&u.toString!==Object.prototype.toString&&u.toString!==Array.prototype.toString){let d=cAt(u);return u instanceof Error&&u.cause?`${d} (cause: ${c(u.cause,l)})`:d}if(Fo(u))return JSON.stringify(u);if(Ls(u)||u==null||hm(u)||fE(u))return String(u);if($g(u))return String(u)+"n";if(u instanceof Set||u instanceof Map)return n.has(u)?WJ:(n.add(u),`${u.constructor.name}(${c(Array.from(u),l)})`);if(yi(u)){if(n.has(u))return WJ;n.add(u);let d=a(u);if(!o||d.length<=1){let p=`{${d.map(m=>`${Hg(m)}:${c(u[m],l)}`).join(",")}}`;return s(u,p)}let f=`{
25
+ ${i(l)}]`}if(KM(u))return EEe(u);if(!t?.ignoreToString&&se(u,"toString")&&gm(u.toString)&&u.toString!==Object.prototype.toString&&u.toString!==Array.prototype.toString){let d=cAt(u);return u instanceof Error&&u.cause?`${d} (cause: ${c(u.cause,l)})`:d}if(Fo(u))return JSON.stringify(u);if(Ls(u)||u==null||hm(u)||fE(u))return String(u);if($g(u))return String(u)+"n";if(u instanceof Set||u instanceof Map)return n.has(u)?WJ:(n.add(u),`${u.constructor.name}(${c(Array.from(u),l)})`);if(xi(u)){if(n.has(u))return WJ;n.add(u);let d=a(u);if(!o||d.length<=1){let p=`{${d.map(m=>`${Hg(m)}:${c(u[m],l)}`).join(",")}}`;return s(u,p)}let f=`{
26
26
  ${d.map(p=>`${i(l+1)}${Hg(p)}: ${c(u[p],l+1)}`).join(`,
27
27
  `)}
28
- ${i(l)}}`;return s(u,f)}return String(u)}return c(e,0)}var Ce,xt,WJ,Fe,Am,Wg,ym,rF,d_,bEe,hE,SEe,xw,ht=h(()=>{yn();ct();Ce=Symbol.for("nodejs.util.inspect.custom"),xt=e=>{try{if(se(e,"toJSON")&&gm(e.toJSON)&&e.toJSON.length===0)return e.toJSON();if(Array.isArray(e))return e.map(xt)}catch{return{}}return xw(e)},WJ="[Circular]";Fe=e=>JSON.stringify(e,null,2),Am={toJSON(){return xt(this)},[Ce](){return this.toJSON()},toString(){return Fe(this.toJSON())}},Wg=class{[Ce](){return this.toJSON()}toString(){return Fe(this.toJSON())}},ym=(e,t=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?rF(e,t):String(e)}catch{return String(e)}},rF=(e,t)=>{let r=[],n=JSON.stringify(e,(o,i)=>typeof i=="object"&&i!==null?r.includes(i)?void 0:r.push(i)&&(hE.fiberRefs!==void 0&&bEe(i)?i[d_](hE.fiberRefs):i):i,t);return r=void 0,n},d_=Symbol.for("effect/Inspectable/Redactable"),bEe=e=>typeof e=="object"&&e!==null&&d_ in e,hE=Te("effect/Inspectable/redactableState",()=>({fiberRefs:void 0})),SEe=(e,t)=>{let r=hE.fiberRefs;hE.fiberRefs=e;try{return t()}finally{hE.fiberRefs=r}},xw=e=>bEe(e)&&hE.fiberRefs!==void 0?e[d_](hE.fiberRefs):e});var Z,Me=h(()=>{Z=(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 r=e;for(let n=0,o=t.length;n<o;n++)r=t[n](r);return r}}}});var gE,AE,Rr,Ew,bw,Sw,_r,nF,CEe,xm,Cw,yE,oF,ww,f_,Iw=h(()=>{gE="Async",AE="Commit",Rr="Failure",Ew="OnFailure",bw="OnSuccess",Sw="OnSuccessAndFailure",_r="Success",nF="Sync",CEe="Tag",xm="UpdateRuntimeFlags",Cw="While",yE="Iterator",oF="WithRuntime",ww="Yield",f_="RevertFlags"});var lAt,m_,jJ=h(()=>{lAt="3.21.3",m_=()=>lAt});var IEe,kEe,vEe,REe,jg,dAt,fAt,Em,gf,gu,iF,_Ee,BEe,Af=h(()=>{mt();ir();Me();mu();Iw();jJ();IEe=Symbol.for("effect/Effect"),kEe=Symbol.for("effect/Stream"),vEe=Symbol.for("effect/Sink"),REe=Symbol.for("effect/Channel"),jg={_R:e=>e,_E:e=>e,_A:e=>e,_V:m_()},dAt={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e},fAt={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},Em={[IEe]:jg,[kEe]:jg,[vEe]:dAt,[REe]:fAt,[me](e){return this===e},[he](){return We(this,Aw(this))},[Symbol.iterator](){return new mE(new hf(this))},pipe(){return Z(this,arguments)}},gf={[he](){return We(this,eF(this))},[me](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n of t)if(!(n in e&&ce(this[n],e[n])))return!1;return!0}},gu={...Em,_op:AE},iF={...gu,...gf},_Ee=function(){function e(){}return e.prototype=gu,e}(),BEe=function(){function e(){}return e.prototype=iF,e}()});var DEe,QEe,pAt,mAt,hAt,sF,qg,qJ,Gg,Au,h_=h(()=>{mt();ir();ht();ct();Af();DEe=Symbol.for("effect/Option"),QEe={...Em,[DEe]:{_A:e=>e},[Ce](){return this.toJSON()},toString(){return Fe(this.toJSON())}},pAt=Object.assign(Object.create(QEe),{_tag:"Some",_op:"Some",[me](e){return sF(e)&&qJ(e)&&ce(this.value,e.value)},[he](){return We(this,we(ae(this._tag))(ae(this.value)))},toJSON(){return{_id:"Option",_tag:this._tag,value:xt(this.value)}}}),mAt=ae("None"),hAt=Object.assign(Object.create(QEe),{_tag:"None",_op:"None",[me](e){return sF(e)&&qg(e)},[he](){return mAt},toJSON(){return{_id:"Option",_tag:this._tag}}}),sF=e=>se(e,DEe),qg=e=>e._tag==="None",qJ=e=>e._tag==="Some",Gg=Object.create(hAt),Au=e=>{let t=Object.create(pAt);return t.value=e,t}});var GJ,OEe,gAt,AAt,cF,kw,uF,g_,A_,zJ,VJ,NEe,YJ=h(()=>{mt();oe();ir();ht();ct();Af();h_();GJ=Symbol.for("effect/Either"),OEe={...Em,[GJ]:{_R:e=>e},[Ce](){return this.toJSON()},toString(){return Fe(this.toJSON())}},gAt=Object.assign(Object.create(OEe),{_tag:"Right",_op:"Right",[me](e){return cF(e)&&uF(e)&&ce(this.right,e.right)},[he](){return we(ae(this._tag))(ae(this.right))},toJSON(){return{_id:"Either",_tag:this._tag,right:xt(this.right)}}}),AAt=Object.assign(Object.create(OEe),{_tag:"Left",_op:"Left",[me](e){return cF(e)&&kw(e)&&ce(this.left,e.left)},[he](){return we(ae(this._tag))(ae(this.left))},toJSON(){return{_id:"Either",_tag:this._tag,left:xt(this.left)}}}),cF=e=>se(e,GJ),kw=e=>e._tag==="Left",uF=e=>e._tag==="Right",g_=e=>{let t=Object.create(AAt);return t.left=e,t},A_=e=>{let t=Object.create(gAt);return t.right=e,t},zJ=e=>uF(e)?Gg:Au(e.left),VJ=e=>kw(e)?Gg:Au(e.right),NEe=x(2,(e,t)=>qg(e)?g_(t()):A_(e.value))});var Le,Re,JJ,MEe,xr,ii,FEe,LEe,lF,xi,vw,y_,UEe,$Ee,Ei=h(()=>{oe();YJ();Le=A_,Re=g_,JJ=NEe,MEe=cF,xr=kw,ii=uF,FEe=x(2,(e,{onLeft:t,onRight:r})=>xr(e)?Re(t(e.left)):Le(r(e.right))),LEe=x(2,(e,t)=>xr(e)?Re(t(e.left)):Le(e.right)),lF=x(2,(e,t)=>ii(e)?Le(t(e.right)):Re(e.left)),xi=x(2,(e,{onLeft:t,onRight:r})=>xr(e)?t(e.left):r(e.right)),vw=xi({onLeft:be,onRight:be}),y_=x(2,(e,t)=>{if(ii(e))return e.right;throw t(e.left)}),UEe=y_(()=>new Error("getOrThrow called on a Left")),$Ee=e=>{if(Symbol.iterator in e){let r=[];for(let n of e){if(xr(n))return n;r.push(n.right)}return Le(r)}let t={};for(let r of Object.keys(e)){let n=e[r];if(xr(n))return n;t[r]=n.right}return Le(t)}});var KJ,HEe=h(()=>{KJ=e=>e.length>0});var xE,WEe,yf,xAt,jEe,ZJ,dF,fF,pF,XJ,e6,bm=h(()=>{oe();xE=e=>(t,r)=>t===r?0:e(t,r),WEe=xE((e,t)=>e<t?-1:1),yf=x(2,(e,t)=>xE((r,n)=>e(t(r),t(n)))),xAt=e=>xE((t,r)=>{let n=Math.min(t.length,r.length),o=0;for(let i of e){if(o>=n)break;let s=i(t[o],r[o]);if(s!==0)return s;o++}return 0}),jEe=(...e)=>xAt(e),ZJ=e=>x(2,(t,r)=>e(t,r)===-1),dF=e=>x(2,(t,r)=>e(t,r)===1),fF=e=>x(2,(t,r)=>t===r||e(t,r)<1?t:r),pF=e=>x(2,(t,r)=>t===r||e(t,r)>-1?t:r),XJ=e=>x(2,(t,r)=>fF(e)(r.maximum,pF(e)(r.minimum,t))),e6=e=>x(2,(t,r)=>!ZJ(e)(t,r.minimum)&&!dF(e)(t,r.maximum))});var Ke={};tr(Ke,{Do:()=>qAt,TypeId:()=>EAt,all:()=>JEe,andThen:()=>_At,ap:()=>NAt,as:()=>zEe,asVoid:()=>vAt,bind:()=>jAt,bindTo:()=>HAt,composeK:()=>QAt,contains:()=>s6,containsWith:()=>ebe,exists:()=>a6,filter:()=>hF,filterMap:()=>ZEe,firstSomeOf:()=>IAt,flatMap:()=>Gn,flatMapNullable:()=>o6,flatten:()=>BAt,fromIterable:()=>SAt,fromNullable:()=>en,gen:()=>zAt,getEquivalence:()=>XEe,getLeft:()=>CAt,getOrElse:()=>Nt,getOrNull:()=>qEe,getOrThrow:()=>mF,getOrThrowWith:()=>GEe,getOrUndefined:()=>Gr,getOrder:()=>FAt,getRight:()=>r6,isNone:()=>Ct,isOption:()=>t6,isSome:()=>pt,let:()=>WAt,lift2:()=>LAt,liftNullable:()=>kAt,liftPredicate:()=>UAt,liftThrowable:()=>EE,map:()=>dr,match:()=>wt,mergeWith:()=>Vg,none:()=>W,orElse:()=>lc,orElseEither:()=>wAt,orElseSome:()=>n6,partitionMap:()=>MAt,product:()=>YEe,productMany:()=>OAt,reduceCompact:()=>PAt,some:()=>H,tap:()=>VEe,toArray:()=>KEe,toRefinement:()=>bAt,void:()=>RAt,zipLeft:()=>DAt,zipRight:()=>TAt,zipWith:()=>i6});var EAt,W,H,t6,Ct,pt,wt,bAt,SAt,r6,CAt,Nt,lc,n6,wAt,IAt,en,kAt,qEe,Gr,EE,GEe,mF,dr,zEe,vAt,RAt,Gn,_At,o6,BAt,TAt,DAt,QAt,VEe,YEe,OAt,JEe,i6,NAt,PAt,KEe,MAt,ZEe,hF,XEe,FAt,LAt,UAt,ebe,$At,s6,a6,HAt,WAt,jAt,qAt,GAt,zAt,Vg,it=h(()=>{mt();mm();oe();NJ();YJ();h_();bm();mu();EAt=Symbol.for("effect/Option"),W=()=>Gg,H=Au,t6=sF,Ct=qg,pt=qJ,wt=x(2,(e,{onNone:t,onSome:r})=>Ct(e)?t():r(e.value)),bAt=e=>t=>pt(e(t)),SAt=e=>{for(let t of e)return H(t);return W()},r6=VJ,CAt=zJ,Nt=x(2,(e,t)=>Ct(e)?t():e.value),lc=x(2,(e,t)=>Ct(e)?t():e),n6=x(2,(e,t)=>Ct(e)?H(t()):e),wAt=x(2,(e,t)=>Ct(e)?dr(t(),A_):dr(e,g_)),IAt=e=>{let t=W();for(t of e)if(pt(t))return t;return t},en=e=>e==null?W():H(e),kAt=e=>(...t)=>en(e(...t)),qEe=Nt(DJ),Gr=Nt(hw),EE=e=>(...t)=>{try{return H(e(...t))}catch{return W()}},GEe=x(2,(e,t)=>{if(pt(e))return e.value;throw t()}),mF=GEe(()=>new Error("getOrThrow called on a None")),dr=x(2,(e,t)=>Ct(e)?W():H(t(e.value))),zEe=x(2,(e,t)=>dr(e,()=>t)),vAt=zEe(void 0),RAt=H(void 0),Gn=x(2,(e,t)=>Ct(e)?W():t(e.value)),_At=x(2,(e,t)=>Gn(e,r=>{let n=GM(t)?t(r):t;return t6(n)?n:H(n)})),o6=x(2,(e,t)=>Ct(e)?W():en(t(e.value))),BAt=Gn(be),TAt=x(2,(e,t)=>Gn(e,()=>t)),DAt=x(2,(e,t)=>VEe(e,()=>t)),QAt=x(2,(e,t)=>r=>Gn(e(r),t)),VEe=x(2,(e,t)=>Gn(e,r=>dr(t(r),()=>r))),YEe=(e,t)=>pt(e)&&pt(t)?H([e.value,t.value]):W(),OAt=(e,t)=>{if(Ct(e))return W();let r=[e.value];for(let n of t){if(Ct(n))return W();r.push(n.value)}return H(r)},JEe=e=>{if(Symbol.iterator in e){let r=[];for(let n of e){if(Ct(n))return W();r.push(n.value)}return H(r)}let t={};for(let r of Object.keys(e)){let n=e[r];if(Ct(n))return W();t[r]=n.value}return H(t)},i6=x(3,(e,t,r)=>dr(YEe(e,t),([n,o])=>r(n,o))),NAt=x(2,(e,t)=>i6(e,t,(r,n)=>r(n))),PAt=x(3,(e,t,r)=>{let n=t;for(let o of e)pt(o)&&(n=r(n,o.value));return n}),KEe=e=>Ct(e)?[]:[e.value],MAt=x(2,(e,t)=>{if(Ct(e))return[W(),W()];let r=t(e.value);return kw(r)?[H(r.left),W()]:[W(),H(r.right)]}),ZEe=Gn,hF=x(2,(e,t)=>ZEe(e,r=>t(r)?Au(r):Gg)),XEe=e=>Ml((t,r)=>Ct(t)?Ct(r):Ct(r)?!1:e(t.value,r.value)),FAt=e=>xE((t,r)=>pt(t)?pt(r)?e(t.value,r.value):1:-1),LAt=e=>x(2,(t,r)=>i6(t,r,e)),UAt=x(2,(e,t)=>t(e)?H(e):W()),ebe=e=>x(2,(t,r)=>Ct(t)?!1:e(t.value,r)),$At=l_(),s6=ebe($At),a6=x(2,(e,t)=>Ct(e)?!1:t(e.value)),HAt=YM(dr),WAt=VM(dr),jAt=JM(dr,Gn),qAt=H({}),GAt=AEe(),zAt=(...e)=>{let r=(e.length===1?e[0]:e[1].bind(e[0]))(GAt),n=r.next();for(;!n.done;){let o=gEe(n.value)?n.value.value:u_(n.value);if(Ct(o))return o;n=r.next(o.value)}return H(n.value)},Vg=e=>(t,r)=>Ct(t)?r:Ct(r)?t:H(e(t.value,r.value))});var tbe,c6=h(()=>{tbe=(...e)=>e});var VAt,YAt,gF,u6,x_=h(()=>{oe();VAt={[Symbol.iterator](){return YAt}},YAt={next(){return{done:!0,value:void 0}}},gF=()=>VAt,u6=x(2,(e,t)=>({[Symbol.iterator](){let r=e[Symbol.iterator](),n=0;return{next(){let o=r.next();return o.done?{done:!0,value:void 0}:{done:!1,value:t(o.value,n++)}}}}}))});var Sm,JAt,l6,E_=h(()=>{oe();Sm=x(2,(e,t)=>{let r={...e};for(let n of JAt(e))r[n]=t(e[n],n);return r}),JAt=e=>Object.keys(e),l6=x(3,(e,t,r)=>({...e,[t]:r}))});var bE,d6,_e,f6,nbe,Rw,p6,xF,m6,KAt,obe,Cm,zr,ibe,ZAt,XAt,h6,wm,Lo,EF,g6,Ll,eyt,sbe,abe,bF,Vi,A6,cbe,tyt,y6,ryt,_w,nyt,Ul,Us,hs,$l,SE,b_,Yg,x6,ube,E6,yu,SF,b6,Jg,lbe,S6,Im,wr=h(()=>{Ei();mt();mm();oe();HEe();it();c6();bE=e=>new Array(e),d6=x(2,(e,t)=>{let r=Math.max(1,Math.floor(e)),n=new Array(r);for(let o=0;o<r;o++)n[o]=t(o);return n}),_e=e=>Array.isArray(e)?e:Array.from(e),f6=e=>Array.isArray(e)?e:[e],nbe=x(2,(e,{onEmpty:t,onNonEmpty:r})=>zr(e)?r(Lo(e),Ll(e)):t()),Rw=x(2,(e,t)=>[t,...e]),p6=x(2,(e,t)=>[...e,t]),xF=x(2,(e,t)=>_e(e).concat(_e(t))),m6=Array.isArray,KAt=e=>e.length===0,obe=KAt,Cm=KJ,zr=KJ,ibe=(e,t)=>e<0||e>=t.length,ZAt=(e,t)=>Math.floor(Math.min(Math.max(0,e),t.length)),XAt=x(2,(e,t)=>{let r=Math.floor(t);return ibe(r,e)?W():H(e[r])}),h6=x(2,(e,t)=>{let r=Math.floor(t);if(ibe(r,e))throw new Error(`Index ${r} out of bounds`);return e[r]}),wm=XAt(0),Lo=h6(0),EF=e=>zr(e)?H(g6(e)):W(),g6=e=>e[e.length-1],Ll=e=>e.slice(1),eyt=(e,t)=>{let r=0;for(let n of e){if(!t(n,r))break;r++}return r},sbe=x(2,(e,t)=>y6(e,eyt(e,t))),abe=x(2,(e,t)=>{let r=_e(e);return r.slice(ZAt(t,r),r.length)}),bF=e=>Array.from(e).reverse(),Vi=x(2,(e,t)=>{let r=Array.from(e);return r.sort(t),r}),A6=x(2,(e,t)=>cbe(e,t,tbe)),cbe=x(3,(e,t,r)=>{let n=_e(e),o=_e(t);if(zr(n)&&zr(o)){let i=[r(Lo(n),Lo(o))],s=Math.min(n.length,o.length);for(let a=1;a<s;a++)i[a]=r(n[a],o[a]);return i}return[]}),tyt=l_(),y6=x(2,(e,t)=>{let r=Array.from(e),n=Math.floor(t);return zr(r)?n>=1?ryt(r,n):[[],r]:[r,[]]}),ryt=x(2,(e,t)=>{let r=Math.max(1,Math.floor(t));return r>=e.length?[_w(e),[]]:[Rw(e.slice(1,r),Lo(e)),e.slice(r)]}),_w=e=>e.slice(),nyt=x(3,(e,t,r)=>{let n=_e(e),o=_e(t);return zr(n)?zr(o)?lbe(r)(xF(n,o)):n:o}),Ul=x(2,(e,t)=>nyt(e,t,tyt)),Us=()=>[],hs=e=>[e],$l=x(2,(e,t)=>e.map(t)),SE=x(2,(e,t)=>{if(obe(e))return[];let r=[];for(let n=0;n<e.length;n++){let o=t(e[n],n);for(let i=0;i<o.length;i++)r.push(o[i])}return r}),b_=SE(be),Yg=x(2,(e,t)=>{let r=_e(e),n=[];for(let o=0;o<r.length;o++){let i=t(r[o],o);pt(i)&&n.push(i.value)}return n}),x6=x(2,(e,t)=>{let r=[],n=[],o=_e(e);for(let i=0;i<o.length;i++){let s=t(o[i],i);xr(s)?r.push(s.left):n.push(s.right)}return[r,n]}),ube=Yg(be),E6=x(2,(e,t)=>{let r=_e(e),n=[];for(let o=0;o<r.length;o++)t(r[o],o)&&n.push(r[o]);return n}),yu=x(3,(e,t,r)=>_e(e).reduce((n,o,i)=>r(n,o,i),t)),SF=x(3,(e,t,r)=>_e(e).reduceRight((n,o,i)=>r(n,o,i),t)),b6=(e,t)=>{let r=[],n=e,o;for(;pt(o=t(n));){let[i,s]=o.value;r.push(i),n=s}return r},Jg=zM,lbe=x(2,(e,t)=>{let r=_e(e);if(zr(r)){let n=[Lo(r)],o=Ll(r);for(let i of o)n.every(s=>!t(i,s))&&n.push(i);return n}return[]}),S6=e=>lbe(e,l_()),Im=x(2,(e,t)=>_e(e).join(t))});function syt(e,t,r,n,o){for(let i=t;i<Math.min(e.length,t+o);i++)r[n+i-t]=e[i];return r}var fbe,pbe,ayt,cyt,uyt,Xn,S_,Hl,Ut,Kg,Dt,Co,C6,lyt,mbe,dyt,Uo,fyt,gs,pyt,ln,myt,Wl,$s,fr,Bw,jl,Ir,Tw,C_,xu,kr,CE,w_,Gt,xf,hbe,Ur,w6,gbe,I_,vr=h(()=>{wr();mt();mm();oe();ir();ht();it();Me();ct();fbe=Symbol.for("effect/Chunk");pbe=[],ayt=e=>Ml((t,r)=>t.length===r.length&&Uo(t).every((n,o)=>e(n,Wl(r,o)))),cyt=ayt(ce),uyt={[fbe]:{_A:e=>e},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"Chunk",values:Uo(this).map(xt)}},[Ce](){return this.toJSON()},[me](e){return S_(e)&&cyt(this,e)},[he](){return We(this,So(Uo(this)))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return pbe[Symbol.iterator]();default:return Uo(this)[Symbol.iterator]()}},pipe(){return Z(this,arguments)}},Xn=e=>{let t=Object.create(uyt);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=Hl,t.right=Hl;break}case"ISingleton":{t.length=1,t.depth=0,t.left=Hl,t.right=Hl;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=Hl,t.right=Hl;break}}return t},S_=e=>se(e,fbe),Hl=Xn({_tag:"IEmpty"}),Ut=()=>Hl,Kg=(...e)=>myt(e),Dt=e=>Xn({_tag:"ISingleton",a:e}),Co=e=>S_(e)?e:ln(_e(e)),C6=(e,t,r)=>{switch(e.backing._tag){case"IArray":{syt(e.backing.array,0,t,r,e.length);break}case"IConcat":{C6(e.left,t,r),C6(e.right,t,r+e.left.length);break}case"ISingleton":{t[r]=e.backing.a;break}case"ISlice":{let n=0,o=r;for(;n<e.length;)t[o]=Wl(e,n),n+=1,o+=1;break}}},lyt=e=>Uo(e).slice(),mbe=lyt,dyt=e=>{switch(e.backing._tag){case"IEmpty":return pbe;case"IArray":return e.backing.array;default:{let t=new Array(e.length);return C6(e,t,0),e.backing={_tag:"IArray",array:t},e.left=Hl,e.right=Hl,e.depth=0,t}}},Uo=dyt,fyt=e=>{switch(e.backing._tag){case"IEmpty":case"ISingleton":return e;case"IArray":return Xn({_tag:"IArray",array:bF(e.backing.array)});case"IConcat":return Xn({_tag:"IConcat",left:gs(e.backing.right),right:gs(e.backing.left)});case"ISlice":return ln(bF(Uo(e)))}},gs=fyt,pyt=x(2,(e,t)=>t<0||t>=e.length?W():H(Wl(e,t))),ln=e=>e.length===0?Ut():e.length===1?Dt(e[0]):Xn({_tag:"IArray",array:e}),myt=e=>ln(e),Wl=x(2,(e,t)=>{switch(e.backing._tag){case"IEmpty":throw new Error("Index out of bounds");case"ISingleton":{if(t!==0)throw new Error("Index out of bounds");return e.backing.a}case"IArray":{if(t>=e.length||t<0)throw new Error("Index out of bounds");return e.backing.array[t]}case"IConcat":return t<e.left.length?Wl(e.left,t):Wl(e.right,t-e.left.length);case"ISlice":return Wl(e.backing.chunk,t+e.backing.offset)}}),$s=x(2,(e,t)=>Ir(e,Dt(t))),fr=x(2,(e,t)=>Ir(Dt(t),e)),Bw=x(2,(e,t)=>{if(t<=0)return Hl;if(t>=e.length)return e;switch(e.backing._tag){case"ISlice":return Xn({_tag:"ISlice",chunk:e.backing.chunk,length:t,offset:e.backing.offset});case"IConcat":return t>e.left.length?Xn({_tag:"IConcat",left:e.left,right:Bw(e.right,t-e.left.length)}):Bw(e.left,t);default:return Xn({_tag:"ISlice",chunk:e,offset:0,length:t})}}),jl=x(2,(e,t)=>{if(t<=0)return e;if(t>=e.length)return Hl;switch(e.backing._tag){case"ISlice":return Xn({_tag:"ISlice",chunk:e.backing.chunk,offset:e.backing.offset+t,length:e.backing.length-t});case"IConcat":return t>e.left.length?jl(e.right,t-e.left.length):Xn({_tag:"IConcat",left:jl(e.left,t),right:e.right});default:return Xn({_tag:"ISlice",chunk:e,offset:t,length:e.length-t})}}),Ir=x(2,(e,t)=>{if(e.backing._tag==="IEmpty")return t;if(t.backing._tag==="IEmpty")return e;let r=t.depth-e.depth;if(Math.abs(r)<=1)return Xn({_tag:"IConcat",left:e,right:t});if(r<-1)if(e.left.depth>=e.right.depth){let n=Ir(e.right,t);return Xn({_tag:"IConcat",left:e.left,right:n})}else{let n=Ir(e.right.right,t);if(n.depth===e.depth-3){let o=Xn({_tag:"IConcat",left:e.right.left,right:n});return Xn({_tag:"IConcat",left:e.left,right:o})}else{let o=Xn({_tag:"IConcat",left:e.left,right:e.right.left});return Xn({_tag:"IConcat",left:o,right:n})}}else if(t.right.depth>=t.left.depth){let n=Ir(e,t.left);return Xn({_tag:"IConcat",left:n,right:t.right})}else{let n=Ir(e,t.left.left);if(n.depth===t.depth-3){let o=Xn({_tag:"IConcat",left:n,right:t.left.right});return Xn({_tag:"IConcat",left:o,right:t.right})}else{let o=Xn({_tag:"IConcat",left:t.left.right,right:t.right});return Xn({_tag:"IConcat",left:n,right:o})}}}),Tw=x(2,(e,t)=>ln(E6(e,t))),C_=x(2,(e,t)=>Uo(e).forEach(t)),xu=e=>e.length===0,kr=e=>e.length>0,CE=pyt(0),w_=e=>Wl(e,0),Gt=w_,xf=x(2,(e,t)=>e.backing._tag==="ISingleton"?Dt(t(e.backing.a,0)):ln(C(Uo(e),$l((r,n)=>t(r,n))))),hbe=x(2,(e,t)=>ln(Vi(Uo(e),t))),Ur=e=>jl(e,1),w6=x(2,(e,t)=>jl(e,e.length-t)),gbe=x(2,(e,t)=>_e(e).some(t)),I_=yu});var I6,Abe,ybe,xbe,k6=h(()=>{I6=Math.pow(2,5),Abe=I6-1,ybe=I6/2,xbe=I6/4});function hyt(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,e+=e>>16,e&127}function Zg(e,t){return t>>>e&Abe}function Xg(e){return 1<<e}function CF(e,t){return hyt(e&t-1)}var v6=h(()=>{k6()});var Ebe,bbe=h(()=>{Ebe=(e,t)=>({value:e,previous:t})});function wE(e,t,r,n){let o=n;if(!e){let i=n.length;o=new Array(i);for(let s=0;s<i;++s)o[s]=n[s]}return o[t]=r,o}function R6(e,t,r){let n=r.length-1,o=0,i=0,s=r;if(e)o=i=t;else for(s=new Array(n);o<t;)s[i++]=r[o++];for(++o;o<=n;)s[i++]=r[o++];return e&&(s.length=n),s}function Sbe(e,t,r,n){let o=n.length;if(e){let c=o;for(;c>=t;)n[c--]=n[c];return n[t]=r,n}let i=0,s=0,a=new Array(o+1);for(;i<t;)a[s++]=n[i++];for(a[t]=r;i<o;)a[++s]=n[i++];return a}var Cbe=h(()=>{});function Eu(e){return mf(e,"EmptyNode")}function Ayt(e){return Eu(e)||e._tag==="LeafNode"||e._tag==="CollisionNode"}function wF(e,t){return Eu(e)?!1:t===e.edit}function yyt(e,t,r,n){let o=new Array(t-1),i=0,s=0;for(let a=0,c=n.length;a<c;++a)if(a!==r){let u=n[a];u&&!Eu(u)&&(o[i++]=u,s|=1<<a)}return new k_(e,s,o)}function xyt(e,t,r,n,o){let i=[],s=n,a=0;for(let c=0;s;++c)s&1&&(i[c]=o[a++]),s>>>=1;return i[t]=r,new B6(e,a+1,i)}function Eyt(e,t,r,n,o,i){if(r===o)return new _6(e,r,[i,n]);let s=Zg(t,r),a=Zg(t,o);if(s===a)return c=>new k_(e,Xg(s)|Xg(a),[c]);{let c=s<a?[n,i]:[i,n];return new k_(e,Xg(s)|Xg(a),c)}}function wbe(e,t,r,n,o,i){let s,a=t;for(;;){let c=Eyt(e,a,r,n,o,i);if(typeof c=="function")s=Ebe(c,s),a=a+5;else{let u=c;for(;s!=null;)u=s.value(u),s=s.previous;return u}}}var km,Dw,_6,k_,B6,Ibe=h(()=>{mt();it();ct();bbe();Cbe();v6();k6();km=class e{_tag="EmptyNode";modify(t,r,n,o,i,s){let a=n(W());return Ct(a)?new e:(++s.value,new Dw(t,o,i,a))}};Dw=class e{edit;hash;key;value;_tag="LeafNode";constructor(t,r,n,o){this.edit=t,this.hash=r,this.key=n,this.value=o}modify(t,r,n,o,i,s){if(ce(i,this.key)){let c=n(this.value);return c===this.value?this:Ct(c)?(--s.value,new km):wF(this,t)?(this.value=c,this):new e(t,o,i,c)}let a=n(W());return Ct(a)?this:(++s.value,wbe(t,r,this.hash,this,o,new e(t,o,i,a)))}},_6=class e{edit;hash;children;_tag="CollisionNode";constructor(t,r,n){this.edit=t,this.hash=r,this.children=n}modify(t,r,n,o,i,s){if(o===this.hash){let c=wF(this,t),u=this.updateCollisionList(c,t,this.hash,this.children,n,i,s);return u===this.children?this:u.length>1?new e(t,this.hash,u):u[0]}let a=n(W());return Ct(a)?this:(++s.value,wbe(t,r,this.hash,this,o,new Dw(t,o,i,a)))}updateCollisionList(t,r,n,o,i,s,a){let c=o.length;for(let l=0;l<c;++l){let d=o[l];if("key"in d&&ce(s,d.key)){let f=d.value,p=i(f);return p===f?o:Ct(p)?(--a.value,R6(t,l,o)):wE(t,l,new Dw(r,n,s,p),o)}}let u=i(W());return Ct(u)?o:(++a.value,wE(t,c,new Dw(r,n,s,u),o))}},k_=class e{edit;mask;children;_tag="IndexedNode";constructor(t,r,n){this.edit=t,this.mask=r,this.children=n}modify(t,r,n,o,i,s){let a=this.mask,c=this.children,u=Zg(r,o),l=Xg(u),d=CF(a,l),f=a&l,p=wF(this,t);if(!f){let y=new km().modify(t,r+5,n,o,i,s);return y?c.length>=ybe?xyt(t,u,y,a,c):new e(t,a|l,Sbe(p,d,y,c)):this}let m=c[d],g=m.modify(t,r+5,n,o,i,s);if(m===g)return this;let A=a,E;if(Eu(g)){if(A&=~l,!A)return new km;if(c.length<=2&&Ayt(c[d^1]))return c[d^1];E=R6(p,d,c)}else E=wE(p,d,g,c);return p?(this.mask=A,this.children=E,this):new e(t,A,E)}},B6=class e{edit;size;children;_tag="ArrayNode";constructor(t,r,n){this.edit=t,this.size=r,this.children=n}modify(t,r,n,o,i,s){let a=this.size,c=this.children,u=Zg(r,o),l=c[u],d=(l||new km).modify(t,r+5,n,o,i,s);if(l===d)return this;let f=wF(this,t),p;if(Eu(l)&&!Eu(d))++a,p=wE(f,u,d,c);else if(!Eu(l)&&Eu(d)){if(--a,a<=xbe)return yyt(t,a,u,c);p=wE(f,u,new km,c)}else p=wE(f,u,d,c);return f?(this.size=a,this.children=p,this):new e(t,a,p)}}});var kbe,IF,Syt,T6,kF,vF,vbe,Rbe,Cyt,Ow,_be,Bbe,Tbe,Dbe,v_,Qbe,RF,IE,wyt,_F,R_,__,D6,Obe,BF,Nbe,TF,Pbe,DF,Nw,Q6=h(()=>{mt();oe();oe();ir();ht();it();Me();ct();v6();Ibe();kbe="effect/HashMap",IF=Symbol.for(kbe),Syt={[IF]:IF,[Symbol.iterator](){return new kF(this,(e,t)=>[e,t])},[he](){let e=ae(kbe);for(let t of this)e^=C(ae(t[0]),we(ae(t[1])));return We(this,e)},[me](e){if(Bbe(e)){if(e._size!==this._size)return!1;for(let t of this){let r=C(e,v_(t[0],ae(t[0])));if(Ct(r))return!1;if(!ce(t[1],r.value))return!1}return!0}return!1},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"HashMap",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},T6=(e,t,r,n)=>{let o=Object.create(Syt);return o._editable=e,o._edit=t,o._root=r,o._size=n,o},kF=class e{map;f;v;constructor(t,r){this.map=t,this.f=r,this.v=vbe(this.map._root,this.f,void 0)}next(){if(Ct(this.v))return{done:!0,value:void 0};let t=this.v.value;return this.v=vF(t.cont),{done:!1,value:t.value}}[Symbol.iterator](){return new e(this.map,this.f)}},vF=e=>e?Rbe(e[0],e[1],e[2],e[3],e[4]):W(),vbe=(e,t,r=void 0)=>{switch(e._tag){case"LeafNode":return pt(e.value)?H({value:t(e.key,e.value.value),cont:r}):vF(r);case"CollisionNode":case"ArrayNode":case"IndexedNode":{let n=e.children;return Rbe(n.length,n,0,t,r)}default:return vF(r)}},Rbe=(e,t,r,n,o)=>{for(;r<e;){let i=t[r++];if(i&&!Eu(i))return vbe(i,n,[e,t,r,n,o])}return vF(o)},Cyt=T6(!1,0,new km,0),Ow=()=>Cyt,_be=e=>{let t=__(Ow());for(let r of e)IE(t,r[0],r[1]);return D6(t)},Bbe=e=>se(e,IF),Tbe=e=>e&&Eu(e._root),Dbe=x(2,(e,t)=>v_(e,t,ae(t))),v_=x(3,(e,t,r)=>{let n=e._root,o=0;for(;;)switch(n._tag){case"LeafNode":return ce(t,n.key)?n.value:W();case"CollisionNode":{if(r===n.hash){let i=n.children;for(let s=0,a=i.length;s<a;++s){let c=i[s];if("key"in c&&ce(t,c.key))return c.value}}return W()}case"IndexedNode":{let i=Zg(o,r),s=Xg(i);if(n.mask&s){n=n.children[CF(n.mask,s)],o+=5;break}return W()}case"ArrayNode":{if(n=n.children[Zg(o,r)],n){o+=5;break}return W()}default:return W()}}),Qbe=x(2,(e,t)=>{let r=v_(e,t,ae(t));if(Ct(r))throw new Error("Expected map to contain key");return r.value}),RF=x(2,(e,t)=>pt(v_(e,t,ae(t)))),IE=x(3,(e,t,r)=>BF(e,t,()=>H(r))),wyt=x(3,(e,t,r)=>e._editable?(e._root=t,e._size=r,e):t===e._root?e:T6(e._editable,e._edit,t,r)),_F=e=>new kF(e,t=>t),R_=e=>e._size,__=e=>T6(!0,e._edit+1,e._root,e._size),D6=e=>(e._editable=!1,e),Obe=x(2,(e,t)=>{let r=__(e);return t(r),D6(r)}),BF=x(3,(e,t,r)=>Nbe(e,t,ae(t),r)),Nbe=x(4,(e,t,r,n)=>{let o={value:e._size},i=e._root.modify(e._editable?e._edit:NaN,0,n,r,t,o);return C(e,wyt(i,o.value))}),TF=x(2,(e,t)=>BF(e,t,W)),Pbe=x(2,(e,t)=>Nw(e,Ow(),(r,n,o)=>IE(r,o,t(n,o)))),DF=x(2,(e,t)=>Nw(e,void 0,(r,n,o)=>t(n,o))),Nw=x(3,(e,t,r)=>{let n=e._root;if(n._tag==="LeafNode")return pt(n.value)?r(t,n.value.value,n.key):t;if(n._tag==="EmptyNode")return t;let o=[n.children],i;for(;i=o.pop();)for(let s=0,a=i.length;s<a;){let c=i[s++];c&&!Eu(c)&&(c._tag==="LeafNode"?pt(c.value)&&(t=r(t,c.value.value,c.key)):o.push(c.children))}return t})});var Fbe,QF,Iyt,OF,Lbe,kyt,B_,Ube,$be,Hbe,Wbe,jbe,qbe,NF,PF,O6,Pw,N6,Gbe,zbe,Vbe,Ybe,Jbe=h(()=>{mt();oe();ir();ht();Me();ct();Q6();Fbe="effect/HashSet",QF=Symbol.for(Fbe),Iyt={[QF]:QF,[Symbol.iterator](){return _F(this._keyMap)},[he](){return We(this,we(ae(this._keyMap))(ae(Fbe)))},[me](e){return Lbe(e)?R_(this._keyMap)===R_(e._keyMap)&&ce(this._keyMap,e._keyMap):!1},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"HashSet",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},OF=e=>{let t=Object.create(Iyt);return t._keyMap=e,t},Lbe=e=>se(e,QF),kyt=OF(Ow()),B_=()=>kyt,Ube=e=>{let t=NF(B_());for(let r of e)Pw(t,r);return PF(t)},$be=(...e)=>{let t=NF(B_());for(let r of e)Pw(t,r);return PF(t)},Hbe=x(2,(e,t)=>RF(e._keyMap,t)),Wbe=x(2,(e,t)=>{let r=!1;for(let n of e)if(r=t(n),r)break;return r}),jbe=x(2,(e,t)=>!Wbe(e,r=>!t(r))),qbe=e=>R_(e._keyMap),NF=e=>OF(__(e._keyMap)),PF=e=>(e._keyMap._editable=!1,e),O6=x(2,(e,t)=>{let r=NF(e);return t(r),PF(r)}),Pw=x(2,(e,t)=>e._keyMap._editable?(IE(t,!0)(e._keyMap),e):OF(IE(t,!0)(e._keyMap))),N6=x(2,(e,t)=>e._keyMap._editable?(TF(t)(e._keyMap),e):OF(TF(t)(e._keyMap))),Gbe=x(2,(e,t)=>O6(e,r=>{for(let n of t)N6(r,n)})),zbe=x(2,(e,t)=>O6(B_(),r=>{Vbe(e,n=>Pw(r,n));for(let n of t)Pw(r,n)})),Vbe=x(2,(e,t)=>DF(e._keyMap,(r,n)=>t(n))),Ybe=x(3,(e,t,r)=>Nw(e._keyMap,t,(n,o,i)=>r(n,i)))});var ql,MF,eA,FF,Kbe,Gl,kE,P6,M6,Ef,tA,dc=h(()=>{Jbe();ql=B_,MF=Ube,eA=$be,FF=Hbe,Kbe=jbe,Gl=qbe,kE=Pw,P6=N6,M6=Gbe,Ef=zbe,tA=Ybe});var vE,rA,nA,RE,_E,BE,Zbe=h(()=>{vE="Die",rA="Empty",nA="Fail",RE="Interrupt",_E="Parallel",BE="Sequential"});var tSe,U6,_yt,Mw,Yi,zl,eo,Hs,to,Vr,T_,$6,rSe,QE,LF,Fw,OE,D_,Q_,NE,UF,Vl,nSe,oSe,H6,iSe,$F,sSe,O_,W6,j6,Byt,Tyt,Dyt,oA,F6,Qyt,Xbe,eSe,PE,TE,N_,Yl,aSe,L6,HF,Oyt,P_,Nyt,DE,M_,Jl=h(()=>{wr();vr();Ei();mt();oe();yn();ir();dc();ht();it();Me();ct();gw();Zbe();tSe="effect/Cause",U6=Symbol.for(tSe),_yt={_E:e=>e},Mw={[U6]:_yt,[he](){return C(ae(tSe),we(ae(Tyt(this))),We(this))},[me](e){return T_(e)&&Byt(this,e)},pipe(){return Z(this,arguments)},toJSON(){switch(this._tag){case"Empty":return{_id:"Cause",_tag:this._tag};case"Die":return{_id:"Cause",_tag:this._tag,defect:xt(this.defect)};case"Interrupt":return{_id:"Cause",_tag:this._tag,fiberId:this.fiberId.toJSON()};case"Fail":return{_id:"Cause",_tag:this._tag,failure:xt(this.error)};case"Sequential":case"Parallel":return{_id:"Cause",_tag:this._tag,left:xt(this.left),right:xt(this.right)}}},toString(){return Yl(this)},[Ce](){return this.toJSON()}},Yi=(()=>{let e=Object.create(Mw);return e._tag=rA,e})(),zl=e=>{let t=Object.create(Mw);return t._tag=nA,t.error=e,t},eo=e=>{let t=Object.create(Mw);return t._tag=vE,t.defect=e,t},Hs=e=>{let t=Object.create(Mw);return t._tag=RE,t.fiberId=e,t},to=(e,t)=>{let r=Object.create(Mw);return r._tag=_E,r.left=e,r.right=t,r},Vr=(e,t)=>{let r=Object.create(Mw);return r._tag=BE,r.left=e,r.right=t,r},T_=e=>se(e,U6),$6=e=>e._tag===rA,rSe=e=>e._tag===nA,QE=e=>e._tag===vE,LF=e=>e._tag===rA?!0:TE(e,!0,(t,r)=>{switch(r._tag){case rA:return H(t);case vE:case nA:case RE:return H(!1);default:return W()}}),Fw=e=>pt(oSe(e)),OE=e=>N_(void 0,Qyt)(e),D_=e=>gs(TE(e,Ut(),(t,r)=>r._tag===nA?H(C(t,fr(r.error))):W())),Q_=e=>gs(TE(e,Ut(),(t,r)=>r._tag===vE?H(C(t,fr(r.defect))):W())),NE=e=>TE(e,ql(),(t,r)=>r._tag===RE?H(C(t,kE(r.fiberId))):W()),UF=e=>oA(e,t=>t._tag===nA?H(t.error):W()),Vl=e=>{let t=UF(e);switch(t._tag){case"None":return Le(e);case"Some":return Re(t.value)}},nSe=e=>PE(e,{onEmpty:H(Yi),onFail:dr(zl),onDie:t=>H(eo(t)),onInterrupt:t=>H(Hs(t)),onSequential:Vg(Vr),onParallel:Vg(to)}),oSe=e=>oA(e,t=>t._tag===RE?H(t.fiberId):W()),H6=e=>PE(e,{onEmpty:W(),onFail:()=>W(),onDie:t=>H(eo(t)),onInterrupt:()=>W(),onSequential:Vg(Vr),onParallel:Vg(to)}),iSe=e=>PE(e,{onEmpty:W(),onFail:t=>H(eo(t)),onDie:t=>H(eo(t)),onInterrupt:()=>W(),onSequential:Vg(Vr),onParallel:Vg(to)}),$F=e=>PE(e,{onEmpty:Yi,onFail:()=>Yi,onDie:eo,onInterrupt:Hs,onSequential:Vr,onParallel:to}),sSe=e=>PE(e,{onEmpty:Yi,onFail:eo,onDie:eo,onInterrupt:Hs,onSequential:Vr,onParallel:to}),O_=x(2,(e,t)=>W6(e,r=>zl(t(r)))),W6=x(2,(e,t)=>PE(e,{onEmpty:Yi,onFail:r=>t(r),onDie:r=>eo(r),onInterrupt:r=>Hs(r),onSequential:(r,n)=>Vr(r,n),onParallel:(r,n)=>to(r,n)})),j6=e=>W6(e,be),Byt=(e,t)=>{let r=Dt(e),n=Dt(t);for(;kr(r)&&kr(n);){let[o,i]=C(Gt(r),TE([ql(),Ut()],([c,u],l)=>{let[d,f]=F6(l);return H([C(c,Ef(d)),C(u,Ir(f))])})),[s,a]=C(Gt(n),TE([ql(),Ut()],([c,u],l)=>{let[d,f]=F6(l);return H([C(c,Ef(d)),C(u,Ir(f))])}));if(!ce(o,s))return!1;r=i,n=a}return!0},Tyt=e=>Dyt(Dt(e),Ut()),Dyt=(e,t)=>{for(;;){let[r,n]=C(e,yu([ql(),Ut()],([i,s],a)=>{let[c,u]=F6(a);return[C(i,Ef(c)),C(s,Ir(u))]})),o=Gl(r)>0?C(t,fr(r)):t;if(xu(n))return gs(o);e=n,t=o}throw new Error(Fl("Cause.flattenCauseLoop"))},oA=x(2,(e,t)=>{let r=[e];for(;r.length>0;){let n=r.pop(),o=t(n);switch(o._tag){case"None":{switch(n._tag){case BE:case _E:{r.push(n.right),r.push(n.left);break}}break}case"Some":return o}}return W()}),F6=e=>{let t=e,r=[],n=ql(),o=Ut();for(;t!==void 0;)switch(t._tag){case rA:{if(r.length===0)return[n,o];t=r.pop();break}case nA:{if(n=kE(n,Kg(t._tag,t.error)),r.length===0)return[n,o];t=r.pop();break}case vE:{if(n=kE(n,Kg(t._tag,t.defect)),r.length===0)return[n,o];t=r.pop();break}case RE:{if(n=kE(n,Kg(t._tag,t.fiberId)),r.length===0)return[n,o];t=r.pop();break}case BE:{switch(t.left._tag){case rA:{t=t.right;break}case BE:{t=Vr(t.left.left,Vr(t.left.right,t.right));break}case _E:{t=to(Vr(t.left.left,t.right),Vr(t.left.right,t.right));break}default:{o=fr(o,t.right),t=t.left;break}}break}case _E:{r.push(t.right),t=t.left;break}}throw new Error(Fl("Cause.evaluateCauseLoop"))},Qyt={emptyCase:ka,failCase:Gi,dieCase:Gi,interruptCase:ka,sequentialCase:(e,t,r)=>t&&r,parallelCase:(e,t,r)=>t&&r},Xbe="SequentialCase",eSe="ParallelCase",PE=x(2,(e,{onDie:t,onEmpty:r,onFail:n,onInterrupt:o,onParallel:i,onSequential:s})=>N_(e,void 0,{emptyCase:()=>r,failCase:(a,c)=>n(c),dieCase:(a,c)=>t(c),interruptCase:(a,c)=>o(c),sequentialCase:(a,c,u)=>s(c,u),parallelCase:(a,c,u)=>i(c,u)})),TE=x(3,(e,t,r)=>{let n=t,o=e,i=[];for(;o!==void 0;){let s=r(n,o);switch(n=pt(s)?s.value:n,o._tag){case BE:{i.push(o.right),o=o.left;break}case _E:{i.push(o.right),o=o.left;break}default:{o=void 0;break}}o===void 0&&i.length>0&&(o=i.pop())}return n}),N_=x(3,(e,t,r)=>{let n=[e],o=[];for(;n.length>0;){let s=n.pop();switch(s._tag){case rA:{o.push(Le(r.emptyCase(t)));break}case nA:{o.push(Le(r.failCase(t,s.error)));break}case vE:{o.push(Le(r.dieCase(t,s.defect)));break}case RE:{o.push(Le(r.interruptCase(t,s.fiberId)));break}case BE:{n.push(s.right),n.push(s.left),o.push(Re({_tag:Xbe}));break}case _E:{n.push(s.right),n.push(s.left),o.push(Re({_tag:eSe}));break}}}let i=[];for(;o.length>0;){let s=o.pop();switch(s._tag){case"Left":{switch(s.left._tag){case Xbe:{let a=i.pop(),c=i.pop(),u=r.sequentialCase(t,a,c);i.push(u);break}case eSe:{let a=i.pop(),c=i.pop(),u=r.parallelCase(t,a,c);i.push(u);break}}break}case"Right":{i.push(s.right);break}}}if(i.length===0)throw new Error("BUG: Cause.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");return i.pop()}),Yl=(e,t)=>OE(e)?"All fibers interrupted without errors.":M_(e).map(function(r){return t?.renderErrorCause!==!0||r.cause===void 0?r.stack:`${r.stack} {
28
+ ${i(l)}}`;return s(u,f)}return String(u)}return c(e,0)}var Ce,xt,WJ,Fe,Am,Wg,ym,rF,d_,bEe,hE,SEe,xw,ht=h(()=>{yn();ct();Ce=Symbol.for("nodejs.util.inspect.custom"),xt=e=>{try{if(se(e,"toJSON")&&gm(e.toJSON)&&e.toJSON.length===0)return e.toJSON();if(Array.isArray(e))return e.map(xt)}catch{return{}}return xw(e)},WJ="[Circular]";Fe=e=>JSON.stringify(e,null,2),Am={toJSON(){return xt(this)},[Ce](){return this.toJSON()},toString(){return Fe(this.toJSON())}},Wg=class{[Ce](){return this.toJSON()}toString(){return Fe(this.toJSON())}},ym=(e,t=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?rF(e,t):String(e)}catch{return String(e)}},rF=(e,t)=>{let r=[],n=JSON.stringify(e,(o,i)=>typeof i=="object"&&i!==null?r.includes(i)?void 0:r.push(i)&&(hE.fiberRefs!==void 0&&bEe(i)?i[d_](hE.fiberRefs):i):i,t);return r=void 0,n},d_=Symbol.for("effect/Inspectable/Redactable"),bEe=e=>typeof e=="object"&&e!==null&&d_ in e,hE=Te("effect/Inspectable/redactableState",()=>({fiberRefs:void 0})),SEe=(e,t)=>{let r=hE.fiberRefs;hE.fiberRefs=e;try{return t()}finally{hE.fiberRefs=r}},xw=e=>bEe(e)&&hE.fiberRefs!==void 0?e[d_](hE.fiberRefs):e});var Z,Me=h(()=>{Z=(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 r=e;for(let n=0,o=t.length;n<o;n++)r=t[n](r);return r}}}});var gE,AE,Rr,Ew,bw,Sw,_r,nF,CEe,xm,Cw,yE,oF,ww,f_,Iw=h(()=>{gE="Async",AE="Commit",Rr="Failure",Ew="OnFailure",bw="OnSuccess",Sw="OnSuccessAndFailure",_r="Success",nF="Sync",CEe="Tag",xm="UpdateRuntimeFlags",Cw="While",yE="Iterator",oF="WithRuntime",ww="Yield",f_="RevertFlags"});var lAt,m_,jJ=h(()=>{lAt="3.21.3",m_=()=>lAt});var IEe,kEe,vEe,REe,jg,dAt,fAt,Em,gf,gu,iF,_Ee,BEe,Af=h(()=>{mt();ir();Me();mu();Iw();jJ();IEe=Symbol.for("effect/Effect"),kEe=Symbol.for("effect/Stream"),vEe=Symbol.for("effect/Sink"),REe=Symbol.for("effect/Channel"),jg={_R:e=>e,_E:e=>e,_A:e=>e,_V:m_()},dAt={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e},fAt={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},Em={[IEe]:jg,[kEe]:jg,[vEe]:dAt,[REe]:fAt,[me](e){return this===e},[he](){return We(this,Aw(this))},[Symbol.iterator](){return new mE(new hf(this))},pipe(){return Z(this,arguments)}},gf={[he](){return We(this,eF(this))},[me](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n of t)if(!(n in e&&ce(this[n],e[n])))return!1;return!0}},gu={...Em,_op:AE},iF={...gu,...gf},_Ee=function(){function e(){}return e.prototype=gu,e}(),BEe=function(){function e(){}return e.prototype=iF,e}()});var DEe,QEe,pAt,mAt,hAt,sF,qg,qJ,Gg,Au,h_=h(()=>{mt();ir();ht();ct();Af();DEe=Symbol.for("effect/Option"),QEe={...Em,[DEe]:{_A:e=>e},[Ce](){return this.toJSON()},toString(){return Fe(this.toJSON())}},pAt=Object.assign(Object.create(QEe),{_tag:"Some",_op:"Some",[me](e){return sF(e)&&qJ(e)&&ce(this.value,e.value)},[he](){return We(this,we(ae(this._tag))(ae(this.value)))},toJSON(){return{_id:"Option",_tag:this._tag,value:xt(this.value)}}}),mAt=ae("None"),hAt=Object.assign(Object.create(QEe),{_tag:"None",_op:"None",[me](e){return sF(e)&&qg(e)},[he](){return mAt},toJSON(){return{_id:"Option",_tag:this._tag}}}),sF=e=>se(e,DEe),qg=e=>e._tag==="None",qJ=e=>e._tag==="Some",Gg=Object.create(hAt),Au=e=>{let t=Object.create(pAt);return t.value=e,t}});var GJ,OEe,gAt,AAt,cF,kw,uF,g_,A_,zJ,VJ,NEe,YJ=h(()=>{mt();oe();ir();ht();ct();Af();h_();GJ=Symbol.for("effect/Either"),OEe={...Em,[GJ]:{_R:e=>e},[Ce](){return this.toJSON()},toString(){return Fe(this.toJSON())}},gAt=Object.assign(Object.create(OEe),{_tag:"Right",_op:"Right",[me](e){return cF(e)&&uF(e)&&ce(this.right,e.right)},[he](){return we(ae(this._tag))(ae(this.right))},toJSON(){return{_id:"Either",_tag:this._tag,right:xt(this.right)}}}),AAt=Object.assign(Object.create(OEe),{_tag:"Left",_op:"Left",[me](e){return cF(e)&&kw(e)&&ce(this.left,e.left)},[he](){return we(ae(this._tag))(ae(this.left))},toJSON(){return{_id:"Either",_tag:this._tag,left:xt(this.left)}}}),cF=e=>se(e,GJ),kw=e=>e._tag==="Left",uF=e=>e._tag==="Right",g_=e=>{let t=Object.create(AAt);return t.left=e,t},A_=e=>{let t=Object.create(gAt);return t.right=e,t},zJ=e=>uF(e)?Gg:Au(e.left),VJ=e=>kw(e)?Gg:Au(e.right),NEe=x(2,(e,t)=>qg(e)?g_(t()):A_(e.value))});var Le,Re,JJ,MEe,xr,si,FEe,LEe,lF,Ei,vw,y_,UEe,$Ee,bi=h(()=>{oe();YJ();Le=A_,Re=g_,JJ=NEe,MEe=cF,xr=kw,si=uF,FEe=x(2,(e,{onLeft:t,onRight:r})=>xr(e)?Re(t(e.left)):Le(r(e.right))),LEe=x(2,(e,t)=>xr(e)?Re(t(e.left)):Le(e.right)),lF=x(2,(e,t)=>si(e)?Le(t(e.right)):Re(e.left)),Ei=x(2,(e,{onLeft:t,onRight:r})=>xr(e)?t(e.left):r(e.right)),vw=Ei({onLeft:be,onRight:be}),y_=x(2,(e,t)=>{if(si(e))return e.right;throw t(e.left)}),UEe=y_(()=>new Error("getOrThrow called on a Left")),$Ee=e=>{if(Symbol.iterator in e){let r=[];for(let n of e){if(xr(n))return n;r.push(n.right)}return Le(r)}let t={};for(let r of Object.keys(e)){let n=e[r];if(xr(n))return n;t[r]=n.right}return Le(t)}});var KJ,HEe=h(()=>{KJ=e=>e.length>0});var xE,WEe,yf,xAt,jEe,ZJ,dF,fF,pF,XJ,e6,bm=h(()=>{oe();xE=e=>(t,r)=>t===r?0:e(t,r),WEe=xE((e,t)=>e<t?-1:1),yf=x(2,(e,t)=>xE((r,n)=>e(t(r),t(n)))),xAt=e=>xE((t,r)=>{let n=Math.min(t.length,r.length),o=0;for(let i of e){if(o>=n)break;let s=i(t[o],r[o]);if(s!==0)return s;o++}return 0}),jEe=(...e)=>xAt(e),ZJ=e=>x(2,(t,r)=>e(t,r)===-1),dF=e=>x(2,(t,r)=>e(t,r)===1),fF=e=>x(2,(t,r)=>t===r||e(t,r)<1?t:r),pF=e=>x(2,(t,r)=>t===r||e(t,r)>-1?t:r),XJ=e=>x(2,(t,r)=>fF(e)(r.maximum,pF(e)(r.minimum,t))),e6=e=>x(2,(t,r)=>!ZJ(e)(t,r.minimum)&&!dF(e)(t,r.maximum))});var Ke={};tr(Ke,{Do:()=>qAt,TypeId:()=>EAt,all:()=>JEe,andThen:()=>_At,ap:()=>NAt,as:()=>zEe,asVoid:()=>vAt,bind:()=>jAt,bindTo:()=>HAt,composeK:()=>QAt,contains:()=>s6,containsWith:()=>ebe,exists:()=>a6,filter:()=>hF,filterMap:()=>ZEe,firstSomeOf:()=>IAt,flatMap:()=>Gn,flatMapNullable:()=>o6,flatten:()=>BAt,fromIterable:()=>SAt,fromNullable:()=>en,gen:()=>zAt,getEquivalence:()=>XEe,getLeft:()=>CAt,getOrElse:()=>Nt,getOrNull:()=>qEe,getOrThrow:()=>mF,getOrThrowWith:()=>GEe,getOrUndefined:()=>Gr,getOrder:()=>FAt,getRight:()=>r6,isNone:()=>Ct,isOption:()=>t6,isSome:()=>pt,let:()=>WAt,lift2:()=>LAt,liftNullable:()=>kAt,liftPredicate:()=>UAt,liftThrowable:()=>EE,map:()=>dr,match:()=>wt,mergeWith:()=>Vg,none:()=>W,orElse:()=>lc,orElseEither:()=>wAt,orElseSome:()=>n6,partitionMap:()=>MAt,product:()=>YEe,productMany:()=>OAt,reduceCompact:()=>PAt,some:()=>H,tap:()=>VEe,toArray:()=>KEe,toRefinement:()=>bAt,void:()=>RAt,zipLeft:()=>DAt,zipRight:()=>TAt,zipWith:()=>i6});var EAt,W,H,t6,Ct,pt,wt,bAt,SAt,r6,CAt,Nt,lc,n6,wAt,IAt,en,kAt,qEe,Gr,EE,GEe,mF,dr,zEe,vAt,RAt,Gn,_At,o6,BAt,TAt,DAt,QAt,VEe,YEe,OAt,JEe,i6,NAt,PAt,KEe,MAt,ZEe,hF,XEe,FAt,LAt,UAt,ebe,$At,s6,a6,HAt,WAt,jAt,qAt,GAt,zAt,Vg,it=h(()=>{mt();mm();oe();NJ();YJ();h_();bm();mu();EAt=Symbol.for("effect/Option"),W=()=>Gg,H=Au,t6=sF,Ct=qg,pt=qJ,wt=x(2,(e,{onNone:t,onSome:r})=>Ct(e)?t():r(e.value)),bAt=e=>t=>pt(e(t)),SAt=e=>{for(let t of e)return H(t);return W()},r6=VJ,CAt=zJ,Nt=x(2,(e,t)=>Ct(e)?t():e.value),lc=x(2,(e,t)=>Ct(e)?t():e),n6=x(2,(e,t)=>Ct(e)?H(t()):e),wAt=x(2,(e,t)=>Ct(e)?dr(t(),A_):dr(e,g_)),IAt=e=>{let t=W();for(t of e)if(pt(t))return t;return t},en=e=>e==null?W():H(e),kAt=e=>(...t)=>en(e(...t)),qEe=Nt(DJ),Gr=Nt(hw),EE=e=>(...t)=>{try{return H(e(...t))}catch{return W()}},GEe=x(2,(e,t)=>{if(pt(e))return e.value;throw t()}),mF=GEe(()=>new Error("getOrThrow called on a None")),dr=x(2,(e,t)=>Ct(e)?W():H(t(e.value))),zEe=x(2,(e,t)=>dr(e,()=>t)),vAt=zEe(void 0),RAt=H(void 0),Gn=x(2,(e,t)=>Ct(e)?W():t(e.value)),_At=x(2,(e,t)=>Gn(e,r=>{let n=GM(t)?t(r):t;return t6(n)?n:H(n)})),o6=x(2,(e,t)=>Ct(e)?W():en(t(e.value))),BAt=Gn(be),TAt=x(2,(e,t)=>Gn(e,()=>t)),DAt=x(2,(e,t)=>VEe(e,()=>t)),QAt=x(2,(e,t)=>r=>Gn(e(r),t)),VEe=x(2,(e,t)=>Gn(e,r=>dr(t(r),()=>r))),YEe=(e,t)=>pt(e)&&pt(t)?H([e.value,t.value]):W(),OAt=(e,t)=>{if(Ct(e))return W();let r=[e.value];for(let n of t){if(Ct(n))return W();r.push(n.value)}return H(r)},JEe=e=>{if(Symbol.iterator in e){let r=[];for(let n of e){if(Ct(n))return W();r.push(n.value)}return H(r)}let t={};for(let r of Object.keys(e)){let n=e[r];if(Ct(n))return W();t[r]=n.value}return H(t)},i6=x(3,(e,t,r)=>dr(YEe(e,t),([n,o])=>r(n,o))),NAt=x(2,(e,t)=>i6(e,t,(r,n)=>r(n))),PAt=x(3,(e,t,r)=>{let n=t;for(let o of e)pt(o)&&(n=r(n,o.value));return n}),KEe=e=>Ct(e)?[]:[e.value],MAt=x(2,(e,t)=>{if(Ct(e))return[W(),W()];let r=t(e.value);return kw(r)?[H(r.left),W()]:[W(),H(r.right)]}),ZEe=Gn,hF=x(2,(e,t)=>ZEe(e,r=>t(r)?Au(r):Gg)),XEe=e=>Ml((t,r)=>Ct(t)?Ct(r):Ct(r)?!1:e(t.value,r.value)),FAt=e=>xE((t,r)=>pt(t)?pt(r)?e(t.value,r.value):1:-1),LAt=e=>x(2,(t,r)=>i6(t,r,e)),UAt=x(2,(e,t)=>t(e)?H(e):W()),ebe=e=>x(2,(t,r)=>Ct(t)?!1:e(t.value,r)),$At=l_(),s6=ebe($At),a6=x(2,(e,t)=>Ct(e)?!1:t(e.value)),HAt=YM(dr),WAt=VM(dr),jAt=JM(dr,Gn),qAt=H({}),GAt=AEe(),zAt=(...e)=>{let r=(e.length===1?e[0]:e[1].bind(e[0]))(GAt),n=r.next();for(;!n.done;){let o=gEe(n.value)?n.value.value:u_(n.value);if(Ct(o))return o;n=r.next(o.value)}return H(n.value)},Vg=e=>(t,r)=>Ct(t)?r:Ct(r)?t:H(e(t.value,r.value))});var tbe,c6=h(()=>{tbe=(...e)=>e});var VAt,YAt,gF,u6,x_=h(()=>{oe();VAt={[Symbol.iterator](){return YAt}},YAt={next(){return{done:!0,value:void 0}}},gF=()=>VAt,u6=x(2,(e,t)=>({[Symbol.iterator](){let r=e[Symbol.iterator](),n=0;return{next(){let o=r.next();return o.done?{done:!0,value:void 0}:{done:!1,value:t(o.value,n++)}}}}}))});var Sm,JAt,l6,E_=h(()=>{oe();Sm=x(2,(e,t)=>{let r={...e};for(let n of JAt(e))r[n]=t(e[n],n);return r}),JAt=e=>Object.keys(e),l6=x(3,(e,t,r)=>({...e,[t]:r}))});var bE,d6,_e,f6,nbe,Rw,p6,xF,m6,KAt,obe,Cm,zr,ibe,ZAt,XAt,h6,wm,Lo,EF,g6,Ll,eyt,sbe,abe,bF,Vi,A6,cbe,tyt,y6,ryt,_w,nyt,Ul,Us,hs,$l,SE,b_,Yg,x6,ube,E6,yu,SF,b6,Jg,lbe,S6,Im,wr=h(()=>{bi();mt();mm();oe();HEe();it();c6();bE=e=>new Array(e),d6=x(2,(e,t)=>{let r=Math.max(1,Math.floor(e)),n=new Array(r);for(let o=0;o<r;o++)n[o]=t(o);return n}),_e=e=>Array.isArray(e)?e:Array.from(e),f6=e=>Array.isArray(e)?e:[e],nbe=x(2,(e,{onEmpty:t,onNonEmpty:r})=>zr(e)?r(Lo(e),Ll(e)):t()),Rw=x(2,(e,t)=>[t,...e]),p6=x(2,(e,t)=>[...e,t]),xF=x(2,(e,t)=>_e(e).concat(_e(t))),m6=Array.isArray,KAt=e=>e.length===0,obe=KAt,Cm=KJ,zr=KJ,ibe=(e,t)=>e<0||e>=t.length,ZAt=(e,t)=>Math.floor(Math.min(Math.max(0,e),t.length)),XAt=x(2,(e,t)=>{let r=Math.floor(t);return ibe(r,e)?W():H(e[r])}),h6=x(2,(e,t)=>{let r=Math.floor(t);if(ibe(r,e))throw new Error(`Index ${r} out of bounds`);return e[r]}),wm=XAt(0),Lo=h6(0),EF=e=>zr(e)?H(g6(e)):W(),g6=e=>e[e.length-1],Ll=e=>e.slice(1),eyt=(e,t)=>{let r=0;for(let n of e){if(!t(n,r))break;r++}return r},sbe=x(2,(e,t)=>y6(e,eyt(e,t))),abe=x(2,(e,t)=>{let r=_e(e);return r.slice(ZAt(t,r),r.length)}),bF=e=>Array.from(e).reverse(),Vi=x(2,(e,t)=>{let r=Array.from(e);return r.sort(t),r}),A6=x(2,(e,t)=>cbe(e,t,tbe)),cbe=x(3,(e,t,r)=>{let n=_e(e),o=_e(t);if(zr(n)&&zr(o)){let i=[r(Lo(n),Lo(o))],s=Math.min(n.length,o.length);for(let a=1;a<s;a++)i[a]=r(n[a],o[a]);return i}return[]}),tyt=l_(),y6=x(2,(e,t)=>{let r=Array.from(e),n=Math.floor(t);return zr(r)?n>=1?ryt(r,n):[[],r]:[r,[]]}),ryt=x(2,(e,t)=>{let r=Math.max(1,Math.floor(t));return r>=e.length?[_w(e),[]]:[Rw(e.slice(1,r),Lo(e)),e.slice(r)]}),_w=e=>e.slice(),nyt=x(3,(e,t,r)=>{let n=_e(e),o=_e(t);return zr(n)?zr(o)?lbe(r)(xF(n,o)):n:o}),Ul=x(2,(e,t)=>nyt(e,t,tyt)),Us=()=>[],hs=e=>[e],$l=x(2,(e,t)=>e.map(t)),SE=x(2,(e,t)=>{if(obe(e))return[];let r=[];for(let n=0;n<e.length;n++){let o=t(e[n],n);for(let i=0;i<o.length;i++)r.push(o[i])}return r}),b_=SE(be),Yg=x(2,(e,t)=>{let r=_e(e),n=[];for(let o=0;o<r.length;o++){let i=t(r[o],o);pt(i)&&n.push(i.value)}return n}),x6=x(2,(e,t)=>{let r=[],n=[],o=_e(e);for(let i=0;i<o.length;i++){let s=t(o[i],i);xr(s)?r.push(s.left):n.push(s.right)}return[r,n]}),ube=Yg(be),E6=x(2,(e,t)=>{let r=_e(e),n=[];for(let o=0;o<r.length;o++)t(r[o],o)&&n.push(r[o]);return n}),yu=x(3,(e,t,r)=>_e(e).reduce((n,o,i)=>r(n,o,i),t)),SF=x(3,(e,t,r)=>_e(e).reduceRight((n,o,i)=>r(n,o,i),t)),b6=(e,t)=>{let r=[],n=e,o;for(;pt(o=t(n));){let[i,s]=o.value;r.push(i),n=s}return r},Jg=zM,lbe=x(2,(e,t)=>{let r=_e(e);if(zr(r)){let n=[Lo(r)],o=Ll(r);for(let i of o)n.every(s=>!t(i,s))&&n.push(i);return n}return[]}),S6=e=>lbe(e,l_()),Im=x(2,(e,t)=>_e(e).join(t))});function syt(e,t,r,n,o){for(let i=t;i<Math.min(e.length,t+o);i++)r[n+i-t]=e[i];return r}var fbe,pbe,ayt,cyt,uyt,Xn,S_,Hl,Ut,Kg,Dt,Co,C6,lyt,mbe,dyt,Uo,fyt,gs,pyt,ln,myt,Wl,$s,fr,Bw,jl,Ir,Tw,C_,xu,kr,CE,w_,Gt,xf,hbe,Ur,w6,gbe,I_,vr=h(()=>{wr();mt();mm();oe();ir();ht();it();Me();ct();fbe=Symbol.for("effect/Chunk");pbe=[],ayt=e=>Ml((t,r)=>t.length===r.length&&Uo(t).every((n,o)=>e(n,Wl(r,o)))),cyt=ayt(ce),uyt={[fbe]:{_A:e=>e},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"Chunk",values:Uo(this).map(xt)}},[Ce](){return this.toJSON()},[me](e){return S_(e)&&cyt(this,e)},[he](){return We(this,So(Uo(this)))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return pbe[Symbol.iterator]();default:return Uo(this)[Symbol.iterator]()}},pipe(){return Z(this,arguments)}},Xn=e=>{let t=Object.create(uyt);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=Hl,t.right=Hl;break}case"ISingleton":{t.length=1,t.depth=0,t.left=Hl,t.right=Hl;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=Hl,t.right=Hl;break}}return t},S_=e=>se(e,fbe),Hl=Xn({_tag:"IEmpty"}),Ut=()=>Hl,Kg=(...e)=>myt(e),Dt=e=>Xn({_tag:"ISingleton",a:e}),Co=e=>S_(e)?e:ln(_e(e)),C6=(e,t,r)=>{switch(e.backing._tag){case"IArray":{syt(e.backing.array,0,t,r,e.length);break}case"IConcat":{C6(e.left,t,r),C6(e.right,t,r+e.left.length);break}case"ISingleton":{t[r]=e.backing.a;break}case"ISlice":{let n=0,o=r;for(;n<e.length;)t[o]=Wl(e,n),n+=1,o+=1;break}}},lyt=e=>Uo(e).slice(),mbe=lyt,dyt=e=>{switch(e.backing._tag){case"IEmpty":return pbe;case"IArray":return e.backing.array;default:{let t=new Array(e.length);return C6(e,t,0),e.backing={_tag:"IArray",array:t},e.left=Hl,e.right=Hl,e.depth=0,t}}},Uo=dyt,fyt=e=>{switch(e.backing._tag){case"IEmpty":case"ISingleton":return e;case"IArray":return Xn({_tag:"IArray",array:bF(e.backing.array)});case"IConcat":return Xn({_tag:"IConcat",left:gs(e.backing.right),right:gs(e.backing.left)});case"ISlice":return ln(bF(Uo(e)))}},gs=fyt,pyt=x(2,(e,t)=>t<0||t>=e.length?W():H(Wl(e,t))),ln=e=>e.length===0?Ut():e.length===1?Dt(e[0]):Xn({_tag:"IArray",array:e}),myt=e=>ln(e),Wl=x(2,(e,t)=>{switch(e.backing._tag){case"IEmpty":throw new Error("Index out of bounds");case"ISingleton":{if(t!==0)throw new Error("Index out of bounds");return e.backing.a}case"IArray":{if(t>=e.length||t<0)throw new Error("Index out of bounds");return e.backing.array[t]}case"IConcat":return t<e.left.length?Wl(e.left,t):Wl(e.right,t-e.left.length);case"ISlice":return Wl(e.backing.chunk,t+e.backing.offset)}}),$s=x(2,(e,t)=>Ir(e,Dt(t))),fr=x(2,(e,t)=>Ir(Dt(t),e)),Bw=x(2,(e,t)=>{if(t<=0)return Hl;if(t>=e.length)return e;switch(e.backing._tag){case"ISlice":return Xn({_tag:"ISlice",chunk:e.backing.chunk,length:t,offset:e.backing.offset});case"IConcat":return t>e.left.length?Xn({_tag:"IConcat",left:e.left,right:Bw(e.right,t-e.left.length)}):Bw(e.left,t);default:return Xn({_tag:"ISlice",chunk:e,offset:0,length:t})}}),jl=x(2,(e,t)=>{if(t<=0)return e;if(t>=e.length)return Hl;switch(e.backing._tag){case"ISlice":return Xn({_tag:"ISlice",chunk:e.backing.chunk,offset:e.backing.offset+t,length:e.backing.length-t});case"IConcat":return t>e.left.length?jl(e.right,t-e.left.length):Xn({_tag:"IConcat",left:jl(e.left,t),right:e.right});default:return Xn({_tag:"ISlice",chunk:e,offset:t,length:e.length-t})}}),Ir=x(2,(e,t)=>{if(e.backing._tag==="IEmpty")return t;if(t.backing._tag==="IEmpty")return e;let r=t.depth-e.depth;if(Math.abs(r)<=1)return Xn({_tag:"IConcat",left:e,right:t});if(r<-1)if(e.left.depth>=e.right.depth){let n=Ir(e.right,t);return Xn({_tag:"IConcat",left:e.left,right:n})}else{let n=Ir(e.right.right,t);if(n.depth===e.depth-3){let o=Xn({_tag:"IConcat",left:e.right.left,right:n});return Xn({_tag:"IConcat",left:e.left,right:o})}else{let o=Xn({_tag:"IConcat",left:e.left,right:e.right.left});return Xn({_tag:"IConcat",left:o,right:n})}}else if(t.right.depth>=t.left.depth){let n=Ir(e,t.left);return Xn({_tag:"IConcat",left:n,right:t.right})}else{let n=Ir(e,t.left.left);if(n.depth===t.depth-3){let o=Xn({_tag:"IConcat",left:n,right:t.left.right});return Xn({_tag:"IConcat",left:o,right:t.right})}else{let o=Xn({_tag:"IConcat",left:t.left.right,right:t.right});return Xn({_tag:"IConcat",left:n,right:o})}}}),Tw=x(2,(e,t)=>ln(E6(e,t))),C_=x(2,(e,t)=>Uo(e).forEach(t)),xu=e=>e.length===0,kr=e=>e.length>0,CE=pyt(0),w_=e=>Wl(e,0),Gt=w_,xf=x(2,(e,t)=>e.backing._tag==="ISingleton"?Dt(t(e.backing.a,0)):ln(C(Uo(e),$l((r,n)=>t(r,n))))),hbe=x(2,(e,t)=>ln(Vi(Uo(e),t))),Ur=e=>jl(e,1),w6=x(2,(e,t)=>jl(e,e.length-t)),gbe=x(2,(e,t)=>_e(e).some(t)),I_=yu});var I6,Abe,ybe,xbe,k6=h(()=>{I6=Math.pow(2,5),Abe=I6-1,ybe=I6/2,xbe=I6/4});function hyt(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,e+=e>>16,e&127}function Zg(e,t){return t>>>e&Abe}function Xg(e){return 1<<e}function CF(e,t){return hyt(e&t-1)}var v6=h(()=>{k6()});var Ebe,bbe=h(()=>{Ebe=(e,t)=>({value:e,previous:t})});function wE(e,t,r,n){let o=n;if(!e){let i=n.length;o=new Array(i);for(let s=0;s<i;++s)o[s]=n[s]}return o[t]=r,o}function R6(e,t,r){let n=r.length-1,o=0,i=0,s=r;if(e)o=i=t;else for(s=new Array(n);o<t;)s[i++]=r[o++];for(++o;o<=n;)s[i++]=r[o++];return e&&(s.length=n),s}function Sbe(e,t,r,n){let o=n.length;if(e){let c=o;for(;c>=t;)n[c--]=n[c];return n[t]=r,n}let i=0,s=0,a=new Array(o+1);for(;i<t;)a[s++]=n[i++];for(a[t]=r;i<o;)a[++s]=n[i++];return a}var Cbe=h(()=>{});function Eu(e){return mf(e,"EmptyNode")}function Ayt(e){return Eu(e)||e._tag==="LeafNode"||e._tag==="CollisionNode"}function wF(e,t){return Eu(e)?!1:t===e.edit}function yyt(e,t,r,n){let o=new Array(t-1),i=0,s=0;for(let a=0,c=n.length;a<c;++a)if(a!==r){let u=n[a];u&&!Eu(u)&&(o[i++]=u,s|=1<<a)}return new k_(e,s,o)}function xyt(e,t,r,n,o){let i=[],s=n,a=0;for(let c=0;s;++c)s&1&&(i[c]=o[a++]),s>>>=1;return i[t]=r,new B6(e,a+1,i)}function Eyt(e,t,r,n,o,i){if(r===o)return new _6(e,r,[i,n]);let s=Zg(t,r),a=Zg(t,o);if(s===a)return c=>new k_(e,Xg(s)|Xg(a),[c]);{let c=s<a?[n,i]:[i,n];return new k_(e,Xg(s)|Xg(a),c)}}function wbe(e,t,r,n,o,i){let s,a=t;for(;;){let c=Eyt(e,a,r,n,o,i);if(typeof c=="function")s=Ebe(c,s),a=a+5;else{let u=c;for(;s!=null;)u=s.value(u),s=s.previous;return u}}}var km,Dw,_6,k_,B6,Ibe=h(()=>{mt();it();ct();bbe();Cbe();v6();k6();km=class e{_tag="EmptyNode";modify(t,r,n,o,i,s){let a=n(W());return Ct(a)?new e:(++s.value,new Dw(t,o,i,a))}};Dw=class e{edit;hash;key;value;_tag="LeafNode";constructor(t,r,n,o){this.edit=t,this.hash=r,this.key=n,this.value=o}modify(t,r,n,o,i,s){if(ce(i,this.key)){let c=n(this.value);return c===this.value?this:Ct(c)?(--s.value,new km):wF(this,t)?(this.value=c,this):new e(t,o,i,c)}let a=n(W());return Ct(a)?this:(++s.value,wbe(t,r,this.hash,this,o,new e(t,o,i,a)))}},_6=class e{edit;hash;children;_tag="CollisionNode";constructor(t,r,n){this.edit=t,this.hash=r,this.children=n}modify(t,r,n,o,i,s){if(o===this.hash){let c=wF(this,t),u=this.updateCollisionList(c,t,this.hash,this.children,n,i,s);return u===this.children?this:u.length>1?new e(t,this.hash,u):u[0]}let a=n(W());return Ct(a)?this:(++s.value,wbe(t,r,this.hash,this,o,new Dw(t,o,i,a)))}updateCollisionList(t,r,n,o,i,s,a){let c=o.length;for(let l=0;l<c;++l){let d=o[l];if("key"in d&&ce(s,d.key)){let f=d.value,p=i(f);return p===f?o:Ct(p)?(--a.value,R6(t,l,o)):wE(t,l,new Dw(r,n,s,p),o)}}let u=i(W());return Ct(u)?o:(++a.value,wE(t,c,new Dw(r,n,s,u),o))}},k_=class e{edit;mask;children;_tag="IndexedNode";constructor(t,r,n){this.edit=t,this.mask=r,this.children=n}modify(t,r,n,o,i,s){let a=this.mask,c=this.children,u=Zg(r,o),l=Xg(u),d=CF(a,l),f=a&l,p=wF(this,t);if(!f){let y=new km().modify(t,r+5,n,o,i,s);return y?c.length>=ybe?xyt(t,u,y,a,c):new e(t,a|l,Sbe(p,d,y,c)):this}let m=c[d],g=m.modify(t,r+5,n,o,i,s);if(m===g)return this;let A=a,E;if(Eu(g)){if(A&=~l,!A)return new km;if(c.length<=2&&Ayt(c[d^1]))return c[d^1];E=R6(p,d,c)}else E=wE(p,d,g,c);return p?(this.mask=A,this.children=E,this):new e(t,A,E)}},B6=class e{edit;size;children;_tag="ArrayNode";constructor(t,r,n){this.edit=t,this.size=r,this.children=n}modify(t,r,n,o,i,s){let a=this.size,c=this.children,u=Zg(r,o),l=c[u],d=(l||new km).modify(t,r+5,n,o,i,s);if(l===d)return this;let f=wF(this,t),p;if(Eu(l)&&!Eu(d))++a,p=wE(f,u,d,c);else if(!Eu(l)&&Eu(d)){if(--a,a<=xbe)return yyt(t,a,u,c);p=wE(f,u,new km,c)}else p=wE(f,u,d,c);return f?(this.size=a,this.children=p,this):new e(t,a,p)}}});var kbe,IF,Syt,T6,kF,vF,vbe,Rbe,Cyt,Ow,_be,Bbe,Tbe,Dbe,v_,Qbe,RF,IE,wyt,_F,R_,__,D6,Obe,BF,Nbe,TF,Pbe,DF,Nw,Q6=h(()=>{mt();oe();oe();ir();ht();it();Me();ct();v6();Ibe();kbe="effect/HashMap",IF=Symbol.for(kbe),Syt={[IF]:IF,[Symbol.iterator](){return new kF(this,(e,t)=>[e,t])},[he](){let e=ae(kbe);for(let t of this)e^=C(ae(t[0]),we(ae(t[1])));return We(this,e)},[me](e){if(Bbe(e)){if(e._size!==this._size)return!1;for(let t of this){let r=C(e,v_(t[0],ae(t[0])));if(Ct(r))return!1;if(!ce(t[1],r.value))return!1}return!0}return!1},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"HashMap",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},T6=(e,t,r,n)=>{let o=Object.create(Syt);return o._editable=e,o._edit=t,o._root=r,o._size=n,o},kF=class e{map;f;v;constructor(t,r){this.map=t,this.f=r,this.v=vbe(this.map._root,this.f,void 0)}next(){if(Ct(this.v))return{done:!0,value:void 0};let t=this.v.value;return this.v=vF(t.cont),{done:!1,value:t.value}}[Symbol.iterator](){return new e(this.map,this.f)}},vF=e=>e?Rbe(e[0],e[1],e[2],e[3],e[4]):W(),vbe=(e,t,r=void 0)=>{switch(e._tag){case"LeafNode":return pt(e.value)?H({value:t(e.key,e.value.value),cont:r}):vF(r);case"CollisionNode":case"ArrayNode":case"IndexedNode":{let n=e.children;return Rbe(n.length,n,0,t,r)}default:return vF(r)}},Rbe=(e,t,r,n,o)=>{for(;r<e;){let i=t[r++];if(i&&!Eu(i))return vbe(i,n,[e,t,r,n,o])}return vF(o)},Cyt=T6(!1,0,new km,0),Ow=()=>Cyt,_be=e=>{let t=__(Ow());for(let r of e)IE(t,r[0],r[1]);return D6(t)},Bbe=e=>se(e,IF),Tbe=e=>e&&Eu(e._root),Dbe=x(2,(e,t)=>v_(e,t,ae(t))),v_=x(3,(e,t,r)=>{let n=e._root,o=0;for(;;)switch(n._tag){case"LeafNode":return ce(t,n.key)?n.value:W();case"CollisionNode":{if(r===n.hash){let i=n.children;for(let s=0,a=i.length;s<a;++s){let c=i[s];if("key"in c&&ce(t,c.key))return c.value}}return W()}case"IndexedNode":{let i=Zg(o,r),s=Xg(i);if(n.mask&s){n=n.children[CF(n.mask,s)],o+=5;break}return W()}case"ArrayNode":{if(n=n.children[Zg(o,r)],n){o+=5;break}return W()}default:return W()}}),Qbe=x(2,(e,t)=>{let r=v_(e,t,ae(t));if(Ct(r))throw new Error("Expected map to contain key");return r.value}),RF=x(2,(e,t)=>pt(v_(e,t,ae(t)))),IE=x(3,(e,t,r)=>BF(e,t,()=>H(r))),wyt=x(3,(e,t,r)=>e._editable?(e._root=t,e._size=r,e):t===e._root?e:T6(e._editable,e._edit,t,r)),_F=e=>new kF(e,t=>t),R_=e=>e._size,__=e=>T6(!0,e._edit+1,e._root,e._size),D6=e=>(e._editable=!1,e),Obe=x(2,(e,t)=>{let r=__(e);return t(r),D6(r)}),BF=x(3,(e,t,r)=>Nbe(e,t,ae(t),r)),Nbe=x(4,(e,t,r,n)=>{let o={value:e._size},i=e._root.modify(e._editable?e._edit:NaN,0,n,r,t,o);return C(e,wyt(i,o.value))}),TF=x(2,(e,t)=>BF(e,t,W)),Pbe=x(2,(e,t)=>Nw(e,Ow(),(r,n,o)=>IE(r,o,t(n,o)))),DF=x(2,(e,t)=>Nw(e,void 0,(r,n,o)=>t(n,o))),Nw=x(3,(e,t,r)=>{let n=e._root;if(n._tag==="LeafNode")return pt(n.value)?r(t,n.value.value,n.key):t;if(n._tag==="EmptyNode")return t;let o=[n.children],i;for(;i=o.pop();)for(let s=0,a=i.length;s<a;){let c=i[s++];c&&!Eu(c)&&(c._tag==="LeafNode"?pt(c.value)&&(t=r(t,c.value.value,c.key)):o.push(c.children))}return t})});var Fbe,QF,Iyt,OF,Lbe,kyt,B_,Ube,$be,Hbe,Wbe,jbe,qbe,NF,PF,O6,Pw,N6,Gbe,zbe,Vbe,Ybe,Jbe=h(()=>{mt();oe();ir();ht();Me();ct();Q6();Fbe="effect/HashSet",QF=Symbol.for(Fbe),Iyt={[QF]:QF,[Symbol.iterator](){return _F(this._keyMap)},[he](){return We(this,we(ae(this._keyMap))(ae(Fbe)))},[me](e){return Lbe(e)?R_(this._keyMap)===R_(e._keyMap)&&ce(this._keyMap,e._keyMap):!1},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"HashSet",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},OF=e=>{let t=Object.create(Iyt);return t._keyMap=e,t},Lbe=e=>se(e,QF),kyt=OF(Ow()),B_=()=>kyt,Ube=e=>{let t=NF(B_());for(let r of e)Pw(t,r);return PF(t)},$be=(...e)=>{let t=NF(B_());for(let r of e)Pw(t,r);return PF(t)},Hbe=x(2,(e,t)=>RF(e._keyMap,t)),Wbe=x(2,(e,t)=>{let r=!1;for(let n of e)if(r=t(n),r)break;return r}),jbe=x(2,(e,t)=>!Wbe(e,r=>!t(r))),qbe=e=>R_(e._keyMap),NF=e=>OF(__(e._keyMap)),PF=e=>(e._keyMap._editable=!1,e),O6=x(2,(e,t)=>{let r=NF(e);return t(r),PF(r)}),Pw=x(2,(e,t)=>e._keyMap._editable?(IE(t,!0)(e._keyMap),e):OF(IE(t,!0)(e._keyMap))),N6=x(2,(e,t)=>e._keyMap._editable?(TF(t)(e._keyMap),e):OF(TF(t)(e._keyMap))),Gbe=x(2,(e,t)=>O6(e,r=>{for(let n of t)N6(r,n)})),zbe=x(2,(e,t)=>O6(B_(),r=>{Vbe(e,n=>Pw(r,n));for(let n of t)Pw(r,n)})),Vbe=x(2,(e,t)=>DF(e._keyMap,(r,n)=>t(n))),Ybe=x(3,(e,t,r)=>Nw(e._keyMap,t,(n,o,i)=>r(n,i)))});var ql,MF,eA,FF,Kbe,Gl,kE,P6,M6,Ef,tA,dc=h(()=>{Jbe();ql=B_,MF=Ube,eA=$be,FF=Hbe,Kbe=jbe,Gl=qbe,kE=Pw,P6=N6,M6=Gbe,Ef=zbe,tA=Ybe});var vE,rA,nA,RE,_E,BE,Zbe=h(()=>{vE="Die",rA="Empty",nA="Fail",RE="Interrupt",_E="Parallel",BE="Sequential"});var tSe,U6,_yt,Mw,Yi,zl,eo,Hs,to,Vr,T_,$6,rSe,QE,LF,Fw,OE,D_,Q_,NE,UF,Vl,nSe,oSe,H6,iSe,$F,sSe,O_,W6,j6,Byt,Tyt,Dyt,oA,F6,Qyt,Xbe,eSe,PE,TE,N_,Yl,aSe,L6,HF,Oyt,P_,Nyt,DE,M_,Jl=h(()=>{wr();vr();bi();mt();oe();yn();ir();dc();ht();it();Me();ct();gw();Zbe();tSe="effect/Cause",U6=Symbol.for(tSe),_yt={_E:e=>e},Mw={[U6]:_yt,[he](){return C(ae(tSe),we(ae(Tyt(this))),We(this))},[me](e){return T_(e)&&Byt(this,e)},pipe(){return Z(this,arguments)},toJSON(){switch(this._tag){case"Empty":return{_id:"Cause",_tag:this._tag};case"Die":return{_id:"Cause",_tag:this._tag,defect:xt(this.defect)};case"Interrupt":return{_id:"Cause",_tag:this._tag,fiberId:this.fiberId.toJSON()};case"Fail":return{_id:"Cause",_tag:this._tag,failure:xt(this.error)};case"Sequential":case"Parallel":return{_id:"Cause",_tag:this._tag,left:xt(this.left),right:xt(this.right)}}},toString(){return Yl(this)},[Ce](){return this.toJSON()}},Yi=(()=>{let e=Object.create(Mw);return e._tag=rA,e})(),zl=e=>{let t=Object.create(Mw);return t._tag=nA,t.error=e,t},eo=e=>{let t=Object.create(Mw);return t._tag=vE,t.defect=e,t},Hs=e=>{let t=Object.create(Mw);return t._tag=RE,t.fiberId=e,t},to=(e,t)=>{let r=Object.create(Mw);return r._tag=_E,r.left=e,r.right=t,r},Vr=(e,t)=>{let r=Object.create(Mw);return r._tag=BE,r.left=e,r.right=t,r},T_=e=>se(e,U6),$6=e=>e._tag===rA,rSe=e=>e._tag===nA,QE=e=>e._tag===vE,LF=e=>e._tag===rA?!0:TE(e,!0,(t,r)=>{switch(r._tag){case rA:return H(t);case vE:case nA:case RE:return H(!1);default:return W()}}),Fw=e=>pt(oSe(e)),OE=e=>N_(void 0,Qyt)(e),D_=e=>gs(TE(e,Ut(),(t,r)=>r._tag===nA?H(C(t,fr(r.error))):W())),Q_=e=>gs(TE(e,Ut(),(t,r)=>r._tag===vE?H(C(t,fr(r.defect))):W())),NE=e=>TE(e,ql(),(t,r)=>r._tag===RE?H(C(t,kE(r.fiberId))):W()),UF=e=>oA(e,t=>t._tag===nA?H(t.error):W()),Vl=e=>{let t=UF(e);switch(t._tag){case"None":return Le(e);case"Some":return Re(t.value)}},nSe=e=>PE(e,{onEmpty:H(Yi),onFail:dr(zl),onDie:t=>H(eo(t)),onInterrupt:t=>H(Hs(t)),onSequential:Vg(Vr),onParallel:Vg(to)}),oSe=e=>oA(e,t=>t._tag===RE?H(t.fiberId):W()),H6=e=>PE(e,{onEmpty:W(),onFail:()=>W(),onDie:t=>H(eo(t)),onInterrupt:()=>W(),onSequential:Vg(Vr),onParallel:Vg(to)}),iSe=e=>PE(e,{onEmpty:W(),onFail:t=>H(eo(t)),onDie:t=>H(eo(t)),onInterrupt:()=>W(),onSequential:Vg(Vr),onParallel:Vg(to)}),$F=e=>PE(e,{onEmpty:Yi,onFail:()=>Yi,onDie:eo,onInterrupt:Hs,onSequential:Vr,onParallel:to}),sSe=e=>PE(e,{onEmpty:Yi,onFail:eo,onDie:eo,onInterrupt:Hs,onSequential:Vr,onParallel:to}),O_=x(2,(e,t)=>W6(e,r=>zl(t(r)))),W6=x(2,(e,t)=>PE(e,{onEmpty:Yi,onFail:r=>t(r),onDie:r=>eo(r),onInterrupt:r=>Hs(r),onSequential:(r,n)=>Vr(r,n),onParallel:(r,n)=>to(r,n)})),j6=e=>W6(e,be),Byt=(e,t)=>{let r=Dt(e),n=Dt(t);for(;kr(r)&&kr(n);){let[o,i]=C(Gt(r),TE([ql(),Ut()],([c,u],l)=>{let[d,f]=F6(l);return H([C(c,Ef(d)),C(u,Ir(f))])})),[s,a]=C(Gt(n),TE([ql(),Ut()],([c,u],l)=>{let[d,f]=F6(l);return H([C(c,Ef(d)),C(u,Ir(f))])}));if(!ce(o,s))return!1;r=i,n=a}return!0},Tyt=e=>Dyt(Dt(e),Ut()),Dyt=(e,t)=>{for(;;){let[r,n]=C(e,yu([ql(),Ut()],([i,s],a)=>{let[c,u]=F6(a);return[C(i,Ef(c)),C(s,Ir(u))]})),o=Gl(r)>0?C(t,fr(r)):t;if(xu(n))return gs(o);e=n,t=o}throw new Error(Fl("Cause.flattenCauseLoop"))},oA=x(2,(e,t)=>{let r=[e];for(;r.length>0;){let n=r.pop(),o=t(n);switch(o._tag){case"None":{switch(n._tag){case BE:case _E:{r.push(n.right),r.push(n.left);break}}break}case"Some":return o}}return W()}),F6=e=>{let t=e,r=[],n=ql(),o=Ut();for(;t!==void 0;)switch(t._tag){case rA:{if(r.length===0)return[n,o];t=r.pop();break}case nA:{if(n=kE(n,Kg(t._tag,t.error)),r.length===0)return[n,o];t=r.pop();break}case vE:{if(n=kE(n,Kg(t._tag,t.defect)),r.length===0)return[n,o];t=r.pop();break}case RE:{if(n=kE(n,Kg(t._tag,t.fiberId)),r.length===0)return[n,o];t=r.pop();break}case BE:{switch(t.left._tag){case rA:{t=t.right;break}case BE:{t=Vr(t.left.left,Vr(t.left.right,t.right));break}case _E:{t=to(Vr(t.left.left,t.right),Vr(t.left.right,t.right));break}default:{o=fr(o,t.right),t=t.left;break}}break}case _E:{r.push(t.right),t=t.left;break}}throw new Error(Fl("Cause.evaluateCauseLoop"))},Qyt={emptyCase:ka,failCase:Gi,dieCase:Gi,interruptCase:ka,sequentialCase:(e,t,r)=>t&&r,parallelCase:(e,t,r)=>t&&r},Xbe="SequentialCase",eSe="ParallelCase",PE=x(2,(e,{onDie:t,onEmpty:r,onFail:n,onInterrupt:o,onParallel:i,onSequential:s})=>N_(e,void 0,{emptyCase:()=>r,failCase:(a,c)=>n(c),dieCase:(a,c)=>t(c),interruptCase:(a,c)=>o(c),sequentialCase:(a,c,u)=>s(c,u),parallelCase:(a,c,u)=>i(c,u)})),TE=x(3,(e,t,r)=>{let n=t,o=e,i=[];for(;o!==void 0;){let s=r(n,o);switch(n=pt(s)?s.value:n,o._tag){case BE:{i.push(o.right),o=o.left;break}case _E:{i.push(o.right),o=o.left;break}default:{o=void 0;break}}o===void 0&&i.length>0&&(o=i.pop())}return n}),N_=x(3,(e,t,r)=>{let n=[e],o=[];for(;n.length>0;){let s=n.pop();switch(s._tag){case rA:{o.push(Le(r.emptyCase(t)));break}case nA:{o.push(Le(r.failCase(t,s.error)));break}case vE:{o.push(Le(r.dieCase(t,s.defect)));break}case RE:{o.push(Le(r.interruptCase(t,s.fiberId)));break}case BE:{n.push(s.right),n.push(s.left),o.push(Re({_tag:Xbe}));break}case _E:{n.push(s.right),n.push(s.left),o.push(Re({_tag:eSe}));break}}}let i=[];for(;o.length>0;){let s=o.pop();switch(s._tag){case"Left":{switch(s.left._tag){case Xbe:{let a=i.pop(),c=i.pop(),u=r.sequentialCase(t,a,c);i.push(u);break}case eSe:{let a=i.pop(),c=i.pop(),u=r.parallelCase(t,a,c);i.push(u);break}}break}case"Right":{i.push(s.right);break}}}if(i.length===0)throw new Error("BUG: Cause.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");return i.pop()}),Yl=(e,t)=>OE(e)?"All fibers interrupted without errors.":M_(e).map(function(r){return t?.renderErrorCause!==!0||r.cause===void 0?r.stack:`${r.stack} {
29
29
  ${aSe(r.cause," ")}
30
30
  }`}).join(`
31
31
  `),aSe=(e,t)=>{let r=e.stack.split(`
@@ -38,38 +38,38 @@ ${t}}`),n},L6=e=>{let t=typeof e=="object"&&e!==null,r=Error.stackTraceLimit;Err
38
38
  `)},DE=Symbol.for("effect/SpanAnnotation"),M_=e=>N_(e,void 0,{emptyCase:()=>[],dieCase:(t,r)=>[L6(r)],failCase:(t,r)=>[L6(r)],interruptCase:()=>[],parallelCase:(t,r,n)=>[...r,...n],sequentialCase:(t,r,n)=>[...r,...n]})});var WF,Lw,Pyt,Myt,Uw,Fyt,cSe,uSe,lSe,G6,Lyt,Su,Uyt,z6,dSe,jF,$yt,fSe,V6,pSe,q6,qF,mSe,Y6,hSe,gSe,ASe,ySe,xSe,ESe,bSe,F_=h(()=>{mt();oe();yn();ir();ht();Me();ct();Af();h_();WF=Symbol.for("effect/Context/Tag"),Lw=Symbol.for("effect/Context/Reference"),Pyt="effect/STM",Myt=Symbol.for(Pyt),Uw={...Em,_op:"Tag",[Myt]:jg,[WF]:{_Service:e=>e,_Identifier:e=>e},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"Tag",key:this.key,stack:this.stack}},[Ce](){return this.toJSON()},of(e){return e},context(e){return V6(this,e)}},Fyt={...Uw,[Lw]:Lw},cSe=e=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=2;let r=new Error;Error.stackTraceLimit=t;let n=Object.create(Uw);return Object.defineProperty(n,"stack",{get(){return r.stack}}),n.key=e,n},uSe=e=>()=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=2;let r=new Error;Error.stackTraceLimit=t;function n(){}return Object.setPrototypeOf(n,Uw),n.key=e,Object.defineProperty(n,"stack",{get(){return r.stack}}),n},lSe=()=>(e,t)=>{let r=Error.stackTraceLimit;Error.stackTraceLimit=2;let n=new Error;Error.stackTraceLimit=r;function o(){}return Object.setPrototypeOf(o,Fyt),o.key=e,o.defaultValue=t.defaultValue,Object.defineProperty(o,"stack",{get(){return n.stack}}),o},G6=Symbol.for("effect/Context"),Lyt={[G6]:{_Services:e=>e},[me](e){if(z6(e)&&this.unsafeMap.size===e.unsafeMap.size){for(let t of this.unsafeMap.keys())if(!e.unsafeMap.has(t)||!ce(this.unsafeMap.get(t),e.unsafeMap.get(t)))return!1;return!0}return!1},[he](){return We(this,hu(this.unsafeMap.size))},pipe(){return Z(this,arguments)},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"Context",services:Array.from(this.unsafeMap).map(xt)}},[Ce](){return this.toJSON()}},Su=e=>{let t=Object.create(Lyt);return t.unsafeMap=e,t},Uyt=e=>{let t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(e.stack){let r=e.stack.split(`
39
39
  `);if(r.length>2){let n=r[2].match(/at (.*)/);n&&(t.message=t.message+` (defined at ${n[1]})`)}}if(t.stack){let r=t.stack.split(`
40
40
  `);r.splice(1,3),t.stack=r.join(`
41
- `)}return t},z6=e=>se(e,G6),dSe=e=>se(e,WF),jF=e=>se(e,Lw),$yt=Su(new Map),fSe=()=>$yt,V6=(e,t)=>Su(new Map([[e.key,t]])),pSe=x(3,(e,t,r)=>{let n=new Map(e.unsafeMap);return n.set(t.key,r),Su(n)}),q6=Te("effect/Context/defaultValueCache",()=>new Map),qF=e=>{if(q6.has(e.key))return q6.get(e.key);let t=e.defaultValue();return q6.set(e.key,t),t},mSe=(e,t)=>e.unsafeMap.has(t.key)?e.unsafeMap.get(t.key):qF(t),Y6=x(2,(e,t)=>{if(!e.unsafeMap.has(t.key)){if(Lw in t)return qF(t);throw Uyt(t)}return e.unsafeMap.get(t.key)}),hSe=Y6,gSe=x(3,(e,t,r)=>e.unsafeMap.has(t.key)?e.unsafeMap.get(t.key):jF(t)?qF(t):r()),ASe=x(2,(e,t)=>e.unsafeMap.has(t.key)?Au(e.unsafeMap.get(t.key)):jF(t)?Au(qF(t)):Gg),ySe=x(2,(e,t)=>{let r=new Map(e.unsafeMap);for(let[n,o]of t.unsafeMap)r.set(n,o);return Su(r)}),xSe=(...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].unsafeMap.forEach((n,o)=>{t.set(o,n)});return Su(t)},ESe=(...e)=>t=>{let r=new Set(e.map(o=>o.key)),n=new Map;for(let[o,i]of t.unsafeMap.entries())r.has(o)&&n.set(o,i);return Su(n)},bSe=(...e)=>t=>{let r=new Map(t.unsafeMap);for(let n of e)r.delete(n.key);return Su(r)}});var Kt={};tr(Kt,{GenericTag:()=>Jt,Reference:()=>si,ReferenceTypeId:()=>Wyt,Tag:()=>Hw,TagTypeId:()=>Hyt,add:()=>zt,empty:()=>ro,get:()=>Dr,getOption:()=>Ji,getOrElse:()=>qyt,isContext:()=>J6,isReference:()=>jyt,isTag:()=>$w,make:()=>Ra,merge:()=>wo,mergeAll:()=>K6,omit:()=>Z6,pick:()=>Gyt,unsafeGet:()=>_a,unsafeMake:()=>iA});var Hyt,Wyt,Jt,iA,J6,$w,jyt,ro,Ra,zt,Dr,qyt,_a,Ji,wo,K6,Gyt,Z6,Hw,si,sr=h(()=>{F_();Hyt=WF,Wyt=Lw,Jt=cSe,iA=Su,J6=z6,$w=dSe,jyt=jF,ro=fSe,Ra=V6,zt=pSe,Dr=hSe,qyt=gSe,_a=Y6,Ji=ASe,wo=ySe,K6=xSe,Gyt=ESe,Z6=bSe,Hw=uSe,si=lSe});var Nn={};tr(Nn,{Equivalence:()=>OSe,Order:()=>U_,between:()=>nxt,clamp:()=>uxt,days:()=>BSe,decode:()=>At,decodeUnknown:()=>Vyt,divide:()=>lxt,equals:()=>NSe,format:()=>YF,formatIso:()=>mxt,fromIso:()=>hxt,greaterThan:()=>pxt,greaterThanOrEqualTo:()=>$_,hours:()=>_Se,infinity:()=>o3,isDuration:()=>n3,isFinite:()=>L_,isZero:()=>kSe,lessThan:()=>i3,lessThanOrEqualTo:()=>s3,match:()=>Sf,matchWith:()=>vm,max:()=>axt,micros:()=>vSe,millis:()=>Ki,min:()=>ixt,minutes:()=>RSe,nanos:()=>Ww,parts:()=>a3,seconds:()=>sA,subtract:()=>fxt,sum:()=>VF,times:()=>zF,toDays:()=>ext,toHours:()=>Xyt,toHrTime:()=>QSe,toMillis:()=>Io,toMinutes:()=>Zyt,toNanos:()=>rxt,toSeconds:()=>Kyt,toWeeks:()=>txt,unsafeDivide:()=>dxt,unsafeFormatIso:()=>PSe,unsafeToNanos:()=>DSe,weeks:()=>TSe,zero:()=>As});var X6,ISe,CSe,GF,e3,t3,r3,zyt,At,Vyt,wSe,Yyt,Jyt,$o,n3,L_,kSe,As,o3,Ww,vSe,Ki,sA,RSe,_Se,BSe,TSe,Io,Kyt,Zyt,Xyt,ext,txt,rxt,DSe,QSe,Sf,vm,U_,nxt,OSe,oxt,ixt,sxt,axt,cxt,uxt,lxt,dxt,zF,fxt,VF,i3,s3,pxt,$_,NSe,a3,YF,PSe,mxt,hxt,gxt,Ws=h(()=>{mt();oe();ir();ht();it();bm();Me();ct();X6=Symbol.for("effect/Duration"),ISe=BigInt(0),CSe=BigInt(24),GF=BigInt(60),e3=BigInt(1e3),t3=BigInt(1e6),r3=BigInt(1e9),zyt=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,At=e=>{if(n3(e))return e;if(Ls(e))return Ki(e);if($g(e))return Ww(e);if(Array.isArray(e)&&e.length===2&&e.every(Ls))return e[0]===-1/0||e[1]===-1/0||Number.isNaN(e[0])||Number.isNaN(e[1])?As:e[0]===1/0||e[1]===1/0?o3:Ww(BigInt(Math.round(e[0]*1e9))+BigInt(Math.round(e[1])));if(Fo(e)){let t=zyt.exec(e);if(t){let[r,n,o]=t,i=Number(n);switch(o){case"nano":case"nanos":return Ww(BigInt(n));case"micro":case"micros":return vSe(BigInt(n));case"milli":case"millis":return Ki(i);case"second":case"seconds":return sA(i);case"minute":case"minutes":return RSe(i);case"hour":case"hours":return _Se(i);case"day":case"days":return BSe(i);case"week":case"weeks":return TSe(i)}}}throw new Error("Invalid DurationInput")},Vyt=EE(At),wSe={_tag:"Millis",millis:0},Yyt={_tag:"Infinity"},Jyt={[X6]:X6,[he](){return We(this,eF(this.value))},[me](e){return n3(e)&&NSe(this,e)},toString(){return`Duration(${YF(this)})`},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",hrtime:QSe(this)};case"Infinity":return{_id:"Duration",_tag:"Infinity"}}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},$o=e=>{let t=Object.create(Jyt);return Ls(e)?isNaN(e)||e<=0?t.value=wSe:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:BigInt(Math.round(e*1e6))}:t.value=Yyt:e<=ISe?t.value=wSe:t.value={_tag:"Nanos",nanos:e},t},n3=e=>se(e,X6),L_=e=>e.value._tag!=="Infinity",kSe=e=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===ISe;case"Infinity":return!1}},As=$o(0),o3=$o(1/0),Ww=e=>$o(e),vSe=e=>$o(e*e3),Ki=e=>$o(e),sA=e=>$o(e*1e3),RSe=e=>$o(e*6e4),_Se=e=>$o(e*36e5),BSe=e=>$o(e*864e5),TSe=e=>$o(e*6048e5),Io=e=>Sf(e,{onMillis:t=>t,onNanos:t=>Number(t)/1e6}),Kyt=e=>Sf(e,{onMillis:t=>t/1e3,onNanos:t=>Number(t)/1e9}),Zyt=e=>Sf(e,{onMillis:t=>t/6e4,onNanos:t=>Number(t)/6e10}),Xyt=e=>Sf(e,{onMillis:t=>t/36e5,onNanos:t=>Number(t)/36e11}),ext=e=>Sf(e,{onMillis:t=>t/864e5,onNanos:t=>Number(t)/864e11}),txt=e=>Sf(e,{onMillis:t=>t/6048e5,onNanos:t=>Number(t)/6048e11}),rxt=e=>{let t=At(e);switch(t.value._tag){case"Infinity":return W();case"Nanos":return H(t.value.nanos);case"Millis":return H(BigInt(Math.round(t.value.millis*1e6)))}},DSe=e=>{let t=At(e);switch(t.value._tag){case"Infinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return BigInt(Math.round(t.value.millis*1e6))}},QSe=e=>{let t=At(e);switch(t.value._tag){case"Infinity":return[1/0,0];case"Nanos":return[Number(t.value.nanos/r3),Number(t.value.nanos%r3)];case"Millis":return[Math.floor(t.value.millis/1e3),Math.round(t.value.millis%1e3*1e6)]}},Sf=x(2,(e,t)=>{let r=At(e);switch(r.value._tag){case"Nanos":return t.onNanos(r.value.nanos);case"Infinity":return t.onMillis(1/0);case"Millis":return t.onMillis(r.value.millis)}}),vm=x(3,(e,t,r)=>{let n=At(e),o=At(t);if(n.value._tag==="Infinity"||o.value._tag==="Infinity")return r.onMillis(Io(n),Io(o));if(n.value._tag==="Nanos"||o.value._tag==="Nanos"){let i=n.value._tag==="Nanos"?n.value.nanos:BigInt(Math.round(n.value.millis*1e6)),s=o.value._tag==="Nanos"?o.value.nanos:BigInt(Math.round(o.value.millis*1e6));return r.onNanos(i,s)}return r.onMillis(n.value.millis,o.value.millis)}),U_=xE((e,t)=>vm(e,t,{onMillis:(r,n)=>r<n?-1:r>n?1:0,onNanos:(r,n)=>r<n?-1:r>n?1:0})),nxt=e6(yf(U_,At)),OSe=(e,t)=>vm(e,t,{onMillis:(r,n)=>r===n,onNanos:(r,n)=>r===n}),oxt=fF(U_),ixt=x(2,(e,t)=>oxt(At(e),At(t))),sxt=pF(U_),axt=x(2,(e,t)=>sxt(At(e),At(t))),cxt=XJ(U_),uxt=x(2,(e,t)=>cxt(At(e),{minimum:At(t.minimum),maximum:At(t.maximum)})),lxt=x(2,(e,t)=>Sf(e,{onMillis:r=>t===0||isNaN(t)||!Number.isFinite(t)?W():H($o(r/t)),onNanos:r=>{if(isNaN(t)||t<=0||!Number.isFinite(t))return W();try{return H($o(r/BigInt(t)))}catch{return W()}}})),dxt=x(2,(e,t)=>Sf(e,{onMillis:r=>$o(r/t),onNanos:r=>isNaN(t)||t<0||Object.is(t,-0)?As:Object.is(t,0)||!Number.isFinite(t)?o3:$o(r/BigInt(t))})),zF=x(2,(e,t)=>Sf(e,{onMillis:r=>$o(r*t),onNanos:r=>$o(r*BigInt(t))})),fxt=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>$o(r-n),onNanos:(r,n)=>$o(r-n)})),VF=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>$o(r+n),onNanos:(r,n)=>$o(r+n)})),i3=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>r<n,onNanos:(r,n)=>r<n})),s3=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>r<=n,onNanos:(r,n)=>r<=n})),pxt=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>r>n,onNanos:(r,n)=>r>n})),$_=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>r>=n,onNanos:(r,n)=>r>=n})),NSe=x(2,(e,t)=>OSe(At(e),At(t))),a3=e=>{let t=At(e);if(t.value._tag==="Infinity")return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};let r=DSe(t),n=r/t3,o=n/e3,i=o/GF,s=i/GF,a=s/CSe;return{days:Number(a),hours:Number(s%CSe),minutes:Number(i%GF),seconds:Number(o%GF),millis:Number(n%e3),nanos:Number(r%t3)}},YF=e=>{let t=At(e);if(t.value._tag==="Infinity")return"Infinity";if(kSe(t))return"0";let r=a3(t),n=[];return r.days!==0&&n.push(`${r.days}d`),r.hours!==0&&n.push(`${r.hours}h`),r.minutes!==0&&n.push(`${r.minutes}m`),r.seconds!==0&&n.push(`${r.seconds}s`),r.millis!==0&&n.push(`${r.millis}ms`),r.nanos!==0&&n.push(`${r.nanos}ns`),n.join(" ")},PSe=e=>{let t=At(e);if(!L_(t))throw new RangeError("Cannot format infinite duration");let r=[],{days:n,hours:o,millis:i,minutes:s,nanos:a,seconds:c}=a3(t),u=n;if(u>=365){let l=Math.floor(u/365);u%=365,r.push(`${l}Y`)}if(u>=30){let l=Math.floor(u/30);u%=30,r.push(`${l}M`)}if(u>=7){let l=Math.floor(u/7);u%=7,r.push(`${l}W`)}if(u>0&&r.push(`${u}D`),(o!==0||s!==0||c!==0||i!==0||a!==0)&&(r.push("T"),o!==0&&r.push(`${o}H`),s!==0&&r.push(`${s}M`),c!==0||i!==0||a!==0)){let l=BigInt(c)*r3+BigInt(i)*t3+BigInt(a),d=(Number(l)/1e9).toFixed(9).replace(/\.?0+$/,"");r.push(`${d}S`)}return`P${r.join("")||"T0S"}`},mxt=e=>{let t=At(e);return L_(t)?H(PSe(t)):W()},hxt=e=>{let t=gxt.exec(e);if(t==null)return W();let[r,n,o,i,s,a,c]=t.slice(1,8).map(l=>l?Number(l):0),u=r*365*24*60*60+n*30*24*60*60+o*7*24*60*60+i*24*60*60+s*60*60+a*60+c;return H(sA(u))},gxt=/^P(?!$)(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?!$)(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/});var MSe,Axt,Ba,JF,Qr,js,Kl=h(()=>{mt();oe();ht();Me();MSe=Symbol.for("effect/MutableRef"),Axt={[MSe]:MSe,toString(){return Fe(this.toJSON())},toJSON(){return{_id:"MutableRef",current:xt(this.current)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},Ba=e=>{let t=Object.create(Axt);return t.current=e,t},JF=x(3,(e,t,r)=>ce(t,e.current)?(e.current=r,!0):!1),Qr=e=>e.current,js=x(2,(e,t)=>(e.current=t,e))});var tL,aA,cA,KF,ZF,yxt,c3,H_,XF,j_,LSe,USe,rL,u3,l3,$Se,HSe,W_,FSe,WSe,nL,eL,jSe,oL=h(()=>{mt();oe();yn();ir();dc();ht();Kl();ct();tL="effect/FiberId",aA=Symbol.for(tL),cA="None",KF="Runtime",ZF="Composite",yxt=Lt(`${tL}-${cA}`),c3=class{[aA]=aA;_tag=cA;id=-1;startTimeMillis=-1;[he](){return yxt}[me](t){return rL(t)&&t._tag===cA}toString(){return Fe(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag}}[Ce](){return this.toJSON()}},H_=class{id;startTimeMillis;[aA]=aA;_tag=KF;constructor(t,r){this.id=t,this.startTimeMillis=r}[he](){return We(this,Lt(`${tL}-${this._tag}-${this.id}-${this.startTimeMillis}`))}[me](t){return rL(t)&&t._tag===KF&&this.id===t.id&&this.startTimeMillis===t.startTimeMillis}toString(){return Fe(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag,id:this.id,startTimeMillis:this.startTimeMillis}}[Ce](){return this.toJSON()}},XF=class{left;right;[aA]=aA;_tag=ZF;constructor(t,r){this.left=t,this.right=r}_hash;[he](){return C(Lt(`${tL}-${this._tag}`),we(ae(this.left)),we(ae(this.right)),We(this))}[me](t){return rL(t)&&t._tag===ZF&&ce(this.left,t.left)&&ce(this.right,t.right)}toString(){return Fe(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag,left:xt(this.left),right:xt(this.right)}}[Ce](){return this.toJSON()}},j_=new c3,LSe=(e,t)=>new H_(e,t),USe=(e,t)=>new XF(e,t),rL=e=>se(e,aA),u3=e=>e._tag===cA||C(eL(e),Kbe(t=>u3(t))),l3=x(2,(e,t)=>e._tag===cA?t:t._tag===cA?e:new XF(e,t)),$Se=e=>C(e,tA(j_,(t,r)=>l3(r)(t))),HSe=x(2,(e,t)=>u3(e)?t:e),W_=e=>{switch(e._tag){case cA:return ql();case KF:return eA(e.id);case ZF:return C(W_(e.left),Ef(W_(e.right)))}},FSe=Te(Symbol.for("effect/Fiber/Id/_fiberCounter"),()=>Ba(0)),WSe=(e,t)=>new H_(e,t),nL=e=>Array.from(W_(e)).map(r=>`#${r}`).join(","),eL=e=>{switch(e._tag){case cA:return ql();case KF:return eA(e);case ZF:return C(eL(e.left),Ef(eL(e.right)))}},jSe=()=>{let e=Qr(FSe);return C(FSe,js(e+1)),new H_(e,Date.now())}});var ai,GSe,zSe,jw,VSe,iL,qw,YSe,JSe,sL,Zl=h(()=>{oL();ai=j_,GSe=LSe,zSe=USe,jw=l3,VSe=$Se,iL=HSe,qw=W_,YSe=WSe,JSe=nL,sL=jSe});var If,KSe,ZSe,aL,d3,f3,ko,p3,XSe,eCe,tCe,rCe,m3,kf=h(()=>{Q6();If=Ow,KSe=_be,ZSe=Tbe,aL=Dbe,d3=Qbe,f3=RF,ko=IE,p3=_F,XSe=Obe,eCe=BF,tCe=Pbe,rCe=DF,m3=Nw});var q_,h3,xxt,Ext,bxt,cL,Sxt,Cxt,nCe,oCe,vf,g3,wxt,_m,Rf,G_,iCe,uL,Ixt,sCe,aCe,Gw=h(()=>{wr();mt();mm();oe();ir();ht();Me();ct();q_=Symbol.for("effect/List"),h3=e=>_e(e),xxt=e=>OJ(Jg(e),h3),Ext=xxt(ce),bxt={[q_]:q_,_tag:"Cons",toString(){return Fe(this.toJSON())},toJSON(){return{_id:"List",_tag:"Cons",values:h3(this).map(xt)}},[Ce](){return this.toJSON()},[me](e){return oCe(e)&&this._tag===e._tag&&Ext(this,e)},[he](){return We(this,So(h3(this)))},[Symbol.iterator](){let e=!1,t=this;return{next(){if(e)return this.return();if(t._tag==="Nil")return e=!0,this.return();let r=t.head;return t=t.tail,{done:e,value:r}},return(r){return e||(e=!0),{done:!0,value:r}}}},pipe(){return Z(this,arguments)}},cL=(e,t)=>{let r=Object.create(bxt);return r.head=e,r.tail=t,r},Sxt=Lt("Nil"),Cxt={[q_]:q_,_tag:"Nil",toString(){return Fe(this.toJSON())},toJSON(){return{_id:"List",_tag:"Nil"}},[Ce](){return this.toJSON()},[he](){return Sxt},[me](e){return oCe(e)&&this._tag===e._tag},[Symbol.iterator](){return{next(){return{done:!0,value:void 0}}}},pipe(){return Z(this,arguments)}},nCe=Object.create(Cxt),oCe=e=>se(e,q_),vf=e=>e._tag==="Nil",g3=e=>e._tag==="Cons",wxt=()=>nCe,_m=(e,t)=>cL(e,t),Rf=wxt,G_=e=>cL(e,nCe),iCe=x(2,(e,t)=>Ixt(t,e)),uL=x(2,(e,t)=>_m(t,e)),Ixt=x(2,(e,t)=>{if(vf(e))return t;if(vf(t))return e;{let r=cL(t.head,e),n=r,o=t.tail;for(;!vf(o);){let i=cL(o.head,e);n.tail=i,n=i,o=o.tail}return r}}),sCe=x(3,(e,t,r)=>{let n=t,o=e;for(;!vf(o);)n=r(n,o.head),o=o.tail;return n}),aCe=e=>{let t=Rf(),r=e;for(;!vf(r);)t=uL(t,r.head),r=r.tail;return t}});var cCe,Bm,zw,Vw=h(()=>{mt();ir();Af();cCe=Object.assign(Object.create(Array.prototype),{[he](){return We(this,So(this))},[me](e){return Array.isArray(e)&&this.length===e.length?this.every((t,r)=>ce(t,e[r])):!1}}),Bm=function(){function e(t){t&&Object.assign(this,t)}return e.prototype=gf,e}(),zw=e=>Object.assign(Object.create(gf),e)});function uCe(e){return e}var kxt,Y_,vxt,Rxt,y3,_xt,Bxt,Txt,Dxt,Qxt,Oxt,Nxt,Pxt,lCe,V_,dCe,fCe=h(()=>{vr();mt();oe();F_();Vw();kxt=Symbol.for("effect/DifferContextPatch");Y_={...Bm.prototype,[kxt]:{_Value:uCe,_Patch:uCe}},vxt=Object.assign(Object.create(Y_),{_tag:"Empty"}),Rxt=Object.create(vxt),y3=()=>Rxt,_xt=Object.assign(Object.create(Y_),{_tag:"AndThen"}),Bxt=(e,t)=>{let r=Object.create(_xt);return r.first=e,r.second=t,r},Txt=Object.assign(Object.create(Y_),{_tag:"AddService"}),Dxt=(e,t)=>{let r=Object.create(Txt);return r.key=e,r.service=t,r},Qxt=Object.assign(Object.create(Y_),{_tag:"RemoveService"}),Oxt=e=>{let t=Object.create(Qxt);return t.key=e,t},Nxt=Object.assign(Object.create(Y_),{_tag:"UpdateService"}),Pxt=(e,t)=>{let r=Object.create(Nxt);return r.key=e,r.update=t,r},lCe=(e,t)=>{let r=new Map(e.unsafeMap),n=y3();for(let[o,i]of t.unsafeMap.entries())if(r.has(o)){let s=r.get(o);r.delete(o),ce(s,i)||(n=V_(Pxt(o,()=>i))(n))}else r.delete(o),n=V_(Dxt(o,i))(n);for(let[o]of r.entries())n=V_(Oxt(o))(n);return n},V_=x(2,(e,t)=>Bxt(e,t)),dCe=x(2,(e,t)=>{if(e._tag==="Empty")return t;let r=!1,n=Dt(e),o=new Map(t.unsafeMap);for(;kr(n);){let s=Gt(n),a=Ur(n);switch(s._tag){case"Empty":{n=a;break}case"AddService":{o.set(s.key,s.service),n=a;break}case"AndThen":{n=fr(fr(a,s.second),s.first);break}case"RemoveService":{o.delete(s.key),n=a;break}case"UpdateService":{o.set(s.key,s.update(o.get(s.key))),r=!0,n=a;break}}}if(!r)return Su(o);let i=new Map;for(let[s]of t.unsafeMap)o.has(s)&&(i.set(s,o.get(s)),o.delete(s));for(let[s,a]of o)i.set(s,a);return Su(i)})});function x3(e){return e}var Fxt,dL,Lxt,Uxt,E3,$xt,Hxt,Wxt,jxt,qxt,Gxt,pCe,lL,mCe,hCe=h(()=>{vr();oe();dc();Vw();Fxt=Symbol.for("effect/DifferHashSetPatch");dL={...Bm.prototype,[Fxt]:{_Value:x3,_Key:x3,_Patch:x3}},Lxt=Object.assign(Object.create(dL),{_tag:"Empty"}),Uxt=Object.create(Lxt),E3=()=>Uxt,$xt=Object.assign(Object.create(dL),{_tag:"AndThen"}),Hxt=(e,t)=>{let r=Object.create($xt);return r.first=e,r.second=t,r},Wxt=Object.assign(Object.create(dL),{_tag:"Add"}),jxt=e=>{let t=Object.create(Wxt);return t.value=e,t},qxt=Object.assign(Object.create(dL),{_tag:"Remove"}),Gxt=e=>{let t=Object.create(qxt);return t.value=e,t},pCe=(e,t)=>{let[r,n]=tA([e,E3()],([o,i],s)=>FF(s)(o)?[P6(s)(o),i]:[o,lL(jxt(s))(i)])(t);return tA(n,(o,i)=>lL(Gxt(i))(o))(r)},lL=x(2,(e,t)=>Hxt(e,t)),mCe=x(2,(e,t)=>{if(e._tag==="Empty")return t;let r=t,n=Dt(e);for(;kr(n);){let o=Gt(n),i=Ur(n);switch(o._tag){case"Empty":{n=i;break}case"AndThen":{n=fr(o.first)(fr(o.second)(i));break}case"Add":{r=kE(o.value)(r),n=i;break}case"Remove":r=P6(o.value)(r),n=i}}return r})});function gCe(e){return e}var Vxt,K_,Yxt,Jxt,b3,Kxt,Zxt,Xxt,eEt,tEt,rEt,nEt,oEt,ACe,J_,yCe,xCe=h(()=>{wr();mt();oe();Vw();Vxt=Symbol.for("effect/DifferReadonlyArrayPatch");K_={...Bm.prototype,[Vxt]:{_Value:gCe,_Patch:gCe}},Yxt=Object.assign(Object.create(K_),{_tag:"Empty"}),Jxt=Object.create(Yxt),b3=()=>Jxt,Kxt=Object.assign(Object.create(K_),{_tag:"AndThen"}),Zxt=(e,t)=>{let r=Object.create(Kxt);return r.first=e,r.second=t,r},Xxt=Object.assign(Object.create(K_),{_tag:"Append"}),eEt=e=>{let t=Object.create(Xxt);return t.values=e,t},tEt=Object.assign(Object.create(K_),{_tag:"Slice"}),rEt=(e,t)=>{let r=Object.create(tEt);return r.from=e,r.until=t,r},nEt=Object.assign(Object.create(K_),{_tag:"Update"}),oEt=(e,t)=>{let r=Object.create(nEt);return r.index=e,r.patch=t,r},ACe=e=>{let t=0,r=b3();for(;t<e.oldValue.length&&t<e.newValue.length;){let n=e.oldValue[t],o=e.newValue[t],i=e.differ.diff(n,o);ce(i,e.differ.empty)||(r=J_(r,oEt(t,i))),t=t+1}return t<e.oldValue.length&&(r=J_(r,rEt(0,t))),t<e.newValue.length&&(r=J_(r,eEt(abe(t)(e.newValue)))),r},J_=x(2,(e,t)=>Zxt(e,t)),yCe=x(3,(e,t,r)=>{if(e._tag==="Empty")return t;let n=t.slice(),o=hs(e);for(;Cm(o);){let i=Lo(o),s=Ll(o);switch(i._tag){case"Empty":{o=s;break}case"AndThen":{s.unshift(i.first,i.second),o=s;break}case"Append":{for(let a of i.values)n.push(a);o=s;break}case"Slice":{n=n.slice(i.from,i.until),o=s;break}case"Update":{n[i.index]=r.patch(i.patch,n[i.index]),o=s;break}}}return n})});var ECe,sEt,uA,S3,C3,w3,fL,bCe,pL=h(()=>{mt();oe();Me();fCe();hCe();xCe();ECe=Symbol.for("effect/Differ"),sEt={[ECe]:{_P:be,_V:be},pipe(){return Z(this,arguments)}},uA=e=>{let t=Object.create(sEt);return t.empty=e.empty,t.diff=e.diff,t.combine=e.combine,t.patch=e.patch,t},S3=()=>uA({empty:y3(),combine:(e,t)=>V_(t)(e),diff:(e,t)=>lCe(e,t),patch:(e,t)=>dCe(t)(e)}),C3=()=>uA({empty:E3(),combine:(e,t)=>lL(t)(e),diff:(e,t)=>pCe(e,t),patch:(e,t)=>mCe(t)(e)}),w3=e=>uA({empty:b3(),combine:(t,r)=>J_(t,r),diff:(t,r)=>ACe({oldValue:t,newValue:r,differ:e}),patch:(t,r)=>yCe(t,r,e)}),fL=()=>bCe((e,t)=>t),bCe=e=>uA({empty:be,combine:(t,r)=>t===be?r:r===be?t:n=>r(t(n)),diff:(t,r)=>ce(t,r)?be:fm(r),patch:(t,r)=>e(r,t(r))})});var Z_,SCe,mL,hL,ME,gL,CCe,wCe,ICe,k3,kCe,v3=h(()=>{oe();Z_=255,SCe=8,mL=e=>e&Z_,hL=e=>e>>SCe&Z_,ME=(e,t)=>(e&Z_)+((t&e&Z_)<<SCe),gL=ME(0,0),CCe=e=>ME(e,e),wCe=e=>ME(e,0),ICe=x(2,(e,t)=>ME(mL(e)&~t,hL(e))),k3=x(2,(e,t)=>e|t),kCe=e=>~e>>>0&Z_});var aEt,Xl,RCe,R3,AL,_3,_Ce,B3,T3,ed,X_,yL,D3,BCe,Q3,cEt,Cu,Tm,O3,lA=h(()=>{oe();pL();v3();aEt=0,Xl=1,RCe=2,R3=4,AL=16,_3=32,_Ce=e=>yL(e,_3),B3=x(2,(e,t)=>e&~t),T3=x(2,(e,t)=>e|t),ed=e=>X_(e)&&!cEt(e),X_=e=>yL(e,Xl),yL=x(2,(e,t)=>(e&t)!==0),D3=(...e)=>e.reduce((t,r)=>t|r,0),BCe=D3(aEt),Q3=e=>yL(e,R3),cEt=e=>yL(e,AL),Cu=x(2,(e,t)=>ME(e^t,t)),Tm=x(2,(e,t)=>e&(kCe(mL(t))|hL(t))|mL(t)&hL(t)),O3=uA({empty:gL,diff:(e,t)=>Cu(e,t),combine:(e,t)=>k3(t)(e),patch:(e,t)=>Tm(t,e)})});var TCe,N3,P3,M3,xL=h(()=>{v3();TCe=gL,N3=CCe,P3=wCe,M3=ICe});var DCe,$3,EL,H3,QCe,uEt,lEt,dEt,U3,fEt,W3,pEt,mEt,eB,OCe,hEt,gEt,AEt,yEt,L3,xEt,EEt,bL,bEt,SEt,CEt,NCe,j3=h(()=>{vr();mt();kf();Gw();it();DCe={_tag:"Empty"},$3=(e,t)=>({_tag:"Par",left:e,right:t}),EL=(e,t)=>({_tag:"Seq",left:e,right:t}),H3=(e,t)=>({_tag:"Single",dataSource:e,blockedRequest:t}),QCe=e=>{let t=G_(e),r=Rf();for(;;){let[n,o]=sCe(t,[OCe(),Rf()],([i,s],a)=>{let[c,u]=uEt(a);return[gEt(i,c),iCe(s,u)]});if(r=lEt(r,n),vf(o))return aCe(r);t=o}throw new Error("BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues")},uEt=e=>{let t=e,r=OCe(),n=Rf(),o=Rf();for(;;)switch(t._tag){case"Empty":{if(vf(n))return[r,o];t=n.head,n=n.tail;break}case"Par":{n=_m(t.right,n),t=t.left;break}case"Seq":{let i=t.left,s=t.right;switch(i._tag){case"Empty":{t=s;break}case"Par":{let a=i.left,c=i.right;t=$3(EL(a,s),EL(c,s));break}case"Seq":{let a=i.left,c=i.right;t=EL(a,EL(c,s));break}case"Single":{t=i,o=_m(s,o);break}}break}case"Single":{if(r=hEt(r,t),vf(n))return[r,o];t=n.head,n=n.tail;break}}throw new Error("BUG: BlockedRequests.step - please report an issue at https://github.com/Effect-TS/effect/issues")},lEt=(e,t)=>{if(vf(e))return G_(L3(t));if(AEt(t))return e;let r=CEt(e.head),n=yEt(t);return r.length===1&&n.length===1&&ce(r[0],n[0])?_m(SEt(e.head,L3(t)),e.tail):_m(L3(t),e)},dEt=Symbol.for("effect/RequestBlock/Entry"),U3=class{request;result;listeners;ownerId;state;[dEt]=fEt;constructor(t,r,n,o,i){this.request=t,this.result=r,this.listeners=n,this.ownerId=o,this.state=i}},fEt={_R:e=>e},W3=e=>new U3(e.request,e.result,e.listeners,e.ownerId,e.state),pEt=Symbol.for("effect/RequestBlock/RequestBlockParallel"),mEt={_R:e=>e},eB=class{map;[pEt]=mEt;constructor(t){this.map=t}},OCe=()=>new eB(If()),hEt=(e,t)=>new eB(eCe(e.map,t.dataSource,r=>n6(dr(r,$s(t.blockedRequest)),()=>Dt(t.blockedRequest)))),gEt=(e,t)=>new eB(m3(e.map,t.map,(r,n,o)=>ko(r,o,wt(aL(r,o),{onNone:()=>n,onSome:i=>Ir(n,i)})))),AEt=e=>ZSe(e.map),yEt=e=>Array.from(p3(e.map)),L3=e=>bEt(tCe(e.map,t=>Dt(t))),xEt=Symbol.for("effect/RequestBlock/RequestBlockSequential"),EEt={_R:e=>e},bL=class{map;[xEt]=EEt;constructor(t){this.map=t}},bEt=e=>new bL(e),SEt=(e,t)=>new bL(m3(t.map,e.map,(r,n,o)=>ko(r,o,wt(aL(r,o),{onNone:()=>Ut(),onSome:i=>Ir(i,n)})))),CEt=e=>Array.from(p3(e.map)),NCe=e=>Array.from(e.map)});var dA,FE,q3=h(()=>{dA="Pending",FE="Done"});var wEt,SL,FCe,LCe,G3,z3=h(()=>{q3();wEt="effect/Deferred",SL=Symbol.for(wEt),FCe={_E:e=>e,_A:e=>e},LCe=e=>({_tag:dA,joiners:e}),G3=e=>({_tag:FE,effect:e})});var Jw,$Ce=h(()=>{Jw=class e{self;called=!1;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(t){return{value:t,done:!0}}throw(t){throw t}[Symbol.iterator](){return new e(this.self)}}});var Qm,RL,Om,CL,zn,wL,IL,ar,st,_L,Zt,$r,oB,Kw,_f,bi,Bf,fc,iB,jCe,qCe,HCe,BL,Si,fA,Ta,wu,fn,ut,pc,kt,Tf,td,Da,O,pA,TL,ys,mA,sB,dn,Ho,Wo,mc,DL,qs,aB,Qa,GCe,Df,te,cB,hA,QL,Gs,hc,LE,UE,eK,zCe,Zw,M,ye,V,jo,OL,IEt,Iu,xn,Ue,gA,AA,yA,rB,uB,Xw,VCe,YCe,NL,JCe,KCe,ku,Nm,$E,je,Zi,xA,gc,xs,ZCe,XCe,ewe,tK,rK,nK,twe,rwe,kEt,nwe,vEt,Xi,ci,Dm,owe,REt,iwe,_Et,WCe,BEt,tn,no,pn,oK,TEt,lB,EA,swe,ui,Qf,dB,Of,PL,fB,iK,awe,pB,eI,tI,mB,cwe,Nf,uwe,nB,bA,rI,Pm,HE,hB,ML,FL,gB,SA,rd,Ac,lwe,dwe,AB,WE,V3,fwe,kL,pwe,sK,Y3,vu,vL,Es,aK,J3,DIr,K3,DEt,Z3,mwe,hwe,X3,nI,jE,LL,yB,gwe,qE,oI,Awe,CA,UL,ywe,nd,$t,cK,xwe,Ewe,bwe,Swe,Cwe,wwe,xB,tB,Iwe,kwe,vwe,GE,zE,Vt,Pn,Rwe,_we,$L,Bwe,Twe,Dwe,Ru,QEt,wA,Ci,uK,Cn,HL,yc,lK,Qwe,Owe,iI,Nwe,Pwe,Mwe,Fwe,EB,Lwe,Uwe,Mm,$we,IA,OEt,NEt,Oa,xc,zs,WL,kA,dK,Hwe,jL,PEt,Wwe,vt=h(()=>{wr();vr();sr();Ws();Ei();mt();Zl();oe();yn();ir();kf();ht();Gw();Kl();it();Me();ct();xL();mu();Jl();z3();pL();Af();gw();q3();Iw();lA();$Ce();Qm=(e,t)=>{let r=new zn("Blocked");return r.effect_instruction_i0=e,r.effect_instruction_i1=t,r},RL=e=>{let t=new zn("RunBlocked");return t.effect_instruction_i0=e,t},Om=Symbol.for("effect/Effect"),CL=class{patch;op;_op=f_;constructor(t,r){this.patch=t,this.op=r}},zn=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[Om]=jg;constructor(t){this._op=t}[me](t){return this===t}[he](){return We(this,Aw(this))}pipe(){return Z(this,arguments)}toJSON(){return{_id:"Effect",_op:this._op,effect_instruction_i0:xt(this.effect_instruction_i0),effect_instruction_i1:xt(this.effect_instruction_i1),effect_instruction_i2:xt(this.effect_instruction_i2)}}toString(){return Fe(this.toJSON())}[Ce](){return this.toJSON()}[Symbol.iterator](){return new Jw(new hf(this))}},wL=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[Om]=jg;constructor(t){this._op=t,this._tag=t}[me](t){return jE(t)&&t._op==="Failure"&&ce(this.effect_instruction_i0,t.effect_instruction_i0)}[he](){return C(Lt(this._tag),we(ae(this.effect_instruction_i0)),We(this))}get cause(){return this.effect_instruction_i0}pipe(){return Z(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,cause:this.cause.toJSON()}}toString(){return Fe(this.toJSON())}[Ce](){return this.toJSON()}[Symbol.iterator](){return new Jw(new hf(this))}},IL=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[Om]=jg;constructor(t){this._op=t,this._tag=t}[me](t){return jE(t)&&t._op==="Success"&&ce(this.effect_instruction_i0,t.effect_instruction_i0)}[he](){return C(Lt(this._tag),we(ae(this.effect_instruction_i0)),We(this))}get value(){return this.effect_instruction_i0}pipe(){return Z(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,value:xt(this.value)}}toString(){return Fe(this.toJSON())}[Ce](){return this.toJSON()}[Symbol.iterator](){return new Jw(new hf(this))}},ar=e=>se(e,Om),st=e=>{let t=new zn(oF);return t.effect_instruction_i0=e,t},_L=x(3,(e,t,r)=>xn(n=>O(e,o=>O(fn(ye(()=>n(t(o)))),i=>ye(()=>r(o,i)).pipe(dn({onFailure:s=>{switch(i._tag){case Rr:return kt(Vr(i.effect_instruction_i0,s));case _r:return kt(s)}},onSuccess:()=>i})))))),Zt=x(2,(e,t)=>O(e,()=>M(t))),$r=e=>Zt(e,void 0),oB=function(){let e=new zn(AE);switch(arguments.length){case 2:{e.effect_instruction_i0=arguments[0],e.commit=arguments[1];break}case 3:{e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.commit=arguments[2];break}case 4:{e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.effect_instruction_i2=arguments[2],e.commit=arguments[3];break}default:throw new Error(Fl("you're not supposed to end up here"))}return e},Kw=(e,t=ai)=>{let r=new zn(gE),n;return r.effect_instruction_i0=o=>{n=e(o)},r.effect_instruction_i1=t,hc(r,o=>ar(n)?n:Ue)},_f=(e,t=ai)=>ye(()=>Kw(e,t)),bi=(e,t=ai)=>oB(e,function(){let r,n;function o(c){r?r(c):n===void 0&&(n=c)}let i=new zn(gE);i.effect_instruction_i0=c=>{r=c,n&&c(n)},i.effect_instruction_i1=t;let s,a;return this.effect_instruction_i0.length!==1?(a=new AbortController,s=qn(()=>this.effect_instruction_i0(o,a.signal))):s=qn(()=>this.effect_instruction_i0(o)),s||a?hc(i,c=>(a&&a.abort(),s??Ue)):i}),Bf=x(2,(e,t)=>{let r=new zn(Ew);return r.effect_instruction_i0=e,r.effect_instruction_i1=t,r}),fc=x(2,(e,t)=>Ho(e,{onFailure:t,onSuccess:M})),iB=x(3,(e,t,r)=>Bf(e,n=>{let o=Vl(n);switch(o._tag){case"Left":return t(o.left)?r(o.left):kt(n);case"Right":return kt(o.right)}})),jCe=x(2,(e,t)=>Bf(e,r=>{let n=Vl(r);switch(n._tag){case"Left":return C(t(n.left),Nt(()=>kt(r)));case"Right":return kt(n.right)}})),qCe=e=>st((t,r)=>e(X_(r.runtimeFlags))),HCe=Symbol.for("effect/OriginalAnnotation"),BL=(e,t)=>pt(t)?new Proxy(e,{has(r,n){return n===DE||n===HCe||n in r},get(r,n){return n===DE?t.value:n===HCe?e:r[n]}}):e,Si=e=>yi(e)&&!(DE in e)?st(t=>kt(eo(BL(e,jL(t))))):kt(eo(e)),fA=e=>Tf(()=>eo(new fwe(e))),Ta=e=>O(V(e),Si),wu=e=>Ho(e,{onFailure:t=>M(Re(t)),onSuccess:t=>M(Le(t))}),fn=e=>sB(e,{onFailure:$t,onSuccess:Vt}),ut=e=>yi(e)&&!(DE in e)?st(t=>kt(zl(BL(e,jL(t))))):kt(zl(e)),pc=e=>O(V(e),ut),kt=e=>{let t=new wL(Rr);return t.effect_instruction_i0=e,t},Tf=e=>O(V(e),kt),td=st(e=>M(e.id())),Da=e=>st(t=>e(t.id())),O=x(2,(e,t)=>{let r=new zn(bw);return r.effect_instruction_i0=e,r.effect_instruction_i1=t,r}),pA=x(2,(e,t)=>O(e,r=>{let n=typeof t=="function"?t(r):t;return ar(n)?n:MJ(n)?Kw(o=>{n.then(i=>o(M(i)),i=>o(ut(new nI(i,"An unknown error occurred in Effect.andThen"))))}):M(n)})),TL=e=>{let t=new zn("OnStep");return t.effect_instruction_i0=e,t},ys=e=>O(e,be),mA=e=>Ho(e,{onFailure:M,onSuccess:ut}),sB=x(2,(e,t)=>dn(e,{onFailure:r=>M(t.onFailure(r)),onSuccess:r=>M(t.onSuccess(r))})),dn=x(2,(e,t)=>{let r=new zn(Sw);return r.effect_instruction_i0=e,r.effect_instruction_i1=t.onFailure,r.effect_instruction_i2=t.onSuccess,r}),Ho=x(2,(e,t)=>dn(e,{onFailure:r=>{if(Q_(r).length>0)return kt(sSe(r));let o=D_(r);return o.length>0?t.onFailure(w_(o)):kt(r)},onSuccess:t.onSuccess})),Wo=x(2,(e,t)=>ye(()=>{let r=_e(e),n=bE(r.length),o=0;return Zt(yA({while:()=>o<r.length,body:()=>t(r[o],o),step:i=>{n[o++]=i}}),n)})),mc=x(2,(e,t)=>ye(()=>{let r=_e(e),n=0;return yA({while:()=>n<r.length,body:()=>t(r[n],n),step:()=>{n++}})})),DL=x(e=>typeof e[0]=="boolean"||ar(e[0]),(e,t)=>ar(e)?O(e,r=>r?t.onTrue():t.onFalse()):e?t.onTrue():t.onFalse()),qs=O(td,e=>aB(e)),aB=e=>kt(Hs(e)),Qa=e=>{let t=new zn(xm);return t.effect_instruction_i0=N3(Xl),t.effect_instruction_i1=()=>e,t},GCe=e=>oB(e,function(){let t=new zn(xm);return t.effect_instruction_i0=N3(Xl),t.effect_instruction_i1=r=>X_(r)?qn(()=>this.effect_instruction_i0(Qa)):qn(()=>this.effect_instruction_i0(Iu)),t}),Df=x(2,(e,t)=>xn(r=>O(fn(r(e)),n=>lK(t,n)))),te=x(2,(e,t)=>O(e,r=>V(()=>t(r)))),cB=x(2,(e,t)=>Ho(e,{onFailure:r=>pc(()=>t.onFailure(r)),onSuccess:r=>V(()=>t.onSuccess(r))})),hA=x(2,(e,t)=>dn(e,{onFailure:r=>{let n=Vl(r);switch(n._tag){case"Left":return pc(()=>t(n.left));case"Right":return kt(n.right)}},onSuccess:M})),QL=x(2,(e,t)=>Gs(e,r=>yB(r)?Ue:t(r.effect_instruction_i0))),Gs=x(2,(e,t)=>xn(r=>dn(r(e),{onFailure:n=>{let o=$t(n);return dn(t(o),{onFailure:i=>$t(Vr(n,i)),onSuccess:()=>o})},onSuccess:n=>{let o=Vt(n);return je(t(o),o)}}))),hc=x(2,(e,t)=>Gs(e,GE({onFailure:r=>OE(r)?$r(t(NE(r))):Ue,onSuccess:()=>Ue}))),LE=x(2,(e,t)=>IEt(e,t,M)),UE=e=>eK(e,be),eK=x(2,(e,t)=>Ho(e,{onFailure:r=>Si(t(r)),onSuccess:M})),zCe=x6,Zw=st((e,t)=>M(t.runtimeFlags)),M=e=>{let t=new IL(_r);return t.effect_instruction_i0=e,t},ye=e=>{let t=new zn(AE);return t.commit=e,t},V=e=>{let t=new zn(nF);return t.effect_instruction_i0=e,t},jo=x(e=>e.length===3||e.length===2&&!(yi(e[1])&&"onlyEffect"in e[1]),(e,t)=>O(e,r=>{let n=typeof t=="function"?t(r):t;return ar(n)?Zt(n,r):MJ(n)?Kw(o=>{n.then(i=>o(M(r)),i=>o(ut(new nI(i,"An unknown error occurred in Effect.tap"))))}):M(r)})),OL=e=>st(t=>{let r=t.getFiberRef(nB),n=C(r,Nt(()=>t.scope()));return e(tn(nB,H(n)))}),IEt=x(3,(e,t,r)=>dn(e,{onFailure:n=>Q_(n).length>0?kt(mF(iSe(n))):t(),onSuccess:r})),Iu=e=>{let t=new zn(xm);return t.effect_instruction_i0=P3(Xl),t.effect_instruction_i1=()=>e,t},xn=e=>oB(e,function(){let t=new zn(xm);return t.effect_instruction_i0=P3(Xl),t.effect_instruction_i1=r=>X_(r)?qn(()=>this.effect_instruction_i0(Qa)):qn(()=>this.effect_instruction_i0(Iu)),t}),Ue=M(void 0),gA=e=>{let t=new zn(xm);return t.effect_instruction_i0=e,t.effect_instruction_i1=void 0,t},AA=x(2,(e,t)=>O(t,r=>r?C(e,te(H)):M(W()))),yA=e=>{let t=new zn(Cw);return t.effect_instruction_i0=e.while,t.effect_instruction_i1=e.body,t.effect_instruction_i2=e.step,t},rB=e=>ye(()=>{let t=new zn(yE);return t.effect_instruction_i0=e(),t}),uB=function(){let e=arguments.length===1?arguments[0]:arguments[1].bind(arguments[0]);return rB(()=>e(C))},Xw=(e,...t)=>Object.defineProperty(t.length===0?function(...r){return rB(()=>e.apply(this,r))}:function(...r){let n=rB(()=>e.apply(this,r));for(let o of t)n=o(n,...r);return n},"length",{value:e.length,configurable:!0}),VCe=x(2,(e,t)=>tn(e,pB,t)),YCe=x(2,(e,t)=>tn(e,eI,t)),NL=x(2,(e,t)=>{let r=new zn(xm);return r.effect_instruction_i0=t,r.effect_instruction_i1=()=>e,r}),JCe=x(2,(e,t)=>tn(e,rI,t)),KCe=x(2,(e,t)=>tn(e,Pm,t)),ku=e=>{let t=new zn(ww);return typeof e?.priority<"u"?iK(t,e.priority):t},Nm=x(2,(e,t)=>O(e,r=>te(t,n=>[r,n]))),$E=x(2,(e,t)=>O(e,r=>Zt(t,r))),je=x(2,(e,t)=>O(e,()=>t)),Zi=x(3,(e,t,r)=>O(e,n=>te(t,o=>r(n,o)))),xA=_f(()=>{let e=setInterval(()=>{},2147483647);return V(()=>clearInterval(e))}),gc=e=>O(td,t=>C(e,xs(t))),xs=x(2,(e,t)=>O(e.interruptAsFork(t),()=>e.await)),ZCe={_tag:"All",syslog:0,label:"ALL",ordinal:Number.MIN_SAFE_INTEGER,pipe(){return Z(this,arguments)}},XCe={_tag:"Fatal",syslog:2,label:"FATAL",ordinal:5e4,pipe(){return Z(this,arguments)}},ewe={_tag:"Error",syslog:3,label:"ERROR",ordinal:4e4,pipe(){return Z(this,arguments)}},tK={_tag:"Warning",syslog:4,label:"WARN",ordinal:3e4,pipe(){return Z(this,arguments)}},rK={_tag:"Info",syslog:6,label:"INFO",ordinal:2e4,pipe(){return Z(this,arguments)}},nK={_tag:"Debug",syslog:7,label:"DEBUG",ordinal:1e4,pipe(){return Z(this,arguments)}},twe={_tag:"Trace",syslog:7,label:"TRACE",ordinal:0,pipe(){return Z(this,arguments)}},rwe={_tag:"None",syslog:7,label:"OFF",ordinal:Number.MAX_SAFE_INTEGER,pipe(){return Z(this,arguments)}},kEt="effect/FiberRef",nwe=Symbol.for(kEt),vEt={_A:e=>e},Xi=e=>st(t=>Vt(t.getFiberRef(e))),ci=x(2,(e,t)=>O(Xi(e),t)),Dm=x(2,(e,t)=>owe(e,()=>[void 0,t])),owe=x(2,(e,t)=>st(r=>{let[n,o]=t(r.getFiberRef(e));return r.setFiberRef(e,o),M(n)})),REt="effect/RequestResolver",iwe=Symbol.for(REt),_Et={_A:e=>e,_R:e=>e},WCe=class e{runAll;target;[iwe]=_Et;constructor(t,r){this.runAll=t,this.target=r}[he](){return We(this,this.target?ae(this.target):Aw(this))}[me](t){return this.target?BEt(t)&&ce(this.target,t.target):this===t}identified(...t){return new e(this.runAll,Co(t))}pipe(){return Z(this,arguments)}},BEt=e=>se(e,iwe),tn=x(3,(e,t,r)=>_L($E(Xi(t),Dm(t,r)),()=>e,n=>Dm(t,n))),no=x(3,(e,t,r)=>ci(t,n=>tn(e,t,r(n)))),pn=(e,t)=>EA(e,{differ:fL(),fork:t?.fork??be,join:t?.join}),oK=e=>{let t=C3();return EA(e,{differ:t,fork:t.empty})},TEt=e=>{let t=w3(fL());return EA(e,{differ:t,fork:t.empty})},lB=e=>{let t=S3();return EA(e,{differ:t,fork:t.empty})},EA=(e,t)=>({...gu,[nwe]:vEt,initial:e,commit(){return Xi(this)},diff:(n,o)=>t.differ.diff(n,o),combine:(n,o)=>t.differ.combine(n,o),patch:n=>o=>t.differ.patch(n,o),fork:t.fork,join:t.join??((n,o)=>o)}),swe=e=>EA(e,{differ:O3,fork:O3.empty}),ui=Te(Symbol.for("effect/FiberRef/currentContext"),()=>lB(ro())),Qf=Te(Symbol.for("effect/FiberRef/currentSchedulingPriority"),()=>pn(0)),dB=Te(Symbol.for("effect/FiberRef/currentMaxOpsBeforeYield"),()=>pn(2048)),Of=Te(Symbol.for("effect/FiberRef/currentLogAnnotation"),()=>pn(If())),PL=Te(Symbol.for("effect/FiberRef/currentLogLevel"),()=>pn(rK)),fB=Te(Symbol.for("effect/FiberRef/currentLogSpan"),()=>pn(Rf())),iK=x(2,(e,t)=>tn(e,Qf,t)),awe=x(2,(e,t)=>tn(e,dB,t)),pB=Te(Symbol.for("effect/FiberRef/currentConcurrency"),()=>pn("unbounded")),eI=Te(Symbol.for("effect/FiberRef/currentRequestBatching"),()=>pn(!0)),tI=Te(Symbol.for("effect/FiberRef/currentUnhandledErrorLogLevel"),()=>pn(H(nK))),mB=Te(Symbol.for("effect/FiberRef/versionMismatchErrorLogLevel"),()=>pn(H(tK))),cwe=x(2,(e,t)=>tn(e,tI,t)),Nf=Te(Symbol.for("effect/FiberRef/currentMetricLabels"),()=>TEt(Us())),uwe=Xi(Nf),nB=Te(Symbol.for("effect/FiberRef/currentForkScopeOverride"),()=>pn(W(),{fork:()=>W(),join:(e,t)=>e})),bA=Te(Symbol.for("effect/FiberRef/currentInterruptedCause"),()=>pn(Yi,{fork:()=>Yi,join:(e,t)=>e})),rI=Te(Symbol.for("effect/FiberRef/currentTracerEnabled"),()=>pn(!0)),Pm=Te(Symbol.for("effect/FiberRef/currentTracerTiming"),()=>pn(!0)),HE=Te(Symbol.for("effect/FiberRef/currentTracerSpanAnnotations"),()=>pn(If())),hB=Te(Symbol.for("effect/FiberRef/currentTracerSpanLinks"),()=>pn(Ut())),ML=Symbol.for("effect/Scope"),FL=Symbol.for("effect/CloseableScope"),gB=(e,t)=>e.addFinalizer(()=>$r(t)),SA=(e,t)=>e.addFinalizer(t),rd=(e,t)=>e.close(t),Ac=(e,t)=>e.fork(t),lwe=e=>dwe(be)(e),dwe=x(2,(e,t)=>{let r=C(e,UF,dr(t));switch(r._tag){case"None":return C(Q_(e),CE,wt({onNone:()=>{let n=_e(NE(e)).flatMap(o=>_e(qw(o)).map(i=>`#${i}`));return new pwe(n?`Interrupted by fibers: ${n.join(", ")}`:void 0)},onSome:be}));case"Some":return r.value}}),AB=function(){class e extends globalThis.Error{commit(){return ut(this)}toJSON(){let r={...this};return this.message&&(r.message=this.message),this.cause&&(r.cause=this.cause),r}[Ce](){return this.toString!==globalThis.Error.prototype.toString?this.stack?`${this.toString()}
41
+ `)}return t},z6=e=>se(e,G6),dSe=e=>se(e,WF),jF=e=>se(e,Lw),$yt=Su(new Map),fSe=()=>$yt,V6=(e,t)=>Su(new Map([[e.key,t]])),pSe=x(3,(e,t,r)=>{let n=new Map(e.unsafeMap);return n.set(t.key,r),Su(n)}),q6=Te("effect/Context/defaultValueCache",()=>new Map),qF=e=>{if(q6.has(e.key))return q6.get(e.key);let t=e.defaultValue();return q6.set(e.key,t),t},mSe=(e,t)=>e.unsafeMap.has(t.key)?e.unsafeMap.get(t.key):qF(t),Y6=x(2,(e,t)=>{if(!e.unsafeMap.has(t.key)){if(Lw in t)return qF(t);throw Uyt(t)}return e.unsafeMap.get(t.key)}),hSe=Y6,gSe=x(3,(e,t,r)=>e.unsafeMap.has(t.key)?e.unsafeMap.get(t.key):jF(t)?qF(t):r()),ASe=x(2,(e,t)=>e.unsafeMap.has(t.key)?Au(e.unsafeMap.get(t.key)):jF(t)?Au(qF(t)):Gg),ySe=x(2,(e,t)=>{let r=new Map(e.unsafeMap);for(let[n,o]of t.unsafeMap)r.set(n,o);return Su(r)}),xSe=(...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].unsafeMap.forEach((n,o)=>{t.set(o,n)});return Su(t)},ESe=(...e)=>t=>{let r=new Set(e.map(o=>o.key)),n=new Map;for(let[o,i]of t.unsafeMap.entries())r.has(o)&&n.set(o,i);return Su(n)},bSe=(...e)=>t=>{let r=new Map(t.unsafeMap);for(let n of e)r.delete(n.key);return Su(r)}});var Kt={};tr(Kt,{GenericTag:()=>Jt,Reference:()=>ai,ReferenceTypeId:()=>Wyt,Tag:()=>Hw,TagTypeId:()=>Hyt,add:()=>zt,empty:()=>ro,get:()=>Dr,getOption:()=>Ji,getOrElse:()=>qyt,isContext:()=>J6,isReference:()=>jyt,isTag:()=>$w,make:()=>Ra,merge:()=>wo,mergeAll:()=>K6,omit:()=>Z6,pick:()=>Gyt,unsafeGet:()=>_a,unsafeMake:()=>iA});var Hyt,Wyt,Jt,iA,J6,$w,jyt,ro,Ra,zt,Dr,qyt,_a,Ji,wo,K6,Gyt,Z6,Hw,ai,sr=h(()=>{F_();Hyt=WF,Wyt=Lw,Jt=cSe,iA=Su,J6=z6,$w=dSe,jyt=jF,ro=fSe,Ra=V6,zt=pSe,Dr=hSe,qyt=gSe,_a=Y6,Ji=ASe,wo=ySe,K6=xSe,Gyt=ESe,Z6=bSe,Hw=uSe,ai=lSe});var Nn={};tr(Nn,{Equivalence:()=>OSe,Order:()=>U_,between:()=>nxt,clamp:()=>uxt,days:()=>BSe,decode:()=>At,decodeUnknown:()=>Vyt,divide:()=>lxt,equals:()=>NSe,format:()=>YF,formatIso:()=>mxt,fromIso:()=>hxt,greaterThan:()=>pxt,greaterThanOrEqualTo:()=>$_,hours:()=>_Se,infinity:()=>o3,isDuration:()=>n3,isFinite:()=>L_,isZero:()=>kSe,lessThan:()=>i3,lessThanOrEqualTo:()=>s3,match:()=>Sf,matchWith:()=>vm,max:()=>axt,micros:()=>vSe,millis:()=>Ki,min:()=>ixt,minutes:()=>RSe,nanos:()=>Ww,parts:()=>a3,seconds:()=>sA,subtract:()=>fxt,sum:()=>VF,times:()=>zF,toDays:()=>ext,toHours:()=>Xyt,toHrTime:()=>QSe,toMillis:()=>Io,toMinutes:()=>Zyt,toNanos:()=>rxt,toSeconds:()=>Kyt,toWeeks:()=>txt,unsafeDivide:()=>dxt,unsafeFormatIso:()=>PSe,unsafeToNanos:()=>DSe,weeks:()=>TSe,zero:()=>As});var X6,ISe,CSe,GF,e3,t3,r3,zyt,At,Vyt,wSe,Yyt,Jyt,$o,n3,L_,kSe,As,o3,Ww,vSe,Ki,sA,RSe,_Se,BSe,TSe,Io,Kyt,Zyt,Xyt,ext,txt,rxt,DSe,QSe,Sf,vm,U_,nxt,OSe,oxt,ixt,sxt,axt,cxt,uxt,lxt,dxt,zF,fxt,VF,i3,s3,pxt,$_,NSe,a3,YF,PSe,mxt,hxt,gxt,Ws=h(()=>{mt();oe();ir();ht();it();bm();Me();ct();X6=Symbol.for("effect/Duration"),ISe=BigInt(0),CSe=BigInt(24),GF=BigInt(60),e3=BigInt(1e3),t3=BigInt(1e6),r3=BigInt(1e9),zyt=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,At=e=>{if(n3(e))return e;if(Ls(e))return Ki(e);if($g(e))return Ww(e);if(Array.isArray(e)&&e.length===2&&e.every(Ls))return e[0]===-1/0||e[1]===-1/0||Number.isNaN(e[0])||Number.isNaN(e[1])?As:e[0]===1/0||e[1]===1/0?o3:Ww(BigInt(Math.round(e[0]*1e9))+BigInt(Math.round(e[1])));if(Fo(e)){let t=zyt.exec(e);if(t){let[r,n,o]=t,i=Number(n);switch(o){case"nano":case"nanos":return Ww(BigInt(n));case"micro":case"micros":return vSe(BigInt(n));case"milli":case"millis":return Ki(i);case"second":case"seconds":return sA(i);case"minute":case"minutes":return RSe(i);case"hour":case"hours":return _Se(i);case"day":case"days":return BSe(i);case"week":case"weeks":return TSe(i)}}}throw new Error("Invalid DurationInput")},Vyt=EE(At),wSe={_tag:"Millis",millis:0},Yyt={_tag:"Infinity"},Jyt={[X6]:X6,[he](){return We(this,eF(this.value))},[me](e){return n3(e)&&NSe(this,e)},toString(){return`Duration(${YF(this)})`},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",hrtime:QSe(this)};case"Infinity":return{_id:"Duration",_tag:"Infinity"}}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},$o=e=>{let t=Object.create(Jyt);return Ls(e)?isNaN(e)||e<=0?t.value=wSe:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:BigInt(Math.round(e*1e6))}:t.value=Yyt:e<=ISe?t.value=wSe:t.value={_tag:"Nanos",nanos:e},t},n3=e=>se(e,X6),L_=e=>e.value._tag!=="Infinity",kSe=e=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===ISe;case"Infinity":return!1}},As=$o(0),o3=$o(1/0),Ww=e=>$o(e),vSe=e=>$o(e*e3),Ki=e=>$o(e),sA=e=>$o(e*1e3),RSe=e=>$o(e*6e4),_Se=e=>$o(e*36e5),BSe=e=>$o(e*864e5),TSe=e=>$o(e*6048e5),Io=e=>Sf(e,{onMillis:t=>t,onNanos:t=>Number(t)/1e6}),Kyt=e=>Sf(e,{onMillis:t=>t/1e3,onNanos:t=>Number(t)/1e9}),Zyt=e=>Sf(e,{onMillis:t=>t/6e4,onNanos:t=>Number(t)/6e10}),Xyt=e=>Sf(e,{onMillis:t=>t/36e5,onNanos:t=>Number(t)/36e11}),ext=e=>Sf(e,{onMillis:t=>t/864e5,onNanos:t=>Number(t)/864e11}),txt=e=>Sf(e,{onMillis:t=>t/6048e5,onNanos:t=>Number(t)/6048e11}),rxt=e=>{let t=At(e);switch(t.value._tag){case"Infinity":return W();case"Nanos":return H(t.value.nanos);case"Millis":return H(BigInt(Math.round(t.value.millis*1e6)))}},DSe=e=>{let t=At(e);switch(t.value._tag){case"Infinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return BigInt(Math.round(t.value.millis*1e6))}},QSe=e=>{let t=At(e);switch(t.value._tag){case"Infinity":return[1/0,0];case"Nanos":return[Number(t.value.nanos/r3),Number(t.value.nanos%r3)];case"Millis":return[Math.floor(t.value.millis/1e3),Math.round(t.value.millis%1e3*1e6)]}},Sf=x(2,(e,t)=>{let r=At(e);switch(r.value._tag){case"Nanos":return t.onNanos(r.value.nanos);case"Infinity":return t.onMillis(1/0);case"Millis":return t.onMillis(r.value.millis)}}),vm=x(3,(e,t,r)=>{let n=At(e),o=At(t);if(n.value._tag==="Infinity"||o.value._tag==="Infinity")return r.onMillis(Io(n),Io(o));if(n.value._tag==="Nanos"||o.value._tag==="Nanos"){let i=n.value._tag==="Nanos"?n.value.nanos:BigInt(Math.round(n.value.millis*1e6)),s=o.value._tag==="Nanos"?o.value.nanos:BigInt(Math.round(o.value.millis*1e6));return r.onNanos(i,s)}return r.onMillis(n.value.millis,o.value.millis)}),U_=xE((e,t)=>vm(e,t,{onMillis:(r,n)=>r<n?-1:r>n?1:0,onNanos:(r,n)=>r<n?-1:r>n?1:0})),nxt=e6(yf(U_,At)),OSe=(e,t)=>vm(e,t,{onMillis:(r,n)=>r===n,onNanos:(r,n)=>r===n}),oxt=fF(U_),ixt=x(2,(e,t)=>oxt(At(e),At(t))),sxt=pF(U_),axt=x(2,(e,t)=>sxt(At(e),At(t))),cxt=XJ(U_),uxt=x(2,(e,t)=>cxt(At(e),{minimum:At(t.minimum),maximum:At(t.maximum)})),lxt=x(2,(e,t)=>Sf(e,{onMillis:r=>t===0||isNaN(t)||!Number.isFinite(t)?W():H($o(r/t)),onNanos:r=>{if(isNaN(t)||t<=0||!Number.isFinite(t))return W();try{return H($o(r/BigInt(t)))}catch{return W()}}})),dxt=x(2,(e,t)=>Sf(e,{onMillis:r=>$o(r/t),onNanos:r=>isNaN(t)||t<0||Object.is(t,-0)?As:Object.is(t,0)||!Number.isFinite(t)?o3:$o(r/BigInt(t))})),zF=x(2,(e,t)=>Sf(e,{onMillis:r=>$o(r*t),onNanos:r=>$o(r*BigInt(t))})),fxt=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>$o(r-n),onNanos:(r,n)=>$o(r-n)})),VF=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>$o(r+n),onNanos:(r,n)=>$o(r+n)})),i3=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>r<n,onNanos:(r,n)=>r<n})),s3=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>r<=n,onNanos:(r,n)=>r<=n})),pxt=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>r>n,onNanos:(r,n)=>r>n})),$_=x(2,(e,t)=>vm(e,t,{onMillis:(r,n)=>r>=n,onNanos:(r,n)=>r>=n})),NSe=x(2,(e,t)=>OSe(At(e),At(t))),a3=e=>{let t=At(e);if(t.value._tag==="Infinity")return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};let r=DSe(t),n=r/t3,o=n/e3,i=o/GF,s=i/GF,a=s/CSe;return{days:Number(a),hours:Number(s%CSe),minutes:Number(i%GF),seconds:Number(o%GF),millis:Number(n%e3),nanos:Number(r%t3)}},YF=e=>{let t=At(e);if(t.value._tag==="Infinity")return"Infinity";if(kSe(t))return"0";let r=a3(t),n=[];return r.days!==0&&n.push(`${r.days}d`),r.hours!==0&&n.push(`${r.hours}h`),r.minutes!==0&&n.push(`${r.minutes}m`),r.seconds!==0&&n.push(`${r.seconds}s`),r.millis!==0&&n.push(`${r.millis}ms`),r.nanos!==0&&n.push(`${r.nanos}ns`),n.join(" ")},PSe=e=>{let t=At(e);if(!L_(t))throw new RangeError("Cannot format infinite duration");let r=[],{days:n,hours:o,millis:i,minutes:s,nanos:a,seconds:c}=a3(t),u=n;if(u>=365){let l=Math.floor(u/365);u%=365,r.push(`${l}Y`)}if(u>=30){let l=Math.floor(u/30);u%=30,r.push(`${l}M`)}if(u>=7){let l=Math.floor(u/7);u%=7,r.push(`${l}W`)}if(u>0&&r.push(`${u}D`),(o!==0||s!==0||c!==0||i!==0||a!==0)&&(r.push("T"),o!==0&&r.push(`${o}H`),s!==0&&r.push(`${s}M`),c!==0||i!==0||a!==0)){let l=BigInt(c)*r3+BigInt(i)*t3+BigInt(a),d=(Number(l)/1e9).toFixed(9).replace(/\.?0+$/,"");r.push(`${d}S`)}return`P${r.join("")||"T0S"}`},mxt=e=>{let t=At(e);return L_(t)?H(PSe(t)):W()},hxt=e=>{let t=gxt.exec(e);if(t==null)return W();let[r,n,o,i,s,a,c]=t.slice(1,8).map(l=>l?Number(l):0),u=r*365*24*60*60+n*30*24*60*60+o*7*24*60*60+i*24*60*60+s*60*60+a*60+c;return H(sA(u))},gxt=/^P(?!$)(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?!$)(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/});var MSe,Axt,Ba,JF,Qr,js,Kl=h(()=>{mt();oe();ht();Me();MSe=Symbol.for("effect/MutableRef"),Axt={[MSe]:MSe,toString(){return Fe(this.toJSON())},toJSON(){return{_id:"MutableRef",current:xt(this.current)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},Ba=e=>{let t=Object.create(Axt);return t.current=e,t},JF=x(3,(e,t,r)=>ce(t,e.current)?(e.current=r,!0):!1),Qr=e=>e.current,js=x(2,(e,t)=>(e.current=t,e))});var tL,aA,cA,KF,ZF,yxt,c3,H_,XF,j_,LSe,USe,rL,u3,l3,$Se,HSe,W_,FSe,WSe,nL,eL,jSe,oL=h(()=>{mt();oe();yn();ir();dc();ht();Kl();ct();tL="effect/FiberId",aA=Symbol.for(tL),cA="None",KF="Runtime",ZF="Composite",yxt=Lt(`${tL}-${cA}`),c3=class{[aA]=aA;_tag=cA;id=-1;startTimeMillis=-1;[he](){return yxt}[me](t){return rL(t)&&t._tag===cA}toString(){return Fe(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag}}[Ce](){return this.toJSON()}},H_=class{id;startTimeMillis;[aA]=aA;_tag=KF;constructor(t,r){this.id=t,this.startTimeMillis=r}[he](){return We(this,Lt(`${tL}-${this._tag}-${this.id}-${this.startTimeMillis}`))}[me](t){return rL(t)&&t._tag===KF&&this.id===t.id&&this.startTimeMillis===t.startTimeMillis}toString(){return Fe(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag,id:this.id,startTimeMillis:this.startTimeMillis}}[Ce](){return this.toJSON()}},XF=class{left;right;[aA]=aA;_tag=ZF;constructor(t,r){this.left=t,this.right=r}_hash;[he](){return C(Lt(`${tL}-${this._tag}`),we(ae(this.left)),we(ae(this.right)),We(this))}[me](t){return rL(t)&&t._tag===ZF&&ce(this.left,t.left)&&ce(this.right,t.right)}toString(){return Fe(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag,left:xt(this.left),right:xt(this.right)}}[Ce](){return this.toJSON()}},j_=new c3,LSe=(e,t)=>new H_(e,t),USe=(e,t)=>new XF(e,t),rL=e=>se(e,aA),u3=e=>e._tag===cA||C(eL(e),Kbe(t=>u3(t))),l3=x(2,(e,t)=>e._tag===cA?t:t._tag===cA?e:new XF(e,t)),$Se=e=>C(e,tA(j_,(t,r)=>l3(r)(t))),HSe=x(2,(e,t)=>u3(e)?t:e),W_=e=>{switch(e._tag){case cA:return ql();case KF:return eA(e.id);case ZF:return C(W_(e.left),Ef(W_(e.right)))}},FSe=Te(Symbol.for("effect/Fiber/Id/_fiberCounter"),()=>Ba(0)),WSe=(e,t)=>new H_(e,t),nL=e=>Array.from(W_(e)).map(r=>`#${r}`).join(","),eL=e=>{switch(e._tag){case cA:return ql();case KF:return eA(e);case ZF:return C(eL(e.left),Ef(eL(e.right)))}},jSe=()=>{let e=Qr(FSe);return C(FSe,js(e+1)),new H_(e,Date.now())}});var ci,GSe,zSe,jw,VSe,iL,qw,YSe,JSe,sL,Zl=h(()=>{oL();ci=j_,GSe=LSe,zSe=USe,jw=l3,VSe=$Se,iL=HSe,qw=W_,YSe=WSe,JSe=nL,sL=jSe});var If,KSe,ZSe,aL,d3,f3,ko,p3,XSe,eCe,tCe,rCe,m3,kf=h(()=>{Q6();If=Ow,KSe=_be,ZSe=Tbe,aL=Dbe,d3=Qbe,f3=RF,ko=IE,p3=_F,XSe=Obe,eCe=BF,tCe=Pbe,rCe=DF,m3=Nw});var q_,h3,xxt,Ext,bxt,cL,Sxt,Cxt,nCe,oCe,vf,g3,wxt,_m,Rf,G_,iCe,uL,Ixt,sCe,aCe,Gw=h(()=>{wr();mt();mm();oe();ir();ht();Me();ct();q_=Symbol.for("effect/List"),h3=e=>_e(e),xxt=e=>OJ(Jg(e),h3),Ext=xxt(ce),bxt={[q_]:q_,_tag:"Cons",toString(){return Fe(this.toJSON())},toJSON(){return{_id:"List",_tag:"Cons",values:h3(this).map(xt)}},[Ce](){return this.toJSON()},[me](e){return oCe(e)&&this._tag===e._tag&&Ext(this,e)},[he](){return We(this,So(h3(this)))},[Symbol.iterator](){let e=!1,t=this;return{next(){if(e)return this.return();if(t._tag==="Nil")return e=!0,this.return();let r=t.head;return t=t.tail,{done:e,value:r}},return(r){return e||(e=!0),{done:!0,value:r}}}},pipe(){return Z(this,arguments)}},cL=(e,t)=>{let r=Object.create(bxt);return r.head=e,r.tail=t,r},Sxt=Lt("Nil"),Cxt={[q_]:q_,_tag:"Nil",toString(){return Fe(this.toJSON())},toJSON(){return{_id:"List",_tag:"Nil"}},[Ce](){return this.toJSON()},[he](){return Sxt},[me](e){return oCe(e)&&this._tag===e._tag},[Symbol.iterator](){return{next(){return{done:!0,value:void 0}}}},pipe(){return Z(this,arguments)}},nCe=Object.create(Cxt),oCe=e=>se(e,q_),vf=e=>e._tag==="Nil",g3=e=>e._tag==="Cons",wxt=()=>nCe,_m=(e,t)=>cL(e,t),Rf=wxt,G_=e=>cL(e,nCe),iCe=x(2,(e,t)=>Ixt(t,e)),uL=x(2,(e,t)=>_m(t,e)),Ixt=x(2,(e,t)=>{if(vf(e))return t;if(vf(t))return e;{let r=cL(t.head,e),n=r,o=t.tail;for(;!vf(o);){let i=cL(o.head,e);n.tail=i,n=i,o=o.tail}return r}}),sCe=x(3,(e,t,r)=>{let n=t,o=e;for(;!vf(o);)n=r(n,o.head),o=o.tail;return n}),aCe=e=>{let t=Rf(),r=e;for(;!vf(r);)t=uL(t,r.head),r=r.tail;return t}});var cCe,Bm,zw,Vw=h(()=>{mt();ir();Af();cCe=Object.assign(Object.create(Array.prototype),{[he](){return We(this,So(this))},[me](e){return Array.isArray(e)&&this.length===e.length?this.every((t,r)=>ce(t,e[r])):!1}}),Bm=function(){function e(t){t&&Object.assign(this,t)}return e.prototype=gf,e}(),zw=e=>Object.assign(Object.create(gf),e)});function uCe(e){return e}var kxt,Y_,vxt,Rxt,y3,_xt,Bxt,Txt,Dxt,Qxt,Oxt,Nxt,Pxt,lCe,V_,dCe,fCe=h(()=>{vr();mt();oe();F_();Vw();kxt=Symbol.for("effect/DifferContextPatch");Y_={...Bm.prototype,[kxt]:{_Value:uCe,_Patch:uCe}},vxt=Object.assign(Object.create(Y_),{_tag:"Empty"}),Rxt=Object.create(vxt),y3=()=>Rxt,_xt=Object.assign(Object.create(Y_),{_tag:"AndThen"}),Bxt=(e,t)=>{let r=Object.create(_xt);return r.first=e,r.second=t,r},Txt=Object.assign(Object.create(Y_),{_tag:"AddService"}),Dxt=(e,t)=>{let r=Object.create(Txt);return r.key=e,r.service=t,r},Qxt=Object.assign(Object.create(Y_),{_tag:"RemoveService"}),Oxt=e=>{let t=Object.create(Qxt);return t.key=e,t},Nxt=Object.assign(Object.create(Y_),{_tag:"UpdateService"}),Pxt=(e,t)=>{let r=Object.create(Nxt);return r.key=e,r.update=t,r},lCe=(e,t)=>{let r=new Map(e.unsafeMap),n=y3();for(let[o,i]of t.unsafeMap.entries())if(r.has(o)){let s=r.get(o);r.delete(o),ce(s,i)||(n=V_(Pxt(o,()=>i))(n))}else r.delete(o),n=V_(Dxt(o,i))(n);for(let[o]of r.entries())n=V_(Oxt(o))(n);return n},V_=x(2,(e,t)=>Bxt(e,t)),dCe=x(2,(e,t)=>{if(e._tag==="Empty")return t;let r=!1,n=Dt(e),o=new Map(t.unsafeMap);for(;kr(n);){let s=Gt(n),a=Ur(n);switch(s._tag){case"Empty":{n=a;break}case"AddService":{o.set(s.key,s.service),n=a;break}case"AndThen":{n=fr(fr(a,s.second),s.first);break}case"RemoveService":{o.delete(s.key),n=a;break}case"UpdateService":{o.set(s.key,s.update(o.get(s.key))),r=!0,n=a;break}}}if(!r)return Su(o);let i=new Map;for(let[s]of t.unsafeMap)o.has(s)&&(i.set(s,o.get(s)),o.delete(s));for(let[s,a]of o)i.set(s,a);return Su(i)})});function x3(e){return e}var Fxt,dL,Lxt,Uxt,E3,$xt,Hxt,Wxt,jxt,qxt,Gxt,pCe,lL,mCe,hCe=h(()=>{vr();oe();dc();Vw();Fxt=Symbol.for("effect/DifferHashSetPatch");dL={...Bm.prototype,[Fxt]:{_Value:x3,_Key:x3,_Patch:x3}},Lxt=Object.assign(Object.create(dL),{_tag:"Empty"}),Uxt=Object.create(Lxt),E3=()=>Uxt,$xt=Object.assign(Object.create(dL),{_tag:"AndThen"}),Hxt=(e,t)=>{let r=Object.create($xt);return r.first=e,r.second=t,r},Wxt=Object.assign(Object.create(dL),{_tag:"Add"}),jxt=e=>{let t=Object.create(Wxt);return t.value=e,t},qxt=Object.assign(Object.create(dL),{_tag:"Remove"}),Gxt=e=>{let t=Object.create(qxt);return t.value=e,t},pCe=(e,t)=>{let[r,n]=tA([e,E3()],([o,i],s)=>FF(s)(o)?[P6(s)(o),i]:[o,lL(jxt(s))(i)])(t);return tA(n,(o,i)=>lL(Gxt(i))(o))(r)},lL=x(2,(e,t)=>Hxt(e,t)),mCe=x(2,(e,t)=>{if(e._tag==="Empty")return t;let r=t,n=Dt(e);for(;kr(n);){let o=Gt(n),i=Ur(n);switch(o._tag){case"Empty":{n=i;break}case"AndThen":{n=fr(o.first)(fr(o.second)(i));break}case"Add":{r=kE(o.value)(r),n=i;break}case"Remove":r=P6(o.value)(r),n=i}}return r})});function gCe(e){return e}var Vxt,K_,Yxt,Jxt,b3,Kxt,Zxt,Xxt,eEt,tEt,rEt,nEt,oEt,ACe,J_,yCe,xCe=h(()=>{wr();mt();oe();Vw();Vxt=Symbol.for("effect/DifferReadonlyArrayPatch");K_={...Bm.prototype,[Vxt]:{_Value:gCe,_Patch:gCe}},Yxt=Object.assign(Object.create(K_),{_tag:"Empty"}),Jxt=Object.create(Yxt),b3=()=>Jxt,Kxt=Object.assign(Object.create(K_),{_tag:"AndThen"}),Zxt=(e,t)=>{let r=Object.create(Kxt);return r.first=e,r.second=t,r},Xxt=Object.assign(Object.create(K_),{_tag:"Append"}),eEt=e=>{let t=Object.create(Xxt);return t.values=e,t},tEt=Object.assign(Object.create(K_),{_tag:"Slice"}),rEt=(e,t)=>{let r=Object.create(tEt);return r.from=e,r.until=t,r},nEt=Object.assign(Object.create(K_),{_tag:"Update"}),oEt=(e,t)=>{let r=Object.create(nEt);return r.index=e,r.patch=t,r},ACe=e=>{let t=0,r=b3();for(;t<e.oldValue.length&&t<e.newValue.length;){let n=e.oldValue[t],o=e.newValue[t],i=e.differ.diff(n,o);ce(i,e.differ.empty)||(r=J_(r,oEt(t,i))),t=t+1}return t<e.oldValue.length&&(r=J_(r,rEt(0,t))),t<e.newValue.length&&(r=J_(r,eEt(abe(t)(e.newValue)))),r},J_=x(2,(e,t)=>Zxt(e,t)),yCe=x(3,(e,t,r)=>{if(e._tag==="Empty")return t;let n=t.slice(),o=hs(e);for(;Cm(o);){let i=Lo(o),s=Ll(o);switch(i._tag){case"Empty":{o=s;break}case"AndThen":{s.unshift(i.first,i.second),o=s;break}case"Append":{for(let a of i.values)n.push(a);o=s;break}case"Slice":{n=n.slice(i.from,i.until),o=s;break}case"Update":{n[i.index]=r.patch(i.patch,n[i.index]),o=s;break}}}return n})});var ECe,sEt,uA,S3,C3,w3,fL,bCe,pL=h(()=>{mt();oe();Me();fCe();hCe();xCe();ECe=Symbol.for("effect/Differ"),sEt={[ECe]:{_P:be,_V:be},pipe(){return Z(this,arguments)}},uA=e=>{let t=Object.create(sEt);return t.empty=e.empty,t.diff=e.diff,t.combine=e.combine,t.patch=e.patch,t},S3=()=>uA({empty:y3(),combine:(e,t)=>V_(t)(e),diff:(e,t)=>lCe(e,t),patch:(e,t)=>dCe(t)(e)}),C3=()=>uA({empty:E3(),combine:(e,t)=>lL(t)(e),diff:(e,t)=>pCe(e,t),patch:(e,t)=>mCe(t)(e)}),w3=e=>uA({empty:b3(),combine:(t,r)=>J_(t,r),diff:(t,r)=>ACe({oldValue:t,newValue:r,differ:e}),patch:(t,r)=>yCe(t,r,e)}),fL=()=>bCe((e,t)=>t),bCe=e=>uA({empty:be,combine:(t,r)=>t===be?r:r===be?t:n=>r(t(n)),diff:(t,r)=>ce(t,r)?be:fm(r),patch:(t,r)=>e(r,t(r))})});var Z_,SCe,mL,hL,ME,gL,CCe,wCe,ICe,k3,kCe,v3=h(()=>{oe();Z_=255,SCe=8,mL=e=>e&Z_,hL=e=>e>>SCe&Z_,ME=(e,t)=>(e&Z_)+((t&e&Z_)<<SCe),gL=ME(0,0),CCe=e=>ME(e,e),wCe=e=>ME(e,0),ICe=x(2,(e,t)=>ME(mL(e)&~t,hL(e))),k3=x(2,(e,t)=>e|t),kCe=e=>~e>>>0&Z_});var aEt,Xl,RCe,R3,AL,_3,_Ce,B3,T3,ed,X_,yL,D3,BCe,Q3,cEt,Cu,Tm,O3,lA=h(()=>{oe();pL();v3();aEt=0,Xl=1,RCe=2,R3=4,AL=16,_3=32,_Ce=e=>yL(e,_3),B3=x(2,(e,t)=>e&~t),T3=x(2,(e,t)=>e|t),ed=e=>X_(e)&&!cEt(e),X_=e=>yL(e,Xl),yL=x(2,(e,t)=>(e&t)!==0),D3=(...e)=>e.reduce((t,r)=>t|r,0),BCe=D3(aEt),Q3=e=>yL(e,R3),cEt=e=>yL(e,AL),Cu=x(2,(e,t)=>ME(e^t,t)),Tm=x(2,(e,t)=>e&(kCe(mL(t))|hL(t))|mL(t)&hL(t)),O3=uA({empty:gL,diff:(e,t)=>Cu(e,t),combine:(e,t)=>k3(t)(e),patch:(e,t)=>Tm(t,e)})});var TCe,N3,P3,M3,xL=h(()=>{v3();TCe=gL,N3=CCe,P3=wCe,M3=ICe});var DCe,$3,EL,H3,QCe,uEt,lEt,dEt,U3,fEt,W3,pEt,mEt,eB,OCe,hEt,gEt,AEt,yEt,L3,xEt,EEt,bL,bEt,SEt,CEt,NCe,j3=h(()=>{vr();mt();kf();Gw();it();DCe={_tag:"Empty"},$3=(e,t)=>({_tag:"Par",left:e,right:t}),EL=(e,t)=>({_tag:"Seq",left:e,right:t}),H3=(e,t)=>({_tag:"Single",dataSource:e,blockedRequest:t}),QCe=e=>{let t=G_(e),r=Rf();for(;;){let[n,o]=sCe(t,[OCe(),Rf()],([i,s],a)=>{let[c,u]=uEt(a);return[gEt(i,c),iCe(s,u)]});if(r=lEt(r,n),vf(o))return aCe(r);t=o}throw new Error("BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues")},uEt=e=>{let t=e,r=OCe(),n=Rf(),o=Rf();for(;;)switch(t._tag){case"Empty":{if(vf(n))return[r,o];t=n.head,n=n.tail;break}case"Par":{n=_m(t.right,n),t=t.left;break}case"Seq":{let i=t.left,s=t.right;switch(i._tag){case"Empty":{t=s;break}case"Par":{let a=i.left,c=i.right;t=$3(EL(a,s),EL(c,s));break}case"Seq":{let a=i.left,c=i.right;t=EL(a,EL(c,s));break}case"Single":{t=i,o=_m(s,o);break}}break}case"Single":{if(r=hEt(r,t),vf(n))return[r,o];t=n.head,n=n.tail;break}}throw new Error("BUG: BlockedRequests.step - please report an issue at https://github.com/Effect-TS/effect/issues")},lEt=(e,t)=>{if(vf(e))return G_(L3(t));if(AEt(t))return e;let r=CEt(e.head),n=yEt(t);return r.length===1&&n.length===1&&ce(r[0],n[0])?_m(SEt(e.head,L3(t)),e.tail):_m(L3(t),e)},dEt=Symbol.for("effect/RequestBlock/Entry"),U3=class{request;result;listeners;ownerId;state;[dEt]=fEt;constructor(t,r,n,o,i){this.request=t,this.result=r,this.listeners=n,this.ownerId=o,this.state=i}},fEt={_R:e=>e},W3=e=>new U3(e.request,e.result,e.listeners,e.ownerId,e.state),pEt=Symbol.for("effect/RequestBlock/RequestBlockParallel"),mEt={_R:e=>e},eB=class{map;[pEt]=mEt;constructor(t){this.map=t}},OCe=()=>new eB(If()),hEt=(e,t)=>new eB(eCe(e.map,t.dataSource,r=>n6(dr(r,$s(t.blockedRequest)),()=>Dt(t.blockedRequest)))),gEt=(e,t)=>new eB(m3(e.map,t.map,(r,n,o)=>ko(r,o,wt(aL(r,o),{onNone:()=>n,onSome:i=>Ir(n,i)})))),AEt=e=>ZSe(e.map),yEt=e=>Array.from(p3(e.map)),L3=e=>bEt(tCe(e.map,t=>Dt(t))),xEt=Symbol.for("effect/RequestBlock/RequestBlockSequential"),EEt={_R:e=>e},bL=class{map;[xEt]=EEt;constructor(t){this.map=t}},bEt=e=>new bL(e),SEt=(e,t)=>new bL(m3(t.map,e.map,(r,n,o)=>ko(r,o,wt(aL(r,o),{onNone:()=>Ut(),onSome:i=>Ir(i,n)})))),CEt=e=>Array.from(p3(e.map)),NCe=e=>Array.from(e.map)});var dA,FE,q3=h(()=>{dA="Pending",FE="Done"});var wEt,SL,FCe,LCe,G3,z3=h(()=>{q3();wEt="effect/Deferred",SL=Symbol.for(wEt),FCe={_E:e=>e,_A:e=>e},LCe=e=>({_tag:dA,joiners:e}),G3=e=>({_tag:FE,effect:e})});var Jw,$Ce=h(()=>{Jw=class e{self;called=!1;constructor(t){this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(t){return{value:t,done:!0}}throw(t){throw t}[Symbol.iterator](){return new e(this.self)}}});var Qm,RL,Om,CL,zn,wL,IL,ar,st,_L,Zt,$r,oB,Kw,_f,Si,Bf,fc,iB,jCe,qCe,HCe,BL,Ci,fA,Ta,wu,fn,ut,pc,kt,Tf,td,Da,O,pA,TL,ys,mA,sB,dn,Ho,Wo,mc,DL,qs,aB,Qa,GCe,Df,te,cB,hA,QL,Gs,hc,LE,UE,eK,zCe,Zw,M,ye,V,jo,OL,IEt,Iu,xn,Ue,gA,AA,yA,rB,uB,Xw,VCe,YCe,NL,JCe,KCe,ku,Nm,$E,je,Zi,xA,gc,xs,ZCe,XCe,ewe,tK,rK,nK,twe,rwe,kEt,nwe,vEt,Xi,ui,Dm,owe,REt,iwe,_Et,WCe,BEt,tn,no,pn,oK,TEt,lB,EA,swe,li,Qf,dB,Of,PL,fB,iK,awe,pB,eI,tI,mB,cwe,Nf,uwe,nB,bA,rI,Pm,HE,hB,ML,FL,gB,SA,rd,Ac,lwe,dwe,AB,WE,V3,fwe,kL,pwe,sK,Y3,vu,vL,Es,aK,J3,DIr,K3,DEt,Z3,mwe,hwe,X3,nI,jE,LL,yB,gwe,qE,oI,Awe,CA,UL,ywe,nd,$t,cK,xwe,Ewe,bwe,Swe,Cwe,wwe,xB,tB,Iwe,kwe,vwe,GE,zE,Vt,Pn,Rwe,_we,$L,Bwe,Twe,Dwe,Ru,QEt,wA,wi,uK,Cn,HL,yc,lK,Qwe,Owe,iI,Nwe,Pwe,Mwe,Fwe,EB,Lwe,Uwe,Mm,$we,IA,OEt,NEt,Oa,xc,zs,WL,kA,dK,Hwe,jL,PEt,Wwe,vt=h(()=>{wr();vr();sr();Ws();bi();mt();Zl();oe();yn();ir();kf();ht();Gw();Kl();it();Me();ct();xL();mu();Jl();z3();pL();Af();gw();q3();Iw();lA();$Ce();Qm=(e,t)=>{let r=new zn("Blocked");return r.effect_instruction_i0=e,r.effect_instruction_i1=t,r},RL=e=>{let t=new zn("RunBlocked");return t.effect_instruction_i0=e,t},Om=Symbol.for("effect/Effect"),CL=class{patch;op;_op=f_;constructor(t,r){this.patch=t,this.op=r}},zn=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[Om]=jg;constructor(t){this._op=t}[me](t){return this===t}[he](){return We(this,Aw(this))}pipe(){return Z(this,arguments)}toJSON(){return{_id:"Effect",_op:this._op,effect_instruction_i0:xt(this.effect_instruction_i0),effect_instruction_i1:xt(this.effect_instruction_i1),effect_instruction_i2:xt(this.effect_instruction_i2)}}toString(){return Fe(this.toJSON())}[Ce](){return this.toJSON()}[Symbol.iterator](){return new Jw(new hf(this))}},wL=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[Om]=jg;constructor(t){this._op=t,this._tag=t}[me](t){return jE(t)&&t._op==="Failure"&&ce(this.effect_instruction_i0,t.effect_instruction_i0)}[he](){return C(Lt(this._tag),we(ae(this.effect_instruction_i0)),We(this))}get cause(){return this.effect_instruction_i0}pipe(){return Z(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,cause:this.cause.toJSON()}}toString(){return Fe(this.toJSON())}[Ce](){return this.toJSON()}[Symbol.iterator](){return new Jw(new hf(this))}},IL=class{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[Om]=jg;constructor(t){this._op=t,this._tag=t}[me](t){return jE(t)&&t._op==="Success"&&ce(this.effect_instruction_i0,t.effect_instruction_i0)}[he](){return C(Lt(this._tag),we(ae(this.effect_instruction_i0)),We(this))}get value(){return this.effect_instruction_i0}pipe(){return Z(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,value:xt(this.value)}}toString(){return Fe(this.toJSON())}[Ce](){return this.toJSON()}[Symbol.iterator](){return new Jw(new hf(this))}},ar=e=>se(e,Om),st=e=>{let t=new zn(oF);return t.effect_instruction_i0=e,t},_L=x(3,(e,t,r)=>xn(n=>O(e,o=>O(fn(ye(()=>n(t(o)))),i=>ye(()=>r(o,i)).pipe(dn({onFailure:s=>{switch(i._tag){case Rr:return kt(Vr(i.effect_instruction_i0,s));case _r:return kt(s)}},onSuccess:()=>i})))))),Zt=x(2,(e,t)=>O(e,()=>M(t))),$r=e=>Zt(e,void 0),oB=function(){let e=new zn(AE);switch(arguments.length){case 2:{e.effect_instruction_i0=arguments[0],e.commit=arguments[1];break}case 3:{e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.commit=arguments[2];break}case 4:{e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.effect_instruction_i2=arguments[2],e.commit=arguments[3];break}default:throw new Error(Fl("you're not supposed to end up here"))}return e},Kw=(e,t=ci)=>{let r=new zn(gE),n;return r.effect_instruction_i0=o=>{n=e(o)},r.effect_instruction_i1=t,hc(r,o=>ar(n)?n:Ue)},_f=(e,t=ci)=>ye(()=>Kw(e,t)),Si=(e,t=ci)=>oB(e,function(){let r,n;function o(c){r?r(c):n===void 0&&(n=c)}let i=new zn(gE);i.effect_instruction_i0=c=>{r=c,n&&c(n)},i.effect_instruction_i1=t;let s,a;return this.effect_instruction_i0.length!==1?(a=new AbortController,s=qn(()=>this.effect_instruction_i0(o,a.signal))):s=qn(()=>this.effect_instruction_i0(o)),s||a?hc(i,c=>(a&&a.abort(),s??Ue)):i}),Bf=x(2,(e,t)=>{let r=new zn(Ew);return r.effect_instruction_i0=e,r.effect_instruction_i1=t,r}),fc=x(2,(e,t)=>Ho(e,{onFailure:t,onSuccess:M})),iB=x(3,(e,t,r)=>Bf(e,n=>{let o=Vl(n);switch(o._tag){case"Left":return t(o.left)?r(o.left):kt(n);case"Right":return kt(o.right)}})),jCe=x(2,(e,t)=>Bf(e,r=>{let n=Vl(r);switch(n._tag){case"Left":return C(t(n.left),Nt(()=>kt(r)));case"Right":return kt(n.right)}})),qCe=e=>st((t,r)=>e(X_(r.runtimeFlags))),HCe=Symbol.for("effect/OriginalAnnotation"),BL=(e,t)=>pt(t)?new Proxy(e,{has(r,n){return n===DE||n===HCe||n in r},get(r,n){return n===DE?t.value:n===HCe?e:r[n]}}):e,Ci=e=>xi(e)&&!(DE in e)?st(t=>kt(eo(BL(e,jL(t))))):kt(eo(e)),fA=e=>Tf(()=>eo(new fwe(e))),Ta=e=>O(V(e),Ci),wu=e=>Ho(e,{onFailure:t=>M(Re(t)),onSuccess:t=>M(Le(t))}),fn=e=>sB(e,{onFailure:$t,onSuccess:Vt}),ut=e=>xi(e)&&!(DE in e)?st(t=>kt(zl(BL(e,jL(t))))):kt(zl(e)),pc=e=>O(V(e),ut),kt=e=>{let t=new wL(Rr);return t.effect_instruction_i0=e,t},Tf=e=>O(V(e),kt),td=st(e=>M(e.id())),Da=e=>st(t=>e(t.id())),O=x(2,(e,t)=>{let r=new zn(bw);return r.effect_instruction_i0=e,r.effect_instruction_i1=t,r}),pA=x(2,(e,t)=>O(e,r=>{let n=typeof t=="function"?t(r):t;return ar(n)?n:MJ(n)?Kw(o=>{n.then(i=>o(M(i)),i=>o(ut(new nI(i,"An unknown error occurred in Effect.andThen"))))}):M(n)})),TL=e=>{let t=new zn("OnStep");return t.effect_instruction_i0=e,t},ys=e=>O(e,be),mA=e=>Ho(e,{onFailure:M,onSuccess:ut}),sB=x(2,(e,t)=>dn(e,{onFailure:r=>M(t.onFailure(r)),onSuccess:r=>M(t.onSuccess(r))})),dn=x(2,(e,t)=>{let r=new zn(Sw);return r.effect_instruction_i0=e,r.effect_instruction_i1=t.onFailure,r.effect_instruction_i2=t.onSuccess,r}),Ho=x(2,(e,t)=>dn(e,{onFailure:r=>{if(Q_(r).length>0)return kt(sSe(r));let o=D_(r);return o.length>0?t.onFailure(w_(o)):kt(r)},onSuccess:t.onSuccess})),Wo=x(2,(e,t)=>ye(()=>{let r=_e(e),n=bE(r.length),o=0;return Zt(yA({while:()=>o<r.length,body:()=>t(r[o],o),step:i=>{n[o++]=i}}),n)})),mc=x(2,(e,t)=>ye(()=>{let r=_e(e),n=0;return yA({while:()=>n<r.length,body:()=>t(r[n],n),step:()=>{n++}})})),DL=x(e=>typeof e[0]=="boolean"||ar(e[0]),(e,t)=>ar(e)?O(e,r=>r?t.onTrue():t.onFalse()):e?t.onTrue():t.onFalse()),qs=O(td,e=>aB(e)),aB=e=>kt(Hs(e)),Qa=e=>{let t=new zn(xm);return t.effect_instruction_i0=N3(Xl),t.effect_instruction_i1=()=>e,t},GCe=e=>oB(e,function(){let t=new zn(xm);return t.effect_instruction_i0=N3(Xl),t.effect_instruction_i1=r=>X_(r)?qn(()=>this.effect_instruction_i0(Qa)):qn(()=>this.effect_instruction_i0(Iu)),t}),Df=x(2,(e,t)=>xn(r=>O(fn(r(e)),n=>lK(t,n)))),te=x(2,(e,t)=>O(e,r=>V(()=>t(r)))),cB=x(2,(e,t)=>Ho(e,{onFailure:r=>pc(()=>t.onFailure(r)),onSuccess:r=>V(()=>t.onSuccess(r))})),hA=x(2,(e,t)=>dn(e,{onFailure:r=>{let n=Vl(r);switch(n._tag){case"Left":return pc(()=>t(n.left));case"Right":return kt(n.right)}},onSuccess:M})),QL=x(2,(e,t)=>Gs(e,r=>yB(r)?Ue:t(r.effect_instruction_i0))),Gs=x(2,(e,t)=>xn(r=>dn(r(e),{onFailure:n=>{let o=$t(n);return dn(t(o),{onFailure:i=>$t(Vr(n,i)),onSuccess:()=>o})},onSuccess:n=>{let o=Vt(n);return je(t(o),o)}}))),hc=x(2,(e,t)=>Gs(e,GE({onFailure:r=>OE(r)?$r(t(NE(r))):Ue,onSuccess:()=>Ue}))),LE=x(2,(e,t)=>IEt(e,t,M)),UE=e=>eK(e,be),eK=x(2,(e,t)=>Ho(e,{onFailure:r=>Ci(t(r)),onSuccess:M})),zCe=x6,Zw=st((e,t)=>M(t.runtimeFlags)),M=e=>{let t=new IL(_r);return t.effect_instruction_i0=e,t},ye=e=>{let t=new zn(AE);return t.commit=e,t},V=e=>{let t=new zn(nF);return t.effect_instruction_i0=e,t},jo=x(e=>e.length===3||e.length===2&&!(xi(e[1])&&"onlyEffect"in e[1]),(e,t)=>O(e,r=>{let n=typeof t=="function"?t(r):t;return ar(n)?Zt(n,r):MJ(n)?Kw(o=>{n.then(i=>o(M(r)),i=>o(ut(new nI(i,"An unknown error occurred in Effect.tap"))))}):M(r)})),OL=e=>st(t=>{let r=t.getFiberRef(nB),n=C(r,Nt(()=>t.scope()));return e(tn(nB,H(n)))}),IEt=x(3,(e,t,r)=>dn(e,{onFailure:n=>Q_(n).length>0?kt(mF(iSe(n))):t(),onSuccess:r})),Iu=e=>{let t=new zn(xm);return t.effect_instruction_i0=P3(Xl),t.effect_instruction_i1=()=>e,t},xn=e=>oB(e,function(){let t=new zn(xm);return t.effect_instruction_i0=P3(Xl),t.effect_instruction_i1=r=>X_(r)?qn(()=>this.effect_instruction_i0(Qa)):qn(()=>this.effect_instruction_i0(Iu)),t}),Ue=M(void 0),gA=e=>{let t=new zn(xm);return t.effect_instruction_i0=e,t.effect_instruction_i1=void 0,t},AA=x(2,(e,t)=>O(t,r=>r?C(e,te(H)):M(W()))),yA=e=>{let t=new zn(Cw);return t.effect_instruction_i0=e.while,t.effect_instruction_i1=e.body,t.effect_instruction_i2=e.step,t},rB=e=>ye(()=>{let t=new zn(yE);return t.effect_instruction_i0=e(),t}),uB=function(){let e=arguments.length===1?arguments[0]:arguments[1].bind(arguments[0]);return rB(()=>e(C))},Xw=(e,...t)=>Object.defineProperty(t.length===0?function(...r){return rB(()=>e.apply(this,r))}:function(...r){let n=rB(()=>e.apply(this,r));for(let o of t)n=o(n,...r);return n},"length",{value:e.length,configurable:!0}),VCe=x(2,(e,t)=>tn(e,pB,t)),YCe=x(2,(e,t)=>tn(e,eI,t)),NL=x(2,(e,t)=>{let r=new zn(xm);return r.effect_instruction_i0=t,r.effect_instruction_i1=()=>e,r}),JCe=x(2,(e,t)=>tn(e,rI,t)),KCe=x(2,(e,t)=>tn(e,Pm,t)),ku=e=>{let t=new zn(ww);return typeof e?.priority<"u"?iK(t,e.priority):t},Nm=x(2,(e,t)=>O(e,r=>te(t,n=>[r,n]))),$E=x(2,(e,t)=>O(e,r=>Zt(t,r))),je=x(2,(e,t)=>O(e,()=>t)),Zi=x(3,(e,t,r)=>O(e,n=>te(t,o=>r(n,o)))),xA=_f(()=>{let e=setInterval(()=>{},2147483647);return V(()=>clearInterval(e))}),gc=e=>O(td,t=>C(e,xs(t))),xs=x(2,(e,t)=>O(e.interruptAsFork(t),()=>e.await)),ZCe={_tag:"All",syslog:0,label:"ALL",ordinal:Number.MIN_SAFE_INTEGER,pipe(){return Z(this,arguments)}},XCe={_tag:"Fatal",syslog:2,label:"FATAL",ordinal:5e4,pipe(){return Z(this,arguments)}},ewe={_tag:"Error",syslog:3,label:"ERROR",ordinal:4e4,pipe(){return Z(this,arguments)}},tK={_tag:"Warning",syslog:4,label:"WARN",ordinal:3e4,pipe(){return Z(this,arguments)}},rK={_tag:"Info",syslog:6,label:"INFO",ordinal:2e4,pipe(){return Z(this,arguments)}},nK={_tag:"Debug",syslog:7,label:"DEBUG",ordinal:1e4,pipe(){return Z(this,arguments)}},twe={_tag:"Trace",syslog:7,label:"TRACE",ordinal:0,pipe(){return Z(this,arguments)}},rwe={_tag:"None",syslog:7,label:"OFF",ordinal:Number.MAX_SAFE_INTEGER,pipe(){return Z(this,arguments)}},kEt="effect/FiberRef",nwe=Symbol.for(kEt),vEt={_A:e=>e},Xi=e=>st(t=>Vt(t.getFiberRef(e))),ui=x(2,(e,t)=>O(Xi(e),t)),Dm=x(2,(e,t)=>owe(e,()=>[void 0,t])),owe=x(2,(e,t)=>st(r=>{let[n,o]=t(r.getFiberRef(e));return r.setFiberRef(e,o),M(n)})),REt="effect/RequestResolver",iwe=Symbol.for(REt),_Et={_A:e=>e,_R:e=>e},WCe=class e{runAll;target;[iwe]=_Et;constructor(t,r){this.runAll=t,this.target=r}[he](){return We(this,this.target?ae(this.target):Aw(this))}[me](t){return this.target?BEt(t)&&ce(this.target,t.target):this===t}identified(...t){return new e(this.runAll,Co(t))}pipe(){return Z(this,arguments)}},BEt=e=>se(e,iwe),tn=x(3,(e,t,r)=>_L($E(Xi(t),Dm(t,r)),()=>e,n=>Dm(t,n))),no=x(3,(e,t,r)=>ui(t,n=>tn(e,t,r(n)))),pn=(e,t)=>EA(e,{differ:fL(),fork:t?.fork??be,join:t?.join}),oK=e=>{let t=C3();return EA(e,{differ:t,fork:t.empty})},TEt=e=>{let t=w3(fL());return EA(e,{differ:t,fork:t.empty})},lB=e=>{let t=S3();return EA(e,{differ:t,fork:t.empty})},EA=(e,t)=>({...gu,[nwe]:vEt,initial:e,commit(){return Xi(this)},diff:(n,o)=>t.differ.diff(n,o),combine:(n,o)=>t.differ.combine(n,o),patch:n=>o=>t.differ.patch(n,o),fork:t.fork,join:t.join??((n,o)=>o)}),swe=e=>EA(e,{differ:O3,fork:O3.empty}),li=Te(Symbol.for("effect/FiberRef/currentContext"),()=>lB(ro())),Qf=Te(Symbol.for("effect/FiberRef/currentSchedulingPriority"),()=>pn(0)),dB=Te(Symbol.for("effect/FiberRef/currentMaxOpsBeforeYield"),()=>pn(2048)),Of=Te(Symbol.for("effect/FiberRef/currentLogAnnotation"),()=>pn(If())),PL=Te(Symbol.for("effect/FiberRef/currentLogLevel"),()=>pn(rK)),fB=Te(Symbol.for("effect/FiberRef/currentLogSpan"),()=>pn(Rf())),iK=x(2,(e,t)=>tn(e,Qf,t)),awe=x(2,(e,t)=>tn(e,dB,t)),pB=Te(Symbol.for("effect/FiberRef/currentConcurrency"),()=>pn("unbounded")),eI=Te(Symbol.for("effect/FiberRef/currentRequestBatching"),()=>pn(!0)),tI=Te(Symbol.for("effect/FiberRef/currentUnhandledErrorLogLevel"),()=>pn(H(nK))),mB=Te(Symbol.for("effect/FiberRef/versionMismatchErrorLogLevel"),()=>pn(H(tK))),cwe=x(2,(e,t)=>tn(e,tI,t)),Nf=Te(Symbol.for("effect/FiberRef/currentMetricLabels"),()=>TEt(Us())),uwe=Xi(Nf),nB=Te(Symbol.for("effect/FiberRef/currentForkScopeOverride"),()=>pn(W(),{fork:()=>W(),join:(e,t)=>e})),bA=Te(Symbol.for("effect/FiberRef/currentInterruptedCause"),()=>pn(Yi,{fork:()=>Yi,join:(e,t)=>e})),rI=Te(Symbol.for("effect/FiberRef/currentTracerEnabled"),()=>pn(!0)),Pm=Te(Symbol.for("effect/FiberRef/currentTracerTiming"),()=>pn(!0)),HE=Te(Symbol.for("effect/FiberRef/currentTracerSpanAnnotations"),()=>pn(If())),hB=Te(Symbol.for("effect/FiberRef/currentTracerSpanLinks"),()=>pn(Ut())),ML=Symbol.for("effect/Scope"),FL=Symbol.for("effect/CloseableScope"),gB=(e,t)=>e.addFinalizer(()=>$r(t)),SA=(e,t)=>e.addFinalizer(t),rd=(e,t)=>e.close(t),Ac=(e,t)=>e.fork(t),lwe=e=>dwe(be)(e),dwe=x(2,(e,t)=>{let r=C(e,UF,dr(t));switch(r._tag){case"None":return C(Q_(e),CE,wt({onNone:()=>{let n=_e(NE(e)).flatMap(o=>_e(qw(o)).map(i=>`#${i}`));return new pwe(n?`Interrupted by fibers: ${n.join(", ")}`:void 0)},onSome:be}));case"Some":return r.value}}),AB=function(){class e extends globalThis.Error{commit(){return ut(this)}toJSON(){let r={...this};return this.message&&(r.message=this.message),this.cause&&(r.cause=this.cause),r}[Ce](){return this.toString!==globalThis.Error.prototype.toString?this.stack?`${this.toString()}
42
42
  ${this.stack.split(`
43
43
  `).slice(1).join(`
44
- `)}`:this.toString():"Bun"in globalThis?Yl(zl(this),{renderErrorCause:!0}):this}}return Object.assign(e.prototype,iF),e}(),WE=(e,t)=>{class r extends AB{_tag=t}return Object.assign(r.prototype,e),r.prototype.name=t,r},V3=Symbol.for("effect/Cause/errors/RuntimeException"),fwe=WE({[V3]:V3},"RuntimeException"),kL=Symbol.for("effect/Cause/errors/InterruptedException"),pwe=WE({[kL]:kL},"InterruptedException"),sK=e=>se(e,kL),Y3=Symbol.for("effect/Cause/errors/IllegalArgument"),vu=WE({[Y3]:Y3},"IllegalArgumentException"),vL=Symbol.for("effect/Cause/errors/NoSuchElement"),Es=WE({[vL]:vL},"NoSuchElementException"),aK=e=>se(e,vL),J3=Symbol.for("effect/Cause/errors/InvalidPubSubCapacityException"),DIr=WE({[J3]:J3},"InvalidPubSubCapacityException"),K3=Symbol.for("effect/Cause/errors/ExceededCapacityException"),DEt=WE({[K3]:K3},"ExceededCapacityException"),Z3=Symbol.for("effect/Cause/errors/Timeout"),mwe=WE({[Z3]:Z3},"TimeoutException"),hwe=e=>new mwe(`Operation timed out after '${YF(e)}'`),X3=Symbol.for("effect/Cause/errors/UnknownException"),nI=function(){class e extends AB{_tag="UnknownException";error;constructor(r,n){super(n??"An unknown error occurred",{cause:r}),this.error=r}}return Object.assign(e.prototype,{[X3]:X3,name:"UnknownException"}),e}(),jE=e=>ar(e)&&"_tag"in e&&(e._tag==="Success"||e._tag==="Failure"),LL=e=>e._tag==="Failure",yB=e=>e._tag==="Success",gwe=e=>{switch(e._tag){case Rr:return Fw(e.effect_instruction_i0);case _r:return!1}},qE=x(2,(e,t)=>{switch(e._tag){case Rr:return $t(e.effect_instruction_i0);case _r:return Vt(t)}}),oI=e=>qE(e,void 0),Awe=e=>{switch(e._tag){case Rr:return H(e.effect_instruction_i0);case _r:return W()}},CA=(e,t)=>QEt(e,t?.parallel?to:Vr),UL=e=>$t(eo(e)),ywe=x(2,(e,t)=>{switch(e._tag){case Rr:return!1;case _r:return t(e.effect_instruction_i0)}}),nd=e=>$t(zl(e)),$t=e=>{let t=new wL(Rr);return t.effect_instruction_i0=e,t},cK=x(2,(e,t)=>{switch(e._tag){case Rr:return $t(e.effect_instruction_i0);case _r:return t(e.effect_instruction_i0)}}),xwe=x(2,(e,t)=>{switch(e._tag){case Rr:return M($t(e.effect_instruction_i0));case _r:return t(e.effect_instruction_i0)}}),Ewe=e=>C(e,cK(be)),bwe=x(2,(e,t)=>{switch(e._tag){case Rr:return M($t(e.effect_instruction_i0));case _r:return fn(t(e.effect_instruction_i0))}}),Swe=e=>{switch(e._tag){case"Left":return nd(e.left);case"Right":return Vt(e.right)}},Cwe=e=>{switch(e._tag){case"None":return nd(void 0);case"Some":return Vt(e.value)}},wwe=x(2,(e,t)=>{switch(e._tag){case Rr:return t(e.effect_instruction_i0);case _r:return e.effect_instruction_i0}}),xB=e=>$t(Hs(e)),tB=x(2,(e,t)=>{switch(e._tag){case Rr:return $t(e.effect_instruction_i0);case _r:return Vt(t(e.effect_instruction_i0))}}),Iwe=x(2,(e,{onFailure:t,onSuccess:r})=>{switch(e._tag){case Rr:return $t(C(e.effect_instruction_i0,O_(t)));case _r:return Vt(r(e.effect_instruction_i0))}}),kwe=x(2,(e,t)=>{switch(e._tag){case Rr:return $t(C(e.effect_instruction_i0,O_(t)));case _r:return Vt(e.effect_instruction_i0)}}),vwe=x(2,(e,t)=>{switch(e._tag){case Rr:return $t(t(e.effect_instruction_i0));case _r:return Vt(e.effect_instruction_i0)}}),GE=x(2,(e,{onFailure:t,onSuccess:r})=>{switch(e._tag){case Rr:return t(e.effect_instruction_i0);case _r:return r(e.effect_instruction_i0)}}),zE=x(2,(e,{onFailure:t,onSuccess:r})=>{switch(e._tag){case Rr:return t(e.effect_instruction_i0);case _r:return r(e.effect_instruction_i0)}}),Vt=e=>{let t=new IL(_r);return t.effect_instruction_i0=e,t},Pn=Vt(void 0),Rwe=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>[r,n],onFailure:Vr})),_we=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>r,onFailure:Vr})),$L=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>n,onFailure:Vr})),Bwe=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>[r,n],onFailure:to})),Twe=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>r,onFailure:to})),Dwe=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>n,onFailure:to})),Ru=x(3,(e,t,{onFailure:r,onSuccess:n})=>{switch(e._tag){case Rr:switch(t._tag){case _r:return $t(e.effect_instruction_i0);case Rr:return $t(r(e.effect_instruction_i0,t.effect_instruction_i0))}case _r:switch(t._tag){case _r:return Vt(n(e.effect_instruction_i0,t.effect_instruction_i0));case Rr:return $t(t.effect_instruction_i0)}}}),QEt=(e,t)=>{let r=Co(e);return kr(r)?C(Ur(r),yu(C(Gt(r),tB(Dt)),(n,o)=>C(n,Ru(o,{onSuccess:(i,s)=>C(i,fr(s)),onFailure:t}))),tB(gs),tB(n=>Uo(n)),H):W()},wA=e=>({...gu,[SL]:FCe,state:Ba(LCe([])),commit(){return Cn(this)},blockingOn:e}),Ci=()=>O(td,e=>uK(e)),uK=e=>V(()=>wA(e)),Cn=e=>_f(t=>{let r=Qr(e.state);switch(r._tag){case FE:return t(r.effect);case dA:return r.joiners.push(t),OEt(e,t)}},e.blockingOn),HL=x(2,(e,t)=>Df(t,e)),yc=x(2,(e,t)=>V(()=>{let r=Qr(e.state);switch(r._tag){case FE:return!1;case dA:{js(e.state,G3(t));for(let n=0,o=r.joiners.length;n<o;n++)r.joiners[n](t);return!0}}})),lK=x(2,(e,t)=>yc(e,t)),Qwe=x(2,(e,t)=>yc(e,ut(t))),Owe=x(2,(e,t)=>yc(e,pc(t))),iI=x(2,(e,t)=>yc(e,kt(t))),Nwe=x(2,(e,t)=>yc(e,Tf(t))),Pwe=x(2,(e,t)=>yc(e,Si(t))),Mwe=x(2,(e,t)=>yc(e,Ta(t))),Fwe=e=>O(td,t=>yc(e,aB(t))),EB=x(2,(e,t)=>yc(e,aB(t))),Lwe=e=>V(()=>Qr(e.state)._tag===FE),Uwe=e=>V(()=>{let t=Qr(e.state);switch(t._tag){case FE:return H(t.effect);case dA:return W()}}),Mm=x(2,(e,t)=>yc(e,M(t))),$we=x(2,(e,t)=>yc(e,V(t))),IA=(e,t)=>{let r=Qr(e.state);if(r._tag===dA){js(e.state,G3(t));for(let n=0,o=r.joiners.length;n<o;n++)r.joiners[n](t)}},OEt=(e,t)=>V(()=>{let r=Qr(e.state);if(r._tag===dA){let n=r.joiners.indexOf(t);n>=0&&r.joiners.splice(n,1)}}),NEt=st(e=>Vt(e.currentContext)),Oa=()=>NEt,xc=e=>O(Oa(),e),zs=x(2,(e,t)=>tn(ui,t)(e)),WL=x(2,(e,t)=>no(ui,r=>wo(r,t))(e)),kA=x(2,(e,t)=>xc(r=>zs(e,t(r)))),dK=x(2,(e,t)=>O(e,r=>O(t.predicate(r),n=>n?M(r):t.orElse(r)))),Hwe=x(2,(e,t)=>dK(e,{predicate:t.predicate,orElse:r=>ut(t.orFailWith(r))})),jL=e=>{let t=e.currentSpan;return t!==void 0&&t._tag==="Span"?H(t):W()},PEt={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:BigInt(0),endTime:BigInt(0),exit:Pn},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},Wwe=e=>Object.assign(Object.create(PEt),e)});var jwe,VE,od,qL,qwe,Gwe,zwe,Vwe,fK,GL,Ywe,Jwe,sI,zL,Fm,pK,Kwe,bB,Zwe,VL,Vs=h(()=>{Jl();vt();jwe=Yi,VE=zl,od=eo,qL=Hs,qwe=to,Gwe=Vr,zwe=T_,Vwe=rSe,fK=QE,GL=Fw,Ywe=OE,Jwe=NE,sI=Vl,zL=nSe,Fm=O_,pK=lwe,Kwe=N_,bB=vu,Zwe=Es,VL=Yl});var MEt,YE,bs,FEt,Xwe,eIe,LEt,mK,YL,JE=h(()=>{sr();Ws();oe();vt();MEt="effect/Clock",YE=Symbol.for(MEt),bs=Jt("effect/Clock"),FEt=2**31-1,Xwe={unsafeSchedule(e,t){let r=Io(t);if(r>FEt)return Gi;let n=!1,o=setTimeout(()=>{n=!0,e()},r);return()=>(clearTimeout(o),!n)}},eIe=function(){let e=BigInt(1e6);if(typeof performance>"u"||typeof performance.now!="function")return()=>BigInt(Date.now())*e;let t;return()=>(t===void 0&&(t=BigInt(Date.now())*e-BigInt(Math.round(performance.now()*1e6))),t+BigInt(Math.round(performance.now()*1e6)))}(),LEt=function(){let e=typeof process=="object"&&"hrtime"in process&&typeof process.hrtime.bigint=="function"?process.hrtime:void 0;if(!e)return eIe;let t=eIe()-e.bigint();return()=>t+e.bigint()}(),mK=class{[YE]=YE;unsafeCurrentTimeMillis(){return Date.now()}unsafeCurrentTimeNanos(){return LEt()}currentTimeMillis=V(()=>this.unsafeCurrentTimeMillis());currentTimeNanos=V(()=>this.unsafeCurrentTimeNanos());scheduler(){return M(Xwe)}sleep(t){return bi(r=>{let n=Xwe.unsafeSchedule(()=>r(Ue),t);return $r(V(n))})}},YL=()=>new mK});var oo,Lm=h(()=>{bm();oo=WEe});var aI,KL=h(()=>{aI=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&")});var gK,AK,yK,xK,EK,bK,tIe=h(()=>{gK="And",AK="Or",yK="InvalidData",xK="MissingData",EK="SourceUnavailable",bK="Unsupported"});var WEt,rIe,cI,SK,CK,jEt,Um,qEt,GEt,RA,wK=h(()=>{wr();oe();tIe();WEt="effect/ConfigError",rIe=Symbol.for(WEt),cI={_tag:"ConfigError",[rIe]:rIe},SK=(e,t)=>{let r=Object.create(cI);return r._op=gK,r.left=e,r.right=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`${this.left} and ${this.right}`}}),Object.defineProperty(r,"message",{enumerable:!1,get(){return this.toString()}}),r},CK=(e,t)=>{let r=Object.create(cI);return r._op=AK,r.left=e,r.right=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`${this.left} or ${this.right}`}}),Object.defineProperty(r,"message",{enumerable:!1,get(){return this.toString()}}),r},jEt=(e,t,r={pathDelim:"."})=>{let n=Object.create(cI);return n._op=yK,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Invalid data at ${C(this.path,Im(r.pathDelim))}: "${this.message}")`}}),n},Um=(e,t,r={pathDelim:"."})=>{let n=Object.create(cI);return n._op=xK,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Missing data at ${C(this.path,Im(r.pathDelim))}: "${this.message}")`}}),n},qEt=(e,t,r,n={pathDelim:"."})=>{let o=Object.create(cI);return o._op=EK,o.path=e,o.message=t,o.cause=r,Object.defineProperty(o,"toString",{enumerable:!1,value(){return`(Source unavailable at ${C(this.path,Im(n.pathDelim))}: "${this.message}")`}}),o},GEt=(e,t,r={pathDelim:"."})=>{let n=Object.create(cI);return n._op=bK,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Unsupported operation at ${C(this.path,Im(r.pathDelim))}: "${this.message}")`}}),n},RA=x(2,(e,t)=>{switch(e._op){case gK:return SK(RA(e.left,t),RA(e.right,t));case AK:return CK(RA(e.left,t),RA(e.right,t));case yK:return jEt([...t,...e.path],e.message);case xK:return Um([...t,...e.path],e.message);case EK:return qEt([...t,...e.path],e.message,e.cause);case bK:return GEt([...t,...e.path],e.message)}})});var oIe,ZL,iIe=h(()=>{wr();Ei();oe();Gw();it();wK();oIe={_tag:"Empty"},ZL=x(2,(e,t)=>{let r=G_(t),n=e;for(;g3(r);){let o=r.head;switch(o._tag){case"Empty":{r=r.tail;break}case"AndThen":{r=_m(o.first,_m(o.second,r.tail));break}case"MapName":{n=$l(n,o.f),r=r.tail;break}case"Nested":{n=Rw(n,o.name),r=r.tail;break}case"Unnested":{if(C(wm(n),s6(o.name)))n=Ll(n),r=r.tail;else return Re(Um(n,`Expected ${o.name} to be in path in ConfigProvider#unnested`));break}}}return Le(n)})});var sIe,aIe,cIe,uIe,lIe,dIe,fIe,pIe,mIe,hIe,gIe,AIe=h(()=>{sIe="Constant",aIe="Fail",cIe="Fallback",uIe="Described",lIe="Lazy",dIe="MapOrFail",fIe="Nested",pIe="Primitive",mIe="Sequence",hIe="HashMap",gIe="ZipWith"});var XL,JEt,yIe,uI,KEt,xIe,ZEt,XEt,ebt,EIe,tbt,rbt,Bu,nbt,obt,ibt,sbt,abt,cbt,ubt,lbt,IK=h(()=>{wr();sr();Ei();oe();kf();dc();Lm();it();Me();KL();wK();iIe();vt();AIe();XL=(e,t)=>[...e,...t],JEt="effect/ConfigProvider",yIe=Symbol.for(JEt),uI=Jt("effect/ConfigProvider"),KEt="effect/ConfigProviderFlat",xIe=Symbol.for(KEt),ZEt=e=>({[yIe]:yIe,pipe(){return Z(this,arguments)},...e}),XEt=e=>({[xIe]:xIe,patch:e.patch,load:(t,r,n=!0)=>e.load(t,r,n),enumerateChildren:e.enumerateChildren}),ebt=e=>ZEt({load:t=>O(Bu(e,Us(),t,!1),r=>wt(wm(r),{onNone:()=>ut(Um(Us(),`Expected a single value having structure: ${t}`)),onSome:M})),flattened:e}),EIe=e=>{let{pathDelim:t,seqDelim:r}=Object.assign({},{pathDelim:"_",seqDelim:","},e),n=c=>C(c,Im(t)),o=c=>c.split(t),i=()=>typeof process<"u"&&"env"in process&&typeof process.env=="object"?process.env:{};return ebt(XEt({load:(c,u,l=!0)=>{let d=n(c),f=i(),p=d in f?H(f[d]):W();return C(p,hA(()=>Um(c,`Expected ${d} to exist in the process context`)),O(m=>ibt(m,c,u,r,l)))},enumerateChildren:c=>V(()=>{let u=i(),f=Object.keys(u).map(p=>o(p.toUpperCase())).filter(p=>{for(let m=0;m<c.length;m++){let g=C(c,h6(m)),A=p[m];if(A===void 0||g!==A)return!1}return!0}).flatMap(p=>p.slice(c.length,c.length+1));return MF(f)}),patch:oIe}))},tbt=(e,t,r,n)=>{let o=b6(r.length,c=>c>=n.length?W():H([e(c),c+1])),i=b6(n.length,c=>c>=r.length?W():H([t(c),c+1])),s=XL(r,o),a=XL(n,i);return[s,a]},rbt=(e,t)=>{let r=t;if(r._tag==="Nested"){let n=e.slice();for(;r._tag==="Nested";)n.push(r.name),r=r.config;return n}return e},Bu=(e,t,r,n)=>{let o=r;switch(o._tag){case sIe:return M(hs(o.value));case uIe:return ye(()=>Bu(e,t,o.config,n));case aIe:return ut(Um(t,o.message));case cIe:return C(ye(()=>Bu(e,t,o.first,n)),fc(i=>o.condition(i)?C(Bu(e,t,o.second,n),fc(s=>ut(CK(i,s)))):ut(i)));case lIe:return ye(()=>Bu(e,t,o.config(),n));case dIe:return ye(()=>C(Bu(e,t,o.original,n),O(Wo(i=>C(o.mapOrFail(i),hA(RA(rbt(t,o.original))))))));case fIe:return ye(()=>Bu(e,XL(t,hs(o.name)),o.config,n));case pIe:return C(ZL(t,e.patch),O(i=>C(e.load(i,o,n),O(s=>{if(s.length===0){let a=C(EF(i),Nt(()=>"<n/a>"));return ut(Um([],`Expected ${o.description} with name ${a}`))}return M(s)}))));case mIe:return C(ZL(t,e.patch),O(i=>C(e.enumerateChildren(i),O(abt),O(s=>s.length===0?ye(()=>te(Bu(e,t,o.config,!0),hs)):C(Wo(s,a=>Bu(e,p6(t,`[${a}]`),o.config,!0)),te(a=>{let c=b_(a);return c.length===0?hs(Us()):hs(c)}))))));case hIe:return ye(()=>C(ZL(t,e.patch),O(i=>C(e.enumerateChildren(i),O(s=>C(s,Wo(a=>Bu(e,XL(i,hs(a)),o.valueConfig,n)),te(a=>a.length===0?hs(If()):C(sbt(a),$l(c=>KSe(A6(_e(s),c)))))))))));case gIe:return ye(()=>C(Bu(e,t,o.left,n),wu,O(i=>C(Bu(e,t,o.right,n),wu,O(s=>{if(xr(i)&&xr(s))return ut(SK(i.left,s.left));if(xr(i)&&ii(s))return ut(i.left);if(ii(i)&&xr(s))return ut(s.left);if(ii(i)&&ii(s)){let a=C(t,Im(".")),c=nbt(t,a),[u,l]=tbt(c,c,C(i.right,$l(Le)),C(s.right,$l(Le)));return C(u,A6(l),Wo(([d,f])=>C(Nm(d,f),te(([p,m])=>o.zip(p,m)))))}throw new Error("BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues")})))))}},nbt=(e,t)=>r=>Re(Um(e,`The element at index ${r} in a sequence at path "${t}" was missing`)),obt=(e,t)=>e.split(new RegExp(`\\s*${aI(t)}\\s*`)),ibt=(e,t,r,n,o)=>o?C(obt(e,n),Wo(i=>r.parse(i.trim())),hA(RA(t))):C(r.parse(e),cB({onFailure:RA(t),onSuccess:hs})),sbt=e=>Object.keys(e[0]).map(t=>e.map(r=>r[t])),abt=e=>C(Wo(e,ubt),cB({onFailure:()=>Us(),onSuccess:Vi(oo)}),wu,te(vw)),cbt=/^(\[(\d+)\])$/,ubt=e=>{let t=e.match(cbt);if(t!==null){let r=t[2];return C(r!==void 0&&r.length>0?H(r):W(),Gn(lbt))}return W()},lbt=e=>{let t=Number.parseInt(e);return Number.isNaN(t)?W():H(t)}});var bIe,$m,SIe,e1=h(()=>{sr();vt();bIe=Symbol.for("effect/Console"),$m=Jt("effect/Console"),SIe={[bIe]:bIe,assert(e,...t){return V(()=>{console.assert(e,...t)})},clear:V(()=>{console.clear()}),count(e){return V(()=>{console.count(e)})},countReset(e){return V(()=>{console.countReset(e)})},debug(...e){return V(()=>{console.debug(...e)})},dir(e,t){return V(()=>{console.dir(e,t)})},dirxml(...e){return V(()=>{console.dirxml(...e)})},error(...e){return V(()=>{console.error(...e)})},group(e){return e?.collapsed?V(()=>console.groupCollapsed(e?.label)):V(()=>console.group(e?.label))},groupEnd:V(()=>{console.groupEnd()}),info(...e){return V(()=>{console.info(...e)})},log(...e){return V(()=>{console.log(...e)})},table(e,t){return V(()=>{console.table(e,t)})},time(e){return V(()=>console.time(e))},timeEnd(e){return V(()=>console.timeEnd(e))},timeLog(e,...t){return V(()=>{console.timeLog(e,...t)})},trace(...e){return V(()=>{console.trace(...e)})},warn(...e){return V(()=>{console.warn(...e)})},unsafe:console}});var fbt,SB,Hm,kK,wIe,pbt,RK,vK,IIe,CB=h(()=>{vr();sr();oe();ir();mu();vt();fbt="effect/Random",SB=Symbol.for(fbt),Hm=Jt("effect/Random"),kK=class{seed;[SB]=SB;PRNG;constructor(t){this.seed=t,this.PRNG=new ZM(t)}get next(){return V(()=>this.PRNG.number())}get nextBoolean(){return te(this.next,t=>t>.5)}get nextInt(){return V(()=>this.PRNG.integer(Number.MAX_SAFE_INTEGER))}nextRange(t,r){return te(this.next,n=>(r-t)*n+t)}nextIntBetween(t,r){return V(()=>this.PRNG.integer(r-t)+t)}shuffle(t){return wIe(t,r=>this.nextIntBetween(0,r))}},wIe=(e,t)=>ye(()=>C(V(()=>Array.from(e)),O(r=>{let n=[];for(let o=r.length;o>=2;o=o-1)n.push(o);return C(n,mc(o=>C(t(o),te(i=>pbt(r,o-1,i)))),Zt(Co(r)))}))),pbt=(e,t,r)=>{let n=e[t];return e[t]=e[r],e[r]=n,e},RK=e=>new kK(ae(e)),vK=class{values;[SB]=SB;index=0;constructor(t){if(this.values=t,t.length===0)throw new Error("Requires at least one value")}getNextValue(){let t=this.values[this.index];return this.index=(this.index+1)%this.values.length,t}get next(){return V(()=>{let t=this.getNextValue();return typeof t=="number"?Math.max(0,Math.min(1,t)):ae(t)/2147483647})}get nextBoolean(){return V(()=>{let t=this.getNextValue();return typeof t=="boolean"?t:ae(t)%2===0})}get nextInt(){return V(()=>{let t=this.getNextValue();return typeof t=="number"&&Number.isFinite(t)?Math.round(t):Math.abs(ae(t))})}nextRange(t,r){return te(this.next,n=>(r-t)*n+t)}nextIntBetween(t,r){return V(()=>{let n=this.getNextValue();if(typeof n=="number"&&Number.isFinite(n))return Math.max(t,Math.min(r-1,Math.round(n)));let o=Math.abs(ae(n));return t+o%(r-t)})}shuffle(t){return wIe(t,r=>this.nextIntBetween(0,r))}},IIe=e=>new vK(e)});var _K,RIe,Pf,wi,vIe,BK,_Ie,Ec,KE,_A=h(()=>{sr();oe();_K=Symbol.for("effect/Tracer"),RIe=e=>({[_K]:_K,...e}),Pf=Jt("effect/Tracer"),wi=Jt("effect/ParentSpan"),vIe=function(){let e="abcdef0123456789",t=e.length;return function(r){let n="";for(let o=0;o<r;o++)n+=e.charAt(Math.floor(Math.random()*t));return n}}(),BK=class{name;parent;context;startTime;kind;_tag="Span";spanId;traceId="native";sampled=!0;status;attributes;events=[];links;constructor(t,r,n,o,i,s){this.name=t,this.parent=r,this.context=n,this.startTime=i,this.kind=s,this.status={_tag:"Started",startTime:i},this.attributes=new Map,this.traceId=r._tag==="Some"?r.value.traceId:vIe(32),this.spanId=vIe(16),this.links=Array.from(o)}end(t,r){this.status={_tag:"Ended",endTime:t,exit:r,startTime:this.status.startTime}}attribute(t,r){this.attributes.set(t,r)}event(t,r,n){this.events.push([t,r,n??{}])}addLinks(t){this.links.push(...t)}},_Ie=RIe({span:(e,t,r,n,o,i)=>new BK(e,t,r,n,o,i),context:e=>e()}),Ec=e=>{if(e?.captureStackTrace===!1)return e;if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!="boolean")return e;let t=Error.stackTraceLimit;Error.stackTraceLimit=3;let r=new Error;Error.stackTraceLimit=t;let n=!1;return{...e,captureStackTrace:()=>{if(n!==!1)return n;if(r.stack!==void 0){let o=r.stack.split(`
45
- `);if(o[3]!==void 0)return n=o[3].trim(),n}}}},KE=si()("effect/Tracer/DisablePropagation",{defaultValue:Gi})});var mbt,mn,BIe,t1,wB,TIe,DIe,QIe,OIe,NIe,lI,PIe,MIe,r1,FIe,Mf=h(()=>{sr();Ws();oe();yn();JE();IK();vt();e1();CB();_A();mbt=C(ro(),zt(bs,YL()),zt($m,SIe),zt(Hm,RK(Math.random())),zt(uI,EIe()),zt(Pf,_Ie)),mn=Te(Symbol.for("effect/DefaultServices/currentServices"),()=>lB(mbt)),BIe=e=>{let t=At(e);return wB(r=>r.sleep(t))},t1=e=>st(t=>e(t.currentDefaultServices)),wB=e=>t1(t=>e(t.unsafeMap.get(bs.key))),TIe=wB(e=>e.currentTimeMillis),DIe=wB(e=>e.currentTimeNanos),QIe=x(2,(e,t)=>no(mn,zt(bs,t))(e)),OIe=x(2,(e,t)=>no(mn,zt(uI,t))(e)),NIe=e=>t1(t=>e(t.unsafeMap.get(uI.key))),lI=e=>t1(t=>e(t.unsafeMap.get(Hm.key))),PIe=x(2,(e,t)=>no(mn,zt(Hm,t))(e)),MIe=lI(e=>e.next),r1=e=>t1(t=>e(t.unsafeMap.get(Pf.key))),FIe=x(2,(e,t)=>no(mn,zt(Pf,t))(e))});var LIe,TK=h(()=>{LIe=e=>!e});var $Ie,n1,hbt,gbt,Ys,dI,id=h(()=>{Af();$Ie=Em,n1=gu,hbt=_Ee,gbt=BEe,Ys=class extends hbt{},dI=class extends gbt{}});var HIe,WIe,Abt,Tu,IB,jIe,DK,QK,kB=h(()=>{HIe="Sequential",WIe="Parallel",Abt="ParallelN",Tu={_tag:HIe},IB={_tag:WIe},jIe=e=>({_tag:Abt,parallelism:e}),DK=e=>e._tag===HIe,QK=e=>e._tag===WIe});var fI,i1,s1,a1=h(()=>{kB();fI=Tu,i1=IB,s1=jIe});function qIe(e){return new Lf(e)}function GIe(){return qIe(new Map)}var NK,Lf,ybt,c1,MK,zIe,VIe,YIe,vB,u1,jm,pI,PK,JIe,l1=h(()=>{wr();mt();oe();dc();it();Me();vt();NK=Symbol.for("effect/FiberRefs"),Lf=class{locals;[NK]=NK;constructor(t){this.locals=t}pipe(){return Z(this,arguments)}},ybt=(e,t,r,n=!1)=>{let o=e,i=t,s=r,a=n,c;for(;c===void 0;)if(zr(i)&&zr(s)){let u=Lo(i)[0],l=Ll(i),d=Lo(s)[0],f=Lo(s)[1],p=Ll(s);u.startTimeMillis<d.startTimeMillis?(s=p,a=!0):u.startTimeMillis>d.startTimeMillis?i=l:u.id<d.id?(s=p,a=!0):u.id>d.id?i=l:c=[f,a]}else c=[o.initial,!0];return c},c1=x(3,(e,t,r)=>{let n=new Map(e.locals);return r.locals.forEach((o,i)=>{let s=o[0][1];if(!o[0][0][me](t)){if(!n.has(i)){if(ce(s,i.initial))return;n.set(i,[[t,i.join(i.initial,s)]]);return}let a=n.get(i),[c,u]=ybt(i,a,o);if(u){let l=i.diff(c,s),d=a[0][1],f=i.join(d,i.patch(l)(d));if(!ce(d,f)){let p,m=a[0][0];m[me](t)?p=[[m,f],...a.slice(1)]:p=[[t,f],...a],n.set(i,p)}}}}),new Lf(n)}),MK=x(2,(e,t)=>{let r=new Map;return zIe(e,r,t),new Lf(r)}),zIe=(e,t,r)=>{e.locals.forEach((n,o)=>{let i=n[0][1],s=o.patch(o.fork)(i);ce(i,s)?t.set(o,n):t.set(o,[[r,s],...n])})},VIe=e=>MF(e.locals.keys()),YIe=e=>mc(VIe(e),t=>Dm(t,jm(e,t))),vB=x(2,(e,t)=>{let r=new Map(e.locals);return r.delete(t),new Lf(r)}),u1=x(2,(e,t)=>e.locals.has(t)?H(Lo(e.locals.get(t))[1]):W()),jm=x(2,(e,t)=>C(u1(e,t),Nt(()=>t.initial))),pI=x(2,(e,{fiberId:t,fiberRef:r,value:n})=>{if(e.locals.size===0)return new Lf(new Map([[r,[[t,n]]]]));let o=new Map(e.locals);return PK(o,t,r,n),new Lf(o)}),PK=(e,t,r,n)=>{let o=e.get(r)??[],i;if(zr(o)){let[s,a]=Lo(o);if(s[me](t)){if(ce(a,n))return;i=[[t,n],...o.slice(1)]}else i=[[t,n],...o]}else i=[[t,n]];e.set(r,i)},JIe=x(2,(e,{entries:t,forkAs:r})=>{if(e.locals.size===0)return new Lf(new Map(t));let n=new Map(e.locals);return r!==void 0&&zIe(e,n,r),t.forEach(([o,i])=>{i.length===1?PK(n,i[0][0],o,i[0][1]):i.forEach(([s,a])=>{PK(n,s,o,a)})}),new Lf(n)})});var LK,d1,KIe,ZIe,XIe,e0e,mI=h(()=>{l1();LK=u1,d1=jm,KIe=c1,ZIe=YIe,XIe=JIe,e0e=GIe});var t0e,r0e,n0e,o0e,i0e,s0e,_B,f1,p1,UK=h(()=>{wr();mt();oe();l1();t0e="Empty",r0e="Add",n0e="Remove",o0e="Update",i0e="AndThen",s0e={_tag:t0e},_B=(e,t)=>{let r=new Map(e.locals),n=s0e;for(let[o,i]of t.locals.entries()){let s=Lo(i)[1],a=r.get(o);if(a!==void 0){let c=Lo(a)[1];ce(c,s)||(n=f1({_tag:o0e,fiberRef:o,patch:o.diff(c,s)})(n))}else n=f1({_tag:r0e,fiberRef:o,value:s})(n);r.delete(o)}for(let[o]of r.entries())n=f1({_tag:n0e,fiberRef:o})(n);return n},f1=x(2,(e,t)=>({_tag:i0e,first:e,second:t})),p1=x(3,(e,t,r)=>{let n=r,o=hs(e);for(;zr(o);){let i=Lo(o),s=Ll(o);switch(i._tag){case t0e:{o=s;break}case r0e:{n=pI(n,{fiberId:t,fiberRef:i.fiberRef,value:i.value}),o=s;break}case n0e:{n=vB(n,i.fiberRef),o=s;break}case o0e:{let a=jm(n,i.fiberRef);n=pI(n,{fiberId:t,fiberRef:i.fiberRef,value:i.fiberRef.patch(i.patch)(a)}),o=s;break}case i0e:{o=Rw(i.first)(Rw(i.second)(s));break}}}return n})});var XE,eb,m1=h(()=>{UK();XE=_B,eb=p1});var g1,BA,h1,HK,WK,xbt,jK,qK,GK,c0e,u0e,l0e,A1,d0e,f0e,p0e,m0e=h(()=>{mt();oe();ir();ct();g1="effect/FiberStatus",BA=Symbol.for(g1),h1="Done",HK="Running",WK="Suspended",xbt=Lt(`${g1}-${h1}`),jK=class{[BA]=BA;_tag=h1;[he](){return xbt}[me](t){return A1(t)&&t._tag===h1}},qK=class{runtimeFlags;[BA]=BA;_tag=HK;constructor(t){this.runtimeFlags=t}[he](){return C(ae(g1),we(ae(this._tag)),we(ae(this.runtimeFlags)),We(this))}[me](t){return A1(t)&&t._tag===HK&&this.runtimeFlags===t.runtimeFlags}},GK=class{runtimeFlags;blockingOn;[BA]=BA;_tag=WK;constructor(t,r){this.runtimeFlags=t,this.blockingOn=r}[he](){return C(ae(g1),we(ae(this._tag)),we(ae(this.runtimeFlags)),we(ae(this.blockingOn)),We(this))}[me](t){return A1(t)&&t._tag===WK&&this.runtimeFlags===t.runtimeFlags&&ce(this.blockingOn,t.blockingOn)}},c0e=new jK,u0e=e=>new qK(e),l0e=(e,t)=>new GK(e,t),A1=e=>se(e,BA),d0e=e=>e._tag===h1,f0e=e=>e._tag===HK,p0e=e=>e._tag===WK});var h0e,zK,g0e,hI,A0e,y1,BB=h(()=>{m0e();h0e=c0e,zK=u0e,g0e=l0e,hI=d0e,A0e=f0e,y1=p0e});var bbt,VK,YK,JK,KK,ZK,XK,Sbt,Cbt,eZ,tZ,E1=h(()=>{oe();vt();Lm();bm();bbt=ZCe,VK=XCe,YK=ewe,JK=tK,KK=rK,ZK=nK,XK=twe,Sbt=rwe,Cbt=C(oo,yf(e=>e.ordinal)),eZ=dF(Cbt),tZ=e=>{switch(e){case"All":return bbt;case"Debug":return ZK;case"Error":return YK;case"Fatal":return VK;case"Info":return KK;case"Trace":return XK;case"None":return Sbt;case"Warning":return JK}}});function Dbt(e){return R1("Micro.evaluate: Not implemented")}var wbt,b1,y0e,Ibt,S1,oZ,kbt,iZ,vbt,S0e,x0e,Rbt,C1,E0e,_bt,C0e,Yr,sZ,TA,AI,w1,gI,Bbt,Tbt,B1,DA,w0e,yI,I1,k1,TB,Qbt,Obt,v1,T1,Nbt,Pbt,I0e,Mbt,Fbt,tb,Lbt,Ubt,$bt,D1,Q1,uZ,R1,xI,Hbt,Wbt,_1,jbt,k0e,aZ,cZ,EI,v0e,qbt,Gbt,nZ,b0e,zbt,lZ,Vbt,Ybt,Jbt,Kbt,Zbt,R0e,dZ=h(()=>{wr();sr();id();mt();oe();yn();ir();ht();F_();Me();ct();mu();wbt=Symbol.for("effect/Micro"),b1=Symbol.for("effect/Micro/MicroExit"),y0e=Symbol.for("effect/Micro/MicroCause"),Ibt={_E:be},S1=class extends globalThis.Error{_tag;traces;[y0e];constructor(t,r,n){let o=`MicroCause.${t}`,i,s,a;if(r instanceof globalThis.Error){i=`(${o}) ${r.name}`,s=r.message;let c=s.split(`
44
+ `)}`:this.toString():"Bun"in globalThis?Yl(zl(this),{renderErrorCause:!0}):this}}return Object.assign(e.prototype,iF),e}(),WE=(e,t)=>{class r extends AB{_tag=t}return Object.assign(r.prototype,e),r.prototype.name=t,r},V3=Symbol.for("effect/Cause/errors/RuntimeException"),fwe=WE({[V3]:V3},"RuntimeException"),kL=Symbol.for("effect/Cause/errors/InterruptedException"),pwe=WE({[kL]:kL},"InterruptedException"),sK=e=>se(e,kL),Y3=Symbol.for("effect/Cause/errors/IllegalArgument"),vu=WE({[Y3]:Y3},"IllegalArgumentException"),vL=Symbol.for("effect/Cause/errors/NoSuchElement"),Es=WE({[vL]:vL},"NoSuchElementException"),aK=e=>se(e,vL),J3=Symbol.for("effect/Cause/errors/InvalidPubSubCapacityException"),DIr=WE({[J3]:J3},"InvalidPubSubCapacityException"),K3=Symbol.for("effect/Cause/errors/ExceededCapacityException"),DEt=WE({[K3]:K3},"ExceededCapacityException"),Z3=Symbol.for("effect/Cause/errors/Timeout"),mwe=WE({[Z3]:Z3},"TimeoutException"),hwe=e=>new mwe(`Operation timed out after '${YF(e)}'`),X3=Symbol.for("effect/Cause/errors/UnknownException"),nI=function(){class e extends AB{_tag="UnknownException";error;constructor(r,n){super(n??"An unknown error occurred",{cause:r}),this.error=r}}return Object.assign(e.prototype,{[X3]:X3,name:"UnknownException"}),e}(),jE=e=>ar(e)&&"_tag"in e&&(e._tag==="Success"||e._tag==="Failure"),LL=e=>e._tag==="Failure",yB=e=>e._tag==="Success",gwe=e=>{switch(e._tag){case Rr:return Fw(e.effect_instruction_i0);case _r:return!1}},qE=x(2,(e,t)=>{switch(e._tag){case Rr:return $t(e.effect_instruction_i0);case _r:return Vt(t)}}),oI=e=>qE(e,void 0),Awe=e=>{switch(e._tag){case Rr:return H(e.effect_instruction_i0);case _r:return W()}},CA=(e,t)=>QEt(e,t?.parallel?to:Vr),UL=e=>$t(eo(e)),ywe=x(2,(e,t)=>{switch(e._tag){case Rr:return!1;case _r:return t(e.effect_instruction_i0)}}),nd=e=>$t(zl(e)),$t=e=>{let t=new wL(Rr);return t.effect_instruction_i0=e,t},cK=x(2,(e,t)=>{switch(e._tag){case Rr:return $t(e.effect_instruction_i0);case _r:return t(e.effect_instruction_i0)}}),xwe=x(2,(e,t)=>{switch(e._tag){case Rr:return M($t(e.effect_instruction_i0));case _r:return t(e.effect_instruction_i0)}}),Ewe=e=>C(e,cK(be)),bwe=x(2,(e,t)=>{switch(e._tag){case Rr:return M($t(e.effect_instruction_i0));case _r:return fn(t(e.effect_instruction_i0))}}),Swe=e=>{switch(e._tag){case"Left":return nd(e.left);case"Right":return Vt(e.right)}},Cwe=e=>{switch(e._tag){case"None":return nd(void 0);case"Some":return Vt(e.value)}},wwe=x(2,(e,t)=>{switch(e._tag){case Rr:return t(e.effect_instruction_i0);case _r:return e.effect_instruction_i0}}),xB=e=>$t(Hs(e)),tB=x(2,(e,t)=>{switch(e._tag){case Rr:return $t(e.effect_instruction_i0);case _r:return Vt(t(e.effect_instruction_i0))}}),Iwe=x(2,(e,{onFailure:t,onSuccess:r})=>{switch(e._tag){case Rr:return $t(C(e.effect_instruction_i0,O_(t)));case _r:return Vt(r(e.effect_instruction_i0))}}),kwe=x(2,(e,t)=>{switch(e._tag){case Rr:return $t(C(e.effect_instruction_i0,O_(t)));case _r:return Vt(e.effect_instruction_i0)}}),vwe=x(2,(e,t)=>{switch(e._tag){case Rr:return $t(t(e.effect_instruction_i0));case _r:return Vt(e.effect_instruction_i0)}}),GE=x(2,(e,{onFailure:t,onSuccess:r})=>{switch(e._tag){case Rr:return t(e.effect_instruction_i0);case _r:return r(e.effect_instruction_i0)}}),zE=x(2,(e,{onFailure:t,onSuccess:r})=>{switch(e._tag){case Rr:return t(e.effect_instruction_i0);case _r:return r(e.effect_instruction_i0)}}),Vt=e=>{let t=new IL(_r);return t.effect_instruction_i0=e,t},Pn=Vt(void 0),Rwe=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>[r,n],onFailure:Vr})),_we=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>r,onFailure:Vr})),$L=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>n,onFailure:Vr})),Bwe=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>[r,n],onFailure:to})),Twe=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>r,onFailure:to})),Dwe=x(2,(e,t)=>Ru(e,t,{onSuccess:(r,n)=>n,onFailure:to})),Ru=x(3,(e,t,{onFailure:r,onSuccess:n})=>{switch(e._tag){case Rr:switch(t._tag){case _r:return $t(e.effect_instruction_i0);case Rr:return $t(r(e.effect_instruction_i0,t.effect_instruction_i0))}case _r:switch(t._tag){case _r:return Vt(n(e.effect_instruction_i0,t.effect_instruction_i0));case Rr:return $t(t.effect_instruction_i0)}}}),QEt=(e,t)=>{let r=Co(e);return kr(r)?C(Ur(r),yu(C(Gt(r),tB(Dt)),(n,o)=>C(n,Ru(o,{onSuccess:(i,s)=>C(i,fr(s)),onFailure:t}))),tB(gs),tB(n=>Uo(n)),H):W()},wA=e=>({...gu,[SL]:FCe,state:Ba(LCe([])),commit(){return Cn(this)},blockingOn:e}),wi=()=>O(td,e=>uK(e)),uK=e=>V(()=>wA(e)),Cn=e=>_f(t=>{let r=Qr(e.state);switch(r._tag){case FE:return t(r.effect);case dA:return r.joiners.push(t),OEt(e,t)}},e.blockingOn),HL=x(2,(e,t)=>Df(t,e)),yc=x(2,(e,t)=>V(()=>{let r=Qr(e.state);switch(r._tag){case FE:return!1;case dA:{js(e.state,G3(t));for(let n=0,o=r.joiners.length;n<o;n++)r.joiners[n](t);return!0}}})),lK=x(2,(e,t)=>yc(e,t)),Qwe=x(2,(e,t)=>yc(e,ut(t))),Owe=x(2,(e,t)=>yc(e,pc(t))),iI=x(2,(e,t)=>yc(e,kt(t))),Nwe=x(2,(e,t)=>yc(e,Tf(t))),Pwe=x(2,(e,t)=>yc(e,Ci(t))),Mwe=x(2,(e,t)=>yc(e,Ta(t))),Fwe=e=>O(td,t=>yc(e,aB(t))),EB=x(2,(e,t)=>yc(e,aB(t))),Lwe=e=>V(()=>Qr(e.state)._tag===FE),Uwe=e=>V(()=>{let t=Qr(e.state);switch(t._tag){case FE:return H(t.effect);case dA:return W()}}),Mm=x(2,(e,t)=>yc(e,M(t))),$we=x(2,(e,t)=>yc(e,V(t))),IA=(e,t)=>{let r=Qr(e.state);if(r._tag===dA){js(e.state,G3(t));for(let n=0,o=r.joiners.length;n<o;n++)r.joiners[n](t)}},OEt=(e,t)=>V(()=>{let r=Qr(e.state);if(r._tag===dA){let n=r.joiners.indexOf(t);n>=0&&r.joiners.splice(n,1)}}),NEt=st(e=>Vt(e.currentContext)),Oa=()=>NEt,xc=e=>O(Oa(),e),zs=x(2,(e,t)=>tn(li,t)(e)),WL=x(2,(e,t)=>no(li,r=>wo(r,t))(e)),kA=x(2,(e,t)=>xc(r=>zs(e,t(r)))),dK=x(2,(e,t)=>O(e,r=>O(t.predicate(r),n=>n?M(r):t.orElse(r)))),Hwe=x(2,(e,t)=>dK(e,{predicate:t.predicate,orElse:r=>ut(t.orFailWith(r))})),jL=e=>{let t=e.currentSpan;return t!==void 0&&t._tag==="Span"?H(t):W()},PEt={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:BigInt(0),endTime:BigInt(0),exit:Pn},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},Wwe=e=>Object.assign(Object.create(PEt),e)});var jwe,VE,od,qL,qwe,Gwe,zwe,Vwe,fK,GL,Ywe,Jwe,sI,zL,Fm,pK,Kwe,bB,Zwe,VL,Vs=h(()=>{Jl();vt();jwe=Yi,VE=zl,od=eo,qL=Hs,qwe=to,Gwe=Vr,zwe=T_,Vwe=rSe,fK=QE,GL=Fw,Ywe=OE,Jwe=NE,sI=Vl,zL=nSe,Fm=O_,pK=lwe,Kwe=N_,bB=vu,Zwe=Es,VL=Yl});var MEt,YE,bs,FEt,Xwe,eIe,LEt,mK,YL,JE=h(()=>{sr();Ws();oe();vt();MEt="effect/Clock",YE=Symbol.for(MEt),bs=Jt("effect/Clock"),FEt=2**31-1,Xwe={unsafeSchedule(e,t){let r=Io(t);if(r>FEt)return Gi;let n=!1,o=setTimeout(()=>{n=!0,e()},r);return()=>(clearTimeout(o),!n)}},eIe=function(){let e=BigInt(1e6);if(typeof performance>"u"||typeof performance.now!="function")return()=>BigInt(Date.now())*e;let t;return()=>(t===void 0&&(t=BigInt(Date.now())*e-BigInt(Math.round(performance.now()*1e6))),t+BigInt(Math.round(performance.now()*1e6)))}(),LEt=function(){let e=typeof process=="object"&&"hrtime"in process&&typeof process.hrtime.bigint=="function"?process.hrtime:void 0;if(!e)return eIe;let t=eIe()-e.bigint();return()=>t+e.bigint()}(),mK=class{[YE]=YE;unsafeCurrentTimeMillis(){return Date.now()}unsafeCurrentTimeNanos(){return LEt()}currentTimeMillis=V(()=>this.unsafeCurrentTimeMillis());currentTimeNanos=V(()=>this.unsafeCurrentTimeNanos());scheduler(){return M(Xwe)}sleep(t){return Si(r=>{let n=Xwe.unsafeSchedule(()=>r(Ue),t);return $r(V(n))})}},YL=()=>new mK});var oo,Lm=h(()=>{bm();oo=WEe});var aI,KL=h(()=>{aI=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&")});var gK,AK,yK,xK,EK,bK,tIe=h(()=>{gK="And",AK="Or",yK="InvalidData",xK="MissingData",EK="SourceUnavailable",bK="Unsupported"});var WEt,rIe,cI,SK,CK,jEt,Um,qEt,GEt,RA,wK=h(()=>{wr();oe();tIe();WEt="effect/ConfigError",rIe=Symbol.for(WEt),cI={_tag:"ConfigError",[rIe]:rIe},SK=(e,t)=>{let r=Object.create(cI);return r._op=gK,r.left=e,r.right=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`${this.left} and ${this.right}`}}),Object.defineProperty(r,"message",{enumerable:!1,get(){return this.toString()}}),r},CK=(e,t)=>{let r=Object.create(cI);return r._op=AK,r.left=e,r.right=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`${this.left} or ${this.right}`}}),Object.defineProperty(r,"message",{enumerable:!1,get(){return this.toString()}}),r},jEt=(e,t,r={pathDelim:"."})=>{let n=Object.create(cI);return n._op=yK,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Invalid data at ${C(this.path,Im(r.pathDelim))}: "${this.message}")`}}),n},Um=(e,t,r={pathDelim:"."})=>{let n=Object.create(cI);return n._op=xK,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Missing data at ${C(this.path,Im(r.pathDelim))}: "${this.message}")`}}),n},qEt=(e,t,r,n={pathDelim:"."})=>{let o=Object.create(cI);return o._op=EK,o.path=e,o.message=t,o.cause=r,Object.defineProperty(o,"toString",{enumerable:!1,value(){return`(Source unavailable at ${C(this.path,Im(n.pathDelim))}: "${this.message}")`}}),o},GEt=(e,t,r={pathDelim:"."})=>{let n=Object.create(cI);return n._op=bK,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Unsupported operation at ${C(this.path,Im(r.pathDelim))}: "${this.message}")`}}),n},RA=x(2,(e,t)=>{switch(e._op){case gK:return SK(RA(e.left,t),RA(e.right,t));case AK:return CK(RA(e.left,t),RA(e.right,t));case yK:return jEt([...t,...e.path],e.message);case xK:return Um([...t,...e.path],e.message);case EK:return qEt([...t,...e.path],e.message,e.cause);case bK:return GEt([...t,...e.path],e.message)}})});var oIe,ZL,iIe=h(()=>{wr();bi();oe();Gw();it();wK();oIe={_tag:"Empty"},ZL=x(2,(e,t)=>{let r=G_(t),n=e;for(;g3(r);){let o=r.head;switch(o._tag){case"Empty":{r=r.tail;break}case"AndThen":{r=_m(o.first,_m(o.second,r.tail));break}case"MapName":{n=$l(n,o.f),r=r.tail;break}case"Nested":{n=Rw(n,o.name),r=r.tail;break}case"Unnested":{if(C(wm(n),s6(o.name)))n=Ll(n),r=r.tail;else return Re(Um(n,`Expected ${o.name} to be in path in ConfigProvider#unnested`));break}}}return Le(n)})});var sIe,aIe,cIe,uIe,lIe,dIe,fIe,pIe,mIe,hIe,gIe,AIe=h(()=>{sIe="Constant",aIe="Fail",cIe="Fallback",uIe="Described",lIe="Lazy",dIe="MapOrFail",fIe="Nested",pIe="Primitive",mIe="Sequence",hIe="HashMap",gIe="ZipWith"});var XL,JEt,yIe,uI,KEt,xIe,ZEt,XEt,ebt,EIe,tbt,rbt,Bu,nbt,obt,ibt,sbt,abt,cbt,ubt,lbt,IK=h(()=>{wr();sr();bi();oe();kf();dc();Lm();it();Me();KL();wK();iIe();vt();AIe();XL=(e,t)=>[...e,...t],JEt="effect/ConfigProvider",yIe=Symbol.for(JEt),uI=Jt("effect/ConfigProvider"),KEt="effect/ConfigProviderFlat",xIe=Symbol.for(KEt),ZEt=e=>({[yIe]:yIe,pipe(){return Z(this,arguments)},...e}),XEt=e=>({[xIe]:xIe,patch:e.patch,load:(t,r,n=!0)=>e.load(t,r,n),enumerateChildren:e.enumerateChildren}),ebt=e=>ZEt({load:t=>O(Bu(e,Us(),t,!1),r=>wt(wm(r),{onNone:()=>ut(Um(Us(),`Expected a single value having structure: ${t}`)),onSome:M})),flattened:e}),EIe=e=>{let{pathDelim:t,seqDelim:r}=Object.assign({},{pathDelim:"_",seqDelim:","},e),n=c=>C(c,Im(t)),o=c=>c.split(t),i=()=>typeof process<"u"&&"env"in process&&typeof process.env=="object"?process.env:{};return ebt(XEt({load:(c,u,l=!0)=>{let d=n(c),f=i(),p=d in f?H(f[d]):W();return C(p,hA(()=>Um(c,`Expected ${d} to exist in the process context`)),O(m=>ibt(m,c,u,r,l)))},enumerateChildren:c=>V(()=>{let u=i(),f=Object.keys(u).map(p=>o(p.toUpperCase())).filter(p=>{for(let m=0;m<c.length;m++){let g=C(c,h6(m)),A=p[m];if(A===void 0||g!==A)return!1}return!0}).flatMap(p=>p.slice(c.length,c.length+1));return MF(f)}),patch:oIe}))},tbt=(e,t,r,n)=>{let o=b6(r.length,c=>c>=n.length?W():H([e(c),c+1])),i=b6(n.length,c=>c>=r.length?W():H([t(c),c+1])),s=XL(r,o),a=XL(n,i);return[s,a]},rbt=(e,t)=>{let r=t;if(r._tag==="Nested"){let n=e.slice();for(;r._tag==="Nested";)n.push(r.name),r=r.config;return n}return e},Bu=(e,t,r,n)=>{let o=r;switch(o._tag){case sIe:return M(hs(o.value));case uIe:return ye(()=>Bu(e,t,o.config,n));case aIe:return ut(Um(t,o.message));case cIe:return C(ye(()=>Bu(e,t,o.first,n)),fc(i=>o.condition(i)?C(Bu(e,t,o.second,n),fc(s=>ut(CK(i,s)))):ut(i)));case lIe:return ye(()=>Bu(e,t,o.config(),n));case dIe:return ye(()=>C(Bu(e,t,o.original,n),O(Wo(i=>C(o.mapOrFail(i),hA(RA(rbt(t,o.original))))))));case fIe:return ye(()=>Bu(e,XL(t,hs(o.name)),o.config,n));case pIe:return C(ZL(t,e.patch),O(i=>C(e.load(i,o,n),O(s=>{if(s.length===0){let a=C(EF(i),Nt(()=>"<n/a>"));return ut(Um([],`Expected ${o.description} with name ${a}`))}return M(s)}))));case mIe:return C(ZL(t,e.patch),O(i=>C(e.enumerateChildren(i),O(abt),O(s=>s.length===0?ye(()=>te(Bu(e,t,o.config,!0),hs)):C(Wo(s,a=>Bu(e,p6(t,`[${a}]`),o.config,!0)),te(a=>{let c=b_(a);return c.length===0?hs(Us()):hs(c)}))))));case hIe:return ye(()=>C(ZL(t,e.patch),O(i=>C(e.enumerateChildren(i),O(s=>C(s,Wo(a=>Bu(e,XL(i,hs(a)),o.valueConfig,n)),te(a=>a.length===0?hs(If()):C(sbt(a),$l(c=>KSe(A6(_e(s),c)))))))))));case gIe:return ye(()=>C(Bu(e,t,o.left,n),wu,O(i=>C(Bu(e,t,o.right,n),wu,O(s=>{if(xr(i)&&xr(s))return ut(SK(i.left,s.left));if(xr(i)&&si(s))return ut(i.left);if(si(i)&&xr(s))return ut(s.left);if(si(i)&&si(s)){let a=C(t,Im(".")),c=nbt(t,a),[u,l]=tbt(c,c,C(i.right,$l(Le)),C(s.right,$l(Le)));return C(u,A6(l),Wo(([d,f])=>C(Nm(d,f),te(([p,m])=>o.zip(p,m)))))}throw new Error("BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues")})))))}},nbt=(e,t)=>r=>Re(Um(e,`The element at index ${r} in a sequence at path "${t}" was missing`)),obt=(e,t)=>e.split(new RegExp(`\\s*${aI(t)}\\s*`)),ibt=(e,t,r,n,o)=>o?C(obt(e,n),Wo(i=>r.parse(i.trim())),hA(RA(t))):C(r.parse(e),cB({onFailure:RA(t),onSuccess:hs})),sbt=e=>Object.keys(e[0]).map(t=>e.map(r=>r[t])),abt=e=>C(Wo(e,ubt),cB({onFailure:()=>Us(),onSuccess:Vi(oo)}),wu,te(vw)),cbt=/^(\[(\d+)\])$/,ubt=e=>{let t=e.match(cbt);if(t!==null){let r=t[2];return C(r!==void 0&&r.length>0?H(r):W(),Gn(lbt))}return W()},lbt=e=>{let t=Number.parseInt(e);return Number.isNaN(t)?W():H(t)}});var bIe,$m,SIe,e1=h(()=>{sr();vt();bIe=Symbol.for("effect/Console"),$m=Jt("effect/Console"),SIe={[bIe]:bIe,assert(e,...t){return V(()=>{console.assert(e,...t)})},clear:V(()=>{console.clear()}),count(e){return V(()=>{console.count(e)})},countReset(e){return V(()=>{console.countReset(e)})},debug(...e){return V(()=>{console.debug(...e)})},dir(e,t){return V(()=>{console.dir(e,t)})},dirxml(...e){return V(()=>{console.dirxml(...e)})},error(...e){return V(()=>{console.error(...e)})},group(e){return e?.collapsed?V(()=>console.groupCollapsed(e?.label)):V(()=>console.group(e?.label))},groupEnd:V(()=>{console.groupEnd()}),info(...e){return V(()=>{console.info(...e)})},log(...e){return V(()=>{console.log(...e)})},table(e,t){return V(()=>{console.table(e,t)})},time(e){return V(()=>console.time(e))},timeEnd(e){return V(()=>console.timeEnd(e))},timeLog(e,...t){return V(()=>{console.timeLog(e,...t)})},trace(...e){return V(()=>{console.trace(...e)})},warn(...e){return V(()=>{console.warn(...e)})},unsafe:console}});var fbt,SB,Hm,kK,wIe,pbt,RK,vK,IIe,CB=h(()=>{vr();sr();oe();ir();mu();vt();fbt="effect/Random",SB=Symbol.for(fbt),Hm=Jt("effect/Random"),kK=class{seed;[SB]=SB;PRNG;constructor(t){this.seed=t,this.PRNG=new ZM(t)}get next(){return V(()=>this.PRNG.number())}get nextBoolean(){return te(this.next,t=>t>.5)}get nextInt(){return V(()=>this.PRNG.integer(Number.MAX_SAFE_INTEGER))}nextRange(t,r){return te(this.next,n=>(r-t)*n+t)}nextIntBetween(t,r){return V(()=>this.PRNG.integer(r-t)+t)}shuffle(t){return wIe(t,r=>this.nextIntBetween(0,r))}},wIe=(e,t)=>ye(()=>C(V(()=>Array.from(e)),O(r=>{let n=[];for(let o=r.length;o>=2;o=o-1)n.push(o);return C(n,mc(o=>C(t(o),te(i=>pbt(r,o-1,i)))),Zt(Co(r)))}))),pbt=(e,t,r)=>{let n=e[t];return e[t]=e[r],e[r]=n,e},RK=e=>new kK(ae(e)),vK=class{values;[SB]=SB;index=0;constructor(t){if(this.values=t,t.length===0)throw new Error("Requires at least one value")}getNextValue(){let t=this.values[this.index];return this.index=(this.index+1)%this.values.length,t}get next(){return V(()=>{let t=this.getNextValue();return typeof t=="number"?Math.max(0,Math.min(1,t)):ae(t)/2147483647})}get nextBoolean(){return V(()=>{let t=this.getNextValue();return typeof t=="boolean"?t:ae(t)%2===0})}get nextInt(){return V(()=>{let t=this.getNextValue();return typeof t=="number"&&Number.isFinite(t)?Math.round(t):Math.abs(ae(t))})}nextRange(t,r){return te(this.next,n=>(r-t)*n+t)}nextIntBetween(t,r){return V(()=>{let n=this.getNextValue();if(typeof n=="number"&&Number.isFinite(n))return Math.max(t,Math.min(r-1,Math.round(n)));let o=Math.abs(ae(n));return t+o%(r-t)})}shuffle(t){return wIe(t,r=>this.nextIntBetween(0,r))}},IIe=e=>new vK(e)});var _K,RIe,Pf,Ii,vIe,BK,_Ie,Ec,KE,_A=h(()=>{sr();oe();_K=Symbol.for("effect/Tracer"),RIe=e=>({[_K]:_K,...e}),Pf=Jt("effect/Tracer"),Ii=Jt("effect/ParentSpan"),vIe=function(){let e="abcdef0123456789",t=e.length;return function(r){let n="";for(let o=0;o<r;o++)n+=e.charAt(Math.floor(Math.random()*t));return n}}(),BK=class{name;parent;context;startTime;kind;_tag="Span";spanId;traceId="native";sampled=!0;status;attributes;events=[];links;constructor(t,r,n,o,i,s){this.name=t,this.parent=r,this.context=n,this.startTime=i,this.kind=s,this.status={_tag:"Started",startTime:i},this.attributes=new Map,this.traceId=r._tag==="Some"?r.value.traceId:vIe(32),this.spanId=vIe(16),this.links=Array.from(o)}end(t,r){this.status={_tag:"Ended",endTime:t,exit:r,startTime:this.status.startTime}}attribute(t,r){this.attributes.set(t,r)}event(t,r,n){this.events.push([t,r,n??{}])}addLinks(t){this.links.push(...t)}},_Ie=RIe({span:(e,t,r,n,o,i)=>new BK(e,t,r,n,o,i),context:e=>e()}),Ec=e=>{if(e?.captureStackTrace===!1)return e;if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!="boolean")return e;let t=Error.stackTraceLimit;Error.stackTraceLimit=3;let r=new Error;Error.stackTraceLimit=t;let n=!1;return{...e,captureStackTrace:()=>{if(n!==!1)return n;if(r.stack!==void 0){let o=r.stack.split(`
45
+ `);if(o[3]!==void 0)return n=o[3].trim(),n}}}},KE=ai()("effect/Tracer/DisablePropagation",{defaultValue:Gi})});var mbt,mn,BIe,t1,wB,TIe,DIe,QIe,OIe,NIe,lI,PIe,MIe,r1,FIe,Mf=h(()=>{sr();Ws();oe();yn();JE();IK();vt();e1();CB();_A();mbt=C(ro(),zt(bs,YL()),zt($m,SIe),zt(Hm,RK(Math.random())),zt(uI,EIe()),zt(Pf,_Ie)),mn=Te(Symbol.for("effect/DefaultServices/currentServices"),()=>lB(mbt)),BIe=e=>{let t=At(e);return wB(r=>r.sleep(t))},t1=e=>st(t=>e(t.currentDefaultServices)),wB=e=>t1(t=>e(t.unsafeMap.get(bs.key))),TIe=wB(e=>e.currentTimeMillis),DIe=wB(e=>e.currentTimeNanos),QIe=x(2,(e,t)=>no(mn,zt(bs,t))(e)),OIe=x(2,(e,t)=>no(mn,zt(uI,t))(e)),NIe=e=>t1(t=>e(t.unsafeMap.get(uI.key))),lI=e=>t1(t=>e(t.unsafeMap.get(Hm.key))),PIe=x(2,(e,t)=>no(mn,zt(Hm,t))(e)),MIe=lI(e=>e.next),r1=e=>t1(t=>e(t.unsafeMap.get(Pf.key))),FIe=x(2,(e,t)=>no(mn,zt(Pf,t))(e))});var LIe,TK=h(()=>{LIe=e=>!e});var $Ie,n1,hbt,gbt,Ys,dI,id=h(()=>{Af();$Ie=Em,n1=gu,hbt=_Ee,gbt=BEe,Ys=class extends hbt{},dI=class extends gbt{}});var HIe,WIe,Abt,Tu,IB,jIe,DK,QK,kB=h(()=>{HIe="Sequential",WIe="Parallel",Abt="ParallelN",Tu={_tag:HIe},IB={_tag:WIe},jIe=e=>({_tag:Abt,parallelism:e}),DK=e=>e._tag===HIe,QK=e=>e._tag===WIe});var fI,i1,s1,a1=h(()=>{kB();fI=Tu,i1=IB,s1=jIe});function qIe(e){return new Lf(e)}function GIe(){return qIe(new Map)}var NK,Lf,ybt,c1,MK,zIe,VIe,YIe,vB,u1,jm,pI,PK,JIe,l1=h(()=>{wr();mt();oe();dc();it();Me();vt();NK=Symbol.for("effect/FiberRefs"),Lf=class{locals;[NK]=NK;constructor(t){this.locals=t}pipe(){return Z(this,arguments)}},ybt=(e,t,r,n=!1)=>{let o=e,i=t,s=r,a=n,c;for(;c===void 0;)if(zr(i)&&zr(s)){let u=Lo(i)[0],l=Ll(i),d=Lo(s)[0],f=Lo(s)[1],p=Ll(s);u.startTimeMillis<d.startTimeMillis?(s=p,a=!0):u.startTimeMillis>d.startTimeMillis?i=l:u.id<d.id?(s=p,a=!0):u.id>d.id?i=l:c=[f,a]}else c=[o.initial,!0];return c},c1=x(3,(e,t,r)=>{let n=new Map(e.locals);return r.locals.forEach((o,i)=>{let s=o[0][1];if(!o[0][0][me](t)){if(!n.has(i)){if(ce(s,i.initial))return;n.set(i,[[t,i.join(i.initial,s)]]);return}let a=n.get(i),[c,u]=ybt(i,a,o);if(u){let l=i.diff(c,s),d=a[0][1],f=i.join(d,i.patch(l)(d));if(!ce(d,f)){let p,m=a[0][0];m[me](t)?p=[[m,f],...a.slice(1)]:p=[[t,f],...a],n.set(i,p)}}}}),new Lf(n)}),MK=x(2,(e,t)=>{let r=new Map;return zIe(e,r,t),new Lf(r)}),zIe=(e,t,r)=>{e.locals.forEach((n,o)=>{let i=n[0][1],s=o.patch(o.fork)(i);ce(i,s)?t.set(o,n):t.set(o,[[r,s],...n])})},VIe=e=>MF(e.locals.keys()),YIe=e=>mc(VIe(e),t=>Dm(t,jm(e,t))),vB=x(2,(e,t)=>{let r=new Map(e.locals);return r.delete(t),new Lf(r)}),u1=x(2,(e,t)=>e.locals.has(t)?H(Lo(e.locals.get(t))[1]):W()),jm=x(2,(e,t)=>C(u1(e,t),Nt(()=>t.initial))),pI=x(2,(e,{fiberId:t,fiberRef:r,value:n})=>{if(e.locals.size===0)return new Lf(new Map([[r,[[t,n]]]]));let o=new Map(e.locals);return PK(o,t,r,n),new Lf(o)}),PK=(e,t,r,n)=>{let o=e.get(r)??[],i;if(zr(o)){let[s,a]=Lo(o);if(s[me](t)){if(ce(a,n))return;i=[[t,n],...o.slice(1)]}else i=[[t,n],...o]}else i=[[t,n]];e.set(r,i)},JIe=x(2,(e,{entries:t,forkAs:r})=>{if(e.locals.size===0)return new Lf(new Map(t));let n=new Map(e.locals);return r!==void 0&&zIe(e,n,r),t.forEach(([o,i])=>{i.length===1?PK(n,i[0][0],o,i[0][1]):i.forEach(([s,a])=>{PK(n,s,o,a)})}),new Lf(n)})});var LK,d1,KIe,ZIe,XIe,e0e,mI=h(()=>{l1();LK=u1,d1=jm,KIe=c1,ZIe=YIe,XIe=JIe,e0e=GIe});var t0e,r0e,n0e,o0e,i0e,s0e,_B,f1,p1,UK=h(()=>{wr();mt();oe();l1();t0e="Empty",r0e="Add",n0e="Remove",o0e="Update",i0e="AndThen",s0e={_tag:t0e},_B=(e,t)=>{let r=new Map(e.locals),n=s0e;for(let[o,i]of t.locals.entries()){let s=Lo(i)[1],a=r.get(o);if(a!==void 0){let c=Lo(a)[1];ce(c,s)||(n=f1({_tag:o0e,fiberRef:o,patch:o.diff(c,s)})(n))}else n=f1({_tag:r0e,fiberRef:o,value:s})(n);r.delete(o)}for(let[o]of r.entries())n=f1({_tag:n0e,fiberRef:o})(n);return n},f1=x(2,(e,t)=>({_tag:i0e,first:e,second:t})),p1=x(3,(e,t,r)=>{let n=r,o=hs(e);for(;zr(o);){let i=Lo(o),s=Ll(o);switch(i._tag){case t0e:{o=s;break}case r0e:{n=pI(n,{fiberId:t,fiberRef:i.fiberRef,value:i.value}),o=s;break}case n0e:{n=vB(n,i.fiberRef),o=s;break}case o0e:{let a=jm(n,i.fiberRef);n=pI(n,{fiberId:t,fiberRef:i.fiberRef,value:i.fiberRef.patch(i.patch)(a)}),o=s;break}case i0e:{o=Rw(i.first)(Rw(i.second)(s));break}}}return n})});var XE,eb,m1=h(()=>{UK();XE=_B,eb=p1});var g1,BA,h1,HK,WK,xbt,jK,qK,GK,c0e,u0e,l0e,A1,d0e,f0e,p0e,m0e=h(()=>{mt();oe();ir();ct();g1="effect/FiberStatus",BA=Symbol.for(g1),h1="Done",HK="Running",WK="Suspended",xbt=Lt(`${g1}-${h1}`),jK=class{[BA]=BA;_tag=h1;[he](){return xbt}[me](t){return A1(t)&&t._tag===h1}},qK=class{runtimeFlags;[BA]=BA;_tag=HK;constructor(t){this.runtimeFlags=t}[he](){return C(ae(g1),we(ae(this._tag)),we(ae(this.runtimeFlags)),We(this))}[me](t){return A1(t)&&t._tag===HK&&this.runtimeFlags===t.runtimeFlags}},GK=class{runtimeFlags;blockingOn;[BA]=BA;_tag=WK;constructor(t,r){this.runtimeFlags=t,this.blockingOn=r}[he](){return C(ae(g1),we(ae(this._tag)),we(ae(this.runtimeFlags)),we(ae(this.blockingOn)),We(this))}[me](t){return A1(t)&&t._tag===WK&&this.runtimeFlags===t.runtimeFlags&&ce(this.blockingOn,t.blockingOn)}},c0e=new jK,u0e=e=>new qK(e),l0e=(e,t)=>new GK(e,t),A1=e=>se(e,BA),d0e=e=>e._tag===h1,f0e=e=>e._tag===HK,p0e=e=>e._tag===WK});var h0e,zK,g0e,hI,A0e,y1,BB=h(()=>{m0e();h0e=c0e,zK=u0e,g0e=l0e,hI=d0e,A0e=f0e,y1=p0e});var bbt,VK,YK,JK,KK,ZK,XK,Sbt,Cbt,eZ,tZ,E1=h(()=>{oe();vt();Lm();bm();bbt=ZCe,VK=XCe,YK=ewe,JK=tK,KK=rK,ZK=nK,XK=twe,Sbt=rwe,Cbt=C(oo,yf(e=>e.ordinal)),eZ=dF(Cbt),tZ=e=>{switch(e){case"All":return bbt;case"Debug":return ZK;case"Error":return YK;case"Fatal":return VK;case"Info":return KK;case"Trace":return XK;case"None":return Sbt;case"Warning":return JK}}});function Dbt(e){return R1("Micro.evaluate: Not implemented")}var wbt,b1,y0e,Ibt,S1,oZ,kbt,iZ,vbt,S0e,x0e,Rbt,C1,E0e,_bt,C0e,Yr,sZ,TA,AI,w1,gI,Bbt,Tbt,B1,DA,w0e,yI,I1,k1,TB,Qbt,Obt,v1,T1,Nbt,Pbt,I0e,Mbt,Fbt,tb,Lbt,Ubt,$bt,D1,Q1,uZ,R1,xI,Hbt,Wbt,_1,jbt,k0e,aZ,cZ,EI,v0e,qbt,Gbt,nZ,b0e,zbt,lZ,Vbt,Ybt,Jbt,Kbt,Zbt,R0e,dZ=h(()=>{wr();sr();id();mt();oe();yn();ir();ht();F_();Me();ct();mu();wbt=Symbol.for("effect/Micro"),b1=Symbol.for("effect/Micro/MicroExit"),y0e=Symbol.for("effect/Micro/MicroCause"),Ibt={_E:be},S1=class extends globalThis.Error{_tag;traces;[y0e];constructor(t,r,n){let o=`MicroCause.${t}`,i,s,a;if(r instanceof globalThis.Error){i=`(${o}) ${r.name}`,s=r.message;let c=s.split(`
46
46
  `).length;a=r.stack?`(${o}) ${r.stack.split(`
47
47
  `).slice(0,c+3).join(`
48
48
  `)}`:`${i}: ${s}`}else i=o,s=ym(r,0),a=`${i}: ${s}`;n.length>0&&(a+=`
49
49
  ${n.join(`
50
- `)}`),super(s),this._tag=t,this.traces=n,this[y0e]=Ibt,this.name=i,this.stack=a}pipe(){return Z(this,arguments)}toString(){return this.stack}[Ce](){return this.stack}},oZ=class extends S1{defect;constructor(t,r=[]){super("Die",t,r),this.defect=t}},kbt=(e,t=[])=>new oZ(e,t),iZ=class extends S1{constructor(t=[]){super("Interrupt","interrupted",t)}},vbt=(e=[])=>new iZ(e),S0e=e=>e._tag==="Interrupt",x0e=Symbol.for("effect/Micro/MicroFiber"),Rbt={_A:be,_E:be},C1=class{context;interruptible;[x0e];_stack=[];_observers=[];_exit;_children;currentOpCount=0;constructor(t,r=!0){this.context=t,this.interruptible=r,this[x0e]=Rbt}getRef(t){return mSe(this.context,t)}addObserver(t){return this._exit?(t(this._exit),Ai):(this._observers.push(t),()=>{let r=this._observers.indexOf(t);r>=0&&this._observers.splice(r,1)})}_interrupted=!1;unsafeInterrupt(){this._exit||(this._interrupted=!0,this.interruptible&&this.evaluate(uZ))}unsafePoll(){return this._exit}evaluate(t){if(this._exit)return;if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let r=this.runLoop(t);if(r===gI)return;let n=E0e.interruptChildren&&E0e.interruptChildren(this);if(n!==void 0)return this.evaluate(tb(n,()=>r));this._exit=r;for(let o=0;o<this._observers.length;o++)this._observers[o](r);this._observers.length=0}runLoop(t){let r=!1,n=t;this.currentOpCount=0;try{for(;;){if(this.currentOpCount++,!r&&this.getRef(EI).shouldYield(this)){r=!0;let o=n;n=tb(Obt,()=>o)}if(n=n[sZ](this),n===gI){let o=this._yielded;return b1 in o?(this._yielded=void 0,o):gI}}}catch(o){return se(n,sZ)?R1(o):R1(`MicroFiber.runLoop: Not a valid effect: ${String(n)}`)}}getCont(t){for(;;){let r=this._stack.pop();if(!r)return;let n=r[w1]&&r[w1](this);if(n)return{[t]:n};if(r[t])return r}}_yielded=void 0;yieldWith(t){return this._yielded=t,gI}children(){return this._children??=new Set}},E0e=Te("effect/Micro/fiberMiddleware",()=>({interruptChildren:void 0})),_bt=e=>TB(()=>{for(let n of e)n.unsafeInterrupt();let t=e[Symbol.iterator](),r=TB(()=>{let n=t.next();for(;!n.done;){if(n.value.unsafePoll()){n=t.next();continue}let o=n.value;return I0e(i=>{o.addObserver(s=>{i(r)})})}return xI});return r}),C0e=Symbol.for("effect/Micro/identifier"),Yr=Symbol.for("effect/Micro/args"),sZ=Symbol.for("effect/Micro/evaluate"),TA=Symbol.for("effect/Micro/successCont"),AI=Symbol.for("effect/Micro/failureCont"),w1=Symbol.for("effect/Micro/ensureCont"),gI=Symbol.for("effect/Micro/Yield"),Bbt={_A:be,_E:be,_R:be},Tbt={...$Ie,_op:"Micro",[wbt]:Bbt,pipe(){return Z(this,arguments)},[Symbol.iterator](){return new mE(new hf(this))},toJSON(){return{_id:"Micro",op:this[C0e],...Yr in this?{args:this[Yr]}:void 0}},toString(){return Fe(this)},[Ce](){return Fe(this)}};B1=e=>({...Tbt,[C0e]:e.op,[sZ]:e.eval??Dbt,[TA]:e.contA,[AI]:e.contE,[w1]:e.ensure}),DA=e=>{let t=B1(e);return function(){let r=Object.create(t);return r[Yr]=e.single===!1?arguments:arguments[0],r}},w0e=e=>{let t={...B1(e),[b1]:b1,_tag:e.op,get[e.prop](){return this[Yr]},toJSON(){return{_id:"MicroExit",_tag:e.op,[e.prop]:this[Yr]}},[me](r){return $bt(r)&&r._tag===e.op&&ce(this[Yr],r[Yr])},[he](){return We(this,we(Lt(e.op))(ae(this[Yr])))}};return function(r){let n=Object.create(t);return n[Yr]=r,n[TA]=void 0,n[AI]=void 0,n[w1]=void 0,n}},yI=w0e({op:"Success",prop:"value",eval(e){let t=e.getCont(TA);return t?t[TA](this[Yr],e):e.yieldWith(this)}}),I1=w0e({op:"Failure",prop:"cause",eval(e){let t=e.getCont(AI);for(;S0e(this[Yr])&&t&&e.interruptible;)t=e.getCont(AI);return t?t[AI](this[Yr],e):e.yieldWith(this)}}),k1=DA({op:"Sync",eval(e){let t=this[Yr](),r=e.getCont(TA);return r?r[TA](t,e):e.yieldWith(D1(t))}}),TB=DA({op:"Suspend",eval(e){return this[Yr]()}}),Qbt=DA({op:"Yield",eval(e){let t=!1;return e.getRef(EI).scheduleTask(()=>{t||e.evaluate(xI)},this[Yr]??0),e.yieldWith(()=>{t=!0})}}),Obt=Qbt(0),v1=yI(void 0),T1=DA({op:"WithMicroFiber",eval(e){return this[Yr](e)}}),Nbt=DA({op:"Async",single:!1,eval(e){let t=this[Yr][0],r=!1,n=!1,o=this[Yr][1]?new AbortController:void 0,i=t(s=>{r||(r=!0,n?e.evaluate(s):n=s)},o?.signal);return n!==!1?n:(n=!0,e._yielded=()=>{r=!0},o===void 0&&i===void 0||e._stack.push(Pbt(()=>(r=!0,o?.abort(),i??xI))),gI)}}),Pbt=DA({op:"AsyncFinalizer",ensure(e){e.interruptible&&(e.interruptible=!1,e._stack.push(lZ(!0)))},contE(e,t){return S0e(e)?tb(this[Yr](),()=>I1(e)):I1(e)}}),I0e=e=>Nbt(e,e.length>=2),Mbt=x(2,(e,t)=>Ubt(e,r=>t)),Fbt=e=>Gbt(e,{onFailure:Q1,onSuccess:D1}),tb=x(2,(e,t)=>{let r=Object.create(Lbt);return r[Yr]=e,r[TA]=t,r}),Lbt=B1({op:"OnSuccess",eval(e){return e._stack.push(this),this[Yr]}}),Ubt=x(2,(e,t)=>tb(e,r=>yI(t(r)))),$bt=e=>se(e,b1),D1=yI,Q1=I1,uZ=Q1(vbt()),R1=e=>Q1(kbt(e)),xI=D1(void 0),Hbt=e=>{for(let t of e)if(t._tag==="Failure")return t;return xI},Wbt="setImmediate"in globalThis?globalThis.setImmediate:e=>setTimeout(e,0),_1=class{tasks=[];running=!1;scheduleTask(t,r){this.tasks.push(t),this.running||(this.running=!0,Wbt(this.afterScheduled))}afterScheduled=()=>{this.running=!1,this.runTasks()};runTasks(){let t=this.tasks;this.tasks=[];for(let r=0,n=t.length;r<n;r++)t[r]()}shouldYield(t){return t.currentOpCount>=t.getRef(aZ)}flush(){for(;this.tasks.length>0;)this.runTasks()}},jbt=x(2,(e,t)=>T1(r=>{let n=r.context;return r.context=t(n),zbt(e,()=>(r.context=n,v1))})),k0e=x(2,(e,t)=>jbt(e,wo(t))),aZ=class extends si()("effect/Micro/currentMaxOpsBeforeYield",{defaultValue:()=>2048}){},cZ=class extends si()("effect/Micro/currentConcurrency",{defaultValue:()=>"unbounded"}){},EI=class extends si()("effect/Micro/currentScheduler",{defaultValue:()=>new _1}){},v0e=x(2,(e,t)=>{let r=Object.create(qbt);return r[Yr]=e,r[TA]=t.onSuccess,r[AI]=t.onFailure,r}),qbt=B1({op:"OnSuccessAndFailure",eval(e){return e._stack.push(this),this[Yr]}}),Gbt=x(2,(e,t)=>v0e(e,{onFailure:r=>k1(()=>t.onFailure(r)),onSuccess:r=>k1(()=>t.onSuccess(r))})),nZ=Symbol.for("effect/Micro/MicroScope"),b0e=class e{[nZ];state={_tag:"Open",finalizers:new Set};constructor(){this[nZ]=nZ}unsafeAddFinalizer(t){this.state._tag==="Open"&&this.state.finalizers.add(t)}addFinalizer(t){return TB(()=>this.state._tag==="Open"?(this.state.finalizers.add(t),v1):t(this.state.exit))}unsafeRemoveFinalizer(t){this.state._tag==="Open"&&this.state.finalizers.delete(t)}close(t){return TB(()=>{if(this.state._tag==="Open"){let r=Array.from(this.state.finalizers).reverse();return this.state={_tag:"Closed",exit:t},tb(Kbt(r,n=>Fbt(n(t))),Hbt)}return v1})}get fork(){return k1(()=>{let t=new e;if(this.state._tag==="Closed")return t.state=this.state,t;function r(n){return t.close(n)}return this.state.finalizers.add(r),t.unsafeAddFinalizer(n=>k1(()=>this.unsafeRemoveFinalizer(r))),t})}},zbt=x(2,(e,t)=>Ybt(r=>v0e(r(e),{onFailure:n=>tb(t(Q1(n)),()=>I1(n)),onSuccess:n=>tb(t(D1(n)),()=>yI(n))}))),lZ=DA({op:"SetInterruptible",ensure(e){if(e.interruptible=this[Yr],e._interrupted&&e.interruptible)return()=>uZ}}),Vbt=e=>T1(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(lZ(!1)),t._interrupted?uZ:e)),Ybt=e=>T1(t=>t.interruptible?(t.interruptible=!1,t._stack.push(lZ(!0)),e(Vbt)):e(be)),Jbt=DA({op:"While",contA(e,t){return this[Yr].step(e),this[Yr].while()?(t._stack.push(this),this[Yr].body()):xI},eval(e){return this[Yr].while()?(e._stack.push(this),this[Yr].body()):xI}}),Kbt=(e,t,r)=>T1(n=>{let o=r?.concurrency==="inherit"?n.getRef(cZ):r?.concurrency??1,i=o==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,o),s=_e(e),a=s.length;if(a===0)return r?.discard?v1:yI([]);let c=r?.discard?void 0:new Array(a),u=0;return i===1?Mbt(Jbt({while:()=>u<s.length,body:()=>t(s[u],u),step:c?l=>c[u++]=l:l=>u++}),c):I0e(l=>{let d=new Set,f,p=0,m=0,g=!1,A=!1;function E(){for(g=!0;p<i&&u<a;){let y=u,b=s[y];u++,p++;try{let w=Zbt(n,t(b,y),!0,!0);d.add(w),w.addObserver(I=>{d.delete(w),!A&&(I._tag==="Failure"?f===void 0&&(f=I,a=u,d.forEach(v=>v.unsafeInterrupt())):c!==void 0&&(c[y]=I.value),m++,p--,m===a?l(f??yI(c)):!g&&p<i&&E())})}catch(w){f=R1(w),a=u,d.forEach(I=>I.unsafeInterrupt())}}g=!1}return E(),TB(()=>(A=!0,u=a,_bt(d)))})}),Zbt=(e,t,r=!1,n=!1)=>{let o=new C1(e.context,e.interruptible);return n||(e.children().add(o),o.addObserver(()=>e.children().delete(o))),r?o.evaluate(t):e.getRef(EI).scheduleTask(()=>o.evaluate(t),0),o},R0e=(e,t)=>{let r=new C1(EI.context(t?.scheduler??new _1));if(r.evaluate(e),t?.signal)if(t.signal.aborted)r.unsafeInterrupt();else{let n=()=>r.unsafeInterrupt();t.signal.addEventListener("abort",n,{once:!0}),r.addObserver(()=>t.signal.removeEventListener("abort",n))}return r}});var Na,R0r,bI=h(()=>{Me();Na=Symbol.for("effect/Readable"),R0r={[Na]:Na,pipe(){return Z(this,arguments)}}});var QB,pZ,fZ,QA,rb,io,Pa,B0e,T0e,D0e,Q0e,nb,O0e,ob,N0e,P0e,M0e,F0e,SI=h(()=>{id();oe();Kl();it();bI();vt();QB=Symbol.for("effect/Ref"),pZ={_A:e=>e},fZ=class extends Ys{ref;commit(){return this.get}[QB]=pZ;[Na]=Na;constructor(t){super(),this.ref=t,this.get=V(()=>Qr(this.ref))}get;modify(t){return V(()=>{let r=Qr(this.ref),[n,o]=t(r);return r!==o&&js(o)(this.ref),n})}},QA=e=>new fZ(Ba(e)),rb=e=>V(()=>QA(e)),io=e=>e.get,Pa=x(2,(e,t)=>e.modify(()=>[void 0,t])),B0e=x(2,(e,t)=>e.modify(r=>[r,t])),T0e=x(2,(e,t)=>e.modify(r=>[r,t(r)])),D0e=x(2,(e,t)=>e.modify(r=>{let n=t(r);switch(n._tag){case"None":return[r,r];case"Some":return[r,n.value]}})),Q0e=x(2,(e,t)=>e.modify(()=>[t,t])),nb=x(2,(e,t)=>e.modify(t)),O0e=x(3,(e,t,r)=>e.modify(n=>{let o=r(n);switch(o._tag){case"None":return[t,n];case"Some":return o.value}})),ob=x(2,(e,t)=>e.modify(r=>[void 0,t(r)])),N0e=x(2,(e,t)=>e.modify(r=>{let n=t(r);return[n,n]})),P0e=x(2,(e,t)=>e.modify(r=>[void 0,wt(t(r),{onNone:()=>r,onSome:n=>n})])),M0e=x(2,(e,t)=>e.modify(r=>{let n=t(r);switch(n._tag){case"None":return[r,r];case"Some":return[n.value,n.value]}})),F0e=e=>Qr(e.ref)});var Ii={};tr(Ii,{RefTypeId:()=>Xbt,get:()=>Sc,getAndSet:()=>O1,getAndUpdate:()=>eSt,getAndUpdateSome:()=>tSt,make:()=>bc,modify:()=>qm,modifySome:()=>rSt,set:()=>ib,setAndGet:()=>nSt,unsafeMake:()=>aSt,update:()=>OA,updateAndGet:()=>oSt,updateSome:()=>iSt,updateSomeAndGet:()=>sSt});var Xbt,bc,Sc,O1,eSt,tSt,qm,rSt,ib,nSt,OA,oSt,iSt,sSt,aSt,NA=h(()=>{SI();Xbt=QB,bc=rb,Sc=io,O1=B0e,eSt=T0e,tSt=D0e,qm=nb,rSt=O0e,ib=Pa,nSt=Q0e,OA=ob,oSt=N0e,iSt=P0e,sSt=M0e,aSt=QA});var mZ,N1,hZ,L0e,CI,Gm,U0e,PA=h(()=>{oe();yn();vt();mZ=class e{scheduleDrain;running=!1;tasks=new N1;constructor(t){this.scheduleDrain=t}starveInternal=t=>{let r=this.tasks.buckets;this.tasks.buckets=[];for(let[n,o]of r)for(let i=0;i<o.length;i++)o[i]();this.tasks.buckets.length===0?this.running=!1:this.starve(t)};starve(t=0){this.scheduleDrain(t,this.starveInternal)}scheduleTask(t,r){this.tasks.scheduleTask(t,r),this.running||(this.running=!0,this.starve())}static cached(t){let r=new e(t),n=new WeakMap;return o=>{if(o===void 0)return r;let i=n.get(o);return i===void 0&&(i=new e(t),n.set(o,i)),i}}},N1=class{buckets=[];scheduleTask(t,r){let n=this.buckets.length,o,i=0;for(;i<n&&this.buckets[i][0]<=r;i++)o=this.buckets[i];o&&o[0]===r?o[1].push(t):i===n?this.buckets.push([r,[t]]):this.buckets.splice(i,0,[r,[t]])}},hZ=class{maxNextTickBeforeTimer;getRunner=mZ.cached((t,r)=>{t>=this.maxNextTickBeforeTimer?setTimeout(()=>r(0),0):Promise.resolve(void 0).then(()=>r(t+1))});constructor(t){this.maxNextTickBeforeTimer=t}shouldYield(t){return t.currentOpCount>t.getFiberRef(dB)?t.getFiberRef(Qf):!1}scheduleTask(t,r,n){this.getRunner(n).scheduleTask(t,r)}},L0e=Te(Symbol.for("effect/Scheduler/defaultScheduler"),()=>new hZ(2048)),CI=class{tasks=new N1;deferred=!1;scheduleTask(t,r,n){this.deferred?L0e.scheduleTask(t,r,n):this.tasks.scheduleTask(t,r)}shouldYield(t){return t.currentOpCount>t.getFiberRef(dB)?t.getFiberRef(Qf):!1}flush(){for(;this.tasks.buckets.length>0;){let t=this.tasks.buckets;this.tasks.buckets=[];for(let[r,n]of t)for(let o=0;o<n.length;o++)n[o]()}this.deferred=!0}},Gm=Te(Symbol.for("effect/FiberRef/currentScheduler"),()=>pn(L0e)),U0e=x(2,(e,t)=>tn(e,Gm,t))});var P1,gZ=h(()=>{yn();vt();P1=Te(Symbol.for("effect/FiberRef/currentRequestMap"),()=>pn(new Map))});var AZ,PB,$0e=h(()=>{vt();AZ=(e,t,r,n)=>{switch(e){case void 0:return t();case"unbounded":return r();case"inherit":return ci(pB,o=>o==="unbounded"?r():o>1?n(o):t());default:return e>1?n(e):t()}},PB=(e,t,r)=>{switch(e){case void 0:return t();case"unbounded":return r();case"inherit":return ci(pB,n=>n==="unbounded"||n>1?r():t());default:return e>1?r():t()}}});var Vm={};tr(Vm,{Clock:()=>EZ,ClockTypeId:()=>lSt,clockWith:()=>xZ,currentTimeMillis:()=>zm,currentTimeNanos:()=>yZ,make:()=>dSt,sleep:()=>wI});var lSt,dSt,wI,zm,yZ,xZ,EZ,II=h(()=>{JE();Mf();lSt=YE,dSt=YL,wI=BIe,zm=TIe,yZ=DIe,xZ=wB,EZ=bs});var H0e,bZ,SZ,CZ=h(()=>{H0e=(e,t)=>({label:e,startTime:t}),bZ=e=>e.replace(/[\s="]/g,"_"),SZ=e=>t=>`${bZ(t.label)}=${e-t.startTime}ms`});var j0e,wZ=h(()=>{CZ();j0e=H0e});var M1,G0e,MB=h(()=>{Mf();_A();M1=wi,G0e=r1});var z0e,IZ,kZ,sb,fSt,L1=h(()=>{mt();ir();Me();ct();z0e="effect/MetricLabel",IZ=Symbol.for(z0e),kZ=class{key;value;[IZ]=IZ;_hash;constructor(t,r){this.key=t,this.value=r,this._hash=Lt(z0e+this.key+this.value)}[he](){return this._hash}[me](t){return fSt(t)&&this.key===t.key&&this.value===t.value}pipe(){return Z(this,arguments)}},sb=(e,t)=>new kZ(e,t),fSt=e=>se(e,IZ)});var V0e,kI,Y0e,RZ,J0e,K0e,Z0e,X0e,eke,tke,rke,Uf,nke,FB,vI,oke,ike,RI,pSt,ske,LB,UB,ake,cke,uke,lke,$B,dke,fke,pke,HB,mke,H1,hke,gke,Ake,yke,WB,xke,Eke,_Z,W1,bke,j1,Ske,Cke,wke,Ike,BZ,Ym,kke,vke,TZ,Rke,jB,_ke,Bke,Tke,Dke,Qke,Oke,Nke,Pke,_I,q1,Mke,qB,Fke,DZ,Lke,Uke,$ke,Hke,ab,Wke,MA,FA,jke,G1,qke,Gke,zke,Vke,Yke,Jke,Kke,Jm,cb,Zke,GB,Xke,QZ,eve,tve,rve,nve,OZ,ove,ive,sve,NZ,mSt,ave,PZ,cve,uve,lve,dve,fve,z1,pve,V1,mve,hve,gve,Ave,yve,MZ,FZ,xve,Eve,LZ,bve,Sve,Cve,wve,UZ,$Z,Ive,kve,zB,Y1,vve,Rve,_ve,HZ,U1,$1,WZ,Bve,Tve,Dve,$f=h(()=>{wr();vr();II();sr();Ws();mI();oe();kf();dc();Gw();E1();wZ();it();ct();NA();MB();mu();Jl();JE();vt();Mf();NJ();UK();L1();lA();_A();V0e=x(e=>ar(e[0]),function(){let e=arguments;return no(e[0],Of,typeof e[1]=="string"?ko(e[1],e[2]):t=>Object.entries(e[1]).reduce((r,[n,o])=>ko(r,n,o),t))}),kI=e=>te(e,H),Y0e=e=>hA(e,H),RZ=e=>{let t,r;return typeof e=="function"?t=e:(t=e.try,r=e.catch),ye(()=>{try{return M(qn(t))}catch(n){return ut(r?qn(()=>r(n)):new nI(n,"An unknown error occurred in Effect.try"))}})},J0e=x(3,(e,t,r)=>fc(e,n=>se(n,t)&&n[t]===r.failure?r.onFailure(n):ut(n))),K0e=x(2,(e,t)=>Bf(e,r=>{let n=oA(r,o=>QE(o)?H(o):W());switch(n._tag){case"None":return kt(r);case"Some":return t(n.value.defect)}})),Z0e=x(2,(e,t)=>dn(e,{onFailure:r=>{let n=t(r);switch(n._tag){case"None":return kt(r);case"Some":return n.value}},onSuccess:M})),X0e=x(2,(e,t)=>Bf(e,r=>{let n=oA(r,o=>QE(o)?H(o):W());switch(n._tag){case"None":return kt(r);case"Some":{let o=t(n.value.defect);return o._tag==="Some"?o.value:kt(r)}}})),eke=x(e=>ar(e[0]),(e,...t)=>{let r=t[t.length-1],n;return t.length===2?n=mf(t[0]):n=o=>{let i=se(o,"_tag")?o._tag:void 0;if(!i)return!1;for(let s=0;s<t.length-1;s++)if(t[s]===i)return!0;return!1},iB(e,n,r)}),tke=x(2,(e,t)=>{let r;return iB(e,n=>(r??=Object.keys(t),se(n,"_tag")&&Fo(n._tag)&&r.includes(n._tag)),n=>t[n._tag](n))}),rke=e=>sB(e,{onFailure:be,onSuccess:()=>Yi}),Uf=xZ,nke=Uf(M),FB=x(2,(e,t)=>je(wI(t),e)),vI=e=>st((t,r)=>e({id:t.id(),status:r,interruptors:NE(t.getFiberRef(bA))})),oke=vI(e=>Gl(e.interruptors)>0?qs:Ue),ike=vI(M),RI=e=>GB(e,W1,_B),pSt=e=>GB(e,Nm(W1,Zw),([t,r],[n,o])=>[_B(t,n),Cu(r,o)]),ske=M({}),LB=JM(te,O),UB=YM(te),ake=VM(te),cke=x(2,(e,t)=>ye(()=>{let r=e[Symbol.iterator](),n=[],o,i=M(!1),s=0;for(;(o=r.next())&&!o.done;){let a=o.value,c=s++;i=O(i,u=>u?(n.push(a),M(!0)):t(a,c))}return te(i,()=>n)})),uke=x(2,(e,t)=>ye(()=>{let r=e[Symbol.iterator](),n=[],o,i=M(!0),s=0;for(;(o=r.next())&&!o.done;){let a=o.value,c=s++;i=O(i,u=>te(u?t(a,c):M(!1),l=>(l||n.push(a),l)))}return te(i,()=>n)})),lke=e=>te(Oa(),e),$B=e=>LE(e,()=>O(ku(),()=>$B(e))),dke=x(2,(e,t)=>te(Wo(e,be),Yg(t))),fke=x(3,(e,t,r)=>HB(e,t,n=>Ta(()=>r(n)))),pke=x(3,(e,t,r)=>HB(e,t,()=>fA(r))),HB=x(3,(e,t,r)=>O(e,n=>t(n)?M(n):r(n))),mke=x(3,(e,t,r)=>ye(()=>t(e)?M(e):ut(r(e)))),H1=x(e=>ar(e[0]),(e,t,r)=>HB(e,t,n=>r===void 0?ut(new Es):pc(()=>r(n)))),hke=x(2,(e,t)=>ye(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?M(W()):gke(r,0,t,n.value)})),gke=(e,t,r,n)=>O(r(n,t),o=>{if(o)return M(H(n));let i=e.next();return i.done?M(W()):gke(e,t+1,r,i.value)}),Ake=e=>ye(()=>{let t=Co(e);return kr(t)?C(Ur(t),yu(Gt(t),(r,n)=>LE(r,()=>n))):Ta(()=>new vu("Received an empty collection of effects"))}),yke=x(2,(e,t)=>mA(t(mA(e)))),WB=x(2,(e,t)=>Ho(e,{onFailure:r=>M(t.onFailure(r)),onSuccess:r=>M(t.onSuccess(r))})),xke=x(2,(e,t)=>ye(()=>Eke(e[Symbol.iterator](),0,t))),Eke=(e,t,r)=>{let n=e.next();return n.done?M(!0):O(r(n.value,t),o=>o?Eke(e,t+1,r):M(o))},_Z=e=>{let t=O(O(e,()=>ku()),()=>t);return t},W1=st(e=>M(e.getFiberRefs())),bke=e=>O(e,t=>{let n=t[Symbol.iterator]().next();return n.done?ut(new Es):M(n.value)}),j1=e=>WB(e,{onFailure:Ai,onSuccess:Ai}),Ske=e=>dn(e,{onFailure:t=>TZ(t,"An error was silently ignored because it is not anticipated to be useful"),onSuccess:()=>Ue}),Cke=e=>z1((t,r)=>KIe(r,t,e)),wke=e=>WB(e,{onFailure:ka,onSuccess:Gi}),Ike=e=>WB(e,{onFailure:Gi,onSuccess:ka}),BZ=(e,t)=>ye(()=>t.while(e)?O(t.body(e),r=>BZ(r,t)):M(e)),Ym=e=>(...t)=>{let r=en(e),n;for(let o=0,i=t.length;o<i;o++){let s=t[o];T_(s)&&(n!==void 0?n=Vr(n,s):n=s,t=[...t.slice(0,o),...t.slice(o+1)],o--)}return n===void 0&&(n=Yi),st(o=>(o.log(t,n,r),Ue))},kke=Ym(),vke=Ym(XK),TZ=Ym(ZK),Rke=Ym(KK),jB=Ym(JK),_ke=Ym(YK),Bke=Ym(VK),Tke=x(2,(e,t)=>O(zm,r=>no(e,fB,uL(j0e(t,r))))),Dke=Xi(Of),Qke=(e,t)=>t.discard?Nke(e,t.while,t.step,t.body):te(Oke(e,t.while,t.step,t.body),_e),Oke=(e,t,r,n)=>ye(()=>t(e)?O(n(e),o=>te(Oke(r(e),t,r,n),uL(o))):V(()=>Rf())),Nke=(e,t,r,n)=>ye(()=>t(e)?O(n(e),()=>Nke(r(e),t,r,n)):Ue),Pke=x(3,(e,t,r)=>ye(()=>{let n=e[Symbol.iterator](),o=[],i=M(t),s,a=0;for(;!(s=n.next()).done;){let c=a++,u=s.value;i=O(i,l=>te(r(l,u,c),([d,f])=>(o.push(f),d)))}return te(i,c=>[c,o])})),_I=x(2,(e,t)=>dn(e,{onFailure:r=>Tf(()=>t(r)),onSuccess:M})),q1=e=>C(Ci(),O(t=>C(pSt(e),Df(t),DZ,te(r=>je(r,C(Cn(t),O(([n,o])=>Zt(Nm(ab(n[0]),gA(n[1])),o)))))))),Mke=e=>Ho(e,{onFailure:t=>M(t),onSuccess:M}),qB=e=>te(e,t=>!t),Fke=e=>O(e,t=>{switch(t._tag){case"None":return Ue;case"Some":return ut(new Es)}}),DZ=e=>te(bc(!0),t=>$r(AA(e,O1(t,!1)))),Lke=e=>Ho(e,{onFailure:()=>M(W()),onSuccess:t=>M(H(t))}),Uke=x(2,(e,t)=>LE(e,()=>pc(t))),$ke=x(2,(e,t)=>LE(e,()=>V(t))),Hke=e=>dn(e,{onFailure:t=>{let r=_e(D_(t));return r.length===0?kt(t):ut(r)},onSuccess:M}),ab=e=>z1((t,r)=>C(e,p1(t,r))),Wke=e=>e.length>=1?bi((t,r)=>{try{e(r).then(n=>t(M(n)),n=>t(Si(n)))}catch(n){t(Si(n))}}):bi(t=>{try{e().then(r=>t(M(r)),r=>t(Si(r)))}catch(r){t(Si(r))}}),MA=x(3,(e,t,r)=>xc(n=>zs(e,zt(n,t,r)))),FA=x(3,(e,t,r)=>xc(n=>O(r,o=>zs(e,C(n,zt(t,o)))))),jke=lI(M),G1=x(3,(e,t,r)=>_e(e).reduce((n,o,i)=>O(n,s=>r(s,o,i)),M(t))),qke=x(3,(e,t,r)=>_e(e).reduceRight((n,o,i)=>O(n,s=>r(o,s,i)),M(t))),Gke=x(3,(e,t,r)=>O(V(()=>e[Symbol.iterator]()),n=>zke(n,0,t,r.while,r.body))),zke=(e,t,r,n,o)=>{let i=e.next();return!i.done&&n(r)?O(o(r,i.value,t),s=>zke(e,t+1,s,n,o)):M(r)},Vke=x(2,(e,t)=>ye(()=>Yke(e,t))),Yke=(e,t)=>O(e,r=>t<=0?M(r):je(ku(),Yke(e,t-1))),Jke=e=>dn(e,{onFailure:ut,onSuccess:M}),Kke=e=>ye(()=>ZIe(e)),Jm=wI,cb=M(W()),Zke=e=>M(H(e)),GB=x(3,(e,t,r)=>O(t,n=>O(e,o=>te(t,i=>[r(n,i),o])))),Xke=x(e=>ar(e[0]),function(){return QZ(arguments[0],typeof arguments[1]=="string"?[sb(arguments[1],arguments[2])]:Object.entries(arguments[1]).map(([e,t])=>sb(e,t)))}),QZ=x(2,(e,t)=>no(e,Nf,r=>Ul(r,t))),eve=x(2,(e,t)=>ye(()=>{let r=e[Symbol.iterator](),n=[],o,i=M(!1),s=0;for(;(o=r.next())&&!o.done;){let a=o.value,c=s++;i=O(i,u=>u?M(!0):(n.push(a),t(a,c)))}return te(i,()=>n)})),tve=x(2,(e,t)=>ye(()=>{let r=e[Symbol.iterator](),n=[],o,i=M(!0),s=0;for(;(o=r.next())&&!o.done;){let a=o.value,c=s++;i=O(i,u=>C(u?t(a,c):M(!1),te(l=>(l&&n.push(a),l))))}return te(i,()=>n)})),rve=x(2,(e,{onFailure:t,onSuccess:r})=>dn(e,{onFailure:n=>{let o=Vl(n);switch(o._tag){case"Left":return je(t(o.left),kt(n));case"Right":return kt(n)}},onSuccess:n=>Zt(r(n),n)})),nve=x(2,(e,t)=>Bf(e,r=>wt(H6(r),{onNone:()=>kt(r),onSome:n=>je(t(n),kt(r))}))),OZ=x(2,(e,t)=>dn(e,{onFailure:r=>{let n=Vl(r);switch(n._tag){case"Left":return je(t(n.left),kt(r));case"Right":return kt(r)}},onSuccess:M})),ove=x(3,(e,t,r)=>OZ(e,n=>mf(n,t)?r(n):Ue)),ive=x(2,(e,t)=>dn(e,{onFailure:r=>je(t(r),kt(r)),onSuccess:M})),sve=e=>NZ(e,yZ),NZ=x(2,(e,t)=>GB(e,t,(r,n)=>Ww(n-r))),mSt=G0e,ave=mSt(M),PZ=e=>{let t,r;typeof e=="function"?t=e:(t=e.try,r=e.catch);let n=o=>r?pc(()=>r(o)):ut(new nI(o,"An unknown error occurred in Effect.tryPromise"));return t.length>=1?bi((o,i)=>{try{t(i).then(s=>o(M(s)),s=>o(n(s)))}catch(s){o(n(s))}}):bi(o=>{try{t().then(i=>o(M(i)),i=>o(n(i)))}catch(i){o(n(i))}})},cve=x(2,(e,t)=>O(e,r=>RZ({try:()=>t.try(r),catch:t.catch}))),uve=x(2,(e,t)=>O(e,r=>PZ({try:t.try.length>=1?n=>t.try(r,n):()=>t.try(r),catch:t.catch}))),lve=x(2,(e,t)=>ye(()=>t()?cb:kI(e))),dve=x(2,(e,t)=>O(t,r=>r?cb:kI(e))),fve=e=>_I(e,j6),z1=e=>st(t=>(t.setFiberRefs(e(t.id(),t.getFiberRefs())),Ue)),pve=x(3,(e,t,r)=>kA(e,n=>zt(n,t,r(_a(n,t))))),V1=x(2,(e,t)=>ye(()=>t()?te(e,H):M(W()))),mve=x(3,(e,t,r)=>O(Xi(t),n=>r(n)?te(e,o=>[n,H(o)]):M([n,W()]))),hve=x(3,(e,t,r)=>O(Sc(t),n=>r(n)?te(e,o=>[n,H(o)]):M([n,W()]))),gve=x(2,(e,t)=>t(e)),Ave=(e,t)=>(...r)=>O(e,n=>t(n)(...r)),yve=(e,t)=>(...r)=>te(e,n=>t(n)(...r)),MZ=e=>new Proxy({},{get(t,r,n){return(...o)=>O(e,i=>i[r](...o))}}),FZ=e=>new Proxy({},{get(t,r,n){return O(e,o=>ar(o[r])?o[r]:M(o[r]))}}),xve=e=>({functions:MZ(e),constants:FZ(e)}),Eve=e=>te(Oa(),Ji(e)),LZ=e=>O(Oa(),Ji(e)),bve=function(){let e=arguments;return j1(O($Z,t=>V(()=>{if(typeof e[0]=="string")t.attribute(e[0],e[1]);else for(let r in e[0])t.attribute(r,e[0][r])})))},Sve=function(){let e=arguments,t=Array.isArray(e[0])?e[0]:[{_tag:"SpanLink",span:e[0],attributes:e[1]??{}}];return j1(O(UZ,r=>V(()=>r.addLinks(t))))},Cve=x(e=>ar(e[0]),function(){let e=arguments;return no(e[0],HE,typeof e[1]=="string"?ko(e[1],e[2]):t=>Object.entries(e[1]).reduce((r,[n,o])=>ko(r,n,o),t))}),wve=LZ(wi),UZ=O(Oa(),e=>{let t=e.unsafeMap.get(wi.key);return t!==void 0&&t._tag==="Span"?M(t):ut(new Es)}),$Z=O(Oa(),e=>{let t=zB(Ji(e,wi));return t._tag==="Some"&&t.value._tag==="Span"?M(t.value):ut(new Es)}),Ive=x(e=>ar(e[0]),(e,t,r)=>no(e,hB,$s({_tag:"SpanLink",span:t,attributes:r??{}}))),kve=BigInt(0),zB=Gn(e=>Dr(e.context,KE)?e._tag==="Span"?zB(e.parent):W():H(e)),Y1=(e,t,r)=>{let n=!e.getFiberRef(rI)||r.context&&Dr(r.context,KE),o=e.getFiberRef(ui),i=r.parent?H(r.parent):r.root?W():zB(Ji(o,wi)),s;if(n)s=Wwe({name:t,parent:i,context:zt(r.context??ro(),KE,!0)});else{let a=e.getFiberRef(mn),c=Dr(a,Pf),u=Dr(a,EZ),l=e.getFiberRef(Pm),d=e.getFiberRefs(),f=LK(d,HE),p=LK(d,hB),m=p._tag==="Some"?r.links!==void 0?[...Uo(p.value),...r.links??[]]:Uo(p.value):r.links??Us();s=c.span(t,i,r.context??ro(),m,l?u.unsafeCurrentTimeNanos():kve,r.kind??"internal",r),f._tag==="Some"&&rCe(f.value,(g,A)=>s.attribute(A,g)),r.attributes!==void 0&&Object.entries(r.attributes).forEach(([g,A])=>s.attribute(g,A))}return typeof r.captureStackTrace=="function"&&P_.set(s,r.captureStackTrace),s},vve=(e,t)=>(t=Ec(t),st(r=>M(Y1(r,e,t)))),Rve=Xi(HE),_ve=Xi(hB),HZ=(e,t,r,n)=>V(()=>{e.status._tag!=="Ended"&&(LL(t)&&P_.has(e)&&e.attribute("code.stacktrace",P_.get(e)()),e.end(n?r.unsafeCurrentTimeNanos():kve,t))}),U1=(e,...t)=>{let r=Ec(t.length===1?void 0:t[0]),n=t[t.length-1];return st(o=>{let i=Y1(o,e,r),s=o.getFiberRef(Pm),a=Dr(o.getFiberRef(mn),bs);return Gs(n(i),c=>HZ(i,c,a,s))})},$1=x(2,(e,t)=>MA(e,wi,t)),WZ=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ec(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return U1(t,r,o=>$1(n,o))}return n=>U1(t,r,o=>$1(n,o))},Bve=e=>function(){let t=e.captureStackTrace??!1;if(e.captureStackTrace!==!1){let r=Error.stackTraceLimit;Error.stackTraceLimit=2;let n=new Error;Error.stackTraceLimit=r;let o=!1;t=()=>{if(o!==!1)return o;if(n.stack)return o=n.stack.trim().split(`
50
+ `)}`),super(s),this._tag=t,this.traces=n,this[y0e]=Ibt,this.name=i,this.stack=a}pipe(){return Z(this,arguments)}toString(){return this.stack}[Ce](){return this.stack}},oZ=class extends S1{defect;constructor(t,r=[]){super("Die",t,r),this.defect=t}},kbt=(e,t=[])=>new oZ(e,t),iZ=class extends S1{constructor(t=[]){super("Interrupt","interrupted",t)}},vbt=(e=[])=>new iZ(e),S0e=e=>e._tag==="Interrupt",x0e=Symbol.for("effect/Micro/MicroFiber"),Rbt={_A:be,_E:be},C1=class{context;interruptible;[x0e];_stack=[];_observers=[];_exit;_children;currentOpCount=0;constructor(t,r=!0){this.context=t,this.interruptible=r,this[x0e]=Rbt}getRef(t){return mSe(this.context,t)}addObserver(t){return this._exit?(t(this._exit),yi):(this._observers.push(t),()=>{let r=this._observers.indexOf(t);r>=0&&this._observers.splice(r,1)})}_interrupted=!1;unsafeInterrupt(){this._exit||(this._interrupted=!0,this.interruptible&&this.evaluate(uZ))}unsafePoll(){return this._exit}evaluate(t){if(this._exit)return;if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let r=this.runLoop(t);if(r===gI)return;let n=E0e.interruptChildren&&E0e.interruptChildren(this);if(n!==void 0)return this.evaluate(tb(n,()=>r));this._exit=r;for(let o=0;o<this._observers.length;o++)this._observers[o](r);this._observers.length=0}runLoop(t){let r=!1,n=t;this.currentOpCount=0;try{for(;;){if(this.currentOpCount++,!r&&this.getRef(EI).shouldYield(this)){r=!0;let o=n;n=tb(Obt,()=>o)}if(n=n[sZ](this),n===gI){let o=this._yielded;return b1 in o?(this._yielded=void 0,o):gI}}}catch(o){return se(n,sZ)?R1(o):R1(`MicroFiber.runLoop: Not a valid effect: ${String(n)}`)}}getCont(t){for(;;){let r=this._stack.pop();if(!r)return;let n=r[w1]&&r[w1](this);if(n)return{[t]:n};if(r[t])return r}}_yielded=void 0;yieldWith(t){return this._yielded=t,gI}children(){return this._children??=new Set}},E0e=Te("effect/Micro/fiberMiddleware",()=>({interruptChildren:void 0})),_bt=e=>TB(()=>{for(let n of e)n.unsafeInterrupt();let t=e[Symbol.iterator](),r=TB(()=>{let n=t.next();for(;!n.done;){if(n.value.unsafePoll()){n=t.next();continue}let o=n.value;return I0e(i=>{o.addObserver(s=>{i(r)})})}return xI});return r}),C0e=Symbol.for("effect/Micro/identifier"),Yr=Symbol.for("effect/Micro/args"),sZ=Symbol.for("effect/Micro/evaluate"),TA=Symbol.for("effect/Micro/successCont"),AI=Symbol.for("effect/Micro/failureCont"),w1=Symbol.for("effect/Micro/ensureCont"),gI=Symbol.for("effect/Micro/Yield"),Bbt={_A:be,_E:be,_R:be},Tbt={...$Ie,_op:"Micro",[wbt]:Bbt,pipe(){return Z(this,arguments)},[Symbol.iterator](){return new mE(new hf(this))},toJSON(){return{_id:"Micro",op:this[C0e],...Yr in this?{args:this[Yr]}:void 0}},toString(){return Fe(this)},[Ce](){return Fe(this)}};B1=e=>({...Tbt,[C0e]:e.op,[sZ]:e.eval??Dbt,[TA]:e.contA,[AI]:e.contE,[w1]:e.ensure}),DA=e=>{let t=B1(e);return function(){let r=Object.create(t);return r[Yr]=e.single===!1?arguments:arguments[0],r}},w0e=e=>{let t={...B1(e),[b1]:b1,_tag:e.op,get[e.prop](){return this[Yr]},toJSON(){return{_id:"MicroExit",_tag:e.op,[e.prop]:this[Yr]}},[me](r){return $bt(r)&&r._tag===e.op&&ce(this[Yr],r[Yr])},[he](){return We(this,we(Lt(e.op))(ae(this[Yr])))}};return function(r){let n=Object.create(t);return n[Yr]=r,n[TA]=void 0,n[AI]=void 0,n[w1]=void 0,n}},yI=w0e({op:"Success",prop:"value",eval(e){let t=e.getCont(TA);return t?t[TA](this[Yr],e):e.yieldWith(this)}}),I1=w0e({op:"Failure",prop:"cause",eval(e){let t=e.getCont(AI);for(;S0e(this[Yr])&&t&&e.interruptible;)t=e.getCont(AI);return t?t[AI](this[Yr],e):e.yieldWith(this)}}),k1=DA({op:"Sync",eval(e){let t=this[Yr](),r=e.getCont(TA);return r?r[TA](t,e):e.yieldWith(D1(t))}}),TB=DA({op:"Suspend",eval(e){return this[Yr]()}}),Qbt=DA({op:"Yield",eval(e){let t=!1;return e.getRef(EI).scheduleTask(()=>{t||e.evaluate(xI)},this[Yr]??0),e.yieldWith(()=>{t=!0})}}),Obt=Qbt(0),v1=yI(void 0),T1=DA({op:"WithMicroFiber",eval(e){return this[Yr](e)}}),Nbt=DA({op:"Async",single:!1,eval(e){let t=this[Yr][0],r=!1,n=!1,o=this[Yr][1]?new AbortController:void 0,i=t(s=>{r||(r=!0,n?e.evaluate(s):n=s)},o?.signal);return n!==!1?n:(n=!0,e._yielded=()=>{r=!0},o===void 0&&i===void 0||e._stack.push(Pbt(()=>(r=!0,o?.abort(),i??xI))),gI)}}),Pbt=DA({op:"AsyncFinalizer",ensure(e){e.interruptible&&(e.interruptible=!1,e._stack.push(lZ(!0)))},contE(e,t){return S0e(e)?tb(this[Yr](),()=>I1(e)):I1(e)}}),I0e=e=>Nbt(e,e.length>=2),Mbt=x(2,(e,t)=>Ubt(e,r=>t)),Fbt=e=>Gbt(e,{onFailure:Q1,onSuccess:D1}),tb=x(2,(e,t)=>{let r=Object.create(Lbt);return r[Yr]=e,r[TA]=t,r}),Lbt=B1({op:"OnSuccess",eval(e){return e._stack.push(this),this[Yr]}}),Ubt=x(2,(e,t)=>tb(e,r=>yI(t(r)))),$bt=e=>se(e,b1),D1=yI,Q1=I1,uZ=Q1(vbt()),R1=e=>Q1(kbt(e)),xI=D1(void 0),Hbt=e=>{for(let t of e)if(t._tag==="Failure")return t;return xI},Wbt="setImmediate"in globalThis?globalThis.setImmediate:e=>setTimeout(e,0),_1=class{tasks=[];running=!1;scheduleTask(t,r){this.tasks.push(t),this.running||(this.running=!0,Wbt(this.afterScheduled))}afterScheduled=()=>{this.running=!1,this.runTasks()};runTasks(){let t=this.tasks;this.tasks=[];for(let r=0,n=t.length;r<n;r++)t[r]()}shouldYield(t){return t.currentOpCount>=t.getRef(aZ)}flush(){for(;this.tasks.length>0;)this.runTasks()}},jbt=x(2,(e,t)=>T1(r=>{let n=r.context;return r.context=t(n),zbt(e,()=>(r.context=n,v1))})),k0e=x(2,(e,t)=>jbt(e,wo(t))),aZ=class extends ai()("effect/Micro/currentMaxOpsBeforeYield",{defaultValue:()=>2048}){},cZ=class extends ai()("effect/Micro/currentConcurrency",{defaultValue:()=>"unbounded"}){},EI=class extends ai()("effect/Micro/currentScheduler",{defaultValue:()=>new _1}){},v0e=x(2,(e,t)=>{let r=Object.create(qbt);return r[Yr]=e,r[TA]=t.onSuccess,r[AI]=t.onFailure,r}),qbt=B1({op:"OnSuccessAndFailure",eval(e){return e._stack.push(this),this[Yr]}}),Gbt=x(2,(e,t)=>v0e(e,{onFailure:r=>k1(()=>t.onFailure(r)),onSuccess:r=>k1(()=>t.onSuccess(r))})),nZ=Symbol.for("effect/Micro/MicroScope"),b0e=class e{[nZ];state={_tag:"Open",finalizers:new Set};constructor(){this[nZ]=nZ}unsafeAddFinalizer(t){this.state._tag==="Open"&&this.state.finalizers.add(t)}addFinalizer(t){return TB(()=>this.state._tag==="Open"?(this.state.finalizers.add(t),v1):t(this.state.exit))}unsafeRemoveFinalizer(t){this.state._tag==="Open"&&this.state.finalizers.delete(t)}close(t){return TB(()=>{if(this.state._tag==="Open"){let r=Array.from(this.state.finalizers).reverse();return this.state={_tag:"Closed",exit:t},tb(Kbt(r,n=>Fbt(n(t))),Hbt)}return v1})}get fork(){return k1(()=>{let t=new e;if(this.state._tag==="Closed")return t.state=this.state,t;function r(n){return t.close(n)}return this.state.finalizers.add(r),t.unsafeAddFinalizer(n=>k1(()=>this.unsafeRemoveFinalizer(r))),t})}},zbt=x(2,(e,t)=>Ybt(r=>v0e(r(e),{onFailure:n=>tb(t(Q1(n)),()=>I1(n)),onSuccess:n=>tb(t(D1(n)),()=>yI(n))}))),lZ=DA({op:"SetInterruptible",ensure(e){if(e.interruptible=this[Yr],e._interrupted&&e.interruptible)return()=>uZ}}),Vbt=e=>T1(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(lZ(!1)),t._interrupted?uZ:e)),Ybt=e=>T1(t=>t.interruptible?(t.interruptible=!1,t._stack.push(lZ(!0)),e(Vbt)):e(be)),Jbt=DA({op:"While",contA(e,t){return this[Yr].step(e),this[Yr].while()?(t._stack.push(this),this[Yr].body()):xI},eval(e){return this[Yr].while()?(e._stack.push(this),this[Yr].body()):xI}}),Kbt=(e,t,r)=>T1(n=>{let o=r?.concurrency==="inherit"?n.getRef(cZ):r?.concurrency??1,i=o==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,o),s=_e(e),a=s.length;if(a===0)return r?.discard?v1:yI([]);let c=r?.discard?void 0:new Array(a),u=0;return i===1?Mbt(Jbt({while:()=>u<s.length,body:()=>t(s[u],u),step:c?l=>c[u++]=l:l=>u++}),c):I0e(l=>{let d=new Set,f,p=0,m=0,g=!1,A=!1;function E(){for(g=!0;p<i&&u<a;){let y=u,b=s[y];u++,p++;try{let w=Zbt(n,t(b,y),!0,!0);d.add(w),w.addObserver(I=>{d.delete(w),!A&&(I._tag==="Failure"?f===void 0&&(f=I,a=u,d.forEach(v=>v.unsafeInterrupt())):c!==void 0&&(c[y]=I.value),m++,p--,m===a?l(f??yI(c)):!g&&p<i&&E())})}catch(w){f=R1(w),a=u,d.forEach(I=>I.unsafeInterrupt())}}g=!1}return E(),TB(()=>(A=!0,u=a,_bt(d)))})}),Zbt=(e,t,r=!1,n=!1)=>{let o=new C1(e.context,e.interruptible);return n||(e.children().add(o),o.addObserver(()=>e.children().delete(o))),r?o.evaluate(t):e.getRef(EI).scheduleTask(()=>o.evaluate(t),0),o},R0e=(e,t)=>{let r=new C1(EI.context(t?.scheduler??new _1));if(r.evaluate(e),t?.signal)if(t.signal.aborted)r.unsafeInterrupt();else{let n=()=>r.unsafeInterrupt();t.signal.addEventListener("abort",n,{once:!0}),r.addObserver(()=>t.signal.removeEventListener("abort",n))}return r}});var Na,R0r,bI=h(()=>{Me();Na=Symbol.for("effect/Readable"),R0r={[Na]:Na,pipe(){return Z(this,arguments)}}});var QB,pZ,fZ,QA,rb,io,Pa,B0e,T0e,D0e,Q0e,nb,O0e,ob,N0e,P0e,M0e,F0e,SI=h(()=>{id();oe();Kl();it();bI();vt();QB=Symbol.for("effect/Ref"),pZ={_A:e=>e},fZ=class extends Ys{ref;commit(){return this.get}[QB]=pZ;[Na]=Na;constructor(t){super(),this.ref=t,this.get=V(()=>Qr(this.ref))}get;modify(t){return V(()=>{let r=Qr(this.ref),[n,o]=t(r);return r!==o&&js(o)(this.ref),n})}},QA=e=>new fZ(Ba(e)),rb=e=>V(()=>QA(e)),io=e=>e.get,Pa=x(2,(e,t)=>e.modify(()=>[void 0,t])),B0e=x(2,(e,t)=>e.modify(r=>[r,t])),T0e=x(2,(e,t)=>e.modify(r=>[r,t(r)])),D0e=x(2,(e,t)=>e.modify(r=>{let n=t(r);switch(n._tag){case"None":return[r,r];case"Some":return[r,n.value]}})),Q0e=x(2,(e,t)=>e.modify(()=>[t,t])),nb=x(2,(e,t)=>e.modify(t)),O0e=x(3,(e,t,r)=>e.modify(n=>{let o=r(n);switch(o._tag){case"None":return[t,n];case"Some":return o.value}})),ob=x(2,(e,t)=>e.modify(r=>[void 0,t(r)])),N0e=x(2,(e,t)=>e.modify(r=>{let n=t(r);return[n,n]})),P0e=x(2,(e,t)=>e.modify(r=>[void 0,wt(t(r),{onNone:()=>r,onSome:n=>n})])),M0e=x(2,(e,t)=>e.modify(r=>{let n=t(r);switch(n._tag){case"None":return[r,r];case"Some":return[n.value,n.value]}})),F0e=e=>Qr(e.ref)});var di={};tr(di,{RefTypeId:()=>Xbt,get:()=>Sc,getAndSet:()=>O1,getAndUpdate:()=>eSt,getAndUpdateSome:()=>tSt,make:()=>bc,modify:()=>qm,modifySome:()=>rSt,set:()=>ib,setAndGet:()=>nSt,unsafeMake:()=>aSt,update:()=>OA,updateAndGet:()=>oSt,updateSome:()=>iSt,updateSomeAndGet:()=>sSt});var Xbt,bc,Sc,O1,eSt,tSt,qm,rSt,ib,nSt,OA,oSt,iSt,sSt,aSt,NA=h(()=>{SI();Xbt=QB,bc=rb,Sc=io,O1=B0e,eSt=T0e,tSt=D0e,qm=nb,rSt=O0e,ib=Pa,nSt=Q0e,OA=ob,oSt=N0e,iSt=P0e,sSt=M0e,aSt=QA});var mZ,N1,hZ,L0e,CI,Gm,U0e,PA=h(()=>{oe();yn();vt();mZ=class e{scheduleDrain;running=!1;tasks=new N1;constructor(t){this.scheduleDrain=t}starveInternal=t=>{let r=this.tasks.buckets;this.tasks.buckets=[];for(let[n,o]of r)for(let i=0;i<o.length;i++)o[i]();this.tasks.buckets.length===0?this.running=!1:this.starve(t)};starve(t=0){this.scheduleDrain(t,this.starveInternal)}scheduleTask(t,r){this.tasks.scheduleTask(t,r),this.running||(this.running=!0,this.starve())}static cached(t){let r=new e(t),n=new WeakMap;return o=>{if(o===void 0)return r;let i=n.get(o);return i===void 0&&(i=new e(t),n.set(o,i)),i}}},N1=class{buckets=[];scheduleTask(t,r){let n=this.buckets.length,o,i=0;for(;i<n&&this.buckets[i][0]<=r;i++)o=this.buckets[i];o&&o[0]===r?o[1].push(t):i===n?this.buckets.push([r,[t]]):this.buckets.splice(i,0,[r,[t]])}},hZ=class{maxNextTickBeforeTimer;getRunner=mZ.cached((t,r)=>{t>=this.maxNextTickBeforeTimer?setTimeout(()=>r(0),0):Promise.resolve(void 0).then(()=>r(t+1))});constructor(t){this.maxNextTickBeforeTimer=t}shouldYield(t){return t.currentOpCount>t.getFiberRef(dB)?t.getFiberRef(Qf):!1}scheduleTask(t,r,n){this.getRunner(n).scheduleTask(t,r)}},L0e=Te(Symbol.for("effect/Scheduler/defaultScheduler"),()=>new hZ(2048)),CI=class{tasks=new N1;deferred=!1;scheduleTask(t,r,n){this.deferred?L0e.scheduleTask(t,r,n):this.tasks.scheduleTask(t,r)}shouldYield(t){return t.currentOpCount>t.getFiberRef(dB)?t.getFiberRef(Qf):!1}flush(){for(;this.tasks.buckets.length>0;){let t=this.tasks.buckets;this.tasks.buckets=[];for(let[r,n]of t)for(let o=0;o<n.length;o++)n[o]()}this.deferred=!0}},Gm=Te(Symbol.for("effect/FiberRef/currentScheduler"),()=>pn(L0e)),U0e=x(2,(e,t)=>tn(e,Gm,t))});var P1,gZ=h(()=>{yn();vt();P1=Te(Symbol.for("effect/FiberRef/currentRequestMap"),()=>pn(new Map))});var AZ,PB,$0e=h(()=>{vt();AZ=(e,t,r,n)=>{switch(e){case void 0:return t();case"unbounded":return r();case"inherit":return ui(pB,o=>o==="unbounded"?r():o>1?n(o):t());default:return e>1?n(e):t()}},PB=(e,t,r)=>{switch(e){case void 0:return t();case"unbounded":return r();case"inherit":return ui(pB,n=>n==="unbounded"||n>1?r():t());default:return e>1?r():t()}}});var Vm={};tr(Vm,{Clock:()=>EZ,ClockTypeId:()=>lSt,clockWith:()=>xZ,currentTimeMillis:()=>zm,currentTimeNanos:()=>yZ,make:()=>dSt,sleep:()=>wI});var lSt,dSt,wI,zm,yZ,xZ,EZ,II=h(()=>{JE();Mf();lSt=YE,dSt=YL,wI=BIe,zm=TIe,yZ=DIe,xZ=wB,EZ=bs});var H0e,bZ,SZ,CZ=h(()=>{H0e=(e,t)=>({label:e,startTime:t}),bZ=e=>e.replace(/[\s="]/g,"_"),SZ=e=>t=>`${bZ(t.label)}=${e-t.startTime}ms`});var j0e,wZ=h(()=>{CZ();j0e=H0e});var M1,G0e,MB=h(()=>{Mf();_A();M1=Ii,G0e=r1});var z0e,IZ,kZ,sb,fSt,L1=h(()=>{mt();ir();Me();ct();z0e="effect/MetricLabel",IZ=Symbol.for(z0e),kZ=class{key;value;[IZ]=IZ;_hash;constructor(t,r){this.key=t,this.value=r,this._hash=Lt(z0e+this.key+this.value)}[he](){return this._hash}[me](t){return fSt(t)&&this.key===t.key&&this.value===t.value}pipe(){return Z(this,arguments)}},sb=(e,t)=>new kZ(e,t),fSt=e=>se(e,IZ)});var V0e,kI,Y0e,RZ,J0e,K0e,Z0e,X0e,eke,tke,rke,Uf,nke,FB,vI,oke,ike,RI,pSt,ske,LB,UB,ake,cke,uke,lke,$B,dke,fke,pke,HB,mke,H1,hke,gke,Ake,yke,WB,xke,Eke,_Z,W1,bke,j1,Ske,Cke,wke,Ike,BZ,Ym,kke,vke,TZ,Rke,jB,_ke,Bke,Tke,Dke,Qke,Oke,Nke,Pke,_I,q1,Mke,qB,Fke,DZ,Lke,Uke,$ke,Hke,ab,Wke,MA,FA,jke,G1,qke,Gke,zke,Vke,Yke,Jke,Kke,Jm,cb,Zke,GB,Xke,QZ,eve,tve,rve,nve,OZ,ove,ive,sve,NZ,mSt,ave,PZ,cve,uve,lve,dve,fve,z1,pve,V1,mve,hve,gve,Ave,yve,MZ,FZ,xve,Eve,LZ,bve,Sve,Cve,wve,UZ,$Z,Ive,kve,zB,Y1,vve,Rve,_ve,HZ,U1,$1,WZ,Bve,Tve,Dve,$f=h(()=>{wr();vr();II();sr();Ws();mI();oe();kf();dc();Gw();E1();wZ();it();ct();NA();MB();mu();Jl();JE();vt();Mf();NJ();UK();L1();lA();_A();V0e=x(e=>ar(e[0]),function(){let e=arguments;return no(e[0],Of,typeof e[1]=="string"?ko(e[1],e[2]):t=>Object.entries(e[1]).reduce((r,[n,o])=>ko(r,n,o),t))}),kI=e=>te(e,H),Y0e=e=>hA(e,H),RZ=e=>{let t,r;return typeof e=="function"?t=e:(t=e.try,r=e.catch),ye(()=>{try{return M(qn(t))}catch(n){return ut(r?qn(()=>r(n)):new nI(n,"An unknown error occurred in Effect.try"))}})},J0e=x(3,(e,t,r)=>fc(e,n=>se(n,t)&&n[t]===r.failure?r.onFailure(n):ut(n))),K0e=x(2,(e,t)=>Bf(e,r=>{let n=oA(r,o=>QE(o)?H(o):W());switch(n._tag){case"None":return kt(r);case"Some":return t(n.value.defect)}})),Z0e=x(2,(e,t)=>dn(e,{onFailure:r=>{let n=t(r);switch(n._tag){case"None":return kt(r);case"Some":return n.value}},onSuccess:M})),X0e=x(2,(e,t)=>Bf(e,r=>{let n=oA(r,o=>QE(o)?H(o):W());switch(n._tag){case"None":return kt(r);case"Some":{let o=t(n.value.defect);return o._tag==="Some"?o.value:kt(r)}}})),eke=x(e=>ar(e[0]),(e,...t)=>{let r=t[t.length-1],n;return t.length===2?n=mf(t[0]):n=o=>{let i=se(o,"_tag")?o._tag:void 0;if(!i)return!1;for(let s=0;s<t.length-1;s++)if(t[s]===i)return!0;return!1},iB(e,n,r)}),tke=x(2,(e,t)=>{let r;return iB(e,n=>(r??=Object.keys(t),se(n,"_tag")&&Fo(n._tag)&&r.includes(n._tag)),n=>t[n._tag](n))}),rke=e=>sB(e,{onFailure:be,onSuccess:()=>Yi}),Uf=xZ,nke=Uf(M),FB=x(2,(e,t)=>je(wI(t),e)),vI=e=>st((t,r)=>e({id:t.id(),status:r,interruptors:NE(t.getFiberRef(bA))})),oke=vI(e=>Gl(e.interruptors)>0?qs:Ue),ike=vI(M),RI=e=>GB(e,W1,_B),pSt=e=>GB(e,Nm(W1,Zw),([t,r],[n,o])=>[_B(t,n),Cu(r,o)]),ske=M({}),LB=JM(te,O),UB=YM(te),ake=VM(te),cke=x(2,(e,t)=>ye(()=>{let r=e[Symbol.iterator](),n=[],o,i=M(!1),s=0;for(;(o=r.next())&&!o.done;){let a=o.value,c=s++;i=O(i,u=>u?(n.push(a),M(!0)):t(a,c))}return te(i,()=>n)})),uke=x(2,(e,t)=>ye(()=>{let r=e[Symbol.iterator](),n=[],o,i=M(!0),s=0;for(;(o=r.next())&&!o.done;){let a=o.value,c=s++;i=O(i,u=>te(u?t(a,c):M(!1),l=>(l||n.push(a),l)))}return te(i,()=>n)})),lke=e=>te(Oa(),e),$B=e=>LE(e,()=>O(ku(),()=>$B(e))),dke=x(2,(e,t)=>te(Wo(e,be),Yg(t))),fke=x(3,(e,t,r)=>HB(e,t,n=>Ta(()=>r(n)))),pke=x(3,(e,t,r)=>HB(e,t,()=>fA(r))),HB=x(3,(e,t,r)=>O(e,n=>t(n)?M(n):r(n))),mke=x(3,(e,t,r)=>ye(()=>t(e)?M(e):ut(r(e)))),H1=x(e=>ar(e[0]),(e,t,r)=>HB(e,t,n=>r===void 0?ut(new Es):pc(()=>r(n)))),hke=x(2,(e,t)=>ye(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?M(W()):gke(r,0,t,n.value)})),gke=(e,t,r,n)=>O(r(n,t),o=>{if(o)return M(H(n));let i=e.next();return i.done?M(W()):gke(e,t+1,r,i.value)}),Ake=e=>ye(()=>{let t=Co(e);return kr(t)?C(Ur(t),yu(Gt(t),(r,n)=>LE(r,()=>n))):Ta(()=>new vu("Received an empty collection of effects"))}),yke=x(2,(e,t)=>mA(t(mA(e)))),WB=x(2,(e,t)=>Ho(e,{onFailure:r=>M(t.onFailure(r)),onSuccess:r=>M(t.onSuccess(r))})),xke=x(2,(e,t)=>ye(()=>Eke(e[Symbol.iterator](),0,t))),Eke=(e,t,r)=>{let n=e.next();return n.done?M(!0):O(r(n.value,t),o=>o?Eke(e,t+1,r):M(o))},_Z=e=>{let t=O(O(e,()=>ku()),()=>t);return t},W1=st(e=>M(e.getFiberRefs())),bke=e=>O(e,t=>{let n=t[Symbol.iterator]().next();return n.done?ut(new Es):M(n.value)}),j1=e=>WB(e,{onFailure:yi,onSuccess:yi}),Ske=e=>dn(e,{onFailure:t=>TZ(t,"An error was silently ignored because it is not anticipated to be useful"),onSuccess:()=>Ue}),Cke=e=>z1((t,r)=>KIe(r,t,e)),wke=e=>WB(e,{onFailure:ka,onSuccess:Gi}),Ike=e=>WB(e,{onFailure:Gi,onSuccess:ka}),BZ=(e,t)=>ye(()=>t.while(e)?O(t.body(e),r=>BZ(r,t)):M(e)),Ym=e=>(...t)=>{let r=en(e),n;for(let o=0,i=t.length;o<i;o++){let s=t[o];T_(s)&&(n!==void 0?n=Vr(n,s):n=s,t=[...t.slice(0,o),...t.slice(o+1)],o--)}return n===void 0&&(n=Yi),st(o=>(o.log(t,n,r),Ue))},kke=Ym(),vke=Ym(XK),TZ=Ym(ZK),Rke=Ym(KK),jB=Ym(JK),_ke=Ym(YK),Bke=Ym(VK),Tke=x(2,(e,t)=>O(zm,r=>no(e,fB,uL(j0e(t,r))))),Dke=Xi(Of),Qke=(e,t)=>t.discard?Nke(e,t.while,t.step,t.body):te(Oke(e,t.while,t.step,t.body),_e),Oke=(e,t,r,n)=>ye(()=>t(e)?O(n(e),o=>te(Oke(r(e),t,r,n),uL(o))):V(()=>Rf())),Nke=(e,t,r,n)=>ye(()=>t(e)?O(n(e),()=>Nke(r(e),t,r,n)):Ue),Pke=x(3,(e,t,r)=>ye(()=>{let n=e[Symbol.iterator](),o=[],i=M(t),s,a=0;for(;!(s=n.next()).done;){let c=a++,u=s.value;i=O(i,l=>te(r(l,u,c),([d,f])=>(o.push(f),d)))}return te(i,c=>[c,o])})),_I=x(2,(e,t)=>dn(e,{onFailure:r=>Tf(()=>t(r)),onSuccess:M})),q1=e=>C(wi(),O(t=>C(pSt(e),Df(t),DZ,te(r=>je(r,C(Cn(t),O(([n,o])=>Zt(Nm(ab(n[0]),gA(n[1])),o)))))))),Mke=e=>Ho(e,{onFailure:t=>M(t),onSuccess:M}),qB=e=>te(e,t=>!t),Fke=e=>O(e,t=>{switch(t._tag){case"None":return Ue;case"Some":return ut(new Es)}}),DZ=e=>te(bc(!0),t=>$r(AA(e,O1(t,!1)))),Lke=e=>Ho(e,{onFailure:()=>M(W()),onSuccess:t=>M(H(t))}),Uke=x(2,(e,t)=>LE(e,()=>pc(t))),$ke=x(2,(e,t)=>LE(e,()=>V(t))),Hke=e=>dn(e,{onFailure:t=>{let r=_e(D_(t));return r.length===0?kt(t):ut(r)},onSuccess:M}),ab=e=>z1((t,r)=>C(e,p1(t,r))),Wke=e=>e.length>=1?Si((t,r)=>{try{e(r).then(n=>t(M(n)),n=>t(Ci(n)))}catch(n){t(Ci(n))}}):Si(t=>{try{e().then(r=>t(M(r)),r=>t(Ci(r)))}catch(r){t(Ci(r))}}),MA=x(3,(e,t,r)=>xc(n=>zs(e,zt(n,t,r)))),FA=x(3,(e,t,r)=>xc(n=>O(r,o=>zs(e,C(n,zt(t,o)))))),jke=lI(M),G1=x(3,(e,t,r)=>_e(e).reduce((n,o,i)=>O(n,s=>r(s,o,i)),M(t))),qke=x(3,(e,t,r)=>_e(e).reduceRight((n,o,i)=>O(n,s=>r(o,s,i)),M(t))),Gke=x(3,(e,t,r)=>O(V(()=>e[Symbol.iterator]()),n=>zke(n,0,t,r.while,r.body))),zke=(e,t,r,n,o)=>{let i=e.next();return!i.done&&n(r)?O(o(r,i.value,t),s=>zke(e,t+1,s,n,o)):M(r)},Vke=x(2,(e,t)=>ye(()=>Yke(e,t))),Yke=(e,t)=>O(e,r=>t<=0?M(r):je(ku(),Yke(e,t-1))),Jke=e=>dn(e,{onFailure:ut,onSuccess:M}),Kke=e=>ye(()=>ZIe(e)),Jm=wI,cb=M(W()),Zke=e=>M(H(e)),GB=x(3,(e,t,r)=>O(t,n=>O(e,o=>te(t,i=>[r(n,i),o])))),Xke=x(e=>ar(e[0]),function(){return QZ(arguments[0],typeof arguments[1]=="string"?[sb(arguments[1],arguments[2])]:Object.entries(arguments[1]).map(([e,t])=>sb(e,t)))}),QZ=x(2,(e,t)=>no(e,Nf,r=>Ul(r,t))),eve=x(2,(e,t)=>ye(()=>{let r=e[Symbol.iterator](),n=[],o,i=M(!1),s=0;for(;(o=r.next())&&!o.done;){let a=o.value,c=s++;i=O(i,u=>u?M(!0):(n.push(a),t(a,c)))}return te(i,()=>n)})),tve=x(2,(e,t)=>ye(()=>{let r=e[Symbol.iterator](),n=[],o,i=M(!0),s=0;for(;(o=r.next())&&!o.done;){let a=o.value,c=s++;i=O(i,u=>C(u?t(a,c):M(!1),te(l=>(l&&n.push(a),l))))}return te(i,()=>n)})),rve=x(2,(e,{onFailure:t,onSuccess:r})=>dn(e,{onFailure:n=>{let o=Vl(n);switch(o._tag){case"Left":return je(t(o.left),kt(n));case"Right":return kt(n)}},onSuccess:n=>Zt(r(n),n)})),nve=x(2,(e,t)=>Bf(e,r=>wt(H6(r),{onNone:()=>kt(r),onSome:n=>je(t(n),kt(r))}))),OZ=x(2,(e,t)=>dn(e,{onFailure:r=>{let n=Vl(r);switch(n._tag){case"Left":return je(t(n.left),kt(r));case"Right":return kt(r)}},onSuccess:M})),ove=x(3,(e,t,r)=>OZ(e,n=>mf(n,t)?r(n):Ue)),ive=x(2,(e,t)=>dn(e,{onFailure:r=>je(t(r),kt(r)),onSuccess:M})),sve=e=>NZ(e,yZ),NZ=x(2,(e,t)=>GB(e,t,(r,n)=>Ww(n-r))),mSt=G0e,ave=mSt(M),PZ=e=>{let t,r;typeof e=="function"?t=e:(t=e.try,r=e.catch);let n=o=>r?pc(()=>r(o)):ut(new nI(o,"An unknown error occurred in Effect.tryPromise"));return t.length>=1?Si((o,i)=>{try{t(i).then(s=>o(M(s)),s=>o(n(s)))}catch(s){o(n(s))}}):Si(o=>{try{t().then(i=>o(M(i)),i=>o(n(i)))}catch(i){o(n(i))}})},cve=x(2,(e,t)=>O(e,r=>RZ({try:()=>t.try(r),catch:t.catch}))),uve=x(2,(e,t)=>O(e,r=>PZ({try:t.try.length>=1?n=>t.try(r,n):()=>t.try(r),catch:t.catch}))),lve=x(2,(e,t)=>ye(()=>t()?cb:kI(e))),dve=x(2,(e,t)=>O(t,r=>r?cb:kI(e))),fve=e=>_I(e,j6),z1=e=>st(t=>(t.setFiberRefs(e(t.id(),t.getFiberRefs())),Ue)),pve=x(3,(e,t,r)=>kA(e,n=>zt(n,t,r(_a(n,t))))),V1=x(2,(e,t)=>ye(()=>t()?te(e,H):M(W()))),mve=x(3,(e,t,r)=>O(Xi(t),n=>r(n)?te(e,o=>[n,H(o)]):M([n,W()]))),hve=x(3,(e,t,r)=>O(Sc(t),n=>r(n)?te(e,o=>[n,H(o)]):M([n,W()]))),gve=x(2,(e,t)=>t(e)),Ave=(e,t)=>(...r)=>O(e,n=>t(n)(...r)),yve=(e,t)=>(...r)=>te(e,n=>t(n)(...r)),MZ=e=>new Proxy({},{get(t,r,n){return(...o)=>O(e,i=>i[r](...o))}}),FZ=e=>new Proxy({},{get(t,r,n){return O(e,o=>ar(o[r])?o[r]:M(o[r]))}}),xve=e=>({functions:MZ(e),constants:FZ(e)}),Eve=e=>te(Oa(),Ji(e)),LZ=e=>O(Oa(),Ji(e)),bve=function(){let e=arguments;return j1(O($Z,t=>V(()=>{if(typeof e[0]=="string")t.attribute(e[0],e[1]);else for(let r in e[0])t.attribute(r,e[0][r])})))},Sve=function(){let e=arguments,t=Array.isArray(e[0])?e[0]:[{_tag:"SpanLink",span:e[0],attributes:e[1]??{}}];return j1(O(UZ,r=>V(()=>r.addLinks(t))))},Cve=x(e=>ar(e[0]),function(){let e=arguments;return no(e[0],HE,typeof e[1]=="string"?ko(e[1],e[2]):t=>Object.entries(e[1]).reduce((r,[n,o])=>ko(r,n,o),t))}),wve=LZ(Ii),UZ=O(Oa(),e=>{let t=e.unsafeMap.get(Ii.key);return t!==void 0&&t._tag==="Span"?M(t):ut(new Es)}),$Z=O(Oa(),e=>{let t=zB(Ji(e,Ii));return t._tag==="Some"&&t.value._tag==="Span"?M(t.value):ut(new Es)}),Ive=x(e=>ar(e[0]),(e,t,r)=>no(e,hB,$s({_tag:"SpanLink",span:t,attributes:r??{}}))),kve=BigInt(0),zB=Gn(e=>Dr(e.context,KE)?e._tag==="Span"?zB(e.parent):W():H(e)),Y1=(e,t,r)=>{let n=!e.getFiberRef(rI)||r.context&&Dr(r.context,KE),o=e.getFiberRef(li),i=r.parent?H(r.parent):r.root?W():zB(Ji(o,Ii)),s;if(n)s=Wwe({name:t,parent:i,context:zt(r.context??ro(),KE,!0)});else{let a=e.getFiberRef(mn),c=Dr(a,Pf),u=Dr(a,EZ),l=e.getFiberRef(Pm),d=e.getFiberRefs(),f=LK(d,HE),p=LK(d,hB),m=p._tag==="Some"?r.links!==void 0?[...Uo(p.value),...r.links??[]]:Uo(p.value):r.links??Us();s=c.span(t,i,r.context??ro(),m,l?u.unsafeCurrentTimeNanos():kve,r.kind??"internal",r),f._tag==="Some"&&rCe(f.value,(g,A)=>s.attribute(A,g)),r.attributes!==void 0&&Object.entries(r.attributes).forEach(([g,A])=>s.attribute(g,A))}return typeof r.captureStackTrace=="function"&&P_.set(s,r.captureStackTrace),s},vve=(e,t)=>(t=Ec(t),st(r=>M(Y1(r,e,t)))),Rve=Xi(HE),_ve=Xi(hB),HZ=(e,t,r,n)=>V(()=>{e.status._tag!=="Ended"&&(LL(t)&&P_.has(e)&&e.attribute("code.stacktrace",P_.get(e)()),e.end(n?r.unsafeCurrentTimeNanos():kve,t))}),U1=(e,...t)=>{let r=Ec(t.length===1?void 0:t[0]),n=t[t.length-1];return st(o=>{let i=Y1(o,e,r),s=o.getFiberRef(Pm),a=Dr(o.getFiberRef(mn),bs);return Gs(n(i),c=>HZ(i,c,a,s))})},$1=x(2,(e,t)=>MA(e,Ii,t)),WZ=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ec(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return U1(t,r,o=>$1(n,o))}return n=>U1(t,r,o=>$1(n,o))},Bve=e=>function(){let t=e.captureStackTrace??!1;if(e.captureStackTrace!==!1){let r=Error.stackTraceLimit;Error.stackTraceLimit=2;let n=new Error;Error.stackTraceLimit=r;let o=!1;t=()=>{if(o!==!1)return o;if(n.stack)return o=n.stack.trim().split(`
51
51
  `).slice(2).join(`
52
- `).trim(),o}}return ye(()=>{let r=typeof e.options=="function"?e.options.apply(null,arguments):e.options;return WZ(ye(()=>qn(()=>e.body.apply(this,arguments))),r.name,{...r,captureStackTrace:t})})},Tve=e=>e==null?ut(new Es):M(e),Dve=e=>fc(te(e,H),t=>aK(t)?cb:ut(t))});var Fn={};tr(Fn,{all:()=>jZ,as:()=>gSt,asVoid:()=>ASt,causeOption:()=>ySt,die:()=>VB,exists:()=>xSt,fail:()=>Cc,failCause:()=>Mn,flatMap:()=>ESt,flatMapEffect:()=>bSt,flatten:()=>qZ,forEachEffect:()=>YB,fromEither:()=>SSt,fromOption:()=>CSt,getOrElse:()=>wSt,interrupt:()=>GZ,isExit:()=>Qve,isFailure:()=>sd,isInterrupted:()=>hSt,isSuccess:()=>Zm,map:()=>J1,mapBoth:()=>K1,mapError:()=>ISt,mapErrorCause:()=>kSt,match:()=>es,matchEffect:()=>Ove,succeed:()=>vo,void:()=>wc,zip:()=>Z1,zipLeft:()=>vSt,zipPar:()=>RSt,zipParLeft:()=>_St,zipParRight:()=>BSt,zipRight:()=>LA,zipWith:()=>zZ});var Qve,sd,Zm,hSt,gSt,ASt,ySt,jZ,VB,xSt,Cc,Mn,ESt,bSt,qZ,YB,SSt,CSt,wSt,GZ,J1,K1,ISt,kSt,es,Ove,vo,wc,Z1,vSt,LA,RSt,_St,BSt,zZ,Ro=h(()=>{vt();Qve=jE,sd=LL,Zm=yB,hSt=gwe,gSt=qE,ASt=oI,ySt=Awe,jZ=CA,VB=UL,xSt=ywe,Cc=nd,Mn=$t,ESt=cK,bSt=xwe,qZ=Ewe,YB=bwe,SSt=Swe,CSt=Cwe,wSt=wwe,GZ=xB,J1=tB,K1=Iwe,ISt=kwe,kSt=vwe,es=GE,Ove=zE,vo=Vt,wc=Pn,Z1=Rwe,vSt=_we,LA=$L,RSt=Bwe,_St=Twe,BSt=Dwe,zZ=Ru});var X1,eU,tU,rU,nU,BI,ub,Nve,VZ=h(()=>{X1="InterruptSignal",eU="Stateful",tU="Resume",rU="YieldNow",nU=e=>({_tag:X1,cause:e}),BI=e=>({_tag:eU,onFiber:e}),ub=e=>({_tag:tU,effect:e}),Nve=()=>({_tag:rU})});var TSt,oU,YZ,JZ,Mve,ad,JB=h(()=>{Zl();yn();VZ();TSt="effect/FiberScope",oU=Symbol.for(TSt),YZ=class{[oU]=oU;fiberId=ai;roots=new Set;add(t,r){this.roots.add(r),r.addObserver(()=>{this.roots.delete(r)})}},JZ=class{fiberId;parent;[oU]=oU;constructor(t,r){this.fiberId=t,this.parent=r}add(t,r){this.parent.tell(BI(n=>{n.addChild(r),r.addObserver(()=>{n.removeChild(r)})}))}},Mve=e=>new JZ(e.id(),e),ad=Te(Symbol.for("effect/FiberScope/Global"),()=>new YZ)});var DSt,Xm,TI,sU,QSt,ZB,XB,Fve,KB,aU,Lve,lb,cU,Uve,$ve,ZZ,Hve,Wve,uU,jve,qve,eT,lU,ki,iU,XZ,Gve,zve,OSt,Vve,e9,Yve,Jve,NSt,PSt,Kve,t9,Zve,Xve,r9,eRe,eh,tRe,tT=h(()=>{II();Ei();Ro();Zl();BB();oe();dc();Lm();it();bm();Me();ct();vt();Af();JB();lA();DSt="effect/Fiber",Xm=Symbol.for(DSt),TI={_E:e=>e,_A:e=>e},sU={[Xm]:TI,pipe(){return Z(this,arguments)}},QSt="effect/Fiber",ZB=Symbol.for(QSt),XB=C(jEe(oo,oo),yf(e=>[e.id().startTimeMillis,e.id().id])),Fve=e=>se(e,Xm),KB=e=>ZB in e,aU=e=>e.await,Lve=e=>e.children,lb=e=>({...gu,commit(){return ki(this)},...sU,id:()=>ai,await:M(e),children:M([]),inheritAll:Ue,poll:M(H(e)),interruptAsFork:()=>Ue}),cU=e=>te(e.status,t=>({id:e.id(),status:t})),Uve=e=>Wo(e,cU),$ve=e=>lb(Cc(e)),ZZ=e=>lb(Mn(e)),Hve=e=>te(fn(e),lb),Wve=e=>e.id(),uU=e=>e.inheritAll,jve=e=>lb(GZ(e)),qve=e=>O(td,t=>C(e,eT(t))),eT=x(2,Xw(function*(e,t){for(let r of e){if(KB(r)){r.unsafeInterruptAsFork(t);continue}yield*r.interruptAsFork(t)}for(let r of e)KB(r)&&r.unsafePoll()||(yield*r.await)})),lU=x(2,(e,t)=>e.interruptAsFork(t)),ki=e=>$E(ys(e.await),e.inheritAll),iU=x(2,(e,t)=>XZ(e,r=>V(()=>t(r)))),XZ=x(2,(e,t)=>({...gu,commit(){return ki(this)},...sU,id:()=>e.id(),await:O(e.await,YB(t)),children:e.children,inheritAll:e.inheritAll,poll:O(e.poll,n=>{switch(n._tag){case"None":return M(W());case"Some":return C(YB(n.value,t),te(H))}}),interruptAsFork:n=>e.interruptAsFork(n)})),Gve=x(2,(e,t)=>te(e.await,es({onFailure:r=>ZZ(r),onSuccess:r=>t(r)}))),zve=x(2,(e,{onFiber:t,onRuntimeFiber:r})=>KB(e)?r(e):t(e)),OSt={...gu,commit(){return ki(this)},...sU,id:()=>ai,await:xA,children:M([]),inheritAll:xA,poll:M(W()),interruptAsFork:()=>xA},Vve=OSt,e9=x(2,(e,t)=>({...gu,commit(){return ki(this)},...sU,id:()=>iL(e.id(),t.id()),await:Zi(e.await,t.await,(r,n)=>Zm(r)?r:n),children:e.children,inheritAll:je(t.inheritAll,e.inheritAll),poll:Zi(e.poll,t.poll,(r,n)=>{switch(r._tag){case"None":return W();case"Some":return Zm(r.value)?r:n}}),interruptAsFork:r=>C(xs(e,r),je(C(t,xs(r))),$r)})),Yve=x(2,(e,t)=>e9(iU(e,Re),iU(t,Le))),Jve=e=>e.poll,NSt=e=>{let t=e>0?Math.floor:Math.ceil;return{days:t(e/864e5),hours:t(e/36e5)%24,minutes:t(e/6e4)%60,seconds:t(e/1e3)%60,milliseconds:t(e)%1e3,microseconds:t(e*1e3)%1e3,nanoseconds:t(e*1e6)%1e3}},PSt=e=>hI(e)?"Done":A0e(e)?"Running":`Suspended(${ed(e.runtimeFlags)?"interruptible":"uninterruptible"})`,Kve=e=>O(zm,t=>te(cU(e),r=>{let n=t-r.id.startTimeMillis,{days:o,hours:i,milliseconds:s,minutes:a,seconds:c}=NSt(n),u=(o===0?"":`${o}d`)+(o===0&&i===0?"":`${i}h`)+(o===0&&i===0&&a===0?"":`${a}m`)+(o===0&&i===0&&a===0&&c===0?"":`${c}s`)+`${s}ms`,l=y1(r.status)?(()=>{let f=qw(r.status.blockingOn);return Gl(f)>0?"waiting on "+Array.from(f).map(p=>`${p}`).join(", "):""})():"",d=PSt(r.status);return`[Fiber](#${r.id.id}) (${u}) ${l}
53
- Status: ${d}`})),t9=()=>Array.from(ad.roots),Zve=V(t9),Xve=e=>e.status,r9=e=>lb(vo(e)),eRe=r9(void 0),eh="effect/FiberCurrent",tRe=()=>en(globalThis[eh])});var MSt,rRe,nRe,fU,G0r,FSt,LSt,USt,oRe,db,z0r,iRe,V0r,Y0r,sRe=h(()=>{wr();oe();ht();Me();Jl();oL();CZ();MSt="effect/Logger",rRe=Symbol.for(MSt),nRe={_Message:e=>e,_Output:e=>e},fU=e=>({[rRe]:nRe,log:e,pipe(){return Z(this,arguments)}}),G0r={[rRe]:nRe,log:Ai,pipe(){return Z(this,arguments)}},FSt=/^[^\s"=]*$/,LSt=(e,t)=>({annotations:r,cause:n,date:o,fiberId:i,logLevel:s,message:a,spans:c})=>{let u=m=>m.match(FSt)?m:e(m),l=(m,g)=>`${bZ(m)}=${u(g)}`,d=(m,g)=>" "+l(m,g),f=l("timestamp",o.toISOString());f+=d("level",s.label),f+=d("fiber",nL(i));let p=f6(a);for(let m=0;m<p.length;m++)f+=d("message",ym(p[m],t));$6(n)||(f+=d("cause",Yl(n,{renderErrorCause:!0})));for(let m of c)f+=" "+SZ(o.getTime())(m);for(let[m,g]of r)f+=d(m,ym(g,t));return f},USt=e=>`"${e.replace(/\\([\s\S])|(")/g,"\\$1$2")}"`,oRe=fU(LSt(USt)),db={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},z0r={None:[],All:[],Trace:[db.gray],Debug:[db.blue],Info:[db.green],Warning:[db.yellow],Error:[db.red],Fatal:[db.bgBrightRed,db.black]},iRe=typeof process=="object"&&process!==null&&typeof process.stdout=="object"&&process.stdout!==null,V0r=iRe&&process.stdout.isTTY===!0,Y0r=iRe||"Deno"in globalThis});var aRe,n9,o9,HSt,WSt,cRe,uRe=h(()=>{wr();vr();mt();oe();ir();Me();ct();aRe="effect/MetricBoundaries",n9=Symbol.for(aRe),o9=class{values;[n9]=n9;constructor(t){this.values=t,this._hash=C(Lt(aRe),we(So(this.values)))}_hash;[he](){return this._hash}[me](t){return HSt(t)&&ce(this.values,t.values)}pipe(){return Z(this,arguments)}},HSt=e=>se(e,n9),WSt=e=>{let t=C(e,xF(Dt(Number.POSITIVE_INFINITY)),S6);return new o9(t)},cRe=e=>C(d6(e.count-1,t=>e.start*Math.pow(e.factor,t)),ln,WSt)});var qSt,rT,pRe,i9,mRe,s9,hRe,a9,gRe,c9,ARe,u9,nT,l9,GSt,lRe,zSt,dRe,d9,fRe,yRe,xRe,f9,p9,m9,h9,g9,A9=h(()=>{mt();oe();ir();Me();ct();qSt="effect/MetricKeyType",rT=Symbol.for(qSt),pRe="effect/MetricKeyType/Counter",i9=Symbol.for(pRe),mRe="effect/MetricKeyType/Frequency",s9=Symbol.for(mRe),hRe="effect/MetricKeyType/Gauge",a9=Symbol.for(hRe),gRe="effect/MetricKeyType/Histogram",c9=Symbol.for(gRe),ARe="effect/MetricKeyType/Summary",u9=Symbol.for(ARe),nT={_In:e=>e,_Out:e=>e},l9=class{incremental;bigint;[rT]=nT;[i9]=i9;constructor(t,r){this.incremental=t,this.bigint=r,this._hash=Lt(pRe)}_hash;[he](){return this._hash}[me](t){return f9(t)}pipe(){return Z(this,arguments)}},GSt=Lt(mRe),lRe=class{preregisteredWords;[rT]=nT;[s9]=s9;constructor(t){this.preregisteredWords=t}[he](){return GSt}[me](t){return p9(t)}pipe(){return Z(this,arguments)}},zSt=Lt(hRe),dRe=class{bigint;[rT]=nT;[a9]=a9;constructor(t){this.bigint=t}[he](){return zSt}[me](t){return m9(t)}pipe(){return Z(this,arguments)}},d9=class{boundaries;[rT]=nT;[c9]=c9;constructor(t){this.boundaries=t,this._hash=C(Lt(gRe),we(ae(this.boundaries)))}_hash;[he](){return this._hash}[me](t){return h9(t)&&ce(this.boundaries,t.boundaries)}pipe(){return Z(this,arguments)}},fRe=class{maxAge;maxSize;error;quantiles;[rT]=nT;[u9]=u9;constructor(t,r,n,o){this.maxAge=t,this.maxSize=r,this.error=n,this.quantiles=o,this._hash=C(Lt(ARe),we(ae(this.maxAge)),we(ae(this.maxSize)),we(ae(this.error)),we(So(this.quantiles)))}_hash;[he](){return this._hash}[me](t){return g9(t)&&ce(this.maxAge,t.maxAge)&&this.maxSize===t.maxSize&&this.error===t.error&&ce(this.quantiles,t.quantiles)}pipe(){return Z(this,arguments)}},yRe=e=>new l9(e?.incremental??!1,e?.bigint??!1),xRe=e=>new d9(e),f9=e=>se(e,i9),p9=e=>se(e,s9),m9=e=>se(e,a9),h9=e=>se(e,c9),g9=e=>se(e,u9)});var VSt,bRe,YSt,JSt,oT,KSt,SRe,CRe,wRe,IRe=h(()=>{wr();mt();oe();ir();it();Me();ct();A9();VSt="effect/MetricKey",bRe=Symbol.for(VSt),YSt={_Type:e=>e},JSt=Jg(ce),oT=class{name;keyType;description;tags;[bRe]=YSt;constructor(t,r,n,o=[]){this.name=t,this.keyType=r,this.description=n,this.tags=o,this._hash=C(Lt(this.name+this.description),we(ae(this.keyType)),we(So(this.tags)))}_hash;[he](){return this._hash}[me](t){return KSt(t)&&this.name===t.name&&ce(this.keyType,t.keyType)&&ce(this.description,t.description)&&JSt(this.tags,t.tags)}pipe(){return Z(this,arguments)}},KSt=e=>se(e,bRe),SRe=(e,t)=>new oT(e,yRe(t),en(t?.description)),CRe=(e,t,r)=>new oT(e,xRe(t),en(r)),wRe=x(2,(e,t)=>t.length===0?e:new oT(e.name,e.keyType,e.description,Ul(e.tags,t)))});var kRe,XSt,y9,x9,fb,_o,eCt,cd,Ma,vRe,pb,pU,iT=h(()=>{mt();oe();ir();ht();it();Me();kRe=Symbol.for("effect/MutableHashMap"),XSt={[kRe]:kRe,[Symbol.iterator](){return new y9(this)},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"MutableHashMap",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},y9=class e{self;referentialIterator;bucketIterator;constructor(t){this.self=t,this.referentialIterator=t.referential[Symbol.iterator]()}next(){if(this.bucketIterator!==void 0)return this.bucketIterator.next();let t=this.referentialIterator.next();return t.done?(this.bucketIterator=new x9(this.self.buckets.values()),this.next()):t}[Symbol.iterator](){return new e(this.self)}},x9=class{backing;constructor(t){this.backing=t}currentBucket;next(){if(this.currentBucket===void 0){let r=this.backing.next();if(r.done)return r;this.currentBucket=r.value[Symbol.iterator]()}let t=this.currentBucket.next();return t.done?(this.currentBucket=void 0,this.next()):t}},fb=()=>{let e=Object.create(XSt);return e.referential=new Map,e.buckets=new Map,e.bucketsSize=0,e},_o=x(2,(e,t)=>{if(yw(t)===!1)return e.referential.has(t)?H(e.referential.get(t)):W();let r=t[he](),n=e.buckets.get(r);return n===void 0?W():eCt(e,n,t)}),eCt=(e,t,r,n=!1)=>{for(let o=0,i=t.length;o<i;o++)if(r[me](t[o][0])){let s=t[o][1];return n&&(t.splice(o,1),e.bucketsSize--),H(s)}return W()},cd=x(2,(e,t)=>pt(_o(e,t))),Ma=x(3,(e,t,r)=>{if(yw(t)===!1)return e.referential.set(t,r),e;let n=t[he](),o=e.buckets.get(n);return o===void 0?(e.buckets.set(n,[[t,r]]),e.bucketsSize++,e):(vRe(e,o,t),o.push([t,r]),e.bucketsSize++,e)}),vRe=(e,t,r)=>{for(let n=0,o=t.length;n<o;n++)if(r[me](t[n][0])){t.splice(n,1),e.bucketsSize--;return}},pb=x(2,(e,t)=>{if(yw(t)===!1)return e.referential.delete(t),e;let r=t[he](),n=e.buckets.get(r);return n===void 0||(vRe(e,n,t),n.length===0&&e.buckets.delete(r)),e}),pU=e=>e.referential.size+e.bucketsSize});var tCt,sT,RRe,E9,_Re,b9,BRe,S9,TRe,C9,DRe,w9,aT,I9,rCt,k9,v9,R9,_9,QRe,ORe,NRe,PRe,MRe,nCt,oCt,iCt,sCt,aCt,FRe=h(()=>{wr();mt();oe();ir();Me();ct();tCt="effect/MetricState",sT=Symbol.for(tCt),RRe="effect/MetricState/Counter",E9=Symbol.for(RRe),_Re="effect/MetricState/Frequency",b9=Symbol.for(_Re),BRe="effect/MetricState/Gauge",S9=Symbol.for(BRe),TRe="effect/MetricState/Histogram",C9=Symbol.for(TRe),DRe="effect/MetricState/Summary",w9=Symbol.for(DRe),aT={_A:e=>e},I9=class{count;[sT]=aT;[E9]=E9;constructor(t){this.count=t}[he](){return C(ae(RRe),we(ae(this.count)),We(this))}[me](t){return nCt(t)&&this.count===t.count}pipe(){return Z(this,arguments)}},rCt=Jg(ce),k9=class{occurrences;[sT]=aT;[b9]=b9;constructor(t){this.occurrences=t}_hash;[he](){return C(Lt(_Re),we(So(_e(this.occurrences.entries()))),We(this))}[me](t){return oCt(t)&&rCt(_e(this.occurrences.entries()),_e(t.occurrences.entries()))}pipe(){return Z(this,arguments)}},v9=class{value;[sT]=aT;[S9]=S9;constructor(t){this.value=t}[he](){return C(ae(BRe),we(ae(this.value)),We(this))}[me](t){return iCt(t)&&this.value===t.value}pipe(){return Z(this,arguments)}},R9=class{buckets;count;min;max;sum;[sT]=aT;[C9]=C9;constructor(t,r,n,o,i){this.buckets=t,this.count=r,this.min=n,this.max=o,this.sum=i}[he](){return C(ae(TRe),we(ae(this.buckets)),we(ae(this.count)),we(ae(this.min)),we(ae(this.max)),we(ae(this.sum)),We(this))}[me](t){return sCt(t)&&ce(this.buckets,t.buckets)&&this.count===t.count&&this.min===t.min&&this.max===t.max&&this.sum===t.sum}pipe(){return Z(this,arguments)}},_9=class{error;quantiles;count;min;max;sum;[sT]=aT;[w9]=w9;constructor(t,r,n,o,i,s){this.error=t,this.quantiles=r,this.count=n,this.min=o,this.max=i,this.sum=s}[he](){return C(ae(DRe),we(ae(this.error)),we(ae(this.quantiles)),we(ae(this.count)),we(ae(this.min)),we(ae(this.max)),we(ae(this.sum)),We(this))}[me](t){return aCt(t)&&this.error===t.error&&ce(this.quantiles,t.quantiles)&&this.count===t.count&&this.min===t.min&&this.max===t.max&&this.sum===t.sum}pipe(){return Z(this,arguments)}},QRe=e=>new I9(e),ORe=e=>new k9(e),NRe=e=>new v9(e),PRe=e=>new R9(e.buckets,e.count,e.min,e.max,e.sum),MRe=e=>new _9(e.error,e.quantiles,e.count,e.min,e.max,e.sum),nCt=e=>se(e,E9),oCt=e=>se(e,b9),iCt=e=>se(e,S9),sCt=e=>se(e,C9),aCt=e=>se(e,w9)});var uCt,lCt,dCt,cT,LRe,$Re,HRe,WRe,jRe,qRe,fCt,URe,GRe=h(()=>{wr();Ws();oe();Lm();it();Me();FRe();uCt="effect/MetricHook",lCt=Symbol.for(uCt),dCt={_In:e=>e,_Out:e=>e},cT=e=>({[lCt]:dCt,pipe(){return Z(this,arguments)},...e}),LRe=BigInt(0),$Re=e=>{let t=e.keyType.bigint?LRe:0,r=e.keyType.incremental?e.keyType.bigint?o=>o>=LRe:o=>o>=0:o=>!0,n=o=>{r(o)&&(t=t+o)};return cT({get:()=>QRe(t),update:n,modify:n})},HRe=e=>{let t=new Map;for(let n of e.keyType.preregisteredWords)t.set(n,0);let r=n=>{let o=t.get(n)??0;t.set(n,o+1)};return cT({get:()=>ORe(t),update:r,modify:r})},WRe=(e,t)=>{let r=t;return cT({get:()=>NRe(r),update:n=>{r=n},modify:n=>{r=r+n}})},jRe=e=>{let t=e.keyType.boundaries.values,r=t.length,n=new Uint32Array(r+1),o=new Float64Array(r),i=0,s=0,a=Number.MAX_VALUE,c=Number.MIN_VALUE;C(t,Vi(oo),$l((d,f)=>{o[f]=d}));let u=d=>{let f=0,p=r;for(;f!==p;){let m=Math.floor(f+(p-f)/2),g=o[m];d<=g?p=m:f=m,p===f+1&&(d<=o[f]?p=f:f=p)}n[f]=n[f]+1,i=i+1,s=s+d,d<a&&(a=d),d>c&&(c=d)},l=()=>{let d=bE(r),f=0;for(let p=0;p<r;p++){let m=o[p],g=n[p];f=f+g,d[p]=[m,f]}return d};return cT({get:()=>PRe({buckets:l(),count:i,min:a,max:c,sum:s}),update:u,modify:u})},qRe=e=>{let{error:t,maxAge:r,maxSize:n,quantiles:o}=e.keyType,i=C(o,Vi(oo)),s=bE(n),a=0,c=0,u=0,l=0,d=0,f=m=>{let g=[],A=0;for(;A!==n-1;){let E=s[A];if(E!=null){let[y,b]=E,w=Ki(m-y);$_(w,As)&&s3(w,r)&&g.push(b)}A=A+1}return fCt(t,i,Vi(g,oo))},p=(m,g)=>{if(n>0){a=a+1;let A=a%n;s[A]=[g,m]}l=c===0?m:Math.min(l,m),d=c===0?m:Math.max(d,m),c=c+1,u=u+m};return cT({get:()=>MRe({error:t,quantiles:f(Date.now()),count:c,min:l,max:d,sum:u}),update:([m,g])=>p(m,g),modify:([m,g])=>p(m,g)})},fCt=(e,t,r)=>{let n=r.length;if(!zr(t))return Us();let o=t[0],i=t.slice(1),s=URe(e,n,W(),0,o,r),a=hs(s);return i.forEach(c=>{a.push(URe(e,n,s.value,s.consumed,c,s.rest))}),$l(a,c=>[c.quantile,c.value])},URe=(e,t,r,n,o,i)=>{let s=e,a=t,c=r,u=n,l=o,d=i,f=e,p=t,m=r,g=n,A=o,E=i;for(;;){if(!zr(d))return{quantile:l,value:W(),consumed:u,rest:[]};if(l===1)return{quantile:l,value:H(g6(d)),consumed:u+d.length,rest:[]};let y=Lo(d),b=sbe(d,R=>R===y),w=l*a,I=s/2*w,v=u+b[0].length,k=Math.abs(v-w);if(v<w-I){f=s,p=a,m=wm(d),g=v,A=l,E=b[1],s=f,a=p,c=m,u=g,l=A,d=E;continue}if(v>w+I){let R=Ct(c)?H(y):c;return{quantile:l,value:R,consumed:u,rest:d}}switch(c._tag){case"None":{f=s,p=a,m=wm(d),g=v,A=l,E=b[1],s=f,a=p,c=m,u=g,l=A,d=E;continue}case"Some":{let R=Math.abs(w-c.value);if(k<R){f=s,p=a,m=wm(d),g=v,A=l,E=b[1],s=f,a=p,c=m,u=g,l=A,d=E;continue}return{quantile:l,value:H(c.value),consumed:u,rest:d}}}}throw new Error("BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues")}});var mCt,hCt,gCt,zRe,VRe=h(()=>{Me();mCt="effect/MetricPair",hCt=Symbol.for(mCt),gCt={_Type:e=>e},zRe=(e,t)=>({[hCt]:gCt,metricKey:e,metricState:t,pipe(){return Z(this,arguments)}})});var yCt,YRe,B9,JRe,KRe=h(()=>{oe();iT();it();GRe();A9();VRe();yCt="effect/MetricRegistry",YRe=Symbol.for(yCt),B9=class{[YRe]=YRe;map=fb();snapshot(){let t=[];for(let[r,n]of this.map)t.push(zRe(r,n.get()));return t}get(t){let r=C(this.map,_o(t),Gr);if(r==null){if(f9(t.keyType))return this.getCounter(t);if(m9(t.keyType))return this.getGauge(t);if(p9(t.keyType))return this.getFrequency(t);if(h9(t.keyType))return this.getHistogram(t);if(g9(t.keyType))return this.getSummary(t);throw new Error("BUG: MetricRegistry.get - unknown MetricKeyType - please report an issue at https://github.com/Effect-TS/effect/issues")}else return r}getCounter(t){let r=C(this.map,_o(t),Gr);if(r==null){let n=$Re(t);C(this.map,cd(t))||C(this.map,Ma(t,n)),r=n}return r}getFrequency(t){let r=C(this.map,_o(t),Gr);if(r==null){let n=HRe(t);C(this.map,cd(t))||C(this.map,Ma(t,n)),r=n}return r}getGauge(t){let r=C(this.map,_o(t),Gr);if(r==null){let n=WRe(t,t.keyType.bigint?BigInt(0):0);C(this.map,cd(t))||C(this.map,Ma(t,n)),r=n}return r}getHistogram(t){let r=C(this.map,_o(t),Gr);if(r==null){let n=jRe(t);C(this.map,cd(t))||C(this.map,Ma(t,n)),r=n}return r}getSummary(t){let r=C(this.map,_o(t),Gr);if(r==null){let n=qRe(t);C(this.map,cd(t))||C(this.map,Ma(t,n)),r=n}return r}},JRe=()=>new B9});var ECt,bCt,SCt,ZRe,XRe,uT,e_e,t_e,r_e,CCt,wCt,n_e=h(()=>{wr();oe();yn();Me();vt();IRe();L1();KRe();ECt="effect/Metric",bCt=Symbol.for(ECt),SCt={_Type:e=>e,_In:e=>e,_Out:e=>e},ZRe=Te(Symbol.for("effect/Metric/globalMetricRegistry"),()=>JRe()),XRe=function(e,t,r,n){let o=Object.assign(i=>jo(i,s=>wCt(o,s)),{[bCt]:SCt,keyType:e,unsafeUpdate:t,unsafeValue:r,unsafeModify:n,register(){return this.unsafeValue([]),this},pipe(){return Z(this,arguments)}});return o},uT=(e,t)=>e_e(SRe(e,t)),e_e=e=>{let t,r=new WeakMap,n=o=>{if(o.length===0)return t!==void 0||(t=ZRe.get(e)),t;let i=r.get(o);return i!==void 0||(i=ZRe.get(wRe(e,o)),r.set(o,i)),i};return XRe(e.keyType,(o,i)=>n(i).update(o),o=>n(o).get(),(o,i)=>n(i).modify(o))},t_e=(e,t,r)=>e_e(CRe(e,t,r)),r_e=x(3,(e,t,r)=>CCt(e,[sb(t,r)])),CCt=x(2,(e,t)=>XRe(e.keyType,(r,n)=>e.unsafeUpdate(r,Ul(t,n)),r=>e.unsafeValue(Ul(t,r)),(r,n)=>e.unsafeModify(r,Ul(t,n)))),wCt=x(2,(e,t)=>ci(Nf,r=>V(()=>e.unsafeUpdate(t,r))))});var kCt,T9,vCt,vkr,o_e,D9,DI,hU=h(()=>{oe();ct();gZ();vt();Af();kCt="effect/Request",T9=Symbol.for(kCt),vCt={_E:e=>e,_A:e=>e},vkr={...gf,[T9]:vCt},o_e=e=>se(e,T9),D9=x(2,(e,t)=>ci(P1,r=>V(()=>{if(r.has(e)){let n=r.get(e);n.state.completed||(n.state.completed=!0,IA(n.result,t))}}))),DI=class{count=0;observers=new Set;interrupted=!1;addObserver(t){this.observers.add(t)}removeObserver(t){this.observers.delete(t)}increment(){this.count++,this.observers.forEach(t=>t(this.count))}decrement(){this.count--,this.observers.forEach(t=>t(this.count))}}});var UA,gU,i_e=h(()=>{wr();it();UA={Forward:0,Backward:1},gU=class e{self;stack;direction;count=0;constructor(t,r,n){this.self=t,this.stack=r,this.direction=n}clone(){return new e(this.self,this.stack.slice(),this.direction)}reversed(){return new e(this.self,this.stack.slice(),this.direction===UA.Forward?UA.Backward:UA.Forward)}next(){let t=this.entry;switch(this.count++,this.direction===UA.Forward?this.moveNext():this.movePrev(),t._tag){case"None":return{done:!0,value:this.count};case"Some":return{done:!1,value:t.value}}}get key(){return this.stack.length>0?H(this.stack[this.stack.length-1].key):W()}get value(){return this.stack.length>0?H(this.stack[this.stack.length-1].value):W()}get entry(){return dr(EF(this.stack),t=>[t.key,t.value])}get index(){let t=0,r=this.stack;if(r.length===0){let n=this.self._root;return n!=null?n.count:0}else r[r.length-1].left!=null&&(t=r[r.length-1].left.count);for(let n=r.length-2;n>=0;--n)r[n+1]===r[n].right&&(++t,r[n].left!=null&&(t+=r[n].left.count));return t}moveNext(){let t=this.stack;if(t.length===0)return;let r=t[t.length-1];if(r.right!=null)for(r=r.right;r!=null;)t.push(r),r=r.left;else for(t.pop();t.length>0&&t[t.length-1].right===r;)r=t[t.length-1],t.pop()}get hasNext(){let t=this.stack;if(t.length===0)return!1;if(t[t.length-1].right!=null)return!0;for(let r=t.length-1;r>0;--r)if(t[r-1].left===t[r])return!0;return!1}movePrev(){let t=this.stack;if(t.length===0)return;let r=t[t.length-1];if(r!=null&&r.left!=null)for(r=r.left;r!=null;)t.push(r),r=r.right;else for(t.pop();t.length>0&&t[t.length-1].left===r;)r=t[t.length-1],t.pop()}get hasPrev(){let t=this.stack;if(t.length===0)return!1;if(t[t.length-1].left!=null)return!0;for(let r=t.length-1;r>0;--r)if(t[r-1].right===t[r])return!0;return!1}}});function Q9(e,t){e.key=t.key,e.value=t.value,e.left=t.left,e.right=t.right,e.color=t.color,e.count=t.count}var Ve,ud,th,wn,s_e=h(()=>{Ve={Red:0,Black:1},ud=({color:e,count:t,key:r,left:n,right:o,value:i})=>({color:e,key:r,value:i,left:n,right:o,count:t});th=({count:e,key:t,left:r,right:n,value:o},i)=>({color:i,key:t,value:o,left:r,right:n,count:e}),wn=e=>{e.count=1+(e.left?.count??0)+(e.right?.count??0)}});var a_e,O9,BCt,TCt,QI,c_e,u_e,l_e,d_e,N9,f_e,p_e,m_e,h_e,DCt,g_e=h(()=>{mt();oe();ir();ht();it();Me();ct();i_e();s_e();a_e="effect/RedBlackTree",O9=Symbol.for(a_e),BCt={_Key:e=>e,_Value:e=>e},TCt={[O9]:BCt,[he](){let e=ae(a_e);for(let t of this)e^=C(ae(t[0]),we(ae(t[1])));return We(this,e)},[me](e){if(c_e(e)){if((this._root?.count??0)!==(e._root?.count??0))return!1;let t=Array.from(e);return Array.from(this).every((r,n)=>{let o=t[n];return ce(r[0],o[0])&&ce(r[1],o[1])})}return!1},[Symbol.iterator](){let e=[],t=this._root;for(;t!=null;)e.push(t),t=t.left;return new gU(this,e,UA.Forward)},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"RedBlackTree",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},QI=(e,t)=>{let r=Object.create(TCt);return r._ord=e,r._root=t,r},c_e=e=>se(e,O9),u_e=e=>QI(e,void 0),l_e=x(2,(e,t)=>{let r=e._ord,n=e._root;for(;n!==void 0;){let o=r(t,n.key);if(ce(t,n.key))return H(n.value);o<=0?n=n.left:n=n.right}return W()}),d_e=e=>e._ord,N9=x(2,(e,t)=>pt(l_e(e,t))),f_e=x(3,(e,t,r)=>{let n=e._ord,o=e._root,i=[],s=[];for(;o!=null;){let a=n(t,o.key);i.push(o),s.push(a),a<=0?o=o.left:o=o.right}i.push({color:Ve.Red,key:t,value:r,left:void 0,right:void 0,count:1});for(let a=i.length-2;a>=0;--a){let c=i[a];s[a]<=0?i[a]={color:c.color,key:c.key,value:c.value,left:i[a+1],right:c.right,count:c.count+1}:i[a]={color:c.color,key:c.key,value:c.value,left:c.left,right:i[a+1],count:c.count+1}}for(let a=i.length-1;a>1;--a){let c=i[a-1],u=i[a];if(c.color===Ve.Black||u.color===Ve.Black)break;let l=i[a-2];if(l.left===c)if(c.left===u){let d=l.right;if(d&&d.color===Ve.Red)c.color=Ve.Black,l.right=th(d,Ve.Black),l.color=Ve.Red,a-=1;else{if(l.color=Ve.Red,l.left=c.right,c.color=Ve.Black,c.right=l,i[a-2]=c,i[a-1]=u,wn(l),wn(c),a>=3){let f=i[a-3];f.left===l?f.left=c:f.right=c}break}}else{let d=l.right;if(d&&d.color===Ve.Red)c.color=Ve.Black,l.right=th(d,Ve.Black),l.color=Ve.Red,a-=1;else{if(c.right=u.left,l.color=Ve.Red,l.left=u.right,u.color=Ve.Black,u.left=c,u.right=l,i[a-2]=u,i[a-1]=c,wn(l),wn(c),wn(u),a>=3){let f=i[a-3];f.left===l?f.left=u:f.right=u}break}}else if(c.right===u){let d=l.left;if(d&&d.color===Ve.Red)c.color=Ve.Black,l.left=th(d,Ve.Black),l.color=Ve.Red,a-=1;else{if(l.color=Ve.Red,l.right=c.left,c.color=Ve.Black,c.left=l,i[a-2]=c,i[a-1]=u,wn(l),wn(c),a>=3){let f=i[a-3];f.right===l?f.right=c:f.left=c}break}}else{let d=l.left;if(d&&d.color===Ve.Red)c.color=Ve.Black,l.left=th(d,Ve.Black),l.color=Ve.Red,a-=1;else{if(c.left=u.right,l.color=Ve.Red,l.right=u.left,u.color=Ve.Black,u.right=c,u.left=l,i[a-2]=u,i[a-1]=c,wn(l),wn(c),wn(u),a>=3){let f=i[a-3];f.right===l?f.right=u:f.left=u}break}}}return i[0].color=Ve.Black,QI(e._ord,i[0])}),p_e=e=>m_e(e,UA.Forward),m_e=(e,t)=>{let r=e[Symbol.iterator](),n=0;return{[Symbol.iterator]:()=>m_e(e,t),next:()=>{n++;let o=r.key;switch(t===UA.Forward?r.moveNext():r.movePrev(),o._tag){case"None":return{done:!0,value:n};case"Some":return{done:!1,value:o.value}}}}},h_e=x(2,(e,t)=>{if(!N9(e,t))return e;let r=e._ord,n=r,o=e._root,i=[];for(;o!==void 0;){let c=n(t,o.key);i.push(o),ce(t,o.key)?o=void 0:c<=0?o=o.left:o=o.right}if(i.length===0)return e;let s=new Array(i.length),a=i[i.length-1];s[s.length-1]={color:a.color,key:a.key,value:a.value,left:a.left,right:a.right,count:a.count};for(let c=i.length-2;c>=0;--c)a=i[c],a.left===i[c+1]?s[c]={color:a.color,key:a.key,value:a.value,left:s[c+1],right:a.right,count:a.count}:s[c]={color:a.color,key:a.key,value:a.value,left:a.left,right:s[c+1],count:a.count};if(a=s[s.length-1],a.left!==void 0&&a.right!==void 0){let c=s.length;for(a=a.left;a.right!=null;)s.push(a),a=a.right;let u=s[c-1];s.push({color:a.color,key:u.key,value:u.value,left:a.left,right:a.right,count:a.count}),s[c-1].key=a.key,s[c-1].value=a.value;for(let l=s.length-2;l>=c;--l)a=s[l],s[l]={color:a.color,key:a.key,value:a.value,left:a.left,right:s[l+1],count:a.count};s[c-1].left=s[c]}if(a=s[s.length-1],a.color===Ve.Red){let c=s[s.length-2];c.left===a?c.left=void 0:c.right===a&&(c.right=void 0),s.pop();for(let u=0;u<s.length;++u)s[u].count--;return QI(r,s[0])}else if(a.left!==void 0||a.right!==void 0){a.left!==void 0?Q9(a,a.left):a.right!==void 0&&Q9(a,a.right),a.color=Ve.Black;for(let c=0;c<s.length-1;++c)s[c].count--;return QI(r,s[0])}else{if(s.length===1)return QI(r,void 0);{for(let u=0;u<s.length;++u)s[u].count--;let c=s[s.length-2];DCt(s),c.left===a?c.left=void 0:c.right=void 0}}return QI(r,s[0])}),DCt=e=>{let t,r,n,o;for(let i=e.length-1;i>=0;--i){if(t=e[i],i===0){t.color=Ve.Black;return}if(r=e[i-1],r.left===t){if(n=r.right,n!==void 0&&n.right!==void 0&&n.right.color===Ve.Red){if(n=r.right=ud(n),o=n.right=ud(n.right),r.right=n.left,n.left=r,n.right=o,n.color=r.color,t.color=Ve.Black,r.color=Ve.Black,o.color=Ve.Black,wn(r),wn(n),i>1){let s=e[i-2];s.left===r?s.left=n:s.right=n}e[i-1]=n;return}else if(n!==void 0&&n.left!==void 0&&n.left.color===Ve.Red){if(n=r.right=ud(n),o=n.left=ud(n.left),r.right=o.left,n.left=o.right,o.left=r,o.right=n,o.color=r.color,r.color=Ve.Black,n.color=Ve.Black,t.color=Ve.Black,wn(r),wn(n),wn(o),i>1){let s=e[i-2];s.left===r?s.left=o:s.right=o}e[i-1]=o;return}if(n!==void 0&&n.color===Ve.Black)if(r.color===Ve.Red){r.color=Ve.Black,r.right=th(n,Ve.Red);return}else{r.right=th(n,Ve.Red);continue}else if(n!==void 0){if(n=ud(n),r.right=n.left,n.left=r,n.color=r.color,r.color=Ve.Red,wn(r),wn(n),i>1){let s=e[i-2];s.left===r?s.left=n:s.right=n}e[i-1]=n,e[i]=r,i+1<e.length?e[i+1]=t:e.push(t),i=i+2}}else{if(n=r.left,n!==void 0&&n.left!==void 0&&n.left.color===Ve.Red){if(n=r.left=ud(n),o=n.left=ud(n.left),r.left=n.right,n.right=r,n.left=o,n.color=r.color,t.color=Ve.Black,r.color=Ve.Black,o.color=Ve.Black,wn(r),wn(n),i>1){let s=e[i-2];s.right===r?s.right=n:s.left=n}e[i-1]=n;return}else if(n!==void 0&&n.right!==void 0&&n.right.color===Ve.Red){if(n=r.left=ud(n),o=n.right=ud(n.right),r.left=o.right,n.right=o.left,o.right=r,o.left=n,o.color=r.color,r.color=Ve.Black,n.color=Ve.Black,t.color=Ve.Black,wn(r),wn(n),wn(o),i>1){let s=e[i-2];s.right===r?s.right=o:s.left=o}e[i-1]=o;return}if(n!==void 0&&n.color===Ve.Black)if(r.color===Ve.Red){r.color=Ve.Black,r.left=th(n,Ve.Red);return}else{r.left=th(n,Ve.Red);continue}else if(n!==void 0){if(n=ud(n),r.left=n.right,n.right=r,n.color=r.color,r.color=Ve.Red,wn(r),wn(n),i>1){let s=e[i-2];s.right===r?s.right=n:s.left=n}e[i-1]=n,e[i]=r,i+1<e.length?e[i+1]=t:e.push(t),i=i+2}}}}});var A_e,P9,y_e,x_e,E_e,b_e,M9=h(()=>{g_e();A_e=u_e,P9=d_e,y_e=N9,x_e=f_e,E_e=p_e,b_e=h_e});var F9,OCt,L9,NCt,dT,lT,C_e,w_e,I_e,AU=h(()=>{mt();oe();oe();ir();ht();Me();ct();M9();F9=Symbol.for("effect/SortedSet"),OCt={[F9]:{_A:e=>e},[he](){return C(ae(this.keyTree),we(ae(F9)),We(this))},[me](e){return NCt(e)&&ce(this.keyTree,e.keyTree)},[Symbol.iterator](){return E_e(this.keyTree)},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"SortedSet",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},L9=e=>{let t=Object.create(OCt);return t.keyTree=e,t},NCt=e=>se(e,F9),dT=e=>L9(A_e(e)),lT=x(2,(e,t)=>y_e(e.keyTree,t)?e:L9(x_e(e.keyTree,t,!0))),C_e=x(2,(e,t)=>{let r=P9(e.keyTree),n=dT(r);for(let o of e)t(o)&&(n=lT(n,o));return n}),w_e=x(2,(e,t)=>L9(b_e(e.keyTree,t))),I_e=x(2,(e,t)=>{let r=P9(e.keyTree),n=dT(r);for(let o of e)n=lT(o)(n);for(let o of t)n=lT(o)(n);return n})});var PCt,WA,mb,$A,HA,W9,$9,H9,k_e,v_e,j9,R_e,jA,OI=h(()=>{oe();yn();Kl();ct();AU();vt();PCt="effect/Supervisor",WA=Symbol.for(PCt),mb={_T:e=>e},$A=class e{underlying;value0;[WA]=mb;constructor(t,r){this.underlying=t,this.value0=r}get value(){return this.value0}onStart(t,r,n,o){this.underlying.onStart(t,r,n,o)}onEnd(t,r){this.underlying.onEnd(t,r)}onEffect(t,r){this.underlying.onEffect(t,r)}onSuspend(t){this.underlying.onSuspend(t)}onResume(t){this.underlying.onResume(t)}map(t){return new e(this,C(this.value,te(t)))}zip(t){return new HA(this,t)}},HA=class e{left;right;_tag="Zip";[WA]=mb;constructor(t,r){this.left=t,this.right=r}get value(){return Nm(this.left.value,this.right.value)}onStart(t,r,n,o){this.left.onStart(t,r,n,o),this.right.onStart(t,r,n,o)}onEnd(t,r){this.left.onEnd(t,r),this.right.onEnd(t,r)}onEffect(t,r){this.left.onEffect(t,r),this.right.onEffect(t,r)}onSuspend(t){this.left.onSuspend(t),this.right.onSuspend(t)}onResume(t){this.left.onResume(t),this.right.onResume(t)}map(t){return new $A(this,C(this.value,te(t)))}zip(t){return new e(this,t)}},W9=e=>se(e,WA)&&mf(e,"Zip"),$9=class{[WA]=mb;fibers=new Set;get value(){return V(()=>Array.from(this.fibers))}onStart(t,r,n,o){this.fibers.add(o)}onEnd(t,r){this.fibers.delete(r)}onEffect(t,r){}onSuspend(t){}onResume(t){}map(t){return new $A(this,C(this.value,te(t)))}zip(t){return new HA(this,t)}onRun(t,r){return t()}},H9=class{effect;[WA]=mb;constructor(t){this.effect=t}get value(){return this.effect}onStart(t,r,n,o){}onEnd(t,r){}onEffect(t,r){}onSuspend(t){}onResume(t){}map(t){return new $A(this,C(this.value,te(t)))}zip(t){return new HA(this,t)}onRun(t,r){return t()}},k_e=class{ref;[WA]=mb;constructor(t){this.ref=t}get value(){return V(()=>Qr(this.ref))}onStart(t,r,n,o){C(this.ref,js(C(Qr(this.ref),lT(o))))}onEnd(t,r){C(this.ref,js(C(Qr(this.ref),w_e(r))))}onEffect(t,r){}onSuspend(t){}onResume(t){}map(t){return new $A(this,C(this.value,te(t)))}zip(t){return new HA(this,t)}onRun(t,r){return t()}},v_e=()=>new $9,j9=V(v_e),R_e=e=>new H9(e),jA=Te("effect/Supervisor/none",()=>R_e(Ue))});var __e,q9=h(()=>{pL();__e=uA});var T_e,D_e,Q_e,O_e,NI,yU,MCt,FCt,G9,xU,LCt,N_e,P_e=h(()=>{vr();q9();mt();oe();dc();OI();T_e="Empty",D_e="AddSupervisor",Q_e="RemoveSupervisor",O_e="AndThen",NI={_tag:T_e},yU=(e,t)=>({_tag:O_e,first:e,second:t}),MCt=(e,t)=>FCt(t,Dt(e)),FCt=(e,t)=>{let r=e,n=t;for(;kr(n);){let o=Gt(n);switch(o._tag){case T_e:{n=Ur(n);break}case D_e:{r=r.zip(o.supervisor),n=Ur(n);break}case Q_e:{r=G9(r,o.supervisor),n=Ur(n);break}case O_e:{n=fr(o.first)(fr(o.second)(Ur(n)));break}}}return r},G9=(e,t)=>ce(e,t)?jA:W9(e)?G9(e.left,t).zip(G9(e.right,t)):e,xU=e=>ce(e,jA)?ql():W9(e)?C(xU(e.left),Ef(xU(e.right))):eA(e),LCt=(e,t)=>{if(ce(e,t))return NI;let r=xU(e),n=xU(t),o=C(n,M6(r),tA(NI,(s,a)=>yU(s,{_tag:D_e,supervisor:a}))),i=C(r,M6(n),tA(NI,(s,a)=>yU(s,{_tag:Q_e,supervisor:a})));return yU(o,i)},N_e=__e({empty:NI,patch:MCt,combine:yU,diff:LCt})});var WCt,M_e,jCt,qCt,GCt,pT,zCt,F_e,VCt,EU,rh,nh,mT,YCt,JCt,KCt,hT,V9,ZCt,XCt,ewt,W_e,j_e,q_e,gb,G_e,ld,z_e,L_e,V_e,Y_e,J_e,twt,rwt,nwt,qA,K_e,Z_e,Y9,X_e,Ic,bU,Du,z9,Ou,PI,eBe,gT,owt,SU,iwt,J9,K9,tBe,rBe,nBe,CU,U_e,oBe,hb,Nu,AT,IU,wU,iBe,Z9,sBe,aBe,X9,cBe,e8,uBe,kU,lBe,dBe,vU,fBe,Hf,t8,Fa,r8,swt,awt,pBe,oh,Wf,mBe,cwt,Ss,ts,$_e,RU,_U,MI,hBe,gBe,ABe,n8,yBe,BU,o8,H_e,Js,uwt,Qu,TU,xBe,La=h(()=>{wr();TK();vr();sr();id();a1();Zl();mI();m1();BB();oe();yn();kf();dc();ht();E1();dZ();Kl();it();Me();ct();NA();xL();PA();mu();j3();Jl();JE();gZ();$0e();IK();$f();vt();Mf();e1();kB();tT();VZ();l1();JB();sRe();n_e();uRe();L1();Iw();CB();hU();lA();lA();OI();P_e();_A();jJ();WCt=uT("effect_fiber_started",{incremental:!0}),M_e=uT("effect_fiber_active"),jCt=uT("effect_fiber_successes",{incremental:!0}),qCt=uT("effect_fiber_failures",{incremental:!0}),GCt=r_e(t_e("effect_fiber_lifetimes",cRe({start:.5,factor:2,count:35})),"time_unit","milliseconds"),pT="Continue",zCt="Done",F_e="Yield",VCt={_E:e=>e,_A:e=>e},EU=e=>{throw new Error(`BUG: FiberRuntime - ${ym(e)} - please report an issue at https://github.com/Effect-TS/effect/issues`)},rh=Symbol.for("effect/internal/fiberRuntime/YieldedOp"),nh=Te("effect/internal/fiberRuntime/yieldedOpChannel",()=>({currentOp:null})),mT={[bw]:(e,t,r)=>qn(()=>t.effect_instruction_i1(r)),OnStep:(e,t,r)=>Vt(Vt(r)),[Sw]:(e,t,r)=>qn(()=>t.effect_instruction_i2(r)),[f_]:(e,t,r)=>(e.patchRuntimeFlags(e.currentRuntimeFlags,t.patch),ed(e.currentRuntimeFlags)&&e.isInterrupted()?$t(e.getInterruptedCause()):Vt(r)),[Cw]:(e,t,r)=>(qn(()=>t.effect_instruction_i2(r)),qn(()=>t.effect_instruction_i0())?(e.pushStack(t),qn(()=>t.effect_instruction_i1())):Ue),[yE]:(e,t,r)=>{for(;;){let n=qn(()=>t.effect_instruction_i0.next(r));if(n.done)return Vt(n.value);let o=u_(n.value);if(jE(o)){if(o._tag==="Failure")return o}else return e.pushStack(t),o;r=o.value}}},YCt={[X1]:(e,t,r,n)=>(e.processNewInterruptSignal(n.cause),ed(t)?$t(n.cause):r),[tU]:(e,t,r,n)=>{throw new Error("It is illegal to have multiple concurrent run loops in a single fiber")},[eU]:(e,t,r,n)=>(n.onFiber(e,zK(t)),r),[rU]:(e,t,r,n)=>O(ku(),()=>r)},JCt=e=>mc(QCe(e),t=>Du(NCe(t),([r,n])=>{let o=new Map,i=[];for(let a of n){i.push(Uo(a));for(let c of a)o.set(c.request,c)}let s=i.flat();return tn(uwt(r.runAll(i),s,()=>s.forEach(a=>{a.listeners.interrupted=!0})),P1,o)},!1,!1)),KCt=m_(),hT=class extends Ys{[Xm]=TI;[ZB]=VCt;_fiberRefs;_fiberId;_queue=new Array;_children=null;_observers=new Array;_running=!1;_stack=[];_asyncInterruptor=null;_asyncBlockingOn=null;_exitValue=null;_steps=[];_isYielding=!1;currentRuntimeFlags;currentOpCount=0;currentSupervisor;currentScheduler;currentTracer;currentSpan;currentContext;currentDefaultServices;constructor(t,r,n){if(super(),this.currentRuntimeFlags=n,this._fiberId=t,this._fiberRefs=r,Q3(n)){let o=this.getFiberRef(Nf);WCt.unsafeUpdate(1,o),M_e.unsafeUpdate(1,o)}this.refreshRefCache()}commit(){return ki(this)}id(){return this._fiberId}resume(t){this.tell(ub(t))}get status(){return this.ask((t,r)=>r)}get runtimeFlags(){return this.ask((t,r)=>hI(r)?t.currentRuntimeFlags:r.runtimeFlags)}scope(){return Mve(this)}get children(){return this.ask(t=>Array.from(t.getChildren()))}getChildren(){return this._children===null&&(this._children=new Set),this._children}getInterruptedCause(){return this.getFiberRef(bA)}fiberRefs(){return this.ask(t=>t.getFiberRefs())}ask(t){return ye(()=>{let r=wA(this._fiberId);return this.tell(BI((n,o)=>{IA(r,V(()=>t(n,o)))})),Cn(r)})}tell(t){this._queue.push(t),this._running||(this._running=!0,this.drainQueueLaterOnExecutor())}get await(){return bi(t=>{let r=n=>t(M(n));if(this._exitValue!==null){r(this._exitValue);return}return this.tell(BI((n,o)=>{n._exitValue!==null?r(this._exitValue):n.addObserver(r)})),V(()=>this.tell(BI((n,o)=>{n.removeObserver(r)})))},this.id())}get inheritAll(){return st((t,r)=>{let n=t.id(),o=t.getFiberRefs(),i=r.runtimeFlags,s=this.getFiberRefs(),a=c1(o,n,s);t.setFiberRefs(a);let c=t.getFiberRef($_e),u=C(Cu(i,c),M3(Xl),M3(AL));return gA(u)})}get poll(){return V(()=>en(this._exitValue))}unsafePoll(){return this._exitValue}interruptAsFork(t){return V(()=>this.tell(nU(Hs(t))))}unsafeInterruptAsFork(t){this.tell(nU(Hs(t)))}addObserver(t){this._exitValue!==null?t(this._exitValue):this._observers.push(t)}removeObserver(t){this._observers=this._observers.filter(r=>r!==t)}getFiberRefs(){return this.setFiberRef($_e,this.currentRuntimeFlags),this._fiberRefs}unsafeDeleteFiberRef(t){this._fiberRefs=vB(this._fiberRefs,t)}getFiberRef(t){return this._fiberRefs.locals.has(t)?this._fiberRefs.locals.get(t)[0][1]:t.initial}setFiberRef(t,r){this._fiberRefs=pI(this._fiberRefs,{fiberId:this._fiberId,fiberRef:t,value:r}),this.refreshRefCache()}refreshRefCache(){this.currentDefaultServices=this.getFiberRef(mn),this.currentTracer=this.currentDefaultServices.unsafeMap.get(Pf.key),this.currentSupervisor=this.getFiberRef(RU),this.currentScheduler=this.getFiberRef(Gm),this.currentContext=this.getFiberRef(ui),this.currentSpan=this.currentContext.unsafeMap.get(wi.key)}setFiberRefs(t){this._fiberRefs=t,this.refreshRefCache()}addChild(t){this.getChildren().add(t)}removeChild(t){this.getChildren().delete(t)}transferChildren(t){let r=this._children;if(this._children=null,r!==null&&r.size>0)for(let n of r)n._exitValue===null&&t.add(this.currentRuntimeFlags,n)}drainQueueOnCurrentThread(){let t=!0;for(;t;){let r=pT,n=globalThis[eh];globalThis[eh]=this;try{for(;r===pT;)r=this._queue.length===0?zCt:this.evaluateMessageWhileSuspended(this._queue.splice(0,1)[0])}finally{this._running=!1,globalThis[eh]=n}this._queue.length>0&&!this._running?(this._running=!0,r===F_e?(this.drainQueueLaterOnExecutor(),t=!1):t=!0):t=!1}}drainQueueLaterOnExecutor(){this.currentScheduler.scheduleTask(this.run,this.getFiberRef(Qf),this)}drainQueueWhileRunning(t,r){let n=r;for(;this._queue.length>0;){let o=this._queue.splice(0,1)[0];n=YCt[o._tag](this,t,n,o)}return n}isInterrupted(){return!LF(this.getFiberRef(bA))}addInterruptedCause(t){let r=this.getFiberRef(bA);this.setFiberRef(bA,Vr(r,t))}processNewInterruptSignal(t){this.addInterruptedCause(t),this.sendInterruptSignalToAllChildren()}sendInterruptSignalToAllChildren(){if(this._children===null||this._children.size===0)return!1;let t=!1;for(let r of this._children)r.tell(nU(Hs(this.id()))),t=!0;return t}interruptAllChildren(){if(this.sendInterruptSignalToAllChildren()){let t=this._children.values();this._children=null;let r=!1;return yA({while:()=>!r,body:()=>{let o=t.next();return o.done?V(()=>{r=!0}):$r(o.value.await)},step:()=>{}})}return null}reportExitValue(t){if(Q3(this.currentRuntimeFlags)){let r=this.getFiberRef(Nf),n=this.id().startTimeMillis,o=Date.now();switch(GCt.unsafeUpdate(o-n,r),M_e.unsafeUpdate(-1,r),t._tag){case _r:{jCt.unsafeUpdate(1,r);break}case Rr:{qCt.unsafeUpdate(1,r);break}}}if(t._tag==="Failure"){let r=this.getFiberRef(tI);!OE(t.cause)&&r._tag==="Some"&&this.log("Fiber terminated with an unhandled error",t.cause,r)}}setExitValue(t){this._exitValue=t,this.reportExitValue(t);for(let r=this._observers.length-1;r>=0;r--)this._observers[r](t);this._observers=[]}getLoggers(){return this.getFiberRef(W_e)}log(t,r,n){let o=pt(n)?n.value:this.getFiberRef(PL),i=this.getFiberRef(V9);if(eZ(i,o))return;let s=this.getFiberRef(fB),a=this.getFiberRef(Of),c=this.getLoggers(),u=this.getFiberRefs();if(Gl(c)>0){let l=Dr(this.getFiberRef(mn),bs),d=new Date(l.unsafeCurrentTimeMillis());SEe(u,()=>{for(let f of c)f.log({fiberId:this.id(),logLevel:o,message:t,cause:r,context:u,spans:s,annotations:a,date:d})})}}evaluateMessageWhileSuspended(t){switch(t._tag){case rU:return F_e;case X1:return this.processNewInterruptSignal(t.cause),this._asyncInterruptor!==null&&(this._asyncInterruptor($t(t.cause)),this._asyncInterruptor=null),pT;case tU:return this._asyncInterruptor=null,this._asyncBlockingOn=null,this.evaluateEffect(t.effect),pT;case eU:return t.onFiber(this,this._exitValue!==null?h0e:g0e(this.currentRuntimeFlags,this._asyncBlockingOn)),pT;default:return EU(t)}}evaluateEffect(t){this.currentSupervisor.onResume(this);try{let r=ed(this.currentRuntimeFlags)&&this.isInterrupted()?$t(this.getInterruptedCause()):t;for(;r!==null;){let n=r,o=this.runLoop(n);if(o===rh){let i=nh.currentOp;nh.currentOp=null,i._op===ww?_Ce(this.currentRuntimeFlags)?(this.tell(Nve()),this.tell(ub(Pn)),r=null):r=Pn:i._op===gE&&(r=null)}else{this.currentRuntimeFlags=C(this.currentRuntimeFlags,T3(AL));let i=this.interruptAllChildren();i!==null?r=O(i,()=>o):(this._queue.length===0?this.setExitValue(o):this.tell(ub(o)),r=null)}}}finally{this.currentSupervisor.onSuspend(this)}}start(t){if(this._running)this.tell(ub(t));else{this._running=!0;let r=globalThis[eh];globalThis[eh]=this;try{this.evaluateEffect(t)}finally{this._running=!1,globalThis[eh]=r,this._queue.length>0&&this.drainQueueLaterOnExecutor()}}}startFork(t){this.tell(ub(t))}patchRuntimeFlags(t,r){let n=Tm(t,r);return globalThis[eh]=this,this.currentRuntimeFlags=n,n}initiateAsync(t,r){let n=!1,o=i=>{n||(n=!0,this.tell(ub(i)))};ed(t)&&(this._asyncInterruptor=o);try{r(o)}catch(i){o(kt(eo(i)))}}pushStack(t){this._stack.push(t),t._op==="OnStep"&&this._steps.push({refs:this.getFiberRefs(),flags:this.currentRuntimeFlags})}popStack(){let t=this._stack.pop();if(t)return t._op==="OnStep"&&this._steps.pop(),t}getNextSuccessCont(){let t=this.popStack();for(;t;){if(t._op!==Ew)return t;t=this.popStack()}}getNextFailCont(){let t=this.popStack();for(;t;){if(t._op!==bw&&t._op!==Cw&&t._op!==yE)return t;t=this.popStack()}}[CEe](t){return V(()=>_a(this.currentContext,t))}Left(t){return ut(t.left)}None(t){return ut(new Es)}Right(t){return Vt(t.right)}Some(t){return Vt(t.value)}Micro(t){return Kw(r=>{let n=r,o=R0e(k0e(t,this.currentContext));return o.addObserver(i=>{if(i._tag==="Success")return n(Vt(i.value));switch(i.cause._tag){case"Interrupt":return n($t(Hs(ai)));case"Fail":return n(ut(i.cause.error));case"Die":return n(Si(i.cause.defect))}}),Kw(i=>{n=s=>{i(Ue)},o.unsafeInterrupt()})})}[nF](t){let r=qn(()=>t.effect_instruction_i0()),n=this.getNextSuccessCont();return n!==void 0?(n._op in mT||EU(n),mT[n._op](this,n,r)):(nh.currentOp=Vt(r),rh)}[_r](t){let r=t,n=this.getNextSuccessCont();return n!==void 0?(n._op in mT||EU(n),mT[n._op](this,n,r.effect_instruction_i0)):(nh.currentOp=r,rh)}[Rr](t){let r=t.effect_instruction_i0,n=this.getNextFailCont();if(n!==void 0)switch(n._op){case Ew:case Sw:return ed(this.currentRuntimeFlags)&&this.isInterrupted()?$t($F(r)):qn(()=>n.effect_instruction_i1(r));case"OnStep":return ed(this.currentRuntimeFlags)&&this.isInterrupted()?$t($F(r)):Vt($t(r));case f_:return this.patchRuntimeFlags(this.currentRuntimeFlags,n.patch),ed(this.currentRuntimeFlags)&&this.isInterrupted()?$t(Vr(r,this.getInterruptedCause())):$t(r);default:EU(n)}else return nh.currentOp=$t(r),rh}[oF](t){return qn(()=>t.effect_instruction_i0(this,zK(this.currentRuntimeFlags)))}Blocked(t){let r=this.getFiberRefs(),n=this.currentRuntimeFlags;if(this._steps.length>0){let o=[],i=this._steps[this._steps.length-1],s=this.popStack();for(;s&&s._op!=="OnStep";)o.push(s),s=this.popStack();this.setFiberRefs(i.refs),this.currentRuntimeFlags=i.flags;let a=XE(i.refs,r),c=Cu(i.flags,n);return Vt(Qm(t.effect_instruction_i0,st(u=>{for(;o.length>0;)u.pushStack(o.pop());return u.setFiberRefs(eb(u.id(),u.getFiberRefs())(a)),u.currentRuntimeFlags=Tm(c)(u.currentRuntimeFlags),t.effect_instruction_i1})))}return xn(o=>O(PI(RL(t.effect_instruction_i0)),()=>o(t.effect_instruction_i1)))}RunBlocked(t){return JCt(t.effect_instruction_i0)}[xm](t){let r=t.effect_instruction_i0,n=this.currentRuntimeFlags,o=Tm(n,r);if(ed(o)&&this.isInterrupted())return $t(this.getInterruptedCause());if(this.patchRuntimeFlags(this.currentRuntimeFlags,r),t.effect_instruction_i1){let i=Cu(o,n);return this.pushStack(new CL(i,t)),qn(()=>t.effect_instruction_i1(n))}else return Pn}[bw](t){return this.pushStack(t),t.effect_instruction_i0}OnStep(t){return this.pushStack(t),t.effect_instruction_i0}[Ew](t){return this.pushStack(t),t.effect_instruction_i0}[Sw](t){return this.pushStack(t),t.effect_instruction_i0}[gE](t){return this._asyncBlockingOn=t.effect_instruction_i1,this.initiateAsync(this.currentRuntimeFlags,t.effect_instruction_i0),nh.currentOp=t,rh}[ww](t){return this._isYielding=!1,nh.currentOp=t,rh}[Cw](t){let r=t.effect_instruction_i0,n=t.effect_instruction_i1;return r()?(this.pushStack(t),n()):Pn}[yE](t){return mT[yE](this,t,void 0)}[AE](t){return qn(()=>t.commit())}runLoop(t){let r=t;for(this.currentOpCount=0;;){if(this.currentRuntimeFlags&RCe&&this.currentSupervisor.onEffect(this,r),this._queue.length>0&&(r=this.drainQueueWhileRunning(this.currentRuntimeFlags,r)),!this._isYielding){this.currentOpCount+=1;let n=this.currentScheduler.shouldYield(this);if(n!==!1){this._isYielding=!0,this.currentOpCount=0;let o=r;r=O(ku({priority:n}),()=>o)}}try{if(r=this.currentTracer.context(()=>{if(KCt!==r[Om]._V){let n=this.getFiberRef(mB);if(n._tag==="Some"){let o=r[Om]._V;this.log(`Executing an Effect versioned ${o} with a Runtime of version ${m_()}, you may want to dedupe the effect dependencies, you can use the language service plugin to detect this at compile time: https://github.com/Effect-TS/language-service`,Yi,n)}}return this[r._op](r)},this),r===rh){let n=nh.currentOp;return n._op===ww||n._op===gE?rh:(nh.currentOp=null,n._op===_r||n._op===Rr?n:$t(eo(n)))}}catch(n){r!==rh&&!se(r,"_op")||!(r._op in this)?r=fA(`Not a valid effect: ${ym(r)}`):sK(n)?r=$t(Vr(eo(n),Hs(ai))):r=Si(n)}}}run=()=>{this.drainQueueOnCurrentThread()}},V9=Te("effect/FiberRef/currentMinimumLogLevel",()=>pn(tZ("Info"))),ZCt=e=>fU(t=>{let r=d1(t.context,mn);Dr(r,$m).unsafe.log(e.log(t))}),XCt=Te(Symbol.for("effect/Logger/defaultLogger"),()=>ZCt(oRe)),ewt=Te(Symbol.for("effect/Logger/tracerLogger"),()=>fU(({annotations:e,cause:t,context:r,fiberId:n,logLevel:o,message:i})=>{let s=zB(Ji(jm(r,ui),wi));if(s._tag==="None"||s.value._tag==="ExternalSpan")return;let a=_a(jm(r,mn),bs),c={};for(let[u,l]of e)c[u]=l;c["effect.fiberId"]=JSe(n),c["effect.logLevel"]=o.label,t!==null&&t._tag!=="Empty"&&(c["effect.cause"]=Yl(t,{renderErrorCause:!0})),s.value.event(ym(Array.isArray(i)&&i.length===1?i[0]:i),a.unsafeCurrentTimeNanos(),c)})),W_e=Te(Symbol.for("effect/FiberRef/currentLoggers"),()=>oK(eA(XCt,ewt))),j_e=function(){if(typeof arguments[0]=="string")return ts(Of,ko(arguments[0],arguments[1]));let e=Object.entries(arguments[0]);return ts(Of,XSe(t=>{for(let r=0;r<e.length;r++){let[n,o]=e[r];ko(t,n,o)}return t}))},q_e=x(2,(e,t)=>{let r=typeof t=="string"?tZ(t):t;return st(n=>{let o=n.getFiberRef(V9);return eZ(o,r)?M(W()):te(e,H)})}),gb=x(e=>ar(e[0]),(e,t)=>Iu(jo(e,r=>ld(n=>t(r,n))))),G_e=x(e=>ar(e[0]),(e,t)=>Js(e,ld(r=>t(r)))),ld=e=>st(t=>{let r=t.getFiberRefs(),n=B3(t.currentRuntimeFlags,Xl);return O(r8,o=>SA(o,i=>st(s=>{let a=s.getFiberRefs(),c=s.currentRuntimeFlags,u=XE(a,r),l=Cu(c,n),d=XE(r,a);return s.setFiberRefs(eb(u,s.id(),r)),Js(NL(e(i),l),V(()=>{s.setFiberRefs(eb(d,s.id(),s.getFiberRefs()))}))})))}),z_e=e=>tn(nB,H(ad))(e),L_e=Symbol.for("effect/Effect/existsPar/found"),V_e=x(e=>fu(e[0])&&!ar(e[0]),(e,t,r)=>PB(r?.concurrency,()=>ye(()=>Y_e(e[Symbol.iterator](),0,t)),()=>Ho(Ic(e,(n,o)=>DL(t(n,o),{onTrue:()=>ut(L_e),onFalse:()=>Ue}),r),{onFailure:n=>n===L_e?M(!0):ut(n),onSuccess:()=>M(!1)}))),Y_e=(e,t,r)=>{let n=e.next();return n.done?M(!1):O(r(n.value,t),o=>o?M(o):Y_e(e,t+1,r))},J_e=x(e=>fu(e[0])&&!ar(e[0]),(e,t,r)=>{let n=r?.negate?(o,i)=>te(t(o,i),LIe):t;return PB(r?.concurrency,()=>ye(()=>_e(e).reduceRight((o,i,s)=>Zi(o,ye(()=>n(i,s)),(a,c)=>c?[i,...a]:a),V(()=>new Array))),()=>te(Ic(e,(o,i)=>te(n(o,i),s=>s?H(o):W()),r),ube))}),twt=e=>{if(Array.isArray(e)||fu(e))return[e,W()];let t=Object.keys(e),r=t.length;return[t.map(n=>e[n]),H(n=>{let o={};for(let i=0;i<r;i++)o[t[i]]=n[i];return o})]},rwt=(e,t,r)=>{let n=[];for(let o of e)n.push(wu(o));return O(Ic(n,be,{concurrency:r?.concurrency,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),o=>{let i=W(),s=o.length,a=new Array(s),c=new Array(s),u=!1;for(let l=0;l<s;l++){let d=o[l];d._tag==="Left"?(a[l]=H(d.left),u=!0):(c[l]=d.right,a[l]=i)}return u?t._tag==="Some"?ut(t.value(a)):ut(a):r?.discard?Ue:t._tag==="Some"?M(t.value(c)):M(c)})},nwt=(e,t,r)=>{let n=[];for(let o of e)n.push(wu(o));return r?.discard?Ic(n,be,{concurrency:r?.concurrency,batching:r?.batching,discard:!0,concurrentFinalizers:r?.concurrentFinalizers}):te(Ic(n,be,{concurrency:r?.concurrency,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),o=>t._tag==="Some"?t.value(o):o)},qA=(e,t)=>{let[r,n]=twt(e);return t?.mode==="validate"?rwt(r,n,t):t?.mode==="either"?nwt(r,n,t):t?.discard!==!0&&n._tag==="Some"?te(Ic(r,be,t),n.value):Ic(r,be,t)},K_e=e=>t=>qA(t,e),Z_e=(e,t)=>te(qA(_e(e).map(fn),t),Yg(r=>yB(r)?H(r.effect_instruction_i0):W())),Y9=x(2,(e,t)=>Array.from({length:t},()=>e)),X_e=x(e=>ar(e[0]),(e,t,r)=>qA(Y9(e,t),r)),Ic=x(e=>fu(e[0]),(e,t,r)=>st(n=>{let o=r?.batching===!0||r?.batching==="inherit"&&n.getFiberRef(eI);return r?.discard?AZ(r.concurrency,()=>hb(fI,r?.concurrentFinalizers)(i=>o?Du(e,(s,a)=>i(t(s,a)),!0,!1,1):mc(e,(s,a)=>i(t(s,a)))),()=>hb(i1,r?.concurrentFinalizers)(i=>Du(e,(s,a)=>i(t(s,a)),o,!1)),i=>hb(s1(i),r?.concurrentFinalizers)(s=>Du(e,(a,c)=>s(t(a,c)),o,!1,i))):AZ(r?.concurrency,()=>hb(fI,r?.concurrentFinalizers)(i=>o?z9(e,1,(s,a)=>i(t(s,a)),!0):Wo(e,(s,a)=>i(t(s,a)))),()=>hb(i1,r?.concurrentFinalizers)(i=>bU(e,(s,a)=>i(t(s,a)),o)),i=>hb(s1(i),r?.concurrentFinalizers)(s=>z9(e,i,(a,c)=>s(t(a,c)),o)))})),bU=(e,t,r)=>ye(()=>{let n=_e(e),o=new Array(n.length);return je(Du(n,(s,a)=>O(t(s,a),c=>V(()=>o[a]=c)),r,!1),M(o))}),Du=(e,t,r,n,o)=>xn(i=>OL(s=>st(a=>{let c=Array.from(e).reverse(),u=c.length;if(u===0)return Ue;let l=0,d=!1,f=o?Math.min(c.length,o):c.length,p=new Set,m=new Array,g=()=>p.forEach(R=>{R.currentScheduler.scheduleTask(()=>{R.unsafeInterruptAsFork(a.id())},0,R)}),A=new Array,E=new Array,y=new Array,b=()=>{let R=m.filter(({exit:B})=>B._tag==="Failure").sort((B,L)=>B.index<L.index?-1:B.index===L.index?0:1).map(({exit:B})=>B);return R.length===0&&R.push(Pn),R},w=(R,B=!1)=>{let L=Iu(s(R)),D=owt(L,a,a.currentRuntimeFlags,ad);return a.currentScheduler.scheduleTask(()=>{B&&D.unsafeInterruptAsFork(a.id()),D.resume(L)},0,D),D},I=()=>{n||(u-=c.length,c=[]),d=!0,g()},v=r?TL:fn,k=w(bi(R=>{let B=(D,ee)=>{D._op==="Blocked"?y.push(D):(m.push({index:ee,exit:D}),D._op==="Failure"&&!d&&I())},L=()=>{if(c.length>0){let D=c.pop(),ee=l++,F=()=>{let N=c.pop();return ee=l++,O(ku(),()=>O(v(i(t(N,ee))),_))},_=N=>c.length>0&&(B(N,ee),c.length>0)?F():M(N),P=O(v(i(t(D,ee))),_),$=w(P);A.push($),p.add($),d&&$.currentScheduler.scheduleTask(()=>{$.unsafeInterruptAsFork(a.id())},0,$),$.addObserver(N=>{let q;if(N._op==="Failure"?q=N:q=N.effect_instruction_i0,E.push($),p.delete($),B(q,ee),m.length===u)R(M(Nt(CA(b(),{parallel:!0}),()=>Pn)));else if(y.length+m.length===u){let re=b(),ie=y.map(ue=>ue.effect_instruction_i0).reduce($3);R(M(Qm(ie,Du([Nt(CA(re,{parallel:!0}),()=>Pn),...y.map(ue=>ue.effect_instruction_i1)],ue=>ue,r,!0,o))))}else L()})}};for(let D=0;D<f;D++)L()}));return $r(Gs(ys(i(ki(k))),GE({onFailure:R=>{I();let B=y.length+1,L=Math.min(typeof o=="number"?o:y.length,y.length),D=Array.from(y);return bi(ee=>{let F=[],_=0,P=0,$=(q,re)=>ie=>{F[q]=ie,_++,_===B&&ee(Vt($t(R))),D.length>0&&re&&N()},N=()=>{w(D.pop(),!0).addObserver($(P,!0)),P++};k.addObserver($(P,!1)),P++;for(let q=0;q<L;q++)N()})},onSuccess:()=>Wo(E,R=>R.inheritAll)})))}))),z9=(e,t,r,n)=>ye(()=>{let o=_e(e),i=new Array(o.length);return je(Du(o,(a,c)=>te(r(a,c),u=>i[c]=u),n,!1,t),M(i))}),Ou=e=>st((t,r)=>M(gT(e,t,r.runtimeFlags))),PI=e=>iwt(e,ad),eBe=x(2,(e,t)=>Ou(QL(e,r=>{let n=Vl(r);switch(n._tag){case"Left":return t(n.left);case"Right":return kt(n.right)}}))),gT=(e,t,r,n=null)=>{let o=SU(e,t,r,n);return o.resume(e),o},owt=(e,t,r,n=null)=>SU(e,t,r,n),SU=(e,t,r,n=null)=>{let o=sL(),i=t.getFiberRefs(),s=MK(i,o),a=new hT(o,s,r),c=jm(s,ui),u=a.currentSupervisor;return u.onStart(c,e,H(t),a),a.addObserver(d=>u.onEnd(d,a)),(n!==null?n:C(t.getFiberRef(nB),Nt(()=>t.scope()))).add(r,a),a},iwt=(e,t)=>st((r,n)=>M(gT(e,r,n.runtimeFlags,t))),J9=x(e=>gm(e[2]),(e,t,r,n)=>PB(n?.concurrency,()=>_e(e).reduce((o,i,s)=>Zi(o,i,(a,c)=>r(a,c,s)),M(t)),()=>O(bc(t),o=>O(Ic(e,(i,s)=>O(i,a=>OA(o,c=>r(c,a,s))),n),()=>Sc(o))))),K9=x(e=>fu(e[0]),(e,t,r)=>C(Ic(e,(n,o)=>wu(t(n,o)),r),te(n=>zCe(n,be)))),tBe=x(e=>fu(e[0]),(e,t,r)=>O(K9(e,t,{concurrency:r?.concurrency,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),([n,o])=>Cm(n)?ut(n):r?.discard?Ue:M(o))),rBe=e=>st((t,r)=>bi(n=>{let o=new Set,i,s=Yi,a=()=>{for(let l of o)l.unsafeInterruptAsFork(t.id())},c=!1,u=!0;for(let l of e){u=!1;let d=gT(Qa(l),t,r.runtimeFlags);if(o.add(d),d.addObserver(f=>{o.delete(d),i||(f._tag==="Success"?(c=!0,i=d,s=Yi,a()):s=to(f.cause,s)),c&&o.size===0&&n(i?je(uU(i),i.unsafePoll()):kt(s))}),i)break}return u?n(Ta(()=>new vu("Received an empty collection of effects"))):(c=!0,eT(o,t.id()))})),nBe=x(e=>fu(e[0])&&!ar(e[0]),(e,t,r,n)=>PB(n?.concurrency,()=>_e(e).reduce((o,i,s)=>Zi(o,i,(a,c)=>r(a,c,s)),t),()=>ye(()=>C(J9([t,...e],W(),(o,i,s)=>{switch(o._tag){case"None":return H(i);case"Some":return H(r(o.value,i,s))}},n),te(o=>{switch(o._tag){case"None":throw new Error("BUG: Effect.reduceEffect - please report an issue at https://github.com/Effect-TS/effect/issues");case"Some":return o.value}}))))),CU=e=>xc(t=>wt(Ji(t,Fa),{onNone:()=>e,onSome:r=>{switch(r.strategy._tag){case"Parallel":return e;case"Sequential":case"ParallelN":return O(Ac(r,i1),n=>Wf(e,n))}}})),U_e=e=>t=>xc(r=>wt(Ji(r,Fa),{onNone:()=>t,onSome:n=>n.strategy._tag==="ParallelN"&&n.strategy.parallelism===e?t:O(Ac(n,s1(e)),o=>Wf(t,o))})),oBe=e=>t=>hb(e,!0)(t),hb=(e,t)=>r=>xc(n=>wt(Ji(n,Fa),{onNone:()=>r(be),onSome:o=>{if(t===!0){let i=e._tag==="Parallel"?CU:e._tag==="Sequential"?wU:U_e(e.parallelism);switch(o.strategy._tag){case"Parallel":return i(r(CU));case"Sequential":return i(r(wU));case"ParallelN":return i(r(U_e(o.strategy.parallelism)))}}else return r(be)}})),Nu=e=>O(Fa,e),AT=e=>O(oh(),t=>Gs(e(t),r=>t.close(r))),IU=e=>O(oh(),t=>mBe(e,t)),wU=e=>xc(t=>wt(Ji(t,Fa),{onNone:()=>e,onSome:r=>{switch(r.strategy._tag){case"Sequential":return e;case"Parallel":case"ParallelN":return O(Ac(r,fI),n=>Wf(e,n))}}})),iBe=(e,t)=>Z9([sb(e,t)]),Z9=e=>ts(Nf,t=>Ul(t,e)),sBe=x(2,(e,t)=>AT(r=>O(Wf(e,r),t))),aBe=x(e=>ar(e[1]),(e,t,r)=>X9(e,t,(n,o)=>[n,o],r)),X9=x(e=>ar(e[1]),(e,t,r,n)=>ys(Hf(fn(e),fn(t),(o,i)=>Ru(o,i,{onSuccess:r,onFailure:(s,a)=>n?.concurrent?to(s,a):Vr(s,a)}),n))),cBe=x(e=>fu(e[0]),(e,t,r)=>mA(Ic(e,(n,o)=>mA(t(n,o)),r))),e8=e=>ts(mn,zt(bs,e)),uBe=e=>ts(mn,zt(Hm,e)),kU=e=>ts(mn,zt(uI,e)),lBe=e=>Nu(t=>O(Ac(t,Tu),r=>C(e,Wf(r),te(n=>[Da(o=>rd(r,xB(o))),n])))),dBe=x(e=>ar(e[1]),(e,t,r)=>Hf(e,t,(n,o)=>[n,o],r)),vU=x(e=>ar(e[1]),(e,t,r)=>r?.concurrent!==!0&&(r?.batching===void 0||r.batching===!1)?$E(e,t):Hf(e,t,(n,o)=>n,r)),fBe=x(e=>ar(e[1]),(e,t,r)=>r?.concurrent!==!0&&(r?.batching===void 0||r.batching===!1)?je(e,t):Hf(e,t,(n,o)=>o,r)),Hf=x(e=>ar(e[1]),(e,t,r,n)=>te(qA([e,t],{concurrency:n?.concurrent?2:1,batching:n?.batching,concurrentFinalizers:n?.concurrentFinalizers}),([o,i])=>r(o,i))),t8=e=>e===TCe?Ue:C(Zw,O(t=>{let r=Tm(t,e),n=Cu(r,t);return C(gA(e),je(ld(()=>gA(n))),$r)}),Iu),Fa=Jt("effect/Scope"),r8=Fa,swt=(e,t)=>{e.state._tag==="Open"&&e.state.finalizers.set({},t)},awt={[ML]:ML,[FL]:FL,pipe(){return Z(this,arguments)},fork(e){return V(()=>{let t=pBe(e);if(this.state._tag==="Closed")return t.state=this.state,t;let r={},n=o=>t.close(o);return this.state.finalizers.set(r,n),swt(t,o=>V(()=>{this.state._tag==="Open"&&this.state.finalizers.delete(r)})),t})},close(e){return ye(()=>{if(this.state._tag==="Closed")return Ue;let t=Array.from(this.state.finalizers.values()).reverse();return this.state={_tag:"Closed",exit:e},t.length===0?Ue:DK(this.strategy)?C(Wo(t,r=>fn(r(e))),O(r=>C(CA(r),dr(oI),Nt(()=>Pn)))):QK(this.strategy)?C(bU(t,r=>fn(r(e)),!1),O(r=>C(CA(r,{parallel:!0}),dr(oI),Nt(()=>Pn)))):C(z9(t,this.strategy.parallelism,r=>fn(r(e)),!1),O(r=>C(CA(r,{parallel:!0}),dr(oI),Nt(()=>Pn))))})},addFinalizer(e){return ye(()=>this.state._tag==="Closed"?e(this.state.exit):(this.state.finalizers.set({},e),Ue))}},pBe=(e=Tu)=>{let t=Object.create(awt);return t.strategy=e,t.state={_tag:"Open",finalizers:new Map},t},oh=(e=Tu)=>V(()=>pBe(e)),Wf=x(2,(e,t)=>kA(e,wo(Ra(Fa,t)))),mBe=x(2,(e,t)=>C(e,Wf(t),Gs(r=>t.close(r)))),cwt=e=>EA(e,{differ:N_e,fork:NI}),Ss=x(2,(e,t)=>$r(gb(O(Xi(e),r=>Zt(Dm(e,t),r)),r=>Dm(e,r)))),ts=x(2,(e,t)=>ci(e,r=>Ss(e,t(r)))),$_e=swe(BCe),RU=cwt(jA),_U=e=>Ic(e,aU),MI=e=>({...n1,commit(){return ki(this)},[Xm]:TI,id:()=>_e(e).reduce((r,n)=>jw(r,n.id()),ai),await:fn(bU(e,r=>ys(r.await),!1)),children:te(bU(e,r=>r.children,!1),b_),inheritAll:mc(e,r=>r.inheritAll),poll:te(Wo(e,r=>r.poll),SF(H(Vt(new Array)),(r,n)=>{switch(n._tag){case"None":return W();case"Some":switch(r._tag){case"None":return W();case"Some":return H(Ru(n.value,r.value,{onSuccess:(o,i)=>[o,...i],onFailure:to}))}}})),interruptAsFork:r=>mc(e,n=>n.interruptAsFork(r))}),hBe=e=>$r(PI(gc(e))),gBe=e=>ki(MI(e)),ABe=e=>gb(M(e),gc),n8=x(3,(e,t,r)=>o8(e,t,{onSelfWin:(n,o)=>O(n.await,i=>{switch(i._tag){case _r:return O(n.inheritAll,()=>r.onSelfDone(i,o));case Rr:return r.onSelfDone(i,o)}}),onOtherWin:(n,o)=>O(n.await,i=>{switch(i._tag){case _r:return O(n.inheritAll,()=>r.onOtherDone(i,o));case Rr:return r.onOtherDone(i,o)}})})),yBe=e=>xn(t=>Da(r=>O(PI(t(e)),n=>C(t(ki(n)),hc(()=>C(n,lU(r))))))),BU=x(2,(e,t)=>Da(r=>n8(e,t,{onSelfDone:(n,o)=>zE(n,{onFailure:i=>C(ki(o),_I(s=>to(i,s))),onSuccess:i=>C(o,xs(r),Zt(i))}),onOtherDone:(n,o)=>zE(n,{onFailure:i=>C(ki(o),_I(s=>to(s,i))),onSuccess:i=>C(o,xs(r),Zt(i))})}))),o8=x(3,(e,t,r)=>st((n,o)=>{let i=o.runtimeFlags,s=Ba(!0),a=SU(e,n,i,r.selfScope),c=SU(t,n,i,r.otherScope);return bi(u=>{a.addObserver(()=>H_e(a,c,r.onSelfWin,s,u)),c.addObserver(()=>H_e(c,a,r.onOtherWin,s,u)),a.startFork(e),c.startFork(t)},jw(a.id(),c.id()))})),H_e=(e,t,r,n,o)=>{JF(!0,!1)(n)&&o(r(e,t))},Js=x(2,(e,t)=>xn(r=>dn(r(e),{onFailure:n=>dn(t,{onFailure:o=>kt(Vr(n,o)),onSuccess:()=>kt(n)}),onSuccess:n=>Zt(t,n)}))),uwt=(e,t,r)=>Da(n=>Js(O(PI(Qa(e)),o=>bi(i=>{let s=t.map(u=>u.listeners.count),a=()=>{s.every(u=>u===0)&&t.every(u=>u.result.state.current._tag==="Pending"?!0:!!(u.result.state.current._tag==="Done"&&jE(u.result.state.current.effect)&&u.result.state.current.effect._tag==="Failure"&&Fw(u.result.state.current.effect.cause)))&&(c.forEach(u=>u()),r?.(),i(gc(o)))};o.addObserver(u=>{c.forEach(l=>l()),i(u)});let c=t.map((u,l)=>{let d=f=>{s[l]=f,a()};return u.listeners.addObserver(d),()=>u.listeners.removeObserver(d)});return a(),V(()=>{c.forEach(u=>u())})})),ye(()=>{let o=t.flatMap(i=>i.state.completed?[]:[i]);return mc(o,i=>D9(i.request,xB(n)))}))),Qu=(e,t)=>(t=Ec(t),Iu(st(r=>{let n=_a(r.getFiberRef(ui),Fa),o=Y1(r,e,t),i=r.getFiberRef(Pm),s=Dr(r.getFiberRef(mn),bs);return Zt(SA(n,a=>HZ(o,a,s,i)),o)}))),TU=e=>ts(mn,zt(Pf,e)),xBe=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ec(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return O(Qu(t,Ec(r)),o=>MA(n,wi,o))}return n=>O(Qu(t,Ec(r)),o=>MA(n,wi,o))}});var lwt,yT,i8,DU,EBe,bBe,SBe,CBe,wBe,IBe,kBe=h(()=>{Ws();oe();lwt="effect/ScheduleInterval",yT=Symbol.for(lwt),i8={[yT]:yT,startMillis:0,endMillis:0},DU=(e,t)=>e>t?i8:{[yT]:yT,startMillis:e,endMillis:t},EBe=x(2,(e,t)=>bBe(e,t)===e),bBe=x(2,(e,t)=>e.endMillis<=t.startMillis?e:t.endMillis<=e.startMillis?t:e.startMillis<t.startMillis?e:t.startMillis<e.startMillis?t:e.endMillis<=t.endMillis?e:t),SBe=e=>e.startMillis>=e.endMillis,CBe=x(2,(e,t)=>{let r=Math.max(e.startMillis,t.startMillis),n=Math.min(e.endMillis,t.endMillis);return DU(r,n)}),wBe=e=>Ki(e.endMillis-e.startMillis),IBe=e=>DU(e,Number.POSITIVE_INFINITY)});var Ks,s8,vBe,RBe,_Be,BBe,dd,QU=h(()=>{kBe();Ks=DU,s8=i8,vBe=EBe,RBe=SBe,_Be=CBe,BBe=wBe,dd=IBe});var fwt,c8,NU,DBe,TBe,QBe,pwt,OU,OBe,u8,NBe,PBe,MBe=h(()=>{vr();oe();it();QU();gw();fwt="effect/ScheduleIntervals",c8=Symbol.for(fwt),NU=e=>({[c8]:c8,intervals:e}),DBe=x(2,(e,t)=>kr(t.intervals)?kr(e.intervals)?Gt(e.intervals).startMillis<Gt(t.intervals).startMillis?TBe(Ur(e.intervals),t.intervals,Gt(e.intervals),Ut()):TBe(e.intervals,Ur(t.intervals),Gt(t.intervals),Ut()):t:e),TBe=(e,t,r,n)=>{let o=e,i=t,s=r,a=n;for(;kr(o)||kr(i);)if(!kr(o)&&kr(i))s.endMillis<Gt(i).startMillis?(a=C(a,fr(s)),s=Gt(i),i=Ur(i),o=Ut()):(s=Ks(s.startMillis,Gt(i).endMillis),i=Ur(i),o=Ut());else if(kr(o)&&xu(i))s.endMillis<Gt(o).startMillis?(a=C(a,fr(s)),s=Gt(o),i=Ut(),o=Ur(o)):(s=Ks(s.startMillis,Gt(o).endMillis),i=Ut(),o=Ur(o));else if(kr(o)&&kr(i))Gt(o).startMillis<Gt(i).startMillis?s.endMillis<Gt(o).startMillis?(a=C(a,fr(s)),s=Gt(o),o=Ur(o)):(s=Ks(s.startMillis,Gt(o).endMillis),o=Ur(o)):s.endMillis<Gt(i).startMillis?(a=C(a,fr(s)),s=Gt(i),i=Ur(i)):(s=Ks(s.startMillis,Gt(i).endMillis),i=Ur(i));else throw new Error(Fl("Intervals.unionLoop"));return NU(C(a,fr(s),gs))},QBe=x(2,(e,t)=>pwt(e.intervals,t.intervals,Ut())),pwt=(e,t,r)=>{let n=e,o=t,i=r;for(;kr(n)&&kr(o);){let s=C(Gt(n),_Be(Gt(o))),a=RBe(s)?i:C(i,fr(s));C(Gt(n),vBe(Gt(o)))?n=Ur(n):o=Ur(o),i=a}return NU(gs(i))},OU=e=>C(e.intervals,CE,Nt(()=>s8)).startMillis,OBe=e=>C(e.intervals,CE,Nt(()=>s8)).endMillis,u8=x(2,(e,t)=>OU(e)<OU(t)),NBe=e=>kr(e.intervals),PBe=x(2,(e,t)=>u8(e,t)?t:e)});var FBe,l8,LBe,GA,PU,UBe,$Be,HBe,xT=h(()=>{MBe();FBe=NU,l8=DBe,LBe=QBe,GA=OU,PU=OBe,UBe=u8,$Be=NBe,HBe=PBe});var d8,WBe,jBe,qBe,GBe,zBe,VBe,YBe=h(()=>{vr();xT();d8="Continue",WBe="Done",jBe=e=>({_tag:d8,intervals:e}),qBe=e=>({_tag:d8,intervals:FBe(Dt(e))}),GBe={_tag:WBe},zBe=e=>e._tag===d8,VBe=e=>e._tag===WBe});var Ab,qo,Mu,ih,li,FU=h(()=>{YBe();Ab=jBe,qo=qBe,Mu=GBe,ih=zBe,li=VBe});var FI,sh,JBe,ET,KBe,LU,ZBe,ah=h(()=>{vt();La();FI=Fa,sh=gB,JBe=SA,ET=rd,KBe=Wf,LU=Ac,ZBe=oh});var m8,LI,eTe,h8,A8,tTe,rTe,nTe,y8,XBe,gwt,Awt,oTe,$U,iTe,bT,HU,sTe,aTe,p8,UU,cTe,uTe,x8,lTe,E8,dTe,fTe,ST,ywt,xwt,Ewt,g8,WU,b8,bwt,pTe,mTe,hTe,CT,gTe,UI=h(()=>{Ws();id();mt();Ro();Zl();oe();ir();iT();it();Me();ct();bI();PA();Jl();$f();vt();tT();La();JB();SI();OI();m8=class{permits;waiters=new Set;taken=0;constructor(t){this.permits=t}get free(){return this.permits-this.taken}take=t=>_f(r=>{if(this.free<t){let n=()=>{this.free<t||(this.waiters.delete(n),r(ye(()=>this.free<t?this.take(t):(this.taken+=t,M(t)))))};return this.waiters.add(n),V(()=>{this.waiters.delete(n)})}r(ye(()=>this.free<t?this.take(t):(this.taken+=t,M(t))))});updateTakenUnsafe(t,r){return this.taken=r(this.taken),this.waiters.size>0&&t.getFiberRef(Gm).scheduleTask(()=>{let n=this.waiters.values(),o=n.next();for(;o.done===!1&&this.free>0;)o.value(),o=n.next()},t.getFiberRef(Qf),t),M(this.free)}updateTaken(t){return st(r=>this.updateTakenUnsafe(r,t))}resize=t=>$r(st(r=>(this.permits=t,this.free<0?Ue:this.updateTakenUnsafe(r,n=>n))));release=t=>this.updateTaken(r=>r-t);releaseAll=this.updateTaken(t=>0);withPermits=t=>r=>xn(n=>O(n(this.take(t)),o=>Js(n(r),this.release(o))));withPermitsIfAvailable=t=>r=>xn(n=>ye(()=>this.free<t?cb:(this.taken+=t,Js(n(kI(r)),this.release(t)))))},LI=e=>new m8(e),eTe=e=>V(()=>LI(e)),h8=class extends Ys{isOpen;waiters=[];scheduled=!1;constructor(t){super(),this.isOpen=t}commit(){return this.await}unsafeSchedule(t){return this.scheduled||this.waiters.length===0?Ue:(this.scheduled=!0,t.currentScheduler.scheduleTask(this.flushWaiters,t.getFiberRef(Qf),t),Ue)}flushWaiters=()=>{this.scheduled=!1;let t=this.waiters;this.waiters=[];for(let r=0;r<t.length;r++)t[r](Pn)};open=st(t=>this.isOpen?Ue:(this.isOpen=!0,this.unsafeSchedule(t)));unsafeOpen(){this.isOpen||(this.isOpen=!0,this.flushWaiters())}release=st(t=>this.isOpen?Ue:this.unsafeSchedule(t));await=_f(t=>this.isOpen?t(Ue):(this.waiters.push(t),V(()=>{let r=this.waiters.indexOf(t);r!==-1&&this.waiters.splice(r,1)})));unsafeClose(){this.isOpen=!1}close=V(()=>{this.isOpen=!1});whenOpen=t=>je(this.await,t)},A8=e=>new h8(e??!1),tTe=e=>V(()=>A8(e)),rTe=e=>$U(e,_U),nTe=x(2,(e,t)=>te(y8(e,t),r=>r[0])),y8=x(2,(e,t)=>{let r=At(t);return O(Oa(),n=>te(WU(W()),o=>[zs(gwt(e,r,o),n),Awt(o)]))}),XBe=(e,t,r)=>{let n=Io(At(t));return C(Ci(),jo(o=>Df(e,o)),te(o=>H([r+n,o])))},gwt=(e,t,r)=>xn(n=>C(Uf(o=>o.currentTimeMillis),O(o=>bwt(r,i=>{switch(i._tag){case"None":return H(XBe(e,t,o));case"Some":{let[s]=i.value;return s-o<=0?H(XBe(e,t,o)):W()}}})),O(o=>Ct(o)?fA("BUG: Effect.cachedInvalidate - please report an issue at https://github.com/Effect-TS/effect/issues"):n(Cn(o.value[1]))))),Awt=e=>Pa(e,W()),oTe=x(2,(e,t)=>$U(e,r=>t(MI(r)))),$U=x(2,(e,t)=>O(j9,r=>C(x8(e,r),Js(O(r.value,t))))),iTe=x(e=>fu(e[0]),(e,t)=>t?.discard?mc(e,Ou):te(Wo(e,Ou),MI)),bT=x(2,(e,t)=>st((r,n)=>{let o=t,i=gT(e,r,n.runtimeFlags,ad);if(o.state._tag==="Open"){let s=()=>Da(c=>ce(c,i.id())?Ue:$r(gc(i))),a={};o.state.finalizers.set(a,s),i.addObserver(()=>{o.state._tag!=="Closed"&&o.state.finalizers.delete(a)})}else i.unsafeInterruptAsFork(r.id());return M(i)})),HU=e=>Nu(t=>bT(e,t)),sTe=e=>ki(e),aTe=e=>ye(()=>O(e,ki)),p8=Symbol.for("effect/Effect/memoizeFunction.key"),UU=class{a;eq;[p8]=p8;constructor(t,r){this.a=t,this.eq=r}[me](t){return se(t,p8)?this.eq?this.eq(this.a,t.a):ce(this.a,t.a):!1}[he](){return this.eq?0:We(this,ae(this.a))}},cTe=(e,t)=>C(V(()=>fb()),O(WU),te(r=>n=>C(r.modifyEffect(o=>{let i=C(o,_o(new UU(n,t)));return Ct(i)?C(Ci(),jo(s=>C(RI(e(n)),Df(s),Ou)),te(s=>[s,C(o,Ma(new UU(n,t),s))])):M([i.value,o])}),O(Cn),O(([o,i])=>C(ab(o),Zt(i)))))),uTe=x(2,(e,t)=>C(fn(e),BU(fn(t)),r=>ys(r))),x8=x(2,(e,t)=>no(RU,n=>n.zip(t))(e)),lTe=x(2,(e,t)=>E8(e,{onTimeout:()=>hwe(t),duration:t})),E8=x(2,(e,{duration:t,onTimeout:r})=>ys(ST(e,{onTimeout:()=>pc(r),onSuccess:M,duration:t}))),dTe=x(2,(e,{duration:t,onTimeout:r})=>ys(ST(e,{onTimeout:()=>Tf(r),onSuccess:M,duration:t}))),fTe=x(2,(e,t)=>ST(e,{duration:t,onSuccess:H,onTimeout:W})),ST=x(2,(e,{duration:t,onSuccess:r,onTimeout:n})=>Da(o=>xn(i=>o8(i(e),Qa(Jm(t)),{onSelfWin:(s,a)=>O(s.await,c=>c._tag==="Success"?O(s.inheritAll,()=>Zt(xs(a,o),r(c.value))):O(xs(a,o),()=>$t(c.cause))),onOtherWin:(s,a)=>O(s.await,c=>c._tag==="Success"?O(s.inheritAll,()=>Zt(xs(a,o),n())):O(xs(a,o),()=>$t(c.cause))),otherScope:ad})))),ywt="effect/Ref/SynchronizedRef",xwt=Symbol.for(ywt),Ewt={_A:e=>e},g8=class extends Ys{ref;withLock;[xwt]=Ewt;[QB]=pZ;[Na]=Na;constructor(t,r){super(),this.ref=t,this.withLock=r,this.get=io(this.ref)}get;commit(){return this.get}modify(t){return this.modifyEffect(r=>M(t(r)))}modifyEffect(t){return this.withLock(C(O(io(this.ref),t),O(([r,n])=>Zt(Pa(this.ref,n),r))))}},WU=e=>V(()=>b8(e)),b8=e=>{let t=QA(e),r=LI(1);return new g8(t,r.withPermits(1))},bwt=x(2,(e,t)=>e.modifyEffect(r=>{let n=t(r);switch(n._tag){case"None":return M([r,r]);case"Some":return te(n.value,o=>[o,o])}})),pTe=x(2,(e,t)=>CT(e,t,(r,n)=>[r,n])),mTe=x(2,(e,t)=>CT(e,t,(r,n)=>r)),hTe=x(2,(e,t)=>CT(e,t,(r,n)=>n)),CT=x(3,(e,t,r)=>({...n1,commit(){return ki(this)},[Xm]:TI,id:()=>C(e.id(),iL(t.id())),await:C(e.await,ys,Hf(ys(t.await),r,{concurrent:!0}),fn),children:e.children,inheritAll:je(t.inheritAll,e.inheritAll),poll:Zi(e.poll,t.poll,(n,o)=>C(n,Gn(i=>C(o,dr(s=>zZ(i,s,{onSuccess:r,onFailure:to})))))),interruptAsFork:n=>je(e.interruptAsFork(n),t.interruptAsFork(n)),pipe(){return Z(this,arguments)}})),gTe=x(e=>ar(e[0]),(e,t,r)=>O(e,n=>qA(t(n),r).pipe(te(o=>Object.assign({},n,o)))))});var ATe,yTe=h(()=>{ATe=Symbol.for("effect/ManagedRuntime")});var xTe,ETe,S8,bTe,STe,CTe,wTe,C8,ITe,kTe,vTe=h(()=>{xTe="ExtendScope",ETe="Fold",S8="Fresh",bTe="FromEffect",STe="Scoped",CTe="Suspend",wTe="Provide",C8="ProvideMerge",ITe="MergeAll",kTe="ZipWith"});var VA={};tr(VA,{FiberTypeId:()=>wwt,Order:()=>kwt,RuntimeFiberTypeId:()=>Iwt,all:()=>Dwt,await:()=>$I,awaitAll:()=>Bwt,children:()=>Twt,done:()=>Qwt,dump:()=>Owt,dumpAll:()=>Nwt,fail:()=>Pwt,failCause:()=>Mwt,fromEffect:()=>Fwt,getCurrentFiber:()=>Lwt,id:()=>_wt,inheritAll:()=>qU,interrupt:()=>jf,interruptAll:()=>Hwt,interruptAllAs:()=>w8,interruptAs:()=>HI,interruptAsFork:()=>$wt,interruptFork:()=>Wwt,interrupted:()=>Uwt,isFiber:()=>vwt,isRuntimeFiber:()=>Rwt,join:()=>GU,joinAll:()=>jwt,map:()=>qwt,mapEffect:()=>Gwt,mapFiber:()=>zwt,match:()=>Vwt,never:()=>Ywt,orElse:()=>Jwt,orElseEither:()=>Kwt,poll:()=>Zwt,pretty:()=>Xwt,roots:()=>eIt,scoped:()=>rIt,status:()=>nIt,succeed:()=>oIt,unsafeRoots:()=>tIt,void:()=>iIt,zip:()=>sIt,zipLeft:()=>aIt,zipRight:()=>cIt,zipWith:()=>uIt});var wwt,Iwt,kwt,vwt,Rwt,_wt,$I,Bwt,Twt,Dwt,Qwt,Owt,Nwt,Pwt,Mwt,Fwt,Lwt,qU,jf,Uwt,HI,$wt,Hwt,w8,Wwt,GU,jwt,qwt,Gwt,zwt,Vwt,Ywt,Jwt,Kwt,Zwt,Xwt,eIt,tIt,rIt,nIt,oIt,iIt,sIt,aIt,cIt,uIt,WI=h(()=>{vt();UI();tT();La();wwt=Xm,Iwt=ZB,kwt=XB,vwt=Fve,Rwt=KB,_wt=Wve,$I=aU,Bwt=_U,Twt=Lve,Dwt=MI,Qwt=lb,Owt=cU,Nwt=Uve,Pwt=$ve,Mwt=ZZ,Fwt=Hve,Lwt=tRe,qU=uU,jf=gc,Uwt=jve,HI=xs,$wt=lU,Hwt=qve,w8=eT,Wwt=hBe,GU=ki,jwt=gBe,qwt=iU,Gwt=XZ,zwt=Gve,Vwt=zve,Ywt=Vve,Jwt=e9,Kwt=Yve,Zwt=Jve,Xwt=Kve,eIt=Zve,tIt=t9,rIt=ABe,nIt=Xve,oIt=r9,iIt=eRe,sIt=pTe,aIt=mTe,cIt=hTe,uIt=CT});var jI,qI,VU,RTe,k8,lIt,I8,wT,v8,R8,_Te,_8,BTe,YU,zU,B8,GI,TTe,qf,DTe,QTe,OTe,NTe,PTe,MTe,FTe,LTe,JU=h(()=>{sr();mt();Ro();WI();Zl();mI();oe();ht();it();Me();PA();ah();Jl();vt();kB();La();JB();Iw();lA();OI();jI=e=>function(){if(arguments.length===1){let t=arguments[0];return(r,...n)=>e(t,r,...n)}return e.apply(this,arguments)},qI=jI((e,t,r)=>{let n=sL(),o=[[ui,[[n,e.context]]]];r?.scheduler&&o.push([Gm,[[n,r.scheduler]]]);let i=XIe(e.fiberRefs,{entries:o,forkAs:n});r?.updateRefs&&(i=r.updateRefs(i,n));let s=new hT(n,i,e.runtimeFlags),a=t;r?.scope&&(a=O(LU(r.scope,Tu),u=>je(gB(u,Da(l=>ce(l,s.id())?Ue:xs(s,l))),Gs(t,l=>ET(u,l)))));let c=s.currentSupervisor;return c!==jA&&(c.onStart(e.context,a,W(),s),s.addObserver(u=>c.onEnd(u,s))),ad.add(e.runtimeFlags,s),r?.immediate===!1?s.resume(a):s.start(a),s}),VU=jI((e,t,r={})=>{let n=qI(e,t,r);return r.onExit&&n.addObserver(o=>{r.onExit(o)}),(o,i)=>VU(e)(C(n,HI(o??ai)),{...i,onExit:i?.onExit?s=>i.onExit(qZ(s)):void 0})}),RTe=jI((e,t)=>{let r=_8(e)(t);if(r._tag==="Failure")throw R8(r.effect_instruction_i0);return r.effect_instruction_i0}),k8=class extends Error{fiber;_tag="AsyncFiberException";constructor(t){super(`Fiber #${t.id().id} cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work`),this.fiber=t,this.name=this._tag,this.stack=this.message}},lIt=e=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let r=new k8(e);return Error.stackTraceLimit=t,r},I8=Symbol.for("effect/Runtime/FiberFailure"),wT=Symbol.for("effect/Runtime/FiberFailure/Cause"),v8=class extends Error{[I8];[wT];constructor(t){let r=M_(t)[0];super(r?.message||"An error has occurred"),this[I8]=I8,this[wT]=t,this.name=r?`(FiberFailure) ${r.name}`:"FiberFailure",r?.stack&&(this.stack=r.stack)}toJSON(){return{_id:"FiberFailure",cause:this[wT].toJSON()}}toString(){return"(FiberFailure) "+Yl(this[wT],{renderErrorCause:!0})}[Ce](){return this.toString()}},R8=e=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let r=new v8(e);return Error.stackTraceLimit=t,r},_Te=e=>{let t=e;switch(t._op){case"Failure":case"Success":return t;case"Left":return nd(t.left);case"Right":return Vt(t.right);case"Some":return Vt(t.value);case"None":return nd(new Es)}},_8=jI((e,t)=>{let r=_Te(t);if(r)return r;let n=new CI,o=qI(e)(t,{scheduler:n});n.flush();let i=o.unsafePoll();return i||UL(BL(lIt(o),jL(o)))}),BTe=jI((e,t,r)=>YU(e,t,r).then(n=>{switch(n._tag){case _r:return n.effect_instruction_i0;case Rr:throw R8(n.effect_instruction_i0)}})),YU=jI((e,t,r)=>new Promise(n=>{let o=_Te(t);o&&n(o);let i=qI(e)(t);i.addObserver(s=>{n(s)}),r?.signal!==void 0&&(r.signal.aborted?i.unsafeInterruptAsFork(i.id()):r.signal.addEventListener("abort",()=>{i.unsafeInterruptAsFork(i.id())},{once:!0}))})),zU=class{context;runtimeFlags;fiberRefs;constructor(t,r,n){this.context=t,this.runtimeFlags=r,this.fiberRefs=n}pipe(){return Z(this,arguments)}},B8=e=>new zU(e.context,e.runtimeFlags,e.fiberRefs),GI=()=>st((e,t)=>M(new zU(e.getFiberRef(ui),t.runtimeFlags,e.getFiberRefs()))),TTe=D3(Xl,_3,R3),qf=B8({context:ro(),runtimeFlags:TTe,fiberRefs:e0e()}),DTe=x(2,(e,t)=>B8({context:t(e.context),runtimeFlags:e.runtimeFlags,fiberRefs:e.fiberRefs})),QTe=VU(qf),OTe=qI(qf),NTe=BTe(qf),PTe=YU(qf),MTe=RTe(qf),FTe=_8(qf),LTe=e=>ye(()=>{let t;return O(Ci(),r=>O(GI(),n=>xn(o=>je(Ou(o(dn(e(i=>VU(n)(Df(i,r))),{onFailure:i=>iI(r,i),onSuccess:i=>(t=i,Ue)}))),o(hc(Cn(r),()=>t??Ue))))))})});var UTe,IT,D8=h(()=>{oe();vt();UTe=x(2,(e,t)=>e.modifyEffect(t)),IT=x(2,(e,t)=>e.modifyEffect(r=>{let n=t(r);switch(n._tag){case"None":return M([void 0,r]);case"Some":return te(n.value,o=>[void 0,o])}}))});function Cs(e){let t=Object.create(Fu);return t._op_layer=bTe,t.effect=e,t}var dIt,XU,fIt,Fu,pIt,kT,Q8,RT,O8,KU,N8,mIt,qTe,YA,e$,GTe,yb,P8,M8,zTe,VTe,t$,YTe,F8,L8,_T,r$,Gf,JTe,U8,JA,KTe,ZTe,n$,o$,XTe,eDe,tDe,rDe,nDe,HTe,hIt,i$,oDe,s$,a$,iDe,$8,c$,sDe,aDe,cDe,uDe,lDe,dDe,gIt,KA,xb,BT,fDe,pDe,zI,ch,mDe,TT,u$,hDe,gDe,ADe,yDe,xDe,EDe,Eb,bDe,H8,W8,vT,SDe,CDe,wDe,ZU,WTe,jTe,l$,DT=h(()=>{Vs();II();sr();Ws();m1();oe();kf();Me();ct();FU();xT();ah();$f();vt();UI();kB();La();yTe();Iw();vTe();SI();JU();lA();D8();_A();dIt="effect/Layer",XU=Symbol.for(dIt),fIt={_RIn:e=>e,_E:e=>e,_ROut:e=>e},Fu={[XU]:fIt,pipe(){return Z(this,arguments)}},pIt="effect/Layer/MemoMap",kT=Symbol.for(pIt),Q8=si()("effect/Layer/CurrentMemoMap",{defaultValue:()=>mIt()}),RT=e=>se(e,XU),O8=e=>e._op_layer===S8,KU=class{ref;[kT];constructor(t){this.ref=t,this[kT]=kT}getOrElseMemoize(t,r){return C(UTe(this.ref,n=>{let o=n.get(t);if(o!==void 0){let[i,s]=o,a=C(i,O(([c,u])=>C(ab(c),Zt(u))),Gs(GE({onFailure:()=>Ue,onSuccess:()=>SA(r,s)})));return M([a,n])}return C(rb(0),O(i=>C(Ci(),O(s=>C(rb(()=>Ue),te(a=>{let c=xn(l=>C(oh(),O(d=>C(l(O(GTe(t,d,!0),f=>RI(f(this)))),fn,O(f=>{switch(f._tag){case Rr:return C(iI(s,f.effect_instruction_i0),je(rd(d,f)),je(kt(f.effect_instruction_i0)));case _r:return C(Pa(a,p=>C(rd(d,p),AA(nb(i,m=>[m===1,m-1])),$r)),je(ob(i,p=>p+1)),je(SA(r,p=>C(V(()=>n.delete(t)),je(io(a)),O(m=>m(p))))),je(Mm(s,f.effect_instruction_i0)),Zt(f.effect_instruction_i0[1]))}}))))),u=[C(Cn(s),Gs(zE({onFailure:()=>Ue,onSuccess:()=>ob(i,l=>l+1)}))),l=>C(io(a),O(d=>d(l)))];return[c,O8(t)?n:n.set(t,u)]}))))))}),ys)}},N8=ye(()=>te(WU(new Map),e=>new KU(e))),mIt=()=>new KU(b8(new Map)),qTe=e=>Nu(t=>YA(e,t)),YA=x(2,(e,t)=>O(N8,r=>e$(e,r,t))),e$=x(3,(e,t,r)=>O(GTe(e,r),n=>MA(n(t),Q8,t))),GTe=(e,t,r=!1)=>{let n=e;switch(n._op_layer){case"Locally":return V(()=>o=>n.f(o.getOrElseMemoize(n.self,t)));case"ExtendScope":return V(()=>o=>Nu(i=>o.getOrElseMemoize(n.layer,i)));case"Fold":return V(()=>o=>C(o.getOrElseMemoize(n.layer,t),dn({onFailure:i=>o.getOrElseMemoize(n.failureK(i),t),onSuccess:i=>o.getOrElseMemoize(n.successK(i),t)})));case"Fresh":return V(()=>o=>C(n.layer,YA(t)));case"FromEffect":return r?V(()=>o=>n.effect):V(()=>o=>o.getOrElseMemoize(e,t));case"Provide":return V(()=>o=>C(o.getOrElseMemoize(n.first,t),O(i=>C(o.getOrElseMemoize(n.second,t),zs(i)))));case"Scoped":return r?V(()=>o=>Wf(n.effect,t)):V(()=>o=>o.getOrElseMemoize(e,t));case"Suspend":return V(()=>o=>o.getOrElseMemoize(n.evaluate(),t));case"ProvideMerge":return V(()=>o=>C(o.getOrElseMemoize(n.first,t),Zi(o.getOrElseMemoize(n.second,t),n.zipK)));case"ZipWith":return uB(function*(){let o=yield*Ac(t,IB),i=yield*Ac(o,Tu),s=yield*Ac(o,Tu);return a=>C(a.getOrElseMemoize(n.first,i),Hf(a.getOrElseMemoize(n.second,s),n.zipK,{concurrent:!0}))});case"MergeAll":{let o=n.layers;return te(Ac(t,IB),i=>s=>{let a=new Array(o.length);return te(Du(o,Xw(function*(c,u){let l=yield*Ac(i,Tu),d=yield*s.getOrElseMemoize(c,l);a[u]=d}),!1,!1),()=>K6(...a))})}}},yb=x(2,(e,t)=>a$(e,{onFailure:t,onSuccess:ch})),P8=x(2,(e,t)=>s$(e,{onFailure:t,onSuccess:ch})),M8=e=>_T(od(e)),zTe=e=>r$(()=>od(e())),VTe=e=>i$(e,()=>ro()),t$=()=>Cs(Oa()),YTe=e=>{let t=Object.create(Fu);return t._op_layer=xTe,t.layer=e,t},F8=e=>_T(VE(e)),L8=e=>r$(()=>VE(e())),_T=e=>Cs(kt(e)),r$=e=>Cs(Tf(e)),Gf=x(2,(e,t)=>a$(e,{onFailure:F8,onSuccess:t})),JTe=x(2,(e,t)=>Gf(e,Dr(t))),U8=e=>{let t=Object.create(Fu);return t._op_layer=S8,t.layer=e,t},JA=x(2,(e,t)=>{let r=$w(e),n=r?e:t;return Cs(te(r?t:e,i=>Ra(n,i)))}),KTe=e=>Cs(te(e,()=>ro()));ZTe=x(3,(e,t,r)=>n$(e,tn(t,r))),n$=x(2,(e,t)=>{let r=Object.create(Fu);return r._op_layer="Locally",r.self=e,r.f=t,r}),o$=x(3,(e,t,r)=>n$(e,no(t,r))),XTe=(e,t)=>xb(Ss(e,t)),eDe=(e,t)=>xb(ts(e,t)),tDe=(e,t,r)=>Cs(te(e,n=>Ra(t,r(n)))),rDe=e=>IU(je(Nu(t=>C(e,YA(t))),xA)),nDe=function(){return arguments.length===1?e=>HTe(arguments[0],e):HTe(arguments[0],arguments[1])},HTe=(e,t)=>zI(e,new Proxy({...t},{get(r,n,o){if(n in r)return r[n];let i=Error.stackTraceLimit;Error.stackTraceLimit=2;let s=new Error(`${e.key}: Unimplemented method "${n.toString()}"`);return Error.stackTraceLimit=i,s.name="UnimplementedError",hIt(s)},has:ka})),hIt=e=>{let t=Si(e);function r(){return t}return Object.assign(r,t),Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r},i$=x(2,(e,t)=>Gf(e,r=>ch(t(r)))),oDe=x(2,(e,t)=>yb(e,r=>L8(()=>t(r)))),s$=x(2,(e,{onFailure:t,onSuccess:r})=>{let n=Object.create(Fu);return n._op_layer=ETe,n.layer=e,n.failureK=t,n.successK=r,n}),a$=x(2,(e,{onFailure:t,onSuccess:r})=>s$(e,{onFailure:n=>{let o=sI(n);switch(o._tag){case"Left":return t(o.left);case"Right":return _T(o.right)}},onSuccess:r})),iDe=e=>Nu(t=>te(q1(YA(e,t)),Cs)),$8=x(2,(e,t)=>H8(e,t,(r,n)=>wo(r,n))),c$=(...e)=>{let t=Object.create(Fu);return t._op_layer=ITe,t.layers=e,t},sDe=e=>yb(e,t=>M8(t)),aDe=x(2,(e,t)=>yb(e,t)),cDe=e=>$8(t$(),e),uDe=x(4,(e,t,r,n)=>i$(e,o=>Ra(r,n(_a(o,t))))),lDe=x(2,(e,t)=>TT(()=>{let r=Jt("effect/Layer/retry/{ state: unknown }");return C(zI(r,{state:t.initial}),Gf(n=>dDe(e,t,r,C(n,Dr(r)).state)))})),dDe=(e,t,r,n)=>C(e,yb(o=>C(gIt(t,r,o,n),Gf(i=>U8(dDe(e,t,r,C(i,Dr(r)).state)))))),gIt=(e,t,r,n)=>JA(t,C(zm,O(o=>C(e.step(o,r,n),O(([i,s,a])=>li(a)?ut(r):C(wI(Ki(GA(a.intervals)-o)),Zt({state:i}))))))),KA=x(2,(e,t)=>{let r=$w(e),n=r?e:t;return BT(te(r?t:e,i=>Ra(n,i)))}),xb=e=>BT(C(e,Zt(ro()))),BT=e=>{let t=Object.create(Fu);return t._op_layer=STe,t.effect=e,t},fDe=BT(te(gb(oh(),(e,t)=>e.close(t)),e=>Ra(FI,e))),pDe=e=>JA(e,e),zI=x(2,(e,t)=>{let r=$w(e);return Cs(M(Ra(r?e:t,r?t:e)))}),ch=e=>Cs(M(e)),mDe=ch(ro()),TT=e=>{let t=Object.create(Fu);return t._op_layer=CTe,t.evaluate=e,t},u$=x(2,(e,t)=>{let r=$w(e),n=r?e:t,o=r?t:e;return Cs(V(()=>Ra(n,o())))}),hDe=e=>Cs(V(e)),gDe=x(2,(e,t)=>Gf(e,r=>Cs(Zt(t(r),r)))),ADe=x(2,(e,t)=>yb(e,r=>Cs(O(t(r),()=>ut(r))))),yDe=x(2,(e,t)=>P8(e,r=>Cs(O(t(r),()=>kt(r))))),xDe=e=>C(Nu(t=>YA(e,t)),O(t=>C(GI(),zs(t)))),EDe=x(2,(e,t)=>O(Nu(r=>e$(e,t,r)),r=>C(GI(),zs(r)))),Eb=x(2,(e,t)=>TT(()=>{let r=Object.create(Fu);return r._op_layer=wTe,r.first=Object.create(Fu,{_op_layer:{value:C8,enumerable:!0},first:{value:t$(),enumerable:!0},second:{value:Array.isArray(t)?c$(...t):t},zipK:{value:(n,o)=>C(n,wo(o))}}),r.second=e,r})),bDe=x(2,(e,t)=>{let r=Object.create(Fu);return r._op_layer=C8,r.first=t,r.second=Eb(e,t),r.zipK=(n,o)=>C(n,wo(o)),r}),H8=x(3,(e,t,r)=>TT(()=>{let n=Object.create(Fu);return n._op_layer=kTe,n.first=e,n.second=t,n.zipK=r,n})),W8=e=>{let t=Jt("effect/Layer/unwrapEffect/Layer.Layer<R1, E1, A>");return Gf(JA(t,e),r=>Dr(r,t))},vT=e=>{let t=Jt("effect/Layer/unwrapScoped/Layer.Layer<R1, E1, A>");return Gf(KA(t,e),r=>Dr(r,t))},SDe=x(e=>RT(e[0]),function(){let e=arguments;return o$(e[0],Of,typeof e[1]=="string"?ko(e[1],e[2]):t=>Object.entries(e[1]).reduce((r,[n,o])=>ko(r,n,o),t))}),CDe=x(e=>RT(e[0]),function(){let e=arguments;return o$(e[0],HE,typeof e[1]=="string"?ko(e[1],e[2]):t=>Object.entries(e[1]).reduce((r,[n,o])=>ko(r,n,o),t))}),wDe=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ec(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return vT(te(r?.onEnd?jo(Qu(t,r),o=>ld(i=>r.onEnd(o,i))):Qu(t,r),o=>ZU(n,o)))}return n=>vT(te(r?.onEnd?jo(Qu(t,r),o=>ld(i=>r.onEnd(o,i))):Qu(t,r),o=>ZU(n,o)))},ZU=x(2,(e,t)=>Eb(e,ch(Ra(wi,t)))),WTe=x(2,(e,t)=>AT(r=>O(YA(t,r),n=>WL(e,n)))),jTe=x(2,(e,t)=>{let r=XE(qf.fiberRefs,t.fiberRefs),n=Cu(qf.runtimeFlags,t.runtimeFlags);return xn(o=>st(i=>{let s=i.getFiberRef(ui),a=i.getFiberRefs(),c=eb(i.id(),a)(r),u=i.currentRuntimeFlags,l=Tm(n)(u),d=XE(c,a),f=Cu(l,u);return i.setFiberRefs(c),i.currentRuntimeFlags=l,Js(WL(o(e),wo(s,t.context)),st(p=>(p.setFiberRefs(eb(p.id(),p.getFiberRefs())(d)),p.currentRuntimeFlags=Tm(f)(p.currentRuntimeFlags),Ue)))}))}),l$=x(2,(e,t)=>Array.isArray(t)?WTe(e,c$(...t)):RT(t)?WTe(e,t):J6(t)?WL(e,t):ATe in t?O(t.runtimeEffect,r=>jTe(e,r)):jTe(e,t))});var IDe,kDe,vDe,RDe,_De=h(()=>{sr();oe();vt();Mf();e1();La();IDe=te(Xi(mn),Dr($m)),kDe=e=>ci(mn,t=>e(Dr(t,$m))),vDe=x(2,(e,t)=>no(e,mn,zt($m,t))),RDe=e=>ts(mn,zt($m,e))});var pr={};tr(pr,{Class:()=>q8,Error:()=>YI,Structural:()=>SIt,TaggedClass:()=>bIt,TaggedError:()=>uh,array:()=>BDe,case:()=>EIt,struct:()=>f$,tagged:()=>VI,taggedEnum:()=>CIt,tuple:()=>xIt,unsafeArray:()=>j8,unsafeStruct:()=>yIt});function wIt(){if(arguments.length===1){let r=arguments[0];return function(n){return r[n._tag](n)}}let e=arguments[0];return arguments[1][e._tag](e)}var f$,yIt,xIt,BDe,j8,EIt,VI,q8,bIt,SIt,CIt,YI,uh,lh=h(()=>{vt();Vw();Af();ct();f$=zw,yIt=e=>Object.setPrototypeOf(e,gf),xIt=(...e)=>j8(e),BDe=e=>j8(e.slice(0)),j8=e=>Object.setPrototypeOf(e,cCe),EIt=()=>e=>e===void 0?Object.create(gf):f$(e),VI=e=>t=>{let r=t===void 0?Object.create(gf):f$(t);return r._tag=e,r},q8=Bm,bIt=e=>{class t extends q8{_tag=e}return t},SIt=Bm,CIt=()=>new Proxy({},{get(e,t,r){return t==="$is"?mf:t==="$match"?wIt:VI(t)}});YI=function(){let e=Symbol.for("effect/Data/Error/plainArgs");return{BaseEffectError:class extends AB{constructor(r){super(r?.message,r?.cause?{cause:r.cause}:void 0),r&&(Object.assign(this,r),Object.defineProperty(this,e,{value:r,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}.BaseEffectError}(),uh=e=>{let t={BaseEffectError:class extends YI{_tag=e}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError}});var G8,z8,QDe,IIt,kIt,ODe,vIt,RIt,zf,NT,_It,JI,NDe,BIt,PDe,p$,TIt,DIt,QIt,OIt,m$,OT,NIt,PIt,MIt,V8,FIt,LIt,Y8,KI,bb,MDe,FDe,UIt,$It,LDe,UDe,HIt,WIt,TDe,$De,jIt,HDe,QT,WDe,qIt,GIt,DDe,zIt,jDe=h(()=>{Vs();mt();oe();yn();ir();ht();it();Me();ct();G8=Symbol.for("effect/DateTime"),z8=Symbol.for("effect/DateTime/TimeZone"),QDe={[G8]:G8,pipe(){return Z(this,arguments)},[Ce](){return this.toString()},toJSON(){return KI(this).toJSON()}},IIt={...QDe,_tag:"Utc",[he](){return We(this,hu(this.epochMillis))},[me](e){return NT(e)&&e._tag==="Utc"&&this.epochMillis===e.epochMillis},toString(){return`DateTime.Utc(${KI(this).toJSON()})`}},kIt={...QDe,_tag:"Zoned",[he](){return C(hu(this.epochMillis),we(ae(this.zone)),We(this))},[me](e){return NT(e)&&e._tag==="Zoned"&&this.epochMillis===e.epochMillis&&ce(this.zone,e.zone)},toString(){return`DateTime.Zoned(${zIt(this)})`}},ODe={[z8]:z8,[Ce](){return this.toString()}},vIt={...ODe,_tag:"Named",[he](){return We(this,Lt(`Named:${this.id}`))},[me](e){return JI(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},RIt={...ODe,_tag:"Offset",[he](){return We(this,Lt(`Offset:${this.offset}`))},[me](e){return JI(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${FDe(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},zf=(e,t,r)=>{let n=Object.create(kIt);return n.epochMillis=e,n.zone=t,Object.defineProperty(n,"partsUtc",{value:r,enumerable:!1,writable:!0}),Object.defineProperty(n,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(n,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),n},NT=e=>se(e,G8),_It=e=>NT(e[0]),JI=e=>se(e,z8),NDe=e=>JI(e)&&e._tag==="Named",BIt=e=>e._tag==="Zoned",PDe=e=>{let t=Object.create(IIt);return t.epochMillis=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},p$=e=>{let t=e.getTime();if(Number.isNaN(t))throw new bB("Invalid date");return PDe(t)},TIt=e=>{if(NT(e))return e;if(e instanceof Date)return p$(e);if(typeof e=="object"){let t=new Date(0);return WIt(t,e),p$(t)}else if(typeof e=="string"&&!DIt(e))return p$(new Date(e+"Z"));return p$(new Date(e))},DIt=e=>/Z|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),QIt=-864e13+12*60*60*1e3,OIt=864e13-14*60*60*1e3,m$=(e,t)=>{if(t?.timeZone===void 0&&NT(e)&&BIt(e))return e;let r=TIt(e);if(r.epochMillis<QIt||r.epochMillis>OIt)throw new RangeError(`Epoch millis out of range: ${r.epochMillis}`);let n;if(t?.timeZone===void 0){let o=new Date(r.epochMillis).getTimezoneOffset()*-60*1e3;n=V8(o)}else if(JI(t?.timeZone))n=t.timeZone;else if(typeof t?.timeZone=="number")n=V8(t.timeZone);else{let o=Y8(t.timeZone);if(Ct(o))throw new bB(`Invalid time zone: ${t.timeZone}`);n=o.value}return t?.adjustForTimeZone!==!0?zf(r.epochMillis,n,r.partsUtc):$De(r.epochMillis,n,t?.disambiguation??"compatible")},OT=Te("effect/DateTime/validZoneCache",()=>new Map),NIt={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},PIt=e=>{let t=e.resolvedOptions().timeZone;if(OT.has(t))return OT.get(t);let r=Object.create(vIt);return r.id=t,r.format=e,OT.set(t,r),r},MIt=e=>{if(OT.has(e))return OT.get(e);try{return PIt(new Intl.DateTimeFormat("en-US",{...NIt,timeZone:e}))}catch{throw new bB(`Invalid time zone: ${e}`)}},V8=e=>{let t=Object.create(RIt);return t.offset=e,t},FIt=EE(MIt),LIt=/^(?:GMT|[+-])/,Y8=e=>{if(LIt.test(e)){let t=HDe(e);return t===null?W():H(V8(t))}return FIt(e)},KI=e=>new Date(e.epochMillis),bb=e=>{if(e._tag==="Utc")return new Date(e.epochMillis);if(e.zone._tag==="Offset")return new Date(e.epochMillis+e.zone.offset);if(e.adjustedEpochMillis!==void 0)return new Date(e.adjustedEpochMillis);let t=e.zone.format.formatToParts(e.epochMillis).filter(n=>n.type!=="literal"),r=new Date(0);return r.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),r.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMillis=r.getTime(),r},MDe=e=>bb(e).getTime()-$It(e),FDe=e=>{let t=Math.abs(e),r=Math.floor(t/(60*60*1e3)),n=Math.round(t%(60*60*1e3)/(60*1e3));return n===60&&(r+=1,n=0),`${e<0?"-":"+"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},UIt=e=>FDe(MDe(e)),$It=e=>e.epochMillis,LDe=e=>({millis:e.getUTCMilliseconds(),seconds:e.getUTCSeconds(),minutes:e.getUTCMinutes(),hours:e.getUTCHours(),day:e.getUTCDate(),weekDay:e.getUTCDay(),month:e.getUTCMonth()+1,year:e.getUTCFullYear()}),UDe=e=>e._tag==="Utc"?HIt(e):(e.partsAdjusted!==void 0||(e.partsAdjusted=qIt(e,LDe)),e.partsAdjusted),HIt=e=>(e.partsUtc!==void 0||(e.partsUtc=GIt(e,LDe)),e.partsUtc),WIt=(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 r=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+r)}t.hours!==void 0&&e.setUTCHours(t.hours),t.minutes!==void 0&&e.setUTCMinutes(t.minutes),t.seconds!==void 0&&e.setUTCSeconds(t.seconds),t.millis!==void 0&&e.setUTCMilliseconds(t.millis)},TDe=24*60*60*1e3,$De=(e,t,r)=>{if(t._tag==="Offset")return zf(e-t.offset,t);let n=QT(e-TDe,e,t),o=QT(e+TDe,e,t);if(n===o)return zf(e-n,t);let i=n<o,s=n-o;if(i){if(QT(e-o,e,t)===o)return zf(e-o,t);let u=zf(e-n,t),l=bb(u).getTime();if(e!==l)switch(r){case"reject":{let d=new Date(e).toISOString();throw new RangeError(`Gap time: ${d} does not exist in time zone ${t.id}`)}case"earlier":return zf(e-o,t);case"compatible":case"later":return u}return u}if(QT(e-n,e,t)===n){if(r==="earlier"||r==="compatible"||QT(e-n+s,e+s,t)===n)return zf(e-n,t);if(r==="reject"){let u=new Date(e).toISOString();throw new RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return zf(e-o,t)},jIt=/([+-])(\d{2}):(\d{2})$/,HDe=e=>{let t=jIt.exec(e);if(t===null)return null;let[,r,n,o]=t;return(r==="+"?1:-1)*(Number(n)*60+Number(o))*60*1e3},QT=(e,t,r)=>{let n=r.format.formatToParts(e).find(i=>i.type==="timeZoneName")?.value??"";if(n==="GMT")return 0;let o=HDe(n);return o===null?MDe(zf(t,r)):o},WDe=x(_It,(e,t,r)=>{if(e._tag==="Utc"){let i=KI(e);return t(i),PDe(i.getTime())}let n=bb(e),o=new Date(n.getTime());return t(o),$De(o.getTime(),e.zone,r?.disambiguation??"compatible")}),qIt=x(2,(e,t)=>t(bb(e))),GIt=x(2,(e,t)=>t(KI(e))),DDe=e=>{let t=bb(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${UIt(e)}`},zIt=e=>e.zone._tag==="Offset"?DDe(e):`${DDe(e)}[${e.zone.id}]`});var qDe,J8=h(()=>{qDe=e=>e.length>0});function Z8(e,t){return t?.[e.toLocaleLowerCase()]??Number(e)}var X8,YIt,e5,JIt,Lu,zDe,Uu,VDe,YDe,K8,JDe,KIt,ZIt,XIt,ZI,e0t,t0t,r0t,n0t,o0t,i0t,s0t,XI,a0t,c0t,t5=h(()=>{wr();lh();Ei();mt();mm();oe();ir();ht();jDe();Lm();it();Me();ct();J8();X8=Symbol.for("effect/Cron"),YIt={[X8]:X8,[me](e){return e5(e)&&e0t(this,e)},[he](){return C(ae(this.tz),we(So(_e(this.seconds))),we(So(_e(this.minutes))),we(So(_e(this.hours))),we(So(_e(this.days))),we(So(_e(this.months))),we(So(_e(this.weekdays))),We(this))},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"Cron",tz:this.tz,seconds:_e(this.seconds),minutes:_e(this.minutes),hours:_e(this.hours),days:_e(this.days),months:_e(this.months),weekdays:_e(this.weekdays)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},e5=e=>se(e,X8),JIt=e=>{let t=Object.create(YIt);t.seconds=new Set(Vi(e.seconds??[0],oo)),t.minutes=new Set(Vi(e.minutes,oo)),t.hours=new Set(Vi(e.hours,oo)),t.days=new Set(Vi(e.days,oo)),t.months=new Set(Vi(e.months,oo)),t.weekdays=new Set(Vi(e.weekdays,oo)),t.tz=en(e.tz);let r=Array.from(t.seconds),n=Array.from(t.minutes),o=Array.from(t.hours),i=Array.from(t.days),s=Array.from(t.months),a=Array.from(t.weekdays);return t.first={second:r[0]??0,minute:n[0]??0,hour:o[0]??0,day:i[0]??1,month:(s[0]??1)-1,weekday:a[0]??0},t.last={second:r[r.length-1]??59,minute:n[n.length-1]??59,hour:o[o.length-1]??23,day:i[i.length-1]??31,month:(s[s.length-1]??12)-1,weekday:a[a.length-1]??6},t.next={second:Lu(r,60,"next"),minute:Lu(n,60,"next"),hour:Lu(o,24,"next"),day:Lu(i,32,"next"),month:Lu(s,13,"next"),weekday:Lu(a,7,"next")},t.prev={second:Lu(r,60,"prev"),minute:Lu(n,60,"prev"),hour:Lu(o,24,"prev"),day:Lu(i,32,"prev"),month:Lu(s,13,"prev"),weekday:Lu(a,7,"prev")},t},Lu=(e,t,r)=>{let n=new Array(t).fill(void 0);if(e.length===0)return n;let o;if(r==="next"){let i=e.length-1;for(let s=t-1;s>=0;s--){for(;i>=0&&e[i]>=s;)o=e[i--];n[s]=o}}else{let i=0;for(let s=0;s<t;s++){for(;i<e.length&&e[i]<=s;)o=e[i++];n[s]=o}}return n},zDe=Symbol.for("effect/Cron/errors/ParseError"),Uu=class extends uh("CronParseError"){[zDe]=zDe},VDe=(e,t)=>{let r=e.split(" ").filter(qDe);if(r.length!==5&&r.length!==6)return Re(new Uu({message:"Invalid number of segments in cron expression",input:e}));r.length===5&&r.unshift("0");let[n,o,i,s,a,c]=r,u=t===void 0||JI(t)?Le(t):JJ(Y8(t),()=>new Uu({message:"Invalid time zone in cron expression",input:t}));return $Ee({tz:u,seconds:XI(n,t0t),minutes:XI(o,r0t),hours:XI(i,n0t),days:XI(s,o0t),months:XI(a,i0t),weekdays:XI(c,s0t)}).pipe(lF(JIt))},YDe=(e,t)=>{let r=m$(t,{timeZone:Gr(e.tz)}).pipe(UDe);return e.seconds.size!==0&&!e.seconds.has(r.seconds)||e.minutes.size!==0&&!e.minutes.has(r.minutes)||e.hours.size!==0&&!e.hours.has(r.hours)||e.months.size!==0&&!e.months.has(r.month)?!1:e.days.size===0&&e.weekdays.size===0?!0:e.weekdays.size===0?e.days.has(r.day):e.days.size===0?e.weekdays.has(r.weekDay):e.days.has(r.day)||e.weekdays.has(r.weekDay)},K8=e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+1,0)).getUTCDate(),JDe=(e,t)=>KIt(e,t,"next"),KIt=(e,t,r)=>{let n=Gr(e.tz),o=m$(t??new Date,{timeZone:n}),i=r==="prev",s=i?-1:1,a=e[r],c=i?e.last:e.first,u=i?(p,m)=>p<m:(p,m)=>p>m,d=n!==void 0&&NDe(n)&&n.id==="UTC"?Ai:p=>{let m=m$(p,{timeZone:o.zone,adjustForTimeZone:!0,disambiguation:i?"later":void 0}).pipe(bb),g=p.getTime()-m.getTime();(i?g!==0:g>0)&&p.setTime(m.getTime())},f=WDe(o,p=>{p.setUTCSeconds(p.getUTCSeconds()+s,0);for(let m=0;m<1e4;m++){if(e.seconds.size!==0){let g=p.getUTCSeconds(),A=a.second[g];if(A===void 0){p.setUTCMinutes(p.getUTCMinutes()+s,c.second),d(p);continue}if(u(A,g)){p.setUTCSeconds(A),d(p);continue}}if(e.minutes.size!==0){let g=p.getUTCMinutes(),A=a.minute[g];if(A===void 0){p.setUTCHours(p.getUTCHours()+s,c.minute,c.second),d(p);continue}if(u(A,g)){p.setUTCMinutes(A,c.second),d(p);continue}}if(e.hours.size!==0){let g=p.getUTCHours(),A=a.hour[g];if(A===void 0){p.setUTCDate(p.getUTCDate()+s),p.setUTCHours(c.hour,c.minute,c.second),d(p);continue}if(u(A,g)){p.setUTCHours(A,c.minute,c.second),d(p);continue}}if(e.weekdays.size!==0||e.days.size!==0){let g=i?-1/0:1/0,A=i?-1/0:1/0;if(e.weekdays.size!==0){let y=p.getUTCDay(),b=a.weekday[y];b===void 0?g=i?y-7+c.weekday:7-y+c.weekday:g=b-y}if(e.days.size!==0&&g!==0){let y=p.getUTCDate(),b=a.day[y];if(b===void 0)if(i){let w=K8(new Date(Date.UTC(p.getUTCFullYear(),p.getUTCMonth(),0)));A=-(y+(w-c.day))}else A=K8(p)-y+c.day;else A=b-y}let E=i?Math.max(g,A):Math.min(g,A);if(E!==0){p.setUTCDate(p.getUTCDate()+E),p.setUTCHours(c.hour,c.minute,c.second),d(p);continue}}if(e.months.size!==0){let g=p.getUTCMonth()+1,A=a.month[g],E=y=>{if(e.days.size!==0)return c.day;let b=K8(new Date(Date.UTC(p.getUTCFullYear(),y,1)));return Math.min(c.day,b)};if(A===void 0){p.setUTCFullYear(p.getUTCFullYear()+s),p.setUTCMonth(c.month,E(c.month)),p.setUTCHours(c.hour,c.minute,c.second),d(p);continue}if(u(A,g)){let y=A-1;p.setUTCMonth(y,E(y)),p.setUTCHours(c.hour,c.minute,c.second),d(p);continue}}return}throw new Error("Unable to find next cron date")});return KI(f)},ZIt=Ml((e,t)=>ZI(e.seconds,t.seconds)&&ZI(e.minutes,t.minutes)&&ZI(e.hours,t.hours)&&ZI(e.days,t.days)&&ZI(e.months,t.months)&&ZI(e.weekdays,t.weekdays)),XIt=zM(QJ),ZI=(e,t)=>XIt(_e(e),_e(t)),e0t=x(2,(e,t)=>ZIt(e,t)),t0t={min:0,max:59},r0t={min:0,max:59},n0t={min:0,max:23},o0t={min:1,max:31},i0t={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}},s0t={min:0,max:6,aliases:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}},XI=(e,t)=>{let r=t.max-t.min+1,n=new Set,o=e.split(",");for(let i of o){let[s,a]=a0t(i);if(s==="*"&&a===void 0)return Le(new Set);if(a!==void 0){if(!Number.isInteger(a))return Re(new Uu({message:"Expected step value to be a positive integer",input:e}));if(a<1)return Re(new Uu({message:"Expected step value to be greater than 0",input:e}));if(a>t.max)return Re(new Uu({message:`Expected step value to be less than ${t.max}`,input:e}))}if(s==="*")for(let c=t.min;c<=t.max;c+=a??1)n.add(c);else{let[c,u]=c0t(s,t.aliases);if(!Number.isInteger(c))return Re(new Uu({message:"Expected a positive integer",input:e}));if(c<t.min||c>t.max)return Re(new Uu({message:`Expected a value between ${t.min} and ${t.max}`,input:e}));if(u===void 0)n.add(c);else{if(!Number.isInteger(u))return Re(new Uu({message:"Expected a positive integer",input:e}));if(u<t.min||u>t.max)return Re(new Uu({message:`Expected a value between ${t.min} and ${t.max}`,input:e}));if(c>u)return Re(new Uu({message:"Invalid value range",input:e}));for(let l=c;l<=u;l+=a??1)n.add(l)}}if(n.size>=r)return Le(new Set)}return Le(n)},a0t=e=>{let t=e.indexOf("/");return t!==-1?[e.slice(0,t),Number(e.slice(t+1))]:[e,void 0]},c0t=(e,t)=>{let r=e.indexOf("-");return r!==-1?[Z8(e.slice(0,r),t),Z8(e.slice(r+1),t)]:[Z8(e,t),void 0]}});var ZDe,XDe,h$=h(()=>{Mf();CB();ZDe=MIe,XDe=IIe});var u0t,y$,x$,l0t,c5,n5,Sb,d0t,f0t,o5,eQe,i5,mr,E$,u5,rQe,l5,nQe,b$,oQe,e0,Cb,iQe,wb,sQe,aQe,cQe,uQe,lQe,d5,dQe,S$,fQe,pQe,mQe,hQe,C$,MT,gQe,AQe,yQe,FT,f5,xQe,EQe,bQe,SQe,CQe,wQe,IQe,kQe,vQe,RQe,dh,ZA,p5,s5,_Qe,m5,BQe,vi,w$,TQe,DQe,LT,QQe,h5,OQe,NQe,g5,A5,PQe,y5,x5,E5,t0,I$,b5,MQe,FQe,S5,LQe,UQe,$Qe,HQe,WQe,jQe,qQe,GQe,UT,C5,k$,w5,$T,I5,zQe,VQe,k5,HT,v$,YQe,JQe,v5,KQe,ZQe,R5,XQe,p0t,eOe,m0t,h0t,tOe,g0t,A0t,_5,rOe,y0t,x0t,nOe,g$,a5,E0t,A$,b0t,WT,tQe,oOe,B5,iOe,PT,sOe,R$,T5,aOe,D5,Q5,cOe,uOe,_$,fd,B$,lOe,dOe,T$=h(()=>{vr();II();sr();t5();Ws();Ei();mt();oe();it();Me();ct();h$();FU();QU();xT();Jl();$f();vt();UI();SI();u0t="effect/Schedule",y$=Symbol.for(u0t),x$=e=>se(e,y$),l0t="effect/ScheduleDriver",c5=Symbol.for(l0t),n5={start:0,now:0,input:void 0,output:void 0,elapsed:As,elapsedSincePrevious:As,recurrence:0},Sb=si()("effect/Schedule/CurrentIterationMetadata",{defaultValue:()=>n5}),d0t={_Out:e=>e,_In:e=>e,_R:e=>e},f0t={_Out:e=>e,_In:e=>e,_R:e=>e},o5=class{initial;step;[y$]=d0t;constructor(t,r){this.initial=t,this.step=r}pipe(){return Z(this,arguments)}},eQe=(e,t,r,n)=>ob(e,o=>o.recurrence===0?{now:t,input:r,output:n,recurrence:o.recurrence+1,elapsed:As,elapsedSincePrevious:As,start:t}:{now:t,input:r,output:n,recurrence:o.recurrence+1,elapsed:Ki(t-o.start),elapsedSincePrevious:Ki(t-o.now),start:o.start}),i5=class{schedule;ref;[c5]=f0t;constructor(t,r){this.schedule=t,this.ref=r}get state(){return te(io(this.ref),t=>t[1])}get last(){return O(io(this.ref),([t,r])=>{switch(t._tag){case"None":return pc(()=>new Es);case"Some":return M(t.value)}})}iterationMeta=QA(n5);get reset(){return Pa(this.ref,[W(),this.schedule.initial]).pipe($E(Pa(this.iterationMeta,n5)))}next(t){return C(te(io(this.ref),r=>r[1]),O(r=>C(zm,O(n=>C(ye(()=>this.schedule.step(n,t,r)),O(([o,i,s])=>{let a=Pa(this.ref,[H(i),o]);if(li(s))return a.pipe(je(ut(W())));let c=GA(s.intervals)-n;if(c<=0)return a.pipe(je(eQe(this.iterationMeta,n,t,i)),Zt(i));let u=Ki(c);return C(a,je(eQe(this.iterationMeta,n,t,i)),je(Jm(u)),Zt(i))}))))))}},mr=(e,t)=>new o5(e,t),E$=x(2,(e,t)=>u5(e,r=>V(()=>t(r)))),u5=x(2,(e,t)=>LT(e,(r,n)=>te(t(r),o=>VF(n,At(o))))),rQe=x(2,(e,t)=>vi(l5(e,t),vw)),l5=x(2,(e,t)=>mr([e.initial,t.initial,!0],(r,n,o)=>o[2]?O(e.step(r,n,o[0]),([i,s,a])=>li(a)?te(t.step(r,n,o[1]),([c,u,l])=>[[i,c,!1],Le(u),l]):M([[i,o[1],!0],Re(s),a])):te(t.step(r,n,o[1]),([i,s,a])=>[[o[0],i,!1],Le(s),a]))),nQe=x(2,(e,t)=>vi(e,()=>t)),b$=e=>vi(e,Ai),oQe=x(2,(e,t)=>mr([e.initial,t.initial],(r,[n,o],i)=>Zi(e.step(r,n,i[0]),t.step(r,o,i[1]),([s,a,c],[u,l,d])=>{if(ih(c)&&ih(d)){let f=C(c.intervals,l8(d.intervals));return[[s,u],[a,l],Ab(f)]}return[[s,u],[a,l],Mu]}))),e0=x(2,(e,t)=>Cb(e,(r,n)=>V(()=>t(r,n)))),Cb=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>li(a)?M([i,s,Mu]):te(t(n,s),c=>c?[i,s,a]:[i,s,Mu])))),iQe=()=>wb(dh()),wb=e=>I$(e,Ut(),(t,r)=>C(t,$s(r))),sQe=e=>wb(g5(e)),aQe=e=>wb(A5(e)),cQe=e=>wb(x5(e)),uQe=e=>wb(E5(e)),lQe=x(2,(e,t)=>mr([e.initial,t.initial],(r,n,o)=>O(e.step(r,n,o[0]),([i,s,a])=>te(t.step(r,s,o[1]),([c,u,l])=>li(a)?[[i,c],u,Mu]:li(l)?[[i,c],u,Mu]:[[i,c],u,Ab(C(a.intervals,HBe(l.intervals)))])))),d5=x(2,(e,t)=>S$(e,r=>V(()=>t(r)))),dQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>kA(e.step(r,n,o),t))),S$=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(t(n),i=>e.step(r,i,o)))),fQe=(e,t)=>{let r=e5(e)?Le(e):VDe(e,t);return mr([!0,[Number.MIN_SAFE_INTEGER,0,0]],(n,o,[i,s])=>{if(n<s[0])return M([[!1,s],[s[1],s[2]],qo(Ks(s[1],s[2]))]);if(xr(r))return Si(r.left);let a=r.right,c=new Date(n),u;i&&YDe(a,c)&&(u=n),u=JDe(a,c).getTime();let l=R5(u),d=XQe(u);return M([[!1,[u,l,d]],[l,d],qo(Ks(l,d))])})},pQe=e=>mr([Number.NEGATIVE_INFINITY,0],(t,r,n)=>{if(!Number.isInteger(e)||e<1||31<e)return Ta(()=>new vu(`Invalid argument in: dayOfMonth(${e}). Must be in range 1...31`));let o=n[1],s=x0t(t,e,o===0),a=_5(s),c=rOe(s),u=Ks(a,c);return M([[c,o+1],o,qo(u)])}),mQe=e=>mr([Number.MIN_SAFE_INTEGER,0],(t,r,n)=>{if(!Number.isInteger(e)||e<1||7<e)return Ta(()=>new vu(`Invalid argument in: dayOfWeek(${e}). Must be in range 1 (Monday)...7 (Sunday)`));let o=n[1],s=y0t(t,e,o===0),a=_5(s),c=rOe(s),u=Ks(a,c);return M([[c,o+1],o,qo(u)])}),hQe=x(2,(e,t)=>C$(e,r=>V(()=>t(r)))),C$=x(2,(e,t)=>LT(e,(r,n)=>t(n))),MT=e=>E$(e,t=>t),gQe=e=>mr(e.initial,(t,r,n)=>C(e.step(t,r,n),O(([o,i,s])=>li(s)?M([o,As,s]):M([o,Ki(GA(s.intervals)-t),s])))),AQe=x(2,(e,{onInput:t,onOutput:r})=>vi(d5(e,t),r)),yQe=x(2,(e,{onInput:t,onOutput:r})=>w$(S$(e,t),r)),FT=e=>C(rb([W(),e.initial]),te(t=>new i5(e,t))),f5=e=>{let t=At(e),r=Io(t);return mr(!0,(n,o,i)=>M(i?[!1,t,qo(dd(n+r))]:[!1,As,Mu]))},xQe=x(2,(e,t)=>C5(e,t)),EQe=x(3,(e,t,r)=>k$(e,t,r)),bQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>li(a)?Zt(t,[i,s,a]):M([i,s,a])))),SQe=(e,t=2)=>{let r=At(e);return MT(vi(fd,n=>zF(r,Math.pow(t,n))))},CQe=e=>{let t=At(e);return MT(C(UT([t,t],([r,n])=>[n,VF(r,n)]),vi(r=>r[0])))},wQe=e=>{let t=At(e),r=Io(t);return mr([W(),0],(n,o,[i,s])=>V(()=>{switch(i._tag){case"None":return[[H([n,n+r]),s+1],s,qo(dd(n+r))];case"Some":{let[a,c]=i.value,u=n>c+r,l=ce(t,As)?t:Ki(r-(n-a)%r),d=ce(l,As)?t:l,f=u?n:n+Io(d);return[[H([a,f]),s+1],s,qo(dd(f))]}}}))},IQe=e=>f5(e),kQe=(e,...t)=>mr([[e,...t].map(r=>At(r)),!0],(r,n,[o,i])=>V(()=>{if(i){let s=o[0],a=dd(r+Io(s));if(o.length>=2)return[[o.slice(1),!0],s,qo(a)];let c=o.slice(1);return[[[s,...c],!1],s,qo(a)]}return[[o,!1],As,Mu]})),vQe=e=>vi(dh(),e),RQe=e=>mr([Number.NEGATIVE_INFINITY,0],(t,r,n)=>{if(!Number.isInteger(e)||e<0||23<e)return Ta(()=>new vu(`Invalid argument in: hourOfDay(${e}). Must be in range 0...23`));let o=n[1],s=A0t(t,e,o===0),a=tOe(s),c=g0t(s),u=Ks(a,c);return M([[c,o+1],o,qo(u)])}),dh=()=>mr(void 0,(e,t,r)=>M([r,t,qo(dd(e))])),ZA=x(2,(e,t)=>p5(e,t,LBe)),p5=x(3,(e,t,r)=>mr([e.initial,t.initial],(n,o,i)=>C(Zi(e.step(n,o,i[0]),t.step(n,o,i[1]),(s,a)=>[s,a]),O(([[s,a,c],[u,l,d]])=>ih(c)&&ih(d)?s5(e,t,o,s,a,c.intervals,u,l,d.intervals,r):M([[s,u],[a,l],Mu]))))),s5=(e,t,r,n,o,i,s,a,c,u)=>{let l=u(i,c);return $Be(l)?M([[n,s],[o,a],Ab(l)]):C(i,UBe(c))?O(e.step(PU(i),r,n),([d,f,p])=>li(p)?M([[d,s],[f,a],Mu]):s5(e,t,r,d,f,p.intervals,s,a,c,u)):O(t.step(PU(c),r,s),([d,f,p])=>li(p)?M([[n,d],[o,f],Mu]):s5(e,t,r,n,o,i,d,f,p.intervals,u))},_Qe=e=>m5(e,{min:.8,max:1.2}),m5=x(2,(e,t)=>{let{max:r,min:n}=Object.assign({min:.8,max:1.2},t);return C$(e,o=>te(ZDe,i=>{let s=Io(o),a=s*n*(1-i)+s*r*i;return Ki(a)}))}),BQe=e=>{let t=At(e);return MT(vi(fd,r=>zF(t,r+1)))},vi=x(2,(e,t)=>w$(e,r=>V(()=>t(r)))),w$=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>te(t(s),c=>[i,c,a])))),TQe=e=>mr([Number.MIN_SAFE_INTEGER,0],(t,r,n)=>{if(!Number.isInteger(e)||e<0||59<e)return Ta(()=>new vu(`Invalid argument in: minuteOfHour(${e}). Must be in range 0...59`));let o=n[1],s=h0t(t,e,o===0),a=eOe(s),c=m0t(s),u=Ks(a,c);return M([[c,o+1],o,qo(u)])}),DQe=x(2,(e,t)=>LT(e,(r,n)=>V(()=>t(r,n)))),LT=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>{if(li(a))return M([i,s,a]);let c=a.intervals,u=BBe(Ks(r,GA(c)));return te(t(s,u),l=>{let d=At(l),f=GA(c),p=r+Io(d),m=p-f,g=Math.max(0,PU(c)+m),A=Ks(p,g);return[i,s,qo(A)]})}))),QQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>Zt(t(s,a),[i,s,a])))),h5=e=>mr(e.initial,(t,r,n)=>C(e.step(t,r,n),te(([o,i,s])=>[o,r,s]))),OQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>zs(e.step(r,n,o),t))),NQe=x(3,(e,t,r)=>mr(e.initial,(n,o,i)=>xc(s=>zs(e.step(n,o,i),zt(s,t,r))))),g5=e=>w5(dh(),e),A5=e=>$T(dh(),e),PQe=e=>I5(vi(dh(),e),pt),y5=e=>{let t=At(e);return v$(_$,r=>i3(r,t))},x5=e=>k5(dh(),e),E5=e=>HT(dh(),e),t0=e=>v$(fd,t=>t<e),I$=x(3,(e,t,r)=>b5(e,t,(n,o)=>V(()=>r(n,o)))),b5=x(3,(e,t,r)=>mr([e.initial,t],(n,o,[i,s])=>O(e.step(n,o,i),([a,c,u])=>li(u)?M([[a,s],s,u]):te(r(s,c),l=>[[a,l],s,u])))),MQe=e=>I$(e,0,(t,r)=>t+1),FQe=x(2,(e,t)=>{let r=At(t);return C(e,ZA(_$),S5(([,n])=>$_(n,r)),vi(n=>n[0]))}),S5=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>t(s)?e.step(r,n,e.initial):M([i,s,a])))),LQe=x(3,(e,t,r)=>C(UQe(e,t,Co(r),e.initial,Ut()),te(n=>gs(n)))),UQe=(e,t,r,n,o)=>{if(!kr(r))return M(o);let i=Gt(r),s=Ur(r);return O(e.step(t,i,n),([a,c,u])=>li(u)?V(()=>C(o,fr(c))):UQe(e,GA(u.intervals),s,a,fr(o,c)))},$Qe=e=>mr([Number.NEGATIVE_INFINITY,0],(t,r,n)=>{if(!Number.isInteger(e)||e<0||59<e)return Ta(()=>new vu(`Invalid argument in: secondOfMinute(${e}). Must be in range 0...59`));let o=n[1],s=p0t(t,e,o===0),a=R5(s),c=XQe(s),u=Ks(a,c);return M([[c,o+1],o,qo(u)])}),HQe=e=>E$(fd,()=>e),WQe=e=>vi(fd,()=>e),jQe=e=>vi(fd,e),qQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>je(t(n),e.step(r,n,o)))),GQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>jo(e.step(r,n,o),([,i])=>t(i)))),UT=(e,t)=>mr(e,(r,n,o)=>V(()=>[t(o),o,qo(dd(r))])),C5=x(2,(e,t)=>k$(e,t,l8)),k$=x(3,(e,t,r)=>mr([e.initial,t.initial],(n,o,i)=>Zi(e.step(n,o,i[0]),t.step(n,o,i[1]),([s,a,c],[u,l,d])=>{if(li(c)&&li(d))return[[s,u],[a,l],Mu];if(li(c)&&ih(d))return[[s,u],[a,l],Ab(d.intervals)];if(ih(c)&&li(d))return[[s,u],[a,l],Ab(c.intervals)];if(ih(c)&&ih(d)){let f=r(c.intervals,d.intervals);return[[s,u],[a,l],Ab(f)]}throw new Error("BUG: Schedule.unionWith - please report an issue at https://github.com/Effect-TS/effect/issues")}))),w5=x(2,(e,t)=>e0(e,(r,n)=>!t(r))),$T=x(2,(e,t)=>Cb(e,(r,n)=>qB(t(r)))),I5=x(2,(e,t)=>e0(e,(r,n)=>!t(n))),zQe=x(2,(e,t)=>Cb(e,(r,n)=>qB(t(n)))),VQe=x(2,(e,t)=>v5(e,y5(t))),k5=x(2,(e,t)=>e0(e,(r,n)=>t(r))),HT=x(2,(e,t)=>Cb(e,(r,n)=>t(r))),v$=x(2,(e,t)=>e0(e,(r,n)=>t(n))),YQe=x(2,(e,t)=>Cb(e,(r,n)=>t(n))),JQe=e=>{let t=At(e),r=Io(t);return mr([W(),0],(n,o,[i,s])=>{switch(i._tag){case"None":return M([[H(n),s+1],s,qo(dd(n+r))]);case"Some":return M([[H(i.value),s+1],s,qo(dd(n+(r-(n-i.value)%r)))])}})},v5=x(2,(e,t)=>vi(ZA(e,t),r=>r[0])),KQe=x(2,(e,t)=>vi(ZA(e,t),r=>r[1])),ZQe=x(3,(e,t,r)=>vi(ZA(e,t),([n,o])=>r(n,o))),R5=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),0).getTime()},XQe=e=>{let t=new Date(R5(e));return t.setSeconds(t.getSeconds()+1)},p0t=(e,t,r)=>{let n=new Date(e);if(n.getSeconds()===t&&r)return e;if(n.getSeconds()<t)return n.setSeconds(t);let o=new Date(n.setSeconds(t));return o.setTime(o.getTime()+1e3*60)},eOe=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),0,0).getTime()},m0t=e=>{let t=new Date(eOe(e));return t.setMinutes(t.getMinutes()+1)},h0t=(e,t,r)=>{let n=new Date(e);if(n.getMinutes()===t&&r)return e;if(n.getMinutes()<t)return n.setMinutes(t);let o=new Date(n.setMinutes(t));return o.setTime(o.getTime()+1e3*60*60)},tOe=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),0,0,0).getTime()},g0t=e=>{let t=new Date(tOe(e));return t.setHours(t.getHours()+1)},A0t=(e,t,r)=>{let n=new Date(e);if(n.getHours()===t&&r)return e;if(n.getHours()<t)return n.setHours(t);let o=new Date(n.setHours(t));return o.setTime(o.getTime()+1e3*60*60*24)},_5=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0).getTime()},rOe=e=>{let t=new Date(_5(e));return t.setDate(t.getDate()+1)},y0t=(e,t,r)=>{let n=new Date(e);if(n.getDay()===t&&r)return e;let o=(7+t-n.getDay())%7;return n.setDate(n.getDate()+(o===0?7:o))},x0t=(e,t,r)=>{let n=new Date(e);return n.getDate()===t&&r?e:n.getDate()<t?n.setDate(t):nOe(e,t,1)},nOe=(e,t,r)=>{let n=new Date(e),o=new Date(n.setDate(t));if(new Date(o.setMonth(o.getMonth()+r)).getDate()===t){let s=new Date(e),a=new Date(s.setDate(t));return a.setMonth(a.getMonth()+r)}return nOe(e,t,r+1)},g$=Symbol.for("effect/Schedule/ScheduleDefect"),a5=class{error;[g$];constructor(t){this.error=t,this[g$]=g$}},E0t=e=>se(e,g$),A$=e=>fc(e,t=>Si(new a5(t))),b0t=e=>wt(oA(e,t=>QE(t)&&E0t(t.defect)?H(t.defect):W()),{onNone:()=>e,onSome:t=>zl(t.error)}),WT=e=>Bf(e,t=>kt(b0t(t))),tQe=x(2,(e,t)=>B5(e,t,(r,n)=>ut(r))),oOe=x(2,(e,t)=>{if(x$(t))return tQe(e,t);let r=t.schedule??h5(fd),n=t.while?HT(r,s=>{let a=t.while(s);return typeof a=="boolean"?M(a):A$(a)}):r,o=t.until?$T(n,s=>{let a=t.until(s);return typeof a=="boolean"?M(a):A$(a)}):n,i=t.times?ZA(o,t0(t.times)).pipe(vi(s=>s[0])):o;return WT(tQe(e,i))}),B5=x(3,(e,t,r)=>O(FT(t),n=>Ho(e,{onFailure:o=>r(o,W()),onSuccess:o=>iOe(FA(e,Sb,io(n.iterationMeta)),n,(i,s)=>FA(r(i,s),Sb,io(n.iterationMeta)),o)}))),iOe=(e,t,r,n)=>Ho(t.next(n),{onFailure:()=>UE(t.last),onSuccess:o=>Ho(e,{onFailure:i=>r(i,H(o)),onSuccess:i=>iOe(e,t,r,i)})}),PT=x(2,(e,t)=>T5(e,t,(r,n)=>ut(r))),sOe=x(2,(e,t)=>x$(t)?PT(e,t):WT(PT(e,R$(t)))),R$=e=>{let t=e.schedule??fd,r=e.while?HT(t,o=>{let i=e.while(o);return typeof i=="boolean"?M(i):A$(i)}):t,n=e.until?$T(r,o=>{let i=e.until(o);return typeof i=="boolean"?M(i):A$(i)}):r;return e.times!==void 0?ZA(n,t0(e.times)):n},T5=x(3,(e,t,r)=>O(FT(t),n=>aOe(FA(e,Sb,io(n.iterationMeta)),n,(o,i)=>FA(r(o,i),Sb,io(n.iterationMeta))))),aOe=(e,t,r)=>fc(e,n=>Ho(t.next(n),{onFailure:()=>C(t.last,UE,O(o=>r(n,o))),onSuccess:()=>aOe(e,t,r)})),D5=x(2,(e,t)=>Q5(e,void 0,t)),Q5=x(3,(e,t,r)=>O(FT(r),n=>cOe(FA(e,Sb,io(n.iterationMeta)),t,n))),cOe=(e,t,r)=>Ho(r.next(t),{onFailure:()=>UE(r.last),onSuccess:()=>O(e,n=>cOe(e,n,r))}),uOe=UT(0,e=>e+1),_$=mr(W(),(e,t,r)=>{switch(r._tag){case"None":return M([H(e),As,qo(dd(e))]);case"Some":return M([H(r.value),Ki(e-r.value),qo(dd(e))])}}),fd=UT(0,e=>e+1),B$=b$(t0(1)),lOe=b$(t0(0)),dOe=x(2,(e,t)=>HU(D5(e,t)))});var pOe,mOe,fOe,N5=h(()=>{Ei();oe();vt();DT();T$();pOe=Symbol.for("effect/ExecutionPlan"),mOe=x(2,(e,t)=>ye(()=>{let r=0,n;return O(yA({while:()=>r<t.steps.length&&(n===void 0||xr(n)),body:()=>{let o=t.steps[r],i=l$(e,o.provide);if(n){let s=!1,a=i;i=ye(()=>s?a:(s=!0,n)),i=WT(PT(i,fOe(o,!1)))}else{let s=fOe(o,!0);i=s?WT(PT(i,s)):i}return wu(i)},step:o=>{n=o,r++}}),()=>n)})),fOe=(e,t)=>{if(t){if(e.attempts===1||!(e.schedule||e.attempts))return}else return R$({schedule:e.schedule?e.schedule:e.attempts?void 0:B$,times:e.attempts,while:e.while});return R$({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})}});var Or={};tr(Or,{DeferredTypeId:()=>fh,await:()=>Ht,complete:()=>jT,completeWith:()=>C0t,die:()=>k0t,dieSync:()=>v0t,done:()=>P5,fail:()=>D$,failCause:()=>pd,failCauseSync:()=>I0t,failSync:()=>w0t,interrupt:()=>r0,interruptWith:()=>R0t,isDone:()=>ph,make:()=>rn,makeAs:()=>S0t,poll:()=>gOe,succeed:()=>di,sync:()=>_0t,unsafeDone:()=>kc,unsafeMake:()=>Q$});var fh,rn,S0t,Ht,jT,C0t,P5,D$,w0t,pd,I0t,k0t,v0t,r0,R0t,ph,gOe,di,_0t,Q$,kc,$u=h(()=>{vt();z3();fh=SL,rn=Ci,S0t=uK,Ht=Cn,jT=HL,C0t=yc,P5=lK,D$=Qwe,w0t=Owe,pd=iI,I0t=Nwe,k0t=Pwe,v0t=Mwe,r0=Fwe,R0t=EB,ph=Lwe,gOe=Uwe,di=Mm,_0t=$we,Q$=wA,kc=IA});var AOe,B0t,T0t,yOe,M5,O$,xOe,EOe,D0t,F5=h(()=>{oe();ht();Me();AOe=Symbol.for("effect/MutableList"),B0t={[AOe]:AOe,[Symbol.iterator](){let e=!1,t=this.head;return{next(){if(e)return this.return();if(t==null)return e=!0,this.return();let r=t.value;return t=t.next,{done:e,value:r}},return(r){return e||(e=!0),{done:!0,value:r}}}},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"MutableList",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},T0t=e=>({value:e,removed:!1,prev:void 0,next:void 0}),yOe=()=>{let e=Object.create(B0t);return e.head=void 0,e.tail=void 0,e._length=0,e},M5=e=>O$(e)===0,O$=e=>e._length,xOe=x(2,(e,t)=>{let r=T0t(t);return e.head===void 0&&(e.head=r),e.tail===void 0||(e.tail.next=r,r.prev=e.tail),e.tail=r,e._length+=1,e}),EOe=e=>{let t=e.head;if(t!==void 0)return D0t(e,t),t.value},D0t=(e,t)=>{t.removed||(t.removed=!0,t.prev!==void 0&&t.next!==void 0?(t.prev.next=t.next,t.next.prev=t.prev):t.prev!==void 0?(e.tail=t.prev,t.prev.next=void 0):t.next!==void 0?(e.head=t.next,t.next.prev=void 0):(e.tail=void 0,e.head=void 0),e._length>0&&(e._length-=1))}});var SOe,fi,Q0t,COe,N$,n0,P$,M$,wOe,XA,L5,md,F$,L$=h(()=>{vr();oe();ht();F5();Me();SOe=Symbol.for("effect/MutableQueue"),fi=Symbol.for("effect/mutable/MutableQueue/Empty"),Q0t={[SOe]:SOe,[Symbol.iterator](){return Array.from(this.queue)[Symbol.iterator]()},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"MutableQueue",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},COe=e=>{let t=Object.create(Q0t);return t.queue=yOe(),t.capacity=e,t},N$=e=>COe(e),n0=()=>COe(void 0),P$=e=>O$(e.queue),M$=e=>M5(e.queue),wOe=e=>e.capacity===void 0?1/0:e.capacity,XA=x(2,(e,t)=>{let r=O$(e.queue);return e.capacity!==void 0&&r===e.capacity?!1:(xOe(t)(e.queue),!0)}),L5=x(2,(e,t)=>{let r=t[Symbol.iterator](),n,o=Ut(),i=!0;for(;i&&(n=r.next())&&!n.done;)i=XA(n.value)(e);for(;n!=null&&!n.done;)o=fr(n.value)(o),n=r.next();return gs(o)}),md=x(2,(e,t)=>M5(e.queue)?t:EOe(e.queue)),F$=x(2,(e,t)=>{let r=Ut(),n=0;for(;n<t;){let o=md(fi)(e);if(o===fi)break;r=fr(o)(r),n+=1}return gs(r)})});var IOe,kOe,O0t,$5,H5,o0,N0t,W5,P0t,M0t,F0t,L0t,U0t,$0t,H0t,W0t,j0t,q0t,U$,j5,vOe,ROe=h(()=>{sr();$u();Ws();Ei();mt();Ro();oe();ir();iT();L$();Kl();it();ct();$f();vt();Vw();oL();IOe=(e,t,r,n)=>zw({_tag:"Complete",key:e,exit:t,entryStats:r,timeToLiveMillis:n}),kOe=(e,t)=>zw({_tag:"Pending",key:e,deferred:t}),O0t=(e,t)=>zw({_tag:"Refreshing",deferred:e,complete:t}),$5=Symbol.for("effect/Cache/MapKey"),H5=class{current;[$5]=$5;previous=void 0;next=void 0;constructor(t){this.current=t}[he](){return C(ae(this.current),we(ae(this.previous)),we(ae(this.next)),We(this))}[me](t){return this===t?!0:N0t(t)&&ce(this.current,t.current)&&ce(this.previous,t.previous)&&ce(this.next,t.next)}},o0=e=>new H5(e),N0t=e=>se(e,$5),W5=class{head=void 0;tail=void 0;add(t){if(t!==this.tail)if(this.tail===void 0)this.head=t,this.tail=t;else{let r=t.previous,n=t.next;n!==void 0&&(t.next=void 0,r!==void 0?(r.next=n,n.previous=r):(this.head=n,this.head.previous=void 0)),this.tail.next=t,t.previous=this.tail,this.tail=t}}remove(){let t=this.head;if(t!==void 0){let r=t.next;r!==void 0?(t.next=void 0,this.head=r,this.head.previous=void 0):(this.head=void 0,this.tail=void 0)}return t}},P0t=()=>new W5,M0t=(e,t,r,n,o,i)=>({map:e,keys:t,accesses:r,updating:n,hits:o,misses:i}),F0t=()=>M0t(fb(),P0t(),n0(),Ba(!1),0,0),L0t="effect/Cache",U0t=Symbol.for(L0t),$0t={_Key:e=>e,_Error:e=>e,_Value:e=>e},H0t="effect/ConsumerCache",W0t=Symbol.for(H0t),j0t={_Key:e=>e,_Error:e=>e,_Value:e=>e},q0t=e=>e,U$=e=>({loadedMillis:e}),j5=class{capacity;context;fiberId;lookup;timeToLive;[U0t]=$0t;[W0t]=j0t;cacheState;constructor(t,r,n,o,i){this.capacity=t,this.context=r,this.fiberId=n,this.lookup=o,this.timeToLive=i,this.cacheState=F0t()}get(t){return te(this.getEither(t),vw)}get cacheStats(){return V(()=>q0t({hits:this.cacheState.hits,misses:this.cacheState.misses,size:pU(this.cacheState.map)}))}getOption(t){return ye(()=>wt(_o(this.cacheState.map,t),{onNone:()=>{let r=o0(t);return this.trackAccess(r),this.trackMiss(),M(W())},onSome:r=>this.resolveMapValue(r)}))}getOptionComplete(t){return ye(()=>wt(_o(this.cacheState.map,t),{onNone:()=>{let r=o0(t);return this.trackAccess(r),this.trackMiss(),M(W())},onSome:r=>this.resolveMapValue(r,!0)}))}contains(t){return V(()=>cd(this.cacheState.map,t))}entryStats(t){return V(()=>{let r=_o(this.cacheState.map,t);if(pt(r))switch(r.value._tag){case"Complete":{let n=r.value.entryStats.loadedMillis;return H(U$(n))}case"Pending":return W();case"Refreshing":{let n=r.value.complete.entryStats.loadedMillis;return H(U$(n))}}return W()})}getEither(t){return ye(()=>{let r=t,n,o,i=Gr(_o(this.cacheState.map,r));return i===void 0&&(o=Q$(this.fiberId),n=o0(r),cd(this.cacheState.map,r)?i=Gr(_o(this.cacheState.map,r)):Ma(this.cacheState.map,r,kOe(n,o))),i===void 0?(this.trackAccess(n),this.trackMiss(),te(this.lookupValueOf(t,o),Le)):O(this.resolveMapValue(i),wt({onNone:()=>this.getEither(t),onSome:s=>M(Re(s))}))})}invalidate(t){return V(()=>{pb(this.cacheState.map,t)})}invalidateWhen(t,r){return V(()=>{let n=_o(this.cacheState.map,t);pt(n)&&n.value._tag==="Complete"&&n.value.exit._tag==="Success"&&r(n.value.exit.value)&&pb(this.cacheState.map,t)})}get invalidateAll(){return V(()=>{this.cacheState.map=fb()})}refresh(t){return Uf(r=>ye(()=>{let n=t,o=Q$(this.fiberId),i=Gr(_o(this.cacheState.map,n));if(i===void 0&&(cd(this.cacheState.map,n)?i=Gr(_o(this.cacheState.map,n)):Ma(this.cacheState.map,n,kOe(o0(n),o))),i===void 0)return $r(this.lookupValueOf(t,o));switch(i._tag){case"Complete":{if(this.hasExpired(r,i.timeToLiveMillis)){let s=Gr(_o(this.cacheState.map,n));return ce(s,i)&&pb(this.cacheState.map,n),$r(this.get(t))}return C(this.lookupValueOf(t,o),V1(()=>{let s=Gr(_o(this.cacheState.map,n));if(ce(s,i)){let a=O0t(o,i);return Ma(this.cacheState.map,n,a),!0}return!1}),$r)}case"Pending":return Ht(i.deferred);case"Refreshing":return Ht(i.deferred)}}))}set(t,r){return Uf(n=>V(()=>{let o=n.unsafeCurrentTimeMillis(),i=t,s=vo(r),a=IOe(o0(i),s,U$(o),o+Io(At(this.timeToLive(s))));Ma(this.cacheState.map,i,a)}))}get size(){return V(()=>pU(this.cacheState.map))}get values(){return V(()=>{let t=[];for(let r of this.cacheState.map)r[1]._tag==="Complete"&&r[1].exit._tag==="Success"&&t.push(r[1].exit.value);return t})}get entries(){return V(()=>{let t=[];for(let r of this.cacheState.map)r[1]._tag==="Complete"&&r[1].exit._tag==="Success"&&t.push([r[0],r[1].exit.value]);return t})}get keys(){return V(()=>{let t=[];for(let r of this.cacheState.map)r[1]._tag==="Complete"&&r[1].exit._tag==="Success"&&t.push(r[0]);return t})}resolveMapValue(t,r=!1){return Uf(n=>{switch(t._tag){case"Complete":return this.trackAccess(t.key),this.hasExpired(n,t.timeToLiveMillis)?(pb(this.cacheState.map,t.key.current),M(W())):(this.trackHit(),te(t.exit,H));case"Pending":return this.trackAccess(t.key),this.trackHit(),r?M(W()):te(Ht(t.deferred),H);case"Refreshing":return this.trackAccess(t.complete.key),this.trackHit(),this.hasExpired(n,t.complete.timeToLiveMillis)?r?M(W()):te(Ht(t.deferred),H):te(t.complete.exit,H)}})}trackHit(){this.cacheState.hits=this.cacheState.hits+1}trackMiss(){this.cacheState.misses=this.cacheState.misses+1}trackAccess(t){if(XA(this.cacheState.accesses,t),JF(this.cacheState.updating,!1,!0)){let r=!0;for(;r;){let o=md(this.cacheState.accesses,fi);o===fi?r=!1:this.cacheState.keys.add(o)}let n=pU(this.cacheState.map);for(r=n>this.capacity;r;){let o=this.cacheState.keys.remove();o!==void 0?cd(this.cacheState.map,o.current)&&(pb(this.cacheState.map,o.current),n=n-1,r=n>this.capacity):r=!1}js(this.cacheState.updating,!1)}}hasExpired(t,r){return t.unsafeCurrentTimeMillis()>r}lookupValueOf(t,r){return Uf(n=>ye(()=>{let o=t;return C(this.lookup(t),zs(this.context),fn,O(i=>{let s=n.unsafeCurrentTimeMillis(),a=U$(s),c=IOe(o0(o),i,a,s+Io(At(this.timeToLive(i))));return Ma(this.cacheState.map,o,c),je(P5(r,i),i)}),hc(()=>je(r0(r),V(()=>{pb(this.cacheState.map,o)}))))}))}},vOe=(e,t,r)=>new j5(e,ro(),j_,t,n=>At(r(n)))});var i0,qT,_Oe,BOe,TOe,DOe,q5=h(()=>{Ws();oe();yn();j3();ROe();vt();La();hU();i0=Te(Symbol.for("effect/FiberRef/currentCache"),()=>pn(vOe(65536,()=>te(Ci(),e=>({listeners:new DI,handle:e})),()=>sA(60)))),qT=Te(Symbol.for("effect/FiberRef/currentCacheEnabled"),()=>pn(!1)),_Oe=(e,t)=>O(ar(t)?t:M(t),r=>Da(n=>{let o=new Proxy(e,{});return ci(qT,i=>{if(i){let a=ci(i0,c=>O(c.getEither(o),u=>{switch(u._tag){case"Left":return u.left.listeners.interrupted?O(c.invalidateWhen(o,l=>l.handle===u.left.handle),()=>a):(u.left.listeners.increment(),xn(l=>O(fn(Qm(DCe,l(Cn(u.left.handle)))),d=>(u.left.listeners.decrement(),d))));case"Right":return u.right.listeners.increment(),xn(l=>O(fn(Qm(H3(r,W3({request:o,result:u.right.handle,listeners:u.right.listeners,ownerId:n,state:{completed:!1}})),l(Cn(u.right.handle)))),()=>(u.right.listeners.decrement(),Cn(u.right.handle))))}}));return a}let s=new DI;return s.increment(),O(Ci(),a=>Js(Qm(H3(r,W3({request:o,result:a,listeners:s,ownerId:n,state:{completed:!1}})),Cn(a)),V(()=>s.decrement())))})})),BOe=(e,t)=>ci(qT,r=>r?ci(i0,n=>O(n.getEither(e),o=>{switch(o._tag){case"Left":return Ue;case"Right":return HL(o.right.handle,t)}})):Ue),TOe=x(2,(e,t)=>tn(e,qT,t)),DOe=x(2,(e,t)=>tn(e,i0,t))});var OOe,G5=h(()=>{hU();OOe=o_e});var S={};tr(S,{Do:()=>$vt,EffectTypeId:()=>G0t,Service:()=>$_t,Tag:()=>U_t,acquireRelease:()=>zo,acquireReleaseInterruptible:()=>qkt,acquireUseRelease:()=>c0,addFinalizer:()=>YT,all:()=>Ib,allSuccesses:()=>Z0t,allWith:()=>K0t,allowInterrupt:()=>Dkt,andThen:()=>iRt,annotateCurrentSpan:()=>I_t,annotateLogs:()=>V$,annotateLogsScoped:()=>NRt,annotateSpans:()=>w_t,ap:()=>u_t,as:()=>ju,asSome:()=>GOe,asSomeError:()=>Lkt,asVoid:()=>gd,async:()=>Zs,asyncEffect:()=>pkt,awaitAllChildren:()=>Zkt,bind:()=>Hvt,bindAll:()=>Wvt,bindTo:()=>jvt,blocked:()=>l_t,cacheRequestResult:()=>m_t,cached:()=>GT,cachedFunction:()=>Y0t,cachedInvalidateWithTTL:()=>V0t,cachedWithTTL:()=>z0t,catch:()=>ykt,catchAll:()=>s0,catchAllCause:()=>Hu,catchAllDefect:()=>xkt,catchIf:()=>Ekt,catchSome:()=>bkt,catchSomeCause:()=>qOe,catchSomeDefect:()=>Skt,catchTag:()=>W$,catchTags:()=>j$,cause:()=>Ckt,checkInterruptible:()=>Qkt,clock:()=>zOe,clockWith:()=>Avt,configProviderWith:()=>Bvt,console:()=>Evt,consoleWith:()=>bvt,context:()=>ty,contextWith:()=>ZT,contextWithEffect:()=>Qvt,currentParentSpan:()=>R_t,currentPropagatedSpan:()=>v_t,currentSpan:()=>k_t,custom:()=>mkt,daemonChildren:()=>Xkt,delay:()=>wvt,descriptor:()=>evt,descriptorWith:()=>tvt,die:()=>Ua,dieMessage:()=>kb,dieSync:()=>jOe,diffFiberRefs:()=>rvt,disconnect:()=>Okt,dropUntil:()=>z5,dropWhile:()=>V5,either:()=>ny,ensureErrorType:()=>j_t,ensureRequirementsType:()=>q_t,ensureSuccessType:()=>W_t,ensuring:()=>qu,ensuringChild:()=>nvt,ensuringChildren:()=>ovt,eventually:()=>wkt,every:()=>ekt,exists:()=>tkt,exit:()=>so,fail:()=>$e,failCause:()=>Is,failCauseSync:()=>WOe,failSync:()=>HOe,fiberId:()=>ivt,fiberIdWith:()=>q$,filter:()=>LOe,filterEffectOrElse:()=>Zvt,filterEffectOrFail:()=>Xvt,filterMap:()=>rkt,filterOrDie:()=>Vvt,filterOrDieMessage:()=>Yvt,filterOrElse:()=>Jvt,filterOrFail:()=>Kvt,finalizersMask:()=>Ykt,findFirst:()=>UOe,firstSuccessOf:()=>HRt,flatMap:()=>Ee,flatten:()=>Vf,flip:()=>Ukt,flipWith:()=>$kt,fn:()=>H_t,fnUntraced:()=>Z$,forEach:()=>pi,forever:()=>ZOe,fork:()=>svt,forkAll:()=>avt,forkDaemon:()=>Rb,forkIn:()=>yd,forkScoped:()=>l0,forkWithErrorHandler:()=>cvt,fromFiber:()=>uvt,fromFiberEffect:()=>lvt,fromNullable:()=>P_t,functionWithSpan:()=>O_t,gen:()=>Go,getFiberRefs:()=>xRt,getRuntimeFlags:()=>zRt,head:()=>nkt,if:()=>zvt,ignore:()=>a0,ignoreLogged:()=>Ikt,inheritFiberRefs:()=>ERt,interrupt:()=>mh,interruptWith:()=>Nkt,interruptible:()=>Bo,interruptibleMask:()=>Pkt,intoDeferred:()=>f0,isEffect:()=>ws,isFailure:()=>vRt,isSuccess:()=>RRt,iterate:()=>fRt,labelMetrics:()=>ZRt,labelMetricsScoped:()=>e_t,let:()=>qvt,liftPredicate:()=>Fkt,linkSpanCurrent:()=>D_t,linkSpans:()=>T_t,locally:()=>p0,locallyScoped:()=>SRt,locallyScopedWith:()=>CRt,locallyWith:()=>bRt,log:()=>eNe,logAnnotations:()=>PRt,logDebug:()=>TRt,logError:()=>QRt,logFatal:()=>ORt,logInfo:()=>DRt,logTrace:()=>BRt,logWarning:()=>rX,logWithLevel:()=>_Rt,loop:()=>pRt,makeLatch:()=>n_t,makeSemaphore:()=>Y$,makeSpan:()=>nNe,makeSpanScoped:()=>Q_t,map:()=>De,mapAccum:()=>Hkt,mapBoth:()=>VT,mapError:()=>Ha,mapErrorCause:()=>Wkt,mapInputContext:()=>Ovt,match:()=>tX,matchCause:()=>oy,matchCauseEffect:()=>vc,matchEffect:()=>rD,merge:()=>jkt,mergeAll:()=>okt,metricLabels:()=>t_t,negate:()=>K5,never:()=>$$,none:()=>hkt,onError:()=>JT,onExit:()=>Gkt,onInterrupt:()=>Mkt,once:()=>J0t,option:()=>Gvt,optionFromOptional:()=>M_t,orDie:()=>Yf,orDieWith:()=>LRt,orElse:()=>nD,orElseFail:()=>URt,orElseSucceed:()=>$Rt,parallelErrors:()=>kkt,parallelFinalizers:()=>zkt,partition:()=>ikt,patchFiberRefs:()=>wRt,patchRuntimeFlags:()=>VRt,promise:()=>Y5,provide:()=>ry,provideService:()=>d0,provideServiceEffect:()=>eX,race:()=>eD,raceAll:()=>sRt,raceFirst:()=>KOe,raceWith:()=>tD,random:()=>WRt,randomWith:()=>jRt,reduce:()=>$Oe,reduceEffect:()=>ckt,reduceRight:()=>akt,reduceWhile:()=>skt,repeat:()=>z$,repeatN:()=>mRt,repeatOrElse:()=>hRt,replicate:()=>ukt,replicateEffect:()=>lkt,request:()=>p_t,retry:()=>J5,retryOrElse:()=>_kt,runCallback:()=>o_t,runFork:()=>m0,runPromise:()=>oX,runPromiseExit:()=>i_t,runRequestBlock:()=>d_t,runSync:()=>xd,runSyncExit:()=>s_t,runtime:()=>hh,sandbox:()=>vkt,schedule:()=>gRt,scheduleForked:()=>ARt,scheduleFrom:()=>yRt,scope:()=>u0,scopeWith:()=>Z5,scoped:()=>Ad,scopedWith:()=>KT,sequentialFinalizers:()=>Vkt,serviceConstants:()=>Fvt,serviceFunction:()=>Nvt,serviceFunctionEffect:()=>Pvt,serviceFunctions:()=>Mvt,serviceMembers:()=>Lvt,serviceOption:()=>G$,serviceOptional:()=>Uvt,setFiberRefs:()=>IRt,sleep:()=>Ivt,spanAnnotations:()=>__t,spanLinks:()=>B_t,step:()=>f_t,succeed:()=>nt,succeedNone:()=>H$,succeedSome:()=>gkt,summarized:()=>aRt,supervised:()=>dvt,suspend:()=>Pt,sync:()=>ot,tagMetrics:()=>KRt,tagMetricsScoped:()=>XRt,takeUntil:()=>X0t,takeWhile:()=>FOe,tap:()=>Ri,tapBoth:()=>cRt,tapDefect:()=>uRt,tapError:()=>lRt,tapErrorCause:()=>_b,tapErrorTag:()=>dRt,timed:()=>kvt,timedWith:()=>vvt,timeout:()=>X5,timeoutFail:()=>VOe,timeoutFailCause:()=>YOe,timeoutOption:()=>Rvt,timeoutTo:()=>_vt,tracer:()=>y_t,tracerWith:()=>x_t,transplant:()=>fvt,transposeMapOption:()=>L_t,transposeOption:()=>F_t,try:()=>Wu,tryMap:()=>zT,tryMapPromise:()=>Bkt,tryPromise:()=>ey,uninterruptible:()=>hd,uninterruptibleMask:()=>vb,unless:()=>eRt,unlessEffect:()=>tRt,unsafeMakeLatch:()=>J$,unsafeMakeSemaphore:()=>nX,unsandbox:()=>Tkt,updateFiberRefs:()=>kRt,updateService:()=>JOe,useSpan:()=>oNe,using:()=>Jkt,validate:()=>a_t,validateAll:()=>dkt,validateFirst:()=>fkt,validateWith:()=>c_t,void:()=>ve,when:()=>XT,whenEffect:()=>rRt,whenFiberRef:()=>nRt,whenLogLevel:()=>FRt,whenRef:()=>oRt,whileLoop:()=>XOe,withClock:()=>xvt,withClockScoped:()=>yvt,withConcurrency:()=>pvt,withConfigProvider:()=>Tvt,withConfigProviderScoped:()=>Dvt,withConsole:()=>Cvt,withConsoleScoped:()=>Svt,withEarlyRelease:()=>Kkt,withExecutionPlan:()=>Rkt,withFiberRuntime:()=>$a,withLogSpan:()=>tNe,withMaxOpsBeforeYield:()=>gvt,withMetric:()=>r_t,withParentSpan:()=>sNe,withRandom:()=>rNe,withRandomFixed:()=>qRt,withRandomScoped:()=>GRt,withRequestBatching:()=>h_t,withRequestCache:()=>A_t,withRequestCaching:()=>g_t,withRuntimeFlagsPatch:()=>YRt,withRuntimeFlagsPatchScoped:()=>JRt,withScheduler:()=>mvt,withSchedulingPriority:()=>hvt,withSpan:()=>iNe,withSpanScoped:()=>N_t,withTracer:()=>E_t,withTracerEnabled:()=>S_t,withTracerScoped:()=>b_t,withTracerTiming:()=>C_t,withUnhandledErrorLogLevel:()=>MRt,yieldNow:()=>Akt,zip:()=>Gu,zipLeft:()=>K$,zipRight:()=>Wt,zipWith:()=>gh});function POe(e,t){return Object.defineProperty(t,"length",{value:e,configurable:!0})}function MOe(e){let t,r;if(xEe(e.body))t=rB(()=>e.body.apply(e.self,e.args));else try{t=e.body.apply(e.self,e.args)}catch(s){r=s,t=Ua(s)}if(e.pipeables.length>0)try{for(let s of e.pipeables)t=s(t,...e.args)}catch(s){t=r?Is(Vr(eo(r),eo(s))):Ua(s)}let n=!1,o=()=>{if(n!==!1)return n;if(e.errorCall.stack){let s=e.errorDef.stack.trim().split(`
52
+ `).trim(),o}}return ye(()=>{let r=typeof e.options=="function"?e.options.apply(null,arguments):e.options;return WZ(ye(()=>qn(()=>e.body.apply(this,arguments))),r.name,{...r,captureStackTrace:t})})},Tve=e=>e==null?ut(new Es):M(e),Dve=e=>fc(te(e,H),t=>aK(t)?cb:ut(t))});var Fn={};tr(Fn,{all:()=>jZ,as:()=>gSt,asVoid:()=>ASt,causeOption:()=>ySt,die:()=>VB,exists:()=>xSt,fail:()=>Cc,failCause:()=>Mn,flatMap:()=>ESt,flatMapEffect:()=>bSt,flatten:()=>qZ,forEachEffect:()=>YB,fromEither:()=>SSt,fromOption:()=>CSt,getOrElse:()=>wSt,interrupt:()=>GZ,isExit:()=>Qve,isFailure:()=>sd,isInterrupted:()=>hSt,isSuccess:()=>Zm,map:()=>J1,mapBoth:()=>K1,mapError:()=>ISt,mapErrorCause:()=>kSt,match:()=>es,matchEffect:()=>Ove,succeed:()=>vo,void:()=>wc,zip:()=>Z1,zipLeft:()=>vSt,zipPar:()=>RSt,zipParLeft:()=>_St,zipParRight:()=>BSt,zipRight:()=>LA,zipWith:()=>zZ});var Qve,sd,Zm,hSt,gSt,ASt,ySt,jZ,VB,xSt,Cc,Mn,ESt,bSt,qZ,YB,SSt,CSt,wSt,GZ,J1,K1,ISt,kSt,es,Ove,vo,wc,Z1,vSt,LA,RSt,_St,BSt,zZ,Ro=h(()=>{vt();Qve=jE,sd=LL,Zm=yB,hSt=gwe,gSt=qE,ASt=oI,ySt=Awe,jZ=CA,VB=UL,xSt=ywe,Cc=nd,Mn=$t,ESt=cK,bSt=xwe,qZ=Ewe,YB=bwe,SSt=Swe,CSt=Cwe,wSt=wwe,GZ=xB,J1=tB,K1=Iwe,ISt=kwe,kSt=vwe,es=GE,Ove=zE,vo=Vt,wc=Pn,Z1=Rwe,vSt=_we,LA=$L,RSt=Bwe,_St=Twe,BSt=Dwe,zZ=Ru});var X1,eU,tU,rU,nU,BI,ub,Nve,VZ=h(()=>{X1="InterruptSignal",eU="Stateful",tU="Resume",rU="YieldNow",nU=e=>({_tag:X1,cause:e}),BI=e=>({_tag:eU,onFiber:e}),ub=e=>({_tag:tU,effect:e}),Nve=()=>({_tag:rU})});var TSt,oU,YZ,JZ,Mve,ad,JB=h(()=>{Zl();yn();VZ();TSt="effect/FiberScope",oU=Symbol.for(TSt),YZ=class{[oU]=oU;fiberId=ci;roots=new Set;add(t,r){this.roots.add(r),r.addObserver(()=>{this.roots.delete(r)})}},JZ=class{fiberId;parent;[oU]=oU;constructor(t,r){this.fiberId=t,this.parent=r}add(t,r){this.parent.tell(BI(n=>{n.addChild(r),r.addObserver(()=>{n.removeChild(r)})}))}},Mve=e=>new JZ(e.id(),e),ad=Te(Symbol.for("effect/FiberScope/Global"),()=>new YZ)});var DSt,Xm,TI,sU,QSt,ZB,XB,Fve,KB,aU,Lve,lb,cU,Uve,$ve,ZZ,Hve,Wve,uU,jve,qve,eT,lU,ki,iU,XZ,Gve,zve,OSt,Vve,e9,Yve,Jve,NSt,PSt,Kve,t9,Zve,Xve,r9,eRe,eh,tRe,tT=h(()=>{II();bi();Ro();Zl();BB();oe();dc();Lm();it();bm();Me();ct();vt();Af();JB();lA();DSt="effect/Fiber",Xm=Symbol.for(DSt),TI={_E:e=>e,_A:e=>e},sU={[Xm]:TI,pipe(){return Z(this,arguments)}},QSt="effect/Fiber",ZB=Symbol.for(QSt),XB=C(jEe(oo,oo),yf(e=>[e.id().startTimeMillis,e.id().id])),Fve=e=>se(e,Xm),KB=e=>ZB in e,aU=e=>e.await,Lve=e=>e.children,lb=e=>({...gu,commit(){return ki(this)},...sU,id:()=>ci,await:M(e),children:M([]),inheritAll:Ue,poll:M(H(e)),interruptAsFork:()=>Ue}),cU=e=>te(e.status,t=>({id:e.id(),status:t})),Uve=e=>Wo(e,cU),$ve=e=>lb(Cc(e)),ZZ=e=>lb(Mn(e)),Hve=e=>te(fn(e),lb),Wve=e=>e.id(),uU=e=>e.inheritAll,jve=e=>lb(GZ(e)),qve=e=>O(td,t=>C(e,eT(t))),eT=x(2,Xw(function*(e,t){for(let r of e){if(KB(r)){r.unsafeInterruptAsFork(t);continue}yield*r.interruptAsFork(t)}for(let r of e)KB(r)&&r.unsafePoll()||(yield*r.await)})),lU=x(2,(e,t)=>e.interruptAsFork(t)),ki=e=>$E(ys(e.await),e.inheritAll),iU=x(2,(e,t)=>XZ(e,r=>V(()=>t(r)))),XZ=x(2,(e,t)=>({...gu,commit(){return ki(this)},...sU,id:()=>e.id(),await:O(e.await,YB(t)),children:e.children,inheritAll:e.inheritAll,poll:O(e.poll,n=>{switch(n._tag){case"None":return M(W());case"Some":return C(YB(n.value,t),te(H))}}),interruptAsFork:n=>e.interruptAsFork(n)})),Gve=x(2,(e,t)=>te(e.await,es({onFailure:r=>ZZ(r),onSuccess:r=>t(r)}))),zve=x(2,(e,{onFiber:t,onRuntimeFiber:r})=>KB(e)?r(e):t(e)),OSt={...gu,commit(){return ki(this)},...sU,id:()=>ci,await:xA,children:M([]),inheritAll:xA,poll:M(W()),interruptAsFork:()=>xA},Vve=OSt,e9=x(2,(e,t)=>({...gu,commit(){return ki(this)},...sU,id:()=>iL(e.id(),t.id()),await:Zi(e.await,t.await,(r,n)=>Zm(r)?r:n),children:e.children,inheritAll:je(t.inheritAll,e.inheritAll),poll:Zi(e.poll,t.poll,(r,n)=>{switch(r._tag){case"None":return W();case"Some":return Zm(r.value)?r:n}}),interruptAsFork:r=>C(xs(e,r),je(C(t,xs(r))),$r)})),Yve=x(2,(e,t)=>e9(iU(e,Re),iU(t,Le))),Jve=e=>e.poll,NSt=e=>{let t=e>0?Math.floor:Math.ceil;return{days:t(e/864e5),hours:t(e/36e5)%24,minutes:t(e/6e4)%60,seconds:t(e/1e3)%60,milliseconds:t(e)%1e3,microseconds:t(e*1e3)%1e3,nanoseconds:t(e*1e6)%1e3}},PSt=e=>hI(e)?"Done":A0e(e)?"Running":`Suspended(${ed(e.runtimeFlags)?"interruptible":"uninterruptible"})`,Kve=e=>O(zm,t=>te(cU(e),r=>{let n=t-r.id.startTimeMillis,{days:o,hours:i,milliseconds:s,minutes:a,seconds:c}=NSt(n),u=(o===0?"":`${o}d`)+(o===0&&i===0?"":`${i}h`)+(o===0&&i===0&&a===0?"":`${a}m`)+(o===0&&i===0&&a===0&&c===0?"":`${c}s`)+`${s}ms`,l=y1(r.status)?(()=>{let f=qw(r.status.blockingOn);return Gl(f)>0?"waiting on "+Array.from(f).map(p=>`${p}`).join(", "):""})():"",d=PSt(r.status);return`[Fiber](#${r.id.id}) (${u}) ${l}
53
+ Status: ${d}`})),t9=()=>Array.from(ad.roots),Zve=V(t9),Xve=e=>e.status,r9=e=>lb(vo(e)),eRe=r9(void 0),eh="effect/FiberCurrent",tRe=()=>en(globalThis[eh])});var MSt,rRe,nRe,fU,G0r,FSt,LSt,USt,oRe,db,z0r,iRe,V0r,Y0r,sRe=h(()=>{wr();oe();ht();Me();Jl();oL();CZ();MSt="effect/Logger",rRe=Symbol.for(MSt),nRe={_Message:e=>e,_Output:e=>e},fU=e=>({[rRe]:nRe,log:e,pipe(){return Z(this,arguments)}}),G0r={[rRe]:nRe,log:yi,pipe(){return Z(this,arguments)}},FSt=/^[^\s"=]*$/,LSt=(e,t)=>({annotations:r,cause:n,date:o,fiberId:i,logLevel:s,message:a,spans:c})=>{let u=m=>m.match(FSt)?m:e(m),l=(m,g)=>`${bZ(m)}=${u(g)}`,d=(m,g)=>" "+l(m,g),f=l("timestamp",o.toISOString());f+=d("level",s.label),f+=d("fiber",nL(i));let p=f6(a);for(let m=0;m<p.length;m++)f+=d("message",ym(p[m],t));$6(n)||(f+=d("cause",Yl(n,{renderErrorCause:!0})));for(let m of c)f+=" "+SZ(o.getTime())(m);for(let[m,g]of r)f+=d(m,ym(g,t));return f},USt=e=>`"${e.replace(/\\([\s\S])|(")/g,"\\$1$2")}"`,oRe=fU(LSt(USt)),db={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},z0r={None:[],All:[],Trace:[db.gray],Debug:[db.blue],Info:[db.green],Warning:[db.yellow],Error:[db.red],Fatal:[db.bgBrightRed,db.black]},iRe=typeof process=="object"&&process!==null&&typeof process.stdout=="object"&&process.stdout!==null,V0r=iRe&&process.stdout.isTTY===!0,Y0r=iRe||"Deno"in globalThis});var aRe,n9,o9,HSt,WSt,cRe,uRe=h(()=>{wr();vr();mt();oe();ir();Me();ct();aRe="effect/MetricBoundaries",n9=Symbol.for(aRe),o9=class{values;[n9]=n9;constructor(t){this.values=t,this._hash=C(Lt(aRe),we(So(this.values)))}_hash;[he](){return this._hash}[me](t){return HSt(t)&&ce(this.values,t.values)}pipe(){return Z(this,arguments)}},HSt=e=>se(e,n9),WSt=e=>{let t=C(e,xF(Dt(Number.POSITIVE_INFINITY)),S6);return new o9(t)},cRe=e=>C(d6(e.count-1,t=>e.start*Math.pow(e.factor,t)),ln,WSt)});var qSt,rT,pRe,i9,mRe,s9,hRe,a9,gRe,c9,ARe,u9,nT,l9,GSt,lRe,zSt,dRe,d9,fRe,yRe,xRe,f9,p9,m9,h9,g9,A9=h(()=>{mt();oe();ir();Me();ct();qSt="effect/MetricKeyType",rT=Symbol.for(qSt),pRe="effect/MetricKeyType/Counter",i9=Symbol.for(pRe),mRe="effect/MetricKeyType/Frequency",s9=Symbol.for(mRe),hRe="effect/MetricKeyType/Gauge",a9=Symbol.for(hRe),gRe="effect/MetricKeyType/Histogram",c9=Symbol.for(gRe),ARe="effect/MetricKeyType/Summary",u9=Symbol.for(ARe),nT={_In:e=>e,_Out:e=>e},l9=class{incremental;bigint;[rT]=nT;[i9]=i9;constructor(t,r){this.incremental=t,this.bigint=r,this._hash=Lt(pRe)}_hash;[he](){return this._hash}[me](t){return f9(t)}pipe(){return Z(this,arguments)}},GSt=Lt(mRe),lRe=class{preregisteredWords;[rT]=nT;[s9]=s9;constructor(t){this.preregisteredWords=t}[he](){return GSt}[me](t){return p9(t)}pipe(){return Z(this,arguments)}},zSt=Lt(hRe),dRe=class{bigint;[rT]=nT;[a9]=a9;constructor(t){this.bigint=t}[he](){return zSt}[me](t){return m9(t)}pipe(){return Z(this,arguments)}},d9=class{boundaries;[rT]=nT;[c9]=c9;constructor(t){this.boundaries=t,this._hash=C(Lt(gRe),we(ae(this.boundaries)))}_hash;[he](){return this._hash}[me](t){return h9(t)&&ce(this.boundaries,t.boundaries)}pipe(){return Z(this,arguments)}},fRe=class{maxAge;maxSize;error;quantiles;[rT]=nT;[u9]=u9;constructor(t,r,n,o){this.maxAge=t,this.maxSize=r,this.error=n,this.quantiles=o,this._hash=C(Lt(ARe),we(ae(this.maxAge)),we(ae(this.maxSize)),we(ae(this.error)),we(So(this.quantiles)))}_hash;[he](){return this._hash}[me](t){return g9(t)&&ce(this.maxAge,t.maxAge)&&this.maxSize===t.maxSize&&this.error===t.error&&ce(this.quantiles,t.quantiles)}pipe(){return Z(this,arguments)}},yRe=e=>new l9(e?.incremental??!1,e?.bigint??!1),xRe=e=>new d9(e),f9=e=>se(e,i9),p9=e=>se(e,s9),m9=e=>se(e,a9),h9=e=>se(e,c9),g9=e=>se(e,u9)});var VSt,bRe,YSt,JSt,oT,KSt,SRe,CRe,wRe,IRe=h(()=>{wr();mt();oe();ir();it();Me();ct();A9();VSt="effect/MetricKey",bRe=Symbol.for(VSt),YSt={_Type:e=>e},JSt=Jg(ce),oT=class{name;keyType;description;tags;[bRe]=YSt;constructor(t,r,n,o=[]){this.name=t,this.keyType=r,this.description=n,this.tags=o,this._hash=C(Lt(this.name+this.description),we(ae(this.keyType)),we(So(this.tags)))}_hash;[he](){return this._hash}[me](t){return KSt(t)&&this.name===t.name&&ce(this.keyType,t.keyType)&&ce(this.description,t.description)&&JSt(this.tags,t.tags)}pipe(){return Z(this,arguments)}},KSt=e=>se(e,bRe),SRe=(e,t)=>new oT(e,yRe(t),en(t?.description)),CRe=(e,t,r)=>new oT(e,xRe(t),en(r)),wRe=x(2,(e,t)=>t.length===0?e:new oT(e.name,e.keyType,e.description,Ul(e.tags,t)))});var kRe,XSt,y9,x9,fb,_o,eCt,cd,Ma,vRe,pb,pU,iT=h(()=>{mt();oe();ir();ht();it();Me();kRe=Symbol.for("effect/MutableHashMap"),XSt={[kRe]:kRe,[Symbol.iterator](){return new y9(this)},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"MutableHashMap",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},y9=class e{self;referentialIterator;bucketIterator;constructor(t){this.self=t,this.referentialIterator=t.referential[Symbol.iterator]()}next(){if(this.bucketIterator!==void 0)return this.bucketIterator.next();let t=this.referentialIterator.next();return t.done?(this.bucketIterator=new x9(this.self.buckets.values()),this.next()):t}[Symbol.iterator](){return new e(this.self)}},x9=class{backing;constructor(t){this.backing=t}currentBucket;next(){if(this.currentBucket===void 0){let r=this.backing.next();if(r.done)return r;this.currentBucket=r.value[Symbol.iterator]()}let t=this.currentBucket.next();return t.done?(this.currentBucket=void 0,this.next()):t}},fb=()=>{let e=Object.create(XSt);return e.referential=new Map,e.buckets=new Map,e.bucketsSize=0,e},_o=x(2,(e,t)=>{if(yw(t)===!1)return e.referential.has(t)?H(e.referential.get(t)):W();let r=t[he](),n=e.buckets.get(r);return n===void 0?W():eCt(e,n,t)}),eCt=(e,t,r,n=!1)=>{for(let o=0,i=t.length;o<i;o++)if(r[me](t[o][0])){let s=t[o][1];return n&&(t.splice(o,1),e.bucketsSize--),H(s)}return W()},cd=x(2,(e,t)=>pt(_o(e,t))),Ma=x(3,(e,t,r)=>{if(yw(t)===!1)return e.referential.set(t,r),e;let n=t[he](),o=e.buckets.get(n);return o===void 0?(e.buckets.set(n,[[t,r]]),e.bucketsSize++,e):(vRe(e,o,t),o.push([t,r]),e.bucketsSize++,e)}),vRe=(e,t,r)=>{for(let n=0,o=t.length;n<o;n++)if(r[me](t[n][0])){t.splice(n,1),e.bucketsSize--;return}},pb=x(2,(e,t)=>{if(yw(t)===!1)return e.referential.delete(t),e;let r=t[he](),n=e.buckets.get(r);return n===void 0||(vRe(e,n,t),n.length===0&&e.buckets.delete(r)),e}),pU=e=>e.referential.size+e.bucketsSize});var tCt,sT,RRe,E9,_Re,b9,BRe,S9,TRe,C9,DRe,w9,aT,I9,rCt,k9,v9,R9,_9,QRe,ORe,NRe,PRe,MRe,nCt,oCt,iCt,sCt,aCt,FRe=h(()=>{wr();mt();oe();ir();Me();ct();tCt="effect/MetricState",sT=Symbol.for(tCt),RRe="effect/MetricState/Counter",E9=Symbol.for(RRe),_Re="effect/MetricState/Frequency",b9=Symbol.for(_Re),BRe="effect/MetricState/Gauge",S9=Symbol.for(BRe),TRe="effect/MetricState/Histogram",C9=Symbol.for(TRe),DRe="effect/MetricState/Summary",w9=Symbol.for(DRe),aT={_A:e=>e},I9=class{count;[sT]=aT;[E9]=E9;constructor(t){this.count=t}[he](){return C(ae(RRe),we(ae(this.count)),We(this))}[me](t){return nCt(t)&&this.count===t.count}pipe(){return Z(this,arguments)}},rCt=Jg(ce),k9=class{occurrences;[sT]=aT;[b9]=b9;constructor(t){this.occurrences=t}_hash;[he](){return C(Lt(_Re),we(So(_e(this.occurrences.entries()))),We(this))}[me](t){return oCt(t)&&rCt(_e(this.occurrences.entries()),_e(t.occurrences.entries()))}pipe(){return Z(this,arguments)}},v9=class{value;[sT]=aT;[S9]=S9;constructor(t){this.value=t}[he](){return C(ae(BRe),we(ae(this.value)),We(this))}[me](t){return iCt(t)&&this.value===t.value}pipe(){return Z(this,arguments)}},R9=class{buckets;count;min;max;sum;[sT]=aT;[C9]=C9;constructor(t,r,n,o,i){this.buckets=t,this.count=r,this.min=n,this.max=o,this.sum=i}[he](){return C(ae(TRe),we(ae(this.buckets)),we(ae(this.count)),we(ae(this.min)),we(ae(this.max)),we(ae(this.sum)),We(this))}[me](t){return sCt(t)&&ce(this.buckets,t.buckets)&&this.count===t.count&&this.min===t.min&&this.max===t.max&&this.sum===t.sum}pipe(){return Z(this,arguments)}},_9=class{error;quantiles;count;min;max;sum;[sT]=aT;[w9]=w9;constructor(t,r,n,o,i,s){this.error=t,this.quantiles=r,this.count=n,this.min=o,this.max=i,this.sum=s}[he](){return C(ae(DRe),we(ae(this.error)),we(ae(this.quantiles)),we(ae(this.count)),we(ae(this.min)),we(ae(this.max)),we(ae(this.sum)),We(this))}[me](t){return aCt(t)&&this.error===t.error&&ce(this.quantiles,t.quantiles)&&this.count===t.count&&this.min===t.min&&this.max===t.max&&this.sum===t.sum}pipe(){return Z(this,arguments)}},QRe=e=>new I9(e),ORe=e=>new k9(e),NRe=e=>new v9(e),PRe=e=>new R9(e.buckets,e.count,e.min,e.max,e.sum),MRe=e=>new _9(e.error,e.quantiles,e.count,e.min,e.max,e.sum),nCt=e=>se(e,E9),oCt=e=>se(e,b9),iCt=e=>se(e,S9),sCt=e=>se(e,C9),aCt=e=>se(e,w9)});var uCt,lCt,dCt,cT,LRe,$Re,HRe,WRe,jRe,qRe,fCt,URe,GRe=h(()=>{wr();Ws();oe();Lm();it();Me();FRe();uCt="effect/MetricHook",lCt=Symbol.for(uCt),dCt={_In:e=>e,_Out:e=>e},cT=e=>({[lCt]:dCt,pipe(){return Z(this,arguments)},...e}),LRe=BigInt(0),$Re=e=>{let t=e.keyType.bigint?LRe:0,r=e.keyType.incremental?e.keyType.bigint?o=>o>=LRe:o=>o>=0:o=>!0,n=o=>{r(o)&&(t=t+o)};return cT({get:()=>QRe(t),update:n,modify:n})},HRe=e=>{let t=new Map;for(let n of e.keyType.preregisteredWords)t.set(n,0);let r=n=>{let o=t.get(n)??0;t.set(n,o+1)};return cT({get:()=>ORe(t),update:r,modify:r})},WRe=(e,t)=>{let r=t;return cT({get:()=>NRe(r),update:n=>{r=n},modify:n=>{r=r+n}})},jRe=e=>{let t=e.keyType.boundaries.values,r=t.length,n=new Uint32Array(r+1),o=new Float64Array(r),i=0,s=0,a=Number.MAX_VALUE,c=Number.MIN_VALUE;C(t,Vi(oo),$l((d,f)=>{o[f]=d}));let u=d=>{let f=0,p=r;for(;f!==p;){let m=Math.floor(f+(p-f)/2),g=o[m];d<=g?p=m:f=m,p===f+1&&(d<=o[f]?p=f:f=p)}n[f]=n[f]+1,i=i+1,s=s+d,d<a&&(a=d),d>c&&(c=d)},l=()=>{let d=bE(r),f=0;for(let p=0;p<r;p++){let m=o[p],g=n[p];f=f+g,d[p]=[m,f]}return d};return cT({get:()=>PRe({buckets:l(),count:i,min:a,max:c,sum:s}),update:u,modify:u})},qRe=e=>{let{error:t,maxAge:r,maxSize:n,quantiles:o}=e.keyType,i=C(o,Vi(oo)),s=bE(n),a=0,c=0,u=0,l=0,d=0,f=m=>{let g=[],A=0;for(;A!==n-1;){let E=s[A];if(E!=null){let[y,b]=E,w=Ki(m-y);$_(w,As)&&s3(w,r)&&g.push(b)}A=A+1}return fCt(t,i,Vi(g,oo))},p=(m,g)=>{if(n>0){a=a+1;let A=a%n;s[A]=[g,m]}l=c===0?m:Math.min(l,m),d=c===0?m:Math.max(d,m),c=c+1,u=u+m};return cT({get:()=>MRe({error:t,quantiles:f(Date.now()),count:c,min:l,max:d,sum:u}),update:([m,g])=>p(m,g),modify:([m,g])=>p(m,g)})},fCt=(e,t,r)=>{let n=r.length;if(!zr(t))return Us();let o=t[0],i=t.slice(1),s=URe(e,n,W(),0,o,r),a=hs(s);return i.forEach(c=>{a.push(URe(e,n,s.value,s.consumed,c,s.rest))}),$l(a,c=>[c.quantile,c.value])},URe=(e,t,r,n,o,i)=>{let s=e,a=t,c=r,u=n,l=o,d=i,f=e,p=t,m=r,g=n,A=o,E=i;for(;;){if(!zr(d))return{quantile:l,value:W(),consumed:u,rest:[]};if(l===1)return{quantile:l,value:H(g6(d)),consumed:u+d.length,rest:[]};let y=Lo(d),b=sbe(d,R=>R===y),w=l*a,I=s/2*w,v=u+b[0].length,k=Math.abs(v-w);if(v<w-I){f=s,p=a,m=wm(d),g=v,A=l,E=b[1],s=f,a=p,c=m,u=g,l=A,d=E;continue}if(v>w+I){let R=Ct(c)?H(y):c;return{quantile:l,value:R,consumed:u,rest:d}}switch(c._tag){case"None":{f=s,p=a,m=wm(d),g=v,A=l,E=b[1],s=f,a=p,c=m,u=g,l=A,d=E;continue}case"Some":{let R=Math.abs(w-c.value);if(k<R){f=s,p=a,m=wm(d),g=v,A=l,E=b[1],s=f,a=p,c=m,u=g,l=A,d=E;continue}return{quantile:l,value:H(c.value),consumed:u,rest:d}}}}throw new Error("BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues")}});var mCt,hCt,gCt,zRe,VRe=h(()=>{Me();mCt="effect/MetricPair",hCt=Symbol.for(mCt),gCt={_Type:e=>e},zRe=(e,t)=>({[hCt]:gCt,metricKey:e,metricState:t,pipe(){return Z(this,arguments)}})});var yCt,YRe,B9,JRe,KRe=h(()=>{oe();iT();it();GRe();A9();VRe();yCt="effect/MetricRegistry",YRe=Symbol.for(yCt),B9=class{[YRe]=YRe;map=fb();snapshot(){let t=[];for(let[r,n]of this.map)t.push(zRe(r,n.get()));return t}get(t){let r=C(this.map,_o(t),Gr);if(r==null){if(f9(t.keyType))return this.getCounter(t);if(m9(t.keyType))return this.getGauge(t);if(p9(t.keyType))return this.getFrequency(t);if(h9(t.keyType))return this.getHistogram(t);if(g9(t.keyType))return this.getSummary(t);throw new Error("BUG: MetricRegistry.get - unknown MetricKeyType - please report an issue at https://github.com/Effect-TS/effect/issues")}else return r}getCounter(t){let r=C(this.map,_o(t),Gr);if(r==null){let n=$Re(t);C(this.map,cd(t))||C(this.map,Ma(t,n)),r=n}return r}getFrequency(t){let r=C(this.map,_o(t),Gr);if(r==null){let n=HRe(t);C(this.map,cd(t))||C(this.map,Ma(t,n)),r=n}return r}getGauge(t){let r=C(this.map,_o(t),Gr);if(r==null){let n=WRe(t,t.keyType.bigint?BigInt(0):0);C(this.map,cd(t))||C(this.map,Ma(t,n)),r=n}return r}getHistogram(t){let r=C(this.map,_o(t),Gr);if(r==null){let n=jRe(t);C(this.map,cd(t))||C(this.map,Ma(t,n)),r=n}return r}getSummary(t){let r=C(this.map,_o(t),Gr);if(r==null){let n=qRe(t);C(this.map,cd(t))||C(this.map,Ma(t,n)),r=n}return r}},JRe=()=>new B9});var ECt,bCt,SCt,ZRe,XRe,uT,e_e,t_e,r_e,CCt,wCt,n_e=h(()=>{wr();oe();yn();Me();vt();IRe();L1();KRe();ECt="effect/Metric",bCt=Symbol.for(ECt),SCt={_Type:e=>e,_In:e=>e,_Out:e=>e},ZRe=Te(Symbol.for("effect/Metric/globalMetricRegistry"),()=>JRe()),XRe=function(e,t,r,n){let o=Object.assign(i=>jo(i,s=>wCt(o,s)),{[bCt]:SCt,keyType:e,unsafeUpdate:t,unsafeValue:r,unsafeModify:n,register(){return this.unsafeValue([]),this},pipe(){return Z(this,arguments)}});return o},uT=(e,t)=>e_e(SRe(e,t)),e_e=e=>{let t,r=new WeakMap,n=o=>{if(o.length===0)return t!==void 0||(t=ZRe.get(e)),t;let i=r.get(o);return i!==void 0||(i=ZRe.get(wRe(e,o)),r.set(o,i)),i};return XRe(e.keyType,(o,i)=>n(i).update(o),o=>n(o).get(),(o,i)=>n(i).modify(o))},t_e=(e,t,r)=>e_e(CRe(e,t,r)),r_e=x(3,(e,t,r)=>CCt(e,[sb(t,r)])),CCt=x(2,(e,t)=>XRe(e.keyType,(r,n)=>e.unsafeUpdate(r,Ul(t,n)),r=>e.unsafeValue(Ul(t,r)),(r,n)=>e.unsafeModify(r,Ul(t,n)))),wCt=x(2,(e,t)=>ui(Nf,r=>V(()=>e.unsafeUpdate(t,r))))});var kCt,T9,vCt,vkr,o_e,D9,DI,hU=h(()=>{oe();ct();gZ();vt();Af();kCt="effect/Request",T9=Symbol.for(kCt),vCt={_E:e=>e,_A:e=>e},vkr={...gf,[T9]:vCt},o_e=e=>se(e,T9),D9=x(2,(e,t)=>ui(P1,r=>V(()=>{if(r.has(e)){let n=r.get(e);n.state.completed||(n.state.completed=!0,IA(n.result,t))}}))),DI=class{count=0;observers=new Set;interrupted=!1;addObserver(t){this.observers.add(t)}removeObserver(t){this.observers.delete(t)}increment(){this.count++,this.observers.forEach(t=>t(this.count))}decrement(){this.count--,this.observers.forEach(t=>t(this.count))}}});var UA,gU,i_e=h(()=>{wr();it();UA={Forward:0,Backward:1},gU=class e{self;stack;direction;count=0;constructor(t,r,n){this.self=t,this.stack=r,this.direction=n}clone(){return new e(this.self,this.stack.slice(),this.direction)}reversed(){return new e(this.self,this.stack.slice(),this.direction===UA.Forward?UA.Backward:UA.Forward)}next(){let t=this.entry;switch(this.count++,this.direction===UA.Forward?this.moveNext():this.movePrev(),t._tag){case"None":return{done:!0,value:this.count};case"Some":return{done:!1,value:t.value}}}get key(){return this.stack.length>0?H(this.stack[this.stack.length-1].key):W()}get value(){return this.stack.length>0?H(this.stack[this.stack.length-1].value):W()}get entry(){return dr(EF(this.stack),t=>[t.key,t.value])}get index(){let t=0,r=this.stack;if(r.length===0){let n=this.self._root;return n!=null?n.count:0}else r[r.length-1].left!=null&&(t=r[r.length-1].left.count);for(let n=r.length-2;n>=0;--n)r[n+1]===r[n].right&&(++t,r[n].left!=null&&(t+=r[n].left.count));return t}moveNext(){let t=this.stack;if(t.length===0)return;let r=t[t.length-1];if(r.right!=null)for(r=r.right;r!=null;)t.push(r),r=r.left;else for(t.pop();t.length>0&&t[t.length-1].right===r;)r=t[t.length-1],t.pop()}get hasNext(){let t=this.stack;if(t.length===0)return!1;if(t[t.length-1].right!=null)return!0;for(let r=t.length-1;r>0;--r)if(t[r-1].left===t[r])return!0;return!1}movePrev(){let t=this.stack;if(t.length===0)return;let r=t[t.length-1];if(r!=null&&r.left!=null)for(r=r.left;r!=null;)t.push(r),r=r.right;else for(t.pop();t.length>0&&t[t.length-1].left===r;)r=t[t.length-1],t.pop()}get hasPrev(){let t=this.stack;if(t.length===0)return!1;if(t[t.length-1].left!=null)return!0;for(let r=t.length-1;r>0;--r)if(t[r-1].right===t[r])return!0;return!1}}});function Q9(e,t){e.key=t.key,e.value=t.value,e.left=t.left,e.right=t.right,e.color=t.color,e.count=t.count}var Ve,ud,th,wn,s_e=h(()=>{Ve={Red:0,Black:1},ud=({color:e,count:t,key:r,left:n,right:o,value:i})=>({color:e,key:r,value:i,left:n,right:o,count:t});th=({count:e,key:t,left:r,right:n,value:o},i)=>({color:i,key:t,value:o,left:r,right:n,count:e}),wn=e=>{e.count=1+(e.left?.count??0)+(e.right?.count??0)}});var a_e,O9,BCt,TCt,QI,c_e,u_e,l_e,d_e,N9,f_e,p_e,m_e,h_e,DCt,g_e=h(()=>{mt();oe();ir();ht();it();Me();ct();i_e();s_e();a_e="effect/RedBlackTree",O9=Symbol.for(a_e),BCt={_Key:e=>e,_Value:e=>e},TCt={[O9]:BCt,[he](){let e=ae(a_e);for(let t of this)e^=C(ae(t[0]),we(ae(t[1])));return We(this,e)},[me](e){if(c_e(e)){if((this._root?.count??0)!==(e._root?.count??0))return!1;let t=Array.from(e);return Array.from(this).every((r,n)=>{let o=t[n];return ce(r[0],o[0])&&ce(r[1],o[1])})}return!1},[Symbol.iterator](){let e=[],t=this._root;for(;t!=null;)e.push(t),t=t.left;return new gU(this,e,UA.Forward)},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"RedBlackTree",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},QI=(e,t)=>{let r=Object.create(TCt);return r._ord=e,r._root=t,r},c_e=e=>se(e,O9),u_e=e=>QI(e,void 0),l_e=x(2,(e,t)=>{let r=e._ord,n=e._root;for(;n!==void 0;){let o=r(t,n.key);if(ce(t,n.key))return H(n.value);o<=0?n=n.left:n=n.right}return W()}),d_e=e=>e._ord,N9=x(2,(e,t)=>pt(l_e(e,t))),f_e=x(3,(e,t,r)=>{let n=e._ord,o=e._root,i=[],s=[];for(;o!=null;){let a=n(t,o.key);i.push(o),s.push(a),a<=0?o=o.left:o=o.right}i.push({color:Ve.Red,key:t,value:r,left:void 0,right:void 0,count:1});for(let a=i.length-2;a>=0;--a){let c=i[a];s[a]<=0?i[a]={color:c.color,key:c.key,value:c.value,left:i[a+1],right:c.right,count:c.count+1}:i[a]={color:c.color,key:c.key,value:c.value,left:c.left,right:i[a+1],count:c.count+1}}for(let a=i.length-1;a>1;--a){let c=i[a-1],u=i[a];if(c.color===Ve.Black||u.color===Ve.Black)break;let l=i[a-2];if(l.left===c)if(c.left===u){let d=l.right;if(d&&d.color===Ve.Red)c.color=Ve.Black,l.right=th(d,Ve.Black),l.color=Ve.Red,a-=1;else{if(l.color=Ve.Red,l.left=c.right,c.color=Ve.Black,c.right=l,i[a-2]=c,i[a-1]=u,wn(l),wn(c),a>=3){let f=i[a-3];f.left===l?f.left=c:f.right=c}break}}else{let d=l.right;if(d&&d.color===Ve.Red)c.color=Ve.Black,l.right=th(d,Ve.Black),l.color=Ve.Red,a-=1;else{if(c.right=u.left,l.color=Ve.Red,l.left=u.right,u.color=Ve.Black,u.left=c,u.right=l,i[a-2]=u,i[a-1]=c,wn(l),wn(c),wn(u),a>=3){let f=i[a-3];f.left===l?f.left=u:f.right=u}break}}else if(c.right===u){let d=l.left;if(d&&d.color===Ve.Red)c.color=Ve.Black,l.left=th(d,Ve.Black),l.color=Ve.Red,a-=1;else{if(l.color=Ve.Red,l.right=c.left,c.color=Ve.Black,c.left=l,i[a-2]=c,i[a-1]=u,wn(l),wn(c),a>=3){let f=i[a-3];f.right===l?f.right=c:f.left=c}break}}else{let d=l.left;if(d&&d.color===Ve.Red)c.color=Ve.Black,l.left=th(d,Ve.Black),l.color=Ve.Red,a-=1;else{if(c.left=u.right,l.color=Ve.Red,l.right=u.left,u.color=Ve.Black,u.right=c,u.left=l,i[a-2]=u,i[a-1]=c,wn(l),wn(c),wn(u),a>=3){let f=i[a-3];f.right===l?f.right=u:f.left=u}break}}}return i[0].color=Ve.Black,QI(e._ord,i[0])}),p_e=e=>m_e(e,UA.Forward),m_e=(e,t)=>{let r=e[Symbol.iterator](),n=0;return{[Symbol.iterator]:()=>m_e(e,t),next:()=>{n++;let o=r.key;switch(t===UA.Forward?r.moveNext():r.movePrev(),o._tag){case"None":return{done:!0,value:n};case"Some":return{done:!1,value:o.value}}}}},h_e=x(2,(e,t)=>{if(!N9(e,t))return e;let r=e._ord,n=r,o=e._root,i=[];for(;o!==void 0;){let c=n(t,o.key);i.push(o),ce(t,o.key)?o=void 0:c<=0?o=o.left:o=o.right}if(i.length===0)return e;let s=new Array(i.length),a=i[i.length-1];s[s.length-1]={color:a.color,key:a.key,value:a.value,left:a.left,right:a.right,count:a.count};for(let c=i.length-2;c>=0;--c)a=i[c],a.left===i[c+1]?s[c]={color:a.color,key:a.key,value:a.value,left:s[c+1],right:a.right,count:a.count}:s[c]={color:a.color,key:a.key,value:a.value,left:a.left,right:s[c+1],count:a.count};if(a=s[s.length-1],a.left!==void 0&&a.right!==void 0){let c=s.length;for(a=a.left;a.right!=null;)s.push(a),a=a.right;let u=s[c-1];s.push({color:a.color,key:u.key,value:u.value,left:a.left,right:a.right,count:a.count}),s[c-1].key=a.key,s[c-1].value=a.value;for(let l=s.length-2;l>=c;--l)a=s[l],s[l]={color:a.color,key:a.key,value:a.value,left:a.left,right:s[l+1],count:a.count};s[c-1].left=s[c]}if(a=s[s.length-1],a.color===Ve.Red){let c=s[s.length-2];c.left===a?c.left=void 0:c.right===a&&(c.right=void 0),s.pop();for(let u=0;u<s.length;++u)s[u].count--;return QI(r,s[0])}else if(a.left!==void 0||a.right!==void 0){a.left!==void 0?Q9(a,a.left):a.right!==void 0&&Q9(a,a.right),a.color=Ve.Black;for(let c=0;c<s.length-1;++c)s[c].count--;return QI(r,s[0])}else{if(s.length===1)return QI(r,void 0);{for(let u=0;u<s.length;++u)s[u].count--;let c=s[s.length-2];DCt(s),c.left===a?c.left=void 0:c.right=void 0}}return QI(r,s[0])}),DCt=e=>{let t,r,n,o;for(let i=e.length-1;i>=0;--i){if(t=e[i],i===0){t.color=Ve.Black;return}if(r=e[i-1],r.left===t){if(n=r.right,n!==void 0&&n.right!==void 0&&n.right.color===Ve.Red){if(n=r.right=ud(n),o=n.right=ud(n.right),r.right=n.left,n.left=r,n.right=o,n.color=r.color,t.color=Ve.Black,r.color=Ve.Black,o.color=Ve.Black,wn(r),wn(n),i>1){let s=e[i-2];s.left===r?s.left=n:s.right=n}e[i-1]=n;return}else if(n!==void 0&&n.left!==void 0&&n.left.color===Ve.Red){if(n=r.right=ud(n),o=n.left=ud(n.left),r.right=o.left,n.left=o.right,o.left=r,o.right=n,o.color=r.color,r.color=Ve.Black,n.color=Ve.Black,t.color=Ve.Black,wn(r),wn(n),wn(o),i>1){let s=e[i-2];s.left===r?s.left=o:s.right=o}e[i-1]=o;return}if(n!==void 0&&n.color===Ve.Black)if(r.color===Ve.Red){r.color=Ve.Black,r.right=th(n,Ve.Red);return}else{r.right=th(n,Ve.Red);continue}else if(n!==void 0){if(n=ud(n),r.right=n.left,n.left=r,n.color=r.color,r.color=Ve.Red,wn(r),wn(n),i>1){let s=e[i-2];s.left===r?s.left=n:s.right=n}e[i-1]=n,e[i]=r,i+1<e.length?e[i+1]=t:e.push(t),i=i+2}}else{if(n=r.left,n!==void 0&&n.left!==void 0&&n.left.color===Ve.Red){if(n=r.left=ud(n),o=n.left=ud(n.left),r.left=n.right,n.right=r,n.left=o,n.color=r.color,t.color=Ve.Black,r.color=Ve.Black,o.color=Ve.Black,wn(r),wn(n),i>1){let s=e[i-2];s.right===r?s.right=n:s.left=n}e[i-1]=n;return}else if(n!==void 0&&n.right!==void 0&&n.right.color===Ve.Red){if(n=r.left=ud(n),o=n.right=ud(n.right),r.left=o.right,n.right=o.left,o.right=r,o.left=n,o.color=r.color,r.color=Ve.Black,n.color=Ve.Black,t.color=Ve.Black,wn(r),wn(n),wn(o),i>1){let s=e[i-2];s.right===r?s.right=o:s.left=o}e[i-1]=o;return}if(n!==void 0&&n.color===Ve.Black)if(r.color===Ve.Red){r.color=Ve.Black,r.left=th(n,Ve.Red);return}else{r.left=th(n,Ve.Red);continue}else if(n!==void 0){if(n=ud(n),r.left=n.right,n.right=r,n.color=r.color,r.color=Ve.Red,wn(r),wn(n),i>1){let s=e[i-2];s.right===r?s.right=n:s.left=n}e[i-1]=n,e[i]=r,i+1<e.length?e[i+1]=t:e.push(t),i=i+2}}}}});var A_e,P9,y_e,x_e,E_e,b_e,M9=h(()=>{g_e();A_e=u_e,P9=d_e,y_e=N9,x_e=f_e,E_e=p_e,b_e=h_e});var F9,OCt,L9,NCt,dT,lT,C_e,w_e,I_e,AU=h(()=>{mt();oe();oe();ir();ht();Me();ct();M9();F9=Symbol.for("effect/SortedSet"),OCt={[F9]:{_A:e=>e},[he](){return C(ae(this.keyTree),we(ae(F9)),We(this))},[me](e){return NCt(e)&&ce(this.keyTree,e.keyTree)},[Symbol.iterator](){return E_e(this.keyTree)},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"SortedSet",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},L9=e=>{let t=Object.create(OCt);return t.keyTree=e,t},NCt=e=>se(e,F9),dT=e=>L9(A_e(e)),lT=x(2,(e,t)=>y_e(e.keyTree,t)?e:L9(x_e(e.keyTree,t,!0))),C_e=x(2,(e,t)=>{let r=P9(e.keyTree),n=dT(r);for(let o of e)t(o)&&(n=lT(n,o));return n}),w_e=x(2,(e,t)=>L9(b_e(e.keyTree,t))),I_e=x(2,(e,t)=>{let r=P9(e.keyTree),n=dT(r);for(let o of e)n=lT(o)(n);for(let o of t)n=lT(o)(n);return n})});var PCt,WA,mb,$A,HA,W9,$9,H9,k_e,v_e,j9,R_e,jA,OI=h(()=>{oe();yn();Kl();ct();AU();vt();PCt="effect/Supervisor",WA=Symbol.for(PCt),mb={_T:e=>e},$A=class e{underlying;value0;[WA]=mb;constructor(t,r){this.underlying=t,this.value0=r}get value(){return this.value0}onStart(t,r,n,o){this.underlying.onStart(t,r,n,o)}onEnd(t,r){this.underlying.onEnd(t,r)}onEffect(t,r){this.underlying.onEffect(t,r)}onSuspend(t){this.underlying.onSuspend(t)}onResume(t){this.underlying.onResume(t)}map(t){return new e(this,C(this.value,te(t)))}zip(t){return new HA(this,t)}},HA=class e{left;right;_tag="Zip";[WA]=mb;constructor(t,r){this.left=t,this.right=r}get value(){return Nm(this.left.value,this.right.value)}onStart(t,r,n,o){this.left.onStart(t,r,n,o),this.right.onStart(t,r,n,o)}onEnd(t,r){this.left.onEnd(t,r),this.right.onEnd(t,r)}onEffect(t,r){this.left.onEffect(t,r),this.right.onEffect(t,r)}onSuspend(t){this.left.onSuspend(t),this.right.onSuspend(t)}onResume(t){this.left.onResume(t),this.right.onResume(t)}map(t){return new $A(this,C(this.value,te(t)))}zip(t){return new e(this,t)}},W9=e=>se(e,WA)&&mf(e,"Zip"),$9=class{[WA]=mb;fibers=new Set;get value(){return V(()=>Array.from(this.fibers))}onStart(t,r,n,o){this.fibers.add(o)}onEnd(t,r){this.fibers.delete(r)}onEffect(t,r){}onSuspend(t){}onResume(t){}map(t){return new $A(this,C(this.value,te(t)))}zip(t){return new HA(this,t)}onRun(t,r){return t()}},H9=class{effect;[WA]=mb;constructor(t){this.effect=t}get value(){return this.effect}onStart(t,r,n,o){}onEnd(t,r){}onEffect(t,r){}onSuspend(t){}onResume(t){}map(t){return new $A(this,C(this.value,te(t)))}zip(t){return new HA(this,t)}onRun(t,r){return t()}},k_e=class{ref;[WA]=mb;constructor(t){this.ref=t}get value(){return V(()=>Qr(this.ref))}onStart(t,r,n,o){C(this.ref,js(C(Qr(this.ref),lT(o))))}onEnd(t,r){C(this.ref,js(C(Qr(this.ref),w_e(r))))}onEffect(t,r){}onSuspend(t){}onResume(t){}map(t){return new $A(this,C(this.value,te(t)))}zip(t){return new HA(this,t)}onRun(t,r){return t()}},v_e=()=>new $9,j9=V(v_e),R_e=e=>new H9(e),jA=Te("effect/Supervisor/none",()=>R_e(Ue))});var __e,q9=h(()=>{pL();__e=uA});var T_e,D_e,Q_e,O_e,NI,yU,MCt,FCt,G9,xU,LCt,N_e,P_e=h(()=>{vr();q9();mt();oe();dc();OI();T_e="Empty",D_e="AddSupervisor",Q_e="RemoveSupervisor",O_e="AndThen",NI={_tag:T_e},yU=(e,t)=>({_tag:O_e,first:e,second:t}),MCt=(e,t)=>FCt(t,Dt(e)),FCt=(e,t)=>{let r=e,n=t;for(;kr(n);){let o=Gt(n);switch(o._tag){case T_e:{n=Ur(n);break}case D_e:{r=r.zip(o.supervisor),n=Ur(n);break}case Q_e:{r=G9(r,o.supervisor),n=Ur(n);break}case O_e:{n=fr(o.first)(fr(o.second)(Ur(n)));break}}}return r},G9=(e,t)=>ce(e,t)?jA:W9(e)?G9(e.left,t).zip(G9(e.right,t)):e,xU=e=>ce(e,jA)?ql():W9(e)?C(xU(e.left),Ef(xU(e.right))):eA(e),LCt=(e,t)=>{if(ce(e,t))return NI;let r=xU(e),n=xU(t),o=C(n,M6(r),tA(NI,(s,a)=>yU(s,{_tag:D_e,supervisor:a}))),i=C(r,M6(n),tA(NI,(s,a)=>yU(s,{_tag:Q_e,supervisor:a})));return yU(o,i)},N_e=__e({empty:NI,patch:MCt,combine:yU,diff:LCt})});var WCt,M_e,jCt,qCt,GCt,pT,zCt,F_e,VCt,EU,rh,nh,mT,YCt,JCt,KCt,hT,V9,ZCt,XCt,ewt,W_e,j_e,q_e,gb,G_e,ld,z_e,L_e,V_e,Y_e,J_e,twt,rwt,nwt,qA,K_e,Z_e,Y9,X_e,Ic,bU,Du,z9,Ou,PI,eBe,gT,owt,SU,iwt,J9,K9,tBe,rBe,nBe,CU,U_e,oBe,hb,Nu,AT,IU,wU,iBe,Z9,sBe,aBe,X9,cBe,e8,uBe,kU,lBe,dBe,vU,fBe,Hf,t8,Fa,r8,swt,awt,pBe,oh,Wf,mBe,cwt,Ss,ts,$_e,RU,_U,MI,hBe,gBe,ABe,n8,yBe,BU,o8,H_e,Js,uwt,Qu,TU,xBe,La=h(()=>{wr();TK();vr();sr();id();a1();Zl();mI();m1();BB();oe();yn();kf();dc();ht();E1();dZ();Kl();it();Me();ct();NA();xL();PA();mu();j3();Jl();JE();gZ();$0e();IK();$f();vt();Mf();e1();kB();tT();VZ();l1();JB();sRe();n_e();uRe();L1();Iw();CB();hU();lA();lA();OI();P_e();_A();jJ();WCt=uT("effect_fiber_started",{incremental:!0}),M_e=uT("effect_fiber_active"),jCt=uT("effect_fiber_successes",{incremental:!0}),qCt=uT("effect_fiber_failures",{incremental:!0}),GCt=r_e(t_e("effect_fiber_lifetimes",cRe({start:.5,factor:2,count:35})),"time_unit","milliseconds"),pT="Continue",zCt="Done",F_e="Yield",VCt={_E:e=>e,_A:e=>e},EU=e=>{throw new Error(`BUG: FiberRuntime - ${ym(e)} - please report an issue at https://github.com/Effect-TS/effect/issues`)},rh=Symbol.for("effect/internal/fiberRuntime/YieldedOp"),nh=Te("effect/internal/fiberRuntime/yieldedOpChannel",()=>({currentOp:null})),mT={[bw]:(e,t,r)=>qn(()=>t.effect_instruction_i1(r)),OnStep:(e,t,r)=>Vt(Vt(r)),[Sw]:(e,t,r)=>qn(()=>t.effect_instruction_i2(r)),[f_]:(e,t,r)=>(e.patchRuntimeFlags(e.currentRuntimeFlags,t.patch),ed(e.currentRuntimeFlags)&&e.isInterrupted()?$t(e.getInterruptedCause()):Vt(r)),[Cw]:(e,t,r)=>(qn(()=>t.effect_instruction_i2(r)),qn(()=>t.effect_instruction_i0())?(e.pushStack(t),qn(()=>t.effect_instruction_i1())):Ue),[yE]:(e,t,r)=>{for(;;){let n=qn(()=>t.effect_instruction_i0.next(r));if(n.done)return Vt(n.value);let o=u_(n.value);if(jE(o)){if(o._tag==="Failure")return o}else return e.pushStack(t),o;r=o.value}}},YCt={[X1]:(e,t,r,n)=>(e.processNewInterruptSignal(n.cause),ed(t)?$t(n.cause):r),[tU]:(e,t,r,n)=>{throw new Error("It is illegal to have multiple concurrent run loops in a single fiber")},[eU]:(e,t,r,n)=>(n.onFiber(e,zK(t)),r),[rU]:(e,t,r,n)=>O(ku(),()=>r)},JCt=e=>mc(QCe(e),t=>Du(NCe(t),([r,n])=>{let o=new Map,i=[];for(let a of n){i.push(Uo(a));for(let c of a)o.set(c.request,c)}let s=i.flat();return tn(uwt(r.runAll(i),s,()=>s.forEach(a=>{a.listeners.interrupted=!0})),P1,o)},!1,!1)),KCt=m_(),hT=class extends Ys{[Xm]=TI;[ZB]=VCt;_fiberRefs;_fiberId;_queue=new Array;_children=null;_observers=new Array;_running=!1;_stack=[];_asyncInterruptor=null;_asyncBlockingOn=null;_exitValue=null;_steps=[];_isYielding=!1;currentRuntimeFlags;currentOpCount=0;currentSupervisor;currentScheduler;currentTracer;currentSpan;currentContext;currentDefaultServices;constructor(t,r,n){if(super(),this.currentRuntimeFlags=n,this._fiberId=t,this._fiberRefs=r,Q3(n)){let o=this.getFiberRef(Nf);WCt.unsafeUpdate(1,o),M_e.unsafeUpdate(1,o)}this.refreshRefCache()}commit(){return ki(this)}id(){return this._fiberId}resume(t){this.tell(ub(t))}get status(){return this.ask((t,r)=>r)}get runtimeFlags(){return this.ask((t,r)=>hI(r)?t.currentRuntimeFlags:r.runtimeFlags)}scope(){return Mve(this)}get children(){return this.ask(t=>Array.from(t.getChildren()))}getChildren(){return this._children===null&&(this._children=new Set),this._children}getInterruptedCause(){return this.getFiberRef(bA)}fiberRefs(){return this.ask(t=>t.getFiberRefs())}ask(t){return ye(()=>{let r=wA(this._fiberId);return this.tell(BI((n,o)=>{IA(r,V(()=>t(n,o)))})),Cn(r)})}tell(t){this._queue.push(t),this._running||(this._running=!0,this.drainQueueLaterOnExecutor())}get await(){return Si(t=>{let r=n=>t(M(n));if(this._exitValue!==null){r(this._exitValue);return}return this.tell(BI((n,o)=>{n._exitValue!==null?r(this._exitValue):n.addObserver(r)})),V(()=>this.tell(BI((n,o)=>{n.removeObserver(r)})))},this.id())}get inheritAll(){return st((t,r)=>{let n=t.id(),o=t.getFiberRefs(),i=r.runtimeFlags,s=this.getFiberRefs(),a=c1(o,n,s);t.setFiberRefs(a);let c=t.getFiberRef($_e),u=C(Cu(i,c),M3(Xl),M3(AL));return gA(u)})}get poll(){return V(()=>en(this._exitValue))}unsafePoll(){return this._exitValue}interruptAsFork(t){return V(()=>this.tell(nU(Hs(t))))}unsafeInterruptAsFork(t){this.tell(nU(Hs(t)))}addObserver(t){this._exitValue!==null?t(this._exitValue):this._observers.push(t)}removeObserver(t){this._observers=this._observers.filter(r=>r!==t)}getFiberRefs(){return this.setFiberRef($_e,this.currentRuntimeFlags),this._fiberRefs}unsafeDeleteFiberRef(t){this._fiberRefs=vB(this._fiberRefs,t)}getFiberRef(t){return this._fiberRefs.locals.has(t)?this._fiberRefs.locals.get(t)[0][1]:t.initial}setFiberRef(t,r){this._fiberRefs=pI(this._fiberRefs,{fiberId:this._fiberId,fiberRef:t,value:r}),this.refreshRefCache()}refreshRefCache(){this.currentDefaultServices=this.getFiberRef(mn),this.currentTracer=this.currentDefaultServices.unsafeMap.get(Pf.key),this.currentSupervisor=this.getFiberRef(RU),this.currentScheduler=this.getFiberRef(Gm),this.currentContext=this.getFiberRef(li),this.currentSpan=this.currentContext.unsafeMap.get(Ii.key)}setFiberRefs(t){this._fiberRefs=t,this.refreshRefCache()}addChild(t){this.getChildren().add(t)}removeChild(t){this.getChildren().delete(t)}transferChildren(t){let r=this._children;if(this._children=null,r!==null&&r.size>0)for(let n of r)n._exitValue===null&&t.add(this.currentRuntimeFlags,n)}drainQueueOnCurrentThread(){let t=!0;for(;t;){let r=pT,n=globalThis[eh];globalThis[eh]=this;try{for(;r===pT;)r=this._queue.length===0?zCt:this.evaluateMessageWhileSuspended(this._queue.splice(0,1)[0])}finally{this._running=!1,globalThis[eh]=n}this._queue.length>0&&!this._running?(this._running=!0,r===F_e?(this.drainQueueLaterOnExecutor(),t=!1):t=!0):t=!1}}drainQueueLaterOnExecutor(){this.currentScheduler.scheduleTask(this.run,this.getFiberRef(Qf),this)}drainQueueWhileRunning(t,r){let n=r;for(;this._queue.length>0;){let o=this._queue.splice(0,1)[0];n=YCt[o._tag](this,t,n,o)}return n}isInterrupted(){return!LF(this.getFiberRef(bA))}addInterruptedCause(t){let r=this.getFiberRef(bA);this.setFiberRef(bA,Vr(r,t))}processNewInterruptSignal(t){this.addInterruptedCause(t),this.sendInterruptSignalToAllChildren()}sendInterruptSignalToAllChildren(){if(this._children===null||this._children.size===0)return!1;let t=!1;for(let r of this._children)r.tell(nU(Hs(this.id()))),t=!0;return t}interruptAllChildren(){if(this.sendInterruptSignalToAllChildren()){let t=this._children.values();this._children=null;let r=!1;return yA({while:()=>!r,body:()=>{let o=t.next();return o.done?V(()=>{r=!0}):$r(o.value.await)},step:()=>{}})}return null}reportExitValue(t){if(Q3(this.currentRuntimeFlags)){let r=this.getFiberRef(Nf),n=this.id().startTimeMillis,o=Date.now();switch(GCt.unsafeUpdate(o-n,r),M_e.unsafeUpdate(-1,r),t._tag){case _r:{jCt.unsafeUpdate(1,r);break}case Rr:{qCt.unsafeUpdate(1,r);break}}}if(t._tag==="Failure"){let r=this.getFiberRef(tI);!OE(t.cause)&&r._tag==="Some"&&this.log("Fiber terminated with an unhandled error",t.cause,r)}}setExitValue(t){this._exitValue=t,this.reportExitValue(t);for(let r=this._observers.length-1;r>=0;r--)this._observers[r](t);this._observers=[]}getLoggers(){return this.getFiberRef(W_e)}log(t,r,n){let o=pt(n)?n.value:this.getFiberRef(PL),i=this.getFiberRef(V9);if(eZ(i,o))return;let s=this.getFiberRef(fB),a=this.getFiberRef(Of),c=this.getLoggers(),u=this.getFiberRefs();if(Gl(c)>0){let l=Dr(this.getFiberRef(mn),bs),d=new Date(l.unsafeCurrentTimeMillis());SEe(u,()=>{for(let f of c)f.log({fiberId:this.id(),logLevel:o,message:t,cause:r,context:u,spans:s,annotations:a,date:d})})}}evaluateMessageWhileSuspended(t){switch(t._tag){case rU:return F_e;case X1:return this.processNewInterruptSignal(t.cause),this._asyncInterruptor!==null&&(this._asyncInterruptor($t(t.cause)),this._asyncInterruptor=null),pT;case tU:return this._asyncInterruptor=null,this._asyncBlockingOn=null,this.evaluateEffect(t.effect),pT;case eU:return t.onFiber(this,this._exitValue!==null?h0e:g0e(this.currentRuntimeFlags,this._asyncBlockingOn)),pT;default:return EU(t)}}evaluateEffect(t){this.currentSupervisor.onResume(this);try{let r=ed(this.currentRuntimeFlags)&&this.isInterrupted()?$t(this.getInterruptedCause()):t;for(;r!==null;){let n=r,o=this.runLoop(n);if(o===rh){let i=nh.currentOp;nh.currentOp=null,i._op===ww?_Ce(this.currentRuntimeFlags)?(this.tell(Nve()),this.tell(ub(Pn)),r=null):r=Pn:i._op===gE&&(r=null)}else{this.currentRuntimeFlags=C(this.currentRuntimeFlags,T3(AL));let i=this.interruptAllChildren();i!==null?r=O(i,()=>o):(this._queue.length===0?this.setExitValue(o):this.tell(ub(o)),r=null)}}}finally{this.currentSupervisor.onSuspend(this)}}start(t){if(this._running)this.tell(ub(t));else{this._running=!0;let r=globalThis[eh];globalThis[eh]=this;try{this.evaluateEffect(t)}finally{this._running=!1,globalThis[eh]=r,this._queue.length>0&&this.drainQueueLaterOnExecutor()}}}startFork(t){this.tell(ub(t))}patchRuntimeFlags(t,r){let n=Tm(t,r);return globalThis[eh]=this,this.currentRuntimeFlags=n,n}initiateAsync(t,r){let n=!1,o=i=>{n||(n=!0,this.tell(ub(i)))};ed(t)&&(this._asyncInterruptor=o);try{r(o)}catch(i){o(kt(eo(i)))}}pushStack(t){this._stack.push(t),t._op==="OnStep"&&this._steps.push({refs:this.getFiberRefs(),flags:this.currentRuntimeFlags})}popStack(){let t=this._stack.pop();if(t)return t._op==="OnStep"&&this._steps.pop(),t}getNextSuccessCont(){let t=this.popStack();for(;t;){if(t._op!==Ew)return t;t=this.popStack()}}getNextFailCont(){let t=this.popStack();for(;t;){if(t._op!==bw&&t._op!==Cw&&t._op!==yE)return t;t=this.popStack()}}[CEe](t){return V(()=>_a(this.currentContext,t))}Left(t){return ut(t.left)}None(t){return ut(new Es)}Right(t){return Vt(t.right)}Some(t){return Vt(t.value)}Micro(t){return Kw(r=>{let n=r,o=R0e(k0e(t,this.currentContext));return o.addObserver(i=>{if(i._tag==="Success")return n(Vt(i.value));switch(i.cause._tag){case"Interrupt":return n($t(Hs(ci)));case"Fail":return n(ut(i.cause.error));case"Die":return n(Ci(i.cause.defect))}}),Kw(i=>{n=s=>{i(Ue)},o.unsafeInterrupt()})})}[nF](t){let r=qn(()=>t.effect_instruction_i0()),n=this.getNextSuccessCont();return n!==void 0?(n._op in mT||EU(n),mT[n._op](this,n,r)):(nh.currentOp=Vt(r),rh)}[_r](t){let r=t,n=this.getNextSuccessCont();return n!==void 0?(n._op in mT||EU(n),mT[n._op](this,n,r.effect_instruction_i0)):(nh.currentOp=r,rh)}[Rr](t){let r=t.effect_instruction_i0,n=this.getNextFailCont();if(n!==void 0)switch(n._op){case Ew:case Sw:return ed(this.currentRuntimeFlags)&&this.isInterrupted()?$t($F(r)):qn(()=>n.effect_instruction_i1(r));case"OnStep":return ed(this.currentRuntimeFlags)&&this.isInterrupted()?$t($F(r)):Vt($t(r));case f_:return this.patchRuntimeFlags(this.currentRuntimeFlags,n.patch),ed(this.currentRuntimeFlags)&&this.isInterrupted()?$t(Vr(r,this.getInterruptedCause())):$t(r);default:EU(n)}else return nh.currentOp=$t(r),rh}[oF](t){return qn(()=>t.effect_instruction_i0(this,zK(this.currentRuntimeFlags)))}Blocked(t){let r=this.getFiberRefs(),n=this.currentRuntimeFlags;if(this._steps.length>0){let o=[],i=this._steps[this._steps.length-1],s=this.popStack();for(;s&&s._op!=="OnStep";)o.push(s),s=this.popStack();this.setFiberRefs(i.refs),this.currentRuntimeFlags=i.flags;let a=XE(i.refs,r),c=Cu(i.flags,n);return Vt(Qm(t.effect_instruction_i0,st(u=>{for(;o.length>0;)u.pushStack(o.pop());return u.setFiberRefs(eb(u.id(),u.getFiberRefs())(a)),u.currentRuntimeFlags=Tm(c)(u.currentRuntimeFlags),t.effect_instruction_i1})))}return xn(o=>O(PI(RL(t.effect_instruction_i0)),()=>o(t.effect_instruction_i1)))}RunBlocked(t){return JCt(t.effect_instruction_i0)}[xm](t){let r=t.effect_instruction_i0,n=this.currentRuntimeFlags,o=Tm(n,r);if(ed(o)&&this.isInterrupted())return $t(this.getInterruptedCause());if(this.patchRuntimeFlags(this.currentRuntimeFlags,r),t.effect_instruction_i1){let i=Cu(o,n);return this.pushStack(new CL(i,t)),qn(()=>t.effect_instruction_i1(n))}else return Pn}[bw](t){return this.pushStack(t),t.effect_instruction_i0}OnStep(t){return this.pushStack(t),t.effect_instruction_i0}[Ew](t){return this.pushStack(t),t.effect_instruction_i0}[Sw](t){return this.pushStack(t),t.effect_instruction_i0}[gE](t){return this._asyncBlockingOn=t.effect_instruction_i1,this.initiateAsync(this.currentRuntimeFlags,t.effect_instruction_i0),nh.currentOp=t,rh}[ww](t){return this._isYielding=!1,nh.currentOp=t,rh}[Cw](t){let r=t.effect_instruction_i0,n=t.effect_instruction_i1;return r()?(this.pushStack(t),n()):Pn}[yE](t){return mT[yE](this,t,void 0)}[AE](t){return qn(()=>t.commit())}runLoop(t){let r=t;for(this.currentOpCount=0;;){if(this.currentRuntimeFlags&RCe&&this.currentSupervisor.onEffect(this,r),this._queue.length>0&&(r=this.drainQueueWhileRunning(this.currentRuntimeFlags,r)),!this._isYielding){this.currentOpCount+=1;let n=this.currentScheduler.shouldYield(this);if(n!==!1){this._isYielding=!0,this.currentOpCount=0;let o=r;r=O(ku({priority:n}),()=>o)}}try{if(r=this.currentTracer.context(()=>{if(KCt!==r[Om]._V){let n=this.getFiberRef(mB);if(n._tag==="Some"){let o=r[Om]._V;this.log(`Executing an Effect versioned ${o} with a Runtime of version ${m_()}, you may want to dedupe the effect dependencies, you can use the language service plugin to detect this at compile time: https://github.com/Effect-TS/language-service`,Yi,n)}}return this[r._op](r)},this),r===rh){let n=nh.currentOp;return n._op===ww||n._op===gE?rh:(nh.currentOp=null,n._op===_r||n._op===Rr?n:$t(eo(n)))}}catch(n){r!==rh&&!se(r,"_op")||!(r._op in this)?r=fA(`Not a valid effect: ${ym(r)}`):sK(n)?r=$t(Vr(eo(n),Hs(ci))):r=Ci(n)}}}run=()=>{this.drainQueueOnCurrentThread()}},V9=Te("effect/FiberRef/currentMinimumLogLevel",()=>pn(tZ("Info"))),ZCt=e=>fU(t=>{let r=d1(t.context,mn);Dr(r,$m).unsafe.log(e.log(t))}),XCt=Te(Symbol.for("effect/Logger/defaultLogger"),()=>ZCt(oRe)),ewt=Te(Symbol.for("effect/Logger/tracerLogger"),()=>fU(({annotations:e,cause:t,context:r,fiberId:n,logLevel:o,message:i})=>{let s=zB(Ji(jm(r,li),Ii));if(s._tag==="None"||s.value._tag==="ExternalSpan")return;let a=_a(jm(r,mn),bs),c={};for(let[u,l]of e)c[u]=l;c["effect.fiberId"]=JSe(n),c["effect.logLevel"]=o.label,t!==null&&t._tag!=="Empty"&&(c["effect.cause"]=Yl(t,{renderErrorCause:!0})),s.value.event(ym(Array.isArray(i)&&i.length===1?i[0]:i),a.unsafeCurrentTimeNanos(),c)})),W_e=Te(Symbol.for("effect/FiberRef/currentLoggers"),()=>oK(eA(XCt,ewt))),j_e=function(){if(typeof arguments[0]=="string")return ts(Of,ko(arguments[0],arguments[1]));let e=Object.entries(arguments[0]);return ts(Of,XSe(t=>{for(let r=0;r<e.length;r++){let[n,o]=e[r];ko(t,n,o)}return t}))},q_e=x(2,(e,t)=>{let r=typeof t=="string"?tZ(t):t;return st(n=>{let o=n.getFiberRef(V9);return eZ(o,r)?M(W()):te(e,H)})}),gb=x(e=>ar(e[0]),(e,t)=>Iu(jo(e,r=>ld(n=>t(r,n))))),G_e=x(e=>ar(e[0]),(e,t)=>Js(e,ld(r=>t(r)))),ld=e=>st(t=>{let r=t.getFiberRefs(),n=B3(t.currentRuntimeFlags,Xl);return O(r8,o=>SA(o,i=>st(s=>{let a=s.getFiberRefs(),c=s.currentRuntimeFlags,u=XE(a,r),l=Cu(c,n),d=XE(r,a);return s.setFiberRefs(eb(u,s.id(),r)),Js(NL(e(i),l),V(()=>{s.setFiberRefs(eb(d,s.id(),s.getFiberRefs()))}))})))}),z_e=e=>tn(nB,H(ad))(e),L_e=Symbol.for("effect/Effect/existsPar/found"),V_e=x(e=>fu(e[0])&&!ar(e[0]),(e,t,r)=>PB(r?.concurrency,()=>ye(()=>Y_e(e[Symbol.iterator](),0,t)),()=>Ho(Ic(e,(n,o)=>DL(t(n,o),{onTrue:()=>ut(L_e),onFalse:()=>Ue}),r),{onFailure:n=>n===L_e?M(!0):ut(n),onSuccess:()=>M(!1)}))),Y_e=(e,t,r)=>{let n=e.next();return n.done?M(!1):O(r(n.value,t),o=>o?M(o):Y_e(e,t+1,r))},J_e=x(e=>fu(e[0])&&!ar(e[0]),(e,t,r)=>{let n=r?.negate?(o,i)=>te(t(o,i),LIe):t;return PB(r?.concurrency,()=>ye(()=>_e(e).reduceRight((o,i,s)=>Zi(o,ye(()=>n(i,s)),(a,c)=>c?[i,...a]:a),V(()=>new Array))),()=>te(Ic(e,(o,i)=>te(n(o,i),s=>s?H(o):W()),r),ube))}),twt=e=>{if(Array.isArray(e)||fu(e))return[e,W()];let t=Object.keys(e),r=t.length;return[t.map(n=>e[n]),H(n=>{let o={};for(let i=0;i<r;i++)o[t[i]]=n[i];return o})]},rwt=(e,t,r)=>{let n=[];for(let o of e)n.push(wu(o));return O(Ic(n,be,{concurrency:r?.concurrency,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),o=>{let i=W(),s=o.length,a=new Array(s),c=new Array(s),u=!1;for(let l=0;l<s;l++){let d=o[l];d._tag==="Left"?(a[l]=H(d.left),u=!0):(c[l]=d.right,a[l]=i)}return u?t._tag==="Some"?ut(t.value(a)):ut(a):r?.discard?Ue:t._tag==="Some"?M(t.value(c)):M(c)})},nwt=(e,t,r)=>{let n=[];for(let o of e)n.push(wu(o));return r?.discard?Ic(n,be,{concurrency:r?.concurrency,batching:r?.batching,discard:!0,concurrentFinalizers:r?.concurrentFinalizers}):te(Ic(n,be,{concurrency:r?.concurrency,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),o=>t._tag==="Some"?t.value(o):o)},qA=(e,t)=>{let[r,n]=twt(e);return t?.mode==="validate"?rwt(r,n,t):t?.mode==="either"?nwt(r,n,t):t?.discard!==!0&&n._tag==="Some"?te(Ic(r,be,t),n.value):Ic(r,be,t)},K_e=e=>t=>qA(t,e),Z_e=(e,t)=>te(qA(_e(e).map(fn),t),Yg(r=>yB(r)?H(r.effect_instruction_i0):W())),Y9=x(2,(e,t)=>Array.from({length:t},()=>e)),X_e=x(e=>ar(e[0]),(e,t,r)=>qA(Y9(e,t),r)),Ic=x(e=>fu(e[0]),(e,t,r)=>st(n=>{let o=r?.batching===!0||r?.batching==="inherit"&&n.getFiberRef(eI);return r?.discard?AZ(r.concurrency,()=>hb(fI,r?.concurrentFinalizers)(i=>o?Du(e,(s,a)=>i(t(s,a)),!0,!1,1):mc(e,(s,a)=>i(t(s,a)))),()=>hb(i1,r?.concurrentFinalizers)(i=>Du(e,(s,a)=>i(t(s,a)),o,!1)),i=>hb(s1(i),r?.concurrentFinalizers)(s=>Du(e,(a,c)=>s(t(a,c)),o,!1,i))):AZ(r?.concurrency,()=>hb(fI,r?.concurrentFinalizers)(i=>o?z9(e,1,(s,a)=>i(t(s,a)),!0):Wo(e,(s,a)=>i(t(s,a)))),()=>hb(i1,r?.concurrentFinalizers)(i=>bU(e,(s,a)=>i(t(s,a)),o)),i=>hb(s1(i),r?.concurrentFinalizers)(s=>z9(e,i,(a,c)=>s(t(a,c)),o)))})),bU=(e,t,r)=>ye(()=>{let n=_e(e),o=new Array(n.length);return je(Du(n,(s,a)=>O(t(s,a),c=>V(()=>o[a]=c)),r,!1),M(o))}),Du=(e,t,r,n,o)=>xn(i=>OL(s=>st(a=>{let c=Array.from(e).reverse(),u=c.length;if(u===0)return Ue;let l=0,d=!1,f=o?Math.min(c.length,o):c.length,p=new Set,m=new Array,g=()=>p.forEach(R=>{R.currentScheduler.scheduleTask(()=>{R.unsafeInterruptAsFork(a.id())},0,R)}),A=new Array,E=new Array,y=new Array,b=()=>{let R=m.filter(({exit:B})=>B._tag==="Failure").sort((B,L)=>B.index<L.index?-1:B.index===L.index?0:1).map(({exit:B})=>B);return R.length===0&&R.push(Pn),R},w=(R,B=!1)=>{let L=Iu(s(R)),D=owt(L,a,a.currentRuntimeFlags,ad);return a.currentScheduler.scheduleTask(()=>{B&&D.unsafeInterruptAsFork(a.id()),D.resume(L)},0,D),D},I=()=>{n||(u-=c.length,c=[]),d=!0,g()},v=r?TL:fn,k=w(Si(R=>{let B=(D,ee)=>{D._op==="Blocked"?y.push(D):(m.push({index:ee,exit:D}),D._op==="Failure"&&!d&&I())},L=()=>{if(c.length>0){let D=c.pop(),ee=l++,F=()=>{let N=c.pop();return ee=l++,O(ku(),()=>O(v(i(t(N,ee))),_))},_=N=>c.length>0&&(B(N,ee),c.length>0)?F():M(N),P=O(v(i(t(D,ee))),_),$=w(P);A.push($),p.add($),d&&$.currentScheduler.scheduleTask(()=>{$.unsafeInterruptAsFork(a.id())},0,$),$.addObserver(N=>{let q;if(N._op==="Failure"?q=N:q=N.effect_instruction_i0,E.push($),p.delete($),B(q,ee),m.length===u)R(M(Nt(CA(b(),{parallel:!0}),()=>Pn)));else if(y.length+m.length===u){let re=b(),ie=y.map(ue=>ue.effect_instruction_i0).reduce($3);R(M(Qm(ie,Du([Nt(CA(re,{parallel:!0}),()=>Pn),...y.map(ue=>ue.effect_instruction_i1)],ue=>ue,r,!0,o))))}else L()})}};for(let D=0;D<f;D++)L()}));return $r(Gs(ys(i(ki(k))),GE({onFailure:R=>{I();let B=y.length+1,L=Math.min(typeof o=="number"?o:y.length,y.length),D=Array.from(y);return Si(ee=>{let F=[],_=0,P=0,$=(q,re)=>ie=>{F[q]=ie,_++,_===B&&ee(Vt($t(R))),D.length>0&&re&&N()},N=()=>{w(D.pop(),!0).addObserver($(P,!0)),P++};k.addObserver($(P,!1)),P++;for(let q=0;q<L;q++)N()})},onSuccess:()=>Wo(E,R=>R.inheritAll)})))}))),z9=(e,t,r,n)=>ye(()=>{let o=_e(e),i=new Array(o.length);return je(Du(o,(a,c)=>te(r(a,c),u=>i[c]=u),n,!1,t),M(i))}),Ou=e=>st((t,r)=>M(gT(e,t,r.runtimeFlags))),PI=e=>iwt(e,ad),eBe=x(2,(e,t)=>Ou(QL(e,r=>{let n=Vl(r);switch(n._tag){case"Left":return t(n.left);case"Right":return kt(n.right)}}))),gT=(e,t,r,n=null)=>{let o=SU(e,t,r,n);return o.resume(e),o},owt=(e,t,r,n=null)=>SU(e,t,r,n),SU=(e,t,r,n=null)=>{let o=sL(),i=t.getFiberRefs(),s=MK(i,o),a=new hT(o,s,r),c=jm(s,li),u=a.currentSupervisor;return u.onStart(c,e,H(t),a),a.addObserver(d=>u.onEnd(d,a)),(n!==null?n:C(t.getFiberRef(nB),Nt(()=>t.scope()))).add(r,a),a},iwt=(e,t)=>st((r,n)=>M(gT(e,r,n.runtimeFlags,t))),J9=x(e=>gm(e[2]),(e,t,r,n)=>PB(n?.concurrency,()=>_e(e).reduce((o,i,s)=>Zi(o,i,(a,c)=>r(a,c,s)),M(t)),()=>O(bc(t),o=>O(Ic(e,(i,s)=>O(i,a=>OA(o,c=>r(c,a,s))),n),()=>Sc(o))))),K9=x(e=>fu(e[0]),(e,t,r)=>C(Ic(e,(n,o)=>wu(t(n,o)),r),te(n=>zCe(n,be)))),tBe=x(e=>fu(e[0]),(e,t,r)=>O(K9(e,t,{concurrency:r?.concurrency,batching:r?.batching,concurrentFinalizers:r?.concurrentFinalizers}),([n,o])=>Cm(n)?ut(n):r?.discard?Ue:M(o))),rBe=e=>st((t,r)=>Si(n=>{let o=new Set,i,s=Yi,a=()=>{for(let l of o)l.unsafeInterruptAsFork(t.id())},c=!1,u=!0;for(let l of e){u=!1;let d=gT(Qa(l),t,r.runtimeFlags);if(o.add(d),d.addObserver(f=>{o.delete(d),i||(f._tag==="Success"?(c=!0,i=d,s=Yi,a()):s=to(f.cause,s)),c&&o.size===0&&n(i?je(uU(i),i.unsafePoll()):kt(s))}),i)break}return u?n(Ta(()=>new vu("Received an empty collection of effects"))):(c=!0,eT(o,t.id()))})),nBe=x(e=>fu(e[0])&&!ar(e[0]),(e,t,r,n)=>PB(n?.concurrency,()=>_e(e).reduce((o,i,s)=>Zi(o,i,(a,c)=>r(a,c,s)),t),()=>ye(()=>C(J9([t,...e],W(),(o,i,s)=>{switch(o._tag){case"None":return H(i);case"Some":return H(r(o.value,i,s))}},n),te(o=>{switch(o._tag){case"None":throw new Error("BUG: Effect.reduceEffect - please report an issue at https://github.com/Effect-TS/effect/issues");case"Some":return o.value}}))))),CU=e=>xc(t=>wt(Ji(t,Fa),{onNone:()=>e,onSome:r=>{switch(r.strategy._tag){case"Parallel":return e;case"Sequential":case"ParallelN":return O(Ac(r,i1),n=>Wf(e,n))}}})),U_e=e=>t=>xc(r=>wt(Ji(r,Fa),{onNone:()=>t,onSome:n=>n.strategy._tag==="ParallelN"&&n.strategy.parallelism===e?t:O(Ac(n,s1(e)),o=>Wf(t,o))})),oBe=e=>t=>hb(e,!0)(t),hb=(e,t)=>r=>xc(n=>wt(Ji(n,Fa),{onNone:()=>r(be),onSome:o=>{if(t===!0){let i=e._tag==="Parallel"?CU:e._tag==="Sequential"?wU:U_e(e.parallelism);switch(o.strategy._tag){case"Parallel":return i(r(CU));case"Sequential":return i(r(wU));case"ParallelN":return i(r(U_e(o.strategy.parallelism)))}}else return r(be)}})),Nu=e=>O(Fa,e),AT=e=>O(oh(),t=>Gs(e(t),r=>t.close(r))),IU=e=>O(oh(),t=>mBe(e,t)),wU=e=>xc(t=>wt(Ji(t,Fa),{onNone:()=>e,onSome:r=>{switch(r.strategy._tag){case"Sequential":return e;case"Parallel":case"ParallelN":return O(Ac(r,fI),n=>Wf(e,n))}}})),iBe=(e,t)=>Z9([sb(e,t)]),Z9=e=>ts(Nf,t=>Ul(t,e)),sBe=x(2,(e,t)=>AT(r=>O(Wf(e,r),t))),aBe=x(e=>ar(e[1]),(e,t,r)=>X9(e,t,(n,o)=>[n,o],r)),X9=x(e=>ar(e[1]),(e,t,r,n)=>ys(Hf(fn(e),fn(t),(o,i)=>Ru(o,i,{onSuccess:r,onFailure:(s,a)=>n?.concurrent?to(s,a):Vr(s,a)}),n))),cBe=x(e=>fu(e[0]),(e,t,r)=>mA(Ic(e,(n,o)=>mA(t(n,o)),r))),e8=e=>ts(mn,zt(bs,e)),uBe=e=>ts(mn,zt(Hm,e)),kU=e=>ts(mn,zt(uI,e)),lBe=e=>Nu(t=>O(Ac(t,Tu),r=>C(e,Wf(r),te(n=>[Da(o=>rd(r,xB(o))),n])))),dBe=x(e=>ar(e[1]),(e,t,r)=>Hf(e,t,(n,o)=>[n,o],r)),vU=x(e=>ar(e[1]),(e,t,r)=>r?.concurrent!==!0&&(r?.batching===void 0||r.batching===!1)?$E(e,t):Hf(e,t,(n,o)=>n,r)),fBe=x(e=>ar(e[1]),(e,t,r)=>r?.concurrent!==!0&&(r?.batching===void 0||r.batching===!1)?je(e,t):Hf(e,t,(n,o)=>o,r)),Hf=x(e=>ar(e[1]),(e,t,r,n)=>te(qA([e,t],{concurrency:n?.concurrent?2:1,batching:n?.batching,concurrentFinalizers:n?.concurrentFinalizers}),([o,i])=>r(o,i))),t8=e=>e===TCe?Ue:C(Zw,O(t=>{let r=Tm(t,e),n=Cu(r,t);return C(gA(e),je(ld(()=>gA(n))),$r)}),Iu),Fa=Jt("effect/Scope"),r8=Fa,swt=(e,t)=>{e.state._tag==="Open"&&e.state.finalizers.set({},t)},awt={[ML]:ML,[FL]:FL,pipe(){return Z(this,arguments)},fork(e){return V(()=>{let t=pBe(e);if(this.state._tag==="Closed")return t.state=this.state,t;let r={},n=o=>t.close(o);return this.state.finalizers.set(r,n),swt(t,o=>V(()=>{this.state._tag==="Open"&&this.state.finalizers.delete(r)})),t})},close(e){return ye(()=>{if(this.state._tag==="Closed")return Ue;let t=Array.from(this.state.finalizers.values()).reverse();return this.state={_tag:"Closed",exit:e},t.length===0?Ue:DK(this.strategy)?C(Wo(t,r=>fn(r(e))),O(r=>C(CA(r),dr(oI),Nt(()=>Pn)))):QK(this.strategy)?C(bU(t,r=>fn(r(e)),!1),O(r=>C(CA(r,{parallel:!0}),dr(oI),Nt(()=>Pn)))):C(z9(t,this.strategy.parallelism,r=>fn(r(e)),!1),O(r=>C(CA(r,{parallel:!0}),dr(oI),Nt(()=>Pn))))})},addFinalizer(e){return ye(()=>this.state._tag==="Closed"?e(this.state.exit):(this.state.finalizers.set({},e),Ue))}},pBe=(e=Tu)=>{let t=Object.create(awt);return t.strategy=e,t.state={_tag:"Open",finalizers:new Map},t},oh=(e=Tu)=>V(()=>pBe(e)),Wf=x(2,(e,t)=>kA(e,wo(Ra(Fa,t)))),mBe=x(2,(e,t)=>C(e,Wf(t),Gs(r=>t.close(r)))),cwt=e=>EA(e,{differ:N_e,fork:NI}),Ss=x(2,(e,t)=>$r(gb(O(Xi(e),r=>Zt(Dm(e,t),r)),r=>Dm(e,r)))),ts=x(2,(e,t)=>ui(e,r=>Ss(e,t(r)))),$_e=swe(BCe),RU=cwt(jA),_U=e=>Ic(e,aU),MI=e=>({...n1,commit(){return ki(this)},[Xm]:TI,id:()=>_e(e).reduce((r,n)=>jw(r,n.id()),ci),await:fn(bU(e,r=>ys(r.await),!1)),children:te(bU(e,r=>r.children,!1),b_),inheritAll:mc(e,r=>r.inheritAll),poll:te(Wo(e,r=>r.poll),SF(H(Vt(new Array)),(r,n)=>{switch(n._tag){case"None":return W();case"Some":switch(r._tag){case"None":return W();case"Some":return H(Ru(n.value,r.value,{onSuccess:(o,i)=>[o,...i],onFailure:to}))}}})),interruptAsFork:r=>mc(e,n=>n.interruptAsFork(r))}),hBe=e=>$r(PI(gc(e))),gBe=e=>ki(MI(e)),ABe=e=>gb(M(e),gc),n8=x(3,(e,t,r)=>o8(e,t,{onSelfWin:(n,o)=>O(n.await,i=>{switch(i._tag){case _r:return O(n.inheritAll,()=>r.onSelfDone(i,o));case Rr:return r.onSelfDone(i,o)}}),onOtherWin:(n,o)=>O(n.await,i=>{switch(i._tag){case _r:return O(n.inheritAll,()=>r.onOtherDone(i,o));case Rr:return r.onOtherDone(i,o)}})})),yBe=e=>xn(t=>Da(r=>O(PI(t(e)),n=>C(t(ki(n)),hc(()=>C(n,lU(r))))))),BU=x(2,(e,t)=>Da(r=>n8(e,t,{onSelfDone:(n,o)=>zE(n,{onFailure:i=>C(ki(o),_I(s=>to(i,s))),onSuccess:i=>C(o,xs(r),Zt(i))}),onOtherDone:(n,o)=>zE(n,{onFailure:i=>C(ki(o),_I(s=>to(s,i))),onSuccess:i=>C(o,xs(r),Zt(i))})}))),o8=x(3,(e,t,r)=>st((n,o)=>{let i=o.runtimeFlags,s=Ba(!0),a=SU(e,n,i,r.selfScope),c=SU(t,n,i,r.otherScope);return Si(u=>{a.addObserver(()=>H_e(a,c,r.onSelfWin,s,u)),c.addObserver(()=>H_e(c,a,r.onOtherWin,s,u)),a.startFork(e),c.startFork(t)},jw(a.id(),c.id()))})),H_e=(e,t,r,n,o)=>{JF(!0,!1)(n)&&o(r(e,t))},Js=x(2,(e,t)=>xn(r=>dn(r(e),{onFailure:n=>dn(t,{onFailure:o=>kt(Vr(n,o)),onSuccess:()=>kt(n)}),onSuccess:n=>Zt(t,n)}))),uwt=(e,t,r)=>Da(n=>Js(O(PI(Qa(e)),o=>Si(i=>{let s=t.map(u=>u.listeners.count),a=()=>{s.every(u=>u===0)&&t.every(u=>u.result.state.current._tag==="Pending"?!0:!!(u.result.state.current._tag==="Done"&&jE(u.result.state.current.effect)&&u.result.state.current.effect._tag==="Failure"&&Fw(u.result.state.current.effect.cause)))&&(c.forEach(u=>u()),r?.(),i(gc(o)))};o.addObserver(u=>{c.forEach(l=>l()),i(u)});let c=t.map((u,l)=>{let d=f=>{s[l]=f,a()};return u.listeners.addObserver(d),()=>u.listeners.removeObserver(d)});return a(),V(()=>{c.forEach(u=>u())})})),ye(()=>{let o=t.flatMap(i=>i.state.completed?[]:[i]);return mc(o,i=>D9(i.request,xB(n)))}))),Qu=(e,t)=>(t=Ec(t),Iu(st(r=>{let n=_a(r.getFiberRef(li),Fa),o=Y1(r,e,t),i=r.getFiberRef(Pm),s=Dr(r.getFiberRef(mn),bs);return Zt(SA(n,a=>HZ(o,a,s,i)),o)}))),TU=e=>ts(mn,zt(Pf,e)),xBe=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ec(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return O(Qu(t,Ec(r)),o=>MA(n,Ii,o))}return n=>O(Qu(t,Ec(r)),o=>MA(n,Ii,o))}});var lwt,yT,i8,DU,EBe,bBe,SBe,CBe,wBe,IBe,kBe=h(()=>{Ws();oe();lwt="effect/ScheduleInterval",yT=Symbol.for(lwt),i8={[yT]:yT,startMillis:0,endMillis:0},DU=(e,t)=>e>t?i8:{[yT]:yT,startMillis:e,endMillis:t},EBe=x(2,(e,t)=>bBe(e,t)===e),bBe=x(2,(e,t)=>e.endMillis<=t.startMillis?e:t.endMillis<=e.startMillis?t:e.startMillis<t.startMillis?e:t.startMillis<e.startMillis?t:e.endMillis<=t.endMillis?e:t),SBe=e=>e.startMillis>=e.endMillis,CBe=x(2,(e,t)=>{let r=Math.max(e.startMillis,t.startMillis),n=Math.min(e.endMillis,t.endMillis);return DU(r,n)}),wBe=e=>Ki(e.endMillis-e.startMillis),IBe=e=>DU(e,Number.POSITIVE_INFINITY)});var Ks,s8,vBe,RBe,_Be,BBe,dd,QU=h(()=>{kBe();Ks=DU,s8=i8,vBe=EBe,RBe=SBe,_Be=CBe,BBe=wBe,dd=IBe});var fwt,c8,NU,DBe,TBe,QBe,pwt,OU,OBe,u8,NBe,PBe,MBe=h(()=>{vr();oe();it();QU();gw();fwt="effect/ScheduleIntervals",c8=Symbol.for(fwt),NU=e=>({[c8]:c8,intervals:e}),DBe=x(2,(e,t)=>kr(t.intervals)?kr(e.intervals)?Gt(e.intervals).startMillis<Gt(t.intervals).startMillis?TBe(Ur(e.intervals),t.intervals,Gt(e.intervals),Ut()):TBe(e.intervals,Ur(t.intervals),Gt(t.intervals),Ut()):t:e),TBe=(e,t,r,n)=>{let o=e,i=t,s=r,a=n;for(;kr(o)||kr(i);)if(!kr(o)&&kr(i))s.endMillis<Gt(i).startMillis?(a=C(a,fr(s)),s=Gt(i),i=Ur(i),o=Ut()):(s=Ks(s.startMillis,Gt(i).endMillis),i=Ur(i),o=Ut());else if(kr(o)&&xu(i))s.endMillis<Gt(o).startMillis?(a=C(a,fr(s)),s=Gt(o),i=Ut(),o=Ur(o)):(s=Ks(s.startMillis,Gt(o).endMillis),i=Ut(),o=Ur(o));else if(kr(o)&&kr(i))Gt(o).startMillis<Gt(i).startMillis?s.endMillis<Gt(o).startMillis?(a=C(a,fr(s)),s=Gt(o),o=Ur(o)):(s=Ks(s.startMillis,Gt(o).endMillis),o=Ur(o)):s.endMillis<Gt(i).startMillis?(a=C(a,fr(s)),s=Gt(i),i=Ur(i)):(s=Ks(s.startMillis,Gt(i).endMillis),i=Ur(i));else throw new Error(Fl("Intervals.unionLoop"));return NU(C(a,fr(s),gs))},QBe=x(2,(e,t)=>pwt(e.intervals,t.intervals,Ut())),pwt=(e,t,r)=>{let n=e,o=t,i=r;for(;kr(n)&&kr(o);){let s=C(Gt(n),_Be(Gt(o))),a=RBe(s)?i:C(i,fr(s));C(Gt(n),vBe(Gt(o)))?n=Ur(n):o=Ur(o),i=a}return NU(gs(i))},OU=e=>C(e.intervals,CE,Nt(()=>s8)).startMillis,OBe=e=>C(e.intervals,CE,Nt(()=>s8)).endMillis,u8=x(2,(e,t)=>OU(e)<OU(t)),NBe=e=>kr(e.intervals),PBe=x(2,(e,t)=>u8(e,t)?t:e)});var FBe,l8,LBe,GA,PU,UBe,$Be,HBe,xT=h(()=>{MBe();FBe=NU,l8=DBe,LBe=QBe,GA=OU,PU=OBe,UBe=u8,$Be=NBe,HBe=PBe});var d8,WBe,jBe,qBe,GBe,zBe,VBe,YBe=h(()=>{vr();xT();d8="Continue",WBe="Done",jBe=e=>({_tag:d8,intervals:e}),qBe=e=>({_tag:d8,intervals:FBe(Dt(e))}),GBe={_tag:WBe},zBe=e=>e._tag===d8,VBe=e=>e._tag===WBe});var Ab,qo,Mu,ih,fi,FU=h(()=>{YBe();Ab=jBe,qo=qBe,Mu=GBe,ih=zBe,fi=VBe});var FI,sh,JBe,ET,KBe,LU,ZBe,ah=h(()=>{vt();La();FI=Fa,sh=gB,JBe=SA,ET=rd,KBe=Wf,LU=Ac,ZBe=oh});var m8,LI,eTe,h8,A8,tTe,rTe,nTe,y8,XBe,gwt,Awt,oTe,$U,iTe,bT,HU,sTe,aTe,p8,UU,cTe,uTe,x8,lTe,E8,dTe,fTe,ST,ywt,xwt,Ewt,g8,WU,b8,bwt,pTe,mTe,hTe,CT,gTe,UI=h(()=>{Ws();id();mt();Ro();Zl();oe();ir();iT();it();Me();ct();bI();PA();Jl();$f();vt();tT();La();JB();SI();OI();m8=class{permits;waiters=new Set;taken=0;constructor(t){this.permits=t}get free(){return this.permits-this.taken}take=t=>_f(r=>{if(this.free<t){let n=()=>{this.free<t||(this.waiters.delete(n),r(ye(()=>this.free<t?this.take(t):(this.taken+=t,M(t)))))};return this.waiters.add(n),V(()=>{this.waiters.delete(n)})}r(ye(()=>this.free<t?this.take(t):(this.taken+=t,M(t))))});updateTakenUnsafe(t,r){return this.taken=r(this.taken),this.waiters.size>0&&t.getFiberRef(Gm).scheduleTask(()=>{let n=this.waiters.values(),o=n.next();for(;o.done===!1&&this.free>0;)o.value(),o=n.next()},t.getFiberRef(Qf),t),M(this.free)}updateTaken(t){return st(r=>this.updateTakenUnsafe(r,t))}resize=t=>$r(st(r=>(this.permits=t,this.free<0?Ue:this.updateTakenUnsafe(r,n=>n))));release=t=>this.updateTaken(r=>r-t);releaseAll=this.updateTaken(t=>0);withPermits=t=>r=>xn(n=>O(n(this.take(t)),o=>Js(n(r),this.release(o))));withPermitsIfAvailable=t=>r=>xn(n=>ye(()=>this.free<t?cb:(this.taken+=t,Js(n(kI(r)),this.release(t)))))},LI=e=>new m8(e),eTe=e=>V(()=>LI(e)),h8=class extends Ys{isOpen;waiters=[];scheduled=!1;constructor(t){super(),this.isOpen=t}commit(){return this.await}unsafeSchedule(t){return this.scheduled||this.waiters.length===0?Ue:(this.scheduled=!0,t.currentScheduler.scheduleTask(this.flushWaiters,t.getFiberRef(Qf),t),Ue)}flushWaiters=()=>{this.scheduled=!1;let t=this.waiters;this.waiters=[];for(let r=0;r<t.length;r++)t[r](Pn)};open=st(t=>this.isOpen?Ue:(this.isOpen=!0,this.unsafeSchedule(t)));unsafeOpen(){this.isOpen||(this.isOpen=!0,this.flushWaiters())}release=st(t=>this.isOpen?Ue:this.unsafeSchedule(t));await=_f(t=>this.isOpen?t(Ue):(this.waiters.push(t),V(()=>{let r=this.waiters.indexOf(t);r!==-1&&this.waiters.splice(r,1)})));unsafeClose(){this.isOpen=!1}close=V(()=>{this.isOpen=!1});whenOpen=t=>je(this.await,t)},A8=e=>new h8(e??!1),tTe=e=>V(()=>A8(e)),rTe=e=>$U(e,_U),nTe=x(2,(e,t)=>te(y8(e,t),r=>r[0])),y8=x(2,(e,t)=>{let r=At(t);return O(Oa(),n=>te(WU(W()),o=>[zs(gwt(e,r,o),n),Awt(o)]))}),XBe=(e,t,r)=>{let n=Io(At(t));return C(wi(),jo(o=>Df(e,o)),te(o=>H([r+n,o])))},gwt=(e,t,r)=>xn(n=>C(Uf(o=>o.currentTimeMillis),O(o=>bwt(r,i=>{switch(i._tag){case"None":return H(XBe(e,t,o));case"Some":{let[s]=i.value;return s-o<=0?H(XBe(e,t,o)):W()}}})),O(o=>Ct(o)?fA("BUG: Effect.cachedInvalidate - please report an issue at https://github.com/Effect-TS/effect/issues"):n(Cn(o.value[1]))))),Awt=e=>Pa(e,W()),oTe=x(2,(e,t)=>$U(e,r=>t(MI(r)))),$U=x(2,(e,t)=>O(j9,r=>C(x8(e,r),Js(O(r.value,t))))),iTe=x(e=>fu(e[0]),(e,t)=>t?.discard?mc(e,Ou):te(Wo(e,Ou),MI)),bT=x(2,(e,t)=>st((r,n)=>{let o=t,i=gT(e,r,n.runtimeFlags,ad);if(o.state._tag==="Open"){let s=()=>Da(c=>ce(c,i.id())?Ue:$r(gc(i))),a={};o.state.finalizers.set(a,s),i.addObserver(()=>{o.state._tag!=="Closed"&&o.state.finalizers.delete(a)})}else i.unsafeInterruptAsFork(r.id());return M(i)})),HU=e=>Nu(t=>bT(e,t)),sTe=e=>ki(e),aTe=e=>ye(()=>O(e,ki)),p8=Symbol.for("effect/Effect/memoizeFunction.key"),UU=class{a;eq;[p8]=p8;constructor(t,r){this.a=t,this.eq=r}[me](t){return se(t,p8)?this.eq?this.eq(this.a,t.a):ce(this.a,t.a):!1}[he](){return this.eq?0:We(this,ae(this.a))}},cTe=(e,t)=>C(V(()=>fb()),O(WU),te(r=>n=>C(r.modifyEffect(o=>{let i=C(o,_o(new UU(n,t)));return Ct(i)?C(wi(),jo(s=>C(RI(e(n)),Df(s),Ou)),te(s=>[s,C(o,Ma(new UU(n,t),s))])):M([i.value,o])}),O(Cn),O(([o,i])=>C(ab(o),Zt(i)))))),uTe=x(2,(e,t)=>C(fn(e),BU(fn(t)),r=>ys(r))),x8=x(2,(e,t)=>no(RU,n=>n.zip(t))(e)),lTe=x(2,(e,t)=>E8(e,{onTimeout:()=>hwe(t),duration:t})),E8=x(2,(e,{duration:t,onTimeout:r})=>ys(ST(e,{onTimeout:()=>pc(r),onSuccess:M,duration:t}))),dTe=x(2,(e,{duration:t,onTimeout:r})=>ys(ST(e,{onTimeout:()=>Tf(r),onSuccess:M,duration:t}))),fTe=x(2,(e,t)=>ST(e,{duration:t,onSuccess:H,onTimeout:W})),ST=x(2,(e,{duration:t,onSuccess:r,onTimeout:n})=>Da(o=>xn(i=>o8(i(e),Qa(Jm(t)),{onSelfWin:(s,a)=>O(s.await,c=>c._tag==="Success"?O(s.inheritAll,()=>Zt(xs(a,o),r(c.value))):O(xs(a,o),()=>$t(c.cause))),onOtherWin:(s,a)=>O(s.await,c=>c._tag==="Success"?O(s.inheritAll,()=>Zt(xs(a,o),n())):O(xs(a,o),()=>$t(c.cause))),otherScope:ad})))),ywt="effect/Ref/SynchronizedRef",xwt=Symbol.for(ywt),Ewt={_A:e=>e},g8=class extends Ys{ref;withLock;[xwt]=Ewt;[QB]=pZ;[Na]=Na;constructor(t,r){super(),this.ref=t,this.withLock=r,this.get=io(this.ref)}get;commit(){return this.get}modify(t){return this.modifyEffect(r=>M(t(r)))}modifyEffect(t){return this.withLock(C(O(io(this.ref),t),O(([r,n])=>Zt(Pa(this.ref,n),r))))}},WU=e=>V(()=>b8(e)),b8=e=>{let t=QA(e),r=LI(1);return new g8(t,r.withPermits(1))},bwt=x(2,(e,t)=>e.modifyEffect(r=>{let n=t(r);switch(n._tag){case"None":return M([r,r]);case"Some":return te(n.value,o=>[o,o])}})),pTe=x(2,(e,t)=>CT(e,t,(r,n)=>[r,n])),mTe=x(2,(e,t)=>CT(e,t,(r,n)=>r)),hTe=x(2,(e,t)=>CT(e,t,(r,n)=>n)),CT=x(3,(e,t,r)=>({...n1,commit(){return ki(this)},[Xm]:TI,id:()=>C(e.id(),iL(t.id())),await:C(e.await,ys,Hf(ys(t.await),r,{concurrent:!0}),fn),children:e.children,inheritAll:je(t.inheritAll,e.inheritAll),poll:Zi(e.poll,t.poll,(n,o)=>C(n,Gn(i=>C(o,dr(s=>zZ(i,s,{onSuccess:r,onFailure:to})))))),interruptAsFork:n=>je(e.interruptAsFork(n),t.interruptAsFork(n)),pipe(){return Z(this,arguments)}})),gTe=x(e=>ar(e[0]),(e,t,r)=>O(e,n=>qA(t(n),r).pipe(te(o=>Object.assign({},n,o)))))});var ATe,yTe=h(()=>{ATe=Symbol.for("effect/ManagedRuntime")});var xTe,ETe,S8,bTe,STe,CTe,wTe,C8,ITe,kTe,vTe=h(()=>{xTe="ExtendScope",ETe="Fold",S8="Fresh",bTe="FromEffect",STe="Scoped",CTe="Suspend",wTe="Provide",C8="ProvideMerge",ITe="MergeAll",kTe="ZipWith"});var VA={};tr(VA,{FiberTypeId:()=>wwt,Order:()=>kwt,RuntimeFiberTypeId:()=>Iwt,all:()=>Dwt,await:()=>$I,awaitAll:()=>Bwt,children:()=>Twt,done:()=>Qwt,dump:()=>Owt,dumpAll:()=>Nwt,fail:()=>Pwt,failCause:()=>Mwt,fromEffect:()=>Fwt,getCurrentFiber:()=>Lwt,id:()=>_wt,inheritAll:()=>qU,interrupt:()=>jf,interruptAll:()=>Hwt,interruptAllAs:()=>w8,interruptAs:()=>HI,interruptAsFork:()=>$wt,interruptFork:()=>Wwt,interrupted:()=>Uwt,isFiber:()=>vwt,isRuntimeFiber:()=>Rwt,join:()=>GU,joinAll:()=>jwt,map:()=>qwt,mapEffect:()=>Gwt,mapFiber:()=>zwt,match:()=>Vwt,never:()=>Ywt,orElse:()=>Jwt,orElseEither:()=>Kwt,poll:()=>Zwt,pretty:()=>Xwt,roots:()=>eIt,scoped:()=>rIt,status:()=>nIt,succeed:()=>oIt,unsafeRoots:()=>tIt,void:()=>iIt,zip:()=>sIt,zipLeft:()=>aIt,zipRight:()=>cIt,zipWith:()=>uIt});var wwt,Iwt,kwt,vwt,Rwt,_wt,$I,Bwt,Twt,Dwt,Qwt,Owt,Nwt,Pwt,Mwt,Fwt,Lwt,qU,jf,Uwt,HI,$wt,Hwt,w8,Wwt,GU,jwt,qwt,Gwt,zwt,Vwt,Ywt,Jwt,Kwt,Zwt,Xwt,eIt,tIt,rIt,nIt,oIt,iIt,sIt,aIt,cIt,uIt,WI=h(()=>{vt();UI();tT();La();wwt=Xm,Iwt=ZB,kwt=XB,vwt=Fve,Rwt=KB,_wt=Wve,$I=aU,Bwt=_U,Twt=Lve,Dwt=MI,Qwt=lb,Owt=cU,Nwt=Uve,Pwt=$ve,Mwt=ZZ,Fwt=Hve,Lwt=tRe,qU=uU,jf=gc,Uwt=jve,HI=xs,$wt=lU,Hwt=qve,w8=eT,Wwt=hBe,GU=ki,jwt=gBe,qwt=iU,Gwt=XZ,zwt=Gve,Vwt=zve,Ywt=Vve,Jwt=e9,Kwt=Yve,Zwt=Jve,Xwt=Kve,eIt=Zve,tIt=t9,rIt=ABe,nIt=Xve,oIt=r9,iIt=eRe,sIt=pTe,aIt=mTe,cIt=hTe,uIt=CT});var jI,qI,VU,RTe,k8,lIt,I8,wT,v8,R8,_Te,_8,BTe,YU,zU,B8,GI,TTe,qf,DTe,QTe,OTe,NTe,PTe,MTe,FTe,LTe,JU=h(()=>{sr();mt();Ro();WI();Zl();mI();oe();ht();it();Me();PA();ah();Jl();vt();kB();La();JB();Iw();lA();OI();jI=e=>function(){if(arguments.length===1){let t=arguments[0];return(r,...n)=>e(t,r,...n)}return e.apply(this,arguments)},qI=jI((e,t,r)=>{let n=sL(),o=[[li,[[n,e.context]]]];r?.scheduler&&o.push([Gm,[[n,r.scheduler]]]);let i=XIe(e.fiberRefs,{entries:o,forkAs:n});r?.updateRefs&&(i=r.updateRefs(i,n));let s=new hT(n,i,e.runtimeFlags),a=t;r?.scope&&(a=O(LU(r.scope,Tu),u=>je(gB(u,Da(l=>ce(l,s.id())?Ue:xs(s,l))),Gs(t,l=>ET(u,l)))));let c=s.currentSupervisor;return c!==jA&&(c.onStart(e.context,a,W(),s),s.addObserver(u=>c.onEnd(u,s))),ad.add(e.runtimeFlags,s),r?.immediate===!1?s.resume(a):s.start(a),s}),VU=jI((e,t,r={})=>{let n=qI(e,t,r);return r.onExit&&n.addObserver(o=>{r.onExit(o)}),(o,i)=>VU(e)(C(n,HI(o??ci)),{...i,onExit:i?.onExit?s=>i.onExit(qZ(s)):void 0})}),RTe=jI((e,t)=>{let r=_8(e)(t);if(r._tag==="Failure")throw R8(r.effect_instruction_i0);return r.effect_instruction_i0}),k8=class extends Error{fiber;_tag="AsyncFiberException";constructor(t){super(`Fiber #${t.id().id} cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work`),this.fiber=t,this.name=this._tag,this.stack=this.message}},lIt=e=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let r=new k8(e);return Error.stackTraceLimit=t,r},I8=Symbol.for("effect/Runtime/FiberFailure"),wT=Symbol.for("effect/Runtime/FiberFailure/Cause"),v8=class extends Error{[I8];[wT];constructor(t){let r=M_(t)[0];super(r?.message||"An error has occurred"),this[I8]=I8,this[wT]=t,this.name=r?`(FiberFailure) ${r.name}`:"FiberFailure",r?.stack&&(this.stack=r.stack)}toJSON(){return{_id:"FiberFailure",cause:this[wT].toJSON()}}toString(){return"(FiberFailure) "+Yl(this[wT],{renderErrorCause:!0})}[Ce](){return this.toString()}},R8=e=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let r=new v8(e);return Error.stackTraceLimit=t,r},_Te=e=>{let t=e;switch(t._op){case"Failure":case"Success":return t;case"Left":return nd(t.left);case"Right":return Vt(t.right);case"Some":return Vt(t.value);case"None":return nd(new Es)}},_8=jI((e,t)=>{let r=_Te(t);if(r)return r;let n=new CI,o=qI(e)(t,{scheduler:n});n.flush();let i=o.unsafePoll();return i||UL(BL(lIt(o),jL(o)))}),BTe=jI((e,t,r)=>YU(e,t,r).then(n=>{switch(n._tag){case _r:return n.effect_instruction_i0;case Rr:throw R8(n.effect_instruction_i0)}})),YU=jI((e,t,r)=>new Promise(n=>{let o=_Te(t);o&&n(o);let i=qI(e)(t);i.addObserver(s=>{n(s)}),r?.signal!==void 0&&(r.signal.aborted?i.unsafeInterruptAsFork(i.id()):r.signal.addEventListener("abort",()=>{i.unsafeInterruptAsFork(i.id())},{once:!0}))})),zU=class{context;runtimeFlags;fiberRefs;constructor(t,r,n){this.context=t,this.runtimeFlags=r,this.fiberRefs=n}pipe(){return Z(this,arguments)}},B8=e=>new zU(e.context,e.runtimeFlags,e.fiberRefs),GI=()=>st((e,t)=>M(new zU(e.getFiberRef(li),t.runtimeFlags,e.getFiberRefs()))),TTe=D3(Xl,_3,R3),qf=B8({context:ro(),runtimeFlags:TTe,fiberRefs:e0e()}),DTe=x(2,(e,t)=>B8({context:t(e.context),runtimeFlags:e.runtimeFlags,fiberRefs:e.fiberRefs})),QTe=VU(qf),OTe=qI(qf),NTe=BTe(qf),PTe=YU(qf),MTe=RTe(qf),FTe=_8(qf),LTe=e=>ye(()=>{let t;return O(wi(),r=>O(GI(),n=>xn(o=>je(Ou(o(dn(e(i=>VU(n)(Df(i,r))),{onFailure:i=>iI(r,i),onSuccess:i=>(t=i,Ue)}))),o(hc(Cn(r),()=>t??Ue))))))})});var UTe,IT,D8=h(()=>{oe();vt();UTe=x(2,(e,t)=>e.modifyEffect(t)),IT=x(2,(e,t)=>e.modifyEffect(r=>{let n=t(r);switch(n._tag){case"None":return M([void 0,r]);case"Some":return te(n.value,o=>[void 0,o])}}))});function Cs(e){let t=Object.create(Fu);return t._op_layer=bTe,t.effect=e,t}var dIt,XU,fIt,Fu,pIt,kT,Q8,RT,O8,KU,N8,mIt,qTe,YA,e$,GTe,yb,P8,M8,zTe,VTe,t$,YTe,F8,L8,_T,r$,Gf,JTe,U8,JA,KTe,ZTe,n$,o$,XTe,eDe,tDe,rDe,nDe,HTe,hIt,i$,oDe,s$,a$,iDe,$8,c$,sDe,aDe,cDe,uDe,lDe,dDe,gIt,KA,xb,BT,fDe,pDe,zI,ch,mDe,TT,u$,hDe,gDe,ADe,yDe,xDe,EDe,Eb,bDe,H8,W8,vT,SDe,CDe,wDe,ZU,WTe,jTe,l$,DT=h(()=>{Vs();II();sr();Ws();m1();oe();kf();Me();ct();FU();xT();ah();$f();vt();UI();kB();La();yTe();Iw();vTe();SI();JU();lA();D8();_A();dIt="effect/Layer",XU=Symbol.for(dIt),fIt={_RIn:e=>e,_E:e=>e,_ROut:e=>e},Fu={[XU]:fIt,pipe(){return Z(this,arguments)}},pIt="effect/Layer/MemoMap",kT=Symbol.for(pIt),Q8=ai()("effect/Layer/CurrentMemoMap",{defaultValue:()=>mIt()}),RT=e=>se(e,XU),O8=e=>e._op_layer===S8,KU=class{ref;[kT];constructor(t){this.ref=t,this[kT]=kT}getOrElseMemoize(t,r){return C(UTe(this.ref,n=>{let o=n.get(t);if(o!==void 0){let[i,s]=o,a=C(i,O(([c,u])=>C(ab(c),Zt(u))),Gs(GE({onFailure:()=>Ue,onSuccess:()=>SA(r,s)})));return M([a,n])}return C(rb(0),O(i=>C(wi(),O(s=>C(rb(()=>Ue),te(a=>{let c=xn(l=>C(oh(),O(d=>C(l(O(GTe(t,d,!0),f=>RI(f(this)))),fn,O(f=>{switch(f._tag){case Rr:return C(iI(s,f.effect_instruction_i0),je(rd(d,f)),je(kt(f.effect_instruction_i0)));case _r:return C(Pa(a,p=>C(rd(d,p),AA(nb(i,m=>[m===1,m-1])),$r)),je(ob(i,p=>p+1)),je(SA(r,p=>C(V(()=>n.delete(t)),je(io(a)),O(m=>m(p))))),je(Mm(s,f.effect_instruction_i0)),Zt(f.effect_instruction_i0[1]))}}))))),u=[C(Cn(s),Gs(zE({onFailure:()=>Ue,onSuccess:()=>ob(i,l=>l+1)}))),l=>C(io(a),O(d=>d(l)))];return[c,O8(t)?n:n.set(t,u)]}))))))}),ys)}},N8=ye(()=>te(WU(new Map),e=>new KU(e))),mIt=()=>new KU(b8(new Map)),qTe=e=>Nu(t=>YA(e,t)),YA=x(2,(e,t)=>O(N8,r=>e$(e,r,t))),e$=x(3,(e,t,r)=>O(GTe(e,r),n=>MA(n(t),Q8,t))),GTe=(e,t,r=!1)=>{let n=e;switch(n._op_layer){case"Locally":return V(()=>o=>n.f(o.getOrElseMemoize(n.self,t)));case"ExtendScope":return V(()=>o=>Nu(i=>o.getOrElseMemoize(n.layer,i)));case"Fold":return V(()=>o=>C(o.getOrElseMemoize(n.layer,t),dn({onFailure:i=>o.getOrElseMemoize(n.failureK(i),t),onSuccess:i=>o.getOrElseMemoize(n.successK(i),t)})));case"Fresh":return V(()=>o=>C(n.layer,YA(t)));case"FromEffect":return r?V(()=>o=>n.effect):V(()=>o=>o.getOrElseMemoize(e,t));case"Provide":return V(()=>o=>C(o.getOrElseMemoize(n.first,t),O(i=>C(o.getOrElseMemoize(n.second,t),zs(i)))));case"Scoped":return r?V(()=>o=>Wf(n.effect,t)):V(()=>o=>o.getOrElseMemoize(e,t));case"Suspend":return V(()=>o=>o.getOrElseMemoize(n.evaluate(),t));case"ProvideMerge":return V(()=>o=>C(o.getOrElseMemoize(n.first,t),Zi(o.getOrElseMemoize(n.second,t),n.zipK)));case"ZipWith":return uB(function*(){let o=yield*Ac(t,IB),i=yield*Ac(o,Tu),s=yield*Ac(o,Tu);return a=>C(a.getOrElseMemoize(n.first,i),Hf(a.getOrElseMemoize(n.second,s),n.zipK,{concurrent:!0}))});case"MergeAll":{let o=n.layers;return te(Ac(t,IB),i=>s=>{let a=new Array(o.length);return te(Du(o,Xw(function*(c,u){let l=yield*Ac(i,Tu),d=yield*s.getOrElseMemoize(c,l);a[u]=d}),!1,!1),()=>K6(...a))})}}},yb=x(2,(e,t)=>a$(e,{onFailure:t,onSuccess:ch})),P8=x(2,(e,t)=>s$(e,{onFailure:t,onSuccess:ch})),M8=e=>_T(od(e)),zTe=e=>r$(()=>od(e())),VTe=e=>i$(e,()=>ro()),t$=()=>Cs(Oa()),YTe=e=>{let t=Object.create(Fu);return t._op_layer=xTe,t.layer=e,t},F8=e=>_T(VE(e)),L8=e=>r$(()=>VE(e())),_T=e=>Cs(kt(e)),r$=e=>Cs(Tf(e)),Gf=x(2,(e,t)=>a$(e,{onFailure:F8,onSuccess:t})),JTe=x(2,(e,t)=>Gf(e,Dr(t))),U8=e=>{let t=Object.create(Fu);return t._op_layer=S8,t.layer=e,t},JA=x(2,(e,t)=>{let r=$w(e),n=r?e:t;return Cs(te(r?t:e,i=>Ra(n,i)))}),KTe=e=>Cs(te(e,()=>ro()));ZTe=x(3,(e,t,r)=>n$(e,tn(t,r))),n$=x(2,(e,t)=>{let r=Object.create(Fu);return r._op_layer="Locally",r.self=e,r.f=t,r}),o$=x(3,(e,t,r)=>n$(e,no(t,r))),XTe=(e,t)=>xb(Ss(e,t)),eDe=(e,t)=>xb(ts(e,t)),tDe=(e,t,r)=>Cs(te(e,n=>Ra(t,r(n)))),rDe=e=>IU(je(Nu(t=>C(e,YA(t))),xA)),nDe=function(){return arguments.length===1?e=>HTe(arguments[0],e):HTe(arguments[0],arguments[1])},HTe=(e,t)=>zI(e,new Proxy({...t},{get(r,n,o){if(n in r)return r[n];let i=Error.stackTraceLimit;Error.stackTraceLimit=2;let s=new Error(`${e.key}: Unimplemented method "${n.toString()}"`);return Error.stackTraceLimit=i,s.name="UnimplementedError",hIt(s)},has:ka})),hIt=e=>{let t=Ci(e);function r(){return t}return Object.assign(r,t),Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r},i$=x(2,(e,t)=>Gf(e,r=>ch(t(r)))),oDe=x(2,(e,t)=>yb(e,r=>L8(()=>t(r)))),s$=x(2,(e,{onFailure:t,onSuccess:r})=>{let n=Object.create(Fu);return n._op_layer=ETe,n.layer=e,n.failureK=t,n.successK=r,n}),a$=x(2,(e,{onFailure:t,onSuccess:r})=>s$(e,{onFailure:n=>{let o=sI(n);switch(o._tag){case"Left":return t(o.left);case"Right":return _T(o.right)}},onSuccess:r})),iDe=e=>Nu(t=>te(q1(YA(e,t)),Cs)),$8=x(2,(e,t)=>H8(e,t,(r,n)=>wo(r,n))),c$=(...e)=>{let t=Object.create(Fu);return t._op_layer=ITe,t.layers=e,t},sDe=e=>yb(e,t=>M8(t)),aDe=x(2,(e,t)=>yb(e,t)),cDe=e=>$8(t$(),e),uDe=x(4,(e,t,r,n)=>i$(e,o=>Ra(r,n(_a(o,t))))),lDe=x(2,(e,t)=>TT(()=>{let r=Jt("effect/Layer/retry/{ state: unknown }");return C(zI(r,{state:t.initial}),Gf(n=>dDe(e,t,r,C(n,Dr(r)).state)))})),dDe=(e,t,r,n)=>C(e,yb(o=>C(gIt(t,r,o,n),Gf(i=>U8(dDe(e,t,r,C(i,Dr(r)).state)))))),gIt=(e,t,r,n)=>JA(t,C(zm,O(o=>C(e.step(o,r,n),O(([i,s,a])=>fi(a)?ut(r):C(wI(Ki(GA(a.intervals)-o)),Zt({state:i}))))))),KA=x(2,(e,t)=>{let r=$w(e),n=r?e:t;return BT(te(r?t:e,i=>Ra(n,i)))}),xb=e=>BT(C(e,Zt(ro()))),BT=e=>{let t=Object.create(Fu);return t._op_layer=STe,t.effect=e,t},fDe=BT(te(gb(oh(),(e,t)=>e.close(t)),e=>Ra(FI,e))),pDe=e=>JA(e,e),zI=x(2,(e,t)=>{let r=$w(e);return Cs(M(Ra(r?e:t,r?t:e)))}),ch=e=>Cs(M(e)),mDe=ch(ro()),TT=e=>{let t=Object.create(Fu);return t._op_layer=CTe,t.evaluate=e,t},u$=x(2,(e,t)=>{let r=$w(e),n=r?e:t,o=r?t:e;return Cs(V(()=>Ra(n,o())))}),hDe=e=>Cs(V(e)),gDe=x(2,(e,t)=>Gf(e,r=>Cs(Zt(t(r),r)))),ADe=x(2,(e,t)=>yb(e,r=>Cs(O(t(r),()=>ut(r))))),yDe=x(2,(e,t)=>P8(e,r=>Cs(O(t(r),()=>kt(r))))),xDe=e=>C(Nu(t=>YA(e,t)),O(t=>C(GI(),zs(t)))),EDe=x(2,(e,t)=>O(Nu(r=>e$(e,t,r)),r=>C(GI(),zs(r)))),Eb=x(2,(e,t)=>TT(()=>{let r=Object.create(Fu);return r._op_layer=wTe,r.first=Object.create(Fu,{_op_layer:{value:C8,enumerable:!0},first:{value:t$(),enumerable:!0},second:{value:Array.isArray(t)?c$(...t):t},zipK:{value:(n,o)=>C(n,wo(o))}}),r.second=e,r})),bDe=x(2,(e,t)=>{let r=Object.create(Fu);return r._op_layer=C8,r.first=t,r.second=Eb(e,t),r.zipK=(n,o)=>C(n,wo(o)),r}),H8=x(3,(e,t,r)=>TT(()=>{let n=Object.create(Fu);return n._op_layer=kTe,n.first=e,n.second=t,n.zipK=r,n})),W8=e=>{let t=Jt("effect/Layer/unwrapEffect/Layer.Layer<R1, E1, A>");return Gf(JA(t,e),r=>Dr(r,t))},vT=e=>{let t=Jt("effect/Layer/unwrapScoped/Layer.Layer<R1, E1, A>");return Gf(KA(t,e),r=>Dr(r,t))},SDe=x(e=>RT(e[0]),function(){let e=arguments;return o$(e[0],Of,typeof e[1]=="string"?ko(e[1],e[2]):t=>Object.entries(e[1]).reduce((r,[n,o])=>ko(r,n,o),t))}),CDe=x(e=>RT(e[0]),function(){let e=arguments;return o$(e[0],HE,typeof e[1]=="string"?ko(e[1],e[2]):t=>Object.entries(e[1]).reduce((r,[n,o])=>ko(r,n,o),t))}),wDe=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ec(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return vT(te(r?.onEnd?jo(Qu(t,r),o=>ld(i=>r.onEnd(o,i))):Qu(t,r),o=>ZU(n,o)))}return n=>vT(te(r?.onEnd?jo(Qu(t,r),o=>ld(i=>r.onEnd(o,i))):Qu(t,r),o=>ZU(n,o)))},ZU=x(2,(e,t)=>Eb(e,ch(Ra(Ii,t)))),WTe=x(2,(e,t)=>AT(r=>O(YA(t,r),n=>WL(e,n)))),jTe=x(2,(e,t)=>{let r=XE(qf.fiberRefs,t.fiberRefs),n=Cu(qf.runtimeFlags,t.runtimeFlags);return xn(o=>st(i=>{let s=i.getFiberRef(li),a=i.getFiberRefs(),c=eb(i.id(),a)(r),u=i.currentRuntimeFlags,l=Tm(n)(u),d=XE(c,a),f=Cu(l,u);return i.setFiberRefs(c),i.currentRuntimeFlags=l,Js(WL(o(e),wo(s,t.context)),st(p=>(p.setFiberRefs(eb(p.id(),p.getFiberRefs())(d)),p.currentRuntimeFlags=Tm(f)(p.currentRuntimeFlags),Ue)))}))}),l$=x(2,(e,t)=>Array.isArray(t)?WTe(e,c$(...t)):RT(t)?WTe(e,t):J6(t)?WL(e,t):ATe in t?O(t.runtimeEffect,r=>jTe(e,r)):jTe(e,t))});var IDe,kDe,vDe,RDe,_De=h(()=>{sr();oe();vt();Mf();e1();La();IDe=te(Xi(mn),Dr($m)),kDe=e=>ui(mn,t=>e(Dr(t,$m))),vDe=x(2,(e,t)=>no(e,mn,zt($m,t))),RDe=e=>ts(mn,zt($m,e))});var pr={};tr(pr,{Class:()=>q8,Error:()=>YI,Structural:()=>SIt,TaggedClass:()=>bIt,TaggedError:()=>uh,array:()=>BDe,case:()=>EIt,struct:()=>f$,tagged:()=>VI,taggedEnum:()=>CIt,tuple:()=>xIt,unsafeArray:()=>j8,unsafeStruct:()=>yIt});function wIt(){if(arguments.length===1){let r=arguments[0];return function(n){return r[n._tag](n)}}let e=arguments[0];return arguments[1][e._tag](e)}var f$,yIt,xIt,BDe,j8,EIt,VI,q8,bIt,SIt,CIt,YI,uh,lh=h(()=>{vt();Vw();Af();ct();f$=zw,yIt=e=>Object.setPrototypeOf(e,gf),xIt=(...e)=>j8(e),BDe=e=>j8(e.slice(0)),j8=e=>Object.setPrototypeOf(e,cCe),EIt=()=>e=>e===void 0?Object.create(gf):f$(e),VI=e=>t=>{let r=t===void 0?Object.create(gf):f$(t);return r._tag=e,r},q8=Bm,bIt=e=>{class t extends q8{_tag=e}return t},SIt=Bm,CIt=()=>new Proxy({},{get(e,t,r){return t==="$is"?mf:t==="$match"?wIt:VI(t)}});YI=function(){let e=Symbol.for("effect/Data/Error/plainArgs");return{BaseEffectError:class extends AB{constructor(r){super(r?.message,r?.cause?{cause:r.cause}:void 0),r&&(Object.assign(this,r),Object.defineProperty(this,e,{value:r,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}.BaseEffectError}(),uh=e=>{let t={BaseEffectError:class extends YI{_tag=e}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError}});var G8,z8,QDe,IIt,kIt,ODe,vIt,RIt,zf,NT,_It,JI,NDe,BIt,PDe,p$,TIt,DIt,QIt,OIt,m$,OT,NIt,PIt,MIt,V8,FIt,LIt,Y8,KI,bb,MDe,FDe,UIt,$It,LDe,UDe,HIt,WIt,TDe,$De,jIt,HDe,QT,WDe,qIt,GIt,DDe,zIt,jDe=h(()=>{Vs();mt();oe();yn();ir();ht();it();Me();ct();G8=Symbol.for("effect/DateTime"),z8=Symbol.for("effect/DateTime/TimeZone"),QDe={[G8]:G8,pipe(){return Z(this,arguments)},[Ce](){return this.toString()},toJSON(){return KI(this).toJSON()}},IIt={...QDe,_tag:"Utc",[he](){return We(this,hu(this.epochMillis))},[me](e){return NT(e)&&e._tag==="Utc"&&this.epochMillis===e.epochMillis},toString(){return`DateTime.Utc(${KI(this).toJSON()})`}},kIt={...QDe,_tag:"Zoned",[he](){return C(hu(this.epochMillis),we(ae(this.zone)),We(this))},[me](e){return NT(e)&&e._tag==="Zoned"&&this.epochMillis===e.epochMillis&&ce(this.zone,e.zone)},toString(){return`DateTime.Zoned(${zIt(this)})`}},ODe={[z8]:z8,[Ce](){return this.toString()}},vIt={...ODe,_tag:"Named",[he](){return We(this,Lt(`Named:${this.id}`))},[me](e){return JI(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},RIt={...ODe,_tag:"Offset",[he](){return We(this,Lt(`Offset:${this.offset}`))},[me](e){return JI(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${FDe(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},zf=(e,t,r)=>{let n=Object.create(kIt);return n.epochMillis=e,n.zone=t,Object.defineProperty(n,"partsUtc",{value:r,enumerable:!1,writable:!0}),Object.defineProperty(n,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(n,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),n},NT=e=>se(e,G8),_It=e=>NT(e[0]),JI=e=>se(e,z8),NDe=e=>JI(e)&&e._tag==="Named",BIt=e=>e._tag==="Zoned",PDe=e=>{let t=Object.create(IIt);return t.epochMillis=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},p$=e=>{let t=e.getTime();if(Number.isNaN(t))throw new bB("Invalid date");return PDe(t)},TIt=e=>{if(NT(e))return e;if(e instanceof Date)return p$(e);if(typeof e=="object"){let t=new Date(0);return WIt(t,e),p$(t)}else if(typeof e=="string"&&!DIt(e))return p$(new Date(e+"Z"));return p$(new Date(e))},DIt=e=>/Z|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),QIt=-864e13+12*60*60*1e3,OIt=864e13-14*60*60*1e3,m$=(e,t)=>{if(t?.timeZone===void 0&&NT(e)&&BIt(e))return e;let r=TIt(e);if(r.epochMillis<QIt||r.epochMillis>OIt)throw new RangeError(`Epoch millis out of range: ${r.epochMillis}`);let n;if(t?.timeZone===void 0){let o=new Date(r.epochMillis).getTimezoneOffset()*-60*1e3;n=V8(o)}else if(JI(t?.timeZone))n=t.timeZone;else if(typeof t?.timeZone=="number")n=V8(t.timeZone);else{let o=Y8(t.timeZone);if(Ct(o))throw new bB(`Invalid time zone: ${t.timeZone}`);n=o.value}return t?.adjustForTimeZone!==!0?zf(r.epochMillis,n,r.partsUtc):$De(r.epochMillis,n,t?.disambiguation??"compatible")},OT=Te("effect/DateTime/validZoneCache",()=>new Map),NIt={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},PIt=e=>{let t=e.resolvedOptions().timeZone;if(OT.has(t))return OT.get(t);let r=Object.create(vIt);return r.id=t,r.format=e,OT.set(t,r),r},MIt=e=>{if(OT.has(e))return OT.get(e);try{return PIt(new Intl.DateTimeFormat("en-US",{...NIt,timeZone:e}))}catch{throw new bB(`Invalid time zone: ${e}`)}},V8=e=>{let t=Object.create(RIt);return t.offset=e,t},FIt=EE(MIt),LIt=/^(?:GMT|[+-])/,Y8=e=>{if(LIt.test(e)){let t=HDe(e);return t===null?W():H(V8(t))}return FIt(e)},KI=e=>new Date(e.epochMillis),bb=e=>{if(e._tag==="Utc")return new Date(e.epochMillis);if(e.zone._tag==="Offset")return new Date(e.epochMillis+e.zone.offset);if(e.adjustedEpochMillis!==void 0)return new Date(e.adjustedEpochMillis);let t=e.zone.format.formatToParts(e.epochMillis).filter(n=>n.type!=="literal"),r=new Date(0);return r.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),r.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMillis=r.getTime(),r},MDe=e=>bb(e).getTime()-$It(e),FDe=e=>{let t=Math.abs(e),r=Math.floor(t/(60*60*1e3)),n=Math.round(t%(60*60*1e3)/(60*1e3));return n===60&&(r+=1,n=0),`${e<0?"-":"+"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},UIt=e=>FDe(MDe(e)),$It=e=>e.epochMillis,LDe=e=>({millis:e.getUTCMilliseconds(),seconds:e.getUTCSeconds(),minutes:e.getUTCMinutes(),hours:e.getUTCHours(),day:e.getUTCDate(),weekDay:e.getUTCDay(),month:e.getUTCMonth()+1,year:e.getUTCFullYear()}),UDe=e=>e._tag==="Utc"?HIt(e):(e.partsAdjusted!==void 0||(e.partsAdjusted=qIt(e,LDe)),e.partsAdjusted),HIt=e=>(e.partsUtc!==void 0||(e.partsUtc=GIt(e,LDe)),e.partsUtc),WIt=(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 r=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+r)}t.hours!==void 0&&e.setUTCHours(t.hours),t.minutes!==void 0&&e.setUTCMinutes(t.minutes),t.seconds!==void 0&&e.setUTCSeconds(t.seconds),t.millis!==void 0&&e.setUTCMilliseconds(t.millis)},TDe=24*60*60*1e3,$De=(e,t,r)=>{if(t._tag==="Offset")return zf(e-t.offset,t);let n=QT(e-TDe,e,t),o=QT(e+TDe,e,t);if(n===o)return zf(e-n,t);let i=n<o,s=n-o;if(i){if(QT(e-o,e,t)===o)return zf(e-o,t);let u=zf(e-n,t),l=bb(u).getTime();if(e!==l)switch(r){case"reject":{let d=new Date(e).toISOString();throw new RangeError(`Gap time: ${d} does not exist in time zone ${t.id}`)}case"earlier":return zf(e-o,t);case"compatible":case"later":return u}return u}if(QT(e-n,e,t)===n){if(r==="earlier"||r==="compatible"||QT(e-n+s,e+s,t)===n)return zf(e-n,t);if(r==="reject"){let u=new Date(e).toISOString();throw new RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return zf(e-o,t)},jIt=/([+-])(\d{2}):(\d{2})$/,HDe=e=>{let t=jIt.exec(e);if(t===null)return null;let[,r,n,o]=t;return(r==="+"?1:-1)*(Number(n)*60+Number(o))*60*1e3},QT=(e,t,r)=>{let n=r.format.formatToParts(e).find(i=>i.type==="timeZoneName")?.value??"";if(n==="GMT")return 0;let o=HDe(n);return o===null?MDe(zf(t,r)):o},WDe=x(_It,(e,t,r)=>{if(e._tag==="Utc"){let i=KI(e);return t(i),PDe(i.getTime())}let n=bb(e),o=new Date(n.getTime());return t(o),$De(o.getTime(),e.zone,r?.disambiguation??"compatible")}),qIt=x(2,(e,t)=>t(bb(e))),GIt=x(2,(e,t)=>t(KI(e))),DDe=e=>{let t=bb(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${UIt(e)}`},zIt=e=>e.zone._tag==="Offset"?DDe(e):`${DDe(e)}[${e.zone.id}]`});var qDe,J8=h(()=>{qDe=e=>e.length>0});function Z8(e,t){return t?.[e.toLocaleLowerCase()]??Number(e)}var X8,YIt,e5,JIt,Lu,zDe,Uu,VDe,YDe,K8,JDe,KIt,ZIt,XIt,ZI,e0t,t0t,r0t,n0t,o0t,i0t,s0t,XI,a0t,c0t,t5=h(()=>{wr();lh();bi();mt();mm();oe();ir();ht();jDe();Lm();it();Me();ct();J8();X8=Symbol.for("effect/Cron"),YIt={[X8]:X8,[me](e){return e5(e)&&e0t(this,e)},[he](){return C(ae(this.tz),we(So(_e(this.seconds))),we(So(_e(this.minutes))),we(So(_e(this.hours))),we(So(_e(this.days))),we(So(_e(this.months))),we(So(_e(this.weekdays))),We(this))},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"Cron",tz:this.tz,seconds:_e(this.seconds),minutes:_e(this.minutes),hours:_e(this.hours),days:_e(this.days),months:_e(this.months),weekdays:_e(this.weekdays)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},e5=e=>se(e,X8),JIt=e=>{let t=Object.create(YIt);t.seconds=new Set(Vi(e.seconds??[0],oo)),t.minutes=new Set(Vi(e.minutes,oo)),t.hours=new Set(Vi(e.hours,oo)),t.days=new Set(Vi(e.days,oo)),t.months=new Set(Vi(e.months,oo)),t.weekdays=new Set(Vi(e.weekdays,oo)),t.tz=en(e.tz);let r=Array.from(t.seconds),n=Array.from(t.minutes),o=Array.from(t.hours),i=Array.from(t.days),s=Array.from(t.months),a=Array.from(t.weekdays);return t.first={second:r[0]??0,minute:n[0]??0,hour:o[0]??0,day:i[0]??1,month:(s[0]??1)-1,weekday:a[0]??0},t.last={second:r[r.length-1]??59,minute:n[n.length-1]??59,hour:o[o.length-1]??23,day:i[i.length-1]??31,month:(s[s.length-1]??12)-1,weekday:a[a.length-1]??6},t.next={second:Lu(r,60,"next"),minute:Lu(n,60,"next"),hour:Lu(o,24,"next"),day:Lu(i,32,"next"),month:Lu(s,13,"next"),weekday:Lu(a,7,"next")},t.prev={second:Lu(r,60,"prev"),minute:Lu(n,60,"prev"),hour:Lu(o,24,"prev"),day:Lu(i,32,"prev"),month:Lu(s,13,"prev"),weekday:Lu(a,7,"prev")},t},Lu=(e,t,r)=>{let n=new Array(t).fill(void 0);if(e.length===0)return n;let o;if(r==="next"){let i=e.length-1;for(let s=t-1;s>=0;s--){for(;i>=0&&e[i]>=s;)o=e[i--];n[s]=o}}else{let i=0;for(let s=0;s<t;s++){for(;i<e.length&&e[i]<=s;)o=e[i++];n[s]=o}}return n},zDe=Symbol.for("effect/Cron/errors/ParseError"),Uu=class extends uh("CronParseError"){[zDe]=zDe},VDe=(e,t)=>{let r=e.split(" ").filter(qDe);if(r.length!==5&&r.length!==6)return Re(new Uu({message:"Invalid number of segments in cron expression",input:e}));r.length===5&&r.unshift("0");let[n,o,i,s,a,c]=r,u=t===void 0||JI(t)?Le(t):JJ(Y8(t),()=>new Uu({message:"Invalid time zone in cron expression",input:t}));return $Ee({tz:u,seconds:XI(n,t0t),minutes:XI(o,r0t),hours:XI(i,n0t),days:XI(s,o0t),months:XI(a,i0t),weekdays:XI(c,s0t)}).pipe(lF(JIt))},YDe=(e,t)=>{let r=m$(t,{timeZone:Gr(e.tz)}).pipe(UDe);return e.seconds.size!==0&&!e.seconds.has(r.seconds)||e.minutes.size!==0&&!e.minutes.has(r.minutes)||e.hours.size!==0&&!e.hours.has(r.hours)||e.months.size!==0&&!e.months.has(r.month)?!1:e.days.size===0&&e.weekdays.size===0?!0:e.weekdays.size===0?e.days.has(r.day):e.days.size===0?e.weekdays.has(r.weekDay):e.days.has(r.day)||e.weekdays.has(r.weekDay)},K8=e=>new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth()+1,0)).getUTCDate(),JDe=(e,t)=>KIt(e,t,"next"),KIt=(e,t,r)=>{let n=Gr(e.tz),o=m$(t??new Date,{timeZone:n}),i=r==="prev",s=i?-1:1,a=e[r],c=i?e.last:e.first,u=i?(p,m)=>p<m:(p,m)=>p>m,d=n!==void 0&&NDe(n)&&n.id==="UTC"?yi:p=>{let m=m$(p,{timeZone:o.zone,adjustForTimeZone:!0,disambiguation:i?"later":void 0}).pipe(bb),g=p.getTime()-m.getTime();(i?g!==0:g>0)&&p.setTime(m.getTime())},f=WDe(o,p=>{p.setUTCSeconds(p.getUTCSeconds()+s,0);for(let m=0;m<1e4;m++){if(e.seconds.size!==0){let g=p.getUTCSeconds(),A=a.second[g];if(A===void 0){p.setUTCMinutes(p.getUTCMinutes()+s,c.second),d(p);continue}if(u(A,g)){p.setUTCSeconds(A),d(p);continue}}if(e.minutes.size!==0){let g=p.getUTCMinutes(),A=a.minute[g];if(A===void 0){p.setUTCHours(p.getUTCHours()+s,c.minute,c.second),d(p);continue}if(u(A,g)){p.setUTCMinutes(A,c.second),d(p);continue}}if(e.hours.size!==0){let g=p.getUTCHours(),A=a.hour[g];if(A===void 0){p.setUTCDate(p.getUTCDate()+s),p.setUTCHours(c.hour,c.minute,c.second),d(p);continue}if(u(A,g)){p.setUTCHours(A,c.minute,c.second),d(p);continue}}if(e.weekdays.size!==0||e.days.size!==0){let g=i?-1/0:1/0,A=i?-1/0:1/0;if(e.weekdays.size!==0){let y=p.getUTCDay(),b=a.weekday[y];b===void 0?g=i?y-7+c.weekday:7-y+c.weekday:g=b-y}if(e.days.size!==0&&g!==0){let y=p.getUTCDate(),b=a.day[y];if(b===void 0)if(i){let w=K8(new Date(Date.UTC(p.getUTCFullYear(),p.getUTCMonth(),0)));A=-(y+(w-c.day))}else A=K8(p)-y+c.day;else A=b-y}let E=i?Math.max(g,A):Math.min(g,A);if(E!==0){p.setUTCDate(p.getUTCDate()+E),p.setUTCHours(c.hour,c.minute,c.second),d(p);continue}}if(e.months.size!==0){let g=p.getUTCMonth()+1,A=a.month[g],E=y=>{if(e.days.size!==0)return c.day;let b=K8(new Date(Date.UTC(p.getUTCFullYear(),y,1)));return Math.min(c.day,b)};if(A===void 0){p.setUTCFullYear(p.getUTCFullYear()+s),p.setUTCMonth(c.month,E(c.month)),p.setUTCHours(c.hour,c.minute,c.second),d(p);continue}if(u(A,g)){let y=A-1;p.setUTCMonth(y,E(y)),p.setUTCHours(c.hour,c.minute,c.second),d(p);continue}}return}throw new Error("Unable to find next cron date")});return KI(f)},ZIt=Ml((e,t)=>ZI(e.seconds,t.seconds)&&ZI(e.minutes,t.minutes)&&ZI(e.hours,t.hours)&&ZI(e.days,t.days)&&ZI(e.months,t.months)&&ZI(e.weekdays,t.weekdays)),XIt=zM(QJ),ZI=(e,t)=>XIt(_e(e),_e(t)),e0t=x(2,(e,t)=>ZIt(e,t)),t0t={min:0,max:59},r0t={min:0,max:59},n0t={min:0,max:23},o0t={min:1,max:31},i0t={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}},s0t={min:0,max:6,aliases:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6}},XI=(e,t)=>{let r=t.max-t.min+1,n=new Set,o=e.split(",");for(let i of o){let[s,a]=a0t(i);if(s==="*"&&a===void 0)return Le(new Set);if(a!==void 0){if(!Number.isInteger(a))return Re(new Uu({message:"Expected step value to be a positive integer",input:e}));if(a<1)return Re(new Uu({message:"Expected step value to be greater than 0",input:e}));if(a>t.max)return Re(new Uu({message:`Expected step value to be less than ${t.max}`,input:e}))}if(s==="*")for(let c=t.min;c<=t.max;c+=a??1)n.add(c);else{let[c,u]=c0t(s,t.aliases);if(!Number.isInteger(c))return Re(new Uu({message:"Expected a positive integer",input:e}));if(c<t.min||c>t.max)return Re(new Uu({message:`Expected a value between ${t.min} and ${t.max}`,input:e}));if(u===void 0)n.add(c);else{if(!Number.isInteger(u))return Re(new Uu({message:"Expected a positive integer",input:e}));if(u<t.min||u>t.max)return Re(new Uu({message:`Expected a value between ${t.min} and ${t.max}`,input:e}));if(c>u)return Re(new Uu({message:"Invalid value range",input:e}));for(let l=c;l<=u;l+=a??1)n.add(l)}}if(n.size>=r)return Le(new Set)}return Le(n)},a0t=e=>{let t=e.indexOf("/");return t!==-1?[e.slice(0,t),Number(e.slice(t+1))]:[e,void 0]},c0t=(e,t)=>{let r=e.indexOf("-");return r!==-1?[Z8(e.slice(0,r),t),Z8(e.slice(r+1),t)]:[Z8(e,t),void 0]}});var ZDe,XDe,h$=h(()=>{Mf();CB();ZDe=MIe,XDe=IIe});var u0t,y$,x$,l0t,c5,n5,Sb,d0t,f0t,o5,eQe,i5,mr,E$,u5,rQe,l5,nQe,b$,oQe,e0,Cb,iQe,wb,sQe,aQe,cQe,uQe,lQe,d5,dQe,S$,fQe,pQe,mQe,hQe,C$,MT,gQe,AQe,yQe,FT,f5,xQe,EQe,bQe,SQe,CQe,wQe,IQe,kQe,vQe,RQe,dh,ZA,p5,s5,_Qe,m5,BQe,vi,w$,TQe,DQe,LT,QQe,h5,OQe,NQe,g5,A5,PQe,y5,x5,E5,t0,I$,b5,MQe,FQe,S5,LQe,UQe,$Qe,HQe,WQe,jQe,qQe,GQe,UT,C5,k$,w5,$T,I5,zQe,VQe,k5,HT,v$,YQe,JQe,v5,KQe,ZQe,R5,XQe,p0t,eOe,m0t,h0t,tOe,g0t,A0t,_5,rOe,y0t,x0t,nOe,g$,a5,E0t,A$,b0t,WT,tQe,oOe,B5,iOe,PT,sOe,R$,T5,aOe,D5,Q5,cOe,uOe,_$,fd,B$,lOe,dOe,T$=h(()=>{vr();II();sr();t5();Ws();bi();mt();oe();it();Me();ct();h$();FU();QU();xT();Jl();$f();vt();UI();SI();u0t="effect/Schedule",y$=Symbol.for(u0t),x$=e=>se(e,y$),l0t="effect/ScheduleDriver",c5=Symbol.for(l0t),n5={start:0,now:0,input:void 0,output:void 0,elapsed:As,elapsedSincePrevious:As,recurrence:0},Sb=ai()("effect/Schedule/CurrentIterationMetadata",{defaultValue:()=>n5}),d0t={_Out:e=>e,_In:e=>e,_R:e=>e},f0t={_Out:e=>e,_In:e=>e,_R:e=>e},o5=class{initial;step;[y$]=d0t;constructor(t,r){this.initial=t,this.step=r}pipe(){return Z(this,arguments)}},eQe=(e,t,r,n)=>ob(e,o=>o.recurrence===0?{now:t,input:r,output:n,recurrence:o.recurrence+1,elapsed:As,elapsedSincePrevious:As,start:t}:{now:t,input:r,output:n,recurrence:o.recurrence+1,elapsed:Ki(t-o.start),elapsedSincePrevious:Ki(t-o.now),start:o.start}),i5=class{schedule;ref;[c5]=f0t;constructor(t,r){this.schedule=t,this.ref=r}get state(){return te(io(this.ref),t=>t[1])}get last(){return O(io(this.ref),([t,r])=>{switch(t._tag){case"None":return pc(()=>new Es);case"Some":return M(t.value)}})}iterationMeta=QA(n5);get reset(){return Pa(this.ref,[W(),this.schedule.initial]).pipe($E(Pa(this.iterationMeta,n5)))}next(t){return C(te(io(this.ref),r=>r[1]),O(r=>C(zm,O(n=>C(ye(()=>this.schedule.step(n,t,r)),O(([o,i,s])=>{let a=Pa(this.ref,[H(i),o]);if(fi(s))return a.pipe(je(ut(W())));let c=GA(s.intervals)-n;if(c<=0)return a.pipe(je(eQe(this.iterationMeta,n,t,i)),Zt(i));let u=Ki(c);return C(a,je(eQe(this.iterationMeta,n,t,i)),je(Jm(u)),Zt(i))}))))))}},mr=(e,t)=>new o5(e,t),E$=x(2,(e,t)=>u5(e,r=>V(()=>t(r)))),u5=x(2,(e,t)=>LT(e,(r,n)=>te(t(r),o=>VF(n,At(o))))),rQe=x(2,(e,t)=>vi(l5(e,t),vw)),l5=x(2,(e,t)=>mr([e.initial,t.initial,!0],(r,n,o)=>o[2]?O(e.step(r,n,o[0]),([i,s,a])=>fi(a)?te(t.step(r,n,o[1]),([c,u,l])=>[[i,c,!1],Le(u),l]):M([[i,o[1],!0],Re(s),a])):te(t.step(r,n,o[1]),([i,s,a])=>[[o[0],i,!1],Le(s),a]))),nQe=x(2,(e,t)=>vi(e,()=>t)),b$=e=>vi(e,yi),oQe=x(2,(e,t)=>mr([e.initial,t.initial],(r,[n,o],i)=>Zi(e.step(r,n,i[0]),t.step(r,o,i[1]),([s,a,c],[u,l,d])=>{if(ih(c)&&ih(d)){let f=C(c.intervals,l8(d.intervals));return[[s,u],[a,l],Ab(f)]}return[[s,u],[a,l],Mu]}))),e0=x(2,(e,t)=>Cb(e,(r,n)=>V(()=>t(r,n)))),Cb=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>fi(a)?M([i,s,Mu]):te(t(n,s),c=>c?[i,s,a]:[i,s,Mu])))),iQe=()=>wb(dh()),wb=e=>I$(e,Ut(),(t,r)=>C(t,$s(r))),sQe=e=>wb(g5(e)),aQe=e=>wb(A5(e)),cQe=e=>wb(x5(e)),uQe=e=>wb(E5(e)),lQe=x(2,(e,t)=>mr([e.initial,t.initial],(r,n,o)=>O(e.step(r,n,o[0]),([i,s,a])=>te(t.step(r,s,o[1]),([c,u,l])=>fi(a)?[[i,c],u,Mu]:fi(l)?[[i,c],u,Mu]:[[i,c],u,Ab(C(a.intervals,HBe(l.intervals)))])))),d5=x(2,(e,t)=>S$(e,r=>V(()=>t(r)))),dQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>kA(e.step(r,n,o),t))),S$=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(t(n),i=>e.step(r,i,o)))),fQe=(e,t)=>{let r=e5(e)?Le(e):VDe(e,t);return mr([!0,[Number.MIN_SAFE_INTEGER,0,0]],(n,o,[i,s])=>{if(n<s[0])return M([[!1,s],[s[1],s[2]],qo(Ks(s[1],s[2]))]);if(xr(r))return Ci(r.left);let a=r.right,c=new Date(n),u;i&&YDe(a,c)&&(u=n),u=JDe(a,c).getTime();let l=R5(u),d=XQe(u);return M([[!1,[u,l,d]],[l,d],qo(Ks(l,d))])})},pQe=e=>mr([Number.NEGATIVE_INFINITY,0],(t,r,n)=>{if(!Number.isInteger(e)||e<1||31<e)return Ta(()=>new vu(`Invalid argument in: dayOfMonth(${e}). Must be in range 1...31`));let o=n[1],s=x0t(t,e,o===0),a=_5(s),c=rOe(s),u=Ks(a,c);return M([[c,o+1],o,qo(u)])}),mQe=e=>mr([Number.MIN_SAFE_INTEGER,0],(t,r,n)=>{if(!Number.isInteger(e)||e<1||7<e)return Ta(()=>new vu(`Invalid argument in: dayOfWeek(${e}). Must be in range 1 (Monday)...7 (Sunday)`));let o=n[1],s=y0t(t,e,o===0),a=_5(s),c=rOe(s),u=Ks(a,c);return M([[c,o+1],o,qo(u)])}),hQe=x(2,(e,t)=>C$(e,r=>V(()=>t(r)))),C$=x(2,(e,t)=>LT(e,(r,n)=>t(n))),MT=e=>E$(e,t=>t),gQe=e=>mr(e.initial,(t,r,n)=>C(e.step(t,r,n),O(([o,i,s])=>fi(s)?M([o,As,s]):M([o,Ki(GA(s.intervals)-t),s])))),AQe=x(2,(e,{onInput:t,onOutput:r})=>vi(d5(e,t),r)),yQe=x(2,(e,{onInput:t,onOutput:r})=>w$(S$(e,t),r)),FT=e=>C(rb([W(),e.initial]),te(t=>new i5(e,t))),f5=e=>{let t=At(e),r=Io(t);return mr(!0,(n,o,i)=>M(i?[!1,t,qo(dd(n+r))]:[!1,As,Mu]))},xQe=x(2,(e,t)=>C5(e,t)),EQe=x(3,(e,t,r)=>k$(e,t,r)),bQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>fi(a)?Zt(t,[i,s,a]):M([i,s,a])))),SQe=(e,t=2)=>{let r=At(e);return MT(vi(fd,n=>zF(r,Math.pow(t,n))))},CQe=e=>{let t=At(e);return MT(C(UT([t,t],([r,n])=>[n,VF(r,n)]),vi(r=>r[0])))},wQe=e=>{let t=At(e),r=Io(t);return mr([W(),0],(n,o,[i,s])=>V(()=>{switch(i._tag){case"None":return[[H([n,n+r]),s+1],s,qo(dd(n+r))];case"Some":{let[a,c]=i.value,u=n>c+r,l=ce(t,As)?t:Ki(r-(n-a)%r),d=ce(l,As)?t:l,f=u?n:n+Io(d);return[[H([a,f]),s+1],s,qo(dd(f))]}}}))},IQe=e=>f5(e),kQe=(e,...t)=>mr([[e,...t].map(r=>At(r)),!0],(r,n,[o,i])=>V(()=>{if(i){let s=o[0],a=dd(r+Io(s));if(o.length>=2)return[[o.slice(1),!0],s,qo(a)];let c=o.slice(1);return[[[s,...c],!1],s,qo(a)]}return[[o,!1],As,Mu]})),vQe=e=>vi(dh(),e),RQe=e=>mr([Number.NEGATIVE_INFINITY,0],(t,r,n)=>{if(!Number.isInteger(e)||e<0||23<e)return Ta(()=>new vu(`Invalid argument in: hourOfDay(${e}). Must be in range 0...23`));let o=n[1],s=A0t(t,e,o===0),a=tOe(s),c=g0t(s),u=Ks(a,c);return M([[c,o+1],o,qo(u)])}),dh=()=>mr(void 0,(e,t,r)=>M([r,t,qo(dd(e))])),ZA=x(2,(e,t)=>p5(e,t,LBe)),p5=x(3,(e,t,r)=>mr([e.initial,t.initial],(n,o,i)=>C(Zi(e.step(n,o,i[0]),t.step(n,o,i[1]),(s,a)=>[s,a]),O(([[s,a,c],[u,l,d]])=>ih(c)&&ih(d)?s5(e,t,o,s,a,c.intervals,u,l,d.intervals,r):M([[s,u],[a,l],Mu]))))),s5=(e,t,r,n,o,i,s,a,c,u)=>{let l=u(i,c);return $Be(l)?M([[n,s],[o,a],Ab(l)]):C(i,UBe(c))?O(e.step(PU(i),r,n),([d,f,p])=>fi(p)?M([[d,s],[f,a],Mu]):s5(e,t,r,d,f,p.intervals,s,a,c,u)):O(t.step(PU(c),r,s),([d,f,p])=>fi(p)?M([[n,d],[o,f],Mu]):s5(e,t,r,n,o,i,d,f,p.intervals,u))},_Qe=e=>m5(e,{min:.8,max:1.2}),m5=x(2,(e,t)=>{let{max:r,min:n}=Object.assign({min:.8,max:1.2},t);return C$(e,o=>te(ZDe,i=>{let s=Io(o),a=s*n*(1-i)+s*r*i;return Ki(a)}))}),BQe=e=>{let t=At(e);return MT(vi(fd,r=>zF(t,r+1)))},vi=x(2,(e,t)=>w$(e,r=>V(()=>t(r)))),w$=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>te(t(s),c=>[i,c,a])))),TQe=e=>mr([Number.MIN_SAFE_INTEGER,0],(t,r,n)=>{if(!Number.isInteger(e)||e<0||59<e)return Ta(()=>new vu(`Invalid argument in: minuteOfHour(${e}). Must be in range 0...59`));let o=n[1],s=h0t(t,e,o===0),a=eOe(s),c=m0t(s),u=Ks(a,c);return M([[c,o+1],o,qo(u)])}),DQe=x(2,(e,t)=>LT(e,(r,n)=>V(()=>t(r,n)))),LT=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>{if(fi(a))return M([i,s,a]);let c=a.intervals,u=BBe(Ks(r,GA(c)));return te(t(s,u),l=>{let d=At(l),f=GA(c),p=r+Io(d),m=p-f,g=Math.max(0,PU(c)+m),A=Ks(p,g);return[i,s,qo(A)]})}))),QQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>Zt(t(s,a),[i,s,a])))),h5=e=>mr(e.initial,(t,r,n)=>C(e.step(t,r,n),te(([o,i,s])=>[o,r,s]))),OQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>zs(e.step(r,n,o),t))),NQe=x(3,(e,t,r)=>mr(e.initial,(n,o,i)=>xc(s=>zs(e.step(n,o,i),zt(s,t,r))))),g5=e=>w5(dh(),e),A5=e=>$T(dh(),e),PQe=e=>I5(vi(dh(),e),pt),y5=e=>{let t=At(e);return v$(_$,r=>i3(r,t))},x5=e=>k5(dh(),e),E5=e=>HT(dh(),e),t0=e=>v$(fd,t=>t<e),I$=x(3,(e,t,r)=>b5(e,t,(n,o)=>V(()=>r(n,o)))),b5=x(3,(e,t,r)=>mr([e.initial,t],(n,o,[i,s])=>O(e.step(n,o,i),([a,c,u])=>fi(u)?M([[a,s],s,u]):te(r(s,c),l=>[[a,l],s,u])))),MQe=e=>I$(e,0,(t,r)=>t+1),FQe=x(2,(e,t)=>{let r=At(t);return C(e,ZA(_$),S5(([,n])=>$_(n,r)),vi(n=>n[0]))}),S5=x(2,(e,t)=>mr(e.initial,(r,n,o)=>O(e.step(r,n,o),([i,s,a])=>t(s)?e.step(r,n,e.initial):M([i,s,a])))),LQe=x(3,(e,t,r)=>C(UQe(e,t,Co(r),e.initial,Ut()),te(n=>gs(n)))),UQe=(e,t,r,n,o)=>{if(!kr(r))return M(o);let i=Gt(r),s=Ur(r);return O(e.step(t,i,n),([a,c,u])=>fi(u)?V(()=>C(o,fr(c))):UQe(e,GA(u.intervals),s,a,fr(o,c)))},$Qe=e=>mr([Number.NEGATIVE_INFINITY,0],(t,r,n)=>{if(!Number.isInteger(e)||e<0||59<e)return Ta(()=>new vu(`Invalid argument in: secondOfMinute(${e}). Must be in range 0...59`));let o=n[1],s=p0t(t,e,o===0),a=R5(s),c=XQe(s),u=Ks(a,c);return M([[c,o+1],o,qo(u)])}),HQe=e=>E$(fd,()=>e),WQe=e=>vi(fd,()=>e),jQe=e=>vi(fd,e),qQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>je(t(n),e.step(r,n,o)))),GQe=x(2,(e,t)=>mr(e.initial,(r,n,o)=>jo(e.step(r,n,o),([,i])=>t(i)))),UT=(e,t)=>mr(e,(r,n,o)=>V(()=>[t(o),o,qo(dd(r))])),C5=x(2,(e,t)=>k$(e,t,l8)),k$=x(3,(e,t,r)=>mr([e.initial,t.initial],(n,o,i)=>Zi(e.step(n,o,i[0]),t.step(n,o,i[1]),([s,a,c],[u,l,d])=>{if(fi(c)&&fi(d))return[[s,u],[a,l],Mu];if(fi(c)&&ih(d))return[[s,u],[a,l],Ab(d.intervals)];if(ih(c)&&fi(d))return[[s,u],[a,l],Ab(c.intervals)];if(ih(c)&&ih(d)){let f=r(c.intervals,d.intervals);return[[s,u],[a,l],Ab(f)]}throw new Error("BUG: Schedule.unionWith - please report an issue at https://github.com/Effect-TS/effect/issues")}))),w5=x(2,(e,t)=>e0(e,(r,n)=>!t(r))),$T=x(2,(e,t)=>Cb(e,(r,n)=>qB(t(r)))),I5=x(2,(e,t)=>e0(e,(r,n)=>!t(n))),zQe=x(2,(e,t)=>Cb(e,(r,n)=>qB(t(n)))),VQe=x(2,(e,t)=>v5(e,y5(t))),k5=x(2,(e,t)=>e0(e,(r,n)=>t(r))),HT=x(2,(e,t)=>Cb(e,(r,n)=>t(r))),v$=x(2,(e,t)=>e0(e,(r,n)=>t(n))),YQe=x(2,(e,t)=>Cb(e,(r,n)=>t(n))),JQe=e=>{let t=At(e),r=Io(t);return mr([W(),0],(n,o,[i,s])=>{switch(i._tag){case"None":return M([[H(n),s+1],s,qo(dd(n+r))]);case"Some":return M([[H(i.value),s+1],s,qo(dd(n+(r-(n-i.value)%r)))])}})},v5=x(2,(e,t)=>vi(ZA(e,t),r=>r[0])),KQe=x(2,(e,t)=>vi(ZA(e,t),r=>r[1])),ZQe=x(3,(e,t,r)=>vi(ZA(e,t),([n,o])=>r(n,o))),R5=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),0).getTime()},XQe=e=>{let t=new Date(R5(e));return t.setSeconds(t.getSeconds()+1)},p0t=(e,t,r)=>{let n=new Date(e);if(n.getSeconds()===t&&r)return e;if(n.getSeconds()<t)return n.setSeconds(t);let o=new Date(n.setSeconds(t));return o.setTime(o.getTime()+1e3*60)},eOe=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),0,0).getTime()},m0t=e=>{let t=new Date(eOe(e));return t.setMinutes(t.getMinutes()+1)},h0t=(e,t,r)=>{let n=new Date(e);if(n.getMinutes()===t&&r)return e;if(n.getMinutes()<t)return n.setMinutes(t);let o=new Date(n.setMinutes(t));return o.setTime(o.getTime()+1e3*60*60)},tOe=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),0,0,0).getTime()},g0t=e=>{let t=new Date(tOe(e));return t.setHours(t.getHours()+1)},A0t=(e,t,r)=>{let n=new Date(e);if(n.getHours()===t&&r)return e;if(n.getHours()<t)return n.setHours(t);let o=new Date(n.setHours(t));return o.setTime(o.getTime()+1e3*60*60*24)},_5=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0).getTime()},rOe=e=>{let t=new Date(_5(e));return t.setDate(t.getDate()+1)},y0t=(e,t,r)=>{let n=new Date(e);if(n.getDay()===t&&r)return e;let o=(7+t-n.getDay())%7;return n.setDate(n.getDate()+(o===0?7:o))},x0t=(e,t,r)=>{let n=new Date(e);return n.getDate()===t&&r?e:n.getDate()<t?n.setDate(t):nOe(e,t,1)},nOe=(e,t,r)=>{let n=new Date(e),o=new Date(n.setDate(t));if(new Date(o.setMonth(o.getMonth()+r)).getDate()===t){let s=new Date(e),a=new Date(s.setDate(t));return a.setMonth(a.getMonth()+r)}return nOe(e,t,r+1)},g$=Symbol.for("effect/Schedule/ScheduleDefect"),a5=class{error;[g$];constructor(t){this.error=t,this[g$]=g$}},E0t=e=>se(e,g$),A$=e=>fc(e,t=>Ci(new a5(t))),b0t=e=>wt(oA(e,t=>QE(t)&&E0t(t.defect)?H(t.defect):W()),{onNone:()=>e,onSome:t=>zl(t.error)}),WT=e=>Bf(e,t=>kt(b0t(t))),tQe=x(2,(e,t)=>B5(e,t,(r,n)=>ut(r))),oOe=x(2,(e,t)=>{if(x$(t))return tQe(e,t);let r=t.schedule??h5(fd),n=t.while?HT(r,s=>{let a=t.while(s);return typeof a=="boolean"?M(a):A$(a)}):r,o=t.until?$T(n,s=>{let a=t.until(s);return typeof a=="boolean"?M(a):A$(a)}):n,i=t.times?ZA(o,t0(t.times)).pipe(vi(s=>s[0])):o;return WT(tQe(e,i))}),B5=x(3,(e,t,r)=>O(FT(t),n=>Ho(e,{onFailure:o=>r(o,W()),onSuccess:o=>iOe(FA(e,Sb,io(n.iterationMeta)),n,(i,s)=>FA(r(i,s),Sb,io(n.iterationMeta)),o)}))),iOe=(e,t,r,n)=>Ho(t.next(n),{onFailure:()=>UE(t.last),onSuccess:o=>Ho(e,{onFailure:i=>r(i,H(o)),onSuccess:i=>iOe(e,t,r,i)})}),PT=x(2,(e,t)=>T5(e,t,(r,n)=>ut(r))),sOe=x(2,(e,t)=>x$(t)?PT(e,t):WT(PT(e,R$(t)))),R$=e=>{let t=e.schedule??fd,r=e.while?HT(t,o=>{let i=e.while(o);return typeof i=="boolean"?M(i):A$(i)}):t,n=e.until?$T(r,o=>{let i=e.until(o);return typeof i=="boolean"?M(i):A$(i)}):r;return e.times!==void 0?ZA(n,t0(e.times)):n},T5=x(3,(e,t,r)=>O(FT(t),n=>aOe(FA(e,Sb,io(n.iterationMeta)),n,(o,i)=>FA(r(o,i),Sb,io(n.iterationMeta))))),aOe=(e,t,r)=>fc(e,n=>Ho(t.next(n),{onFailure:()=>C(t.last,UE,O(o=>r(n,o))),onSuccess:()=>aOe(e,t,r)})),D5=x(2,(e,t)=>Q5(e,void 0,t)),Q5=x(3,(e,t,r)=>O(FT(r),n=>cOe(FA(e,Sb,io(n.iterationMeta)),t,n))),cOe=(e,t,r)=>Ho(r.next(t),{onFailure:()=>UE(r.last),onSuccess:()=>O(e,n=>cOe(e,n,r))}),uOe=UT(0,e=>e+1),_$=mr(W(),(e,t,r)=>{switch(r._tag){case"None":return M([H(e),As,qo(dd(e))]);case"Some":return M([H(r.value),Ki(e-r.value),qo(dd(e))])}}),fd=UT(0,e=>e+1),B$=b$(t0(1)),lOe=b$(t0(0)),dOe=x(2,(e,t)=>HU(D5(e,t)))});var pOe,mOe,fOe,N5=h(()=>{bi();oe();vt();DT();T$();pOe=Symbol.for("effect/ExecutionPlan"),mOe=x(2,(e,t)=>ye(()=>{let r=0,n;return O(yA({while:()=>r<t.steps.length&&(n===void 0||xr(n)),body:()=>{let o=t.steps[r],i=l$(e,o.provide);if(n){let s=!1,a=i;i=ye(()=>s?a:(s=!0,n)),i=WT(PT(i,fOe(o,!1)))}else{let s=fOe(o,!0);i=s?WT(PT(i,s)):i}return wu(i)},step:o=>{n=o,r++}}),()=>n)})),fOe=(e,t)=>{if(t){if(e.attempts===1||!(e.schedule||e.attempts))return}else return R$({schedule:e.schedule?e.schedule:e.attempts?void 0:B$,times:e.attempts,while:e.while});return R$({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})}});var Or={};tr(Or,{DeferredTypeId:()=>fh,await:()=>Ht,complete:()=>jT,completeWith:()=>C0t,die:()=>k0t,dieSync:()=>v0t,done:()=>P5,fail:()=>D$,failCause:()=>pd,failCauseSync:()=>I0t,failSync:()=>w0t,interrupt:()=>r0,interruptWith:()=>R0t,isDone:()=>ph,make:()=>rn,makeAs:()=>S0t,poll:()=>gOe,succeed:()=>pi,sync:()=>_0t,unsafeDone:()=>kc,unsafeMake:()=>Q$});var fh,rn,S0t,Ht,jT,C0t,P5,D$,w0t,pd,I0t,k0t,v0t,r0,R0t,ph,gOe,pi,_0t,Q$,kc,$u=h(()=>{vt();z3();fh=SL,rn=wi,S0t=uK,Ht=Cn,jT=HL,C0t=yc,P5=lK,D$=Qwe,w0t=Owe,pd=iI,I0t=Nwe,k0t=Pwe,v0t=Mwe,r0=Fwe,R0t=EB,ph=Lwe,gOe=Uwe,pi=Mm,_0t=$we,Q$=wA,kc=IA});var AOe,B0t,T0t,yOe,M5,O$,xOe,EOe,D0t,F5=h(()=>{oe();ht();Me();AOe=Symbol.for("effect/MutableList"),B0t={[AOe]:AOe,[Symbol.iterator](){let e=!1,t=this.head;return{next(){if(e)return this.return();if(t==null)return e=!0,this.return();let r=t.value;return t=t.next,{done:e,value:r}},return(r){return e||(e=!0),{done:!0,value:r}}}},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"MutableList",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},T0t=e=>({value:e,removed:!1,prev:void 0,next:void 0}),yOe=()=>{let e=Object.create(B0t);return e.head=void 0,e.tail=void 0,e._length=0,e},M5=e=>O$(e)===0,O$=e=>e._length,xOe=x(2,(e,t)=>{let r=T0t(t);return e.head===void 0&&(e.head=r),e.tail===void 0||(e.tail.next=r,r.prev=e.tail),e.tail=r,e._length+=1,e}),EOe=e=>{let t=e.head;if(t!==void 0)return D0t(e,t),t.value},D0t=(e,t)=>{t.removed||(t.removed=!0,t.prev!==void 0&&t.next!==void 0?(t.prev.next=t.next,t.next.prev=t.prev):t.prev!==void 0?(e.tail=t.prev,t.prev.next=void 0):t.next!==void 0?(e.head=t.next,t.next.prev=void 0):(e.tail=void 0,e.head=void 0),e._length>0&&(e._length-=1))}});var SOe,mi,Q0t,COe,N$,n0,P$,M$,wOe,XA,L5,md,F$,L$=h(()=>{vr();oe();ht();F5();Me();SOe=Symbol.for("effect/MutableQueue"),mi=Symbol.for("effect/mutable/MutableQueue/Empty"),Q0t={[SOe]:SOe,[Symbol.iterator](){return Array.from(this.queue)[Symbol.iterator]()},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"MutableQueue",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},COe=e=>{let t=Object.create(Q0t);return t.queue=yOe(),t.capacity=e,t},N$=e=>COe(e),n0=()=>COe(void 0),P$=e=>O$(e.queue),M$=e=>M5(e.queue),wOe=e=>e.capacity===void 0?1/0:e.capacity,XA=x(2,(e,t)=>{let r=O$(e.queue);return e.capacity!==void 0&&r===e.capacity?!1:(xOe(t)(e.queue),!0)}),L5=x(2,(e,t)=>{let r=t[Symbol.iterator](),n,o=Ut(),i=!0;for(;i&&(n=r.next())&&!n.done;)i=XA(n.value)(e);for(;n!=null&&!n.done;)o=fr(n.value)(o),n=r.next();return gs(o)}),md=x(2,(e,t)=>M5(e.queue)?t:EOe(e.queue)),F$=x(2,(e,t)=>{let r=Ut(),n=0;for(;n<t;){let o=md(mi)(e);if(o===mi)break;r=fr(o)(r),n+=1}return gs(r)})});var IOe,kOe,O0t,$5,H5,o0,N0t,W5,P0t,M0t,F0t,L0t,U0t,$0t,H0t,W0t,j0t,q0t,U$,j5,vOe,ROe=h(()=>{sr();$u();Ws();bi();mt();Ro();oe();ir();iT();L$();Kl();it();ct();$f();vt();Vw();oL();IOe=(e,t,r,n)=>zw({_tag:"Complete",key:e,exit:t,entryStats:r,timeToLiveMillis:n}),kOe=(e,t)=>zw({_tag:"Pending",key:e,deferred:t}),O0t=(e,t)=>zw({_tag:"Refreshing",deferred:e,complete:t}),$5=Symbol.for("effect/Cache/MapKey"),H5=class{current;[$5]=$5;previous=void 0;next=void 0;constructor(t){this.current=t}[he](){return C(ae(this.current),we(ae(this.previous)),we(ae(this.next)),We(this))}[me](t){return this===t?!0:N0t(t)&&ce(this.current,t.current)&&ce(this.previous,t.previous)&&ce(this.next,t.next)}},o0=e=>new H5(e),N0t=e=>se(e,$5),W5=class{head=void 0;tail=void 0;add(t){if(t!==this.tail)if(this.tail===void 0)this.head=t,this.tail=t;else{let r=t.previous,n=t.next;n!==void 0&&(t.next=void 0,r!==void 0?(r.next=n,n.previous=r):(this.head=n,this.head.previous=void 0)),this.tail.next=t,t.previous=this.tail,this.tail=t}}remove(){let t=this.head;if(t!==void 0){let r=t.next;r!==void 0?(t.next=void 0,this.head=r,this.head.previous=void 0):(this.head=void 0,this.tail=void 0)}return t}},P0t=()=>new W5,M0t=(e,t,r,n,o,i)=>({map:e,keys:t,accesses:r,updating:n,hits:o,misses:i}),F0t=()=>M0t(fb(),P0t(),n0(),Ba(!1),0,0),L0t="effect/Cache",U0t=Symbol.for(L0t),$0t={_Key:e=>e,_Error:e=>e,_Value:e=>e},H0t="effect/ConsumerCache",W0t=Symbol.for(H0t),j0t={_Key:e=>e,_Error:e=>e,_Value:e=>e},q0t=e=>e,U$=e=>({loadedMillis:e}),j5=class{capacity;context;fiberId;lookup;timeToLive;[U0t]=$0t;[W0t]=j0t;cacheState;constructor(t,r,n,o,i){this.capacity=t,this.context=r,this.fiberId=n,this.lookup=o,this.timeToLive=i,this.cacheState=F0t()}get(t){return te(this.getEither(t),vw)}get cacheStats(){return V(()=>q0t({hits:this.cacheState.hits,misses:this.cacheState.misses,size:pU(this.cacheState.map)}))}getOption(t){return ye(()=>wt(_o(this.cacheState.map,t),{onNone:()=>{let r=o0(t);return this.trackAccess(r),this.trackMiss(),M(W())},onSome:r=>this.resolveMapValue(r)}))}getOptionComplete(t){return ye(()=>wt(_o(this.cacheState.map,t),{onNone:()=>{let r=o0(t);return this.trackAccess(r),this.trackMiss(),M(W())},onSome:r=>this.resolveMapValue(r,!0)}))}contains(t){return V(()=>cd(this.cacheState.map,t))}entryStats(t){return V(()=>{let r=_o(this.cacheState.map,t);if(pt(r))switch(r.value._tag){case"Complete":{let n=r.value.entryStats.loadedMillis;return H(U$(n))}case"Pending":return W();case"Refreshing":{let n=r.value.complete.entryStats.loadedMillis;return H(U$(n))}}return W()})}getEither(t){return ye(()=>{let r=t,n,o,i=Gr(_o(this.cacheState.map,r));return i===void 0&&(o=Q$(this.fiberId),n=o0(r),cd(this.cacheState.map,r)?i=Gr(_o(this.cacheState.map,r)):Ma(this.cacheState.map,r,kOe(n,o))),i===void 0?(this.trackAccess(n),this.trackMiss(),te(this.lookupValueOf(t,o),Le)):O(this.resolveMapValue(i),wt({onNone:()=>this.getEither(t),onSome:s=>M(Re(s))}))})}invalidate(t){return V(()=>{pb(this.cacheState.map,t)})}invalidateWhen(t,r){return V(()=>{let n=_o(this.cacheState.map,t);pt(n)&&n.value._tag==="Complete"&&n.value.exit._tag==="Success"&&r(n.value.exit.value)&&pb(this.cacheState.map,t)})}get invalidateAll(){return V(()=>{this.cacheState.map=fb()})}refresh(t){return Uf(r=>ye(()=>{let n=t,o=Q$(this.fiberId),i=Gr(_o(this.cacheState.map,n));if(i===void 0&&(cd(this.cacheState.map,n)?i=Gr(_o(this.cacheState.map,n)):Ma(this.cacheState.map,n,kOe(o0(n),o))),i===void 0)return $r(this.lookupValueOf(t,o));switch(i._tag){case"Complete":{if(this.hasExpired(r,i.timeToLiveMillis)){let s=Gr(_o(this.cacheState.map,n));return ce(s,i)&&pb(this.cacheState.map,n),$r(this.get(t))}return C(this.lookupValueOf(t,o),V1(()=>{let s=Gr(_o(this.cacheState.map,n));if(ce(s,i)){let a=O0t(o,i);return Ma(this.cacheState.map,n,a),!0}return!1}),$r)}case"Pending":return Ht(i.deferred);case"Refreshing":return Ht(i.deferred)}}))}set(t,r){return Uf(n=>V(()=>{let o=n.unsafeCurrentTimeMillis(),i=t,s=vo(r),a=IOe(o0(i),s,U$(o),o+Io(At(this.timeToLive(s))));Ma(this.cacheState.map,i,a)}))}get size(){return V(()=>pU(this.cacheState.map))}get values(){return V(()=>{let t=[];for(let r of this.cacheState.map)r[1]._tag==="Complete"&&r[1].exit._tag==="Success"&&t.push(r[1].exit.value);return t})}get entries(){return V(()=>{let t=[];for(let r of this.cacheState.map)r[1]._tag==="Complete"&&r[1].exit._tag==="Success"&&t.push([r[0],r[1].exit.value]);return t})}get keys(){return V(()=>{let t=[];for(let r of this.cacheState.map)r[1]._tag==="Complete"&&r[1].exit._tag==="Success"&&t.push(r[0]);return t})}resolveMapValue(t,r=!1){return Uf(n=>{switch(t._tag){case"Complete":return this.trackAccess(t.key),this.hasExpired(n,t.timeToLiveMillis)?(pb(this.cacheState.map,t.key.current),M(W())):(this.trackHit(),te(t.exit,H));case"Pending":return this.trackAccess(t.key),this.trackHit(),r?M(W()):te(Ht(t.deferred),H);case"Refreshing":return this.trackAccess(t.complete.key),this.trackHit(),this.hasExpired(n,t.complete.timeToLiveMillis)?r?M(W()):te(Ht(t.deferred),H):te(t.complete.exit,H)}})}trackHit(){this.cacheState.hits=this.cacheState.hits+1}trackMiss(){this.cacheState.misses=this.cacheState.misses+1}trackAccess(t){if(XA(this.cacheState.accesses,t),JF(this.cacheState.updating,!1,!0)){let r=!0;for(;r;){let o=md(this.cacheState.accesses,mi);o===mi?r=!1:this.cacheState.keys.add(o)}let n=pU(this.cacheState.map);for(r=n>this.capacity;r;){let o=this.cacheState.keys.remove();o!==void 0?cd(this.cacheState.map,o.current)&&(pb(this.cacheState.map,o.current),n=n-1,r=n>this.capacity):r=!1}js(this.cacheState.updating,!1)}}hasExpired(t,r){return t.unsafeCurrentTimeMillis()>r}lookupValueOf(t,r){return Uf(n=>ye(()=>{let o=t;return C(this.lookup(t),zs(this.context),fn,O(i=>{let s=n.unsafeCurrentTimeMillis(),a=U$(s),c=IOe(o0(o),i,a,s+Io(At(this.timeToLive(i))));return Ma(this.cacheState.map,o,c),je(P5(r,i),i)}),hc(()=>je(r0(r),V(()=>{pb(this.cacheState.map,o)}))))}))}},vOe=(e,t,r)=>new j5(e,ro(),j_,t,n=>At(r(n)))});var i0,qT,_Oe,BOe,TOe,DOe,q5=h(()=>{Ws();oe();yn();j3();ROe();vt();La();hU();i0=Te(Symbol.for("effect/FiberRef/currentCache"),()=>pn(vOe(65536,()=>te(wi(),e=>({listeners:new DI,handle:e})),()=>sA(60)))),qT=Te(Symbol.for("effect/FiberRef/currentCacheEnabled"),()=>pn(!1)),_Oe=(e,t)=>O(ar(t)?t:M(t),r=>Da(n=>{let o=new Proxy(e,{});return ui(qT,i=>{if(i){let a=ui(i0,c=>O(c.getEither(o),u=>{switch(u._tag){case"Left":return u.left.listeners.interrupted?O(c.invalidateWhen(o,l=>l.handle===u.left.handle),()=>a):(u.left.listeners.increment(),xn(l=>O(fn(Qm(DCe,l(Cn(u.left.handle)))),d=>(u.left.listeners.decrement(),d))));case"Right":return u.right.listeners.increment(),xn(l=>O(fn(Qm(H3(r,W3({request:o,result:u.right.handle,listeners:u.right.listeners,ownerId:n,state:{completed:!1}})),l(Cn(u.right.handle)))),()=>(u.right.listeners.decrement(),Cn(u.right.handle))))}}));return a}let s=new DI;return s.increment(),O(wi(),a=>Js(Qm(H3(r,W3({request:o,result:a,listeners:s,ownerId:n,state:{completed:!1}})),Cn(a)),V(()=>s.decrement())))})})),BOe=(e,t)=>ui(qT,r=>r?ui(i0,n=>O(n.getEither(e),o=>{switch(o._tag){case"Left":return Ue;case"Right":return HL(o.right.handle,t)}})):Ue),TOe=x(2,(e,t)=>tn(e,qT,t)),DOe=x(2,(e,t)=>tn(e,i0,t))});var OOe,G5=h(()=>{hU();OOe=o_e});var S={};tr(S,{Do:()=>$vt,EffectTypeId:()=>G0t,Service:()=>$_t,Tag:()=>U_t,acquireRelease:()=>zo,acquireReleaseInterruptible:()=>qkt,acquireUseRelease:()=>c0,addFinalizer:()=>YT,all:()=>Ib,allSuccesses:()=>Z0t,allWith:()=>K0t,allowInterrupt:()=>Dkt,andThen:()=>iRt,annotateCurrentSpan:()=>I_t,annotateLogs:()=>V$,annotateLogsScoped:()=>NRt,annotateSpans:()=>w_t,ap:()=>u_t,as:()=>ju,asSome:()=>GOe,asSomeError:()=>Lkt,asVoid:()=>gd,async:()=>Zs,asyncEffect:()=>pkt,awaitAllChildren:()=>Zkt,bind:()=>Hvt,bindAll:()=>Wvt,bindTo:()=>jvt,blocked:()=>l_t,cacheRequestResult:()=>m_t,cached:()=>GT,cachedFunction:()=>Y0t,cachedInvalidateWithTTL:()=>V0t,cachedWithTTL:()=>z0t,catch:()=>ykt,catchAll:()=>s0,catchAllCause:()=>Hu,catchAllDefect:()=>xkt,catchIf:()=>Ekt,catchSome:()=>bkt,catchSomeCause:()=>qOe,catchSomeDefect:()=>Skt,catchTag:()=>W$,catchTags:()=>j$,cause:()=>Ckt,checkInterruptible:()=>Qkt,clock:()=>zOe,clockWith:()=>Avt,configProviderWith:()=>Bvt,console:()=>Evt,consoleWith:()=>bvt,context:()=>ty,contextWith:()=>ZT,contextWithEffect:()=>Qvt,currentParentSpan:()=>R_t,currentPropagatedSpan:()=>v_t,currentSpan:()=>k_t,custom:()=>mkt,daemonChildren:()=>Xkt,delay:()=>wvt,descriptor:()=>evt,descriptorWith:()=>tvt,die:()=>Ua,dieMessage:()=>kb,dieSync:()=>jOe,diffFiberRefs:()=>rvt,disconnect:()=>Okt,dropUntil:()=>z5,dropWhile:()=>V5,either:()=>ny,ensureErrorType:()=>j_t,ensureRequirementsType:()=>q_t,ensureSuccessType:()=>W_t,ensuring:()=>qu,ensuringChild:()=>nvt,ensuringChildren:()=>ovt,eventually:()=>wkt,every:()=>ekt,exists:()=>tkt,exit:()=>so,fail:()=>$e,failCause:()=>Is,failCauseSync:()=>WOe,failSync:()=>HOe,fiberId:()=>ivt,fiberIdWith:()=>q$,filter:()=>LOe,filterEffectOrElse:()=>Zvt,filterEffectOrFail:()=>Xvt,filterMap:()=>rkt,filterOrDie:()=>Vvt,filterOrDieMessage:()=>Yvt,filterOrElse:()=>Jvt,filterOrFail:()=>Kvt,finalizersMask:()=>Ykt,findFirst:()=>UOe,firstSuccessOf:()=>HRt,flatMap:()=>Ee,flatten:()=>Vf,flip:()=>Ukt,flipWith:()=>$kt,fn:()=>H_t,fnUntraced:()=>Z$,forEach:()=>hi,forever:()=>ZOe,fork:()=>svt,forkAll:()=>avt,forkDaemon:()=>Rb,forkIn:()=>yd,forkScoped:()=>l0,forkWithErrorHandler:()=>cvt,fromFiber:()=>uvt,fromFiberEffect:()=>lvt,fromNullable:()=>P_t,functionWithSpan:()=>O_t,gen:()=>Go,getFiberRefs:()=>xRt,getRuntimeFlags:()=>zRt,head:()=>nkt,if:()=>zvt,ignore:()=>a0,ignoreLogged:()=>Ikt,inheritFiberRefs:()=>ERt,interrupt:()=>mh,interruptWith:()=>Nkt,interruptible:()=>Bo,interruptibleMask:()=>Pkt,intoDeferred:()=>f0,isEffect:()=>ws,isFailure:()=>vRt,isSuccess:()=>RRt,iterate:()=>fRt,labelMetrics:()=>ZRt,labelMetricsScoped:()=>e_t,let:()=>qvt,liftPredicate:()=>Fkt,linkSpanCurrent:()=>D_t,linkSpans:()=>T_t,locally:()=>p0,locallyScoped:()=>SRt,locallyScopedWith:()=>CRt,locallyWith:()=>bRt,log:()=>eNe,logAnnotations:()=>PRt,logDebug:()=>TRt,logError:()=>QRt,logFatal:()=>ORt,logInfo:()=>DRt,logTrace:()=>BRt,logWarning:()=>rX,logWithLevel:()=>_Rt,loop:()=>pRt,makeLatch:()=>n_t,makeSemaphore:()=>Y$,makeSpan:()=>nNe,makeSpanScoped:()=>Q_t,map:()=>De,mapAccum:()=>Hkt,mapBoth:()=>VT,mapError:()=>Ha,mapErrorCause:()=>Wkt,mapInputContext:()=>Ovt,match:()=>tX,matchCause:()=>oy,matchCauseEffect:()=>vc,matchEffect:()=>rD,merge:()=>jkt,mergeAll:()=>okt,metricLabels:()=>t_t,negate:()=>K5,never:()=>$$,none:()=>hkt,onError:()=>JT,onExit:()=>Gkt,onInterrupt:()=>Mkt,once:()=>J0t,option:()=>Gvt,optionFromOptional:()=>M_t,orDie:()=>Yf,orDieWith:()=>LRt,orElse:()=>nD,orElseFail:()=>URt,orElseSucceed:()=>$Rt,parallelErrors:()=>kkt,parallelFinalizers:()=>zkt,partition:()=>ikt,patchFiberRefs:()=>wRt,patchRuntimeFlags:()=>VRt,promise:()=>Y5,provide:()=>ry,provideService:()=>d0,provideServiceEffect:()=>eX,race:()=>eD,raceAll:()=>sRt,raceFirst:()=>KOe,raceWith:()=>tD,random:()=>WRt,randomWith:()=>jRt,reduce:()=>$Oe,reduceEffect:()=>ckt,reduceRight:()=>akt,reduceWhile:()=>skt,repeat:()=>z$,repeatN:()=>mRt,repeatOrElse:()=>hRt,replicate:()=>ukt,replicateEffect:()=>lkt,request:()=>p_t,retry:()=>J5,retryOrElse:()=>_kt,runCallback:()=>o_t,runFork:()=>m0,runPromise:()=>oX,runPromiseExit:()=>i_t,runRequestBlock:()=>d_t,runSync:()=>xd,runSyncExit:()=>s_t,runtime:()=>hh,sandbox:()=>vkt,schedule:()=>gRt,scheduleForked:()=>ARt,scheduleFrom:()=>yRt,scope:()=>u0,scopeWith:()=>Z5,scoped:()=>Ad,scopedWith:()=>KT,sequentialFinalizers:()=>Vkt,serviceConstants:()=>Fvt,serviceFunction:()=>Nvt,serviceFunctionEffect:()=>Pvt,serviceFunctions:()=>Mvt,serviceMembers:()=>Lvt,serviceOption:()=>G$,serviceOptional:()=>Uvt,setFiberRefs:()=>IRt,sleep:()=>Ivt,spanAnnotations:()=>__t,spanLinks:()=>B_t,step:()=>f_t,succeed:()=>nt,succeedNone:()=>H$,succeedSome:()=>gkt,summarized:()=>aRt,supervised:()=>dvt,suspend:()=>Pt,sync:()=>ot,tagMetrics:()=>KRt,tagMetricsScoped:()=>XRt,takeUntil:()=>X0t,takeWhile:()=>FOe,tap:()=>Ri,tapBoth:()=>cRt,tapDefect:()=>uRt,tapError:()=>lRt,tapErrorCause:()=>_b,tapErrorTag:()=>dRt,timed:()=>kvt,timedWith:()=>vvt,timeout:()=>X5,timeoutFail:()=>VOe,timeoutFailCause:()=>YOe,timeoutOption:()=>Rvt,timeoutTo:()=>_vt,tracer:()=>y_t,tracerWith:()=>x_t,transplant:()=>fvt,transposeMapOption:()=>L_t,transposeOption:()=>F_t,try:()=>Wu,tryMap:()=>zT,tryMapPromise:()=>Bkt,tryPromise:()=>ey,uninterruptible:()=>hd,uninterruptibleMask:()=>vb,unless:()=>eRt,unlessEffect:()=>tRt,unsafeMakeLatch:()=>J$,unsafeMakeSemaphore:()=>nX,unsandbox:()=>Tkt,updateFiberRefs:()=>kRt,updateService:()=>JOe,useSpan:()=>oNe,using:()=>Jkt,validate:()=>a_t,validateAll:()=>dkt,validateFirst:()=>fkt,validateWith:()=>c_t,void:()=>ve,when:()=>XT,whenEffect:()=>rRt,whenFiberRef:()=>nRt,whenLogLevel:()=>FRt,whenRef:()=>oRt,whileLoop:()=>XOe,withClock:()=>xvt,withClockScoped:()=>yvt,withConcurrency:()=>pvt,withConfigProvider:()=>Tvt,withConfigProviderScoped:()=>Dvt,withConsole:()=>Cvt,withConsoleScoped:()=>Svt,withEarlyRelease:()=>Kkt,withExecutionPlan:()=>Rkt,withFiberRuntime:()=>$a,withLogSpan:()=>tNe,withMaxOpsBeforeYield:()=>gvt,withMetric:()=>r_t,withParentSpan:()=>sNe,withRandom:()=>rNe,withRandomFixed:()=>qRt,withRandomScoped:()=>GRt,withRequestBatching:()=>h_t,withRequestCache:()=>A_t,withRequestCaching:()=>g_t,withRuntimeFlagsPatch:()=>YRt,withRuntimeFlagsPatchScoped:()=>JRt,withScheduler:()=>mvt,withSchedulingPriority:()=>hvt,withSpan:()=>iNe,withSpanScoped:()=>N_t,withTracer:()=>E_t,withTracerEnabled:()=>S_t,withTracerScoped:()=>b_t,withTracerTiming:()=>C_t,withUnhandledErrorLogLevel:()=>MRt,yieldNow:()=>Akt,zip:()=>Gu,zipLeft:()=>K$,zipRight:()=>Wt,zipWith:()=>gh});function POe(e,t){return Object.defineProperty(t,"length",{value:e,configurable:!0})}function MOe(e){let t,r;if(xEe(e.body))t=rB(()=>e.body.apply(e.self,e.args));else try{t=e.body.apply(e.self,e.args)}catch(s){r=s,t=Ua(s)}if(e.pipeables.length>0)try{for(let s of e.pipeables)t=s(t,...e.args)}catch(s){t=r?Is(Vr(eo(r),eo(s))):Ua(s)}let n=!1,o=()=>{if(n!==!1)return n;if(e.errorCall.stack){let s=e.errorDef.stack.trim().split(`
54
54
  `),a=e.errorCall.stack.trim().split(`
55
55
  `),c=s.slice(2).join(`
56
56
  `).trim();c.includes("(")||(c=c.replace(/at (.*)/,"at ($1)"));let u=a.slice(2).join(`
57
57
  `).trim();return u.includes("(")||(u=u.replace(/at (.*)/,"at ($1)")),n=`${c}
58
- ${u}`,n}},i=e.spanOptions&&"captureStackTrace"in e.spanOptions?e.spanOptions:{captureStackTrace:o,...e.spanOptions};return iNe(t,e.spanName,i)}var G0t,ws,z0t,V0t,GT,Y0t,J0t,Ib,K0t,Z0t,z5,V5,X0t,FOe,ekt,tkt,LOe,rkt,UOe,pi,nkt,okt,ikt,$Oe,skt,akt,ckt,ukt,lkt,dkt,fkt,Zs,pkt,mkt,$a,$e,HOe,Is,WOe,Ua,kb,jOe,Go,$$,hkt,Y5,nt,H$,gkt,Pt,ot,ve,Akt,ykt,s0,Hu,xkt,Ekt,bkt,qOe,Skt,W$,j$,Ckt,wkt,a0,Ikt,kkt,vkt,J5,Rkt,_kt,Wu,zT,Bkt,ey,Tkt,Dkt,Qkt,Okt,mh,Nkt,Bo,Pkt,Mkt,hd,vb,Fkt,ju,GOe,Lkt,gd,Ukt,$kt,De,Hkt,VT,Ha,Wkt,jkt,K5,zo,qkt,c0,YT,qu,JT,Gkt,zkt,Vkt,Ykt,u0,Z5,KT,Ad,Jkt,Kkt,Zkt,Xkt,evt,tvt,rvt,nvt,ovt,ivt,q$,svt,Rb,avt,yd,l0,cvt,uvt,lvt,dvt,fvt,pvt,mvt,hvt,gvt,zOe,Avt,yvt,xvt,Evt,bvt,Svt,Cvt,wvt,Ivt,kvt,vvt,X5,Rvt,VOe,YOe,_vt,Bvt,Tvt,Dvt,ty,ZT,Qvt,Ovt,ry,d0,eX,Nvt,Pvt,Mvt,Fvt,Lvt,G$,Uvt,JOe,$vt,Hvt,Wvt,jvt,qvt,Gvt,ny,so,f0,zvt,Vvt,Yvt,Jvt,Kvt,Zvt,Xvt,eRt,tRt,XT,rRt,nRt,oRt,Ee,iRt,Vf,eD,sRt,KOe,tD,aRt,Ri,cRt,uRt,lRt,dRt,_b,ZOe,fRt,pRt,z$,mRt,hRt,gRt,ARt,yRt,XOe,xRt,ERt,p0,bRt,SRt,CRt,wRt,IRt,kRt,vRt,RRt,tX,oy,vc,rD,eNe,_Rt,BRt,TRt,DRt,rX,QRt,ORt,tNe,V$,NRt,PRt,MRt,FRt,Yf,LRt,nD,URt,$Rt,HRt,WRt,jRt,rNe,qRt,GRt,hh,zRt,VRt,YRt,JRt,KRt,ZRt,XRt,e_t,t_t,r_t,nX,Y$,J$,n_t,m0,o_t,oX,i_t,xd,s_t,a_t,c_t,Gu,K$,Wt,gh,u_t,l_t,d_t,f_t,p_t,m_t,h_t,g_t,A_t,y_t,x_t,E_t,b_t,S_t,C_t,w_t,I_t,k_t,v_t,R_t,__t,B_t,T_t,D_t,nNe,Q_t,oNe,iNe,O_t,N_t,sNe,P_t,M_t,F_t,L_t,aNe,U_t,$_t,H_t,Z$,W_t,j_t,q_t,nr=h(()=>{oe();Jl();_De();F_();$f();vt();Mf();UI();N5();La();DT();h_();q5();JU();T$();_A();h$();G5();PA();mu();G0t=Om,ws=ar,z0t=nTe,V0t=y8,GT=q1,Y0t=cTe,J0t=DZ,Ib=qA,K0t=K_e,Z0t=Z_e,z5=cke,V5=uke,X0t=eve,FOe=tve,ekt=xke,tkt=V_e,LOe=J_e,rkt=dke,UOe=hke,pi=Ic,nkt=bke,okt=J9,ikt=K9,$Oe=G1,skt=Gke,akt=qke,ckt=nBe,ukt=Y9,lkt=X_e,dkt=tBe,fkt=cBe,Zs=bi,pkt=LTe,mkt=oB,$a=st,$e=ut,HOe=pc,Is=kt,WOe=Tf,Ua=Si,kb=fA,jOe=Ta,Go=uB,$$=xA,hkt=Fke,Y5=Wke,nt=M,H$=cb,gkt=Zke,Pt=ye,ot=V,ve=Ue,Akt=ku,ykt=J0e,s0=fc,Hu=Bf,xkt=K0e,Ekt=iB,bkt=jCe,qOe=Z0e,Skt=X0e,W$=eke,j$=tke,Ckt=rke,wkt=$B,a0=j1,Ikt=Ske,kkt=Hke,vkt=Jke,J5=sOe,Rkt=mOe,_kt=T5,Wu=RZ,zT=cve,Bkt=uve,ey=PZ,Tkt=fve,Dkt=oke,Qkt=qCe,Okt=yBe,mh=qs,Nkt=aB,Bo=Qa,Pkt=GCe,Mkt=hc,hd=Iu,vb=xn,Fkt=mke,ju=Zt,GOe=kI,Lkt=Y0e,gd=$r,Ukt=mA,$kt=yke,De=te,Hkt=Pke,VT=cB,Ha=hA,Wkt=_I,jkt=Mke,K5=qB,zo=gb,qkt=G_e,c0=_L,YT=ld,qu=Js,JT=QL,Gkt=Gs,zkt=CU,Vkt=wU,Ykt=oBe,u0=r8,Z5=Nu,KT=AT,Ad=IU,Jkt=sBe,Kkt=lBe,Zkt=rTe,Xkt=z_e,evt=ike,tvt=vI,rvt=RI,nvt=oTe,ovt=$U,ivt=td,q$=Da,svt=Ou,Rb=PI,avt=iTe,yd=bT,l0=HU,cvt=eBe,uvt=sTe,lvt=aTe,dvt=x8,fvt=OL,pvt=VCe,mvt=U0e,hvt=iK,gvt=awe,zOe=nke,Avt=Uf,yvt=e8,xvt=QIe,Evt=IDe,bvt=kDe,Svt=RDe,Cvt=vDe,wvt=FB,Ivt=Jm,kvt=sve,vvt=NZ,X5=lTe,Rvt=fTe,VOe=E8,YOe=dTe,_vt=ST,Bvt=NIe,Tvt=OIe,Dvt=kU,ty=Oa,ZT=lke,Qvt=xc,Ovt=kA,ry=l$,d0=MA,eX=FA,Nvt=yve,Pvt=Ave,Mvt=MZ,Fvt=FZ,Lvt=xve,G$=Eve,Uvt=LZ,JOe=pve,$vt=ske,Hvt=LB,Wvt=gTe,jvt=UB,qvt=ake,Gvt=Lke,ny=wu,so=fn,f0=Df,zvt=DL,Vvt=fke,Yvt=pke,Jvt=HB,Kvt=H1,Zvt=dK,Xvt=Hwe,eRt=lve,tRt=dve,XT=V1,rRt=AA,nRt=mve,oRt=hve,Ee=O,iRt=pA,Vf=ys,eD=BU,sRt=rBe,KOe=uTe,tD=n8,aRt=GB,Ri=jo,cRt=rve,uRt=nve,lRt=OZ,dRt=ove,_b=ive,ZOe=_Z,fRt=BZ,pRt=Qke,z$=oOe,mRt=Vke,hRt=B5,gRt=D5,ARt=dOe,yRt=Q5,XOe=yA,xRt=W1,ERt=Cke,p0=tn,bRt=no,SRt=Ss,CRt=ts,wRt=ab,IRt=Kke,kRt=z1,vRt=wke,RRt=Ike,tX=WB,oy=sB,vc=dn,rD=Ho,eNe=kke,_Rt=(e,...t)=>Ym(e)(...t),BRt=vke,TRt=TZ,DRt=Rke,rX=jB,QRt=_ke,ORt=Bke,tNe=Tke,V$=V0e,NRt=j_e,PRt=Dke,MRt=cwe,FRt=q_e,Yf=UE,LRt=eK,nD=LE,URt=Uke,$Rt=$ke,HRt=Ake,WRt=jke,jRt=lI,rNe=PIe,qRt=x(2,(e,t)=>rNe(e,XDe(t))),GRt=uBe,hh=GI,zRt=Zw,VRt=gA,YRt=NL,JRt=t8,KRt=Xke,ZRt=QZ,XRt=iBe,e_t=Z9,t_t=uwe,r_t=gve,nX=LI,Y$=eTe,J$=A8,n_t=tTe,m0=OTe,o_t=QTe,oX=NTe,i_t=PTe,xd=MTe,s_t=FTe,a_t=aBe,c_t=X9,Gu=dBe,K$=vU,Wt=fBe,gh=Hf,u_t=x(2,(e,t)=>gh(e,t,(r,n)=>r(n))),l_t=Qm,d_t=RL,f_t=TL,p_t=x(e=>OOe(e[0]),_Oe),m_t=BOe,h_t=YCe,g_t=TOe,A_t=DOe,y_t=ave,x_t=r1,E_t=FIe,b_t=TU,S_t=JCe,C_t=KCe,w_t=Cve,I_t=bve,k_t=UZ,v_t=$Z,R_t=wve,__t=Rve,B_t=_ve,T_t=Ive,D_t=Sve,nNe=vve,Q_t=Qu,oNe=U1,iNe=WZ,O_t=Bve,N_t=xBe,sNe=$1,P_t=Tve,M_t=Dve,F_t=e=>qg(e)?H$:De(e.value,Au),L_t=x(2,(e,t)=>qg(e)?H$:De(t(e.value),Au)),aNe=e=>{let t=new Map;return new Proxy(e,{get(r,n,o){if(n in r)return Reflect.get(r,n,o);if(t.has(n))return t.get(n);let i=(...d)=>pA(r,f=>typeof f[n]=="function"?(t.set(n,(...p)=>pA(r,m=>m[n](...p))),f[n](...d)):(t.set(n,pA(r,p=>p[n])),f[n])),s=pA(r,d=>d[n]);Object.assign(i,s);let a=i.apply,c=i.bind,u=i.call,l=Object.setPrototypeOf({},Object.getPrototypeOf(s));return l.apply=a,l.bind=c,l.call=u,Object.setPrototypeOf(i,l),t.set(n,i),i}})},U_t=e=>()=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=2;let r=new Error;Error.stackTraceLimit=t;function n(){}return Object.setPrototypeOf(n,Uw),n.key=e,Object.defineProperty(n,"use",{get(){return o=>pA(this,o)}}),Object.defineProperty(n,"stack",{get(){return r.stack}}),aNe(n)},$_t=function(){return function(){let[e,t]=arguments,r="accessors"in t?t.accessors:!1,n=Error.stackTraceLimit;Error.stackTraceLimit=2;let o=new Error;Error.stackTraceLimit=n;let i="unchecked",s=function(d){if(i==="unchecked"){let f=Object.getPrototypeOf(d);if(f===Object.prototype||f===null)i="plain";else{let p=Object.getPrototypeOf(this);Object.setPrototypeOf(p,f),i="patched"}}if(i==="plain")Object.assign(this,d);else if(i==="patched")return Object.setPrototypeOf(d,Object.getPrototypeOf(this)),d};s.prototype._tag=e,Object.defineProperty(s,"make",{get(){return d=>new this(d)}}),Object.defineProperty(s,"use",{get(){return d=>pA(this,d)}}),s.key=e,Object.assign(s,Uw),Object.defineProperty(s,"stack",{get(){return o.stack}});let a="dependencies"in t&&t.dependencies.length>0,c=a?"DefaultWithoutDependencies":"Default",u,l=!1;if("effect"in t?(l=typeof t.effect=="function",Object.defineProperty(s,c,{get(){return l?function(){return JA(s,De(t.effect.apply(null,arguments),d=>new this(d)))}.bind(this):u??=JA(s,De(t.effect,d=>new this(d)))}})):"scoped"in t?(l=typeof t.scoped=="function",Object.defineProperty(s,c,{get(){return l?function(){return KA(s,De(t.scoped.apply(null,arguments),d=>new this(d)))}.bind(this):u??=KA(s,De(t.scoped,d=>new this(d)))}})):"sync"in t?Object.defineProperty(s,c,{get(){return u??=u$(s,()=>new this(t.sync()))}}):Object.defineProperty(s,c,{get(){return u??=zI(s,new this(t.succeed))}}),a){let d;Object.defineProperty(s,"Default",{get(){return l?function(){return Eb(this.DefaultWithoutDependencies.apply(null,arguments),t.dependencies)}:d??=Eb(this.DefaultWithoutDependencies,t.dependencies)}})}return r===!0?aNe(s):s}},H_t=function(e,...t){let r=Error.stackTraceLimit;Error.stackTraceLimit=2;let n=new Error;if(Error.stackTraceLimit=r,typeof e!="string")return POe(e.length,function(...s){let a=Error.stackTraceLimit;Error.stackTraceLimit=2;let c=new Error;return Error.stackTraceLimit=a,MOe({self:this,body:e,args:s,pipeables:t,spanName:"<anonymous>",spanOptions:{context:KE.context(!0)},errorDef:n,errorCall:c})});let o=e,i=t[0];return(s,...a)=>POe(s.length,{[o](...c){let u=Error.stackTraceLimit;Error.stackTraceLimit=2;let l=new Error;return Error.stackTraceLimit=u,MOe({self:this,body:s,args:c,pipeables:a,spanName:o,spanOptions:i,errorDef:n,errorCall:l})}}[o])};Z$=Xw,W_t=()=>e=>e,j_t=()=>e=>e,q_t=()=>e=>e});var h0,cNe,uNe,Bb,g0=h(()=>{vt();h0=pn,cNe=Xi,uNe=Dm,Bb=ui});var lNe,dNe,fNe,pNe,mNe=h(()=>{sr();vt();La();DT();_A();lNe=e=>xb(kU(e)),dNe=e=>ch(Ra(wi,e)),fNe=(e,t)=>(t=Ec(t),KA(wi,t?.onEnd?jo(Qu(e,t),r=>ld(n=>t.onEnd(r,n))):Qu(e,t))),pNe=e=>xb(TU(e))});var Er={};tr(Er,{CurrentMemoMap:()=>iX,LayerTypeId:()=>z_t,MemoMapTypeId:()=>V_t,annotateLogs:()=>J_t,annotateSpans:()=>K_t,build:()=>Z_t,buildWithMemoMap:()=>cX,buildWithScope:()=>X_t,catchAll:()=>eBt,catchAllCause:()=>tBt,context:()=>hNe,die:()=>rBt,dieSync:()=>nBt,discard:()=>oBt,effect:()=>iy,effectContext:()=>iBt,effectDiscard:()=>gNe,empty:()=>sBt,ensureErrorType:()=>uTt,ensureRequirementsType:()=>lTt,ensureSuccessType:()=>cTt,extendScope:()=>aBt,fail:()=>cBt,failCause:()=>lBt,failCauseSync:()=>dBt,failSync:()=>uBt,fiberRefLocallyScopedWith:()=>BBt,flatMap:()=>fBt,flatten:()=>pBt,fresh:()=>mBt,function:()=>gBt,isFresh:()=>Y_t,isLayer:()=>sX,launch:()=>ABt,locally:()=>vBt,locallyEffect:()=>kBt,locallyScoped:()=>_Bt,locallyWith:()=>RBt,makeMemoMap:()=>sTt,map:()=>ANe,mapError:()=>yBt,match:()=>xBt,matchCause:()=>EBt,memoize:()=>bBt,merge:()=>yNe,mergeAll:()=>aX,mock:()=>hBt,orDie:()=>SBt,orElse:()=>CBt,parentSpan:()=>GBt,passthrough:()=>wBt,project:()=>IBt,provide:()=>sy,provideMerge:()=>sD,retry:()=>TBt,scope:()=>DBt,scoped:()=>X$,scopedContext:()=>e2,scopedDiscard:()=>Rc,service:()=>QBt,setClock:()=>jBt,setConfigProvider:()=>qBt,setRandom:()=>zBt,setRequestBatching:()=>VBt,setRequestCache:()=>JBt,setRequestCaching:()=>YBt,setScheduler:()=>KBt,setTracer:()=>XBt,setTracerEnabled:()=>eTt,setTracerTiming:()=>tTt,setUnhandledErrorLogLevel:()=>rTt,setVersionMismatchErrorLogLevel:()=>nTt,span:()=>ZBt,succeed:()=>Ed,succeedContext:()=>iD,suspend:()=>OBt,sync:()=>NBt,syncContext:()=>PBt,tap:()=>MBt,tapError:()=>FBt,tapErrorCause:()=>LBt,toRuntime:()=>UBt,toRuntimeWithMemoMap:()=>$Bt,unwrapEffect:()=>WBt,unwrapScoped:()=>xNe,updateService:()=>aTt,withParentSpan:()=>iTt,withSpan:()=>oTt,zipWith:()=>HBt});var z_t,V_t,iX,sX,Y_t,J_t,K_t,Z_t,X_t,eBt,tBt,hNe,rBt,nBt,oBt,iy,gNe,iBt,sBt,aBt,cBt,uBt,lBt,dBt,fBt,pBt,mBt,hBt,gBt,ABt,ANe,yBt,xBt,EBt,bBt,yNe,aX,SBt,CBt,wBt,IBt,kBt,vBt,RBt,_Bt,BBt,TBt,DBt,X$,Rc,e2,QBt,Ed,iD,OBt,NBt,PBt,MBt,FBt,LBt,UBt,$Bt,sy,sD,HBt,WBt,xNe,jBt,qBt,GBt,zBt,VBt,YBt,JBt,KBt,ZBt,XBt,eTt,tTt,rTt,nTt,oTt,iTt,sTt,cX,aTt,cTt,uTt,lTt,zu=h(()=>{sr();oe();JE();vt();Mf();La();DT();mNe();q5();CB();PA();z_t=XU,V_t=kT,iX=Q8,sX=RT,Y_t=O8,J_t=SDe,K_t=CDe,Z_t=qTe,X_t=YA,eBt=yb,tBt=P8,hNe=t$,rBt=M8,nBt=zTe,oBt=VTe,iy=JA,gNe=KTe,iBt=Cs,sBt=mDe,aBt=YTe,cBt=F8,uBt=L8,lBt=_T,dBt=r$,fBt=Gf,pBt=JTe,mBt=U8,hBt=nDe,gBt=tDe,ABt=rDe,ANe=i$,yBt=oDe,xBt=a$,EBt=s$,bBt=iDe,yNe=$8,aX=c$,SBt=sDe,CBt=aDe,wBt=cDe,IBt=uDe,kBt=n$,vBt=ZTe,RBt=o$,_Bt=XTe,BBt=eDe,TBt=lDe,DBt=fDe,X$=KA,Rc=xb,e2=BT,QBt=pDe,Ed=zI,iD=ch,OBt=TT,NBt=u$,PBt=hDe,MBt=gDe,FBt=ADe,LBt=yDe,UBt=xDe,$Bt=EDe,sy=Eb,sD=bDe,HBt=H8,WBt=W8,xNe=vT,jBt=e=>Rc(ts(mn,zt(bs,e))),qBt=lNe,GBt=dNe,zBt=e=>Rc(ts(mn,zt(Hm,e))),VBt=e=>Rc(Ss(eI,e)),YBt=e=>Rc(Ss(qT,e)),JBt=e=>Rc(ar(e)?O(e,t=>Ss(i0,t)):Ss(i0,e)),KBt=e=>Rc(Ss(Gm,e)),ZBt=fNe,XBt=pNe,eTt=e=>Rc(Ss(rI,e)),tTt=e=>Rc(Ss(Pm,e)),rTt=e=>Rc(Ss(tI,e)),nTt=e=>Rc(Ss(mB,e)),oTt=wDe,iTt=ZU,sTt=N8,cX=e$,aTt=x(3,(e,t,r)=>sy(e,ANe(hNe(),n=>zt(n,t,r(_a(n,t)))))),cTt=()=>e=>e,uTt=()=>e=>e,lTt=()=>e=>e});var aD={};tr(aD,{CurrentIterationMetadata:()=>rQt,ScheduleDriverTypeId:()=>fTt,ScheduleTypeId:()=>dTt,addDelay:()=>hTt,addDelayEffect:()=>gTt,andThen:()=>ATt,andThenEither:()=>yTt,as:()=>xTt,asVoid:()=>ETt,bothInOut:()=>bTt,check:()=>STt,checkEffect:()=>CTt,collectAllInputs:()=>wTt,collectAllOutputs:()=>ITt,collectUntil:()=>kTt,collectUntilEffect:()=>vTt,collectWhile:()=>RTt,collectWhileEffect:()=>_Tt,compose:()=>BTt,count:()=>OTt,cron:()=>NTt,dayOfMonth:()=>LTt,dayOfWeek:()=>UTt,delayed:()=>$Tt,delayedEffect:()=>HTt,delayedSchedule:()=>WTt,delays:()=>jTt,driver:()=>zTt,duration:()=>VTt,either:()=>YTt,eitherWith:()=>JTt,elapsed:()=>KTt,ensuring:()=>ZTt,exponential:()=>XTt,fibonacci:()=>eDt,fixed:()=>tDt,forever:()=>rDt,fromDelay:()=>nDt,fromDelays:()=>oDt,fromFunction:()=>iDt,hourOfDay:()=>FTt,identity:()=>sDt,intersect:()=>cDt,intersectWith:()=>uDt,isSchedule:()=>mTt,jittered:()=>lDt,jitteredWith:()=>dDt,linear:()=>fDt,makeWithState:()=>pTt,map:()=>pDt,mapBoth:()=>qTt,mapBothEffect:()=>GTt,mapEffect:()=>mDt,mapInput:()=>TTt,mapInputContext:()=>QTt,mapInputEffect:()=>DTt,minuteOfHour:()=>MTt,modifyDelay:()=>hDt,modifyDelayEffect:()=>gDt,onDecision:()=>ADt,once:()=>yDt,passthrough:()=>aDt,provideContext:()=>xDt,provideService:()=>EDt,recurUntil:()=>bDt,recurUntilEffect:()=>SDt,recurUntilOption:()=>CDt,recurUpTo:()=>wDt,recurWhile:()=>IDt,recurWhileEffect:()=>kDt,recurs:()=>vDt,reduce:()=>RDt,reduceEffect:()=>_Dt,repeatForever:()=>BDt,repetitions:()=>TDt,resetAfter:()=>DDt,resetWhen:()=>QDt,run:()=>ODt,secondOfMinute:()=>PTt,spaced:()=>uX,stop:()=>NDt,succeed:()=>PDt,sync:()=>MDt,tapInput:()=>FDt,tapOutput:()=>LDt,unfold:()=>UDt,union:()=>$Dt,unionWith:()=>HDt,untilInput:()=>WDt,untilInputEffect:()=>jDt,untilOutput:()=>qDt,untilOutputEffect:()=>GDt,upTo:()=>zDt,whileInput:()=>VDt,whileInputEffect:()=>YDt,whileOutput:()=>JDt,whileOutputEffect:()=>KDt,windowed:()=>ZDt,zipLeft:()=>XDt,zipRight:()=>eQt,zipWith:()=>tQt});var dTt,fTt,pTt,mTt,hTt,gTt,ATt,yTt,xTt,ETt,bTt,STt,CTt,wTt,ITt,kTt,vTt,RTt,_Tt,BTt,TTt,DTt,QTt,OTt,NTt,PTt,MTt,FTt,LTt,UTt,$Tt,HTt,WTt,jTt,qTt,GTt,zTt,VTt,YTt,JTt,KTt,ZTt,XTt,eDt,tDt,rDt,nDt,oDt,iDt,sDt,aDt,cDt,uDt,lDt,dDt,fDt,pDt,mDt,hDt,gDt,ADt,yDt,xDt,EDt,bDt,SDt,CDt,wDt,IDt,kDt,vDt,RDt,_Dt,BDt,TDt,DDt,QDt,ODt,uX,NDt,PDt,MDt,FDt,LDt,UDt,$Dt,HDt,WDt,jDt,qDt,GDt,zDt,VDt,YDt,JDt,KDt,ZDt,XDt,eQt,tQt,rQt,lX=h(()=>{T$();dTt=y$,fTt=c5,pTt=mr,mTt=x$,hTt=E$,gTt=u5,ATt=rQe,yTt=l5,xTt=nQe,ETt=b$,bTt=oQe,STt=e0,CTt=Cb,wTt=iQe,ITt=wb,kTt=sQe,vTt=aQe,RTt=cQe,_Tt=uQe,BTt=lQe,TTt=d5,DTt=S$,QTt=dQe,OTt=uOe,NTt=fQe,PTt=$Qe,MTt=TQe,FTt=RQe,LTt=pQe,UTt=mQe,$Tt=hQe,HTt=C$,WTt=MT,jTt=gQe,qTt=AQe,GTt=yQe,zTt=FT,VTt=f5,YTt=xQe,JTt=EQe,KTt=_$,ZTt=bQe,XTt=SQe,eDt=CQe,tDt=wQe,rDt=fd,nDt=IQe,oDt=kQe,iDt=vQe,sDt=dh,aDt=h5,cDt=ZA,uDt=p5,lDt=_Qe,dDt=m5,fDt=BQe,pDt=vi,mDt=w$,hDt=DQe,gDt=LT,ADt=QQe,yDt=B$,xDt=OQe,EDt=NQe,bDt=g5,SDt=A5,CDt=PQe,wDt=y5,IDt=x5,kDt=E5,vDt=t0,RDt=I$,_Dt=b5,BDt=fd,TDt=MQe,DDt=FQe,QDt=S5,ODt=LQe,uX=HQe,NDt=lOe,PDt=WQe,MDt=jQe,FDt=qQe,LDt=GQe,UDt=UT,$Dt=C5,HDt=k$,WDt=w5,jDt=$T,qDt=I5,GDt=zQe,zDt=VQe,VDt=k5,YDt=HT,JDt=v$,KDt=YQe,ZDt=JQe,XDt=v5,eQt=KQe,tQt=ZQe,rQt=Sb});var nQt,ENe,oQt,bNe,iQt,n2,sQt,SNe,gX,aQt,cQt,uQt,dX,CNe,wNe,INe,kNe,vNe,lQt,cD,fX,o2,RNe,_Ne,BNe,t2,TNe,DNe,AX,QNe,pX,mX,hX,Db,r2,A0,dQt,fQt,Tb,ONe=h(()=>{wr();vr();id();oe();L$();Kl();it();Me();vt();La();nQt="effect/QueueEnqueue",ENe=Symbol.for(nQt),oQt="effect/QueueDequeue",bNe=Symbol.for(oQt),iQt="effect/QueueStrategy",n2=Symbol.for(iQt),sQt="effect/BackingQueue",SNe=Symbol.for(sQt),gX={_A:e=>e},aQt={_A:e=>e},cQt={_In:e=>e},uQt={_Out:e=>e},dX=class extends Ys{queue;takers;shutdownHook;shutdownFlag;strategy;[ENe]=cQt;[bNe]=uQt;constructor(t,r,n,o,i){super(),this.queue=t,this.takers=r,this.shutdownHook=n,this.shutdownFlag=o,this.strategy=i}pipe(){return Z(this,arguments)}commit(){return this.take}capacity(){return this.queue.capacity()}get size(){return ye(()=>fc(this.unsafeSize(),()=>qs))}unsafeSize(){return Qr(this.shutdownFlag)?W():H(this.queue.length()-P$(this.takers)+this.strategy.surplusSize())}get isEmpty(){return te(this.size,t=>t<=0)}get isFull(){return te(this.size,t=>t>=this.capacity())}get shutdown(){return Iu(st(t=>(C(this.shutdownFlag,js(!0)),C(Du(A0(this.takers),r=>EB(r,t.id()),!1,!1),je(this.strategy.shutdown),AA(Mm(this.shutdownHook,void 0)),$r))))}get isShutdown(){return V(()=>Qr(this.shutdownFlag))}get awaitShutdown(){return Cn(this.shutdownHook)}isActive(){return!Qr(this.shutdownFlag)}unsafeOffer(t){if(Qr(this.shutdownFlag))return!1;let r;if(this.queue.length()===0){let o=C(this.takers,md(fi));o!==fi?(Db(o,t),r=!0):r=!1}else r=!1;if(r)return!0;let n=this.queue.offer(t);return Tb(this.strategy,this.queue,this.takers),n}offer(t){return ye(()=>{if(Qr(this.shutdownFlag))return qs;let r;if(this.queue.length()===0){let o=C(this.takers,md(fi));o!==fi?(Db(o,t),r=!0):r=!1}else r=!1;if(r)return M(!0);let n=this.queue.offer(t);return Tb(this.strategy,this.queue,this.takers),n?M(!0):this.strategy.handleSurplus([t],this.queue,this.takers,this.shutdownFlag)})}offerAll(t){return ye(()=>{if(Qr(this.shutdownFlag))return qs;let r=_e(t),n=this.queue.length()===0?_e(dQt(this.takers,r.length)):Us,[o,i]=C(r,y6(n.length));for(let a=0;a<n.length;a++){let c=n[a],u=o[a];Db(c,u)}if(i.length===0)return M(!0);let s=this.queue.offerAll(i);return Tb(this.strategy,this.queue,this.takers),xu(s)?M(!0):this.strategy.handleSurplus(s,this.queue,this.takers,this.shutdownFlag)})}get take(){return st(t=>{if(Qr(this.shutdownFlag))return qs;let r=this.queue.poll(fi);if(r!==fi)return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),M(r);{let n=wA(t.id());return C(ye(()=>(C(this.takers,XA(n)),Tb(this.strategy,this.queue,this.takers),Qr(this.shutdownFlag)?qs:Cn(n))),hc(()=>V(()=>fQt(this.takers,n))))}})}get takeAll(){return ye(()=>Qr(this.shutdownFlag)?qs:V(()=>{let t=this.queue.pollUpTo(Number.POSITIVE_INFINITY);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Co(t)}))}takeUpTo(t){return ye(()=>Qr(this.shutdownFlag)?qs:V(()=>{let r=this.queue.pollUpTo(t);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Co(r)}))}takeBetween(t,r){return ye(()=>CNe(this,t,r,Ut()))}},CNe=(e,t,r,n)=>r<t?M(n):C(TNe(e,r),O(o=>{let i=t-o.length;return i===1?C(t2(e),te(s=>C(n,Ir(o),$s(s)))):i>1?C(t2(e),O(s=>CNe(e,i-1,r-o.length-1,C(n,Ir(o),$s(s))))):M(C(n,Ir(o)))})),wNe=e=>C(V(()=>N$(e)),O(t=>cD(o2(t),DNe()))),INe=e=>C(V(()=>N$(e)),O(t=>cD(o2(t),AX()))),kNe=e=>C(V(()=>N$(e)),O(t=>cD(o2(t),QNe()))),vNe=()=>C(V(()=>n0()),O(e=>cD(o2(e),AX()))),lQt=(e,t,r,n,o)=>new dX(e,t,r,n,o),cD=(e,t)=>C(Ci(),te(r=>lQt(e,n0(),r,Ba(!1),t))),fX=class{mutable;[SNe]=aQt;constructor(t){this.mutable=t}poll(t){return md(this.mutable,t)}pollUpTo(t){return F$(this.mutable,t)}offerAll(t){return L5(this.mutable,t)}offer(t){return XA(this.mutable,t)}capacity(){return wOe(this.mutable)}length(){return P$(this.mutable)}},o2=e=>new fX(e),RNe=e=>e.size,_Ne=e=>e.shutdown,BNe=x(2,(e,t)=>e.offer(t)),t2=e=>e.take,TNe=x(2,(e,t)=>e.takeUpTo(t)),DNe=()=>new pX,AX=()=>new mX,QNe=()=>new hX,pX=class{[n2]=gX;putters=n0();surplusSize(){return P$(this.putters)}onCompleteTakersWithEmptyQueue(t){for(;!M$(this.putters)&&!M$(t);){let r=md(t,void 0),n=md(this.putters,void 0);n[2]&&Db(n[1],!0),Db(r,n[0])}}get shutdown(){return C(td,O(t=>C(V(()=>A0(this.putters)),O(r=>Du(r,([n,o,i])=>i?C(EB(o,t),$r):Ue,!1,!1)))))}handleSurplus(t,r,n,o){return st(i=>{let s=wA(i.id());return C(ye(()=>(this.unsafeOffer(t,s),this.unsafeOnQueueEmptySpace(r,n),Tb(this,r,n),Qr(o)?qs:Cn(s))),hc(()=>V(()=>this.unsafeRemove(s))))})}unsafeOnQueueEmptySpace(t,r){let n=!0;for(;n&&(t.capacity()===Number.POSITIVE_INFINITY||t.length()<t.capacity());){let o=C(this.putters,md(fi));if(o===fi)n=!1;else{let i=t.offer(o[0]);i&&o[2]?Db(o[1],!0):i||r2(this.putters,C(A0(this.putters),fr(o))),Tb(this,t,r)}}}unsafeOffer(t,r){let n=_e(t);for(let o=0;o<n.length;o++){let i=n[o];o===n.length-1?C(this.putters,XA([i,r,!0])):C(this.putters,XA([i,r,!1]))}}unsafeRemove(t){r2(this.putters,C(A0(this.putters),Tw(([,r])=>r!==t)))}},mX=class{[n2]=gX;surplusSize(){return 0}get shutdown(){return Ue}onCompleteTakersWithEmptyQueue(){}handleSurplus(t,r,n,o){return M(!1)}unsafeOnQueueEmptySpace(t,r){}},hX=class{[n2]=gX;surplusSize(){return 0}get shutdown(){return Ue}onCompleteTakersWithEmptyQueue(){}handleSurplus(t,r,n,o){return V(()=>(this.unsafeOffer(r,t),Tb(this,r,n),!0))}unsafeOnQueueEmptySpace(t,r){}unsafeOffer(t,r){let n=r[Symbol.iterator](),o,i=!0;for(;!(o=n.next()).done&&i;){if(t.capacity()===0)return;t.poll(fi),i=t.offer(o.value)}}},Db=(e,t)=>IA(e,M(t)),r2=(e,t)=>C(e,L5(t)),A0=e=>C(e,F$(Number.POSITIVE_INFINITY)),dQt=(e,t)=>C(e,F$(t)),fQt=(e,t)=>{r2(e,C(A0(e),Tw(r=>t!==r)))},Tb=(e,t,r)=>{let n=!0;for(;n&&t.length()!==0;){let o=C(r,md(fi));if(o!==fi){let i=t.poll(fi);i!==fi?(Db(o,i),e.unsafeOnQueueEmptySpace(t,r)):r2(r,C(A0(r),fr(o))),n=!0}else n=!1}n&&t.length()===0&&!M$(r)&&e.onCompleteTakersWithEmptyQueue(r)}});var y0,i2,s2,uD,NNe,Ah,Vu,Qb,a2=h(()=>{ONe();y0=wNe,i2=INe,s2=kNe,uD=vNe,NNe=RNe,Ah=_Ne,Vu=BNe,Qb=t2});var PNe=h(()=>{});var c2,xX,EX,bX=h(()=>{c2="Continue",xX="Close",EX="Yield"});var hQt,FNe,gQt,SX,LNe=h(()=>{bX();hQt="effect/ChannelChildExecutorDecision",FNe=Symbol.for(hQt),gQt={[FNe]:FNe},SX=e=>{let t=Object.create(gQt);return t._tag=c2,t}});var x0,UNe,CX=h(()=>{x0="ContinuationK",UNe="ContinuationFinalizer"});var HNe,WNe,E0,u2,wX=h(()=>{Ro();CX();HNe=Symbol.for("effect/ChannelContinuation"),WNe={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutDone:e=>e,_OutErr2:e=>e,_OutElem:e=>e,_OutDone2:e=>e},E0=class{onSuccess;onHalt;_tag=x0;[HNe]=WNe;constructor(t,r){this.onSuccess=t,this.onHalt=r}onExit(t){return sd(t)?this.onHalt(t.cause):this.onSuccess(t.value)}},u2=class{finalizer;_tag=UNe;[HNe]=WNe;constructor(t){this.finalizer=t}}});var l2,IX,kX=h(()=>{l2="PullAfterNext",IX="PullAfterAllEnqueued"});var xQt,EQt,bQt,SQt,vX,qNe=h(()=>{kX();xQt="effect/ChannelUpstreamPullStrategy",EQt=Symbol.for(xQt),bQt={_A:e=>e},SQt={[EQt]:bQt},vX=e=>{let t=Object.create(SQt);return t._tag=l2,t.emitSeparator=e,t}});var d2,f2,lD,p2,m2,h2,dD,g2,A2,RX,y2,x2,E2,b2,_X=h(()=>{d2="BracketOut",f2="Bridge",lD="ConcatAll",p2="Emit",m2="Ensuring",h2="Fail",dD="Fold",g2="FromEffect",A2="PipeTo",RX="Provide",y2="Read",x2="Succeed",E2="SucceedNow",b2="Suspend"});var wQt,BX,IQt,Xs,S2,TX,C2,w2,zNe,I2,DX,fD,b0,_c,In,k2,Et,nn,Vn,bd,ea,Yu,ta,Ju,Jf,rs,cr,Ob=h(()=>{Vs();vr();nr();Ei();oe();it();Me();ct();LNe();wX();qNe();_X();wQt="effect/Channel",BX=Symbol.for(wQt),IQt={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},Xs={[BX]:IQt,pipe(){return Z(this,arguments)}},S2=e=>se(e,BX)||ws(e),TX=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=d2,r.acquire=()=>e,r.finalizer=t,r}),C2=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=dD,r.channel=e,r.k=new E0(Yu,t),r}),w2=e=>Ju(()=>{let t=[];return Et(Vn(e,zNe(t)),r=>Jf(()=>[Co(t),r]))}),zNe=e=>bd({onInput:t=>Et(Jf(()=>{e.push(t)}),()=>zNe(e)),onFailure:_c,onDone:ta}),I2=(e,t,r)=>{let n=Object.create(Xs);return n._tag=lD,n.combineInners=t,n.combineAll=r,n.onPull=()=>vX(W()),n.onEmit=()=>SX,n.value=()=>e,n.k=be,n},DX=x(4,(e,t,r,n)=>{let o=Object.create(Xs);return o._tag=lD,o.combineInners=r,o.combineAll=n,o.onPull=()=>vX(W()),o.onEmit=()=>SX,o.value=()=>e,o.k=t,o}),fD=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=f2,r.input=t,r.channel=e,r}),b0=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=m2,r.channel=e,r.finalizer=t,r}),_c=e=>In(VE(e)),In=e=>k2(()=>e),k2=e=>{let t=Object.create(Xs);return t._tag=h2,t.error=e,t},Et=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=dD,r.channel=e,r.k=new E0(t,In),r}),nn=e=>{let t=Object.create(Xs);return t._tag=g2,t.effect=()=>e,t},Vn=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=A2,r.left=()=>e,r.right=()=>t,r}),bd=e=>ea({onInput:e.onInput,onFailure:t=>xi(sI(t),{onLeft:e.onFailure,onRight:In}),onDone:e.onDone}),ea=e=>{let t=Object.create(Xs);return t._tag=y2,t.more=e.onInput,t.done=new E0(e.onDone,e.onFailure),t},Yu=e=>Jf(()=>e),ta=e=>{let t=Object.create(Xs);return t._tag=E2,t.terminal=e,t},Ju=e=>{let t=Object.create(Xs);return t._tag=b2,t.channel=e,t},Jf=e=>{let t=Object.create(Xs);return t._tag=x2,t.evaluate=e,t},rs=ta(void 0),cr=e=>{let t=Object.create(Xs);return t._tag=p2,t.out=e,t}});var ay,cy,yh,uy,v2=h(()=>{ay="Done",cy="Emit",yh="FromEffect",uy="Read"});var kQt,vQt,R2,Nb,_2,C0,B2,pD,VNe,OX,YNe=h(()=>{nr();v2();kQt=Symbol.for("effect/ChannelState"),vQt={_E:e=>e,_R:e=>e},R2={[kQt]:vQt},Nb=()=>{let e=Object.create(R2);return e._tag=ay,e},_2=()=>{let e=Object.create(R2);return e._tag=cy,e},C0=e=>{let t=Object.create(R2);return t._tag=yh,t.effect=e,t},B2=(e,t,r,n)=>{let o=Object.create(R2);return o._tag=uy,o.upstream=e,o.onEffect=t,o.onEmit=r,o.onDone=n,o},pD=e=>e._tag===yh,VNe=e=>pD(e)?e.effect:ve,OX=e=>pD(e)?a0(e.effect):void 0});var NX,T2,D2,PX,Pb,ly,Mb,w0,JNe=h(()=>{nr();Ro();oe();NX="PullFromChild",T2="PullFromUpstream",D2="DrainChildExecutors",PX="Emit",Pb=class{childExecutor;parentSubexecutor;onEmit;_tag=NX;constructor(t,r,n){this.childExecutor=t,this.parentSubexecutor=r,this.onEmit=n}close(t){let r=this.childExecutor.close(t),n=this.parentSubexecutor.close(t);return r!==void 0&&n!==void 0?gh(so(r),so(n),(o,i)=>C(o,LA(i))):r!==void 0?r:n!==void 0?n:void 0}enqueuePullFromChild(t){return this}},ly=class e{upstreamExecutor;createChild;lastDone;activeChildExecutors;combineChildResults;combineWithChildResult;onPull;onEmit;_tag=T2;constructor(t,r,n,o,i,s,a,c){this.upstreamExecutor=t,this.createChild=r,this.lastDone=n,this.activeChildExecutors=o,this.combineChildResults=i,this.combineWithChildResult=s,this.onPull=a,this.onEmit=c}close(t){let r=this.upstreamExecutor.close(t),o=[...this.activeChildExecutors.map(i=>i!==void 0?i.childExecutor.close(t):void 0),r].reduce((i,s)=>i!==void 0&&s!==void 0?gh(i,so(s),(a,c)=>LA(a,c)):i!==void 0?i:s!==void 0?so(s):void 0,void 0);return o}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.createChild,this.lastDone,[...this.activeChildExecutors,t],this.combineChildResults,this.combineWithChildResult,this.onPull,this.onEmit)}},Mb=class e{upstreamExecutor;lastDone;activeChildExecutors;upstreamDone;combineChildResults;combineWithChildResult;onPull;_tag=D2;constructor(t,r,n,o,i,s,a){this.upstreamExecutor=t,this.lastDone=r,this.activeChildExecutors=n,this.upstreamDone=o,this.combineChildResults=i,this.combineWithChildResult=s,this.onPull=a}close(t){let r=this.upstreamExecutor.close(t),o=[...this.activeChildExecutors.map(i=>i!==void 0?i.childExecutor.close(t):void 0),r].reduce((i,s)=>i!==void 0&&s!==void 0?gh(i,so(s),(a,c)=>LA(a,c)):i!==void 0?i:s!==void 0?so(s):void 0,void 0);return o}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.lastDone,[...this.activeChildExecutors,t],this.upstreamDone,this.combineChildResults,this.combineWithChildResult,this.onPull)}},w0=class{value;next;_tag=PX;constructor(t,r){this.value=t,this.next=r}close(t){let r=this.next.close(t);return r}enqueuePullFromChild(t){return this}}});var KNe,ZNe,XNe=h(()=>{KNe="Pulled",ZNe="NoUpstream"});var TQt,DQt,QQt,ePe,MX,tPe,rPe=h(()=>{XNe();TQt="effect/ChannelUpstreamPullRequest",DQt=Symbol.for(TQt),QQt={_A:e=>e},ePe={[DQt]:QQt},MX=e=>{let t=Object.create(ePe);return t._tag=KNe,t.value=e,t},tPe=e=>{let t=Object.create(ePe);return t._tag=ZNe,t.activeDownstreamCount=e,t}});var mD,FX,LX,O2,UX,Q2,nPe=h(()=>{Vs();$u();nr();a1();Ro();WI();Zl();oe();dc();it();ah();Ob();_X();bX();v2();kX();CX();YNe();wX();JNe();rPe();mD=class e{_activeSubexecutor=void 0;_cancelled=void 0;_closeLastSubstream=void 0;_currentChannel;_done=void 0;_doneStack=[];_emitted=void 0;_executeCloseLastSubstream;_input=void 0;_inProgressFinalizer=void 0;_providedEnv;constructor(t,r,n){this._currentChannel=t,this._executeCloseLastSubstream=n,this._providedEnv=r}run(){let t;for(;t===void 0;)if(this._cancelled!==void 0)t=this.processCancellation();else if(this._activeSubexecutor!==void 0)t=this.runSubexecutor();else try{if(this._currentChannel===void 0)t=Nb();else switch(ws(this._currentChannel)&&(this._currentChannel=nn(this._currentChannel)),this._currentChannel._tag){case d2:{t=this.runBracketOut(this._currentChannel);break}case f2:{let r=this._currentChannel.input;if(this._currentChannel=this._currentChannel.channel,this._input!==void 0){let n=this._input;this._input=void 0;let o=()=>Ee(r.awaitRead(),()=>Pt(()=>{let i=n.run();switch(i._tag){case ay:return es(n.getDone(),{onFailure:s=>r.error(s),onSuccess:s=>r.done(s)});case cy:return Ee(r.emit(n.getEmit()),()=>o());case yh:return vc(i.effect,{onFailure:s=>r.error(s),onSuccess:()=>o()});case uy:return O2(i,()=>o(),s=>r.error(s))}}));t=C0(Ee(Rb(Bo(o())),i=>ot(()=>this.addFinalizer(s=>Ee(jf(i),()=>Pt(()=>{let a=this.restorePipe(s,n);return a!==void 0?a:ve}))))))}break}case lD:{let r=new e(this._currentChannel.value(),this._providedEnv,o=>ot(()=>{let i=this._closeLastSubstream===void 0?ve:this._closeLastSubstream;this._closeLastSubstream=C(i,Wt(o))}));r._input=this._input;let n=this._currentChannel;this._activeSubexecutor=new ly(r,o=>n.k(o),void 0,[],(o,i)=>n.combineInners(o,i),(o,i)=>n.combineAll(o,i),o=>n.onPull(o),o=>n.onEmit(o)),this._closeLastSubstream=void 0,this._currentChannel=void 0;break}case p2:{this._emitted=this._currentChannel.out,this._currentChannel=this._activeSubexecutor!==void 0?void 0:rs,t=_2();break}case m2:{this.runEnsuring(this._currentChannel);break}case h2:{t=this.doneHalt(this._currentChannel.error());break}case dD:{this._doneStack.push(this._currentChannel.k),this._currentChannel=this._currentChannel.channel;break}case g2:{let r=this._providedEnv===void 0?this._currentChannel.effect():C(this._currentChannel.effect(),ry(this._providedEnv));t=C0(vc(r,{onFailure:n=>{let o=this.doneHalt(n);return o!==void 0&&pD(o)?o.effect:ve},onSuccess:n=>{let o=this.doneSucceed(n);return o!==void 0&&pD(o)?o.effect:ve}}));break}case A2:{let r=this._input,n=new e(this._currentChannel.left(),this._providedEnv,o=>this._executeCloseLastSubstream(o));n._input=r,this._input=n,this.addFinalizer(o=>{let i=this.restorePipe(o,r);return i!==void 0?i:ve}),this._currentChannel=this._currentChannel.right();break}case RX:{let r=this._providedEnv;this._providedEnv=this._currentChannel.context(),this._currentChannel=this._currentChannel.inner,this.addFinalizer(()=>ot(()=>{this._providedEnv=r}));break}case y2:{let r=this._currentChannel;t=B2(this._input,be,n=>{try{this._currentChannel=r.more(n)}catch(o){this._currentChannel=r.done.onExit(VB(o))}},n=>{let o=i=>r.done.onExit(i);this._currentChannel=o(n)});break}case x2:{t=this.doneSucceed(this._currentChannel.evaluate());break}case E2:{t=this.doneSucceed(this._currentChannel.terminal);break}case b2:{this._currentChannel=this._currentChannel.channel();break}}}catch(r){this._currentChannel=In(od(r))}return t}getDone(){return this._done}getEmit(){return this._emitted}cancelWith(t){this._cancelled=t}clearInProgressFinalizer(){this._inProgressFinalizer=void 0}storeInProgressFinalizer(t){this._inProgressFinalizer=t}popAllFinalizers(t){let r=[],n=this._doneStack.pop();for(;n;)n._tag==="ContinuationFinalizer"&&r.push(n.finalizer),n=this._doneStack.pop();let o=r.length===0?ve:LX(r,t);return this.storeInProgressFinalizer(o),o}popNextFinalizers(){let t=[];for(;this._doneStack.length!==0;){let r=this._doneStack[this._doneStack.length-1];if(r._tag===x0)return t;t.push(r),this._doneStack.pop()}return t}restorePipe(t,r){let n=this._input;return this._input=r,n!==void 0?n.close(t):ve}close(t){let r,n=this._inProgressFinalizer;n!==void 0&&(r=C(n,qu(ot(()=>this.clearInProgressFinalizer()))));let o,i=this.popAllFinalizers(t);i!==void 0&&(o=C(i,qu(ot(()=>this.clearInProgressFinalizer()))));let s=this._activeSubexecutor===void 0?void 0:this._activeSubexecutor.close(t);if(!(s===void 0&&r===void 0&&o===void 0))return C(so(FX(s)),Gu(so(FX(r))),Gu(so(FX(o))),De(([[a,c],u])=>C(a,LA(c),LA(u))),hd,Ee(a=>Pt(()=>a)))}doneSucceed(t){if(this._doneStack.length===0)return this._done=vo(t),this._currentChannel=void 0,Nb();let r=this._doneStack[this._doneStack.length-1];if(r._tag===x0){this._doneStack.pop(),this._currentChannel=r.onSuccess(t);return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=vo(t),this._currentChannel=void 0,Nb();let o=LX(n.map(s=>s.finalizer),vo(t));this.storeInProgressFinalizer(o);let i=C(o,qu(ot(()=>this.clearInProgressFinalizer())),hd,Ee(()=>ot(()=>this.doneSucceed(t))));return C0(i)}doneHalt(t){if(this._doneStack.length===0)return this._done=Mn(t),this._currentChannel=void 0,Nb();let r=this._doneStack[this._doneStack.length-1];if(r._tag===x0){this._doneStack.pop();try{this._currentChannel=r.onHalt(t)}catch(s){this._currentChannel=In(od(s))}return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=Mn(t),this._currentChannel=void 0,Nb();let o=LX(n.map(s=>s.finalizer),Mn(t));this.storeInProgressFinalizer(o);let i=C(o,qu(ot(()=>this.clearInProgressFinalizer())),hd,Ee(()=>ot(()=>this.doneHalt(t))));return C0(i)}processCancellation(){return this._currentChannel=void 0,this._done=this._cancelled,this._cancelled=void 0,Nb()}runBracketOut(t){let r=hd(vc(this.provide(t.acquire()),{onFailure:n=>ot(()=>{this._currentChannel=In(n)}),onSuccess:n=>ot(()=>{this.addFinalizer(o=>this.provide(t.finalizer(n,o))),this._currentChannel=cr(n)})}));return C0(r)}provide(t){return this._providedEnv===void 0?t:C(t,ry(this._providedEnv))}runEnsuring(t){this.addFinalizer(t.finalizer),this._currentChannel=t.channel}addFinalizer(t){this._doneStack.push(new u2(t))}runSubexecutor(){let t=this._activeSubexecutor;switch(t._tag){case NX:return this.pullFromChild(t.childExecutor,t.parentSubexecutor,t.onEmit,t);case T2:return this.pullFromUpstream(t);case D2:return this.drainChildExecutors(t);case PX:return this._emitted=t.value,this._activeSubexecutor=t.next,_2()}}replaceSubexecutor(t){this._currentChannel=void 0,this._activeSubexecutor=t}finishWithExit(t){let r=es(t,{onFailure:n=>this.doneHalt(n),onSuccess:n=>this.doneSucceed(n)});return this._activeSubexecutor=void 0,r===void 0?ve:VNe(r)}finishSubexecutorWithCloseEffect(t,...r){this.addFinalizer(()=>C(r,pi(o=>C(ot(()=>o(t)),Ee(i=>i!==void 0?i:ve)),{discard:!0})));let n=C(t,es({onFailure:o=>this.doneHalt(o),onSuccess:o=>this.doneSucceed(o)}));return this._activeSubexecutor=void 0,n}applyUpstreamPullStrategy(t,r,n){switch(n._tag){case l2:{let o=!t||r.some(i=>i!==void 0);return[n.emitSeparator,o?[void 0,...r]:r]}case IX:{let o=!t||r.some(i=>i!==void 0);return[n.emitSeparator,o?[...r,void 0]:r]}}}pullFromChild(t,r,n,o){return B2(t,be,i=>{let s=n(i);switch(s._tag){case c2:break;case xX:{this.finishWithDoneValue(t,r,s.value);break}case EX:{let a=r.enqueuePullFromChild(o);this.replaceSubexecutor(a);break}}this._activeSubexecutor=new w0(i,this._activeSubexecutor)},es({onFailure:i=>{let s=this.handleSubexecutorFailure(t,r,i);return s===void 0?void 0:OX(s)},onSuccess:i=>{this.finishWithDoneValue(t,r,i)}}))}finishWithDoneValue(t,r,n){let o=r;switch(o._tag){case T2:{let i=new ly(o.upstreamExecutor,o.createChild,o.lastDone!==void 0?o.combineChildResults(o.lastDone,n):n,o.activeChildExecutors,o.combineChildResults,o.combineWithChildResult,o.onPull,o.onEmit);this._closeLastSubstream=t.close(vo(n)),this.replaceSubexecutor(i);break}case D2:{let i=new Mb(o.upstreamExecutor,o.lastDone!==void 0?o.combineChildResults(o.lastDone,n):n,o.activeChildExecutors,o.upstreamDone,o.combineChildResults,o.combineWithChildResult,o.onPull);this._closeLastSubstream=t.close(vo(n)),this.replaceSubexecutor(i);break}default:break}}handleSubexecutorFailure(t,r,n){return this.finishSubexecutorWithCloseEffect(Mn(n),o=>r.close(o),o=>t.close(o))}pullFromUpstream(t){if(t.activeChildExecutors.length===0)return this.performPullFromUpstream(t);let r=t.activeChildExecutors[0],n=new ly(t.upstreamExecutor,t.createChild,t.lastDone,t.activeChildExecutors.slice(1),t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit);if(r===void 0)return this.performPullFromUpstream(n);this.replaceSubexecutor(new Pb(r.childExecutor,n,r.onEmit))}performPullFromUpstream(t){return B2(t.upstreamExecutor,r=>{let n=this._closeLastSubstream===void 0?ve:this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(n),Wt(r))},r=>{if(this._closeLastSubstream!==void 0){let s=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(s),De(()=>{let a=new e(t.createChild(r),this._providedEnv,this._executeCloseLastSubstream);a._input=this._input;let[c,u]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(MX(r)));this._activeSubexecutor=new Pb(a,new ly(t.upstreamExecutor,t.createChild,t.lastDone,u,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),pt(c)&&(this._activeSubexecutor=new w0(c.value,this._activeSubexecutor))}))}let n=new e(t.createChild(r),this._providedEnv,this._executeCloseLastSubstream);n._input=this._input;let[o,i]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(MX(r)));this._activeSubexecutor=new Pb(n,new ly(t.upstreamExecutor,t.createChild,t.lastDone,i,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),pt(o)&&(this._activeSubexecutor=new w0(o.value,this._activeSubexecutor))},r=>{if(t.activeChildExecutors.some(i=>i!==void 0)){let i=new Mb(t.upstreamExecutor,t.lastDone,[void 0,...t.activeChildExecutors],t.upstreamExecutor.getDone(),t.combineChildResults,t.combineWithChildResult,t.onPull);if(this._closeLastSubstream!==void 0){let s=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(s),De(()=>this.replaceSubexecutor(i)))}this.replaceSubexecutor(i);return}let n=this._closeLastSubstream,o=this.finishSubexecutorWithCloseEffect(C(r,J1(i=>t.combineWithChildResult(t.lastDone,i))),()=>n,i=>t.upstreamExecutor.close(i));return o===void 0?void 0:OX(o)})}drainChildExecutors(t){if(t.activeChildExecutors.length===0){let i=this._closeLastSubstream;return i!==void 0&&this.addFinalizer(()=>nt(i)),this.finishSubexecutorWithCloseEffect(t.upstreamDone,()=>i,s=>t.upstreamExecutor.close(s))}let r=t.activeChildExecutors[0],n=t.activeChildExecutors.slice(1);if(r===void 0){let[i,s]=this.applyUpstreamPullStrategy(!0,n,t.onPull(tPe(n.reduce((a,c)=>c!==void 0?a+1:a,0))));return this.replaceSubexecutor(new Mb(t.upstreamExecutor,t.lastDone,s,t.upstreamDone,t.combineChildResults,t.combineWithChildResult,t.onPull)),pt(i)?(this._emitted=i.value,_2()):void 0}let o=new Mb(t.upstreamExecutor,t.lastDone,n,t.upstreamDone,t.combineChildResults,t.combineWithChildResult,t.onPull);this.replaceSubexecutor(new Pb(r.childExecutor,o,r.onEmit))}},FX=e=>e!==void 0?e:ve,LX=(e,t)=>C(pi(e,r=>so(r(t))),De(r=>C(jZ(r),Nt(()=>wc))),Ee(r=>Pt(()=>r))),O2=(e,t,r)=>{let n=[e],o=()=>{let i=n.pop();if(i===void 0||i.upstream===void 0)return kb("Unexpected end of input for channel execution");let s=i.upstream.run();switch(s._tag){case cy:{let a=i.onEmit(i.upstream.getEmit());return n.length===0?a===void 0?Pt(t):C(a,vc({onFailure:r,onSuccess:t})):a===void 0?Pt(()=>o()):C(a,vc({onFailure:r,onSuccess:()=>o()}))}case ay:{let a=i.onDone(i.upstream.getDone());return n.length===0?a===void 0?Pt(t):C(a,vc({onFailure:r,onSuccess:t})):a===void 0?Pt(()=>o()):C(a,vc({onFailure:r,onSuccess:()=>o()}))}case yh:return n.push(i),C(i.onEffect(s.effect),Hu(a=>Pt(()=>{let c=i.onDone(Mn(a));return c===void 0?ve:c})),vc({onFailure:r,onSuccess:()=>o()}));case uy:return n.push(i),n.push(s),Pt(()=>o())}};return o()},UX=x(2,(e,t)=>{let r=(n,o,i)=>c0(ot(()=>new mD(e,void 0,be)),s=>Pt(()=>Q2(s.run(),s).pipe(f0(n),Wt(Ht(n)),K$(Ht(o)))),(s,a)=>{let c=s.close(a);return c===void 0?ve:_b(c,u=>sh(i,Is(u)))});return vb(n=>Ib([LU(t,fI),rn(),rn()]).pipe(Ee(([o,i,s])=>n(r(i,s,o)).pipe(yd(t),Ee(a=>t.addFinalizer(c=>{let u=sd(c)?Jwe(c.cause):void 0;return ph(i).pipe(Ee(l=>l?di(s,void 0).pipe(Wt($I(a)),Wt(qU(a))):di(s,void 0).pipe(Wt(u&&Gl(u)>0?HI(a,VSe(u)):jf(a)),Wt(qU(a)))))}).pipe(Wt(n(Ht(i)))))))))}),Q2=(e,t)=>{let r=e;switch(r._tag){case yh:return C(r.effect,Ee(()=>Q2(t.run(),t)));case cy:return Q2(t.run(),t);case ay:return Pt(()=>t.getDone());case uy:return O2(r,()=>Q2(t.run(),t),Is)}}});var $X,oPe,HX=h(()=>{$X="Done",oPe="Await"});var PQt,MQt,FQt,WX,sPe=h(()=>{HX();PQt="effect/ChannelMergeDecision",MQt=Symbol.for(PQt),FQt={[MQt]:{_R:e=>e,_E0:e=>e,_Z0:e=>e,_E:e=>e,_Z:e=>e}},WX=e=>{let t=Object.create(FQt);return t._tag=oPe,t.f=e,t}});var N2,P2,M2,jX=h(()=>{N2="BothRunning",P2="LeftDone",M2="RightDone"});var UQt,cPe,qX,F2,GX,zX,uPe=h(()=>{jX();UQt="effect/ChannelMergeState",cPe=Symbol.for(UQt),qX={[cPe]:cPe},F2=(e,t)=>{let r=Object.create(qX);return r._tag=N2,r.left=e,r.right=t,r},GX=e=>{let t=Object.create(qX);return t._tag=P2,t.f=e,t},zX=e=>{let t=Object.create(qX);return t._tag=M2,t.f=e,t}});var VX,YX,lPe=h(()=>{VX="BackPressure",YX="BufferSliding"});var WQt,dPe,fPe,pPe,mPe,hPe,JX=h(()=>{oe();lPe();WQt="effect/ChannelMergeStrategy",dPe=Symbol.for(WQt),fPe={[dPe]:dPe},pPe=e=>{let t=Object.create(fPe);return t._tag=VX,t},mPe=e=>{let t=Object.create(fPe);return t._tag=YX,t},hPe=x(2,(e,{onBackPressure:t,onBufferSliding:r})=>{switch(e._tag){case VX:return t();case YX:return r()}})});var I0,hD,gD,AD,APe,KX,jQt,qQt,ZX,XX,yPe=h(()=>{Vs();$u();nr();Ei();Ro();oe();NA();I0="Empty",hD="Emit",gD="Error",AD="Done",APe=e=>({_tag:I0,notifyProducer:e}),KX=e=>({_tag:hD,notifyConsumers:e}),jQt=e=>({_tag:gD,cause:e}),qQt=e=>({_tag:AD,done:e}),ZX=class{ref;constructor(t){this.ref=t}awaitRead(){return Vf(qm(this.ref,t=>t._tag===I0?[Ht(t.notifyProducer),t]:[ve,t]))}get close(){return q$(t=>this.error(qL(t)))}done(t){return Vf(qm(this.ref,r=>{switch(r._tag){case I0:return[Ht(r.notifyProducer),r];case hD:return[pi(r.notifyConsumers,n=>di(n,Re(t)),{discard:!0}),qQt(t)];case gD:return[mh,r];case AD:return[mh,r]}}))}emit(t){return Ee(rn(),r=>Vf(qm(this.ref,n=>{switch(n._tag){case I0:return[Ht(n.notifyProducer),n];case hD:{let o=n.notifyConsumers[0],i=n.notifyConsumers.slice(1);if(o!==void 0)return[di(o,Le(t)),i.length===0?APe(r):KX(i)];throw new Error("Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues")}case gD:return[mh,n];case AD:return[mh,n]}})))}error(t){return Vf(qm(this.ref,r=>{switch(r._tag){case I0:return[Ht(r.notifyProducer),r];case hD:return[pi(r.notifyConsumers,n=>pd(n,t),{discard:!0}),jQt(t)];case gD:return[mh,r];case AD:return[mh,r]}}))}get take(){return this.takeWith(t=>Mn(Fm(t,Re)),t=>vo(t),t=>Cc(Le(t)))}takeWith(t,r,n){return Ee(rn(),o=>Vf(qm(this.ref,i=>{switch(i._tag){case I0:return[Wt(di(i.notifyProducer,void 0),oy(Ht(o),{onFailure:t,onSuccess:xi({onLeft:n,onRight:r})})),KX([o])];case hD:return[oy(Ht(o),{onFailure:t,onSuccess:xi({onLeft:n,onRight:r})}),KX([...i.notifyConsumers,o])];case gD:return[nt(t(i.cause)),i];case AD:return[nt(n(i.done)),i]}})))}},XX=()=>C(rn(),Ee(e=>bc(APe(e))),De(e=>new ZX(e)))});var EPe,yD,v0,xD,bPe,U2,ED,$2,H2,r7,bD,n7,SPe,CPe,W2,j2,SD,q2,o7,G2,z2,i7,s7,k0,e7,Sd,Fb,CD,R0,wPe,IPe,Kf,L2,kPe,vPe,wD=h(()=>{Vs();vr();$u();nr();Ei();mt();Ro();WI();oe();it();ct();a2();NA();ah();nPe();sPe();uPe();JX();yPe();Ob();HX();jX();v2();EPe=(e,t,r)=>Et(nn(bc(()=>ve)),n=>C(nn(hd(Ri(e,o=>ib(n,i=>r(o,i))))),Et(t),b0(o=>Ee(Sc(n),i=>i(o))))),yD=x(2,(e,t)=>DX(e,t,()=>{},()=>{})),v0=e=>{let t=ea({onInput:()=>t,onFailure:In,onDone:Yu});return Vn(e,t)},xD=x(2,(e,t)=>b0(e,()=>t)),bPe=e=>Et(e,be),U2=e=>Sd(e.takeWith(In,t=>Et(cr(t),()=>U2(e)),Yu)),ED=()=>bd({onInput:e=>Et(cr(e),()=>ED()),onFailure:_c,onDone:ta}),$2=x(2,(e,t)=>Et(e,r=>Jf(()=>t(r)))),H2=x(2,(e,t)=>r7(e,Fm(t))),r7=x(2,(e,t)=>C2(e,r=>In(t(r)))),bD=x(2,(e,t)=>{let r=bd({onInput:n=>Et(cr(t(n)),()=>r),onFailure:_c,onDone:ta});return Vn(e,r)}),n7=x(2,(e,t)=>{let r=ea({onInput:n=>C(nn(t(n)),Et(cr),Et(()=>r)),onFailure:In,onDone:ta});return Vn(e,r)}),SPe=e=>t=>CPe(e)(t,Ai),CPe=({bufferSize:e=16,concurrency:t,mergeStrategy:r=pPe()})=>(n,o)=>CD(i=>Go(function*(){let s=t==="unbounded"?Number.MAX_SAFE_INTEGER:t,a=yield*XX(),c=U2(a),u=yield*y0(e);yield*sh(i,Ah(u));let l=yield*uD();yield*sh(i,Ah(l));let d=yield*bc(W()),f=yield*rn(),p=(yield*Y$(s)).withPermits,m=yield*k0(Vn(c,n),i);function g(E){return E.pipe(Ee(xi({onLeft:y=>nt(H(y)),onRight:y=>ju(Vu(u,nt(Le(y))),W())})),z$({until:y=>pt(y)}),Ee(y=>OA(d,wt({onNone:()=>H(y.value),onSome:b=>H(o(b,y.value))}))),Hu(y=>GL(y)?Is(y):Vu(u,Is(y)).pipe(Wt(di(f,void 0)),gd)))}yield*m.pipe(vc({onFailure:E=>Vu(u,Is(E)).pipe(Wt(nt(!1))),onSuccess:xi({onLeft:E=>tD(Bo(Ht(f)),Bo(p(s)(ve)),{onSelfDone:(y,b)=>ju(jf(b),!1),onOtherDone:(y,b)=>Wt(jf(b),Sc(d).pipe(Ee(wt({onNone:()=>Vu(u,nt(Re(E))),onSome:w=>Vu(u,nt(Re(o(w,E))))})),ju(!1)))}),onRight:E=>hPe(r,{onBackPressure:()=>Go(function*(){let y=yield*rn(),b=KT(I=>k0(Vn(c,E),I).pipe(Ee(v=>eD(so(g(v)),so(Bo(Ht(f))))),Ee(be)));return yield*di(y,void 0).pipe(Wt(b),p(1),yd(i)),yield*Ht(y),!(yield*ph(f))}),onBufferSliding:()=>Go(function*(){let y=yield*rn(),b=yield*rn(),w=yield*NNe(l);yield*Qb(l).pipe(Ee(k=>di(k,void 0)),XT(()=>w>=s)),yield*Vu(l,y);let I=KT(k=>k0(Vn(c,E),k).pipe(Ee(R=>so(g(R)).pipe(eD(so(Bo(Ht(f)))),eD(so(Bo(Ht(y)))))),Ee(be)));return yield*di(b,void 0).pipe(Wt(I),p(1),yd(i)),yield*Ht(b),!(yield*ph(f))})})})}),z$({while:E=>E}),yd(i));let A=C(Qb(u),Vf,oy({onFailure:In,onSuccess:xi({onLeft:ta,onRight:E=>Et(cr(E),()=>A)})}),Sd);return fD(A,a)})),W2=x(3,(e,t,r)=>SPe(r)(bD(e,t))),j2=x(2,(e,t)=>{function r(n){return Go(function*(){let o=yield*XX(),i=U2(o),s=yield*k0(Vn(i,e),n),a=yield*k0(Vn(i,t.other),n);function c(l,d,f){return(p,m,g)=>{function A(E){let y=E;return y._tag===$X?nt(nn(Wt(jf(d),y.effect))):De($I(d),es({onFailure:b=>nn(y.f(Mn(b))),onSuccess:xi({onLeft:b=>nn(y.f(vo(b))),onRight:b=>Kf(cr(b),u(g(y.f)))})}))}return es(l,{onFailure:E=>A(p(Mn(E))),onSuccess:xi({onLeft:E=>A(p(vo(E))),onRight:E=>nt(Et(cr(E),()=>Et(nn(yd(Bo(f),n)),y=>u(m(y,d)))))})})}}function u(l){switch(l._tag){case N2:{let d=Bo(GU(l.left)),f=Bo(GU(l.right));return Sd(tD(d,f,{onSelfDone:(p,m)=>Wt(jf(m),c(p,l.right,s)(t.onSelfDone,F2,g=>GX(g))),onOtherDone:(p,m)=>Wt(jf(m),c(p,l.left,a)(t.onOtherDone,(g,A)=>F2(A,g),g=>zX(g)))}))}case P2:return Sd(De(so(a),es({onFailure:d=>nn(l.f(Mn(d))),onSuccess:xi({onLeft:d=>nn(l.f(vo(d))),onRight:d=>Et(cr(d),()=>u(GX(l.f)))})})));case M2:return Sd(De(so(s),es({onFailure:d=>nn(l.f(Mn(d))),onSuccess:xi({onLeft:d=>nn(l.f(vo(d))),onRight:d=>Et(cr(d),()=>u(zX(l.f)))})})))}}return nn($a(l=>{let d=$a(m=>(m.transferChildren(l.scope()),ve)),f=Bo(s).pipe(qu(d),yd(n)),p=Bo(a).pipe(qu(d),yd(n));return gh(f,p,(m,g)=>F2(m,g))})).pipe(Et(u),fD(o))})}return CD(r)}),SD=x(2,(e,t)=>Ju(()=>{let r,n=bd({onInput:i=>Et(cr(i),()=>n),onFailure:i=>(r=kPe(i),In(od(r))),onDone:ta}),o=ea({onInput:i=>C(cr(i),Et(()=>o)),onFailure:i=>fK(i)&&vPe(i.defect)&&ce(i.defect,r)?_c(i.defect.error):In(i),onDone:ta});return Vn(Vn(Vn(e,n),t),o)})),q2=e=>KT(t=>UX(e,t)),o7=e=>q2(v0(e)),G2=e=>Z5(t=>UX(e,t)),z2=e=>Sd(vb(t=>De(ZBe(),r=>TX(_b(t(KBe(e,r)),n=>ET(r,Mn(n))),(n,o)=>ET(r,o))))),i7=e=>Fb(De(u0,t=>Et(nn(e(t)),cr))),s7=()=>Ju(()=>{let e="",t=!1,r=o=>{let i=[];return xf(o,s=>{if(s.length!==0){let a=0,c=s.indexOf("\r"),u=s.indexOf(`
58
+ ${u}`,n}},i=e.spanOptions&&"captureStackTrace"in e.spanOptions?e.spanOptions:{captureStackTrace:o,...e.spanOptions};return iNe(t,e.spanName,i)}var G0t,ws,z0t,V0t,GT,Y0t,J0t,Ib,K0t,Z0t,z5,V5,X0t,FOe,ekt,tkt,LOe,rkt,UOe,hi,nkt,okt,ikt,$Oe,skt,akt,ckt,ukt,lkt,dkt,fkt,Zs,pkt,mkt,$a,$e,HOe,Is,WOe,Ua,kb,jOe,Go,$$,hkt,Y5,nt,H$,gkt,Pt,ot,ve,Akt,ykt,s0,Hu,xkt,Ekt,bkt,qOe,Skt,W$,j$,Ckt,wkt,a0,Ikt,kkt,vkt,J5,Rkt,_kt,Wu,zT,Bkt,ey,Tkt,Dkt,Qkt,Okt,mh,Nkt,Bo,Pkt,Mkt,hd,vb,Fkt,ju,GOe,Lkt,gd,Ukt,$kt,De,Hkt,VT,Ha,Wkt,jkt,K5,zo,qkt,c0,YT,qu,JT,Gkt,zkt,Vkt,Ykt,u0,Z5,KT,Ad,Jkt,Kkt,Zkt,Xkt,evt,tvt,rvt,nvt,ovt,ivt,q$,svt,Rb,avt,yd,l0,cvt,uvt,lvt,dvt,fvt,pvt,mvt,hvt,gvt,zOe,Avt,yvt,xvt,Evt,bvt,Svt,Cvt,wvt,Ivt,kvt,vvt,X5,Rvt,VOe,YOe,_vt,Bvt,Tvt,Dvt,ty,ZT,Qvt,Ovt,ry,d0,eX,Nvt,Pvt,Mvt,Fvt,Lvt,G$,Uvt,JOe,$vt,Hvt,Wvt,jvt,qvt,Gvt,ny,so,f0,zvt,Vvt,Yvt,Jvt,Kvt,Zvt,Xvt,eRt,tRt,XT,rRt,nRt,oRt,Ee,iRt,Vf,eD,sRt,KOe,tD,aRt,Ri,cRt,uRt,lRt,dRt,_b,ZOe,fRt,pRt,z$,mRt,hRt,gRt,ARt,yRt,XOe,xRt,ERt,p0,bRt,SRt,CRt,wRt,IRt,kRt,vRt,RRt,tX,oy,vc,rD,eNe,_Rt,BRt,TRt,DRt,rX,QRt,ORt,tNe,V$,NRt,PRt,MRt,FRt,Yf,LRt,nD,URt,$Rt,HRt,WRt,jRt,rNe,qRt,GRt,hh,zRt,VRt,YRt,JRt,KRt,ZRt,XRt,e_t,t_t,r_t,nX,Y$,J$,n_t,m0,o_t,oX,i_t,xd,s_t,a_t,c_t,Gu,K$,Wt,gh,u_t,l_t,d_t,f_t,p_t,m_t,h_t,g_t,A_t,y_t,x_t,E_t,b_t,S_t,C_t,w_t,I_t,k_t,v_t,R_t,__t,B_t,T_t,D_t,nNe,Q_t,oNe,iNe,O_t,N_t,sNe,P_t,M_t,F_t,L_t,aNe,U_t,$_t,H_t,Z$,W_t,j_t,q_t,nr=h(()=>{oe();Jl();_De();F_();$f();vt();Mf();UI();N5();La();DT();h_();q5();JU();T$();_A();h$();G5();PA();mu();G0t=Om,ws=ar,z0t=nTe,V0t=y8,GT=q1,Y0t=cTe,J0t=DZ,Ib=qA,K0t=K_e,Z0t=Z_e,z5=cke,V5=uke,X0t=eve,FOe=tve,ekt=xke,tkt=V_e,LOe=J_e,rkt=dke,UOe=hke,hi=Ic,nkt=bke,okt=J9,ikt=K9,$Oe=G1,skt=Gke,akt=qke,ckt=nBe,ukt=Y9,lkt=X_e,dkt=tBe,fkt=cBe,Zs=Si,pkt=LTe,mkt=oB,$a=st,$e=ut,HOe=pc,Is=kt,WOe=Tf,Ua=Ci,kb=fA,jOe=Ta,Go=uB,$$=xA,hkt=Fke,Y5=Wke,nt=M,H$=cb,gkt=Zke,Pt=ye,ot=V,ve=Ue,Akt=ku,ykt=J0e,s0=fc,Hu=Bf,xkt=K0e,Ekt=iB,bkt=jCe,qOe=Z0e,Skt=X0e,W$=eke,j$=tke,Ckt=rke,wkt=$B,a0=j1,Ikt=Ske,kkt=Hke,vkt=Jke,J5=sOe,Rkt=mOe,_kt=T5,Wu=RZ,zT=cve,Bkt=uve,ey=PZ,Tkt=fve,Dkt=oke,Qkt=qCe,Okt=yBe,mh=qs,Nkt=aB,Bo=Qa,Pkt=GCe,Mkt=hc,hd=Iu,vb=xn,Fkt=mke,ju=Zt,GOe=kI,Lkt=Y0e,gd=$r,Ukt=mA,$kt=yke,De=te,Hkt=Pke,VT=cB,Ha=hA,Wkt=_I,jkt=Mke,K5=qB,zo=gb,qkt=G_e,c0=_L,YT=ld,qu=Js,JT=QL,Gkt=Gs,zkt=CU,Vkt=wU,Ykt=oBe,u0=r8,Z5=Nu,KT=AT,Ad=IU,Jkt=sBe,Kkt=lBe,Zkt=rTe,Xkt=z_e,evt=ike,tvt=vI,rvt=RI,nvt=oTe,ovt=$U,ivt=td,q$=Da,svt=Ou,Rb=PI,avt=iTe,yd=bT,l0=HU,cvt=eBe,uvt=sTe,lvt=aTe,dvt=x8,fvt=OL,pvt=VCe,mvt=U0e,hvt=iK,gvt=awe,zOe=nke,Avt=Uf,yvt=e8,xvt=QIe,Evt=IDe,bvt=kDe,Svt=RDe,Cvt=vDe,wvt=FB,Ivt=Jm,kvt=sve,vvt=NZ,X5=lTe,Rvt=fTe,VOe=E8,YOe=dTe,_vt=ST,Bvt=NIe,Tvt=OIe,Dvt=kU,ty=Oa,ZT=lke,Qvt=xc,Ovt=kA,ry=l$,d0=MA,eX=FA,Nvt=yve,Pvt=Ave,Mvt=MZ,Fvt=FZ,Lvt=xve,G$=Eve,Uvt=LZ,JOe=pve,$vt=ske,Hvt=LB,Wvt=gTe,jvt=UB,qvt=ake,Gvt=Lke,ny=wu,so=fn,f0=Df,zvt=DL,Vvt=fke,Yvt=pke,Jvt=HB,Kvt=H1,Zvt=dK,Xvt=Hwe,eRt=lve,tRt=dve,XT=V1,rRt=AA,nRt=mve,oRt=hve,Ee=O,iRt=pA,Vf=ys,eD=BU,sRt=rBe,KOe=uTe,tD=n8,aRt=GB,Ri=jo,cRt=rve,uRt=nve,lRt=OZ,dRt=ove,_b=ive,ZOe=_Z,fRt=BZ,pRt=Qke,z$=oOe,mRt=Vke,hRt=B5,gRt=D5,ARt=dOe,yRt=Q5,XOe=yA,xRt=W1,ERt=Cke,p0=tn,bRt=no,SRt=Ss,CRt=ts,wRt=ab,IRt=Kke,kRt=z1,vRt=wke,RRt=Ike,tX=WB,oy=sB,vc=dn,rD=Ho,eNe=kke,_Rt=(e,...t)=>Ym(e)(...t),BRt=vke,TRt=TZ,DRt=Rke,rX=jB,QRt=_ke,ORt=Bke,tNe=Tke,V$=V0e,NRt=j_e,PRt=Dke,MRt=cwe,FRt=q_e,Yf=UE,LRt=eK,nD=LE,URt=Uke,$Rt=$ke,HRt=Ake,WRt=jke,jRt=lI,rNe=PIe,qRt=x(2,(e,t)=>rNe(e,XDe(t))),GRt=uBe,hh=GI,zRt=Zw,VRt=gA,YRt=NL,JRt=t8,KRt=Xke,ZRt=QZ,XRt=iBe,e_t=Z9,t_t=uwe,r_t=gve,nX=LI,Y$=eTe,J$=A8,n_t=tTe,m0=OTe,o_t=QTe,oX=NTe,i_t=PTe,xd=MTe,s_t=FTe,a_t=aBe,c_t=X9,Gu=dBe,K$=vU,Wt=fBe,gh=Hf,u_t=x(2,(e,t)=>gh(e,t,(r,n)=>r(n))),l_t=Qm,d_t=RL,f_t=TL,p_t=x(e=>OOe(e[0]),_Oe),m_t=BOe,h_t=YCe,g_t=TOe,A_t=DOe,y_t=ave,x_t=r1,E_t=FIe,b_t=TU,S_t=JCe,C_t=KCe,w_t=Cve,I_t=bve,k_t=UZ,v_t=$Z,R_t=wve,__t=Rve,B_t=_ve,T_t=Ive,D_t=Sve,nNe=vve,Q_t=Qu,oNe=U1,iNe=WZ,O_t=Bve,N_t=xBe,sNe=$1,P_t=Tve,M_t=Dve,F_t=e=>qg(e)?H$:De(e.value,Au),L_t=x(2,(e,t)=>qg(e)?H$:De(t(e.value),Au)),aNe=e=>{let t=new Map;return new Proxy(e,{get(r,n,o){if(n in r)return Reflect.get(r,n,o);if(t.has(n))return t.get(n);let i=(...d)=>pA(r,f=>typeof f[n]=="function"?(t.set(n,(...p)=>pA(r,m=>m[n](...p))),f[n](...d)):(t.set(n,pA(r,p=>p[n])),f[n])),s=pA(r,d=>d[n]);Object.assign(i,s);let a=i.apply,c=i.bind,u=i.call,l=Object.setPrototypeOf({},Object.getPrototypeOf(s));return l.apply=a,l.bind=c,l.call=u,Object.setPrototypeOf(i,l),t.set(n,i),i}})},U_t=e=>()=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=2;let r=new Error;Error.stackTraceLimit=t;function n(){}return Object.setPrototypeOf(n,Uw),n.key=e,Object.defineProperty(n,"use",{get(){return o=>pA(this,o)}}),Object.defineProperty(n,"stack",{get(){return r.stack}}),aNe(n)},$_t=function(){return function(){let[e,t]=arguments,r="accessors"in t?t.accessors:!1,n=Error.stackTraceLimit;Error.stackTraceLimit=2;let o=new Error;Error.stackTraceLimit=n;let i="unchecked",s=function(d){if(i==="unchecked"){let f=Object.getPrototypeOf(d);if(f===Object.prototype||f===null)i="plain";else{let p=Object.getPrototypeOf(this);Object.setPrototypeOf(p,f),i="patched"}}if(i==="plain")Object.assign(this,d);else if(i==="patched")return Object.setPrototypeOf(d,Object.getPrototypeOf(this)),d};s.prototype._tag=e,Object.defineProperty(s,"make",{get(){return d=>new this(d)}}),Object.defineProperty(s,"use",{get(){return d=>pA(this,d)}}),s.key=e,Object.assign(s,Uw),Object.defineProperty(s,"stack",{get(){return o.stack}});let a="dependencies"in t&&t.dependencies.length>0,c=a?"DefaultWithoutDependencies":"Default",u,l=!1;if("effect"in t?(l=typeof t.effect=="function",Object.defineProperty(s,c,{get(){return l?function(){return JA(s,De(t.effect.apply(null,arguments),d=>new this(d)))}.bind(this):u??=JA(s,De(t.effect,d=>new this(d)))}})):"scoped"in t?(l=typeof t.scoped=="function",Object.defineProperty(s,c,{get(){return l?function(){return KA(s,De(t.scoped.apply(null,arguments),d=>new this(d)))}.bind(this):u??=KA(s,De(t.scoped,d=>new this(d)))}})):"sync"in t?Object.defineProperty(s,c,{get(){return u??=u$(s,()=>new this(t.sync()))}}):Object.defineProperty(s,c,{get(){return u??=zI(s,new this(t.succeed))}}),a){let d;Object.defineProperty(s,"Default",{get(){return l?function(){return Eb(this.DefaultWithoutDependencies.apply(null,arguments),t.dependencies)}:d??=Eb(this.DefaultWithoutDependencies,t.dependencies)}})}return r===!0?aNe(s):s}},H_t=function(e,...t){let r=Error.stackTraceLimit;Error.stackTraceLimit=2;let n=new Error;if(Error.stackTraceLimit=r,typeof e!="string")return POe(e.length,function(...s){let a=Error.stackTraceLimit;Error.stackTraceLimit=2;let c=new Error;return Error.stackTraceLimit=a,MOe({self:this,body:e,args:s,pipeables:t,spanName:"<anonymous>",spanOptions:{context:KE.context(!0)},errorDef:n,errorCall:c})});let o=e,i=t[0];return(s,...a)=>POe(s.length,{[o](...c){let u=Error.stackTraceLimit;Error.stackTraceLimit=2;let l=new Error;return Error.stackTraceLimit=u,MOe({self:this,body:s,args:c,pipeables:a,spanName:o,spanOptions:i,errorDef:n,errorCall:l})}}[o])};Z$=Xw,W_t=()=>e=>e,j_t=()=>e=>e,q_t=()=>e=>e});var h0,cNe,uNe,Bb,g0=h(()=>{vt();h0=pn,cNe=Xi,uNe=Dm,Bb=li});var lNe,dNe,fNe,pNe,mNe=h(()=>{sr();vt();La();DT();_A();lNe=e=>xb(kU(e)),dNe=e=>ch(Ra(Ii,e)),fNe=(e,t)=>(t=Ec(t),KA(Ii,t?.onEnd?jo(Qu(e,t),r=>ld(n=>t.onEnd(r,n))):Qu(e,t))),pNe=e=>xb(TU(e))});var Er={};tr(Er,{CurrentMemoMap:()=>iX,LayerTypeId:()=>z_t,MemoMapTypeId:()=>V_t,annotateLogs:()=>J_t,annotateSpans:()=>K_t,build:()=>Z_t,buildWithMemoMap:()=>cX,buildWithScope:()=>X_t,catchAll:()=>eBt,catchAllCause:()=>tBt,context:()=>hNe,die:()=>rBt,dieSync:()=>nBt,discard:()=>oBt,effect:()=>iy,effectContext:()=>iBt,effectDiscard:()=>gNe,empty:()=>sBt,ensureErrorType:()=>uTt,ensureRequirementsType:()=>lTt,ensureSuccessType:()=>cTt,extendScope:()=>aBt,fail:()=>cBt,failCause:()=>lBt,failCauseSync:()=>dBt,failSync:()=>uBt,fiberRefLocallyScopedWith:()=>BBt,flatMap:()=>fBt,flatten:()=>pBt,fresh:()=>mBt,function:()=>gBt,isFresh:()=>Y_t,isLayer:()=>sX,launch:()=>ABt,locally:()=>vBt,locallyEffect:()=>kBt,locallyScoped:()=>_Bt,locallyWith:()=>RBt,makeMemoMap:()=>sTt,map:()=>ANe,mapError:()=>yBt,match:()=>xBt,matchCause:()=>EBt,memoize:()=>bBt,merge:()=>yNe,mergeAll:()=>aX,mock:()=>hBt,orDie:()=>SBt,orElse:()=>CBt,parentSpan:()=>GBt,passthrough:()=>wBt,project:()=>IBt,provide:()=>sy,provideMerge:()=>sD,retry:()=>TBt,scope:()=>DBt,scoped:()=>X$,scopedContext:()=>e2,scopedDiscard:()=>Rc,service:()=>QBt,setClock:()=>jBt,setConfigProvider:()=>qBt,setRandom:()=>zBt,setRequestBatching:()=>VBt,setRequestCache:()=>JBt,setRequestCaching:()=>YBt,setScheduler:()=>KBt,setTracer:()=>XBt,setTracerEnabled:()=>eTt,setTracerTiming:()=>tTt,setUnhandledErrorLogLevel:()=>rTt,setVersionMismatchErrorLogLevel:()=>nTt,span:()=>ZBt,succeed:()=>Ed,succeedContext:()=>iD,suspend:()=>OBt,sync:()=>NBt,syncContext:()=>PBt,tap:()=>MBt,tapError:()=>FBt,tapErrorCause:()=>LBt,toRuntime:()=>UBt,toRuntimeWithMemoMap:()=>$Bt,unwrapEffect:()=>WBt,unwrapScoped:()=>xNe,updateService:()=>aTt,withParentSpan:()=>iTt,withSpan:()=>oTt,zipWith:()=>HBt});var z_t,V_t,iX,sX,Y_t,J_t,K_t,Z_t,X_t,eBt,tBt,hNe,rBt,nBt,oBt,iy,gNe,iBt,sBt,aBt,cBt,uBt,lBt,dBt,fBt,pBt,mBt,hBt,gBt,ABt,ANe,yBt,xBt,EBt,bBt,yNe,aX,SBt,CBt,wBt,IBt,kBt,vBt,RBt,_Bt,BBt,TBt,DBt,X$,Rc,e2,QBt,Ed,iD,OBt,NBt,PBt,MBt,FBt,LBt,UBt,$Bt,sy,sD,HBt,WBt,xNe,jBt,qBt,GBt,zBt,VBt,YBt,JBt,KBt,ZBt,XBt,eTt,tTt,rTt,nTt,oTt,iTt,sTt,cX,aTt,cTt,uTt,lTt,zu=h(()=>{sr();oe();JE();vt();Mf();La();DT();mNe();q5();CB();PA();z_t=XU,V_t=kT,iX=Q8,sX=RT,Y_t=O8,J_t=SDe,K_t=CDe,Z_t=qTe,X_t=YA,eBt=yb,tBt=P8,hNe=t$,rBt=M8,nBt=zTe,oBt=VTe,iy=JA,gNe=KTe,iBt=Cs,sBt=mDe,aBt=YTe,cBt=F8,uBt=L8,lBt=_T,dBt=r$,fBt=Gf,pBt=JTe,mBt=U8,hBt=nDe,gBt=tDe,ABt=rDe,ANe=i$,yBt=oDe,xBt=a$,EBt=s$,bBt=iDe,yNe=$8,aX=c$,SBt=sDe,CBt=aDe,wBt=cDe,IBt=uDe,kBt=n$,vBt=ZTe,RBt=o$,_Bt=XTe,BBt=eDe,TBt=lDe,DBt=fDe,X$=KA,Rc=xb,e2=BT,QBt=pDe,Ed=zI,iD=ch,OBt=TT,NBt=u$,PBt=hDe,MBt=gDe,FBt=ADe,LBt=yDe,UBt=xDe,$Bt=EDe,sy=Eb,sD=bDe,HBt=H8,WBt=W8,xNe=vT,jBt=e=>Rc(ts(mn,zt(bs,e))),qBt=lNe,GBt=dNe,zBt=e=>Rc(ts(mn,zt(Hm,e))),VBt=e=>Rc(Ss(eI,e)),YBt=e=>Rc(Ss(qT,e)),JBt=e=>Rc(ar(e)?O(e,t=>Ss(i0,t)):Ss(i0,e)),KBt=e=>Rc(Ss(Gm,e)),ZBt=fNe,XBt=pNe,eTt=e=>Rc(Ss(rI,e)),tTt=e=>Rc(Ss(Pm,e)),rTt=e=>Rc(Ss(tI,e)),nTt=e=>Rc(Ss(mB,e)),oTt=wDe,iTt=ZU,sTt=N8,cX=e$,aTt=x(3,(e,t,r)=>sy(e,ANe(hNe(),n=>zt(n,t,r(_a(n,t)))))),cTt=()=>e=>e,uTt=()=>e=>e,lTt=()=>e=>e});var aD={};tr(aD,{CurrentIterationMetadata:()=>rQt,ScheduleDriverTypeId:()=>fTt,ScheduleTypeId:()=>dTt,addDelay:()=>hTt,addDelayEffect:()=>gTt,andThen:()=>ATt,andThenEither:()=>yTt,as:()=>xTt,asVoid:()=>ETt,bothInOut:()=>bTt,check:()=>STt,checkEffect:()=>CTt,collectAllInputs:()=>wTt,collectAllOutputs:()=>ITt,collectUntil:()=>kTt,collectUntilEffect:()=>vTt,collectWhile:()=>RTt,collectWhileEffect:()=>_Tt,compose:()=>BTt,count:()=>OTt,cron:()=>NTt,dayOfMonth:()=>LTt,dayOfWeek:()=>UTt,delayed:()=>$Tt,delayedEffect:()=>HTt,delayedSchedule:()=>WTt,delays:()=>jTt,driver:()=>zTt,duration:()=>VTt,either:()=>YTt,eitherWith:()=>JTt,elapsed:()=>KTt,ensuring:()=>ZTt,exponential:()=>XTt,fibonacci:()=>eDt,fixed:()=>tDt,forever:()=>rDt,fromDelay:()=>nDt,fromDelays:()=>oDt,fromFunction:()=>iDt,hourOfDay:()=>FTt,identity:()=>sDt,intersect:()=>cDt,intersectWith:()=>uDt,isSchedule:()=>mTt,jittered:()=>lDt,jitteredWith:()=>dDt,linear:()=>fDt,makeWithState:()=>pTt,map:()=>pDt,mapBoth:()=>qTt,mapBothEffect:()=>GTt,mapEffect:()=>mDt,mapInput:()=>TTt,mapInputContext:()=>QTt,mapInputEffect:()=>DTt,minuteOfHour:()=>MTt,modifyDelay:()=>hDt,modifyDelayEffect:()=>gDt,onDecision:()=>ADt,once:()=>yDt,passthrough:()=>aDt,provideContext:()=>xDt,provideService:()=>EDt,recurUntil:()=>bDt,recurUntilEffect:()=>SDt,recurUntilOption:()=>CDt,recurUpTo:()=>wDt,recurWhile:()=>IDt,recurWhileEffect:()=>kDt,recurs:()=>vDt,reduce:()=>RDt,reduceEffect:()=>_Dt,repeatForever:()=>BDt,repetitions:()=>TDt,resetAfter:()=>DDt,resetWhen:()=>QDt,run:()=>ODt,secondOfMinute:()=>PTt,spaced:()=>uX,stop:()=>NDt,succeed:()=>PDt,sync:()=>MDt,tapInput:()=>FDt,tapOutput:()=>LDt,unfold:()=>UDt,union:()=>$Dt,unionWith:()=>HDt,untilInput:()=>WDt,untilInputEffect:()=>jDt,untilOutput:()=>qDt,untilOutputEffect:()=>GDt,upTo:()=>zDt,whileInput:()=>VDt,whileInputEffect:()=>YDt,whileOutput:()=>JDt,whileOutputEffect:()=>KDt,windowed:()=>ZDt,zipLeft:()=>XDt,zipRight:()=>eQt,zipWith:()=>tQt});var dTt,fTt,pTt,mTt,hTt,gTt,ATt,yTt,xTt,ETt,bTt,STt,CTt,wTt,ITt,kTt,vTt,RTt,_Tt,BTt,TTt,DTt,QTt,OTt,NTt,PTt,MTt,FTt,LTt,UTt,$Tt,HTt,WTt,jTt,qTt,GTt,zTt,VTt,YTt,JTt,KTt,ZTt,XTt,eDt,tDt,rDt,nDt,oDt,iDt,sDt,aDt,cDt,uDt,lDt,dDt,fDt,pDt,mDt,hDt,gDt,ADt,yDt,xDt,EDt,bDt,SDt,CDt,wDt,IDt,kDt,vDt,RDt,_Dt,BDt,TDt,DDt,QDt,ODt,uX,NDt,PDt,MDt,FDt,LDt,UDt,$Dt,HDt,WDt,jDt,qDt,GDt,zDt,VDt,YDt,JDt,KDt,ZDt,XDt,eQt,tQt,rQt,lX=h(()=>{T$();dTt=y$,fTt=c5,pTt=mr,mTt=x$,hTt=E$,gTt=u5,ATt=rQe,yTt=l5,xTt=nQe,ETt=b$,bTt=oQe,STt=e0,CTt=Cb,wTt=iQe,ITt=wb,kTt=sQe,vTt=aQe,RTt=cQe,_Tt=uQe,BTt=lQe,TTt=d5,DTt=S$,QTt=dQe,OTt=uOe,NTt=fQe,PTt=$Qe,MTt=TQe,FTt=RQe,LTt=pQe,UTt=mQe,$Tt=hQe,HTt=C$,WTt=MT,jTt=gQe,qTt=AQe,GTt=yQe,zTt=FT,VTt=f5,YTt=xQe,JTt=EQe,KTt=_$,ZTt=bQe,XTt=SQe,eDt=CQe,tDt=wQe,rDt=fd,nDt=IQe,oDt=kQe,iDt=vQe,sDt=dh,aDt=h5,cDt=ZA,uDt=p5,lDt=_Qe,dDt=m5,fDt=BQe,pDt=vi,mDt=w$,hDt=DQe,gDt=LT,ADt=QQe,yDt=B$,xDt=OQe,EDt=NQe,bDt=g5,SDt=A5,CDt=PQe,wDt=y5,IDt=x5,kDt=E5,vDt=t0,RDt=I$,_Dt=b5,BDt=fd,TDt=MQe,DDt=FQe,QDt=S5,ODt=LQe,uX=HQe,NDt=lOe,PDt=WQe,MDt=jQe,FDt=qQe,LDt=GQe,UDt=UT,$Dt=C5,HDt=k$,WDt=w5,jDt=$T,qDt=I5,GDt=zQe,zDt=VQe,VDt=k5,YDt=HT,JDt=v$,KDt=YQe,ZDt=JQe,XDt=v5,eQt=KQe,tQt=ZQe,rQt=Sb});var nQt,ENe,oQt,bNe,iQt,n2,sQt,SNe,gX,aQt,cQt,uQt,dX,CNe,wNe,INe,kNe,vNe,lQt,cD,fX,o2,RNe,_Ne,BNe,t2,TNe,DNe,AX,QNe,pX,mX,hX,Db,r2,A0,dQt,fQt,Tb,ONe=h(()=>{wr();vr();id();oe();L$();Kl();it();Me();vt();La();nQt="effect/QueueEnqueue",ENe=Symbol.for(nQt),oQt="effect/QueueDequeue",bNe=Symbol.for(oQt),iQt="effect/QueueStrategy",n2=Symbol.for(iQt),sQt="effect/BackingQueue",SNe=Symbol.for(sQt),gX={_A:e=>e},aQt={_A:e=>e},cQt={_In:e=>e},uQt={_Out:e=>e},dX=class extends Ys{queue;takers;shutdownHook;shutdownFlag;strategy;[ENe]=cQt;[bNe]=uQt;constructor(t,r,n,o,i){super(),this.queue=t,this.takers=r,this.shutdownHook=n,this.shutdownFlag=o,this.strategy=i}pipe(){return Z(this,arguments)}commit(){return this.take}capacity(){return this.queue.capacity()}get size(){return ye(()=>fc(this.unsafeSize(),()=>qs))}unsafeSize(){return Qr(this.shutdownFlag)?W():H(this.queue.length()-P$(this.takers)+this.strategy.surplusSize())}get isEmpty(){return te(this.size,t=>t<=0)}get isFull(){return te(this.size,t=>t>=this.capacity())}get shutdown(){return Iu(st(t=>(C(this.shutdownFlag,js(!0)),C(Du(A0(this.takers),r=>EB(r,t.id()),!1,!1),je(this.strategy.shutdown),AA(Mm(this.shutdownHook,void 0)),$r))))}get isShutdown(){return V(()=>Qr(this.shutdownFlag))}get awaitShutdown(){return Cn(this.shutdownHook)}isActive(){return!Qr(this.shutdownFlag)}unsafeOffer(t){if(Qr(this.shutdownFlag))return!1;let r;if(this.queue.length()===0){let o=C(this.takers,md(mi));o!==mi?(Db(o,t),r=!0):r=!1}else r=!1;if(r)return!0;let n=this.queue.offer(t);return Tb(this.strategy,this.queue,this.takers),n}offer(t){return ye(()=>{if(Qr(this.shutdownFlag))return qs;let r;if(this.queue.length()===0){let o=C(this.takers,md(mi));o!==mi?(Db(o,t),r=!0):r=!1}else r=!1;if(r)return M(!0);let n=this.queue.offer(t);return Tb(this.strategy,this.queue,this.takers),n?M(!0):this.strategy.handleSurplus([t],this.queue,this.takers,this.shutdownFlag)})}offerAll(t){return ye(()=>{if(Qr(this.shutdownFlag))return qs;let r=_e(t),n=this.queue.length()===0?_e(dQt(this.takers,r.length)):Us,[o,i]=C(r,y6(n.length));for(let a=0;a<n.length;a++){let c=n[a],u=o[a];Db(c,u)}if(i.length===0)return M(!0);let s=this.queue.offerAll(i);return Tb(this.strategy,this.queue,this.takers),xu(s)?M(!0):this.strategy.handleSurplus(s,this.queue,this.takers,this.shutdownFlag)})}get take(){return st(t=>{if(Qr(this.shutdownFlag))return qs;let r=this.queue.poll(mi);if(r!==mi)return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),M(r);{let n=wA(t.id());return C(ye(()=>(C(this.takers,XA(n)),Tb(this.strategy,this.queue,this.takers),Qr(this.shutdownFlag)?qs:Cn(n))),hc(()=>V(()=>fQt(this.takers,n))))}})}get takeAll(){return ye(()=>Qr(this.shutdownFlag)?qs:V(()=>{let t=this.queue.pollUpTo(Number.POSITIVE_INFINITY);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Co(t)}))}takeUpTo(t){return ye(()=>Qr(this.shutdownFlag)?qs:V(()=>{let r=this.queue.pollUpTo(t);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),Co(r)}))}takeBetween(t,r){return ye(()=>CNe(this,t,r,Ut()))}},CNe=(e,t,r,n)=>r<t?M(n):C(TNe(e,r),O(o=>{let i=t-o.length;return i===1?C(t2(e),te(s=>C(n,Ir(o),$s(s)))):i>1?C(t2(e),O(s=>CNe(e,i-1,r-o.length-1,C(n,Ir(o),$s(s))))):M(C(n,Ir(o)))})),wNe=e=>C(V(()=>N$(e)),O(t=>cD(o2(t),DNe()))),INe=e=>C(V(()=>N$(e)),O(t=>cD(o2(t),AX()))),kNe=e=>C(V(()=>N$(e)),O(t=>cD(o2(t),QNe()))),vNe=()=>C(V(()=>n0()),O(e=>cD(o2(e),AX()))),lQt=(e,t,r,n,o)=>new dX(e,t,r,n,o),cD=(e,t)=>C(wi(),te(r=>lQt(e,n0(),r,Ba(!1),t))),fX=class{mutable;[SNe]=aQt;constructor(t){this.mutable=t}poll(t){return md(this.mutable,t)}pollUpTo(t){return F$(this.mutable,t)}offerAll(t){return L5(this.mutable,t)}offer(t){return XA(this.mutable,t)}capacity(){return wOe(this.mutable)}length(){return P$(this.mutable)}},o2=e=>new fX(e),RNe=e=>e.size,_Ne=e=>e.shutdown,BNe=x(2,(e,t)=>e.offer(t)),t2=e=>e.take,TNe=x(2,(e,t)=>e.takeUpTo(t)),DNe=()=>new pX,AX=()=>new mX,QNe=()=>new hX,pX=class{[n2]=gX;putters=n0();surplusSize(){return P$(this.putters)}onCompleteTakersWithEmptyQueue(t){for(;!M$(this.putters)&&!M$(t);){let r=md(t,void 0),n=md(this.putters,void 0);n[2]&&Db(n[1],!0),Db(r,n[0])}}get shutdown(){return C(td,O(t=>C(V(()=>A0(this.putters)),O(r=>Du(r,([n,o,i])=>i?C(EB(o,t),$r):Ue,!1,!1)))))}handleSurplus(t,r,n,o){return st(i=>{let s=wA(i.id());return C(ye(()=>(this.unsafeOffer(t,s),this.unsafeOnQueueEmptySpace(r,n),Tb(this,r,n),Qr(o)?qs:Cn(s))),hc(()=>V(()=>this.unsafeRemove(s))))})}unsafeOnQueueEmptySpace(t,r){let n=!0;for(;n&&(t.capacity()===Number.POSITIVE_INFINITY||t.length()<t.capacity());){let o=C(this.putters,md(mi));if(o===mi)n=!1;else{let i=t.offer(o[0]);i&&o[2]?Db(o[1],!0):i||r2(this.putters,C(A0(this.putters),fr(o))),Tb(this,t,r)}}}unsafeOffer(t,r){let n=_e(t);for(let o=0;o<n.length;o++){let i=n[o];o===n.length-1?C(this.putters,XA([i,r,!0])):C(this.putters,XA([i,r,!1]))}}unsafeRemove(t){r2(this.putters,C(A0(this.putters),Tw(([,r])=>r!==t)))}},mX=class{[n2]=gX;surplusSize(){return 0}get shutdown(){return Ue}onCompleteTakersWithEmptyQueue(){}handleSurplus(t,r,n,o){return M(!1)}unsafeOnQueueEmptySpace(t,r){}},hX=class{[n2]=gX;surplusSize(){return 0}get shutdown(){return Ue}onCompleteTakersWithEmptyQueue(){}handleSurplus(t,r,n,o){return V(()=>(this.unsafeOffer(r,t),Tb(this,r,n),!0))}unsafeOnQueueEmptySpace(t,r){}unsafeOffer(t,r){let n=r[Symbol.iterator](),o,i=!0;for(;!(o=n.next()).done&&i;){if(t.capacity()===0)return;t.poll(mi),i=t.offer(o.value)}}},Db=(e,t)=>IA(e,M(t)),r2=(e,t)=>C(e,L5(t)),A0=e=>C(e,F$(Number.POSITIVE_INFINITY)),dQt=(e,t)=>C(e,F$(t)),fQt=(e,t)=>{r2(e,C(A0(e),Tw(r=>t!==r)))},Tb=(e,t,r)=>{let n=!0;for(;n&&t.length()!==0;){let o=C(r,md(mi));if(o!==mi){let i=t.poll(mi);i!==mi?(Db(o,i),e.unsafeOnQueueEmptySpace(t,r)):r2(r,C(A0(r),fr(o))),n=!0}else n=!1}n&&t.length()===0&&!M$(r)&&e.onCompleteTakersWithEmptyQueue(r)}});var y0,i2,s2,uD,NNe,Ah,Vu,Qb,a2=h(()=>{ONe();y0=wNe,i2=INe,s2=kNe,uD=vNe,NNe=RNe,Ah=_Ne,Vu=BNe,Qb=t2});var PNe=h(()=>{});var c2,xX,EX,bX=h(()=>{c2="Continue",xX="Close",EX="Yield"});var hQt,FNe,gQt,SX,LNe=h(()=>{bX();hQt="effect/ChannelChildExecutorDecision",FNe=Symbol.for(hQt),gQt={[FNe]:FNe},SX=e=>{let t=Object.create(gQt);return t._tag=c2,t}});var x0,UNe,CX=h(()=>{x0="ContinuationK",UNe="ContinuationFinalizer"});var HNe,WNe,E0,u2,wX=h(()=>{Ro();CX();HNe=Symbol.for("effect/ChannelContinuation"),WNe={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutDone:e=>e,_OutErr2:e=>e,_OutElem:e=>e,_OutDone2:e=>e},E0=class{onSuccess;onHalt;_tag=x0;[HNe]=WNe;constructor(t,r){this.onSuccess=t,this.onHalt=r}onExit(t){return sd(t)?this.onHalt(t.cause):this.onSuccess(t.value)}},u2=class{finalizer;_tag=UNe;[HNe]=WNe;constructor(t){this.finalizer=t}}});var l2,IX,kX=h(()=>{l2="PullAfterNext",IX="PullAfterAllEnqueued"});var xQt,EQt,bQt,SQt,vX,qNe=h(()=>{kX();xQt="effect/ChannelUpstreamPullStrategy",EQt=Symbol.for(xQt),bQt={_A:e=>e},SQt={[EQt]:bQt},vX=e=>{let t=Object.create(SQt);return t._tag=l2,t.emitSeparator=e,t}});var d2,f2,lD,p2,m2,h2,dD,g2,A2,RX,y2,x2,E2,b2,_X=h(()=>{d2="BracketOut",f2="Bridge",lD="ConcatAll",p2="Emit",m2="Ensuring",h2="Fail",dD="Fold",g2="FromEffect",A2="PipeTo",RX="Provide",y2="Read",x2="Succeed",E2="SucceedNow",b2="Suspend"});var wQt,BX,IQt,Xs,S2,TX,C2,w2,zNe,I2,DX,fD,b0,_c,In,k2,Et,nn,Vn,bd,ea,Yu,ta,Ju,Jf,rs,cr,Ob=h(()=>{Vs();vr();nr();bi();oe();it();Me();ct();LNe();wX();qNe();_X();wQt="effect/Channel",BX=Symbol.for(wQt),IQt={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},Xs={[BX]:IQt,pipe(){return Z(this,arguments)}},S2=e=>se(e,BX)||ws(e),TX=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=d2,r.acquire=()=>e,r.finalizer=t,r}),C2=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=dD,r.channel=e,r.k=new E0(Yu,t),r}),w2=e=>Ju(()=>{let t=[];return Et(Vn(e,zNe(t)),r=>Jf(()=>[Co(t),r]))}),zNe=e=>bd({onInput:t=>Et(Jf(()=>{e.push(t)}),()=>zNe(e)),onFailure:_c,onDone:ta}),I2=(e,t,r)=>{let n=Object.create(Xs);return n._tag=lD,n.combineInners=t,n.combineAll=r,n.onPull=()=>vX(W()),n.onEmit=()=>SX,n.value=()=>e,n.k=be,n},DX=x(4,(e,t,r,n)=>{let o=Object.create(Xs);return o._tag=lD,o.combineInners=r,o.combineAll=n,o.onPull=()=>vX(W()),o.onEmit=()=>SX,o.value=()=>e,o.k=t,o}),fD=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=f2,r.input=t,r.channel=e,r}),b0=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=m2,r.channel=e,r.finalizer=t,r}),_c=e=>In(VE(e)),In=e=>k2(()=>e),k2=e=>{let t=Object.create(Xs);return t._tag=h2,t.error=e,t},Et=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=dD,r.channel=e,r.k=new E0(t,In),r}),nn=e=>{let t=Object.create(Xs);return t._tag=g2,t.effect=()=>e,t},Vn=x(2,(e,t)=>{let r=Object.create(Xs);return r._tag=A2,r.left=()=>e,r.right=()=>t,r}),bd=e=>ea({onInput:e.onInput,onFailure:t=>Ei(sI(t),{onLeft:e.onFailure,onRight:In}),onDone:e.onDone}),ea=e=>{let t=Object.create(Xs);return t._tag=y2,t.more=e.onInput,t.done=new E0(e.onDone,e.onFailure),t},Yu=e=>Jf(()=>e),ta=e=>{let t=Object.create(Xs);return t._tag=E2,t.terminal=e,t},Ju=e=>{let t=Object.create(Xs);return t._tag=b2,t.channel=e,t},Jf=e=>{let t=Object.create(Xs);return t._tag=x2,t.evaluate=e,t},rs=ta(void 0),cr=e=>{let t=Object.create(Xs);return t._tag=p2,t.out=e,t}});var ay,cy,yh,uy,v2=h(()=>{ay="Done",cy="Emit",yh="FromEffect",uy="Read"});var kQt,vQt,R2,Nb,_2,C0,B2,pD,VNe,OX,YNe=h(()=>{nr();v2();kQt=Symbol.for("effect/ChannelState"),vQt={_E:e=>e,_R:e=>e},R2={[kQt]:vQt},Nb=()=>{let e=Object.create(R2);return e._tag=ay,e},_2=()=>{let e=Object.create(R2);return e._tag=cy,e},C0=e=>{let t=Object.create(R2);return t._tag=yh,t.effect=e,t},B2=(e,t,r,n)=>{let o=Object.create(R2);return o._tag=uy,o.upstream=e,o.onEffect=t,o.onEmit=r,o.onDone=n,o},pD=e=>e._tag===yh,VNe=e=>pD(e)?e.effect:ve,OX=e=>pD(e)?a0(e.effect):void 0});var NX,T2,D2,PX,Pb,ly,Mb,w0,JNe=h(()=>{nr();Ro();oe();NX="PullFromChild",T2="PullFromUpstream",D2="DrainChildExecutors",PX="Emit",Pb=class{childExecutor;parentSubexecutor;onEmit;_tag=NX;constructor(t,r,n){this.childExecutor=t,this.parentSubexecutor=r,this.onEmit=n}close(t){let r=this.childExecutor.close(t),n=this.parentSubexecutor.close(t);return r!==void 0&&n!==void 0?gh(so(r),so(n),(o,i)=>C(o,LA(i))):r!==void 0?r:n!==void 0?n:void 0}enqueuePullFromChild(t){return this}},ly=class e{upstreamExecutor;createChild;lastDone;activeChildExecutors;combineChildResults;combineWithChildResult;onPull;onEmit;_tag=T2;constructor(t,r,n,o,i,s,a,c){this.upstreamExecutor=t,this.createChild=r,this.lastDone=n,this.activeChildExecutors=o,this.combineChildResults=i,this.combineWithChildResult=s,this.onPull=a,this.onEmit=c}close(t){let r=this.upstreamExecutor.close(t),o=[...this.activeChildExecutors.map(i=>i!==void 0?i.childExecutor.close(t):void 0),r].reduce((i,s)=>i!==void 0&&s!==void 0?gh(i,so(s),(a,c)=>LA(a,c)):i!==void 0?i:s!==void 0?so(s):void 0,void 0);return o}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.createChild,this.lastDone,[...this.activeChildExecutors,t],this.combineChildResults,this.combineWithChildResult,this.onPull,this.onEmit)}},Mb=class e{upstreamExecutor;lastDone;activeChildExecutors;upstreamDone;combineChildResults;combineWithChildResult;onPull;_tag=D2;constructor(t,r,n,o,i,s,a){this.upstreamExecutor=t,this.lastDone=r,this.activeChildExecutors=n,this.upstreamDone=o,this.combineChildResults=i,this.combineWithChildResult=s,this.onPull=a}close(t){let r=this.upstreamExecutor.close(t),o=[...this.activeChildExecutors.map(i=>i!==void 0?i.childExecutor.close(t):void 0),r].reduce((i,s)=>i!==void 0&&s!==void 0?gh(i,so(s),(a,c)=>LA(a,c)):i!==void 0?i:s!==void 0?so(s):void 0,void 0);return o}enqueuePullFromChild(t){return new e(this.upstreamExecutor,this.lastDone,[...this.activeChildExecutors,t],this.upstreamDone,this.combineChildResults,this.combineWithChildResult,this.onPull)}},w0=class{value;next;_tag=PX;constructor(t,r){this.value=t,this.next=r}close(t){let r=this.next.close(t);return r}enqueuePullFromChild(t){return this}}});var KNe,ZNe,XNe=h(()=>{KNe="Pulled",ZNe="NoUpstream"});var TQt,DQt,QQt,ePe,MX,tPe,rPe=h(()=>{XNe();TQt="effect/ChannelUpstreamPullRequest",DQt=Symbol.for(TQt),QQt={_A:e=>e},ePe={[DQt]:QQt},MX=e=>{let t=Object.create(ePe);return t._tag=KNe,t.value=e,t},tPe=e=>{let t=Object.create(ePe);return t._tag=ZNe,t.activeDownstreamCount=e,t}});var mD,FX,LX,O2,UX,Q2,nPe=h(()=>{Vs();$u();nr();a1();Ro();WI();Zl();oe();dc();it();ah();Ob();_X();bX();v2();kX();CX();YNe();wX();JNe();rPe();mD=class e{_activeSubexecutor=void 0;_cancelled=void 0;_closeLastSubstream=void 0;_currentChannel;_done=void 0;_doneStack=[];_emitted=void 0;_executeCloseLastSubstream;_input=void 0;_inProgressFinalizer=void 0;_providedEnv;constructor(t,r,n){this._currentChannel=t,this._executeCloseLastSubstream=n,this._providedEnv=r}run(){let t;for(;t===void 0;)if(this._cancelled!==void 0)t=this.processCancellation();else if(this._activeSubexecutor!==void 0)t=this.runSubexecutor();else try{if(this._currentChannel===void 0)t=Nb();else switch(ws(this._currentChannel)&&(this._currentChannel=nn(this._currentChannel)),this._currentChannel._tag){case d2:{t=this.runBracketOut(this._currentChannel);break}case f2:{let r=this._currentChannel.input;if(this._currentChannel=this._currentChannel.channel,this._input!==void 0){let n=this._input;this._input=void 0;let o=()=>Ee(r.awaitRead(),()=>Pt(()=>{let i=n.run();switch(i._tag){case ay:return es(n.getDone(),{onFailure:s=>r.error(s),onSuccess:s=>r.done(s)});case cy:return Ee(r.emit(n.getEmit()),()=>o());case yh:return vc(i.effect,{onFailure:s=>r.error(s),onSuccess:()=>o()});case uy:return O2(i,()=>o(),s=>r.error(s))}}));t=C0(Ee(Rb(Bo(o())),i=>ot(()=>this.addFinalizer(s=>Ee(jf(i),()=>Pt(()=>{let a=this.restorePipe(s,n);return a!==void 0?a:ve}))))))}break}case lD:{let r=new e(this._currentChannel.value(),this._providedEnv,o=>ot(()=>{let i=this._closeLastSubstream===void 0?ve:this._closeLastSubstream;this._closeLastSubstream=C(i,Wt(o))}));r._input=this._input;let n=this._currentChannel;this._activeSubexecutor=new ly(r,o=>n.k(o),void 0,[],(o,i)=>n.combineInners(o,i),(o,i)=>n.combineAll(o,i),o=>n.onPull(o),o=>n.onEmit(o)),this._closeLastSubstream=void 0,this._currentChannel=void 0;break}case p2:{this._emitted=this._currentChannel.out,this._currentChannel=this._activeSubexecutor!==void 0?void 0:rs,t=_2();break}case m2:{this.runEnsuring(this._currentChannel);break}case h2:{t=this.doneHalt(this._currentChannel.error());break}case dD:{this._doneStack.push(this._currentChannel.k),this._currentChannel=this._currentChannel.channel;break}case g2:{let r=this._providedEnv===void 0?this._currentChannel.effect():C(this._currentChannel.effect(),ry(this._providedEnv));t=C0(vc(r,{onFailure:n=>{let o=this.doneHalt(n);return o!==void 0&&pD(o)?o.effect:ve},onSuccess:n=>{let o=this.doneSucceed(n);return o!==void 0&&pD(o)?o.effect:ve}}));break}case A2:{let r=this._input,n=new e(this._currentChannel.left(),this._providedEnv,o=>this._executeCloseLastSubstream(o));n._input=r,this._input=n,this.addFinalizer(o=>{let i=this.restorePipe(o,r);return i!==void 0?i:ve}),this._currentChannel=this._currentChannel.right();break}case RX:{let r=this._providedEnv;this._providedEnv=this._currentChannel.context(),this._currentChannel=this._currentChannel.inner,this.addFinalizer(()=>ot(()=>{this._providedEnv=r}));break}case y2:{let r=this._currentChannel;t=B2(this._input,be,n=>{try{this._currentChannel=r.more(n)}catch(o){this._currentChannel=r.done.onExit(VB(o))}},n=>{let o=i=>r.done.onExit(i);this._currentChannel=o(n)});break}case x2:{t=this.doneSucceed(this._currentChannel.evaluate());break}case E2:{t=this.doneSucceed(this._currentChannel.terminal);break}case b2:{this._currentChannel=this._currentChannel.channel();break}}}catch(r){this._currentChannel=In(od(r))}return t}getDone(){return this._done}getEmit(){return this._emitted}cancelWith(t){this._cancelled=t}clearInProgressFinalizer(){this._inProgressFinalizer=void 0}storeInProgressFinalizer(t){this._inProgressFinalizer=t}popAllFinalizers(t){let r=[],n=this._doneStack.pop();for(;n;)n._tag==="ContinuationFinalizer"&&r.push(n.finalizer),n=this._doneStack.pop();let o=r.length===0?ve:LX(r,t);return this.storeInProgressFinalizer(o),o}popNextFinalizers(){let t=[];for(;this._doneStack.length!==0;){let r=this._doneStack[this._doneStack.length-1];if(r._tag===x0)return t;t.push(r),this._doneStack.pop()}return t}restorePipe(t,r){let n=this._input;return this._input=r,n!==void 0?n.close(t):ve}close(t){let r,n=this._inProgressFinalizer;n!==void 0&&(r=C(n,qu(ot(()=>this.clearInProgressFinalizer()))));let o,i=this.popAllFinalizers(t);i!==void 0&&(o=C(i,qu(ot(()=>this.clearInProgressFinalizer()))));let s=this._activeSubexecutor===void 0?void 0:this._activeSubexecutor.close(t);if(!(s===void 0&&r===void 0&&o===void 0))return C(so(FX(s)),Gu(so(FX(r))),Gu(so(FX(o))),De(([[a,c],u])=>C(a,LA(c),LA(u))),hd,Ee(a=>Pt(()=>a)))}doneSucceed(t){if(this._doneStack.length===0)return this._done=vo(t),this._currentChannel=void 0,Nb();let r=this._doneStack[this._doneStack.length-1];if(r._tag===x0){this._doneStack.pop(),this._currentChannel=r.onSuccess(t);return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=vo(t),this._currentChannel=void 0,Nb();let o=LX(n.map(s=>s.finalizer),vo(t));this.storeInProgressFinalizer(o);let i=C(o,qu(ot(()=>this.clearInProgressFinalizer())),hd,Ee(()=>ot(()=>this.doneSucceed(t))));return C0(i)}doneHalt(t){if(this._doneStack.length===0)return this._done=Mn(t),this._currentChannel=void 0,Nb();let r=this._doneStack[this._doneStack.length-1];if(r._tag===x0){this._doneStack.pop();try{this._currentChannel=r.onHalt(t)}catch(s){this._currentChannel=In(od(s))}return}let n=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=n.reverse(),this._done=Mn(t),this._currentChannel=void 0,Nb();let o=LX(n.map(s=>s.finalizer),Mn(t));this.storeInProgressFinalizer(o);let i=C(o,qu(ot(()=>this.clearInProgressFinalizer())),hd,Ee(()=>ot(()=>this.doneHalt(t))));return C0(i)}processCancellation(){return this._currentChannel=void 0,this._done=this._cancelled,this._cancelled=void 0,Nb()}runBracketOut(t){let r=hd(vc(this.provide(t.acquire()),{onFailure:n=>ot(()=>{this._currentChannel=In(n)}),onSuccess:n=>ot(()=>{this.addFinalizer(o=>this.provide(t.finalizer(n,o))),this._currentChannel=cr(n)})}));return C0(r)}provide(t){return this._providedEnv===void 0?t:C(t,ry(this._providedEnv))}runEnsuring(t){this.addFinalizer(t.finalizer),this._currentChannel=t.channel}addFinalizer(t){this._doneStack.push(new u2(t))}runSubexecutor(){let t=this._activeSubexecutor;switch(t._tag){case NX:return this.pullFromChild(t.childExecutor,t.parentSubexecutor,t.onEmit,t);case T2:return this.pullFromUpstream(t);case D2:return this.drainChildExecutors(t);case PX:return this._emitted=t.value,this._activeSubexecutor=t.next,_2()}}replaceSubexecutor(t){this._currentChannel=void 0,this._activeSubexecutor=t}finishWithExit(t){let r=es(t,{onFailure:n=>this.doneHalt(n),onSuccess:n=>this.doneSucceed(n)});return this._activeSubexecutor=void 0,r===void 0?ve:VNe(r)}finishSubexecutorWithCloseEffect(t,...r){this.addFinalizer(()=>C(r,hi(o=>C(ot(()=>o(t)),Ee(i=>i!==void 0?i:ve)),{discard:!0})));let n=C(t,es({onFailure:o=>this.doneHalt(o),onSuccess:o=>this.doneSucceed(o)}));return this._activeSubexecutor=void 0,n}applyUpstreamPullStrategy(t,r,n){switch(n._tag){case l2:{let o=!t||r.some(i=>i!==void 0);return[n.emitSeparator,o?[void 0,...r]:r]}case IX:{let o=!t||r.some(i=>i!==void 0);return[n.emitSeparator,o?[...r,void 0]:r]}}}pullFromChild(t,r,n,o){return B2(t,be,i=>{let s=n(i);switch(s._tag){case c2:break;case xX:{this.finishWithDoneValue(t,r,s.value);break}case EX:{let a=r.enqueuePullFromChild(o);this.replaceSubexecutor(a);break}}this._activeSubexecutor=new w0(i,this._activeSubexecutor)},es({onFailure:i=>{let s=this.handleSubexecutorFailure(t,r,i);return s===void 0?void 0:OX(s)},onSuccess:i=>{this.finishWithDoneValue(t,r,i)}}))}finishWithDoneValue(t,r,n){let o=r;switch(o._tag){case T2:{let i=new ly(o.upstreamExecutor,o.createChild,o.lastDone!==void 0?o.combineChildResults(o.lastDone,n):n,o.activeChildExecutors,o.combineChildResults,o.combineWithChildResult,o.onPull,o.onEmit);this._closeLastSubstream=t.close(vo(n)),this.replaceSubexecutor(i);break}case D2:{let i=new Mb(o.upstreamExecutor,o.lastDone!==void 0?o.combineChildResults(o.lastDone,n):n,o.activeChildExecutors,o.upstreamDone,o.combineChildResults,o.combineWithChildResult,o.onPull);this._closeLastSubstream=t.close(vo(n)),this.replaceSubexecutor(i);break}default:break}}handleSubexecutorFailure(t,r,n){return this.finishSubexecutorWithCloseEffect(Mn(n),o=>r.close(o),o=>t.close(o))}pullFromUpstream(t){if(t.activeChildExecutors.length===0)return this.performPullFromUpstream(t);let r=t.activeChildExecutors[0],n=new ly(t.upstreamExecutor,t.createChild,t.lastDone,t.activeChildExecutors.slice(1),t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit);if(r===void 0)return this.performPullFromUpstream(n);this.replaceSubexecutor(new Pb(r.childExecutor,n,r.onEmit))}performPullFromUpstream(t){return B2(t.upstreamExecutor,r=>{let n=this._closeLastSubstream===void 0?ve:this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(n),Wt(r))},r=>{if(this._closeLastSubstream!==void 0){let s=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(s),De(()=>{let a=new e(t.createChild(r),this._providedEnv,this._executeCloseLastSubstream);a._input=this._input;let[c,u]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(MX(r)));this._activeSubexecutor=new Pb(a,new ly(t.upstreamExecutor,t.createChild,t.lastDone,u,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),pt(c)&&(this._activeSubexecutor=new w0(c.value,this._activeSubexecutor))}))}let n=new e(t.createChild(r),this._providedEnv,this._executeCloseLastSubstream);n._input=this._input;let[o,i]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(MX(r)));this._activeSubexecutor=new Pb(n,new ly(t.upstreamExecutor,t.createChild,t.lastDone,i,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),pt(o)&&(this._activeSubexecutor=new w0(o.value,this._activeSubexecutor))},r=>{if(t.activeChildExecutors.some(i=>i!==void 0)){let i=new Mb(t.upstreamExecutor,t.lastDone,[void 0,...t.activeChildExecutors],t.upstreamExecutor.getDone(),t.combineChildResults,t.combineWithChildResult,t.onPull);if(this._closeLastSubstream!==void 0){let s=this._closeLastSubstream;return this._closeLastSubstream=void 0,C(this._executeCloseLastSubstream(s),De(()=>this.replaceSubexecutor(i)))}this.replaceSubexecutor(i);return}let n=this._closeLastSubstream,o=this.finishSubexecutorWithCloseEffect(C(r,J1(i=>t.combineWithChildResult(t.lastDone,i))),()=>n,i=>t.upstreamExecutor.close(i));return o===void 0?void 0:OX(o)})}drainChildExecutors(t){if(t.activeChildExecutors.length===0){let i=this._closeLastSubstream;return i!==void 0&&this.addFinalizer(()=>nt(i)),this.finishSubexecutorWithCloseEffect(t.upstreamDone,()=>i,s=>t.upstreamExecutor.close(s))}let r=t.activeChildExecutors[0],n=t.activeChildExecutors.slice(1);if(r===void 0){let[i,s]=this.applyUpstreamPullStrategy(!0,n,t.onPull(tPe(n.reduce((a,c)=>c!==void 0?a+1:a,0))));return this.replaceSubexecutor(new Mb(t.upstreamExecutor,t.lastDone,s,t.upstreamDone,t.combineChildResults,t.combineWithChildResult,t.onPull)),pt(i)?(this._emitted=i.value,_2()):void 0}let o=new Mb(t.upstreamExecutor,t.lastDone,n,t.upstreamDone,t.combineChildResults,t.combineWithChildResult,t.onPull);this.replaceSubexecutor(new Pb(r.childExecutor,o,r.onEmit))}},FX=e=>e!==void 0?e:ve,LX=(e,t)=>C(hi(e,r=>so(r(t))),De(r=>C(jZ(r),Nt(()=>wc))),Ee(r=>Pt(()=>r))),O2=(e,t,r)=>{let n=[e],o=()=>{let i=n.pop();if(i===void 0||i.upstream===void 0)return kb("Unexpected end of input for channel execution");let s=i.upstream.run();switch(s._tag){case cy:{let a=i.onEmit(i.upstream.getEmit());return n.length===0?a===void 0?Pt(t):C(a,vc({onFailure:r,onSuccess:t})):a===void 0?Pt(()=>o()):C(a,vc({onFailure:r,onSuccess:()=>o()}))}case ay:{let a=i.onDone(i.upstream.getDone());return n.length===0?a===void 0?Pt(t):C(a,vc({onFailure:r,onSuccess:t})):a===void 0?Pt(()=>o()):C(a,vc({onFailure:r,onSuccess:()=>o()}))}case yh:return n.push(i),C(i.onEffect(s.effect),Hu(a=>Pt(()=>{let c=i.onDone(Mn(a));return c===void 0?ve:c})),vc({onFailure:r,onSuccess:()=>o()}));case uy:return n.push(i),n.push(s),Pt(()=>o())}};return o()},UX=x(2,(e,t)=>{let r=(n,o,i)=>c0(ot(()=>new mD(e,void 0,be)),s=>Pt(()=>Q2(s.run(),s).pipe(f0(n),Wt(Ht(n)),K$(Ht(o)))),(s,a)=>{let c=s.close(a);return c===void 0?ve:_b(c,u=>sh(i,Is(u)))});return vb(n=>Ib([LU(t,fI),rn(),rn()]).pipe(Ee(([o,i,s])=>n(r(i,s,o)).pipe(yd(t),Ee(a=>t.addFinalizer(c=>{let u=sd(c)?Jwe(c.cause):void 0;return ph(i).pipe(Ee(l=>l?pi(s,void 0).pipe(Wt($I(a)),Wt(qU(a))):pi(s,void 0).pipe(Wt(u&&Gl(u)>0?HI(a,VSe(u)):jf(a)),Wt(qU(a)))))}).pipe(Wt(n(Ht(i)))))))))}),Q2=(e,t)=>{let r=e;switch(r._tag){case yh:return C(r.effect,Ee(()=>Q2(t.run(),t)));case cy:return Q2(t.run(),t);case ay:return Pt(()=>t.getDone());case uy:return O2(r,()=>Q2(t.run(),t),Is)}}});var $X,oPe,HX=h(()=>{$X="Done",oPe="Await"});var PQt,MQt,FQt,WX,sPe=h(()=>{HX();PQt="effect/ChannelMergeDecision",MQt=Symbol.for(PQt),FQt={[MQt]:{_R:e=>e,_E0:e=>e,_Z0:e=>e,_E:e=>e,_Z:e=>e}},WX=e=>{let t=Object.create(FQt);return t._tag=oPe,t.f=e,t}});var N2,P2,M2,jX=h(()=>{N2="BothRunning",P2="LeftDone",M2="RightDone"});var UQt,cPe,qX,F2,GX,zX,uPe=h(()=>{jX();UQt="effect/ChannelMergeState",cPe=Symbol.for(UQt),qX={[cPe]:cPe},F2=(e,t)=>{let r=Object.create(qX);return r._tag=N2,r.left=e,r.right=t,r},GX=e=>{let t=Object.create(qX);return t._tag=P2,t.f=e,t},zX=e=>{let t=Object.create(qX);return t._tag=M2,t.f=e,t}});var VX,YX,lPe=h(()=>{VX="BackPressure",YX="BufferSliding"});var WQt,dPe,fPe,pPe,mPe,hPe,JX=h(()=>{oe();lPe();WQt="effect/ChannelMergeStrategy",dPe=Symbol.for(WQt),fPe={[dPe]:dPe},pPe=e=>{let t=Object.create(fPe);return t._tag=VX,t},mPe=e=>{let t=Object.create(fPe);return t._tag=YX,t},hPe=x(2,(e,{onBackPressure:t,onBufferSliding:r})=>{switch(e._tag){case VX:return t();case YX:return r()}})});var I0,hD,gD,AD,APe,KX,jQt,qQt,ZX,XX,yPe=h(()=>{Vs();$u();nr();bi();Ro();oe();NA();I0="Empty",hD="Emit",gD="Error",AD="Done",APe=e=>({_tag:I0,notifyProducer:e}),KX=e=>({_tag:hD,notifyConsumers:e}),jQt=e=>({_tag:gD,cause:e}),qQt=e=>({_tag:AD,done:e}),ZX=class{ref;constructor(t){this.ref=t}awaitRead(){return Vf(qm(this.ref,t=>t._tag===I0?[Ht(t.notifyProducer),t]:[ve,t]))}get close(){return q$(t=>this.error(qL(t)))}done(t){return Vf(qm(this.ref,r=>{switch(r._tag){case I0:return[Ht(r.notifyProducer),r];case hD:return[hi(r.notifyConsumers,n=>pi(n,Re(t)),{discard:!0}),qQt(t)];case gD:return[mh,r];case AD:return[mh,r]}}))}emit(t){return Ee(rn(),r=>Vf(qm(this.ref,n=>{switch(n._tag){case I0:return[Ht(n.notifyProducer),n];case hD:{let o=n.notifyConsumers[0],i=n.notifyConsumers.slice(1);if(o!==void 0)return[pi(o,Le(t)),i.length===0?APe(r):KX(i)];throw new Error("Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues")}case gD:return[mh,n];case AD:return[mh,n]}})))}error(t){return Vf(qm(this.ref,r=>{switch(r._tag){case I0:return[Ht(r.notifyProducer),r];case hD:return[hi(r.notifyConsumers,n=>pd(n,t),{discard:!0}),jQt(t)];case gD:return[mh,r];case AD:return[mh,r]}}))}get take(){return this.takeWith(t=>Mn(Fm(t,Re)),t=>vo(t),t=>Cc(Le(t)))}takeWith(t,r,n){return Ee(rn(),o=>Vf(qm(this.ref,i=>{switch(i._tag){case I0:return[Wt(pi(i.notifyProducer,void 0),oy(Ht(o),{onFailure:t,onSuccess:Ei({onLeft:n,onRight:r})})),KX([o])];case hD:return[oy(Ht(o),{onFailure:t,onSuccess:Ei({onLeft:n,onRight:r})}),KX([...i.notifyConsumers,o])];case gD:return[nt(t(i.cause)),i];case AD:return[nt(n(i.done)),i]}})))}},XX=()=>C(rn(),Ee(e=>bc(APe(e))),De(e=>new ZX(e)))});var EPe,yD,v0,xD,bPe,U2,ED,$2,H2,r7,bD,n7,SPe,CPe,W2,j2,SD,q2,o7,G2,z2,i7,s7,k0,e7,Sd,Fb,CD,R0,wPe,IPe,Kf,L2,kPe,vPe,wD=h(()=>{Vs();vr();$u();nr();bi();mt();Ro();WI();oe();it();ct();a2();NA();ah();nPe();sPe();uPe();JX();yPe();Ob();HX();jX();v2();EPe=(e,t,r)=>Et(nn(bc(()=>ve)),n=>C(nn(hd(Ri(e,o=>ib(n,i=>r(o,i))))),Et(t),b0(o=>Ee(Sc(n),i=>i(o))))),yD=x(2,(e,t)=>DX(e,t,()=>{},()=>{})),v0=e=>{let t=ea({onInput:()=>t,onFailure:In,onDone:Yu});return Vn(e,t)},xD=x(2,(e,t)=>b0(e,()=>t)),bPe=e=>Et(e,be),U2=e=>Sd(e.takeWith(In,t=>Et(cr(t),()=>U2(e)),Yu)),ED=()=>bd({onInput:e=>Et(cr(e),()=>ED()),onFailure:_c,onDone:ta}),$2=x(2,(e,t)=>Et(e,r=>Jf(()=>t(r)))),H2=x(2,(e,t)=>r7(e,Fm(t))),r7=x(2,(e,t)=>C2(e,r=>In(t(r)))),bD=x(2,(e,t)=>{let r=bd({onInput:n=>Et(cr(t(n)),()=>r),onFailure:_c,onDone:ta});return Vn(e,r)}),n7=x(2,(e,t)=>{let r=ea({onInput:n=>C(nn(t(n)),Et(cr),Et(()=>r)),onFailure:In,onDone:ta});return Vn(e,r)}),SPe=e=>t=>CPe(e)(t,yi),CPe=({bufferSize:e=16,concurrency:t,mergeStrategy:r=pPe()})=>(n,o)=>CD(i=>Go(function*(){let s=t==="unbounded"?Number.MAX_SAFE_INTEGER:t,a=yield*XX(),c=U2(a),u=yield*y0(e);yield*sh(i,Ah(u));let l=yield*uD();yield*sh(i,Ah(l));let d=yield*bc(W()),f=yield*rn(),p=(yield*Y$(s)).withPermits,m=yield*k0(Vn(c,n),i);function g(E){return E.pipe(Ee(Ei({onLeft:y=>nt(H(y)),onRight:y=>ju(Vu(u,nt(Le(y))),W())})),z$({until:y=>pt(y)}),Ee(y=>OA(d,wt({onNone:()=>H(y.value),onSome:b=>H(o(b,y.value))}))),Hu(y=>GL(y)?Is(y):Vu(u,Is(y)).pipe(Wt(pi(f,void 0)),gd)))}yield*m.pipe(vc({onFailure:E=>Vu(u,Is(E)).pipe(Wt(nt(!1))),onSuccess:Ei({onLeft:E=>tD(Bo(Ht(f)),Bo(p(s)(ve)),{onSelfDone:(y,b)=>ju(jf(b),!1),onOtherDone:(y,b)=>Wt(jf(b),Sc(d).pipe(Ee(wt({onNone:()=>Vu(u,nt(Re(E))),onSome:w=>Vu(u,nt(Re(o(w,E))))})),ju(!1)))}),onRight:E=>hPe(r,{onBackPressure:()=>Go(function*(){let y=yield*rn(),b=KT(I=>k0(Vn(c,E),I).pipe(Ee(v=>eD(so(g(v)),so(Bo(Ht(f))))),Ee(be)));return yield*pi(y,void 0).pipe(Wt(b),p(1),yd(i)),yield*Ht(y),!(yield*ph(f))}),onBufferSliding:()=>Go(function*(){let y=yield*rn(),b=yield*rn(),w=yield*NNe(l);yield*Qb(l).pipe(Ee(k=>pi(k,void 0)),XT(()=>w>=s)),yield*Vu(l,y);let I=KT(k=>k0(Vn(c,E),k).pipe(Ee(R=>so(g(R)).pipe(eD(so(Bo(Ht(f)))),eD(so(Bo(Ht(y)))))),Ee(be)));return yield*pi(b,void 0).pipe(Wt(I),p(1),yd(i)),yield*Ht(b),!(yield*ph(f))})})})}),z$({while:E=>E}),yd(i));let A=C(Qb(u),Vf,oy({onFailure:In,onSuccess:Ei({onLeft:ta,onRight:E=>Et(cr(E),()=>A)})}),Sd);return fD(A,a)})),W2=x(3,(e,t,r)=>SPe(r)(bD(e,t))),j2=x(2,(e,t)=>{function r(n){return Go(function*(){let o=yield*XX(),i=U2(o),s=yield*k0(Vn(i,e),n),a=yield*k0(Vn(i,t.other),n);function c(l,d,f){return(p,m,g)=>{function A(E){let y=E;return y._tag===$X?nt(nn(Wt(jf(d),y.effect))):De($I(d),es({onFailure:b=>nn(y.f(Mn(b))),onSuccess:Ei({onLeft:b=>nn(y.f(vo(b))),onRight:b=>Kf(cr(b),u(g(y.f)))})}))}return es(l,{onFailure:E=>A(p(Mn(E))),onSuccess:Ei({onLeft:E=>A(p(vo(E))),onRight:E=>nt(Et(cr(E),()=>Et(nn(yd(Bo(f),n)),y=>u(m(y,d)))))})})}}function u(l){switch(l._tag){case N2:{let d=Bo(GU(l.left)),f=Bo(GU(l.right));return Sd(tD(d,f,{onSelfDone:(p,m)=>Wt(jf(m),c(p,l.right,s)(t.onSelfDone,F2,g=>GX(g))),onOtherDone:(p,m)=>Wt(jf(m),c(p,l.left,a)(t.onOtherDone,(g,A)=>F2(A,g),g=>zX(g)))}))}case P2:return Sd(De(so(a),es({onFailure:d=>nn(l.f(Mn(d))),onSuccess:Ei({onLeft:d=>nn(l.f(vo(d))),onRight:d=>Et(cr(d),()=>u(GX(l.f)))})})));case M2:return Sd(De(so(s),es({onFailure:d=>nn(l.f(Mn(d))),onSuccess:Ei({onLeft:d=>nn(l.f(vo(d))),onRight:d=>Et(cr(d),()=>u(zX(l.f)))})})))}}return nn($a(l=>{let d=$a(m=>(m.transferChildren(l.scope()),ve)),f=Bo(s).pipe(qu(d),yd(n)),p=Bo(a).pipe(qu(d),yd(n));return gh(f,p,(m,g)=>F2(m,g))})).pipe(Et(u),fD(o))})}return CD(r)}),SD=x(2,(e,t)=>Ju(()=>{let r,n=bd({onInput:i=>Et(cr(i),()=>n),onFailure:i=>(r=kPe(i),In(od(r))),onDone:ta}),o=ea({onInput:i=>C(cr(i),Et(()=>o)),onFailure:i=>fK(i)&&vPe(i.defect)&&ce(i.defect,r)?_c(i.defect.error):In(i),onDone:ta});return Vn(Vn(Vn(e,n),t),o)})),q2=e=>KT(t=>UX(e,t)),o7=e=>q2(v0(e)),G2=e=>Z5(t=>UX(e,t)),z2=e=>Sd(vb(t=>De(ZBe(),r=>TX(_b(t(KBe(e,r)),n=>ET(r,Mn(n))),(n,o)=>ET(r,o))))),i7=e=>Fb(De(u0,t=>Et(nn(e(t)),cr))),s7=()=>Ju(()=>{let e="",t=!1,r=o=>{let i=[];return xf(o,s=>{if(s.length!==0){let a=0,c=s.indexOf("\r"),u=s.indexOf(`
59
59
  `);for(t&&(u===0?(i.push(e),e="",a=1,u=s.indexOf(`
60
60
  `,a)):e=e+"\r",t=!1);c!==-1||u!==-1;)c===-1||u!==-1&&u<c?(e.length===0?i.push(s.substring(a,u)):(i.push(e+s.substring(a,u)),e=""),a=u+1,u=s.indexOf(`
61
61
  `,a)):s.length===c+1?(t=!0,c=-1):u===c+1?(e.length===0?i.push(s.substring(a,c)):(e=e+s.substring(a,c),i.push(e),e=""),a=c+2,c=s.indexOf("\r",a),u=s.indexOf(`
62
- `,a)):c=s.indexOf("\r",c+1);t?e=e+s.substring(a,s.length-1):e=e+s.substring(a,s.length)}}),ln(i)},n=ea({onInput:o=>{let i=r(o);return xu(i)?n:Et(cr(i),()=>n)},onFailure:o=>e.length===0?In(o):Et(cr(Dt(e)),()=>In(o)),onDone:o=>e.length===0?Yu(o):Et(cr(Dt(e)),()=>Yu(o))});return n}),k0=x(2,(e,t)=>Gu(ot(()=>new mD(e,void 0,be)),hh()).pipe(Ri(([r,n])=>JBe(t,o=>{let i=r.close(o);return i!==void 0?ry(i,n):ve})),hd,De(([r])=>Pt(()=>e7(r.run(),r))))),e7=(e,t)=>{let r=e;switch(r._tag){case ay:return es(t.getDone(),{onFailure:Is,onSuccess:n=>nt(Re(n))});case cy:return nt(Le(t.getEmit()));case yh:return C(r.effect,Ee(()=>e7(t.run(),t)));case uy:return O2(r,()=>e7(t.run(),t),n=>Is(n))}},Sd=e=>bPe(nn(e)),Fb=e=>I2(z2(e),(t,r)=>t,(t,r)=>t),CD=e=>I2(i7(e),(t,r)=>t,(t,r)=>t),R0=e=>wPe(0,e.length,e),wPe=(e,t,r)=>e===t?rs:C(cr(C(r,Wl(e))),Et(()=>wPe(e+1,t,r))),IPe=x(e=>S2(e[1]),(e,t,r)=>r?.concurrent?j2(e,{other:t,onSelfDone:n=>WX(o=>Pt(()=>Z1(n,o))),onOtherDone:n=>WX(o=>Pt(()=>Z1(o,n)))}):Et(e,n=>$2(t,o=>[n,o]))),Kf=x(e=>S2(e[1]),(e,t,r)=>r?.concurrent?$2(IPe(e,t,{concurrent:!0}),n=>n[1]):Et(e,()=>t)),L2=Symbol.for("effect/Channel/ChannelException"),kPe=e=>({_tag:"ChannelException",[L2]:L2,error:e}),vPe=e=>se(e,L2)});var RPe=h(()=>{});var _Pe,a7,JQt,KQt,c7,BPe,u7,TPe=h(()=>{sr();Ws();id();oe();bI();$f();vt();UI();La();_Pe=Symbol.for("effect/RcRef"),a7={_tag:"Empty"},JQt={_tag:"Closed"},KQt={_A:be,_E:be},c7=class extends Ys{acquire;context;scope;idleTimeToLive;[_Pe]=KQt;[Na]=Na;state=a7;semaphore=LI(1);constructor(t,r,n,o){super(),this.acquire=t,this.context=r,this.scope=n,this.idleTimeToLive=o,this.get=u7(this)}get;commit(){return this.get}},BPe=e=>st(t=>{let r=t.getFiberRef(ui),n=Dr(r,Fa),o=new c7(e.acquire,r,n,e.idleTimeToLive?At(e.idleTimeToLive):void 0);return Zt(n.addFinalizer(()=>o.semaphore.withPermits(1)(ye(()=>{let i=o.state._tag==="Acquired"?rd(o.state.scope,Pn):Ue;return o.state=JQt,i}))),o)}),u7=e=>{let t=e,r=t.idleTimeToLive&&!L_(t.idleTimeToLive);return xn(n=>ye(()=>{switch(t.state._tag){case"Closed":return qs;case"Acquired":return t.state.refCount++,t.state.fiber?Zt(gc(t.state.fiber),t.state):M(t.state);case"Empty":return oh().pipe(UB("scope"),LB("value",({scope:o})=>n(tn(t.acquire,ui,zt(t.context,Fa,o)))),te(({scope:o,value:i})=>{let s={_tag:"Acquired",value:i,scope:o,fiber:void 0,refCount:1};return t.state=s,s}))}})).pipe(t.semaphore.withPermits(1),UB("state"),LB("scope",()=>Fa),jo(({scope:n,state:o})=>n.addFinalizer(()=>ye(()=>(o.refCount--,o.refCount>0||r?Ue:t.idleTimeToLive===void 0?(t.state=a7,rd(o.scope,Pn)):Jm(t.idleTimeToLive).pipe(Qa,je(ye(()=>t.state._tag==="Acquired"&&t.state.refCount===0?(t.state=a7,rd(o.scope,Pn)):Ue)),Js(V(()=>{o.fiber=void 0})),bT(t.scope),jo(i=>{o.fiber=i}),t.semaphore.withPermits(1)))))),te(({state:n})=>n.value))}});var DPe,l7,d7=h(()=>{TPe();DPe=BPe,l7=u7});var f7,OPe,NPe,Y2=h(()=>{JU();f7=qI,OPe=YU,NPe=DTe});var PPe=h(()=>{});var LPe,pOt,Cd,UPe,m7,$Pe,h7,g7,HPe,WPe,jPe,J2,A7,y7,Lb,qPe,x7=h(()=>{vr();nr();oe();Me();wD();Ob();LPe=Symbol.for("effect/Sink"),pOt={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e},Cd=class{channel;[LPe]=pOt;constructor(t){this.channel=t}pipe(){return Z(this,arguments)}},UPe=e=>new Cd(Ju(()=>Lb(e()))),m7=()=>new Cd($Pe(Ut())),$Pe=e=>ea({onInput:t=>$Pe(C(e,Ir(t))),onFailure:In,onDone:()=>Yu(e)}),h7=new Cd(v0(ED())),g7=e=>new Cd(_c(e)),HPe=(e,t,r)=>UPe(()=>new Cd(WPe(e,t,r))),WPe=(e,t,r)=>t(e)?bd({onInput:n=>WPe(r(e,n),t,r),onFailure:_c,onDone:()=>ta(e)}):ta(e),jPe=(e,t)=>HPe(e,ka,t),J2=e=>{let t=ea({onInput:r=>C(nn(pi(r,n=>e(n),{discard:!0})),Et(()=>t)),onFailure:In,onDone:()=>rs});return new Cd(t)},A7=e=>new Cd(e),y7=e=>new Cd(nn(e)),Lb=e=>ws(e)?Lb(y7(e)):e.channel,qPe=e=>new Cd(Fb(e.pipe(De(t=>Lb(t)))))});var zPe=h(()=>{});var VPe=h(()=>{});var YPe,JPe=h(()=>{Vs();vr();nr();Ro();oe();it();YPe=e=>Object.assign(e,{chunk(r){return this(nt(r))},die(r){return this(Ua(r))},dieMessage(r){return this(kb(r))},done(r){return this(Pt(()=>K1(r,{onFailure:H,onSuccess:Dt})))},end(){return this($e(W()))},fail(r){return this($e(H(r)))},fromEffect(r){return this(VT(r,{onFailure:H,onSuccess:Dt}))},fromEffectChunk(r){return this(C(r,Ha(H)))},halt(r){return this(Is(C(r,Fm(H))))},single(r){return this(nt(Dt(r)))}})});var yOt,xOt,EOt,ID,K2,KPe,Z2,X2,ZPe,E7,XPe=h(()=>{Vs();nr();Ro();oe();it();Me();yOt="effect/Take",xOt=Symbol.for(yOt),EOt={_A:e=>e,_E:e=>e},ID=class{exit;[xOt]=EOt;constructor(t){this.exit=t}pipe(){return Z(this,arguments)}},K2=e=>new ID(vo(e)),KPe=e=>Pt(()=>e.exit),Z2=new ID(Cc(W())),X2=e=>new ID(Mn(C(e,Fm(H)))),ZPe=e=>oy(e,{onFailure:t=>wt(zL(t),{onNone:()=>Z2,onSome:X2}),onSuccess:K2}),E7=x(2,(e,{onEnd:t,onFailure:r,onSuccess:n})=>es(e.exit,{onFailure:o=>wt(zL(o),{onNone:t,onSome:r}),onSuccess:n}))});var eMe,tMe=h(()=>{nr();it();eMe=()=>$e(W())});var jOt,eH,qOt,ns,b7,GOt,oMe,iMe,zOt,VOt,sMe,aMe,S7,rMe,nMe,C7,cMe,_i,w7,I7,uMe,lMe,dMe,k7,v7,fMe,tH,pMe,mMe,hMe,R7,gMe,AMe,yMe,xMe,EMe,bMe,_7,SMe=h(()=>{Vs();vr();$u();nr();Ro();oe();it();Me();ct();a2();NA();Y2();wD();JX();Ob();x7();JPe();tMe();XPe();jOt="effect/Stream",eH=Symbol.for(jOt),qOt={_R:e=>e,_E:e=>e,_A:e=>e},ns=class{channel;[eH]=qOt;constructor(t){this.channel=t}pipe(){return Z(this,arguments)}},b7=e=>se(e,eH)||ws(e),GOt=e=>{if(e==="unbounded")return uD();if(typeof e=="number"||e===void 0)return y0(e??16);switch(e.strategy){case"dropping":return i2(e.bufferSize??16);case"sliding":return s2(e.bufferSize??16);default:return y0(e.bufferSize??16)}},oMe=(e,t)=>C(zo(GOt(t),r=>Ah(r)),Ee(r=>C(hh(),Ee(n=>C(e(YPe(o=>C(ZPe(o),Ee(i=>Vu(r,i)),gd,OPe(n)).then(i=>{if(sd(i)&&!GL(i.cause))throw pK(i.cause)}))),Wt(bc(!1)),Ee(o=>C(Sc(o),De(i=>i?eMe():C(Qb(r),Ee(KPe),JT(()=>C(ib(o,!0),Wt(Ah(r)))))))))))),R7,S7(v7)),iMe=x(2,(e,t)=>{if(t.strategy==="dropping")return zOt(e,t.capacity);if(t.strategy==="sliding")return VOt(e,t.capacity);let r=yMe(e,t);return new ns(Fb(De(r,n=>{let o=C(nn(Qb(n)),Et(E7({onEnd:()=>rs,onFailure:In,onSuccess:i=>C(cr(i),Et(()=>o))})));return o})))}),zOt=x(2,(e,t)=>{let r=zo(i2(t),n=>Ah(n));return new ns(sMe(r,_i(e)))}),VOt=x(2,(e,t)=>{let r=zo(s2(t),n=>Ah(n));return new ns(sMe(r,_i(e)))}),sMe=(e,t)=>{let r=(o,i)=>{let s=a=>C(Sc(i),Ri(Ht),Wt(rn()),Ee(c=>C(Vu(o,[a,c]),Wt(ib(i,c)),Wt(Ht(c)))),gd,nn);return ea({onInput:a=>C(rn(),Ee(c=>C(Vu(o,[K2(a),c]),Ee(u=>C(ib(i,c),XT(()=>u))))),gd,nn,Et(()=>r(o,i))),onFailure:a=>s(X2(a)),onDone:()=>s(Z2)})},n=o=>{let i=C(nn(Qb(o)),Et(([s,a])=>Kf(nn(di(a,void 0)),E7(s,{onEnd:()=>rs,onFailure:In,onSuccess:c=>C(cr(c),Et(()=>i))}))));return i};return Fb(C(e,Ee(o=>C(rn(),Ri(i=>di(i,void 0)),Ee(i=>C(bc(i),Ee(s=>C(t,Vn(r(o,s)),G2,l0)),ju(n(o))))))))},aMe=e=>I7($e(H(e))),S7=x(e=>b7(e[0]),(e,t,r)=>{let n=r?.bufferSize??16;return r?.switch?rMe(r?.concurrency,()=>nMe(e,1,n,t),o=>nMe(e,o,n,t)):rMe(r?.concurrency,()=>new ns(yD(_i(e),o=>C(o,xf(i=>_i(t(i))),I_(rs,(i,s)=>C(i,Kf(s)))))),o=>new ns(C(_i(e),yD(R0),W2(i=>_i(t(i)),r))))}),rMe=(e,t,r)=>{switch(e){case void 0:return t();case"unbounded":return r(Number.MAX_SAFE_INTEGER);default:return e>1?r(e):t()}},nMe=x(4,(e,t,r,n)=>new ns(C(_i(e),yD(R0),W2(o=>_i(n(o)),{concurrency:t,mergeStrategy:mPe(),bufferSize:r})))),C7=x(e=>b7(e[0]),(e,t)=>S7(e,be,t)),cMe=e=>new ns(e),_i=e=>{if("channel"in e)return e.channel;if(ws(e))return _i(w7(e));throw new TypeError("Expected a Stream.")},w7=e=>C(e,Ha(H),I7),I7=e=>new ns(Sd(tX(e,{onFailure:wt({onNone:()=>rs,onSome:_c}),onSuccess:t=>cr(Dt(t))}))),uMe=(...e)=>{let t=e.length===1?e[0].evaluate:e[0],r=e.length===1?e[0].onError:e[1],n=e.length===1?e[0].releaseLockOnEnd===!0:!1;return _7(De(zo(ot(()=>t().getReader()),o=>n?ot(()=>o.releaseLock()):Y5(()=>o.cancel())),o=>fMe(Ee(ey({try:()=>o.read(),catch:i=>H(r(i))}),({done:i,value:s})=>i?$e(W()):nt(s)))))},lMe=x(2,(e,t)=>new ns(C(_i(e),bD(t)))),dMe=x(2,(e,t)=>new ns(C(_i(e),H2(t)))),k7=x(2,(e,t)=>new ns(Vn(_i(e),t))),v7=e=>EMe(e,t=>C(De(t,r=>H([r,t])),s0(wt({onNone:()=>nt(W()),onSome:$e})))),fMe=e=>v7(C(e,De(Dt))),tH=x(2,(e,t)=>_i(e).pipe(SD(Lb(t)),o7)),pMe=e=>tH(e,m7()),mMe=x(2,(e,t)=>tH(e,J2(t))),hMe=x(2,(e,t)=>{let r=ea({onInput:n=>Et(cr(K2(n)),()=>r),onFailure:n=>cr(X2(n)),onDone:()=>cr(Z2)});return C(Vn(_i(e),r),n7(n=>Vu(t,n)),v0,G2,gd)}),R7=e=>new ns(xD(z2(C(e,De(Dt))),ve)),gMe=e=>k7(e,s7()),AMe=e=>new ns(Ju(()=>_i(e()))),yMe=x(e=>b7(e[0]),(e,t)=>Ri(zo(t?.strategy==="unbounded"?uD():t?.strategy==="dropping"?i2(t.capacity??2):t?.strategy==="sliding"?s2(t.capacity??2):y0(t?.capacity??2),r=>Ah(r)),r=>l0(hMe(e,r)))),xMe=x(2,(e,t)=>{let r=Ju(()=>{let n={ref:Ut()},o={ref:!1},i=Ju(()=>{let u=n.ref;return xu(u)?bd({onInput:l=>C(cr(l),Et(()=>i)),onFailure:_c,onDone:ta}):(n.ref=Ut(),C(R0(u),Et(()=>i)))}),s=u=>{let l=n.ref,d=Ir(l,Tw(u,f=>f.length!==0));return n.ref=d,d},a=bd({onInput:u=>Et(cr(u),()=>a),onFailure:_c,onDone:u=>Kf(Jf(()=>{o.ref=!0}),ta(u))}),c=C(t,Lb,w2,Et(([u,l])=>C(Yu([o.ref,s(u)]),Et(([d,f])=>{let p=d&&xu(f)?rs:c;return C(cr(Dt(l)),Et(()=>p))}))));return C(_i(e),Vn(a),Vn(i),SD(c))});return new ns(r)}),EMe=(e,t)=>AMe(()=>{let r=n=>Sd(De(t(n),wt({onNone:()=>rs,onSome:([o,i])=>Et(cr(o),()=>r(i))})));return new ns(r(e))}),bMe=e=>C7(w7(e)),_7=e=>C7(R7(e))});var B7,CMe,wMe,kD,dy,IMe,kMe,vMe,RMe,_Me,_0,BMe,TMe,DMe,QMe,OMe,fy,wd=h(()=>{SMe();B7=eH,CMe=oMe,wMe=iMe,kD=aMe,dy=cMe,IMe=_i,kMe=uMe,vMe=lMe,RMe=dMe,_Me=k7,_0=tH,BMe=pMe,TMe=mMe,DMe=gMe,QMe=xMe,OMe=bMe,fy=_7});var T7,JOt,KOt,rH,PMe,py,D7,ZOt,Q7,NMe,XOt,eNt,tNt,rNt,nNt,oNt,iNt,MMe=h(()=>{mt();mm();oe();ir();ht();Me();ct();T7=Symbol.for("effect/BigDecimal"),JOt={[T7]:T7,[he](){let e=Q7(this);return C(ae(e.value),we(hu(e.scale)),We(this))},[me](e){return KOt(e)&&tNt(this,e)},toString(){return`BigDecimal(${rNt(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},KOt=e=>se(e,T7),rH=(e,t)=>{let r=Object.create(JOt);return r.value=e,r.scale=t,r},PMe=(e,t)=>{if(e!==py&&e%D7===py)throw new RangeError("Value must be normalized");let r=rH(e,t);return r.normalized=r,r},py=BigInt(0),D7=BigInt(10),ZOt=PMe(py,0),Q7=e=>{if(e.normalized===void 0)if(e.value===py)e.normalized=ZOt;else{let t=`${e.value}`,r=0;for(let i=t.length-1;i>=0&&t[i]==="0";i--)r++;r===0&&(e.normalized=e);let n=BigInt(t.substring(0,t.length-r)),o=e.scale-r;e.normalized=PMe(n,o)}return e.normalized},NMe=x(2,(e,t)=>t>e.scale?rH(e.value*D7**BigInt(t-e.scale),t):t<e.scale?rH(e.value/D7**BigInt(e.scale-t),t):e),XOt=e=>e.value<py?rH(-e.value,e.scale):e,eNt=Ml((e,t)=>e.scale>t.scale?NMe(t,e.scale).value===e.value:e.scale<t.scale?NMe(e,t.scale).value===t.value:e.value===t.value),tNt=x(2,(e,t)=>eNt(e,t)),rNt=e=>{let t=Q7(e);if(Math.abs(t.scale)>=16)return nNt(t);let r=t.value<py,n=r?`${t.value}`.substring(1):`${t.value}`,o,i;if(t.scale>=n.length)o="0",i="0".repeat(t.scale-n.length)+n;else{let a=n.length-t.scale;if(a>n.length){let c=a-n.length;o=`${n}${"0".repeat(c)}`,i=""}else i=n.slice(a),o=n.slice(0,a)}let s=i===""?o:`${o}.${i}`;return r?`-${s}`:s},nNt=e=>{if(oNt(e))return"0e+0";let t=Q7(e),r=`${XOt(t).value}`,n=r.slice(0,1),o=r.slice(1),i=`${iNt(t)?"-":""}${n}`;o!==""&&(i+=`.${o}`);let s=o.length-t.scale;return`${i}e${s>=0?"+":""}${s}`},oNt=e=>e.value===py,iNt=e=>e.value<py});var FMe=h(()=>{});var LMe=h(()=>{});var UMe,nH,O7,uNt,$Me,HMe,WMe=h(()=>{mt();oe();yn();ir();ht();Me();ct();UMe="effect/Redacted",nH=Te("effect/Redacted/redactedRegistry",()=>new WeakMap),O7=Symbol.for(UMe),uNt={[O7]:{_A:e=>e},pipe(){return Z(this,arguments)},toString(){return"<redacted>"},toJSON(){return"<redacted>"},[Ce](){return"<redacted>"},[he](){return C(ae(UMe),we(ae(nH.get(this))),We(this))},[me](e){return $Me(e)&&ce(nH.get(this),nH.get(e))}},$Me=e=>se(e,O7),HMe=e=>{let t=Object.create(uNt);return nH.set(t,e),t}});var jMe=h(()=>{});var qMe=h(()=>{});var GMe=h(()=>{});var Ku,my=h(()=>{Ku=class e extends Error{constructor(t=!1){super(),this.interruptExecution=t,this.footprint=e.SharedFootPrint}static isFailure(t){return t!=null&&t.footprint===e.SharedFootPrint}};Ku.SharedFootPrint=Symbol.for("fast-check/PreconditionFailure")});var zMe=h(()=>{my()});function VMe(){return vD.nil}function*YMe(e,t){for(let r of e)yield t(r)}function*JMe(e,t){for(let r of e)yield*t(r)}function*KMe(e,t){for(let r of e)t(r)&&(yield r)}function*ZMe(e,t){for(let r=0;r<t;++r){let n=e.next();if(n.done)break;yield n.value}}function*XMe(e,t){let r=e.next();for(;!r.done&&t(r.value);)yield r.value,r=e.next()}function*eFe(e,t){for(let r=e.next();!r.done;r=e.next())yield r.value;for(let r of t)for(let n=r.next();!n.done;n=r.next())yield n.value}var vD,tFe=h(()=>{vD=class{[Symbol.iterator](){return this}next(t){return{value:t,done:!0}}};vD.nil=new vD});function hy(e){return new Nr(e)}var mNt,Nr,kn=h(()=>{tFe();mNt=Symbol.iterator,Nr=class e{static nil(){return new e(VMe())}static of(...t){return new e(t[mNt]())}constructor(t){this.g=t}next(){return this.g.next()}[Symbol.iterator](){return this.g}map(t){return new e(YMe(this.g,t))}flatMap(t){return new e(JMe(this.g,t))}dropWhile(t){let r=!1;function*n(o){(r||!t(o))&&(r=!0,yield o)}return this.flatMap(n)}drop(t){if(t<=0)return this;let r=0;function n(){return r++<t}return this.dropWhile(n)}takeWhile(t){return new e(XMe(this.g,t))}take(t){return new e(ZMe(this.g,t))}filter(t){return new e(KMe(this.g,t))}every(t){for(let r of this.g)if(!t(r))return!1;return!0}has(t){for(let r of this.g)if(t(r))return[!0,r];return[!1,null]}join(...t){return new e(eFe(this.g,t))}getNthOrLast(t){let r=t,n=null;for(let o of this.g){if(r--===0)return o;n=o}return n}}});function gy(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&ao in e&&typeof e[ao]=="function"}var ao,ks=h(()=>{ao=Symbol.for("fast-check/cloneMethod")});var hNt,hr,vn=h(()=>{ks();hNt=Object.defineProperty,hr=class{constructor(t,r,n=void 0){this.value_=t,this.context=r,this.hasToBeCloned=n!==void 0||gy(t),this.readOnce=!1,this.hasToBeCloned?hNt(this,"value",{get:n!==void 0?n:this.getValue}):this.value=t}getValue(){return this.hasToBeCloned?this.readOnce?this.value_[ao]():(this.readOnce=!0,this.value_):this.value_}}});var rFe,on,N7,P7,M7,F7,L7,Ln=h(()=>{kn();ks();vn();rFe=Object.assign,on=class{filter(t){return new M7(this,t)}map(t,r){return new P7(this,t,r)}chain(t){return new N7(this,t)}noShrink(){return new F7(this)}noBias(){return new L7(this)}},N7=class extends on{constructor(t,r){super(),this.arb=t,this.chainer=r}generate(t,r){let n=t.clone(),o=this.arb.generate(t,r);return this.valueChainer(o,t,n,r)}canShrinkWithoutContext(t){return!1}shrink(t,r){return this.isSafeContext(r)?(r.stoppedForOriginal?Nr.nil():this.arb.shrink(r.originalValue,r.originalContext).map(n=>this.valueChainer(n,r.clonedMrng.clone(),r.clonedMrng,r.originalBias))).join(r.chainedArbitrary.shrink(t,r.chainedContext).map(n=>{let o=rFe(rFe({},r),{chainedContext:n.context,stoppedForOriginal:!0});return new hr(n.value_,o)})):Nr.nil()}valueChainer(t,r,n,o){let i=this.chainer(t.value_),s=i.generate(r,o),a={originalBias:o,originalValue:t.value_,originalContext:t.context,stoppedForOriginal:!1,chainedArbitrary:i,chainedContext:s.context,clonedMrng:n};return new hr(s.value_,a)}isSafeContext(t){return t!=null&&typeof t=="object"&&"originalBias"in t&&"originalValue"in t&&"originalContext"in t&&"stoppedForOriginal"in t&&"chainedArbitrary"in t&&"chainedContext"in t&&"clonedMrng"in t}},P7=class extends on{constructor(t,r,n){super(),this.arb=t,this.mapper=r,this.unmapper=n,this.bindValueMapper=o=>this.valueMapper(o)}generate(t,r){let n=this.arb.generate(t,r);return this.valueMapper(n)}canShrinkWithoutContext(t){if(this.unmapper!==void 0)try{let r=this.unmapper(t);return this.arb.canShrinkWithoutContext(r)}catch{return!1}return!1}shrink(t,r){if(this.isSafeContext(r))return this.arb.shrink(r.originalValue,r.originalContext).map(this.bindValueMapper);if(this.unmapper!==void 0){let n=this.unmapper(t);return this.arb.shrink(n,void 0).map(this.bindValueMapper)}return Nr.nil()}mapperWithCloneIfNeeded(t){let r=t.value,n=this.mapper(r);return t.hasToBeCloned&&(typeof n=="object"&&n!==null||typeof n=="function")&&Object.isExtensible(n)&&!gy(n)&&Object.defineProperty(n,ao,{get:()=>()=>this.mapperWithCloneIfNeeded(t)[0]}),[n,r]}valueMapper(t){let[r,n]=this.mapperWithCloneIfNeeded(t),o={originalValue:n,originalContext:t.context};return new hr(r,o)}isSafeContext(t){return t!=null&&typeof t=="object"&&"originalValue"in t&&"originalContext"in t}},M7=class extends on{constructor(t,r){super(),this.arb=t,this.refinement=r,this.bindRefinementOnValue=n=>this.refinementOnValue(n)}generate(t,r){for(;;){let n=this.arb.generate(t,r);if(this.refinementOnValue(n))return n}}canShrinkWithoutContext(t){return this.arb.canShrinkWithoutContext(t)&&this.refinement(t)}shrink(t,r){return this.arb.shrink(t,r).filter(this.bindRefinementOnValue)}refinementOnValue(t){return this.refinement(t.value)}},F7=class extends on{constructor(t){super(),this.arb=t}generate(t,r){return this.arb.generate(t,r)}canShrinkWithoutContext(t){return this.arb.canShrinkWithoutContext(t)}shrink(t,r){return Nr.nil()}noShrink(){return this}},L7=class extends on{constructor(t){super(),this.arb=t}generate(t,r){return this.arb.generate(t,void 0)}canShrinkWithoutContext(t){return this.arb.canShrinkWithoutContext(t)}shrink(t,r){return this.arb.shrink(t,r)}noBias(){return this}}});function gNt(e){try{return e.apply}catch{return}}function ANt(e,t,r){let n=e;n[U7]=nFe;let o=n[U7](t,r);return delete n[U7],o}function Zu(e,t,r){return gNt(e)===nFe?e.apply(t,r):ANt(e,t,r)}var nFe,U7,oFe=h(()=>{nFe=Function.prototype.apply,U7=Symbol("apply")});function yNt(e){try{return e.indexOf}catch{return}}function xNt(e){try{return e.join}catch{return}}function ENt(e){try{return e.map}catch{return}}function bNt(e){try{return e.filter}catch{return}}function SNt(e){try{return e.push}catch{return}}function B0(e,...t){return yNt(e)===iFe?e.indexOf(...t):Zu(iFe,e,t)}function Bi(e,...t){return xNt(e)===sFe?e.join(...t):Zu(sFe,e,t)}function Vo(e,t){return ENt(e)===aFe?e.map(t):Zu(aFe,e,[t])}function AFe(e,t){return bNt(e)===cFe?e.filter(t):Zu(cFe,e,[t])}function Un(e,...t){return SNt(e)===uFe?e.push(...t):Zu(uFe,e,t)}function CNt(e){try{return e.getTime}catch{return}}function wNt(e){try{return e.toISOString}catch{return}}function iH(e){return CNt(e)===lFe?e.getTime():Zu(lFe,e,[])}function yFe(e){return wNt(e)===dFe?e.toISOString():Zu(dFe,e,[])}function INt(e){try{return e.split}catch{return}}function kNt(e){try{return e.charCodeAt}catch{return}}function kd(e,...t){return INt(e)===fFe?e.split(...t):Zu(fFe,e,t)}function Ub(e,t){return kNt(e)===pFe?e.charCodeAt(t):Zu(pFe,e,[t])}function vNt(e){try{return e.toString}catch{return}}function sH(e,...t){return vNt(e)===mFe?e.toString(...t):Zu(mFe,e,t)}function $7(e){return Zu(RNt,e,[])}var hFe,co,Id,gFe,oH,rPr,iFe,sFe,aFe,cFe,uFe,nPr,oPr,iPr,sPr,aPr,lFe,dFe,cPr,uPr,lPr,dPr,fPr,pPr,fFe,mPr,hPr,gPr,APr,yPr,xPr,pFe,EPr,bPr,mFe,RNt,ge=h(()=>{oFe();hFe=typeof Array<"u"?Array:void 0,co=typeof Error<"u"?Error:void 0,Id=typeof String<"u"?String:void 0,gFe=typeof encodeURIComponent<"u"?encodeURIComponent:void 0,oH=Symbol,rPr=Array.prototype.forEach,iFe=Array.prototype.indexOf,sFe=Array.prototype.join,aFe=Array.prototype.map,cFe=Array.prototype.filter,uFe=Array.prototype.push,nPr=Array.prototype.pop,oPr=Array.prototype.splice,iPr=Array.prototype.slice,sPr=Array.prototype.sort,aPr=Array.prototype.every;lFe=Date.prototype.getTime,dFe=Date.prototype.toISOString;cPr=Set.prototype.add,uPr=Set.prototype.has,lPr=WeakMap.prototype.set,dPr=WeakMap.prototype.get,fPr=Map.prototype.set,pPr=Map.prototype.get,fFe=String.prototype.split,mPr=String.prototype.startsWith,hPr=String.prototype.endsWith,gPr=String.prototype.substring,APr=String.prototype.toLowerCase,yPr=String.prototype.toUpperCase,xPr=String.prototype.padStart,pFe=String.prototype.charCodeAt,EPr=String.prototype.normalize,bPr=String.prototype.replace;mFe=Number.prototype.toString;RNt=Object.prototype.toString});var T0=h(()=>{});var BPr,H7=h(()=>{kn();ks();Ln();vn();ge();T0();BPr=Array.isArray});var uo=h(()=>{H7()});function cH(e){return 2+~~(_Nt(e+1)*.4342944819032518)}var _Nt,W7=h(()=>{_Nt=Math.log});function Ay(){return BNt}var BNt,$b=h(()=>{BNt={}});function Wb(e){return e.context!==void 0?e:e.hasToBeCloned?new hr(e.value_,Hb,()=>e.value):new hr(e.value_,Hb)}var Hb,uH=h(()=>{vn();Hb=Symbol("UndefinedContextPlaceholder")});var lH,EFe=h(()=>{my();W7();$b();kn();uH();ge();lH=class e{constructor(t,r){this.arb=t,this.predicate=r;let{asyncBeforeEach:n,asyncAfterEach:o,beforeEach:i,afterEach:s}=Ay()||{};if(n!==void 0&&i!==void 0)throw co(`Global "asyncBeforeEach" and "beforeEach" parameters can't be set at the same time when running async properties`);if(o!==void 0&&s!==void 0)throw co(`Global "asyncAfterEach" and "afterEach" parameters can't be set at the same time when running async properties`);this.beforeEachHook=n||i||e.dummyHook,this.afterEachHook=o||s||e.dummyHook}isAsync(){return!0}generate(t,r){let n=this.arb.generate(t,r!=null?cH(r):void 0);return Wb(n)}shrink(t){if(t.context===void 0&&!this.arb.canShrinkWithoutContext(t.value_))return Nr.nil();let r=t.context!==Hb?t.context:void 0;return this.arb.shrink(t.value_,r).map(Wb)}async runBeforeEach(){await this.beforeEachHook()}async runAfterEach(){await this.afterEachHook()}async run(t,r){r||await this.beforeEachHook();try{let n=await this.predicate(t);return n==null||n===!0?null:{error:new co("Property failed by returning false"),errorMessage:"Error: Property failed by returning false"}}catch(n){return Ku.isFailure(n)?n:n instanceof co&&n.stack?{error:n,errorMessage:n.stack}:{error:n,errorMessage:Id(n)}}finally{r||await this.afterEachHook()}}beforeEach(t){let r=this.beforeEachHook;return this.beforeEachHook=()=>t(r),this}afterEach(t){let r=this.afterEachHook;return this.afterEachHook=()=>t(r),this}};lH.dummyHook=()=>{}});var j7=h(()=>{Ln();kn();uH()});var bFe=h(()=>{Ln();uo();EFe();j7();ge()});var RD,q7=h(()=>{my();W7();$b();kn();uH();ge();RD=class e{constructor(t,r){this.arb=t,this.predicate=r;let{beforeEach:n=e.dummyHook,afterEach:o=e.dummyHook,asyncBeforeEach:i,asyncAfterEach:s}=Ay()||{};if(i!==void 0)throw co(`"asyncBeforeEach" can't be set when running synchronous properties`);if(s!==void 0)throw co(`"asyncAfterEach" can't be set when running synchronous properties`);this.beforeEachHook=n,this.afterEachHook=o}isAsync(){return!1}generate(t,r){let n=this.arb.generate(t,r!=null?cH(r):void 0);return Wb(n)}shrink(t){if(t.context===void 0&&!this.arb.canShrinkWithoutContext(t.value_))return Nr.nil();let r=t.context!==Hb?t.context:void 0;return this.arb.shrink(t.value_,r).map(Wb)}runBeforeEach(){this.beforeEachHook()}runAfterEach(){this.afterEachHook()}run(t,r){r||this.beforeEachHook();try{let n=this.predicate(t);return n==null||n===!0?null:{error:new co("Property failed by returning false"),errorMessage:"Error: Property failed by returning false"}}catch(n){return Ku.isFailure(n)?n:n instanceof co&&n.stack?{error:n,errorMessage:n.stack}:{error:n,errorMessage:Id(n)}}finally{r||this.afterEachHook()}}beforeEach(t){let r=this.beforeEachHook;return this.beforeEachHook=()=>t(r),this}afterEach(t){let r=this.afterEachHook;return this.afterEachHook=()=>t(r),this}};RD.dummyHook=()=>{}});var SFe=h(()=>{Ln();uo();q7();j7();ge()});function G7(e,t){for(var r=[],n=0;n!=t;++n)r.push(e.unsafeNext());return r}function CFe(e,t){var r=e.clone(),n=G7(r,t);return[n,r]}function _D(e,t){for(var r=0;r!=t;++r)e.unsafeNext()}function z7(e,t){var r=e.clone();return _D(r,t),r}var wFe=h(()=>{});function FNt(e){var t=e.length===1;if(!t)throw new Error("The state must have been produced by a congruential32 RandomGenerator");return new IFe(e[0])}var ONt,NNt,PNt,MNt,V7,Y7,IFe,kFe,vFe=h(()=>{ONt=214013,NNt=2531011,PNt=4294967295,MNt=(1<<31)-1,V7=function(e){return e*ONt+NNt&PNt},Y7=function(e){return(e&MNt)>>16},IFe=function(){function e(t){this.seed=t}return e.prototype.clone=function(){return new e(this.seed)},e.prototype.next=function(){var t=new e(this.seed),r=t.unsafeNext();return[r,t]},e.prototype.unsafeNext=function(){var t=V7(this.seed),r=Y7(t),n=V7(t),o=Y7(n);this.seed=V7(n);var i=Y7(this.seed),s=i+(o+(r<<15)<<15);return s|0},e.prototype.getState=function(){return[this.seed]},e}();kFe=Object.assign(function(e){return new IFe(e)},{fromState:FNt})});function $Nt(e){return RFe.fromState(e)}var LNt,UNt,RFe,_Fe,BFe=h(()=>{LNt=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i},UNt=function(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))},RFe=function(){function e(t,r){this.states=t,this.index=r}return e.twist=function(t){for(var r=t.slice(),n=0;n!==e.N-e.M;++n){var o=(r[n]&e.MASK_UPPER)+(r[n+1]&e.MASK_LOWER);r[n]=r[n+e.M]^o>>>1^-(o&1)&e.A}for(var n=e.N-e.M;n!==e.N-1;++n){var i=(r[n]&e.MASK_UPPER)+(r[n+1]&e.MASK_LOWER);r[n]=r[n+e.M-e.N]^i>>>1^-(i&1)&e.A}var s=(r[e.N-1]&e.MASK_UPPER)+(r[0]&e.MASK_LOWER);return r[e.N-1]=r[e.M-1]^s>>>1^-(s&1)&e.A,r},e.seeded=function(t){var r=Array(e.N);r[0]=t;for(var n=1;n!==e.N;++n){var o=r[n-1]^r[n-1]>>>30;r[n]=Math.imul(e.F,o)+n|0}return r},e.from=function(t){return new e(e.twist(e.seeded(t)),0)},e.prototype.clone=function(){return new e(this.states,this.index)},e.prototype.next=function(){var t=new e(this.states,this.index),r=t.unsafeNext();return[r,t]},e.prototype.unsafeNext=function(){var t=this.states[this.index];return t^=this.states[this.index]>>>e.U,t^=t<<e.S&e.B,t^=t<<e.T&e.C,t^=t>>>e.L,++this.index>=e.N&&(this.states=e.twist(this.states),this.index=0),t},e.prototype.getState=function(){return UNt([this.index],LNt(this.states),!1)},e.fromState=function(t){var r=t.length===e.N+1&&t[0]>=0&&t[0]<e.N;if(!r)throw new Error("The state must have been produced by a mersenne RandomGenerator");return new e(t.slice(1),t[0])},e.N=624,e.M=397,e.R=31,e.A=2567483615,e.F=1812433253,e.U=11,e.S=7,e.B=2636928640,e.T=15,e.C=4022730752,e.L=18,e.MASK_LOWER=Math.pow(2,e.R)-1,e.MASK_UPPER=Math.pow(2,e.R),e}();_Fe=Object.assign(function(e){return RFe.from(e)},{fromState:$Nt})});function HNt(e){var t=e.length===4;if(!t)throw new Error("The state must have been produced by a xorshift128plus RandomGenerator");return new TFe(e[0],e[1],e[2],e[3])}var TFe,DFe,QFe=h(()=>{TFe=function(){function e(t,r,n,o){this.s01=t,this.s00=r,this.s11=n,this.s10=o}return e.prototype.clone=function(){return new e(this.s01,this.s00,this.s11,this.s10)},e.prototype.next=function(){var t=new e(this.s01,this.s00,this.s11,this.s10),r=t.unsafeNext();return[r,t]},e.prototype.unsafeNext=function(){var t=this.s00^this.s00<<23,r=this.s01^(this.s01<<23|this.s00>>>9),n=t^this.s10^(t>>>18|r<<14)^(this.s10>>>5|this.s11<<27),o=r^this.s11^r>>>18^this.s11>>>5,i=this.s00+this.s10|0;return this.s01=this.s11,this.s00=this.s10,this.s11=o,this.s10=n,i},e.prototype.jump=function(){var t=new e(this.s01,this.s00,this.s11,this.s10);return t.unsafeJump(),t},e.prototype.unsafeJump=function(){for(var t=0,r=0,n=0,o=0,i=[1667051007,2321340297,1548169110,304075285],s=0;s!==4;++s)for(var a=1;a;a<<=1)i[s]&a&&(t^=this.s01,r^=this.s00,n^=this.s11,o^=this.s10),this.unsafeNext();this.s01=t,this.s00=r,this.s11=n,this.s10=o},e.prototype.getState=function(){return[this.s01,this.s00,this.s11,this.s10]},e}();DFe=Object.assign(function(e){return new TFe(-1,~e,e|0,0)},{fromState:HNt})});function WNt(e){var t=e.length===4;if(!t)throw new Error("The state must have been produced by a xoroshiro128plus RandomGenerator");return new OFe(e[0],e[1],e[2],e[3])}var OFe,NFe,PFe=h(()=>{OFe=function(){function e(t,r,n,o){this.s01=t,this.s00=r,this.s11=n,this.s10=o}return e.prototype.clone=function(){return new e(this.s01,this.s00,this.s11,this.s10)},e.prototype.next=function(){var t=new e(this.s01,this.s00,this.s11,this.s10),r=t.unsafeNext();return[r,t]},e.prototype.unsafeNext=function(){var t=this.s00+this.s10|0,r=this.s10^this.s00,n=this.s11^this.s01,o=this.s00,i=this.s01;return this.s00=o<<24^i>>>8^r^r<<16,this.s01=i<<24^o>>>8^n^(n<<16|r>>>16),this.s10=n<<5^r>>>27,this.s11=r<<5^n>>>27,t},e.prototype.jump=function(){var t=new e(this.s01,this.s00,this.s11,this.s10);return t.unsafeJump(),t},e.prototype.unsafeJump=function(){for(var t=0,r=0,n=0,o=0,i=[3639956645,3750757012,1261568508,386426335],s=0;s!==4;++s)for(var a=1;a;a<<=1)i[s]&a&&(t^=this.s01,r^=this.s00,n^=this.s11,o^=this.s10),this.unsafeNext();this.s01=t,this.s00=r,this.s11=n,this.s10=o},e.prototype.getState=function(){return[this.s01,this.s00,this.s11,this.s10]},e}();NFe=Object.assign(function(e){return new OFe(-1,~e,e|0,0)},{fromState:WNt})});function J7(e,t){if(e.sign!==t.sign)return dH(e,{sign:-t.sign,data:t.data});for(var r=[],n=0,o=e.data,i=t.data,s=o.length-1,a=i.length-1;s>=0||a>=0;--s,--a){var c=s>=0?o[s]:0,u=a>=0?i[a]:0,l=c+u+n;r.push(l>>>0),n=~~(l/4294967296)}return n!==0&&r.push(n),{sign:e.sign,data:r.reverse()}}function MFe(e){e.sign=1;for(var t=e.data,r=t.length-1;r>=0;--r)if(t[r]===4294967295)t[r]=0;else return t[r]+=1,e;return t.unshift(1),e}function jNt(e,t){for(var r=Math.max(e.length,t.length),n=0;n<r;++n){var o=n+e.length-r,i=n+t.length-r,s=o>=0?e[o]:0,a=i>=0?t[i]:0;if(s<a)return!0;if(s>a)return!1}return!1}function dH(e,t){if(e.sign!==t.sign)return J7(e,{sign:-t.sign,data:t.data});var r=e.data,n=t.data;if(jNt(r,n)){var o=dH(t,e);return o.sign=-o.sign,o}for(var i=[],s=0,a=r.length-1,c=n.length-1;a>=0||c>=0;--a,--c){var u=a>=0?r[a]:0,l=c>=0?n[c]:0,d=u-l-s;i.push(d>>>0),s=d<0?1:0}return{sign:e.sign,data:i.reverse()}}function K7(e){for(var t=e.data,r=0;r!==t.length&&t[r]===0;++r);return r===t.length?(e.sign=1,e.data=[0],e):(t.splice(0,r),e)}function fH(e,t){if(t<0){var r=-t;e.sign=-1,e.data[0]=~~(r/4294967296),e.data[1]=r>>>0}else e.sign=1,e.data[0]=~~(t/4294967296),e.data[1]=t>>>0;return e}function FFe(e,t,r){var n=t.data[1],o=t.data[0],i=t.sign,s=r.data[1],a=r.data[0],c=r.sign;if(e.sign=1,i===1&&c===-1){var u=n+s,l=o+a+(u>4294967295?1:0);return e.data[0]=l>>>0,e.data[1]=u>>>0,e}var d=n,f=o,p=s,m=a;i===-1&&(d=s,f=a,p=n,m=o);var g=0,A=d-p;return A<0&&(g=1,A=A>>>0),e.data[0]=f-m-g,e.data[1]=A,e}var Z7=h(()=>{});function pH(e,t){for(var r=e>2?~~(4294967296/e)*e:4294967296,n=t.unsafeNext()+2147483648;n>=r;)n=t.unsafeNext()+2147483648;return n%e}var X7=h(()=>{});function mH(e,t,r){for(var n=t.length;;){for(var o=0;o!==n;++o){var i=o===0?t[0]+1:4294967296,s=pH(i,r);e[o]=s}for(var o=0;o!==n;++o){var a=e[o],c=t[o];if(a<c)return e;if(a>c)break}}}var eee=h(()=>{X7()});function jb(e,t,r){var n=K7(MFe(dH(t,e))),o=n.data.slice(0),i=mH(o,n.data,r);return K7(J7({sign:1,data:i},e))}var tee=h(()=>{Z7();eee()});function LFe(e,t,r){if(r!=null){var n=r.clone();return[jb(e,t,n),n]}return function(o){var i=o.clone();return[jb(e,t,i),i]}}var UFe=h(()=>{tee()});function qb(e,t,r){for(var n=t-e+BD(1),o=BD(-2147483648),i=BD(4294967296),s=i,a=1;s<n;)s*=i,++a;for(var c=s-s%n;;){for(var u=BD(0),l=0;l!==a;++l){var d=r.unsafeNext();u=i*u+(BD(d)-o)}if(u<c){var f=u%n;return f+e}}}var BD,ree=h(()=>{BD=typeof BigInt<"u"?BigInt:void 0});function $Fe(e,t,r){if(r!=null){var n=r.clone();return[qb(e,t,n),n]}return function(o){var i=o.clone();return[qb(e,t,i),i]}}var HFe=h(()=>{ree()});function VNt(e,t,r,n){var o=r<=qNt?fH(WFe,r):FFe(WFe,fH(GNt,t),fH(zNt,e));return o.data[1]===4294967295?(o.data[0]+=1,o.data[1]=0):o.data[1]+=1,mH(nee,o.data,n),nee[0]*4294967296+nee[1]+e}function xh(e,t,r){var n=t-e;if(n<=4294967295){var o=pH(n+1,r);return o+e}return VNt(e,t,n,r)}var qNt,GNt,zNt,WFe,nee,oee=h(()=>{X7();Z7();eee();qNt=Number.MAX_SAFE_INTEGER,GNt={sign:1,data:[0,0]},zNt={sign:1,data:[0,0]},WFe={sign:1,data:[0,0]},nee=[0,0]});function jFe(e,t,r){if(r!=null){var n=r.clone();return[xh(e,t,n),n]}return function(o){var i=o.clone();return[xh(e,t,i),i]}}var qFe=h(()=>{oee()});var iee={};tr(iee,{__commitHash:()=>KNt,__type:()=>YNt,__version:()=>JNt,congruential32:()=>kFe,generateN:()=>CFe,mersenne:()=>_Fe,skipN:()=>z7,uniformArrayIntDistribution:()=>LFe,uniformBigIntDistribution:()=>$Fe,uniformIntDistribution:()=>jFe,unsafeGenerateN:()=>G7,unsafeSkipN:()=>_D,unsafeUniformArrayIntDistribution:()=>jb,unsafeUniformBigIntDistribution:()=>qb,unsafeUniformIntDistribution:()=>xh,xoroshiro128plus:()=>NFe,xorshift128plus:()=>DFe});var YNt,JNt,KNt,see=h(()=>{wFe();vFe();BFe();QFe();PFe();UFe();HFe();qFe();tee();ree();oee();YNt="module",JNt="6.1.0",KNt="a413dd2b721516be2ef29adffb515c5ae67bfbad"});var D0,hH=h(()=>{see();see();D0=iee});var vs,TD=h(()=>{(function(e){e[e.None=0]="None",e[e.Verbose=1]="Verbose",e[e.VeryVerbose=2]="VeryVerbose"})(vs||(vs={}))});var ZNt,XNt,ePt,ra,aee=h(()=>{hH();TD();ZNt=Date.now,XNt=Math.min,ePt=Math.random,ra=class e{constructor(t){let r=t||{};this.seed=e.readSeed(r),this.randomType=e.readRandomType(r),this.numRuns=e.readNumRuns(r),this.verbose=e.readVerbose(r),this.maxSkipsPerRun=e.readOrDefault(r,"maxSkipsPerRun",100),this.timeout=e.safeTimeout(e.readOrDefault(r,"timeout",null)),this.skipAllAfterTimeLimit=e.safeTimeout(e.readOrDefault(r,"skipAllAfterTimeLimit",null)),this.interruptAfterTimeLimit=e.safeTimeout(e.readOrDefault(r,"interruptAfterTimeLimit",null)),this.markInterruptAsFailure=e.readBoolean(r,"markInterruptAsFailure"),this.skipEqualValues=e.readBoolean(r,"skipEqualValues"),this.ignoreEqualValues=e.readBoolean(r,"ignoreEqualValues"),this.logger=e.readOrDefault(r,"logger",n=>{console.log(n)}),this.path=e.readOrDefault(r,"path",""),this.unbiased=e.readBoolean(r,"unbiased"),this.examples=e.readOrDefault(r,"examples",[]),this.endOnFailure=e.readBoolean(r,"endOnFailure"),this.reporter=e.readOrDefault(r,"reporter",null),this.asyncReporter=e.readOrDefault(r,"asyncReporter",null),this.errorWithCause=e.readBoolean(r,"errorWithCause")}toParameters(){let t=n=>n!==null?n:void 0;return{seed:this.seed,randomType:this.randomType,numRuns:this.numRuns,maxSkipsPerRun:this.maxSkipsPerRun,timeout:t(this.timeout),skipAllAfterTimeLimit:t(this.skipAllAfterTimeLimit),interruptAfterTimeLimit:t(this.interruptAfterTimeLimit),markInterruptAsFailure:this.markInterruptAsFailure,skipEqualValues:this.skipEqualValues,ignoreEqualValues:this.ignoreEqualValues,path:this.path,logger:this.logger,unbiased:this.unbiased,verbose:this.verbose,examples:this.examples,endOnFailure:this.endOnFailure,reporter:t(this.reporter),asyncReporter:t(this.asyncReporter),errorWithCause:this.errorWithCause}}static read(t){return new e(t)}};ra.createQualifiedRandomGenerator=e=>t=>{let r=e(t);return r.unsafeJump===void 0&&(r.unsafeJump=()=>_D(r,42)),r};ra.readSeed=e=>{if(e.seed==null)return ZNt()^ePt()*4294967296;let t=e.seed|0;if(e.seed===t)return t;let r=e.seed-t;return t^r*4294967296};ra.readRandomType=e=>{if(e.randomType==null)return D0.xorshift128plus;if(typeof e.randomType=="string")switch(e.randomType){case"mersenne":return ra.createQualifiedRandomGenerator(D0.mersenne);case"congruential":case"congruential32":return ra.createQualifiedRandomGenerator(D0.congruential32);case"xorshift128plus":return D0.xorshift128plus;case"xoroshiro128plus":return D0.xoroshiro128plus;default:throw new Error(`Invalid random specified: '${e.randomType}'`)}let t=e.randomType(0);if("min"in t&&t.min!==-2147483648)throw new Error(`Invalid random number generator: min must equal -0x80000000, got ${String(t.min)}`);if("max"in t&&t.max!==2147483647)throw new Error(`Invalid random number generator: max must equal 0x7fffffff, got ${String(t.max)}`);return"unsafeJump"in t?e.randomType:ra.createQualifiedRandomGenerator(e.randomType)};ra.readNumRuns=e=>e.numRuns!=null?e.numRuns:e.num_runs!=null?e.num_runs:100;ra.readVerbose=e=>e.verbose==null?vs.None:typeof e.verbose=="boolean"?e.verbose===!0?vs.Verbose:vs.None:e.verbose<=vs.None?vs.None:e.verbose>=vs.VeryVerbose?vs.VeryVerbose:e.verbose|0;ra.readBoolean=(e,t)=>e[t]===!0;ra.readOrDefault=(e,t,r)=>{let n=e[t];return n??r};ra.safeTimeout=e=>e===null?null:XNt(e,2147483647)});var GFe=h(()=>{my()});var zFe=h(()=>{ge()});var cee=h(()=>{});function uee(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&yy in e&&typeof e[yy]=="function"}function lee(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&O0 in e&&typeof e[O0]=="function"}function sPt(e){if(e.description!==void 0)return e.description;let t=iPt.exec(Id(e));return t&&t[1].length?t[1]:null}function XFe(e){switch(e){case 0:return 1/e===ZFe?"-0":"0";case ZFe:return"Number.NEGATIVE_INFINITY";case oPt:return"Number.POSITIVE_INFINITY";default:return e===e?Id(e):"Number.NaN"}}function aPt(e){let t=-1;for(let r in e){let n=Number(r);if(n!==t+1)return!0;t=n}return t+1!==e.length}function Xu(e,t,r){let n=[...t,e];if(typeof e=="object"&&B0(t,e)!==-1)return"[cyclic]";if(lee(e)){let o=r(e);if(o.state==="fulfilled")return o.value}if(uee(e))try{return e[yy]()}catch{}switch($7(e)){case"[object Array]":{let o=e;if(o.length>=50&&aPt(o)){let s=[];for(let a in o)JFe(Number(a))||Un(s,`${a}:${Xu(o[a],n,r)}`);return s.length!==0?`Object.assign(Array(${o.length}),{${Bi(s,",")}})`:`Array(${o.length})`}let i=Bi(Vo(o,s=>Xu(s,n,r)),",");return o.length===0||o.length-1 in o?`[${i}]`:`[${i},]`}case"[object BigInt]":return`${e}n`;case"[object Boolean]":{let o=e==!0?"true":"false";return typeof e=="boolean"?o:`new Boolean(${o})`}case"[object Date]":{let o=e;return JFe(iH(o))?"new Date(NaN)":`new Date(${Q0(yFe(o))})`}case"[object Map]":return`new Map(${Xu(Array.from(e),n,r)})`;case"[object Null]":return"null";case"[object Number]":return typeof e=="number"?XFe(e):`new Number(${XFe(Number(e))})`;case"[object Object]":{try{let a=e.toString;if(typeof a=="function"&&a!==Object.prototype.toString)return e.toString()}catch{return"[object Object]"}let o=a=>`${a==="__proto__"?'["__proto__"]':typeof a=="symbol"?`[${Xu(a,n,r)}]`:Q0(a)}:${Xu(e[a],n,r)}`,i=[...Vo(tPt(e),o),...Vo(AFe(rPt(e),a=>{let c=nPt(e,a);return c&&c.enumerable}),o)],s="{"+Bi(i,",")+"}";return KFe(e)===null?s==="{}"?"Object.create(null)":`Object.assign(Object.create(null),${s})`:s}case"[object Set]":return`new Set(${Xu(Array.from(e),n,r)})`;case"[object String]":return typeof e=="string"?Q0(e):`new String(${Q0(e)})`;case"[object Symbol]":{let o=e;if(oH.keyFor(o)!==void 0)return`Symbol.for(${Q0(oH.keyFor(o))})`;let i=sPt(o);if(i===null)return"Symbol()";let s=i.startsWith("Symbol.")&&oH[i.substring(7)];return o===s?i:`Symbol(${Q0(i)})`}case"[object Promise]":{let o=r(e);switch(o.state){case"fulfilled":return`Promise.resolve(${Xu(o.value,n,r)})`;case"rejected":return`Promise.reject(${Xu(o.value,n,r)})`;case"pending":return"new Promise(() => {/*pending*/})";case"unknown":default:return"new Promise(() => {/*unknown*/})"}}case"[object Error]":if(e instanceof Error)return`new Error(${Xu(e.message,n,r)})`;break;case"[object Undefined]":return"undefined";case"[object Int8Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Int16Array]":case"[object Uint16Array]":case"[object Int32Array]":case"[object Uint32Array]":case"[object Float32Array]":case"[object Float64Array]":case"[object BigInt64Array]":case"[object BigUint64Array]":{if(typeof YFe=="function"&&YFe(e))return`Buffer.from(${Xu(VFe(e.values()),n,r)})`;let o=KFe(e),i=o&&o.constructor&&o.constructor.name;if(typeof i=="string"){let a=e.values();return`${i}.from(${Xu(VFe(a),n,r)})`}break}}try{return e.toString()}catch{return $7(e)}}function Bc(e){return Xu(e,[],()=>({state:"unknown",value:void 0}))}var VFe,YFe,Q0,JFe,tPt,rPt,nPt,KFe,ZFe,oPt,yy,O0,iPt,Tc=h(()=>{ge();VFe=Array.from,YFe=typeof Buffer<"u"?Buffer.isBuffer:void 0,Q0=JSON.stringify,JFe=Number.isNaN,tPt=Object.keys,rPt=Object.getOwnPropertySymbols,nPt=Object.getOwnPropertyDescriptor,KFe=Object.getPrototypeOf,ZFe=Number.NEGATIVE_INFINITY,oPt=Number.POSITIVE_INFINITY,yy=Symbol.for("fast-check/toStringMethod");O0=Symbol.for("fast-check/asyncToStringMethod");iPt=/^Symbol\((.*)\)$/});var eLe=h(()=>{Tc();my()});var yFr,tLe=h(()=>{GFe();zFe();cee();eLe();yFr=Date.now});var Eh,AH=h(()=>{(function(e){e[e.Success=0]="Success",e[e.Skipped=-1]="Skipped",e[e.Failure=1]="Failure"})(Eh||(Eh={}))});var yH,rLe=h(()=>{TD();AH();ge();yH=class e{constructor(t,r){this.verbosity=t,this.interruptedAsFailure=r,this.isSuccess=()=>this.pathToFailure==null,this.firstFailure=()=>this.pathToFailure?+kd(this.pathToFailure,":")[0]:-1,this.numShrinks=()=>this.pathToFailure?kd(this.pathToFailure,":").length-1:0,this.rootExecutionTrees=[],this.currentLevelExecutionTrees=this.rootExecutionTrees,this.failure=null,this.numSkips=0,this.numSuccesses=0,this.interrupted=!1}appendExecutionTree(t,r){let n={status:t,value:r,children:[]};return this.currentLevelExecutionTrees.push(n),n}fail(t,r,n){if(this.verbosity>=vs.Verbose){let o=this.appendExecutionTree(Eh.Failure,t);this.currentLevelExecutionTrees=o.children}this.pathToFailure==null?this.pathToFailure=`${r}`:this.pathToFailure+=`:${r}`,this.value=t,this.failure=n}skip(t){this.verbosity>=vs.VeryVerbose&&this.appendExecutionTree(Eh.Skipped,t),this.pathToFailure==null&&++this.numSkips}success(t){this.verbosity>=vs.VeryVerbose&&this.appendExecutionTree(Eh.Success,t),this.pathToFailure==null&&++this.numSuccesses}interrupt(){this.interrupted=!0}extractFailures(){if(this.isSuccess())return[];let t=[],r=this.rootExecutionTrees;for(;r.length>0&&r[r.length-1].status===Eh.Failure;){let n=r[r.length-1];t.push(n.value),r=n.children}return t}toRunDetails(t,r,n,o){if(!this.isSuccess())return{failed:!0,interrupted:this.interrupted,numRuns:this.firstFailure()+1-this.numSkips,numSkips:this.numSkips,numShrinks:this.numShrinks(),seed:t,counterexample:this.value,counterexamplePath:e.mergePaths(r,this.pathToFailure),error:this.failure.errorMessage,errorInstance:this.failure.error,failures:this.extractFailures(),executionSummary:this.rootExecutionTrees,verbose:this.verbosity,runConfiguration:o.toParameters()};let i=this.interruptedAsFailure||this.numSuccesses===0;return{failed:this.numSkips>n||this.interrupted&&i,interrupted:this.interrupted,numRuns:this.numSuccesses,numSkips:this.numSkips,numShrinks:0,seed:t,counterexample:null,counterexamplePath:null,error:null,errorInstance:null,failures:[],executionSummary:this.rootExecutionTrees,verbose:this.verbosity,runConfiguration:o.toParameters()}}};yH.mergePaths=(e,t)=>{if(e.length===0)return t;let r=e.split(":"),n=t.split(":"),o=+r[r.length-1]+ +n[0];return[...r.slice(0,r.length-1),`${o}`,...n.slice(1)].join(":")}});var nLe=h(()=>{my();rLe()});var oLe=h(()=>{});var xy,dee=h(()=>{hH();xy=class e{constructor(t){this.internalRng=t.clone()}clone(){return new e(this.internalRng)}next(t){return xh(0,(1<<t)-1,this.internalRng)}nextBoolean(){return xh(0,1,this.internalRng)==1}nextInt(t,r){return xh(t??e.MIN_INT,r??e.MAX_INT,this.internalRng)}nextBigInt(t,r){return qb(t,r,this.internalRng)}nextArrayInt(t,r){return jb(t,r,this.internalRng)}nextDouble(){let t=this.next(26),r=this.next(27);return(t*e.DBL_FACTOR+r)*e.DBL_DIVISOR}getState(){if("getState"in this.internalRng&&typeof this.internalRng.getState=="function")return this.internalRng.getState()}};xy.MIN_INT=-2147483648;xy.MAX_INT=2147483647;xy.DBL_FACTOR=Math.pow(2,27);xy.DBL_DIVISOR=Math.pow(2,-53)});var fee=h(()=>{hH();dee();vn();ge()});var pee=h(()=>{});var mee=h(()=>{ge();Tc();TD();AH()});var iLe=h(()=>{kn();$b();aee();tLe();nLe();oLe();fee();pee();mee()});var sLe=h(()=>{kn();q7();cee();$b();aee();fee();pee()});var aLe=h(()=>{vn();ks();ge();Tc()});var xLr,cLe=h(()=>{ge();xLr=Array.isArray});var uLe=h(()=>{Ln();kn();ge();aLe();cLe();H7()});var lLe=h(()=>{uLe()});function fLe(e){return fPt(dLe(e)/dLe(2))}function hee(e,t,r){if(e===t)return[{min:e,max:t}];if(e<0&&t>0){let s=r(-e),a=r(t);return[{min:-s,max:a},{min:t-a,max:t},{min:e,max:e+s}]}let n=r(t-e),o={min:e,max:e+n},i={min:t-n,max:t};return e<0?[i,o]:[o,i]}var fPt,dLe,gee=h(()=>{ge();fPt=Math.floor,dLe=Math.log});function pLe(e){return mPt(e/2)}function mLe(e){return pPt(e/2)}function Aee(e,t,r){let n=e-t;function*o(){let s=r?void 0:t,a=r?n:pLe(n);for(let c=a;c>0;c=pLe(c)){let u=c===n?t:e-c;yield new hr(u,s),s=u}}function*i(){let s=r?void 0:t,a=r?n:mLe(n);for(let c=a;c<0;c=mLe(c)){let u=c===n?t:e-c;yield new hr(u,s),s=u}}return n>0?hy(o()):hy(i())}var pPt,mPt,hLe=h(()=>{vn();kn();pPt=Math.ceil,mPt=Math.floor});var gLe,hPt,gPt,Ey,N0=h(()=>{Ln();vn();kn();gee();hLe();gLe=Math.sign,hPt=Number.isInteger,gPt=Object.is,Ey=class e extends on{constructor(t,r){super(),this.min=t,this.max=r}generate(t,r){let n=this.computeGenerateRange(t,r);return new hr(t.nextInt(n.min,n.max),void 0)}canShrinkWithoutContext(t){return typeof t=="number"&&hPt(t)&&!gPt(t,-0)&&this.min<=t&&t<=this.max}shrink(t,r){if(!e.isValidContext(t,r)){let n=this.defaultTarget();return Aee(t,n,!0)}return this.isLastChanceTry(t,r)?Nr.of(new hr(r,void 0)):Aee(t,r,!1)}defaultTarget(){return this.min<=0&&this.max>=0?0:this.min<0?this.max:this.min}computeGenerateRange(t,r){if(r===void 0||t.nextInt(1,r)!==1)return{min:this.min,max:this.max};let n=hee(this.min,this.max,fLe);if(n.length===1)return n[0];let o=t.nextInt(-2*(n.length-1),n.length-2);return o<0?n[0]:n[o+1]}isLastChanceTry(t,r){return t>0?t===r+1&&t>this.min:t<0?t===r-1&&t<this.max:!1}static isValidContext(t,r){if(r===void 0)return!1;if(typeof r!="number")throw new Error("Invalid context type passed to IntegerArbitrary (#1)");if(r!==0&&gLe(t)!==gLe(r))throw new Error("Invalid context value passed to IntegerArbitrary (#2)");return!0}}});function APt(e){let t=e.min!==void 0?e.min:-2147483648,r=e.max!==void 0?e.max:2147483647;return{min:t,max:r}}function Jo(e={}){let t=APt(e);if(t.min>t.max)throw new Error("fc.integer maximum value should be equal or greater than the minimum one");if(!ALe(t.min))throw new Error("fc.integer minimum value should be an integer");if(!ALe(t.max))throw new Error("fc.integer maximum value should be an integer");return new Ey(t.min,t.max)}var ALe,Ko=h(()=>{N0();ALe=Number.isInteger});var QD=h(()=>{ge()});var yLe=h(()=>{});var xLe=h(()=>{vn();ge()});var ELe=h(()=>{yLe();xLe()});var h1r,yee=h(()=>{kn();ks();Ko();T0();Ln();vn();QD();ELe();ge();h1r=Array.isArray});var tl=h(()=>{$b();ge()});var Zo=h(()=>{yee();tl()});var SLe=h(()=>{kn();vn();ge()});var OD=h(()=>{kn();Ln();vn();gee();SLe();ge()});var ND=h(()=>{ge();OD()});var CLe=h(()=>{ge();OD()});var wLe=h(()=>{ge();OD()});var bee=h(()=>{ge();OD()});var See=h(()=>{});var M0=h(()=>{Ko();See()});var wee=h(()=>{kn();Ln();vn();ks();ge()});var F0=h(()=>{wee()});var ILe=h(()=>{ge();F0()});function vLe(e){if(typeof e!="string")throw new Error("Cannot unmap non-string");if(e.length===0||e.length>2)throw new Error("Cannot unmap string with more or less than one character");let t=Ub(e,0);if(e.length===1)return t;let r=Ub(e,1);if(t<55296||t>56319||r<56320||r>57343)throw new Error("Cannot unmap invalid surrogate pairs");return e.codePointAt(0)}var kLe,RLe=h(()=>{ge();kLe=String.fromCodePoint});function bh(e,t,r,n){return Jo({min:e,max:t}).map(o=>kLe(r(o)),o=>n(vLe(o)))}var by=h(()=>{Ko();RLe()});function PD(e){return e<95?e+32:e<=126?e-95:e}function MD(e){return e>=32&&e<=126?e-32:e>=0&&e<=31?e+95:e}var FD=h(()=>{});var Iee=h(()=>{by();FD()});var kee=h(()=>{by()});function _Le(e){return e}function vee(){return bh(32,126,_Le,_Le)}var Ree=h(()=>{by()});var _ee=h(()=>{by();FD()});function bPt(e){return e<55296?PD(e):e+Bee}function SPt(e){return e<55296?MD(e):e<=57343?-1:e-Bee}function bH(){return bh(0,1114111-Bee,bPt,SPt)}var Bee,SH=h(()=>{by();FD();Bee=2048});var Tee=h(()=>{by()});var Dee=h(()=>{by();FD()});var rl=h(()=>{wee()});var BLe,TLe=h(()=>{ks();rl();BLe=class e{constructor(){this.receivedLogs=[]}log(t){this.receivedLogs.push(t)}size(){return this.receivedLogs.length}toString(){return JSON.stringify({logs:this.receivedLogs})}[ao](){return new e}}});var $Ur,HUr,DLe=h(()=>{ge();$Ur=Number.NaN,HUr=Number.isNaN});var KUr,Qee=h(()=>{ge();Ko();DLe();KUr=Number.isNaN});var o$r,QLe=h(()=>{Ln();vn();ks();kn();ge();o$r=Array.isArray});var OLe=h(()=>{QLe()});var NLe=h(()=>{ge()});var f$r,MLe=h(()=>{ge();f$r=Number.isNaN});var FLe=h(()=>{ge()});var LLe=h(()=>{ge()});var LD=h(()=>{yee();tl();NLe();MLe();FLe();LLe()});var ULe=h(()=>{ge()});var wH=h(()=>{uo();LD();ULe();rl();M0()});var G$r,z$r,V$r,Nee=h(()=>{kn();Ln();vn();QD();tl();ge();G$r=Number.POSITIVE_INFINITY,z$r=Number.MAX_SAFE_INTEGER,V$r=Number.isInteger});var nl=h(()=>{Ln();ge();Nee()});var r2r,L0=h(()=>{N0();r2r=Number.isInteger});var $Le=h(()=>{ge()});var kH=h(()=>{L0();$Le();ge()});function kPt(e){let t=gFe(e);return e!==t?t:`%${sH(Ub(e,0),16)}`}function vPt(e){if(typeof e!="string")throw new Error("Unsupported");return decodeURIComponent(e)}var g2r,A2r,U0=h(()=>{SH();nl();kH();ge();g2r=String.fromCharCode;A2r=bH().map(kPt,vPt)});var $0=h(()=>{rl();Nee();ge()});var Pee=h(()=>{ge()});var vH=h(()=>{tl();ge();Pee()});var Sh=h(()=>{ge();vH();tl();Pee()});var jLe=h(()=>{});var L2r,qLe=h(()=>{ge();L2r=String.fromCodePoint});var GLe=h(()=>{ge();kH();jLe();qLe()});var Ch=h(()=>{Zo();Sh();GLe();vH()});var zLe=h(()=>{});var lHr,Mee=h(()=>{Ln();vn();kn();lHr=Symbol("adapted-value")});var _H=h(()=>{Zo();U0();$0();Ch();uo();zLe();tl();Mee();ge()});var JLe=h(()=>{Zo();U0();_H();Ch();uo();Mee();ge()});var BH=h(()=>{});var ZLe=h(()=>{kn();Ln();vn();BH()});var qHr,GHr,zHr,XLe,VHr,e1e=h(()=>{BH();qHr=Number.NEGATIVE_INFINITY,GHr=Number.POSITIVE_INFINITY,zHr=Number.EPSILON,XLe=new Float64Array(1),VHr=new Uint32Array(XLe.buffer,XLe.byteOffset)});var JHr,KHr,ZHr,Fee=h(()=>{JHr=Number.isInteger,KHr=Number.NEGATIVE_INFINITY,ZHr=Number.POSITIVE_INFINITY});var tWr,rWr,nWr,t1e=h(()=>{Fee();tWr=Number.NEGATIVE_INFINITY,rWr=Number.POSITIVE_INFINITY,nWr=Number.MAX_VALUE});var hWr,gWr,AWr,yWr,xWr,EWr,UD=h(()=>{BH();ZLe();e1e();t1e();hWr=Number.isInteger,gWr=Number.isNaN,AWr=Number.NEGATIVE_INFINITY,yWr=Number.POSITIVE_INFINITY,xWr=Number.MAX_VALUE,EWr=Number.NaN});var SWr,CWr,wWr,n1e,IWr,r1e,kWr,Lee=h(()=>{SWr=Number.NEGATIVE_INFINITY,CWr=Number.POSITIVE_INFINITY,wWr=2**-126*2**-23,n1e=2**127*(1+(2**23-1)/2**23),IWr=2**-23,r1e=new Float32Array(1),kWr=new Uint32Array(r1e.buffer,r1e.byteOffset)});var BWr,TWr,o1e=h(()=>{Lee();Fee();BWr=Number.NEGATIVE_INFINITY,TWr=Number.POSITIVE_INFINITY});var $Wr,HWr,WWr,jWr,qWr,Uee=h(()=>{Ko();Lee();o1e();$Wr=Number.isInteger,HWr=Number.isNaN,WWr=Number.NEGATIVE_INFINITY,jWr=Number.POSITIVE_INFINITY,qWr=Number.NaN});function i1e(e){return e.replace(/([$`\\])/g,"\\$1").replace(/\r/g,"\\r")}var TH=h(()=>{});var DH=h(()=>{ge()});var QH=h(()=>{});var $ee=h(()=>{TH();ks();DH();Tc();Ko();QH();uo();ge()});var c1e=h(()=>{$ee()});var u1e=h(()=>{$ee()});var d1e=h(()=>{DH();Tc();ks();Zo();Ko();QH();uo();TH();ge()});var bjr,Sjr,Hee=h(()=>{N0();bjr=Number.MIN_SAFE_INTEGER,Sjr=Number.MAX_SAFE_INTEGER});var Ijr,f1e=h(()=>{N0();Ijr=Number.MAX_SAFE_INTEGER});var Rjr,Wee=h(()=>{ge();Rjr=Number.parseInt});var OH=h(()=>{ge();L0();uo();Wee()});var p1e=h(()=>{F0();L0();uo();Wee()});var jee=h(()=>{ge();nl();uo();p1e()});var H0=h(()=>{ge()});var qee=h(()=>{Zo();Tee();H0();Sh()});var m1e=h(()=>{ge()});var Gee=h(()=>{Zo();nl();qee();uo();OH();m1e()});var g1e=h(()=>{Ln()});var zee=h(()=>{g1e();ge()});var A1e=h(()=>{ge()});var y1e=h(()=>{Zo();rl();nl();A1e()});var x1e=h(()=>{ge()});var E1e=h(()=>{ge()});var b1e=h(()=>{bee();Ln();vn();T0();E1e();ge();ge()});var S1e=h(()=>{ge();b1e()});var Vee=h(()=>{Uee();Zo();ge()});var Jee=h(()=>{UD();Zo();ge()});var rp=h(()=>{Zo()});var Kee=h(()=>{ge();Ko();rp()});var Zee=h(()=>{ge();Ko();rp()});var Xee=h(()=>{ge();Ko();rp()});var ete=h(()=>{ge();Ko();rp()});var tte=h(()=>{ge();Ko();rp()});var rte=h(()=>{ge();Ko();rp()});var nte=h(()=>{ge();Ko();rp()});var C1e=h(()=>{Ln();vn()});var ote=h(()=>{Ko();C1e()});var hzr,ite=h(()=>{ge();uo();LD();ote();tl();hzr=hFe.isArray});var w1e=h(()=>{});var I1e=h(()=>{});var ate=h(()=>{Tc();Zo();nl();uo();ND();Qee();Vee();Jee();Kee();Zee();Xee();ete();tte();rte();nte();ite();w1e();I1e();zee();LD();QD();wH()});var MH=h(()=>{Zo();SH();H0();Sh()});var v1e=h(()=>{ge()});var R1e=h(()=>{v1e()});var cte=h(()=>{M0();rl();UD();MH();Hee();nl();Ch();R1e()});var B1e=h(()=>{wH();ate();cte()});var ute=h(()=>{M0();rl();UD()});var FH=h(()=>{ate();cte()});var lte=h(()=>{Ch();ute();FH();MH()});var D1e=h(()=>{lte()});var dte=h(()=>{Zo();Dee();H0();Sh()});var fte=h(()=>{dte();ute();FH()});var Q1e=h(()=>{fte()});var O1e=h(()=>{});var N1e=h(()=>{ge()});var r4r,P1e=h(()=>{ge();M0();rl();$0();uo();O1e();N1e();r4r=Symbol("no-key")});var M1e=h(()=>{P1e()});var F1e=h(()=>{Ln();vn();ks();kn();ge();Tc()});var L1e=h(()=>{F1e()});var U1e=h(()=>{Zo();Iee();H0();Sh()});var $1e=h(()=>{ge()});var H1e=h(()=>{Zo();kee();tl();H0();$1e();Sh()});var W1e=h(()=>{ge()});var j1e=h(()=>{Zo();_ee();W1e();Sh()});var pte=h(()=>{Zo();vH();Sh()});var q1e=h(()=>{ge()});var rYr,mte=h(()=>{Ln();vn();T0();kn();ge();q1e();N0();rYr=Array.isArray});var G1e=h(()=>{mte()});var z1e=h(()=>{mte()});function wMt(e){return e<10?Id(e):CMt[e]}function V1e(e,t){let r="";for(;e.length+r.length<t;)r+="0";return r+e}function Y1e(e){let t="";for(let r=e;r!==0;){let n=r>>5,o=r-(n<<5);t=wMt(o)+t,r=n}return t}function IMt(e,t){let r=~~(e/1073741824),n=e&1073741823;return V1e(Y1e(r),t-6)+V1e(Y1e(n),6)}function hte(e){return function(r){return IMt(r,e)}}var CMt,J1e=h(()=>{ge();CMt={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F",16:"G",17:"H",18:"J",19:"K",20:"M",21:"N",22:"P",23:"Q",24:"R",25:"S",26:"T",27:"V",28:"W",29:"X",30:"Y",31:"Z"}});var mYr,hYr,K1e=h(()=>{uo();Ko();J1e();mYr=hte(10),hYr=hte(8)});var Z1e=h(()=>{ge()});var gte=h(()=>{Ko();Z1e()});var Ate=h(()=>{ge()});var X1e=h(()=>{ge()});var eUe=h(()=>{uo();gte();Ate();ge();X1e()});var tUe=h(()=>{uo();gte();Ate()});var yte=h(()=>{U0();rl();_H();OH();jee();Gee();L0();nl();$0();Ch();uo()});var xte=h(()=>{U0();Ch()});var Ete=h(()=>{xte()});var bte=h(()=>{U0();Ch()});var nUe=h(()=>{ge()});var oUe=h(()=>{bte();Zo();nUe();nl()});var Ste=h(()=>{tl();oUe()});var Cte=h(()=>{xte()});var iUe=h(()=>{});var sUe=h(()=>{F0();rl();$0();uo();Cte();Ete();yte();iUe();tl();Ste()});var wte,aUe=h(()=>{ks();wte=class e{constructor(t,r){this.commands=t,this.metadataForReplay=r}[Symbol.iterator](){return this.commands[Symbol.iterator]()}[ao](){return new e(this.commands.map(t=>t.clone()),this.metadataForReplay)}toString(){let t=this.commands.filter(n=>n.hasRan).map(n=>n.toString()).join(","),r=this.metadataForReplay();return r.length!==0?`${t} /*${r}*/`:t}}});var cUe=h(()=>{Tc();ks()});var uUe=h(()=>{});var lUe=h(()=>{Ln();vn();aUe();cUe();uUe();T0();kn();nl();ote()});var dUe=h(()=>{lUe();tl()});var fUe=h(()=>{});var pUe=h(()=>{fUe()});var LH,UH,Ite=h(()=>{TH();ks();Tc();LH=e=>e(),UH=class e{constructor(t,r){this.act=t,this.taskSelector=r,this.lastTaskId=0,this.sourceTaskSelector=r.clone(),this.scheduledTasks=[],this.triggeredTasks=[],this.scheduledWatchers=[]}static buildLog(t){return`[task\${${t.taskId}}] ${t.label.length!==0?`${t.schedulingType}::${t.label}`:t.schedulingType} ${t.status}${t.outputValue!==void 0?` with value ${i1e(t.outputValue)}`:""}`}log(t,r,n,o,i,s){this.triggeredTasks.push({status:i,schedulingType:t,taskId:r,label:n,metadata:o,outputValue:s!==void 0?Bc(s):void 0})}scheduleInternal(t,r,n,o,i,s){let a=null,c=++this.lastTaskId,u=new Promise((l,d)=>{a=()=>{(s?n.then(()=>s()):n).then(f=>(this.log(t,c,r,o,"resolved",f),l(f)),f=>(this.log(t,c,r,o,"rejected",f),d(f)))}});return this.scheduledTasks.push({original:n,scheduled:u,trigger:a,schedulingType:t,taskId:c,label:r,metadata:o,customAct:i}),this.scheduledWatchers.length!==0&&this.scheduledWatchers[0](),u}schedule(t,r,n,o){return this.scheduleInternal("promise",r||"",t,n,o||LH)}scheduleFunction(t,r){return(...n)=>this.scheduleInternal("function",`${t.name}(${n.map(Bc).join(",")})`,t(...n),void 0,r||LH)}scheduleSequence(t,r){let n={done:!1,faulty:!1},o={then:a=>a()},i=()=>{},s=new Promise(a=>i=a);return t.reduce((a,c)=>{let[u,l,d]=typeof c=="function"?[c,c.name,void 0]:[c.builder,c.label,c.metadata];return a.then(()=>{let f=this.scheduleInternal("sequence",l,o,d,r||LH,()=>u());return f.catch(()=>{n.faulty=!0,i()}),f})},o).then(()=>{n.done=!0,i()},()=>{}),Object.assign(n,{task:Promise.resolve(s).then(()=>({done:n.done,faulty:n.faulty}))})}count(){return this.scheduledTasks.length}internalWaitOne(){if(this.scheduledTasks.length===0)throw new Error("No task scheduled");let t=this.taskSelector.nextTaskIndex(this.scheduledTasks),[r]=this.scheduledTasks.splice(t,1);return r.customAct(async()=>{r.trigger();try{await r.scheduled}catch{}})}async waitOne(t){let r=t||LH;await this.act(()=>r(async()=>await this.internalWaitOne()))}async waitAll(t){for(;this.scheduledTasks.length>0;)await this.waitOne(t)}async waitFor(t,r){let n=!1,o=null,i=async()=>{for(;!n&&this.scheduledTasks.length>0;)await this.waitOne(r);o=null},s=()=>{o===null&&(o=Promise.resolve().then(i))},a=()=>{let u=this.scheduledWatchers.indexOf(s);u!==-1&&this.scheduledWatchers.splice(u,1),u===0&&this.scheduledWatchers.length!==0&&this.scheduledWatchers[0]()},c=t.then(u=>(n=!0,o===null?(a(),u):o.then(()=>(a(),u))),u=>{if(n=!0,o===null)throw a(),u;return o.then(()=>{throw a(),u})});return this.scheduledTasks.length>0&&this.scheduledWatchers.length===0&&s(),this.scheduledWatchers.push(s),c}report(){return[...this.triggeredTasks,...this.scheduledTasks.map(t=>({status:"pending",schedulingType:t.schedulingType,taskId:t.taskId,label:t.label,metadata:t.metadata}))]}toString(){return"schedulerFor()`\n"+this.report().map(e.buildLog).map(t=>`-> ${t}`).join(`
62
+ `,a)):c=s.indexOf("\r",c+1);t?e=e+s.substring(a,s.length-1):e=e+s.substring(a,s.length)}}),ln(i)},n=ea({onInput:o=>{let i=r(o);return xu(i)?n:Et(cr(i),()=>n)},onFailure:o=>e.length===0?In(o):Et(cr(Dt(e)),()=>In(o)),onDone:o=>e.length===0?Yu(o):Et(cr(Dt(e)),()=>Yu(o))});return n}),k0=x(2,(e,t)=>Gu(ot(()=>new mD(e,void 0,be)),hh()).pipe(Ri(([r,n])=>JBe(t,o=>{let i=r.close(o);return i!==void 0?ry(i,n):ve})),hd,De(([r])=>Pt(()=>e7(r.run(),r))))),e7=(e,t)=>{let r=e;switch(r._tag){case ay:return es(t.getDone(),{onFailure:Is,onSuccess:n=>nt(Re(n))});case cy:return nt(Le(t.getEmit()));case yh:return C(r.effect,Ee(()=>e7(t.run(),t)));case uy:return O2(r,()=>e7(t.run(),t),n=>Is(n))}},Sd=e=>bPe(nn(e)),Fb=e=>I2(z2(e),(t,r)=>t,(t,r)=>t),CD=e=>I2(i7(e),(t,r)=>t,(t,r)=>t),R0=e=>wPe(0,e.length,e),wPe=(e,t,r)=>e===t?rs:C(cr(C(r,Wl(e))),Et(()=>wPe(e+1,t,r))),IPe=x(e=>S2(e[1]),(e,t,r)=>r?.concurrent?j2(e,{other:t,onSelfDone:n=>WX(o=>Pt(()=>Z1(n,o))),onOtherDone:n=>WX(o=>Pt(()=>Z1(o,n)))}):Et(e,n=>$2(t,o=>[n,o]))),Kf=x(e=>S2(e[1]),(e,t,r)=>r?.concurrent?$2(IPe(e,t,{concurrent:!0}),n=>n[1]):Et(e,()=>t)),L2=Symbol.for("effect/Channel/ChannelException"),kPe=e=>({_tag:"ChannelException",[L2]:L2,error:e}),vPe=e=>se(e,L2)});var RPe=h(()=>{});var _Pe,a7,JQt,KQt,c7,BPe,u7,TPe=h(()=>{sr();Ws();id();oe();bI();$f();vt();UI();La();_Pe=Symbol.for("effect/RcRef"),a7={_tag:"Empty"},JQt={_tag:"Closed"},KQt={_A:be,_E:be},c7=class extends Ys{acquire;context;scope;idleTimeToLive;[_Pe]=KQt;[Na]=Na;state=a7;semaphore=LI(1);constructor(t,r,n,o){super(),this.acquire=t,this.context=r,this.scope=n,this.idleTimeToLive=o,this.get=u7(this)}get;commit(){return this.get}},BPe=e=>st(t=>{let r=t.getFiberRef(li),n=Dr(r,Fa),o=new c7(e.acquire,r,n,e.idleTimeToLive?At(e.idleTimeToLive):void 0);return Zt(n.addFinalizer(()=>o.semaphore.withPermits(1)(ye(()=>{let i=o.state._tag==="Acquired"?rd(o.state.scope,Pn):Ue;return o.state=JQt,i}))),o)}),u7=e=>{let t=e,r=t.idleTimeToLive&&!L_(t.idleTimeToLive);return xn(n=>ye(()=>{switch(t.state._tag){case"Closed":return qs;case"Acquired":return t.state.refCount++,t.state.fiber?Zt(gc(t.state.fiber),t.state):M(t.state);case"Empty":return oh().pipe(UB("scope"),LB("value",({scope:o})=>n(tn(t.acquire,li,zt(t.context,Fa,o)))),te(({scope:o,value:i})=>{let s={_tag:"Acquired",value:i,scope:o,fiber:void 0,refCount:1};return t.state=s,s}))}})).pipe(t.semaphore.withPermits(1),UB("state"),LB("scope",()=>Fa),jo(({scope:n,state:o})=>n.addFinalizer(()=>ye(()=>(o.refCount--,o.refCount>0||r?Ue:t.idleTimeToLive===void 0?(t.state=a7,rd(o.scope,Pn)):Jm(t.idleTimeToLive).pipe(Qa,je(ye(()=>t.state._tag==="Acquired"&&t.state.refCount===0?(t.state=a7,rd(o.scope,Pn)):Ue)),Js(V(()=>{o.fiber=void 0})),bT(t.scope),jo(i=>{o.fiber=i}),t.semaphore.withPermits(1)))))),te(({state:n})=>n.value))}});var DPe,l7,d7=h(()=>{TPe();DPe=BPe,l7=u7});var f7,OPe,NPe,Y2=h(()=>{JU();f7=qI,OPe=YU,NPe=DTe});var PPe=h(()=>{});var LPe,pOt,Cd,UPe,m7,$Pe,h7,g7,HPe,WPe,jPe,J2,A7,y7,Lb,qPe,x7=h(()=>{vr();nr();oe();Me();wD();Ob();LPe=Symbol.for("effect/Sink"),pOt={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e},Cd=class{channel;[LPe]=pOt;constructor(t){this.channel=t}pipe(){return Z(this,arguments)}},UPe=e=>new Cd(Ju(()=>Lb(e()))),m7=()=>new Cd($Pe(Ut())),$Pe=e=>ea({onInput:t=>$Pe(C(e,Ir(t))),onFailure:In,onDone:()=>Yu(e)}),h7=new Cd(v0(ED())),g7=e=>new Cd(_c(e)),HPe=(e,t,r)=>UPe(()=>new Cd(WPe(e,t,r))),WPe=(e,t,r)=>t(e)?bd({onInput:n=>WPe(r(e,n),t,r),onFailure:_c,onDone:()=>ta(e)}):ta(e),jPe=(e,t)=>HPe(e,ka,t),J2=e=>{let t=ea({onInput:r=>C(nn(hi(r,n=>e(n),{discard:!0})),Et(()=>t)),onFailure:In,onDone:()=>rs});return new Cd(t)},A7=e=>new Cd(e),y7=e=>new Cd(nn(e)),Lb=e=>ws(e)?Lb(y7(e)):e.channel,qPe=e=>new Cd(Fb(e.pipe(De(t=>Lb(t)))))});var zPe=h(()=>{});var VPe=h(()=>{});var YPe,JPe=h(()=>{Vs();vr();nr();Ro();oe();it();YPe=e=>Object.assign(e,{chunk(r){return this(nt(r))},die(r){return this(Ua(r))},dieMessage(r){return this(kb(r))},done(r){return this(Pt(()=>K1(r,{onFailure:H,onSuccess:Dt})))},end(){return this($e(W()))},fail(r){return this($e(H(r)))},fromEffect(r){return this(VT(r,{onFailure:H,onSuccess:Dt}))},fromEffectChunk(r){return this(C(r,Ha(H)))},halt(r){return this(Is(C(r,Fm(H))))},single(r){return this(nt(Dt(r)))}})});var yOt,xOt,EOt,ID,K2,KPe,Z2,X2,ZPe,E7,XPe=h(()=>{Vs();nr();Ro();oe();it();Me();yOt="effect/Take",xOt=Symbol.for(yOt),EOt={_A:e=>e,_E:e=>e},ID=class{exit;[xOt]=EOt;constructor(t){this.exit=t}pipe(){return Z(this,arguments)}},K2=e=>new ID(vo(e)),KPe=e=>Pt(()=>e.exit),Z2=new ID(Cc(W())),X2=e=>new ID(Mn(C(e,Fm(H)))),ZPe=e=>oy(e,{onFailure:t=>wt(zL(t),{onNone:()=>Z2,onSome:X2}),onSuccess:K2}),E7=x(2,(e,{onEnd:t,onFailure:r,onSuccess:n})=>es(e.exit,{onFailure:o=>wt(zL(o),{onNone:t,onSome:r}),onSuccess:n}))});var eMe,tMe=h(()=>{nr();it();eMe=()=>$e(W())});var jOt,eH,qOt,ns,b7,GOt,oMe,iMe,zOt,VOt,sMe,aMe,S7,rMe,nMe,C7,cMe,_i,w7,I7,uMe,lMe,dMe,k7,v7,fMe,tH,pMe,mMe,hMe,R7,gMe,AMe,yMe,xMe,EMe,bMe,_7,SMe=h(()=>{Vs();vr();$u();nr();Ro();oe();it();Me();ct();a2();NA();Y2();wD();JX();Ob();x7();JPe();tMe();XPe();jOt="effect/Stream",eH=Symbol.for(jOt),qOt={_R:e=>e,_E:e=>e,_A:e=>e},ns=class{channel;[eH]=qOt;constructor(t){this.channel=t}pipe(){return Z(this,arguments)}},b7=e=>se(e,eH)||ws(e),GOt=e=>{if(e==="unbounded")return uD();if(typeof e=="number"||e===void 0)return y0(e??16);switch(e.strategy){case"dropping":return i2(e.bufferSize??16);case"sliding":return s2(e.bufferSize??16);default:return y0(e.bufferSize??16)}},oMe=(e,t)=>C(zo(GOt(t),r=>Ah(r)),Ee(r=>C(hh(),Ee(n=>C(e(YPe(o=>C(ZPe(o),Ee(i=>Vu(r,i)),gd,OPe(n)).then(i=>{if(sd(i)&&!GL(i.cause))throw pK(i.cause)}))),Wt(bc(!1)),Ee(o=>C(Sc(o),De(i=>i?eMe():C(Qb(r),Ee(KPe),JT(()=>C(ib(o,!0),Wt(Ah(r)))))))))))),R7,S7(v7)),iMe=x(2,(e,t)=>{if(t.strategy==="dropping")return zOt(e,t.capacity);if(t.strategy==="sliding")return VOt(e,t.capacity);let r=yMe(e,t);return new ns(Fb(De(r,n=>{let o=C(nn(Qb(n)),Et(E7({onEnd:()=>rs,onFailure:In,onSuccess:i=>C(cr(i),Et(()=>o))})));return o})))}),zOt=x(2,(e,t)=>{let r=zo(i2(t),n=>Ah(n));return new ns(sMe(r,_i(e)))}),VOt=x(2,(e,t)=>{let r=zo(s2(t),n=>Ah(n));return new ns(sMe(r,_i(e)))}),sMe=(e,t)=>{let r=(o,i)=>{let s=a=>C(Sc(i),Ri(Ht),Wt(rn()),Ee(c=>C(Vu(o,[a,c]),Wt(ib(i,c)),Wt(Ht(c)))),gd,nn);return ea({onInput:a=>C(rn(),Ee(c=>C(Vu(o,[K2(a),c]),Ee(u=>C(ib(i,c),XT(()=>u))))),gd,nn,Et(()=>r(o,i))),onFailure:a=>s(X2(a)),onDone:()=>s(Z2)})},n=o=>{let i=C(nn(Qb(o)),Et(([s,a])=>Kf(nn(pi(a,void 0)),E7(s,{onEnd:()=>rs,onFailure:In,onSuccess:c=>C(cr(c),Et(()=>i))}))));return i};return Fb(C(e,Ee(o=>C(rn(),Ri(i=>pi(i,void 0)),Ee(i=>C(bc(i),Ee(s=>C(t,Vn(r(o,s)),G2,l0)),ju(n(o))))))))},aMe=e=>I7($e(H(e))),S7=x(e=>b7(e[0]),(e,t,r)=>{let n=r?.bufferSize??16;return r?.switch?rMe(r?.concurrency,()=>nMe(e,1,n,t),o=>nMe(e,o,n,t)):rMe(r?.concurrency,()=>new ns(yD(_i(e),o=>C(o,xf(i=>_i(t(i))),I_(rs,(i,s)=>C(i,Kf(s)))))),o=>new ns(C(_i(e),yD(R0),W2(i=>_i(t(i)),r))))}),rMe=(e,t,r)=>{switch(e){case void 0:return t();case"unbounded":return r(Number.MAX_SAFE_INTEGER);default:return e>1?r(e):t()}},nMe=x(4,(e,t,r,n)=>new ns(C(_i(e),yD(R0),W2(o=>_i(n(o)),{concurrency:t,mergeStrategy:mPe(),bufferSize:r})))),C7=x(e=>b7(e[0]),(e,t)=>S7(e,be,t)),cMe=e=>new ns(e),_i=e=>{if("channel"in e)return e.channel;if(ws(e))return _i(w7(e));throw new TypeError("Expected a Stream.")},w7=e=>C(e,Ha(H),I7),I7=e=>new ns(Sd(tX(e,{onFailure:wt({onNone:()=>rs,onSome:_c}),onSuccess:t=>cr(Dt(t))}))),uMe=(...e)=>{let t=e.length===1?e[0].evaluate:e[0],r=e.length===1?e[0].onError:e[1],n=e.length===1?e[0].releaseLockOnEnd===!0:!1;return _7(De(zo(ot(()=>t().getReader()),o=>n?ot(()=>o.releaseLock()):Y5(()=>o.cancel())),o=>fMe(Ee(ey({try:()=>o.read(),catch:i=>H(r(i))}),({done:i,value:s})=>i?$e(W()):nt(s)))))},lMe=x(2,(e,t)=>new ns(C(_i(e),bD(t)))),dMe=x(2,(e,t)=>new ns(C(_i(e),H2(t)))),k7=x(2,(e,t)=>new ns(Vn(_i(e),t))),v7=e=>EMe(e,t=>C(De(t,r=>H([r,t])),s0(wt({onNone:()=>nt(W()),onSome:$e})))),fMe=e=>v7(C(e,De(Dt))),tH=x(2,(e,t)=>_i(e).pipe(SD(Lb(t)),o7)),pMe=e=>tH(e,m7()),mMe=x(2,(e,t)=>tH(e,J2(t))),hMe=x(2,(e,t)=>{let r=ea({onInput:n=>Et(cr(K2(n)),()=>r),onFailure:n=>cr(X2(n)),onDone:()=>cr(Z2)});return C(Vn(_i(e),r),n7(n=>Vu(t,n)),v0,G2,gd)}),R7=e=>new ns(xD(z2(C(e,De(Dt))),ve)),gMe=e=>k7(e,s7()),AMe=e=>new ns(Ju(()=>_i(e()))),yMe=x(e=>b7(e[0]),(e,t)=>Ri(zo(t?.strategy==="unbounded"?uD():t?.strategy==="dropping"?i2(t.capacity??2):t?.strategy==="sliding"?s2(t.capacity??2):y0(t?.capacity??2),r=>Ah(r)),r=>l0(hMe(e,r)))),xMe=x(2,(e,t)=>{let r=Ju(()=>{let n={ref:Ut()},o={ref:!1},i=Ju(()=>{let u=n.ref;return xu(u)?bd({onInput:l=>C(cr(l),Et(()=>i)),onFailure:_c,onDone:ta}):(n.ref=Ut(),C(R0(u),Et(()=>i)))}),s=u=>{let l=n.ref,d=Ir(l,Tw(u,f=>f.length!==0));return n.ref=d,d},a=bd({onInput:u=>Et(cr(u),()=>a),onFailure:_c,onDone:u=>Kf(Jf(()=>{o.ref=!0}),ta(u))}),c=C(t,Lb,w2,Et(([u,l])=>C(Yu([o.ref,s(u)]),Et(([d,f])=>{let p=d&&xu(f)?rs:c;return C(cr(Dt(l)),Et(()=>p))}))));return C(_i(e),Vn(a),Vn(i),SD(c))});return new ns(r)}),EMe=(e,t)=>AMe(()=>{let r=n=>Sd(De(t(n),wt({onNone:()=>rs,onSome:([o,i])=>Et(cr(o),()=>r(i))})));return new ns(r(e))}),bMe=e=>C7(w7(e)),_7=e=>C7(R7(e))});var B7,CMe,wMe,kD,dy,IMe,kMe,vMe,RMe,_Me,_0,BMe,TMe,DMe,QMe,OMe,fy,wd=h(()=>{SMe();B7=eH,CMe=oMe,wMe=iMe,kD=aMe,dy=cMe,IMe=_i,kMe=uMe,vMe=lMe,RMe=dMe,_Me=k7,_0=tH,BMe=pMe,TMe=mMe,DMe=gMe,QMe=xMe,OMe=bMe,fy=_7});var T7,JOt,KOt,rH,PMe,py,D7,ZOt,Q7,NMe,XOt,eNt,tNt,rNt,nNt,oNt,iNt,MMe=h(()=>{mt();mm();oe();ir();ht();Me();ct();T7=Symbol.for("effect/BigDecimal"),JOt={[T7]:T7,[he](){let e=Q7(this);return C(ae(e.value),we(hu(e.scale)),We(this))},[me](e){return KOt(e)&&tNt(this,e)},toString(){return`BigDecimal(${rNt(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},KOt=e=>se(e,T7),rH=(e,t)=>{let r=Object.create(JOt);return r.value=e,r.scale=t,r},PMe=(e,t)=>{if(e!==py&&e%D7===py)throw new RangeError("Value must be normalized");let r=rH(e,t);return r.normalized=r,r},py=BigInt(0),D7=BigInt(10),ZOt=PMe(py,0),Q7=e=>{if(e.normalized===void 0)if(e.value===py)e.normalized=ZOt;else{let t=`${e.value}`,r=0;for(let i=t.length-1;i>=0&&t[i]==="0";i--)r++;r===0&&(e.normalized=e);let n=BigInt(t.substring(0,t.length-r)),o=e.scale-r;e.normalized=PMe(n,o)}return e.normalized},NMe=x(2,(e,t)=>t>e.scale?rH(e.value*D7**BigInt(t-e.scale),t):t<e.scale?rH(e.value/D7**BigInt(e.scale-t),t):e),XOt=e=>e.value<py?rH(-e.value,e.scale):e,eNt=Ml((e,t)=>e.scale>t.scale?NMe(t,e.scale).value===e.value:e.scale<t.scale?NMe(e,t.scale).value===t.value:e.value===t.value),tNt=x(2,(e,t)=>eNt(e,t)),rNt=e=>{let t=Q7(e);if(Math.abs(t.scale)>=16)return nNt(t);let r=t.value<py,n=r?`${t.value}`.substring(1):`${t.value}`,o,i;if(t.scale>=n.length)o="0",i="0".repeat(t.scale-n.length)+n;else{let a=n.length-t.scale;if(a>n.length){let c=a-n.length;o=`${n}${"0".repeat(c)}`,i=""}else i=n.slice(a),o=n.slice(0,a)}let s=i===""?o:`${o}.${i}`;return r?`-${s}`:s},nNt=e=>{if(oNt(e))return"0e+0";let t=Q7(e),r=`${XOt(t).value}`,n=r.slice(0,1),o=r.slice(1),i=`${iNt(t)?"-":""}${n}`;o!==""&&(i+=`.${o}`);let s=o.length-t.scale;return`${i}e${s>=0?"+":""}${s}`},oNt=e=>e.value===py,iNt=e=>e.value<py});var FMe=h(()=>{});var LMe=h(()=>{});var UMe,nH,O7,uNt,$Me,HMe,WMe=h(()=>{mt();oe();yn();ir();ht();Me();ct();UMe="effect/Redacted",nH=Te("effect/Redacted/redactedRegistry",()=>new WeakMap),O7=Symbol.for(UMe),uNt={[O7]:{_A:e=>e},pipe(){return Z(this,arguments)},toString(){return"<redacted>"},toJSON(){return"<redacted>"},[Ce](){return"<redacted>"},[he](){return C(ae(UMe),we(ae(nH.get(this))),We(this))},[me](e){return $Me(e)&&ce(nH.get(this),nH.get(e))}},$Me=e=>se(e,O7),HMe=e=>{let t=Object.create(uNt);return nH.set(t,e),t}});var jMe=h(()=>{});var qMe=h(()=>{});var GMe=h(()=>{});var Ku,my=h(()=>{Ku=class e extends Error{constructor(t=!1){super(),this.interruptExecution=t,this.footprint=e.SharedFootPrint}static isFailure(t){return t!=null&&t.footprint===e.SharedFootPrint}};Ku.SharedFootPrint=Symbol.for("fast-check/PreconditionFailure")});var zMe=h(()=>{my()});function VMe(){return vD.nil}function*YMe(e,t){for(let r of e)yield t(r)}function*JMe(e,t){for(let r of e)yield*t(r)}function*KMe(e,t){for(let r of e)t(r)&&(yield r)}function*ZMe(e,t){for(let r=0;r<t;++r){let n=e.next();if(n.done)break;yield n.value}}function*XMe(e,t){let r=e.next();for(;!r.done&&t(r.value);)yield r.value,r=e.next()}function*eFe(e,t){for(let r=e.next();!r.done;r=e.next())yield r.value;for(let r of t)for(let n=r.next();!n.done;n=r.next())yield n.value}var vD,tFe=h(()=>{vD=class{[Symbol.iterator](){return this}next(t){return{value:t,done:!0}}};vD.nil=new vD});function hy(e){return new Nr(e)}var mNt,Nr,kn=h(()=>{tFe();mNt=Symbol.iterator,Nr=class e{static nil(){return new e(VMe())}static of(...t){return new e(t[mNt]())}constructor(t){this.g=t}next(){return this.g.next()}[Symbol.iterator](){return this.g}map(t){return new e(YMe(this.g,t))}flatMap(t){return new e(JMe(this.g,t))}dropWhile(t){let r=!1;function*n(o){(r||!t(o))&&(r=!0,yield o)}return this.flatMap(n)}drop(t){if(t<=0)return this;let r=0;function n(){return r++<t}return this.dropWhile(n)}takeWhile(t){return new e(XMe(this.g,t))}take(t){return new e(ZMe(this.g,t))}filter(t){return new e(KMe(this.g,t))}every(t){for(let r of this.g)if(!t(r))return!1;return!0}has(t){for(let r of this.g)if(t(r))return[!0,r];return[!1,null]}join(...t){return new e(eFe(this.g,t))}getNthOrLast(t){let r=t,n=null;for(let o of this.g){if(r--===0)return o;n=o}return n}}});function gy(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&ao in e&&typeof e[ao]=="function"}var ao,ks=h(()=>{ao=Symbol.for("fast-check/cloneMethod")});var hNt,hr,vn=h(()=>{ks();hNt=Object.defineProperty,hr=class{constructor(t,r,n=void 0){this.value_=t,this.context=r,this.hasToBeCloned=n!==void 0||gy(t),this.readOnce=!1,this.hasToBeCloned?hNt(this,"value",{get:n!==void 0?n:this.getValue}):this.value=t}getValue(){return this.hasToBeCloned?this.readOnce?this.value_[ao]():(this.readOnce=!0,this.value_):this.value_}}});var rFe,on,N7,P7,M7,F7,L7,Ln=h(()=>{kn();ks();vn();rFe=Object.assign,on=class{filter(t){return new M7(this,t)}map(t,r){return new P7(this,t,r)}chain(t){return new N7(this,t)}noShrink(){return new F7(this)}noBias(){return new L7(this)}},N7=class extends on{constructor(t,r){super(),this.arb=t,this.chainer=r}generate(t,r){let n=t.clone(),o=this.arb.generate(t,r);return this.valueChainer(o,t,n,r)}canShrinkWithoutContext(t){return!1}shrink(t,r){return this.isSafeContext(r)?(r.stoppedForOriginal?Nr.nil():this.arb.shrink(r.originalValue,r.originalContext).map(n=>this.valueChainer(n,r.clonedMrng.clone(),r.clonedMrng,r.originalBias))).join(r.chainedArbitrary.shrink(t,r.chainedContext).map(n=>{let o=rFe(rFe({},r),{chainedContext:n.context,stoppedForOriginal:!0});return new hr(n.value_,o)})):Nr.nil()}valueChainer(t,r,n,o){let i=this.chainer(t.value_),s=i.generate(r,o),a={originalBias:o,originalValue:t.value_,originalContext:t.context,stoppedForOriginal:!1,chainedArbitrary:i,chainedContext:s.context,clonedMrng:n};return new hr(s.value_,a)}isSafeContext(t){return t!=null&&typeof t=="object"&&"originalBias"in t&&"originalValue"in t&&"originalContext"in t&&"stoppedForOriginal"in t&&"chainedArbitrary"in t&&"chainedContext"in t&&"clonedMrng"in t}},P7=class extends on{constructor(t,r,n){super(),this.arb=t,this.mapper=r,this.unmapper=n,this.bindValueMapper=o=>this.valueMapper(o)}generate(t,r){let n=this.arb.generate(t,r);return this.valueMapper(n)}canShrinkWithoutContext(t){if(this.unmapper!==void 0)try{let r=this.unmapper(t);return this.arb.canShrinkWithoutContext(r)}catch{return!1}return!1}shrink(t,r){if(this.isSafeContext(r))return this.arb.shrink(r.originalValue,r.originalContext).map(this.bindValueMapper);if(this.unmapper!==void 0){let n=this.unmapper(t);return this.arb.shrink(n,void 0).map(this.bindValueMapper)}return Nr.nil()}mapperWithCloneIfNeeded(t){let r=t.value,n=this.mapper(r);return t.hasToBeCloned&&(typeof n=="object"&&n!==null||typeof n=="function")&&Object.isExtensible(n)&&!gy(n)&&Object.defineProperty(n,ao,{get:()=>()=>this.mapperWithCloneIfNeeded(t)[0]}),[n,r]}valueMapper(t){let[r,n]=this.mapperWithCloneIfNeeded(t),o={originalValue:n,originalContext:t.context};return new hr(r,o)}isSafeContext(t){return t!=null&&typeof t=="object"&&"originalValue"in t&&"originalContext"in t}},M7=class extends on{constructor(t,r){super(),this.arb=t,this.refinement=r,this.bindRefinementOnValue=n=>this.refinementOnValue(n)}generate(t,r){for(;;){let n=this.arb.generate(t,r);if(this.refinementOnValue(n))return n}}canShrinkWithoutContext(t){return this.arb.canShrinkWithoutContext(t)&&this.refinement(t)}shrink(t,r){return this.arb.shrink(t,r).filter(this.bindRefinementOnValue)}refinementOnValue(t){return this.refinement(t.value)}},F7=class extends on{constructor(t){super(),this.arb=t}generate(t,r){return this.arb.generate(t,r)}canShrinkWithoutContext(t){return this.arb.canShrinkWithoutContext(t)}shrink(t,r){return Nr.nil()}noShrink(){return this}},L7=class extends on{constructor(t){super(),this.arb=t}generate(t,r){return this.arb.generate(t,void 0)}canShrinkWithoutContext(t){return this.arb.canShrinkWithoutContext(t)}shrink(t,r){return this.arb.shrink(t,r)}noBias(){return this}}});function gNt(e){try{return e.apply}catch{return}}function ANt(e,t,r){let n=e;n[U7]=nFe;let o=n[U7](t,r);return delete n[U7],o}function Zu(e,t,r){return gNt(e)===nFe?e.apply(t,r):ANt(e,t,r)}var nFe,U7,oFe=h(()=>{nFe=Function.prototype.apply,U7=Symbol("apply")});function yNt(e){try{return e.indexOf}catch{return}}function xNt(e){try{return e.join}catch{return}}function ENt(e){try{return e.map}catch{return}}function bNt(e){try{return e.filter}catch{return}}function SNt(e){try{return e.push}catch{return}}function B0(e,...t){return yNt(e)===iFe?e.indexOf(...t):Zu(iFe,e,t)}function Bi(e,...t){return xNt(e)===sFe?e.join(...t):Zu(sFe,e,t)}function Vo(e,t){return ENt(e)===aFe?e.map(t):Zu(aFe,e,[t])}function AFe(e,t){return bNt(e)===cFe?e.filter(t):Zu(cFe,e,[t])}function Un(e,...t){return SNt(e)===uFe?e.push(...t):Zu(uFe,e,t)}function CNt(e){try{return e.getTime}catch{return}}function wNt(e){try{return e.toISOString}catch{return}}function iH(e){return CNt(e)===lFe?e.getTime():Zu(lFe,e,[])}function yFe(e){return wNt(e)===dFe?e.toISOString():Zu(dFe,e,[])}function INt(e){try{return e.split}catch{return}}function kNt(e){try{return e.charCodeAt}catch{return}}function kd(e,...t){return INt(e)===fFe?e.split(...t):Zu(fFe,e,t)}function Ub(e,t){return kNt(e)===pFe?e.charCodeAt(t):Zu(pFe,e,[t])}function vNt(e){try{return e.toString}catch{return}}function sH(e,...t){return vNt(e)===mFe?e.toString(...t):Zu(mFe,e,t)}function $7(e){return Zu(RNt,e,[])}var hFe,co,Id,gFe,oH,rPr,iFe,sFe,aFe,cFe,uFe,nPr,oPr,iPr,sPr,aPr,lFe,dFe,cPr,uPr,lPr,dPr,fPr,pPr,fFe,mPr,hPr,gPr,APr,yPr,xPr,pFe,EPr,bPr,mFe,RNt,ge=h(()=>{oFe();hFe=typeof Array<"u"?Array:void 0,co=typeof Error<"u"?Error:void 0,Id=typeof String<"u"?String:void 0,gFe=typeof encodeURIComponent<"u"?encodeURIComponent:void 0,oH=Symbol,rPr=Array.prototype.forEach,iFe=Array.prototype.indexOf,sFe=Array.prototype.join,aFe=Array.prototype.map,cFe=Array.prototype.filter,uFe=Array.prototype.push,nPr=Array.prototype.pop,oPr=Array.prototype.splice,iPr=Array.prototype.slice,sPr=Array.prototype.sort,aPr=Array.prototype.every;lFe=Date.prototype.getTime,dFe=Date.prototype.toISOString;cPr=Set.prototype.add,uPr=Set.prototype.has,lPr=WeakMap.prototype.set,dPr=WeakMap.prototype.get,fPr=Map.prototype.set,pPr=Map.prototype.get,fFe=String.prototype.split,mPr=String.prototype.startsWith,hPr=String.prototype.endsWith,gPr=String.prototype.substring,APr=String.prototype.toLowerCase,yPr=String.prototype.toUpperCase,xPr=String.prototype.padStart,pFe=String.prototype.charCodeAt,EPr=String.prototype.normalize,bPr=String.prototype.replace;mFe=Number.prototype.toString;RNt=Object.prototype.toString});var T0=h(()=>{});var BPr,H7=h(()=>{kn();ks();Ln();vn();ge();T0();BPr=Array.isArray});var uo=h(()=>{H7()});function cH(e){return 2+~~(_Nt(e+1)*.4342944819032518)}var _Nt,W7=h(()=>{_Nt=Math.log});function Ay(){return BNt}var BNt,$b=h(()=>{BNt={}});function Wb(e){return e.context!==void 0?e:e.hasToBeCloned?new hr(e.value_,Hb,()=>e.value):new hr(e.value_,Hb)}var Hb,uH=h(()=>{vn();Hb=Symbol("UndefinedContextPlaceholder")});var lH,EFe=h(()=>{my();W7();$b();kn();uH();ge();lH=class e{constructor(t,r){this.arb=t,this.predicate=r;let{asyncBeforeEach:n,asyncAfterEach:o,beforeEach:i,afterEach:s}=Ay()||{};if(n!==void 0&&i!==void 0)throw co(`Global "asyncBeforeEach" and "beforeEach" parameters can't be set at the same time when running async properties`);if(o!==void 0&&s!==void 0)throw co(`Global "asyncAfterEach" and "afterEach" parameters can't be set at the same time when running async properties`);this.beforeEachHook=n||i||e.dummyHook,this.afterEachHook=o||s||e.dummyHook}isAsync(){return!0}generate(t,r){let n=this.arb.generate(t,r!=null?cH(r):void 0);return Wb(n)}shrink(t){if(t.context===void 0&&!this.arb.canShrinkWithoutContext(t.value_))return Nr.nil();let r=t.context!==Hb?t.context:void 0;return this.arb.shrink(t.value_,r).map(Wb)}async runBeforeEach(){await this.beforeEachHook()}async runAfterEach(){await this.afterEachHook()}async run(t,r){r||await this.beforeEachHook();try{let n=await this.predicate(t);return n==null||n===!0?null:{error:new co("Property failed by returning false"),errorMessage:"Error: Property failed by returning false"}}catch(n){return Ku.isFailure(n)?n:n instanceof co&&n.stack?{error:n,errorMessage:n.stack}:{error:n,errorMessage:Id(n)}}finally{r||await this.afterEachHook()}}beforeEach(t){let r=this.beforeEachHook;return this.beforeEachHook=()=>t(r),this}afterEach(t){let r=this.afterEachHook;return this.afterEachHook=()=>t(r),this}};lH.dummyHook=()=>{}});var j7=h(()=>{Ln();kn();uH()});var bFe=h(()=>{Ln();uo();EFe();j7();ge()});var RD,q7=h(()=>{my();W7();$b();kn();uH();ge();RD=class e{constructor(t,r){this.arb=t,this.predicate=r;let{beforeEach:n=e.dummyHook,afterEach:o=e.dummyHook,asyncBeforeEach:i,asyncAfterEach:s}=Ay()||{};if(i!==void 0)throw co(`"asyncBeforeEach" can't be set when running synchronous properties`);if(s!==void 0)throw co(`"asyncAfterEach" can't be set when running synchronous properties`);this.beforeEachHook=n,this.afterEachHook=o}isAsync(){return!1}generate(t,r){let n=this.arb.generate(t,r!=null?cH(r):void 0);return Wb(n)}shrink(t){if(t.context===void 0&&!this.arb.canShrinkWithoutContext(t.value_))return Nr.nil();let r=t.context!==Hb?t.context:void 0;return this.arb.shrink(t.value_,r).map(Wb)}runBeforeEach(){this.beforeEachHook()}runAfterEach(){this.afterEachHook()}run(t,r){r||this.beforeEachHook();try{let n=this.predicate(t);return n==null||n===!0?null:{error:new co("Property failed by returning false"),errorMessage:"Error: Property failed by returning false"}}catch(n){return Ku.isFailure(n)?n:n instanceof co&&n.stack?{error:n,errorMessage:n.stack}:{error:n,errorMessage:Id(n)}}finally{r||this.afterEachHook()}}beforeEach(t){let r=this.beforeEachHook;return this.beforeEachHook=()=>t(r),this}afterEach(t){let r=this.afterEachHook;return this.afterEachHook=()=>t(r),this}};RD.dummyHook=()=>{}});var SFe=h(()=>{Ln();uo();q7();j7();ge()});function G7(e,t){for(var r=[],n=0;n!=t;++n)r.push(e.unsafeNext());return r}function CFe(e,t){var r=e.clone(),n=G7(r,t);return[n,r]}function _D(e,t){for(var r=0;r!=t;++r)e.unsafeNext()}function z7(e,t){var r=e.clone();return _D(r,t),r}var wFe=h(()=>{});function FNt(e){var t=e.length===1;if(!t)throw new Error("The state must have been produced by a congruential32 RandomGenerator");return new IFe(e[0])}var ONt,NNt,PNt,MNt,V7,Y7,IFe,kFe,vFe=h(()=>{ONt=214013,NNt=2531011,PNt=4294967295,MNt=(1<<31)-1,V7=function(e){return e*ONt+NNt&PNt},Y7=function(e){return(e&MNt)>>16},IFe=function(){function e(t){this.seed=t}return e.prototype.clone=function(){return new e(this.seed)},e.prototype.next=function(){var t=new e(this.seed),r=t.unsafeNext();return[r,t]},e.prototype.unsafeNext=function(){var t=V7(this.seed),r=Y7(t),n=V7(t),o=Y7(n);this.seed=V7(n);var i=Y7(this.seed),s=i+(o+(r<<15)<<15);return s|0},e.prototype.getState=function(){return[this.seed]},e}();kFe=Object.assign(function(e){return new IFe(e)},{fromState:FNt})});function $Nt(e){return RFe.fromState(e)}var LNt,UNt,RFe,_Fe,BFe=h(()=>{LNt=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],s;try{for(;(t===void 0||t-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i},UNt=function(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))},RFe=function(){function e(t,r){this.states=t,this.index=r}return e.twist=function(t){for(var r=t.slice(),n=0;n!==e.N-e.M;++n){var o=(r[n]&e.MASK_UPPER)+(r[n+1]&e.MASK_LOWER);r[n]=r[n+e.M]^o>>>1^-(o&1)&e.A}for(var n=e.N-e.M;n!==e.N-1;++n){var i=(r[n]&e.MASK_UPPER)+(r[n+1]&e.MASK_LOWER);r[n]=r[n+e.M-e.N]^i>>>1^-(i&1)&e.A}var s=(r[e.N-1]&e.MASK_UPPER)+(r[0]&e.MASK_LOWER);return r[e.N-1]=r[e.M-1]^s>>>1^-(s&1)&e.A,r},e.seeded=function(t){var r=Array(e.N);r[0]=t;for(var n=1;n!==e.N;++n){var o=r[n-1]^r[n-1]>>>30;r[n]=Math.imul(e.F,o)+n|0}return r},e.from=function(t){return new e(e.twist(e.seeded(t)),0)},e.prototype.clone=function(){return new e(this.states,this.index)},e.prototype.next=function(){var t=new e(this.states,this.index),r=t.unsafeNext();return[r,t]},e.prototype.unsafeNext=function(){var t=this.states[this.index];return t^=this.states[this.index]>>>e.U,t^=t<<e.S&e.B,t^=t<<e.T&e.C,t^=t>>>e.L,++this.index>=e.N&&(this.states=e.twist(this.states),this.index=0),t},e.prototype.getState=function(){return UNt([this.index],LNt(this.states),!1)},e.fromState=function(t){var r=t.length===e.N+1&&t[0]>=0&&t[0]<e.N;if(!r)throw new Error("The state must have been produced by a mersenne RandomGenerator");return new e(t.slice(1),t[0])},e.N=624,e.M=397,e.R=31,e.A=2567483615,e.F=1812433253,e.U=11,e.S=7,e.B=2636928640,e.T=15,e.C=4022730752,e.L=18,e.MASK_LOWER=Math.pow(2,e.R)-1,e.MASK_UPPER=Math.pow(2,e.R),e}();_Fe=Object.assign(function(e){return RFe.from(e)},{fromState:$Nt})});function HNt(e){var t=e.length===4;if(!t)throw new Error("The state must have been produced by a xorshift128plus RandomGenerator");return new TFe(e[0],e[1],e[2],e[3])}var TFe,DFe,QFe=h(()=>{TFe=function(){function e(t,r,n,o){this.s01=t,this.s00=r,this.s11=n,this.s10=o}return e.prototype.clone=function(){return new e(this.s01,this.s00,this.s11,this.s10)},e.prototype.next=function(){var t=new e(this.s01,this.s00,this.s11,this.s10),r=t.unsafeNext();return[r,t]},e.prototype.unsafeNext=function(){var t=this.s00^this.s00<<23,r=this.s01^(this.s01<<23|this.s00>>>9),n=t^this.s10^(t>>>18|r<<14)^(this.s10>>>5|this.s11<<27),o=r^this.s11^r>>>18^this.s11>>>5,i=this.s00+this.s10|0;return this.s01=this.s11,this.s00=this.s10,this.s11=o,this.s10=n,i},e.prototype.jump=function(){var t=new e(this.s01,this.s00,this.s11,this.s10);return t.unsafeJump(),t},e.prototype.unsafeJump=function(){for(var t=0,r=0,n=0,o=0,i=[1667051007,2321340297,1548169110,304075285],s=0;s!==4;++s)for(var a=1;a;a<<=1)i[s]&a&&(t^=this.s01,r^=this.s00,n^=this.s11,o^=this.s10),this.unsafeNext();this.s01=t,this.s00=r,this.s11=n,this.s10=o},e.prototype.getState=function(){return[this.s01,this.s00,this.s11,this.s10]},e}();DFe=Object.assign(function(e){return new TFe(-1,~e,e|0,0)},{fromState:HNt})});function WNt(e){var t=e.length===4;if(!t)throw new Error("The state must have been produced by a xoroshiro128plus RandomGenerator");return new OFe(e[0],e[1],e[2],e[3])}var OFe,NFe,PFe=h(()=>{OFe=function(){function e(t,r,n,o){this.s01=t,this.s00=r,this.s11=n,this.s10=o}return e.prototype.clone=function(){return new e(this.s01,this.s00,this.s11,this.s10)},e.prototype.next=function(){var t=new e(this.s01,this.s00,this.s11,this.s10),r=t.unsafeNext();return[r,t]},e.prototype.unsafeNext=function(){var t=this.s00+this.s10|0,r=this.s10^this.s00,n=this.s11^this.s01,o=this.s00,i=this.s01;return this.s00=o<<24^i>>>8^r^r<<16,this.s01=i<<24^o>>>8^n^(n<<16|r>>>16),this.s10=n<<5^r>>>27,this.s11=r<<5^n>>>27,t},e.prototype.jump=function(){var t=new e(this.s01,this.s00,this.s11,this.s10);return t.unsafeJump(),t},e.prototype.unsafeJump=function(){for(var t=0,r=0,n=0,o=0,i=[3639956645,3750757012,1261568508,386426335],s=0;s!==4;++s)for(var a=1;a;a<<=1)i[s]&a&&(t^=this.s01,r^=this.s00,n^=this.s11,o^=this.s10),this.unsafeNext();this.s01=t,this.s00=r,this.s11=n,this.s10=o},e.prototype.getState=function(){return[this.s01,this.s00,this.s11,this.s10]},e}();NFe=Object.assign(function(e){return new OFe(-1,~e,e|0,0)},{fromState:WNt})});function J7(e,t){if(e.sign!==t.sign)return dH(e,{sign:-t.sign,data:t.data});for(var r=[],n=0,o=e.data,i=t.data,s=o.length-1,a=i.length-1;s>=0||a>=0;--s,--a){var c=s>=0?o[s]:0,u=a>=0?i[a]:0,l=c+u+n;r.push(l>>>0),n=~~(l/4294967296)}return n!==0&&r.push(n),{sign:e.sign,data:r.reverse()}}function MFe(e){e.sign=1;for(var t=e.data,r=t.length-1;r>=0;--r)if(t[r]===4294967295)t[r]=0;else return t[r]+=1,e;return t.unshift(1),e}function jNt(e,t){for(var r=Math.max(e.length,t.length),n=0;n<r;++n){var o=n+e.length-r,i=n+t.length-r,s=o>=0?e[o]:0,a=i>=0?t[i]:0;if(s<a)return!0;if(s>a)return!1}return!1}function dH(e,t){if(e.sign!==t.sign)return J7(e,{sign:-t.sign,data:t.data});var r=e.data,n=t.data;if(jNt(r,n)){var o=dH(t,e);return o.sign=-o.sign,o}for(var i=[],s=0,a=r.length-1,c=n.length-1;a>=0||c>=0;--a,--c){var u=a>=0?r[a]:0,l=c>=0?n[c]:0,d=u-l-s;i.push(d>>>0),s=d<0?1:0}return{sign:e.sign,data:i.reverse()}}function K7(e){for(var t=e.data,r=0;r!==t.length&&t[r]===0;++r);return r===t.length?(e.sign=1,e.data=[0],e):(t.splice(0,r),e)}function fH(e,t){if(t<0){var r=-t;e.sign=-1,e.data[0]=~~(r/4294967296),e.data[1]=r>>>0}else e.sign=1,e.data[0]=~~(t/4294967296),e.data[1]=t>>>0;return e}function FFe(e,t,r){var n=t.data[1],o=t.data[0],i=t.sign,s=r.data[1],a=r.data[0],c=r.sign;if(e.sign=1,i===1&&c===-1){var u=n+s,l=o+a+(u>4294967295?1:0);return e.data[0]=l>>>0,e.data[1]=u>>>0,e}var d=n,f=o,p=s,m=a;i===-1&&(d=s,f=a,p=n,m=o);var g=0,A=d-p;return A<0&&(g=1,A=A>>>0),e.data[0]=f-m-g,e.data[1]=A,e}var Z7=h(()=>{});function pH(e,t){for(var r=e>2?~~(4294967296/e)*e:4294967296,n=t.unsafeNext()+2147483648;n>=r;)n=t.unsafeNext()+2147483648;return n%e}var X7=h(()=>{});function mH(e,t,r){for(var n=t.length;;){for(var o=0;o!==n;++o){var i=o===0?t[0]+1:4294967296,s=pH(i,r);e[o]=s}for(var o=0;o!==n;++o){var a=e[o],c=t[o];if(a<c)return e;if(a>c)break}}}var eee=h(()=>{X7()});function jb(e,t,r){var n=K7(MFe(dH(t,e))),o=n.data.slice(0),i=mH(o,n.data,r);return K7(J7({sign:1,data:i},e))}var tee=h(()=>{Z7();eee()});function LFe(e,t,r){if(r!=null){var n=r.clone();return[jb(e,t,n),n]}return function(o){var i=o.clone();return[jb(e,t,i),i]}}var UFe=h(()=>{tee()});function qb(e,t,r){for(var n=t-e+BD(1),o=BD(-2147483648),i=BD(4294967296),s=i,a=1;s<n;)s*=i,++a;for(var c=s-s%n;;){for(var u=BD(0),l=0;l!==a;++l){var d=r.unsafeNext();u=i*u+(BD(d)-o)}if(u<c){var f=u%n;return f+e}}}var BD,ree=h(()=>{BD=typeof BigInt<"u"?BigInt:void 0});function $Fe(e,t,r){if(r!=null){var n=r.clone();return[qb(e,t,n),n]}return function(o){var i=o.clone();return[qb(e,t,i),i]}}var HFe=h(()=>{ree()});function VNt(e,t,r,n){var o=r<=qNt?fH(WFe,r):FFe(WFe,fH(GNt,t),fH(zNt,e));return o.data[1]===4294967295?(o.data[0]+=1,o.data[1]=0):o.data[1]+=1,mH(nee,o.data,n),nee[0]*4294967296+nee[1]+e}function xh(e,t,r){var n=t-e;if(n<=4294967295){var o=pH(n+1,r);return o+e}return VNt(e,t,n,r)}var qNt,GNt,zNt,WFe,nee,oee=h(()=>{X7();Z7();eee();qNt=Number.MAX_SAFE_INTEGER,GNt={sign:1,data:[0,0]},zNt={sign:1,data:[0,0]},WFe={sign:1,data:[0,0]},nee=[0,0]});function jFe(e,t,r){if(r!=null){var n=r.clone();return[xh(e,t,n),n]}return function(o){var i=o.clone();return[xh(e,t,i),i]}}var qFe=h(()=>{oee()});var iee={};tr(iee,{__commitHash:()=>KNt,__type:()=>YNt,__version:()=>JNt,congruential32:()=>kFe,generateN:()=>CFe,mersenne:()=>_Fe,skipN:()=>z7,uniformArrayIntDistribution:()=>LFe,uniformBigIntDistribution:()=>$Fe,uniformIntDistribution:()=>jFe,unsafeGenerateN:()=>G7,unsafeSkipN:()=>_D,unsafeUniformArrayIntDistribution:()=>jb,unsafeUniformBigIntDistribution:()=>qb,unsafeUniformIntDistribution:()=>xh,xoroshiro128plus:()=>NFe,xorshift128plus:()=>DFe});var YNt,JNt,KNt,see=h(()=>{wFe();vFe();BFe();QFe();PFe();UFe();HFe();qFe();tee();ree();oee();YNt="module",JNt="6.1.0",KNt="a413dd2b721516be2ef29adffb515c5ae67bfbad"});var D0,hH=h(()=>{see();see();D0=iee});var vs,TD=h(()=>{(function(e){e[e.None=0]="None",e[e.Verbose=1]="Verbose",e[e.VeryVerbose=2]="VeryVerbose"})(vs||(vs={}))});var ZNt,XNt,ePt,ra,aee=h(()=>{hH();TD();ZNt=Date.now,XNt=Math.min,ePt=Math.random,ra=class e{constructor(t){let r=t||{};this.seed=e.readSeed(r),this.randomType=e.readRandomType(r),this.numRuns=e.readNumRuns(r),this.verbose=e.readVerbose(r),this.maxSkipsPerRun=e.readOrDefault(r,"maxSkipsPerRun",100),this.timeout=e.safeTimeout(e.readOrDefault(r,"timeout",null)),this.skipAllAfterTimeLimit=e.safeTimeout(e.readOrDefault(r,"skipAllAfterTimeLimit",null)),this.interruptAfterTimeLimit=e.safeTimeout(e.readOrDefault(r,"interruptAfterTimeLimit",null)),this.markInterruptAsFailure=e.readBoolean(r,"markInterruptAsFailure"),this.skipEqualValues=e.readBoolean(r,"skipEqualValues"),this.ignoreEqualValues=e.readBoolean(r,"ignoreEqualValues"),this.logger=e.readOrDefault(r,"logger",n=>{console.log(n)}),this.path=e.readOrDefault(r,"path",""),this.unbiased=e.readBoolean(r,"unbiased"),this.examples=e.readOrDefault(r,"examples",[]),this.endOnFailure=e.readBoolean(r,"endOnFailure"),this.reporter=e.readOrDefault(r,"reporter",null),this.asyncReporter=e.readOrDefault(r,"asyncReporter",null),this.errorWithCause=e.readBoolean(r,"errorWithCause")}toParameters(){let t=n=>n!==null?n:void 0;return{seed:this.seed,randomType:this.randomType,numRuns:this.numRuns,maxSkipsPerRun:this.maxSkipsPerRun,timeout:t(this.timeout),skipAllAfterTimeLimit:t(this.skipAllAfterTimeLimit),interruptAfterTimeLimit:t(this.interruptAfterTimeLimit),markInterruptAsFailure:this.markInterruptAsFailure,skipEqualValues:this.skipEqualValues,ignoreEqualValues:this.ignoreEqualValues,path:this.path,logger:this.logger,unbiased:this.unbiased,verbose:this.verbose,examples:this.examples,endOnFailure:this.endOnFailure,reporter:t(this.reporter),asyncReporter:t(this.asyncReporter),errorWithCause:this.errorWithCause}}static read(t){return new e(t)}};ra.createQualifiedRandomGenerator=e=>t=>{let r=e(t);return r.unsafeJump===void 0&&(r.unsafeJump=()=>_D(r,42)),r};ra.readSeed=e=>{if(e.seed==null)return ZNt()^ePt()*4294967296;let t=e.seed|0;if(e.seed===t)return t;let r=e.seed-t;return t^r*4294967296};ra.readRandomType=e=>{if(e.randomType==null)return D0.xorshift128plus;if(typeof e.randomType=="string")switch(e.randomType){case"mersenne":return ra.createQualifiedRandomGenerator(D0.mersenne);case"congruential":case"congruential32":return ra.createQualifiedRandomGenerator(D0.congruential32);case"xorshift128plus":return D0.xorshift128plus;case"xoroshiro128plus":return D0.xoroshiro128plus;default:throw new Error(`Invalid random specified: '${e.randomType}'`)}let t=e.randomType(0);if("min"in t&&t.min!==-2147483648)throw new Error(`Invalid random number generator: min must equal -0x80000000, got ${String(t.min)}`);if("max"in t&&t.max!==2147483647)throw new Error(`Invalid random number generator: max must equal 0x7fffffff, got ${String(t.max)}`);return"unsafeJump"in t?e.randomType:ra.createQualifiedRandomGenerator(e.randomType)};ra.readNumRuns=e=>e.numRuns!=null?e.numRuns:e.num_runs!=null?e.num_runs:100;ra.readVerbose=e=>e.verbose==null?vs.None:typeof e.verbose=="boolean"?e.verbose===!0?vs.Verbose:vs.None:e.verbose<=vs.None?vs.None:e.verbose>=vs.VeryVerbose?vs.VeryVerbose:e.verbose|0;ra.readBoolean=(e,t)=>e[t]===!0;ra.readOrDefault=(e,t,r)=>{let n=e[t];return n??r};ra.safeTimeout=e=>e===null?null:XNt(e,2147483647)});var GFe=h(()=>{my()});var zFe=h(()=>{ge()});var cee=h(()=>{});function uee(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&yy in e&&typeof e[yy]=="function"}function lee(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&O0 in e&&typeof e[O0]=="function"}function sPt(e){if(e.description!==void 0)return e.description;let t=iPt.exec(Id(e));return t&&t[1].length?t[1]:null}function XFe(e){switch(e){case 0:return 1/e===ZFe?"-0":"0";case ZFe:return"Number.NEGATIVE_INFINITY";case oPt:return"Number.POSITIVE_INFINITY";default:return e===e?Id(e):"Number.NaN"}}function aPt(e){let t=-1;for(let r in e){let n=Number(r);if(n!==t+1)return!0;t=n}return t+1!==e.length}function Xu(e,t,r){let n=[...t,e];if(typeof e=="object"&&B0(t,e)!==-1)return"[cyclic]";if(lee(e)){let o=r(e);if(o.state==="fulfilled")return o.value}if(uee(e))try{return e[yy]()}catch{}switch($7(e)){case"[object Array]":{let o=e;if(o.length>=50&&aPt(o)){let s=[];for(let a in o)JFe(Number(a))||Un(s,`${a}:${Xu(o[a],n,r)}`);return s.length!==0?`Object.assign(Array(${o.length}),{${Bi(s,",")}})`:`Array(${o.length})`}let i=Bi(Vo(o,s=>Xu(s,n,r)),",");return o.length===0||o.length-1 in o?`[${i}]`:`[${i},]`}case"[object BigInt]":return`${e}n`;case"[object Boolean]":{let o=e==!0?"true":"false";return typeof e=="boolean"?o:`new Boolean(${o})`}case"[object Date]":{let o=e;return JFe(iH(o))?"new Date(NaN)":`new Date(${Q0(yFe(o))})`}case"[object Map]":return`new Map(${Xu(Array.from(e),n,r)})`;case"[object Null]":return"null";case"[object Number]":return typeof e=="number"?XFe(e):`new Number(${XFe(Number(e))})`;case"[object Object]":{try{let a=e.toString;if(typeof a=="function"&&a!==Object.prototype.toString)return e.toString()}catch{return"[object Object]"}let o=a=>`${a==="__proto__"?'["__proto__"]':typeof a=="symbol"?`[${Xu(a,n,r)}]`:Q0(a)}:${Xu(e[a],n,r)}`,i=[...Vo(tPt(e),o),...Vo(AFe(rPt(e),a=>{let c=nPt(e,a);return c&&c.enumerable}),o)],s="{"+Bi(i,",")+"}";return KFe(e)===null?s==="{}"?"Object.create(null)":`Object.assign(Object.create(null),${s})`:s}case"[object Set]":return`new Set(${Xu(Array.from(e),n,r)})`;case"[object String]":return typeof e=="string"?Q0(e):`new String(${Q0(e)})`;case"[object Symbol]":{let o=e;if(oH.keyFor(o)!==void 0)return`Symbol.for(${Q0(oH.keyFor(o))})`;let i=sPt(o);if(i===null)return"Symbol()";let s=i.startsWith("Symbol.")&&oH[i.substring(7)];return o===s?i:`Symbol(${Q0(i)})`}case"[object Promise]":{let o=r(e);switch(o.state){case"fulfilled":return`Promise.resolve(${Xu(o.value,n,r)})`;case"rejected":return`Promise.reject(${Xu(o.value,n,r)})`;case"pending":return"new Promise(() => {/*pending*/})";case"unknown":default:return"new Promise(() => {/*unknown*/})"}}case"[object Error]":if(e instanceof Error)return`new Error(${Xu(e.message,n,r)})`;break;case"[object Undefined]":return"undefined";case"[object Int8Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Int16Array]":case"[object Uint16Array]":case"[object Int32Array]":case"[object Uint32Array]":case"[object Float32Array]":case"[object Float64Array]":case"[object BigInt64Array]":case"[object BigUint64Array]":{if(typeof YFe=="function"&&YFe(e))return`Buffer.from(${Xu(VFe(e.values()),n,r)})`;let o=KFe(e),i=o&&o.constructor&&o.constructor.name;if(typeof i=="string"){let a=e.values();return`${i}.from(${Xu(VFe(a),n,r)})`}break}}try{return e.toString()}catch{return $7(e)}}function Bc(e){return Xu(e,[],()=>({state:"unknown",value:void 0}))}var VFe,YFe,Q0,JFe,tPt,rPt,nPt,KFe,ZFe,oPt,yy,O0,iPt,Tc=h(()=>{ge();VFe=Array.from,YFe=typeof Buffer<"u"?Buffer.isBuffer:void 0,Q0=JSON.stringify,JFe=Number.isNaN,tPt=Object.keys,rPt=Object.getOwnPropertySymbols,nPt=Object.getOwnPropertyDescriptor,KFe=Object.getPrototypeOf,ZFe=Number.NEGATIVE_INFINITY,oPt=Number.POSITIVE_INFINITY,yy=Symbol.for("fast-check/toStringMethod");O0=Symbol.for("fast-check/asyncToStringMethod");iPt=/^Symbol\((.*)\)$/});var eLe=h(()=>{Tc();my()});var yFr,tLe=h(()=>{GFe();zFe();cee();eLe();yFr=Date.now});var Eh,AH=h(()=>{(function(e){e[e.Success=0]="Success",e[e.Skipped=-1]="Skipped",e[e.Failure=1]="Failure"})(Eh||(Eh={}))});var yH,rLe=h(()=>{TD();AH();ge();yH=class e{constructor(t,r){this.verbosity=t,this.interruptedAsFailure=r,this.isSuccess=()=>this.pathToFailure==null,this.firstFailure=()=>this.pathToFailure?+kd(this.pathToFailure,":")[0]:-1,this.numShrinks=()=>this.pathToFailure?kd(this.pathToFailure,":").length-1:0,this.rootExecutionTrees=[],this.currentLevelExecutionTrees=this.rootExecutionTrees,this.failure=null,this.numSkips=0,this.numSuccesses=0,this.interrupted=!1}appendExecutionTree(t,r){let n={status:t,value:r,children:[]};return this.currentLevelExecutionTrees.push(n),n}fail(t,r,n){if(this.verbosity>=vs.Verbose){let o=this.appendExecutionTree(Eh.Failure,t);this.currentLevelExecutionTrees=o.children}this.pathToFailure==null?this.pathToFailure=`${r}`:this.pathToFailure+=`:${r}`,this.value=t,this.failure=n}skip(t){this.verbosity>=vs.VeryVerbose&&this.appendExecutionTree(Eh.Skipped,t),this.pathToFailure==null&&++this.numSkips}success(t){this.verbosity>=vs.VeryVerbose&&this.appendExecutionTree(Eh.Success,t),this.pathToFailure==null&&++this.numSuccesses}interrupt(){this.interrupted=!0}extractFailures(){if(this.isSuccess())return[];let t=[],r=this.rootExecutionTrees;for(;r.length>0&&r[r.length-1].status===Eh.Failure;){let n=r[r.length-1];t.push(n.value),r=n.children}return t}toRunDetails(t,r,n,o){if(!this.isSuccess())return{failed:!0,interrupted:this.interrupted,numRuns:this.firstFailure()+1-this.numSkips,numSkips:this.numSkips,numShrinks:this.numShrinks(),seed:t,counterexample:this.value,counterexamplePath:e.mergePaths(r,this.pathToFailure),error:this.failure.errorMessage,errorInstance:this.failure.error,failures:this.extractFailures(),executionSummary:this.rootExecutionTrees,verbose:this.verbosity,runConfiguration:o.toParameters()};let i=this.interruptedAsFailure||this.numSuccesses===0;return{failed:this.numSkips>n||this.interrupted&&i,interrupted:this.interrupted,numRuns:this.numSuccesses,numSkips:this.numSkips,numShrinks:0,seed:t,counterexample:null,counterexamplePath:null,error:null,errorInstance:null,failures:[],executionSummary:this.rootExecutionTrees,verbose:this.verbosity,runConfiguration:o.toParameters()}}};yH.mergePaths=(e,t)=>{if(e.length===0)return t;let r=e.split(":"),n=t.split(":"),o=+r[r.length-1]+ +n[0];return[...r.slice(0,r.length-1),`${o}`,...n.slice(1)].join(":")}});var nLe=h(()=>{my();rLe()});var oLe=h(()=>{});var xy,dee=h(()=>{hH();xy=class e{constructor(t){this.internalRng=t.clone()}clone(){return new e(this.internalRng)}next(t){return xh(0,(1<<t)-1,this.internalRng)}nextBoolean(){return xh(0,1,this.internalRng)==1}nextInt(t,r){return xh(t??e.MIN_INT,r??e.MAX_INT,this.internalRng)}nextBigInt(t,r){return qb(t,r,this.internalRng)}nextArrayInt(t,r){return jb(t,r,this.internalRng)}nextDouble(){let t=this.next(26),r=this.next(27);return(t*e.DBL_FACTOR+r)*e.DBL_DIVISOR}getState(){if("getState"in this.internalRng&&typeof this.internalRng.getState=="function")return this.internalRng.getState()}};xy.MIN_INT=-2147483648;xy.MAX_INT=2147483647;xy.DBL_FACTOR=Math.pow(2,27);xy.DBL_DIVISOR=Math.pow(2,-53)});var fee=h(()=>{hH();dee();vn();ge()});var pee=h(()=>{});var mee=h(()=>{ge();Tc();TD();AH()});var iLe=h(()=>{kn();$b();aee();tLe();nLe();oLe();fee();pee();mee()});var sLe=h(()=>{kn();q7();cee();$b();aee();fee();pee()});var aLe=h(()=>{vn();ks();ge();Tc()});var xLr,cLe=h(()=>{ge();xLr=Array.isArray});var uLe=h(()=>{Ln();kn();ge();aLe();cLe();H7()});var lLe=h(()=>{uLe()});function fLe(e){return fPt(dLe(e)/dLe(2))}function hee(e,t,r){if(e===t)return[{min:e,max:t}];if(e<0&&t>0){let s=r(-e),a=r(t);return[{min:-s,max:a},{min:t-a,max:t},{min:e,max:e+s}]}let n=r(t-e),o={min:e,max:e+n},i={min:t-n,max:t};return e<0?[i,o]:[o,i]}var fPt,dLe,gee=h(()=>{ge();fPt=Math.floor,dLe=Math.log});function pLe(e){return mPt(e/2)}function mLe(e){return pPt(e/2)}function Aee(e,t,r){let n=e-t;function*o(){let s=r?void 0:t,a=r?n:pLe(n);for(let c=a;c>0;c=pLe(c)){let u=c===n?t:e-c;yield new hr(u,s),s=u}}function*i(){let s=r?void 0:t,a=r?n:mLe(n);for(let c=a;c<0;c=mLe(c)){let u=c===n?t:e-c;yield new hr(u,s),s=u}}return n>0?hy(o()):hy(i())}var pPt,mPt,hLe=h(()=>{vn();kn();pPt=Math.ceil,mPt=Math.floor});var gLe,hPt,gPt,Ey,N0=h(()=>{Ln();vn();kn();gee();hLe();gLe=Math.sign,hPt=Number.isInteger,gPt=Object.is,Ey=class e extends on{constructor(t,r){super(),this.min=t,this.max=r}generate(t,r){let n=this.computeGenerateRange(t,r);return new hr(t.nextInt(n.min,n.max),void 0)}canShrinkWithoutContext(t){return typeof t=="number"&&hPt(t)&&!gPt(t,-0)&&this.min<=t&&t<=this.max}shrink(t,r){if(!e.isValidContext(t,r)){let n=this.defaultTarget();return Aee(t,n,!0)}return this.isLastChanceTry(t,r)?Nr.of(new hr(r,void 0)):Aee(t,r,!1)}defaultTarget(){return this.min<=0&&this.max>=0?0:this.min<0?this.max:this.min}computeGenerateRange(t,r){if(r===void 0||t.nextInt(1,r)!==1)return{min:this.min,max:this.max};let n=hee(this.min,this.max,fLe);if(n.length===1)return n[0];let o=t.nextInt(-2*(n.length-1),n.length-2);return o<0?n[0]:n[o+1]}isLastChanceTry(t,r){return t>0?t===r+1&&t>this.min:t<0?t===r-1&&t<this.max:!1}static isValidContext(t,r){if(r===void 0)return!1;if(typeof r!="number")throw new Error("Invalid context type passed to IntegerArbitrary (#1)");if(r!==0&&gLe(t)!==gLe(r))throw new Error("Invalid context value passed to IntegerArbitrary (#2)");return!0}}});function APt(e){let t=e.min!==void 0?e.min:-2147483648,r=e.max!==void 0?e.max:2147483647;return{min:t,max:r}}function Jo(e={}){let t=APt(e);if(t.min>t.max)throw new Error("fc.integer maximum value should be equal or greater than the minimum one");if(!ALe(t.min))throw new Error("fc.integer minimum value should be an integer");if(!ALe(t.max))throw new Error("fc.integer maximum value should be an integer");return new Ey(t.min,t.max)}var ALe,Ko=h(()=>{N0();ALe=Number.isInteger});var QD=h(()=>{ge()});var yLe=h(()=>{});var xLe=h(()=>{vn();ge()});var ELe=h(()=>{yLe();xLe()});var h1r,yee=h(()=>{kn();ks();Ko();T0();Ln();vn();QD();ELe();ge();h1r=Array.isArray});var tl=h(()=>{$b();ge()});var Zo=h(()=>{yee();tl()});var SLe=h(()=>{kn();vn();ge()});var OD=h(()=>{kn();Ln();vn();gee();SLe();ge()});var ND=h(()=>{ge();OD()});var CLe=h(()=>{ge();OD()});var wLe=h(()=>{ge();OD()});var bee=h(()=>{ge();OD()});var See=h(()=>{});var M0=h(()=>{Ko();See()});var wee=h(()=>{kn();Ln();vn();ks();ge()});var F0=h(()=>{wee()});var ILe=h(()=>{ge();F0()});function vLe(e){if(typeof e!="string")throw new Error("Cannot unmap non-string");if(e.length===0||e.length>2)throw new Error("Cannot unmap string with more or less than one character");let t=Ub(e,0);if(e.length===1)return t;let r=Ub(e,1);if(t<55296||t>56319||r<56320||r>57343)throw new Error("Cannot unmap invalid surrogate pairs");return e.codePointAt(0)}var kLe,RLe=h(()=>{ge();kLe=String.fromCodePoint});function bh(e,t,r,n){return Jo({min:e,max:t}).map(o=>kLe(r(o)),o=>n(vLe(o)))}var by=h(()=>{Ko();RLe()});function PD(e){return e<95?e+32:e<=126?e-95:e}function MD(e){return e>=32&&e<=126?e-32:e>=0&&e<=31?e+95:e}var FD=h(()=>{});var Iee=h(()=>{by();FD()});var kee=h(()=>{by()});function _Le(e){return e}function vee(){return bh(32,126,_Le,_Le)}var Ree=h(()=>{by()});var _ee=h(()=>{by();FD()});function bPt(e){return e<55296?PD(e):e+Bee}function SPt(e){return e<55296?MD(e):e<=57343?-1:e-Bee}function bH(){return bh(0,1114111-Bee,bPt,SPt)}var Bee,SH=h(()=>{by();FD();Bee=2048});var Tee=h(()=>{by()});var Dee=h(()=>{by();FD()});var rl=h(()=>{wee()});var BLe,TLe=h(()=>{ks();rl();BLe=class e{constructor(){this.receivedLogs=[]}log(t){this.receivedLogs.push(t)}size(){return this.receivedLogs.length}toString(){return JSON.stringify({logs:this.receivedLogs})}[ao](){return new e}}});var $Ur,HUr,DLe=h(()=>{ge();$Ur=Number.NaN,HUr=Number.isNaN});var KUr,Qee=h(()=>{ge();Ko();DLe();KUr=Number.isNaN});var o$r,QLe=h(()=>{Ln();vn();ks();kn();ge();o$r=Array.isArray});var OLe=h(()=>{QLe()});var NLe=h(()=>{ge()});var f$r,MLe=h(()=>{ge();f$r=Number.isNaN});var FLe=h(()=>{ge()});var LLe=h(()=>{ge()});var LD=h(()=>{yee();tl();NLe();MLe();FLe();LLe()});var ULe=h(()=>{ge()});var wH=h(()=>{uo();LD();ULe();rl();M0()});var G$r,z$r,V$r,Nee=h(()=>{kn();Ln();vn();QD();tl();ge();G$r=Number.POSITIVE_INFINITY,z$r=Number.MAX_SAFE_INTEGER,V$r=Number.isInteger});var nl=h(()=>{Ln();ge();Nee()});var r2r,L0=h(()=>{N0();r2r=Number.isInteger});var $Le=h(()=>{ge()});var kH=h(()=>{L0();$Le();ge()});function kPt(e){let t=gFe(e);return e!==t?t:`%${sH(Ub(e,0),16)}`}function vPt(e){if(typeof e!="string")throw new Error("Unsupported");return decodeURIComponent(e)}var g2r,A2r,U0=h(()=>{SH();nl();kH();ge();g2r=String.fromCharCode;A2r=bH().map(kPt,vPt)});var $0=h(()=>{rl();Nee();ge()});var Pee=h(()=>{ge()});var vH=h(()=>{tl();ge();Pee()});var Sh=h(()=>{ge();vH();tl();Pee()});var jLe=h(()=>{});var L2r,qLe=h(()=>{ge();L2r=String.fromCodePoint});var GLe=h(()=>{ge();kH();jLe();qLe()});var Ch=h(()=>{Zo();Sh();GLe();vH()});var zLe=h(()=>{});var lHr,Mee=h(()=>{Ln();vn();kn();lHr=Symbol("adapted-value")});var _H=h(()=>{Zo();U0();$0();Ch();uo();zLe();tl();Mee();ge()});var JLe=h(()=>{Zo();U0();_H();Ch();uo();Mee();ge()});var BH=h(()=>{});var ZLe=h(()=>{kn();Ln();vn();BH()});var qHr,GHr,zHr,XLe,VHr,e1e=h(()=>{BH();qHr=Number.NEGATIVE_INFINITY,GHr=Number.POSITIVE_INFINITY,zHr=Number.EPSILON,XLe=new Float64Array(1),VHr=new Uint32Array(XLe.buffer,XLe.byteOffset)});var JHr,KHr,ZHr,Fee=h(()=>{JHr=Number.isInteger,KHr=Number.NEGATIVE_INFINITY,ZHr=Number.POSITIVE_INFINITY});var tWr,rWr,nWr,t1e=h(()=>{Fee();tWr=Number.NEGATIVE_INFINITY,rWr=Number.POSITIVE_INFINITY,nWr=Number.MAX_VALUE});var hWr,gWr,AWr,yWr,xWr,EWr,UD=h(()=>{BH();ZLe();e1e();t1e();hWr=Number.isInteger,gWr=Number.isNaN,AWr=Number.NEGATIVE_INFINITY,yWr=Number.POSITIVE_INFINITY,xWr=Number.MAX_VALUE,EWr=Number.NaN});var SWr,CWr,wWr,n1e,IWr,r1e,kWr,Lee=h(()=>{SWr=Number.NEGATIVE_INFINITY,CWr=Number.POSITIVE_INFINITY,wWr=2**-126*2**-23,n1e=2**127*(1+(2**23-1)/2**23),IWr=2**-23,r1e=new Float32Array(1),kWr=new Uint32Array(r1e.buffer,r1e.byteOffset)});var BWr,TWr,o1e=h(()=>{Lee();Fee();BWr=Number.NEGATIVE_INFINITY,TWr=Number.POSITIVE_INFINITY});var $Wr,HWr,WWr,jWr,qWr,Uee=h(()=>{Ko();Lee();o1e();$Wr=Number.isInteger,HWr=Number.isNaN,WWr=Number.NEGATIVE_INFINITY,jWr=Number.POSITIVE_INFINITY,qWr=Number.NaN});function i1e(e){return e.replace(/([$`\\])/g,"\\$1").replace(/\r/g,"\\r")}var TH=h(()=>{});var DH=h(()=>{ge()});var QH=h(()=>{});var $ee=h(()=>{TH();ks();DH();Tc();Ko();QH();uo();ge()});var c1e=h(()=>{$ee()});var u1e=h(()=>{$ee()});var d1e=h(()=>{DH();Tc();ks();Zo();Ko();QH();uo();TH();ge()});var bjr,Sjr,Hee=h(()=>{N0();bjr=Number.MIN_SAFE_INTEGER,Sjr=Number.MAX_SAFE_INTEGER});var Ijr,f1e=h(()=>{N0();Ijr=Number.MAX_SAFE_INTEGER});var Rjr,Wee=h(()=>{ge();Rjr=Number.parseInt});var OH=h(()=>{ge();L0();uo();Wee()});var p1e=h(()=>{F0();L0();uo();Wee()});var jee=h(()=>{ge();nl();uo();p1e()});var H0=h(()=>{ge()});var qee=h(()=>{Zo();Tee();H0();Sh()});var m1e=h(()=>{ge()});var Gee=h(()=>{Zo();nl();qee();uo();OH();m1e()});var g1e=h(()=>{Ln()});var zee=h(()=>{g1e();ge()});var A1e=h(()=>{ge()});var y1e=h(()=>{Zo();rl();nl();A1e()});var x1e=h(()=>{ge()});var E1e=h(()=>{ge()});var b1e=h(()=>{bee();Ln();vn();T0();E1e();ge();ge()});var S1e=h(()=>{ge();b1e()});var Vee=h(()=>{Uee();Zo();ge()});var Jee=h(()=>{UD();Zo();ge()});var rp=h(()=>{Zo()});var Kee=h(()=>{ge();Ko();rp()});var Zee=h(()=>{ge();Ko();rp()});var Xee=h(()=>{ge();Ko();rp()});var ete=h(()=>{ge();Ko();rp()});var tte=h(()=>{ge();Ko();rp()});var rte=h(()=>{ge();Ko();rp()});var nte=h(()=>{ge();Ko();rp()});var C1e=h(()=>{Ln();vn()});var ote=h(()=>{Ko();C1e()});var hzr,ite=h(()=>{ge();uo();LD();ote();tl();hzr=hFe.isArray});var w1e=h(()=>{});var I1e=h(()=>{});var ate=h(()=>{Tc();Zo();nl();uo();ND();Qee();Vee();Jee();Kee();Zee();Xee();ete();tte();rte();nte();ite();w1e();I1e();zee();LD();QD();wH()});var MH=h(()=>{Zo();SH();H0();Sh()});var v1e=h(()=>{ge()});var R1e=h(()=>{v1e()});var cte=h(()=>{M0();rl();UD();MH();Hee();nl();Ch();R1e()});var B1e=h(()=>{wH();ate();cte()});var ute=h(()=>{M0();rl();UD()});var FH=h(()=>{ate();cte()});var lte=h(()=>{Ch();ute();FH();MH()});var D1e=h(()=>{lte()});var dte=h(()=>{Zo();Dee();H0();Sh()});var fte=h(()=>{dte();ute();FH()});var Q1e=h(()=>{fte()});var O1e=h(()=>{});var N1e=h(()=>{ge()});var r4r,P1e=h(()=>{ge();M0();rl();$0();uo();O1e();N1e();r4r=Symbol("no-key")});var M1e=h(()=>{P1e()});var F1e=h(()=>{Ln();vn();ks();kn();ge();Tc()});var L1e=h(()=>{F1e()});var U1e=h(()=>{Zo();Iee();H0();Sh()});var $1e=h(()=>{ge()});var H1e=h(()=>{Zo();kee();tl();H0();$1e();Sh()});var W1e=h(()=>{ge()});var j1e=h(()=>{Zo();_ee();W1e();Sh()});var pte=h(()=>{Zo();vH();Sh()});var q1e=h(()=>{ge()});var rYr,mte=h(()=>{Ln();vn();T0();kn();ge();q1e();N0();rYr=Array.isArray});var G1e=h(()=>{mte()});var z1e=h(()=>{mte()});function wMt(e){return e<10?Id(e):CMt[e]}function V1e(e,t){let r="";for(;e.length+r.length<t;)r+="0";return r+e}function Y1e(e){let t="";for(let r=e;r!==0;){let n=r>>5,o=r-(n<<5);t=wMt(o)+t,r=n}return t}function IMt(e,t){let r=~~(e/1073741824),n=e&1073741823;return V1e(Y1e(r),t-6)+V1e(Y1e(n),6)}function hte(e){return function(r){return IMt(r,e)}}var CMt,J1e=h(()=>{ge();CMt={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F",16:"G",17:"H",18:"J",19:"K",20:"M",21:"N",22:"P",23:"Q",24:"R",25:"S",26:"T",27:"V",28:"W",29:"X",30:"Y",31:"Z"}});var mYr,hYr,K1e=h(()=>{uo();Ko();J1e();mYr=hte(10),hYr=hte(8)});var Z1e=h(()=>{ge()});var gte=h(()=>{Ko();Z1e()});var Ate=h(()=>{ge()});var X1e=h(()=>{ge()});var eUe=h(()=>{uo();gte();Ate();ge();X1e()});var tUe=h(()=>{uo();gte();Ate()});var yte=h(()=>{U0();rl();_H();OH();jee();Gee();L0();nl();$0();Ch();uo()});var xte=h(()=>{U0();Ch()});var Ete=h(()=>{xte()});var bte=h(()=>{U0();Ch()});var nUe=h(()=>{ge()});var oUe=h(()=>{bte();Zo();nUe();nl()});var Ste=h(()=>{tl();oUe()});var Cte=h(()=>{xte()});var iUe=h(()=>{});var sUe=h(()=>{F0();rl();$0();uo();Cte();Ete();yte();iUe();tl();Ste()});var wte,aUe=h(()=>{ks();wte=class e{constructor(t,r){this.commands=t,this.metadataForReplay=r}[Symbol.iterator](){return this.commands[Symbol.iterator]()}[ao](){return new e(this.commands.map(t=>t.clone()),this.metadataForReplay)}toString(){let t=this.commands.filter(n=>n.hasRan).map(n=>n.toString()).join(","),r=this.metadataForReplay();return r.length!==0?`${t} /*${r}*/`:t}}});var cUe=h(()=>{Tc();ks()});var uUe=h(()=>{});var lUe=h(()=>{Ln();vn();aUe();cUe();uUe();T0();kn();nl();ote()});var dUe=h(()=>{lUe();tl()});var fUe=h(()=>{});var pUe=h(()=>{fUe()});var LH,UH,Ite=h(()=>{TH();ks();Tc();LH=e=>e(),UH=class e{constructor(t,r){this.act=t,this.taskSelector=r,this.lastTaskId=0,this.sourceTaskSelector=r.clone(),this.scheduledTasks=[],this.triggeredTasks=[],this.scheduledWatchers=[]}static buildLog(t){return`[task\${${t.taskId}}] ${t.label.length!==0?`${t.schedulingType}::${t.label}`:t.schedulingType} ${t.status}${t.outputValue!==void 0?` with value ${i1e(t.outputValue)}`:""}`}log(t,r,n,o,i,s){this.triggeredTasks.push({status:i,schedulingType:t,taskId:r,label:n,metadata:o,outputValue:s!==void 0?Bc(s):void 0})}scheduleInternal(t,r,n,o,i,s){let a=null,c=++this.lastTaskId,u=new Promise((l,d)=>{a=()=>{(s?n.then(()=>s()):n).then(f=>(this.log(t,c,r,o,"resolved",f),l(f)),f=>(this.log(t,c,r,o,"rejected",f),d(f)))}});return this.scheduledTasks.push({original:n,scheduled:u,trigger:a,schedulingType:t,taskId:c,label:r,metadata:o,customAct:i}),this.scheduledWatchers.length!==0&&this.scheduledWatchers[0](),u}schedule(t,r,n,o){return this.scheduleInternal("promise",r||"",t,n,o||LH)}scheduleFunction(t,r){return(...n)=>this.scheduleInternal("function",`${t.name}(${n.map(Bc).join(",")})`,t(...n),void 0,r||LH)}scheduleSequence(t,r){let n={done:!1,faulty:!1},o={then:a=>a()},i=()=>{},s=new Promise(a=>i=a);return t.reduce((a,c)=>{let[u,l,d]=typeof c=="function"?[c,c.name,void 0]:[c.builder,c.label,c.metadata];return a.then(()=>{let f=this.scheduleInternal("sequence",l,o,d,r||LH,()=>u());return f.catch(()=>{n.faulty=!0,i()}),f})},o).then(()=>{n.done=!0,i()},()=>{}),Object.assign(n,{task:Promise.resolve(s).then(()=>({done:n.done,faulty:n.faulty}))})}count(){return this.scheduledTasks.length}internalWaitOne(){if(this.scheduledTasks.length===0)throw new Error("No task scheduled");let t=this.taskSelector.nextTaskIndex(this.scheduledTasks),[r]=this.scheduledTasks.splice(t,1);return r.customAct(async()=>{r.trigger();try{await r.scheduled}catch{}})}async waitOne(t){let r=t||LH;await this.act(()=>r(async()=>await this.internalWaitOne()))}async waitAll(t){for(;this.scheduledTasks.length>0;)await this.waitOne(t)}async waitFor(t,r){let n=!1,o=null,i=async()=>{for(;!n&&this.scheduledTasks.length>0;)await this.waitOne(r);o=null},s=()=>{o===null&&(o=Promise.resolve().then(i))},a=()=>{let u=this.scheduledWatchers.indexOf(s);u!==-1&&this.scheduledWatchers.splice(u,1),u===0&&this.scheduledWatchers.length!==0&&this.scheduledWatchers[0]()},c=t.then(u=>(n=!0,o===null?(a(),u):o.then(()=>(a(),u))),u=>{if(n=!0,o===null)throw a(),u;return o.then(()=>{throw a(),u})});return this.scheduledTasks.length>0&&this.scheduledWatchers.length===0&&s(),this.scheduledWatchers.push(s),c}report(){return[...this.triggeredTasks,...this.scheduledTasks.map(t=>({status:"pending",schedulingType:t.schedulingType,taskId:t.taskId,label:t.label,metadata:t.metadata}))]}toString(){return"schedulerFor()`\n"+this.report().map(e.buildLog).map(t=>`-> ${t}`).join(`
63
63
  `)+"`"}[ao](){return new e(this.act,this.sourceTaskSelector)}}});var mUe=h(()=>{Ite()});var hUe=h(()=>{Ln();vn();kn();Ite()});var gUe=h(()=>{mUe();hUe()});var AUe=h(()=>{ge();ND();rp()});var yUe=h(()=>{ge();ND();rp()});var xUe=h(()=>{Tc()});var kte,EUe=h(()=>{(function(e){e[e.Full=0]="Full",e[e.Character=1]="Character"})(kte||(kte={}))});var L6r,bUe=h(()=>{ge();EUe();L6r=String.fromCodePoint});var e3r,t3r,r3r,n3r,FMt,LMt,o3r,i3r,SUe=h(()=>{ge();Tc();xUe();bUe();Ree();rl();F0();Ko();nl();pte();uo();e3r=String.fromCodePoint,t3r=[..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"],r3r=[..."0123456789"],n3r=[...` \r
64
64
  \v\f`],FMt=[...`\r
65
65
  `],LMt=[...""],o3r=[...FMt,...LMt],i3r=vee()});var CUe=h(()=>{});var wUe=h(()=>{Ln();vn();kn();CUe()});var IUe=h(()=>{wUe()});var vte=h(()=>{zMe();bFe();SFe();iLe();sLe();lLe();Zo();ND();CLe();wLe();bee();M0();ILe();Iee();kee();Ree();_ee();SH();Tee();Dee();rl();F0();TLe();Qee();OLe();wH();JLe();UD();Uee();c1e();u1e();d1e();_H();Ko();Hee();f1e();L0();OH();jee();Gee();zee();y1e();kH();x1e();S1e();B1e();D1e();FH();fte();lte();Q1e();nl();$0();M1e();LD();L1e();U1e();H1e();MH();qee();Ch();j1e();pte();dte();G1e();z1e();uo();K1e();eUe();tUe();yte();Ete();Ste();Cte();bte();sUe();dUe();pUe();dee();$b();TD();AH();ks();kn();DH();Tc();gUe();mee();my();Xee();Kee();Zee();rte();nte();ete();tte();Vee();Jee();ite();Ln();vn();QD();AUe();yUe();SUe();QH();See();IUe()});var kUe=h(()=>{vte();vte()});var vUe=h(()=>{kUe()});var Rte,$D,_te,_Ue,RUe,$H,HD=h(()=>{ht();Rte=(e,t)=>{switch(t._tag){case"StringKeyword":case"TemplateLiteral":return Object.keys(e);case"SymbolKeyword":return Object.getOwnPropertySymbols(e);case"Refinement":return Rte(e,t.from)}},$D=e=>{let t=!1,r;return()=>(t||(r=e(),t=!0),r)},_te=e=>Array.isArray(e),_Ue=e=>!Array.isArray(e),RUe=e=>`[${Hg(e)}]`,$H=e=>_te(e)?e.map(RUe).join(""):RUe(e)});var wy,Bte,BUe,TUe,Tte,DUe,QUe,Dte,WH,Qte=h(()=>{wr();ht();HD();wy=(e,t,r,n)=>{let o=e;return r&&zr(r)&&(o+=`
66
66
  at path: ${$H(r)}`),t!==void 0&&(o+=`
67
67
  details: ${t}`),n&&(o+=`
68
- schema (${n._tag}): ${n}`),o},Bte=(e,t,r)=>wy("Unsupported schema or overlapping types",`cannot extend ${e} with ${t}`,r),BUe=e=>wy("Unsupported key schema",void 0,void 0,e),TUe=e=>wy("Unsupported literal",`literal value: ${uc(e)}`),Tte=e=>wy("Duplicate index signature",`${e} index signature`),DUe=wy("Unsupported index signature parameter","An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),QUe=wy("Invalid element","A required element cannot follow an optional element. ts(1257)"),Dte=e=>wy("Duplicate property signature transformation",`Duplicate key ${uc(e)}`),WH=e=>wy("Duplicate property signature",`Duplicate key ${uc(e)}`)});var NUe,PUe,MUe=h(()=>{NUe=Symbol.for("effect/SchemaId/DateFromSelf"),PUe=Symbol.for("effect/SchemaId/Int")});function ol(e,t){let r=!1,n=bE(e.length);for(let o=0;o<e.length;o++){let i=e[o],s=t(i);s!==i&&(r=!0),n[o]=s}return r?n:e}function iFt(e){return wt(jUe(e),{onNone:()=>"",onSome:t=>t.map(r=>` & Brand<${uc(r)}>`).join("")})}var LUe,UUe,$Ue,Vte,qH,G0,Wa,Kb,kh,Yte,Jte,Kte,Zte,Xte,ere,HUe,tre,rre,nre,ore,ire,GD,WUe,Rs,jUe,qUe,GUe,sre,are,z0,cre,zUe,VUe,YUe,JUe,KUe,ure,WMt,lre,GH,jMt,qMt,zb,vh,Vb,Zb,WD,Nte,zH,Pte,ZUe,Mte,VH,Fte,dre,Lte,XUe,Ute,YH,JH,$te,KH,fre,Hte,pre,mre,Wte,GMt,jte,zMt,e$e,qte,VMt,j0,wh,t$e,jD,YMt,To,r$e,Yb,il,FUe,JMt,hre,KMt,ZMt,n$e,XMt,os,o$e,ZH,V0,Ote,Iy,Jb,ky,XH,Ih,i$e,qD,eFt,Gte,s$e,jH,q0,gre,zD,tFt,rFt,a$e,nFt,c$e,u$e,Are,yre,l$e,oFt,lo,zte,np,VD,Yn,xre,vd,d$e,op,YD=h(()=>{wr();oe();yn();ht();Qte();HD();Lm();it();bm();ct();KL();LUe=Symbol.for("effect/annotation/TypeConstructor"),UUe=Symbol.for("effect/annotation/Brand"),$Ue=Symbol.for("effect/annotation/SchemaId"),Vte=Symbol.for("effect/annotation/Message"),qH=Symbol.for("effect/annotation/MissingMessage"),G0=Symbol.for("effect/annotation/Identifier"),Wa=Symbol.for("effect/annotation/Title"),Kb=Symbol.for("effect/annotation/AutoTitle"),kh=Symbol.for("effect/annotation/Description"),Yte=Symbol.for("effect/annotation/Examples"),Jte=Symbol.for("effect/annotation/Default"),Kte=Symbol.for("effect/annotation/JSONSchema"),Zte=Symbol.for("effect/annotation/Arbitrary"),Xte=Symbol.for("effect/annotation/Pretty"),ere=Symbol.for("effect/annotation/Equivalence"),HUe=Symbol.for("effect/annotation/Documentation"),tre=Symbol.for("effect/annotation/Concurrency"),rre=Symbol.for("effect/annotation/Batching"),nre=Symbol.for("effect/annotation/ParseIssueTitle"),ore=Symbol.for("effect/annotation/ParseOptions"),ire=Symbol.for("effect/annotation/DecodingFallback"),GD=Symbol.for("effect/annotation/Surrogate"),WUe=Symbol.for("effect/annotation/StableFilter"),Rs=x(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?H(e.annotations[t]):W()),jUe=Rs(UUe),qUe=Rs(Vte),GUe=Rs(qH),sre=Rs(Wa),are=Rs(Kb),z0=Rs(G0),cre=Rs(kh),zUe=Rs(tre),VUe=Rs(rre),YUe=Rs(nre),JUe=Rs(ore),KUe=Rs(ire),ure=Rs(GD),WMt=Rs(WUe),lre=e=>a6(WMt(e),t=>t===!0),GH=Symbol.for("effect/annotation/JSONIdentifier"),jMt=Rs(GH),qMt=e=>lc(jMt(e),()=>z0(e)),zb=class{typeParameters;decodeUnknown;encodeUnknown;annotations;_tag="Declaration";constructor(t,r,n,o={}){this.typeParameters=t,this.decodeUnknown=r,this.encodeUnknown=n,this.annotations=o}toString(){return Nt(op(this),()=>"<declaration schema>")}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map(t=>t.toJSON()),annotations:Yn(this.annotations)}}},vh=e=>t=>t._tag===e,Vb=class{literal;annotations;_tag="Literal";constructor(t,r={}){this.literal=t,this.annotations=r}toString(){return Nt(op(this),()=>uc(this.literal))}toJSON(){return{_tag:this._tag,literal:$g(this.literal)?String(this.literal):this.literal,annotations:Yn(this.annotations)}}},Zb=vh("Literal"),WD=class{symbol;annotations;_tag="UniqueSymbol";constructor(t,r={}){this.symbol=t,this.annotations=r}toString(){return Nt(op(this),()=>uc(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:Yn(this.annotations)}}},Nte=class{annotations;_tag="UndefinedKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},zH=new Nte({[Wa]:"undefined"}),Pte=class{annotations;_tag="VoidKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},ZUe=new Pte({[Wa]:"void"}),Mte=class{annotations;_tag="NeverKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},VH=new Mte({[Wa]:"never"}),Fte=class{annotations;_tag="UnknownKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},dre=new Fte({[Wa]:"unknown"}),Lte=class{annotations;_tag="AnyKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},XUe=new Lte({[Wa]:"any"}),Ute=class{annotations;_tag="StringKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},YH=new Ute({[Wa]:"string",[kh]:"a string"}),JH=vh("StringKeyword"),$te=class{annotations;_tag="NumberKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},KH=new $te({[Wa]:"number",[kh]:"a number"}),fre=vh("NumberKeyword"),Hte=class{annotations;_tag="BooleanKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},pre=new Hte({[Wa]:"boolean",[kh]:"a boolean"}),mre=vh("BooleanKeyword"),Wte=class{annotations;_tag="BigIntKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},GMt=new Wte({[Wa]:"bigint",[kh]:"a bigint"}),jte=class{annotations;_tag="SymbolKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},zMt=new jte({[Wa]:"symbol",[kh]:"a symbol"}),e$e=vh("SymbolKeyword"),qte=class{annotations;_tag="ObjectKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},VMt=new qte({[Wa]:"object",[kh]:"an object in the TypeScript meaning, i.e. the `object` type"}),j0=class{type;annotations;constructor(t,r={}){this.type=t,this.annotations=r}toJSON(){return{type:this.type.toJSON(),annotations:Yn(this.annotations)}}toString(){return String(this.type)}},wh=class extends j0{isOptional;constructor(t,r,n={}){super(t,n),this.isOptional=r}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:Yn(this.annotations)}}toString(){return String(this.type)+(this.isOptional?"?":"")}},t$e=e=>e.map(t=>t.type),jD=class{elements;rest;isReadonly;annotations;_tag="TupleType";constructor(t,r,n,o={}){this.elements=t,this.rest=r,this.isReadonly=n,this.annotations=o;let i=!1,s=!1;for(let a of t)if(a.isOptional)i=!0;else if(i){s=!0;break}if(s||i&&r.length>1)throw new Error(QUe)}toString(){return Nt(op(this),()=>YMt(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map(t=>t.toJSON()),rest:this.rest.map(t=>t.toJSON()),isReadonly:this.isReadonly,annotations:Yn(this.annotations)}}},YMt=e=>{let t=e.elements.map(String).join(", ");return nbe(e.rest,{onEmpty:()=>`readonly [${t}]`,onNonEmpty:(r,n)=>{let o=String(r),i=o.includes(" | ")?`(${o})`:o;if(n.length>0){let s=n.map(String).join(", ");return e.elements.length>0?`readonly [${t}, ...${i}[], ${s}]`:`readonly [...${i}[], ${s}]`}else return e.elements.length>0?`readonly [${t}, ...${i}[]]`:`ReadonlyArray<${o}>`}})},To=class extends wh{name;isReadonly;constructor(t,r,n,o,i){super(r,n,i),this.name=t,this.isReadonly=o}toString(){return(this.isReadonly?"readonly ":"")+String(this.name)+(this.isOptional?"?":"")+": "+this.type}toJSON(){return{name:String(this.name),type:this.type.toJSON(),isOptional:this.isOptional,isReadonly:this.isReadonly,annotations:Yn(this.annotations)}}},r$e=e=>{switch(e._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return!0;case"Refinement":return r$e(e.from)}return!1},Yb=class{type;isReadonly;parameter;constructor(t,r,n){if(this.type=r,this.isReadonly=n,r$e(t))this.parameter=t;else throw new Error(DUe)}toString(){return(this.isReadonly?"readonly ":"")+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}},il=class{annotations;_tag="TypeLiteral";propertySignatures;indexSignatures;constructor(t,r,n={}){this.annotations=n;let o={};for(let s=0;s<t.length;s++){let a=t[s].name;if(Object.prototype.hasOwnProperty.call(o,a))throw new Error(WH(a));o[a]=null}let i={string:!1,symbol:!1};for(let s=0;s<r.length;s++){let a=xre(r[s].parameter);if(JH(a)){if(i.string)throw new Error(Tte("string"));i.string=!0}else if(e$e(a)){if(i.symbol)throw new Error(Tte("symbol"));i.symbol=!0}}this.propertySignatures=t,this.indexSignatures=r}toString(){return Nt(op(this),()=>JMt(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map(t=>t.toJSON()),indexSignatures:this.indexSignatures.map(t=>t.toJSON()),annotations:Yn(this.annotations)}}},FUe=e=>e.map(String).join("; "),JMt=e=>{if(e.propertySignatures.length>0){let t=e.propertySignatures.map(String).join("; ");return e.indexSignatures.length>0?`{ ${t}; ${FUe(e.indexSignatures)} }`:`{ ${t} }`}else return e.indexSignatures.length>0?`{ ${FUe(e.indexSignatures)} }`:"{}"},hre=vh("TypeLiteral"),KMt=Vi(yf(oo,e=>{switch(e._tag){case"AnyKeyword":return 0;case"UnknownKeyword":return 1;case"ObjectKeyword":return 2;case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":return 3}return 4})),ZMt={string:"StringKeyword",number:"NumberKeyword",boolean:"BooleanKeyword",bigint:"BigIntKeyword"},n$e=e=>SE(e,t=>V0(t)?n$e(t.types):[t]),XMt=e=>{let t=KMt(e),r=[],n={},o=[];for(let i of t)switch(i._tag){case"NeverKeyword":break;case"AnyKeyword":return[XUe];case"UnknownKeyword":return[dre];case"ObjectKeyword":case"UndefinedKeyword":case"VoidKeyword":case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":{n[i._tag]||(n[i._tag]=i,r.push(i));break}case"Literal":{let s=typeof i.literal;switch(s){case"string":case"number":case"bigint":case"boolean":{let a=ZMt[s];!n[a]&&!o.includes(i.literal)&&(o.push(i.literal),r.push(i));break}case"object":{o.includes(i.literal)||(o.push(i.literal),r.push(i));break}}break}case"UniqueSymbol":{!n.SymbolKeyword&&!o.includes(i.symbol)&&(o.push(i.symbol),r.push(i));break}case"TupleType":{n.ObjectKeyword||r.push(i);break}case"TypeLiteral":{i.propertySignatures.length===0&&i.indexSignatures.length===0?n["{}"]||(n["{}"]=i,r.push(i)):n.ObjectKeyword||r.push(i);break}default:r.push(i)}return r},os=class e{types;annotations;static make=(t,r)=>ZH(t)?new e(t,r):t.length===1?t[0]:VH;static unify=(t,r)=>e.make(XMt(n$e(t)),r);_tag="Union";constructor(t,r={}){this.types=t,this.annotations=r}toString(){return Nt(op(this),()=>this.types.map(String).join(" | "))}toJSON(){return{_tag:this._tag,types:this.types.map(t=>t.toJSON()),annotations:Yn(this.annotations)}}},o$e=(e,t)=>e.map(t),ZH=e=>e.length>1,V0=vh("Union"),Ote=Te(Symbol.for("effect/Schema/AST/toJSONMemoMap"),()=>new WeakMap),Iy=class{f;annotations;_tag="Suspend";constructor(t,r={}){this.f=t,this.annotations=r,this.f=$D(t)}toString(){return op(this).pipe(lc(()=>Gn(EE(this.f)(),t=>op(t))),Nt(()=>"<suspended schema>"))}toJSON(){let t=this.f(),r=Ote.get(t);return r||(Ote.set(t,{_tag:this._tag}),r={_tag:this._tag,ast:t.toJSON(),annotations:Yn(this.annotations)},Ote.set(t,r),r)}},Jb=class{from;filter;annotations;_tag="Refinement";constructor(t,r,n={}){this.from=t,this.filter=r,this.annotations=n}toString(){return z0(this).pipe(Nt(()=>wt(d$e(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:t=>ky(this.from)?String(this.from)+" & "+t:t})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:Yn(this.annotations)}}},ky=vh("Refinement"),XH={},Ih=class{from;to;transformation;annotations;_tag="Transformation";constructor(t,r,n,o={}){this.from=t,this.to=r,this.transformation=n,this.annotations=o}toString(){return Nt(op(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:Yn(this.annotations)}}},i$e=vh("Transformation"),qD=class{decode;encode;_tag="FinalTransformation";constructor(t,r){this.decode=t,this.encode=r}},eFt=e=>t=>t._tag===e,Gte=class{_tag="ComposeTransformation"},s$e=new Gte,jH=class{from;to;decode;encode;constructor(t,r,n,o){this.from=t,this.to=r,this.decode=n,this.encode=o}},q0=class{propertySignatureTransformations;_tag="TypeLiteralTransformation";constructor(t){this.propertySignatureTransformations=t;let r={},n={};for(let o of t){let i=o.from;if(r[i])throw new Error(Dte(i));r[i]=!0;let s=o.to;if(n[s])throw new Error(Dte(s));n[s]=!0}}},gre=eFt("TypeLiteralTransformation"),zD=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={...e.annotations};delete n[G0];let o={...n,...t},i=ure(e);return pt(i)&&(o[GD]=zD(i.value,t)),r.annotations.value=o,Object.create(Object.getPrototypeOf(e),r)},tFt="[\\s\\S]*?",rFt="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?",a$e=(e,t)=>{switch(e._tag){case"Literal":return aI(String(e.literal));case"StringKeyword":return tFt;case"NumberKeyword":return rFt;case"TemplateLiteral":return c$e(e,t,!1);case"Union":return e.types.map(r=>a$e(r,t)).join("|")}},nFt=(e,t,r,n)=>{if(V0(e)){if(r&&!n)return`(?:${t})`}else if(!r||!n)return t;return`(${t})`},c$e=(e,t,r)=>{let n="";if(e.head!==""){let o=aI(e.head);n+=t&&r?`(${o})`:o}for(let o of e.spans){let i=a$e(o.type,t);if(n+=nFt(o.type,i,t,r),o.literal!==""){let s=aI(o.literal);n+=t&&r?`(${s})`:s}}return n},u$e=e=>new RegExp(`^${c$e(e,!1,!0)}$`),Are=(e,t)=>{let r=[],n=[],o=i=>{switch(i._tag){case"NeverKeyword":break;case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":case"Refinement":n.push(new Yb(i,t,!0));break;case"Literal":if(Fo(i.literal)||Ls(i.literal))r.push(new To(i.literal,t,!1,!0));else throw new Error(TUe(i.literal));break;case"Enums":{for(let[s,a]of i.enums)r.push(new To(a,t,!1,!0));break}case"UniqueSymbol":r.push(new To(i.symbol,t,!1,!0));break;case"Union":i.types.forEach(o);break;default:throw new Error(BUe(i))}};return o(e),{propertySignatures:r,indexSignatures:n}},yre=e=>t=>{let r;for(let n of e)Object.prototype.hasOwnProperty.call(t.annotations,n)&&(r===void 0&&(r={}),r[n]=t.annotations[n]);return r},l$e=e=>t=>{let r={...t.annotations};for(let n of e)delete r[n];return r},oFt=yre([Yte,Jte,Kte,Zte,Xte,ere]),lo=e=>{switch(e._tag){case"Declaration":{let t=ol(e.typeParameters,lo);return t===e.typeParameters?e:new zb(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case"TupleType":{let t=ol(e.elements,o=>{let i=lo(o.type);return i===o.type?o:new wh(i,o.isOptional)}),r=t$e(e.rest),n=ol(r,lo);return t===e.elements&&n===r?e:new jD(t,n.map(o=>new j0(o)),e.isReadonly,e.annotations)}case"TypeLiteral":{let t=ol(e.propertySignatures,n=>{let o=lo(n.type);return o===n.type?n:new To(n.name,o,n.isOptional,n.isReadonly)}),r=ol(e.indexSignatures,n=>{let o=lo(n.type);return o===n.type?n:new Yb(n.parameter,o,n.isReadonly)});return t===e.propertySignatures&&r===e.indexSignatures?e:new il(t,r,e.annotations)}case"Union":{let t=ol(e.types,lo);return t===e.types?e:os.make(t,e.annotations)}case"Suspend":return new Iy(()=>lo(e.f()),e.annotations);case"Refinement":{let t=lo(e.from);return t===e.from?e:new Jb(t,e.filter,e.annotations)}case"Transformation":{let t=oFt(e);return lo(t!==void 0?zD(e.to,t):e.to)}}return e};zte=e=>{switch(e._tag){case"Transformation":return e.from;case"Refinement":return zte(e.from);case"Suspend":return zte(e.f())}},np=(e,t)=>{switch(e._tag){case"Declaration":{let r=ol(e.typeParameters,n=>np(n,t));return r===e.typeParameters?e:new zb(r,e.decodeUnknown,e.encodeUnknown)}case"TupleType":{let r=ol(e.elements,i=>{let s=np(i.type,t);return s===i.type?i:new wh(s,i.isOptional)}),n=t$e(e.rest),o=ol(n,i=>np(i,t));return r===e.elements&&o===n?e:new jD(r,o.map(i=>new j0(i)),e.isReadonly)}case"TypeLiteral":{let r=ol(e.propertySignatures,o=>{let i=np(o.type,t);return i===o.type?o:new To(o.name,i,o.isOptional,o.isReadonly)}),n=ol(e.indexSignatures,o=>{let i=np(o.type,t);return i===o.type?o:new Yb(o.parameter,i,o.isReadonly)});return r===e.propertySignatures&&n===e.indexSignatures?e:new il(r,n)}case"Union":{let r=ol(e.types,n=>np(n,t));return r===e.types?e:os.make(r)}case"Suspend":{let r,n=qMt(e);if(pt(n)){let o=t?"Bound":"";r={[GH]:`${n.value}Encoded${o}`}}return new Iy(()=>np(e.f(),t),r)}case"Refinement":{let r=np(e.from,t);return t?r===e.from?e:zte(e.from)===void 0&&lre(e)?new Jb(r,e.filter,e.annotations):r:r}case"Transformation":return np(e.from,t)}return e},VD=e=>np(e,!1),Yn=e=>{let t={};for(let r of Object.getOwnPropertySymbols(e))t[String(r)]=e[r];return t},xre=e=>{switch(e._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return e;case"Refinement":return xre(e.from)}},vd=e=>Nt(op(e),()=>e._tag);d$e=e=>sre(e).pipe(lc(()=>cre(e)),lc(()=>are(e)),dr(t=>t+iFt(e))),op=e=>lc(z0(e),()=>d$e(e))});function Rd(e){return e.sort(lFt).map(t=>t[1])}function gFt(e){return cre(e).pipe(lc(()=>sre(e)),lc(()=>are(e)),lc(()=>z0(e)),Nt(()=>`{ ${e.from} | filter }`))}function AFt(e){return e.message!==void 0?e.message:`Expected ${ky(e.ast)?gFt(e.ast):String(e.ast)}, actual ${uc(e.actual)}`}var Xo,nW,Xb,Rn,ZD,XD,ia,oW,f$e,Sre,h$e,J0,iW,oa,Rh,ja,rW,g$e,A$e,sW,sFt,wre,y$e,x$e,E$e,b$e,Ire,kre,rQ,vre,Rre,aFt,cFt,Di,Ere,bre,uFt,Dc,JD,S$e,C$e,KD,lFt,dFt,na,eQ,fFt,w$e,pFt,mFt,I$e,Cre,hFt,_re,k$e,p$e,m$e,tQ,v$e,yFt,tW,xFt,EFt,bFt,Y0,aW=h(()=>{wr();Vs();lh();nr();Ei();Ro();oe();yn();ht();HD();it();ct();PA();YD();Xo=class{path;actual;issue;_tag="Pointer";constructor(t,r,n){this.path=t,this.actual=r,this.issue=n}},nW=class{actual;message;_tag="Unexpected";constructor(t,r){this.actual=t,this.message=r}},Xb=class{ast;message;_tag="Missing";actual=void 0;constructor(t,r){this.ast=t,this.message=r}},Rn=class{ast;actual;issues;output;_tag="Composite";constructor(t,r,n,o){this.ast=t,this.actual=r,this.issues=n,this.output=o}},ZD=class{ast;actual;kind;issue;_tag="Refinement";constructor(t,r,n,o){this.ast=t,this.actual=r,this.kind=n,this.issue=o}},XD=class{ast;actual;kind;issue;_tag="Transformation";constructor(t,r,n,o){this.ast=t,this.actual=r,this.kind=n,this.issue=o}},ia=class{ast;actual;message;_tag="Type";constructor(t,r,n){this.ast=t,this.actual=r,this.message=n}},oW=class{ast;actual;message;_tag="Forbidden";constructor(t,r,n){this.ast=t,this.actual=r,this.message=n}},f$e=Symbol.for("effect/Schema/ParseErrorTypeId"),Sre=class extends uh("ParseError"){[f$e]=f$e;get message(){return this.toString()}toString(){return eQ.formatIssueSync(this.issue)}toJSON(){return{_id:"ParseError",message:this.toString()}}[Ce](){return this.toJSON()}},h$e=e=>new Sre({issue:e}),J0=Le,iW=Re,oa=MEe,Rh=x(2,(e,t)=>oa(e)?xi(e,{onLeft:Re,onRight:t}):Ee(e,t)),ja=x(2,(e,t)=>oa(e)?lF(e,t):De(e,t)),rW=x(2,(e,t)=>oa(e)?LEe(e,t):Ha(e,t)),g$e=x(2,(e,t)=>oa(e)?FEe(e,{onLeft:t.onFailure,onRight:t.onSuccess}):VT(e,t)),A$e=x(2,(e,t)=>oa(e)?xi(e,{onLeft:t,onRight:Le}):s0(e,t)),sW=(e,t)=>t===void 0||Ls(t)?e:e===void 0?t:{...e,...t},sFt=(e,t,r)=>{let n=Di(e,t);return(o,i)=>n(o,sW(r,i))},wre=(e,t,r)=>{let n=sFt(e,t,r);return(o,i)=>y_(n(o,i),h$e)},y$e=(e,t,r)=>{let n=Di(e,t);return(o,i)=>n(o,{...sW(r,i),isEffectAllowed:!0})},x$e=(e,t)=>wre(e.ast,!0,t),E$e=(e,t)=>y$e(e.ast,!0,t),b$e=(e,t)=>wre(e.ast,!1,t),Ire=(e,t)=>y$e(e.ast,!1,t),kre=x$e,rQ=(e,t)=>wre(lo(e.ast),!0,t),vre=(e,t)=>{let r=Di(lo(e.ast),!0);return(n,o)=>ii(r(n,{exact:!0,...sW(t,o)}))},Rre=b$e,aFt=Te(Symbol.for("effect/ParseResult/decodeMemoMap"),()=>new WeakMap),cFt=Te(Symbol.for("effect/ParseResult/encodeMemoMap"),()=>new WeakMap),Di=(e,t)=>{let r=t?aFt:cFt,n=r.get(e);if(n)return n;let o=uFt(e,t),i=JUe(e),s=pt(i)?(u,l)=>o(u,sW(l,i.value)):o,a=KUe(e),c=t&&pt(a)?(u,l)=>KD(A$e(s(u,l),a.value),e,u,l):s;return r.set(e,c),c},Ere=e=>Gr(zUe(e)),bre=e=>Gr(VUe(e)),uFt=(e,t)=>{switch(e._tag){case"Refinement":if(t){let r=Di(e.from,!0);return(n,o)=>{o=o??XH;let i=o?.errors==="all",s=Rh(A$e(r(n,o),a=>{let c=new ZD(e,n,"From",a);return i&&lre(e)&&k$e(a)?wt(e.filter(n,o,e),{onNone:()=>Re(c),onSome:u=>Re(new Rn(e,n,[c,new ZD(e,n,"Predicate",u)]))}):Re(c)}),a=>wt(e.filter(a,o,e),{onNone:()=>Le(a),onSome:c=>Re(new ZD(e,n,"Predicate",c))}));return KD(s,e,n,o)}}else{let r=Di(lo(e),!0),n=Di(C$e(e.from),!1);return(o,i)=>KD(Rh(r(o,i),s=>n(s,i)),e,o,i)}case"Transformation":{let r=dFt(e.transformation,t),n=t?Di(e.from,!0):Di(e.to,!1),o=t?Di(e.to,!0):Di(e.from,!1);return(i,s)=>KD(Rh(rW(n(i,s),a=>new XD(e,i,t?"Encoded":"Type",a)),a=>Rh(rW(r(a,s??XH,e,i),c=>new XD(e,i,"Transformation",c)),c=>rW(o(c,s),u=>new XD(e,i,t?"Type":"Encoded",u)))),e,i,s)}case"Declaration":{let r=t?e.decodeUnknown(...e.typeParameters):e.encodeUnknown(...e.typeParameters);return(n,o)=>KD(r(n,o??XH,e),e,n,o)}case"Literal":return Dc(e,r=>r===e.literal);case"UniqueSymbol":return Dc(e,r=>r===e.symbol);case"UndefinedKeyword":return Dc(e,fEe);case"NeverKeyword":return Dc(e,pEe);case"UnknownKeyword":case"AnyKeyword":case"VoidKeyword":return Le;case"StringKeyword":return Dc(e,Fo);case"NumberKeyword":return Dc(e,Ls);case"BooleanKeyword":return Dc(e,hm);case"BigIntKeyword":return Dc(e,$g);case"SymbolKeyword":return Dc(e,fE);case"ObjectKeyword":return Dc(e,yi);case"Enums":return Dc(e,r=>e.enums.some(([n,o])=>o===r));case"TemplateLiteral":{let r=u$e(e);return Dc(e,n=>Fo(n)&&r.test(n))}case"TupleType":{let r=e.elements.map(u=>Di(u.type,t)),n=e.rest.map(u=>Di(u.type,t)),o=e.elements.filter(u=>!u.isOptional);e.rest.length>0&&(o=o.concat(e.rest.slice(1)));let i=o.length,s=e.elements.length>0?e.elements.map((u,l)=>l).join(" | "):"never",a=Ere(e),c=bre(e);return(u,l)=>{if(!m6(u))return Re(new ia(e,u));let d=l?.errors==="all",f=[],p=0,m=[],g=u.length;for(let b=g;b<=i-1;b++){let w=new Xo(b,u,new Xb(o[b-g]));if(d){f.push([p++,w]);continue}else return Re(new Rn(e,u,w,m))}if(e.rest.length===0)for(let b=e.elements.length;b<=g-1;b++){let w=new Xo(b,u,new nW(u[b],`is unexpected, expected: ${s}`));if(d){f.push([p++,w]);continue}else return Re(new Rn(e,u,w,m))}let A=0,E;for(;A<r.length;A++)if(g<A+1){if(e.elements[A].isOptional)continue}else{let b=r[A],w=b(u[A],l);if(oa(w)){if(xr(w)){let I=new Xo(A,u,w.left);if(d){f.push([p++,I]);continue}else return Re(new Rn(e,u,I,Rd(m)))}m.push([p++,w.right])}else{let I=p++,v=A;E||(E=[]),E.push(({es:k,output:R})=>Ee(ny(w),B=>{if(xr(B)){let L=new Xo(v,u,B.left);return d?(k.push([I,L]),ve):Re(new Rn(e,u,L,Rd(R)))}return R.push([I,B.right]),ve}))}}if(zr(n)){let[b,...w]=n;for(;A<g-w.length;A++){let I=b(u[A],l);if(oa(I))if(xr(I)){let v=new Xo(A,u,I.left);if(d){f.push([p++,v]);continue}else return Re(new Rn(e,u,v,Rd(m)))}else m.push([p++,I.right]);else{let v=p++,k=A;E||(E=[]),E.push(({es:R,output:B})=>Ee(ny(I),L=>{if(xr(L)){let D=new Xo(k,u,L.left);return d?(R.push([v,D]),ve):Re(new Rn(e,u,D,Rd(B)))}else return B.push([v,L.right]),ve}))}}for(let I=0;I<w.length;I++){let v=A+I;if(!(g<v+1)){let k=w[I](u[v],l);if(oa(k)){if(xr(k)){let R=new Xo(v,u,k.left);if(d){f.push([p++,R]);continue}else return Re(new Rn(e,u,R,Rd(m)))}m.push([p++,k.right])}else{let R=p++;E||(E=[]),E.push(({es:B,output:L})=>Ee(ny(k),D=>{if(xr(D)){let ee=new Xo(v,u,D.left);return d?(B.push([R,ee]),ve):Re(new Rn(e,u,ee,Rd(L)))}return L.push([R,D.right]),ve}))}}}}let y=({es:b,output:w})=>Cm(b)?Re(new Rn(e,u,Rd(b),Rd(w))):Le(Rd(w));if(E&&E.length>0){let b=E;return Pt(()=>{let w={es:_w(f),output:_w(m)};return Ee(pi(b,I=>I(w),{concurrency:a,batching:c,discard:!0}),()=>y(w))})}return y({output:m,es:f})}}case"TypeLiteral":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return Dc(e,mEe);let r=[],n={},o=[];for(let l of e.propertySignatures)r.push([Di(l.type,t),l]),n[l.name]=null,o.push(l.name);let i=e.indexSignatures.map(l=>[Di(l.parameter,t),Di(l.type,t),l.parameter]),s=os.make(e.indexSignatures.map(l=>l.parameter).concat(o.map(l=>fE(l)?new WD(l):new Vb(l)))),a=Di(s,t),c=Ere(e),u=bre(e);return(l,d)=>{if(!PJ(l))return Re(new ia(e,l));let f=d?.errors==="all",p=[],m=0,g=d?.onExcessProperty==="error",A=d?.onExcessProperty==="preserve",E={},y;if(g||A){y=Reflect.ownKeys(l);for(let v of y){let k=a(v,d);if(oa(k)&&xr(k))if(g){let R=new Xo(v,l,new nW(l[v],`is unexpected, expected: ${String(s)}`));if(f){p.push([m++,R]);continue}else return Re(new Rn(e,l,R,E))}else E[v]=l[v]}}let b,w=d?.exact===!0;for(let v=0;v<r.length;v++){let k=r[v][1],R=k.name,B=Object.prototype.hasOwnProperty.call(l,R);if(!B){if(k.isOptional)continue;if(w){let ee=new Xo(R,l,new Xb(k));if(f){p.push([m++,ee]);continue}else return Re(new Rn(e,l,ee,E))}}let L=r[v][0],D=L(l[R],d);if(oa(D)){if(xr(D)){let ee=new Xo(R,l,B?D.left:new Xb(k));if(f){p.push([m++,ee]);continue}else return Re(new Rn(e,l,ee,E))}E[R]=D.right}else{let ee=m++,F=R;b||(b=[]),b.push(({es:_,output:P})=>Ee(ny(D),$=>{if(xr($)){let N=new Xo(F,l,B?$.left:new Xb(k));return f?(_.push([ee,N]),ve):Re(new Rn(e,l,N,P))}return P[F]=$.right,ve}))}}for(let v=0;v<i.length;v++){let k=i[v],R=k[0],B=k[1],L=Rte(l,k[2]);for(let D of L){let ee=R(D,d);if(oa(ee)&&ii(ee)){let F=B(l[D],d);if(oa(F))if(xr(F)){let _=new Xo(D,l,F.left);if(f){p.push([m++,_]);continue}else return Re(new Rn(e,l,_,E))}else Object.prototype.hasOwnProperty.call(n,D)||(E[D]=F.right);else{let _=m++,P=D;b||(b=[]),b.push(({es:$,output:N})=>Ee(ny(F),q=>{if(xr(q)){let re=new Xo(P,l,q.left);return f?($.push([_,re]),ve):Re(new Rn(e,l,re,N))}else return Object.prototype.hasOwnProperty.call(n,D)||(N[D]=q.right),ve}))}}}}let I=({es:v,output:k})=>{if(Cm(v))return Re(new Rn(e,l,Rd(v),k));if(d?.propertyOrder==="original"){let R=y||Reflect.ownKeys(l);for(let L of o)R.indexOf(L)===-1&&R.push(L);let B={};for(let L of R)Object.prototype.hasOwnProperty.call(k,L)&&(B[L]=k[L]);return Le(B)}return Le(k)};if(b&&b.length>0){let v=b;return Pt(()=>{let k={es:_w(p),output:Object.assign({},E)};return Ee(pi(v,R=>R(k),{concurrency:c,batching:u,discard:!0}),()=>I(k))})}return I({es:p,output:E})}}case"Union":{let r=S$e(e.types,t),n=Reflect.ownKeys(r.keys),o=n.length,i=e.types.length,s=new Map;for(let u=0;u<i;u++)s.set(e.types[u],Di(e.types[u],t));let a=Ere(e)??1,c=bre(e);return(u,l)=>{let d=[],f=0,p=[];if(o>0)if(c_(u))for(let A=0;A<o;A++){let E=n[A],y=r.keys[E].buckets;if(Object.prototype.hasOwnProperty.call(u,E)){let b=String(u[E]);if(Object.prototype.hasOwnProperty.call(y,b))p=p.concat(y[b]);else{let{candidates:w,literals:I}=r.keys[E],v=os.make(I),k=w.length===i?new il([new To(E,v,!1,!0)],[]):os.make(w);d.push([f++,new Rn(k,u,new Xo(E,u,new ia(v,u[E])))])}}else{let{candidates:b,literals:w}=r.keys[E],I=new To(E,os.make(w),!1,!0),v=b.length===i?new il([I],[]):os.make(b);d.push([f++,new Rn(v,u,new Xo(E,u,new Xb(I)))])}}else{let A=r.candidates.length===i?e:os.make(r.candidates);d.push([f++,new ia(A,u)])}r.otherwise.length>0&&(p=p.concat(r.otherwise));let m;for(let A=0;A<p.length;A++){let E=p[A],y=s.get(E)(u,l);if(oa(y)&&(!m||m.length===0)){if(ii(y))return y;d.push([f++,y.left])}else{let b=f++;m||(m=[]),m.push(w=>Pt(()=>"finalResult"in w?ve:Ee(ny(y),I=>(ii(I)?w.finalResult=I:w.es.push([b,I.left]),ve))))}}let g=A=>Cm(A)?A.length===1&&A[0][1]._tag==="Type"?Re(A[0][1]):Re(new Rn(e,u,Rd(A))):Re(new ia(e,u));if(m&&m.length>0){let A=m;return Pt(()=>{let E={es:_w(d)};return Ee(pi(A,y=>y(E),{concurrency:a,batching:c,discard:!0}),()=>"finalResult"in E?E.finalResult:g(E.es))})}return g(d)}}case"Suspend":{let r=$D(()=>Di(e.f(),t));return(n,o)=>r()(n,o)}}},Dc=(e,t)=>r=>t(r)?Le(r):Re(new ia(e,r)),JD=(e,t)=>{switch(e._tag){case"Declaration":{let r=ure(e);if(pt(r))return JD(r.value,t);break}case"TypeLiteral":{let r=[];for(let n=0;n<e.propertySignatures.length;n++){let o=e.propertySignatures[n],i=t?VD(o.type):lo(o.type);Zb(i)&&!o.isOptional&&r.push([o.name,i])}return r}case"TupleType":{let r=[];for(let n=0;n<e.elements.length;n++){let o=e.elements[n],i=t?VD(o.type):lo(o.type);Zb(i)&&!o.isOptional&&r.push([n,i])}return r}case"Refinement":return JD(e.from,t);case"Suspend":return JD(e.f(),t);case"Transformation":return JD(t?e.from:e.to,t)}return[]},S$e=(e,t)=>{let r={},n=[],o=[];for(let i=0;i<e.length;i++){let s=e[i],a=JD(s,t);if(a.length>0){o.push(s);for(let c=0;c<a.length;c++){let[u,l]=a[c],d=String(l.literal);r[u]=r[u]||{buckets:{},literals:[],candidates:[]};let f=r[u].buckets;if(Object.prototype.hasOwnProperty.call(f,d)){if(c<a.length-1)continue;f[d].push(s),r[u].literals.push(l),r[u].candidates.push(s)}else{f[d]=[s],r[u].literals.push(l),r[u].candidates.push(s);break}}}else n.push(s)}return{keys:r,otherwise:n,candidates:o}},C$e=e=>ky(e)?C$e(e.from):e,KD=(e,t,r,n)=>{if(n?.isEffectAllowed===!0||oa(e))return e;let o=new CI,i=m0(e,{scheduler:o});o.flush();let s=i.unsafePoll();if(s){if(Zm(s))return Le(s.value);let a=s.cause;return Vwe(a)?Re(a.error):Re(new oW(t,r,VL(a)))}return Re(new oW(t,r,"cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work"))},lFt=([e],[t])=>e>t?1:e<t?-1:0;dFt=(e,t)=>{switch(e._tag){case"FinalTransformation":return t?e.decode:e.encode;case"ComposeTransformation":return Le;case"TypeLiteralTransformation":return r=>{let n=Le(r);for(let o of e.propertySignatureTransformations){let[i,s]=t?[o.from,o.to]:[o.to,o.from],a=t?o.decode:o.encode;n=ja(n,u=>{let l=a(Object.prototype.hasOwnProperty.call(u,i)?H(u[i]):W());return delete u[i],pt(l)&&(u[s]=l.value),u})}return n}}},na=(e,t=[])=>({value:e,forest:t}),eQ={formatIssue:e=>ja(Y0(e),fFt),formatIssueSync:e=>{let t=eQ.formatIssue(e);return oa(t)?UEe(t):xd(t)},formatError:e=>eQ.formatIssue(e.issue),formatErrorSync:e=>eQ.formatIssueSync(e.issue)},fFt=e=>e.value+w$e(`
69
- `,e.forest),w$e=(e,t)=>{let r="",n=t.length,o;for(let i=0;i<n;i++){o=t[i];let s=i===n-1;r+=e+(s?"\u2514":"\u251C")+"\u2500 "+o.value,r+=w$e(e+(n>1&&!s?"\u2502 ":" "),o.forest)}return r},pFt=e=>{switch(e){case"Encoded":return"Encoded side transformation failure";case"Transformation":return"Transformation process failure";case"Type":return"Type side transformation failure"}},mFt=e=>{switch(e){case"From":return"From side refinement failure";case"Predicate":return"Predicate refinement failure"}},I$e=e=>"ast"in e?H(e.ast):W(),Cre=Le(void 0),hFt=e=>I$e(e).pipe(Gn(qUe),wt({onNone:()=>Cre,onSome:t=>{let r=t(e);return Fo(r)?Le({message:r,override:!1}):ws(r)?De(r,n=>({message:n,override:!1})):Fo(r.message)?Le({message:r.message,override:r.override}):De(r.message,n=>({message:n,override:r.override}))}})),_re=e=>t=>t._tag===e,k$e=_re("Composite"),p$e=_re("Refinement"),m$e=_re("Transformation"),tQ=e=>Rh(hFt(e),t=>t!==void 0?!t.override&&(k$e(e)||p$e(e)&&e.kind==="From"||m$e(e)&&e.kind!=="Transformation")?m$e(e)||p$e(e)?tQ(e.issue):Cre:Le(t.message):Cre),v$e=e=>I$e(e).pipe(Gn(YUe),o6(t=>t(e)),Gr);yFt=e=>ja(tQ(e),t=>t??v$e(e)??AFt(e)),tW=e=>v$e(e)??String(e.ast),xFt=e=>e.message??"is forbidden",EFt=e=>e.message??"is unexpected",bFt=e=>{let t=GUe(e.ast);if(pt(t)){let r=t.value();return Fo(r)?Le(r):r}return Le(e.message??"is missing")},Y0=e=>{switch(e._tag){case"Type":return ja(yFt(e),na);case"Forbidden":return Le(na(tW(e),[na(xFt(e))]));case"Unexpected":return Le(na(EFt(e)));case"Missing":return ja(bFt(e),na);case"Transformation":return Rh(tQ(e),t=>t!==void 0?Le(na(t)):ja(Y0(e.issue),r=>na(tW(e),[na(pFt(e.kind),[r])])));case"Refinement":return Rh(tQ(e),t=>t!==void 0?Le(na(t)):ja(Y0(e.issue),r=>na(tW(e),[na(mFt(e.kind),[r])])));case"Pointer":return ja(Y0(e.issue),t=>na($H(e.path),[t]));case"Composite":return Rh(tQ(e),t=>{if(t!==void 0)return Le(na(t));let r=tW(e);return _te(e.issues)?ja(pi(e.issues,Y0),n=>na(r,n)):ja(Y0(e.issues),n=>na(r,[n]))})}}});var Bre,Tre=h(()=>{WMe();Bre=HMe});var B$e,cW,uW=h(()=>{oe();ct();B$e=x(e=>yi(e[0]),(e,...t)=>{let r={};for(let n of t)n in e&&(r[n]=e[n]);return r}),cW=x(e=>yi(e[0]),(e,...t)=>{let r={...e};for(let n of t)delete r[n];return r})});function fo(e){return class{[vy]=Qre;static ast=e;static annotations(r){return fo(oS(this.ast,r))}static pipe(){return Z(this,arguments)}static toString(){return String(e)}static Type;static Encoded;static Context;static[vy]=Qre}}function wFt(e){return ZH(e)?os.make(o$e(e,t=>new Vb(t))):new Vb(e[0])}function H$e(e,t=wFt(e)){return class extends fo(t){static annotations(n){return H$e(this.literals,oS(this.ast,n))}static literals=[...e]}}function is(...e){return zr(e)?H$e(e):pW}function $re(e,t){return class extends fo(t){static annotations(n){return $re(this.typeParameters,oS(this.ast,n))}static typeParameters=[...e]}}function W$e(e,t=vFt(e)){return class extends fo(t){static annotations(n){return W$e(this.members,oS(this.ast,n))}static members=[...e]}}function cQ(...e){return ZH(e)?W$e(e):zr(e)?e[0]:pW}function z$e(e,t,r=QFt(e,t)){return class extends fo(r){static annotations(o){return z$e(this.fields,this.records,oS(this.ast,o))}static fields={...e};static records=[...t];static make=(o,i)=>{let s=G$e(e,{...o});return jre(i)?s:rQ(this)(s)};static pick(...o){return ss(B$e(e,...o))}static omit(...o){return ss(cW(e,...o))}}}function ss(e,...t){return z$e(e,t)}function J$e(e,t,r){return class extends fo(r){static annotations(o){return J$e(this.from,this.filter,oS(this.ast,o))}static[Y$e]=e;static from=e;static filter=t;static make=(o,i)=>jre(i)?o:rQ(this)(o)}}function K$e(e,t){return r=>{function n(i,s,a){return NFt(e(i,s,a),a,i)}let o=new Jb(r.ast,n,nS(t));return J$e(r,n,o)}}function Z$e(e,t,r){return class extends fo(r){static annotations(o){return Z$e(this.from,this.to,oS(this.ast,o))}static from=e;static to=t}}function jre(e){return hm(e)?e:e?.disableValidation??!1}function tS(e){switch(e._tag){case"Empty":return jwe;case"Fail":return VE(e.error);case"Die":return od(e.defect);case"Interrupt":return qL(bW(e.fiberId));case"Sequential":return Gwe(tS(e.left),tS(e.right));case"Parallel":return qwe(tS(e.left),tS(e.right))}}function K0(e){switch(e._tag){case"Empty":return{_tag:"Empty"};case"Fail":return{_tag:"Fail",error:e.error};case"Die":return{_tag:"Die",defect:e.defect};case"Interrupt":return{_tag:"Interrupt",fiberId:e.fiberId};case"Sequential":return{_tag:"Sequential",left:K0(e.left),right:K0(e.right)};case"Parallel":return{_tag:"Parallel",left:K0(e.left),right:K0(e.right)}}}var vy,Qre,T$e,nS,oS,SFt,CFt,iQ,rS,IFt,kFt,aQ,Ore,fW,pW,mW,_d,sQ,vFt,RFt,D$e,Nre,Z0,hW,_Ft,gW,j$e,q$e,Hre,AW,Q$e,yW,BFt,TFt,iS,DFt,QFt,G$e,nQ,OFt,oQ,xW,eS,_h,V$e,Pre,Y$e,O$e,NFt,Mre,uQ,N$e,PFt,MFt,P$e,M$e,FFt,LFt,EW,UFt,F$e,L$e,$Ft,X$e,Wre,e2e,t2e,HFt,sS,lW,U$e,WFt,dW,jFt,qFt,GFt,Fre,zFt,Lre,bW,VFt,YFt,JFt,KFt,ZFt,Ure,XFt,eLt,$$e,tLt,r2e,ip,X0=h(()=>{wr();Vs();lh();mm();Zl();oe();yn();ht();Jl();Qte();MUe();HD();it();aW();Me();ct();YD();uW();aW();vy=Symbol.for("effect/Schema");Qre={_A:e=>e,_I:e=>e,_R:e=>e},T$e={typeConstructor:LUe,schemaId:$Ue,message:Vte,missingMessage:qH,identifier:G0,title:Wa,description:kh,examples:Yte,default:Jte,documentation:HUe,jsonSchema:Kte,arbitrary:Zte,pretty:Xte,equivalence:ere,concurrency:tre,batching:rre,parseIssueTitle:nre,parseOptions:ore,decodingFallback:ire},nS=e=>{if(!e)return{};let t={...e};for(let r in T$e)if(r in e){let n=T$e[r];t[n]=e[r],delete t[r]}return t},oS=(e,t)=>zD(e,nS(t)),SFt=e=>String(e.ast),CFt=e=>fo(VD(e.ast)),iQ=e=>fo(lo(e.ast)),rS=e=>se(e,vy)&&yi(e[vy]);IFt=(e,t,r)=>$re(e,new zb(e.map(n=>n.ast),(...n)=>t.decode(...n.map(fo)),(...n)=>t.encode(...n.map(fo)),nS(r))),kFt=(e,t)=>{let r=()=>(o,i,s)=>e(o)?J0(o):iW(new ia(s,o)),n=r;return $re([],new zb([],r,n,nS(t)))};aQ=function(){if(Array.isArray(arguments[0])){let r=arguments[0],n=arguments[1],o=arguments[2];return IFt(r,n,o)}let e=arguments[0],t=arguments[1];return kFt(e,t)},Ore=class extends fo(zH){},fW=class extends fo(ZUe){},pW=class extends fo(VH){},mW=class extends fo(dre){},_d=class extends fo(YH){},sQ=class extends fo(KH){},vFt=e=>os.make(e.map(t=>t.ast));RFt=e=>cQ(e,Ore),D$e=class e{ast;from;[vy];_Token;constructor(t,r){this.ast=t,this.from=r}annotations(t){return new e(new wh(this.ast.type,this.ast.isOptional,{...this.ast.annotations,...nS(t)}),this.from)}toString(){return`${this.ast.type}${this.ast.isOptional?"?":""}`}},Nre=e=>e?'"?:"':'":"',Z0=class extends wh{isReadonly;defaultValue;_tag="PropertySignatureDeclaration";constructor(t,r,n,o,i){super(t,r,o),this.isReadonly=n,this.defaultValue=i}toString(){let t=Nre(this.isOptional),r=String(this.type);return`PropertySignature<${t}, ${r}, never, ${t}, ${r}>`}},hW=class extends wh{isReadonly;defaultValue;constructor(t,r,n,o,i){super(t,r,o),this.isReadonly=n,this.defaultValue=i}},_Ft=e=>e===void 0?"never":Fo(e)?JSON.stringify(e):String(e),gW=class{from;to;decode;encode;_tag="PropertySignatureTransformation";constructor(t,r,n,o){this.from=t,this.to=r,this.decode=n,this.encode=o}toString(){return`PropertySignature<${Nre(this.to.isOptional)}, ${this.to.type}, ${_Ft(this.from.fromKey)}, ${Nre(this.from.isOptional)}, ${this.from.type}>`}},j$e=(e,t)=>{switch(e._tag){case"PropertySignatureDeclaration":return new Z0(e.type,e.isOptional,e.isReadonly,{...e.annotations,...t},e.defaultValue);case"PropertySignatureTransformation":return new gW(e.from,new hW(e.to.type,e.to.isOptional,e.to.isReadonly,{...e.to.annotations,...t},e.to.defaultValue),e.decode,e.encode)}},q$e=Symbol.for("effect/PropertySignature"),Hre=e=>se(e,q$e),AW=class e{ast;[vy];[q$e]=null;_TypeToken;_Key;_EncodedToken;_HasDefault;constructor(t){this.ast=t}pipe(){return Z(this,arguments)}annotations(t){return new e(j$e(this.ast,nS(t)))}toString(){return String(this.ast)}},Q$e=e=>new AW(e),yW=class e extends AW{from;constructor(t,r){super(t),this.from=r}annotations(t){return new e(j$e(this.ast,nS(t)),this.from)}},BFt=e=>new yW(new Z0(e.ast,!1,!0,{},void 0),e),TFt=x(2,(e,t)=>{let r=e.ast;switch(r._tag){case"PropertySignatureDeclaration":return Q$e(new Z0(r.type,r.isOptional,r.isReadonly,r.annotations,t));case"PropertySignatureTransformation":return Q$e(new gW(r.from,new hW(r.to.type,r.to.isOptional,r.to.isReadonly,r.to.annotations,t),r.decode,r.encode))}}),iS=e=>{let t=e.ast===zH||e.ast===VH?zH:RFt(e).ast;return new yW(new Z0(t,!0,!0,{},void 0),e)},DFt=yre([qH]),QFt=(e,t)=>{let r=Reflect.ownKeys(e),n=[];if(r.length>0){let i=[],s=[],a=[];for(let c=0;c<r.length;c++){let u=r[c],l=e[u];if(Hre(l)){let d=l.ast;switch(d._tag){case"PropertySignatureDeclaration":{let f=d.type,p=d.isOptional,m=d.annotations;i.push(new To(u,f,p,!0,DFt(d))),s.push(new To(u,lo(f),p,!0,m)),n.push(new To(u,f,p,!0,m));break}case"PropertySignatureTransformation":{let f=d.from.fromKey??u;i.push(new To(f,d.from.type,d.from.isOptional,!0,d.from.annotations)),s.push(new To(u,d.to.type,d.to.isOptional,!0,d.to.annotations)),a.push(new jH(f,u,d.decode,d.encode));break}}}else i.push(new To(u,l.ast,!1,!0)),s.push(new To(u,lo(l.ast),!1,!0)),n.push(new To(u,l.ast,!1,!0))}if(zr(a)){let c=[],u=[];for(let l of t){let{indexSignatures:d,propertySignatures:f}=Are(l.key.ast,l.value.ast);f.forEach(p=>{i.push(p),s.push(new To(p.name,lo(p.type),p.isOptional,p.isReadonly,p.annotations))}),d.forEach(p=>{c.push(p),u.push(new Yb(p.parameter,lo(p.type),p.isReadonly))})}return new Ih(new il(i,c,{[Kb]:"Struct (Encoded side)"}),new il(s,u,{[Kb]:"Struct (Type side)"}),new q0(a))}}let o=[];for(let i of t){let{indexSignatures:s,propertySignatures:a}=Are(i.key.ast,i.value.ast);a.forEach(c=>n.push(c)),s.forEach(c=>o.push(c))}return new il(n,o)},G$e=(e,t)=>{let r=Reflect.ownKeys(e);for(let n of r){let o=e[n];if(t[n]===void 0&&Hre(o)){let i=o.ast,s=i._tag==="PropertySignatureDeclaration"?i.defaultValue:i.to.defaultValue;s!==void 0&&(t[n]=s())}}return t};nQ=(e,t,r)=>{if(hre(e)&&hre(t)){let n=[...e.propertySignatures];for(let o of t.propertySignatures){let i=o.name,s=n.findIndex(a=>a.name===i);if(s===-1)n.push(o);else{let{isOptional:a,type:c}=n[s];n[s]=new To(i,xW(c,o.type,r.concat(i)),a,!0)}}return new il(n,e.indexSignatures.concat(t.indexSignatures))}throw new Error(Bte(e,t,r))},OFt=l$e([G0]),oQ=(e,t)=>t.map(r=>new Jb(r,e.filter,OFt(e))),xW=(e,t,r)=>os.make(_h([e],[t],r)),eS=e=>V0(e)?e.types:[e],_h=(e,t,r)=>SE(e,n=>SE(t,o=>{switch(o._tag){case"Literal":{if(Fo(o.literal)&&JH(n)||Ls(o.literal)&&fre(n)||hm(o.literal)&&mre(n))return[o];break}case"StringKeyword":{if(o===YH){if(JH(n)||Zb(n)&&Fo(n.literal))return[n];if(ky(n))return oQ(n,_h(eS(n.from),[o],r))}else if(n===YH)return[o];break}case"NumberKeyword":{if(o===KH){if(fre(n)||Zb(n)&&Ls(n.literal))return[n];if(ky(n))return oQ(n,_h(eS(n.from),[o],r))}else if(n===KH)return[o];break}case"BooleanKeyword":{if(o===pre){if(mre(n)||Zb(n)&&hm(n.literal))return[n];if(ky(n))return oQ(n,_h(eS(n.from),[o],r))}else if(n===pre)return[o];break}case"Union":return _h(eS(n),o.types,r);case"Suspend":return[new Iy(()=>xW(n,o.f(),r))];case"Refinement":return oQ(o,_h(eS(n),eS(o.from),r));case"TypeLiteral":{switch(n._tag){case"Union":return _h(n.types,[o],r);case"Suspend":return[new Iy(()=>xW(n.f(),o,r))];case"Refinement":return oQ(n,_h(eS(n.from),[o],r));case"TypeLiteral":return[nQ(n,o,r)];case"Transformation":{let i=n.transformation,s=nQ(n.from,o,r),a=nQ(n.to,lo(o),r);switch(i._tag){case"TypeLiteralTransformation":return[new Ih(s,a,new q0(i.propertySignatureTransformations))];case"ComposeTransformation":return[new Ih(s,a,s$e)];case"FinalTransformation":return[new Ih(s,a,new qD((c,u,l,d)=>ja(i.decode(c,u,l,d),f=>({...c,...f})),(c,u,l,d)=>ja(i.encode(c,u,l,d),f=>({...c,...f}))))]}}}break}case"Transformation":{if(i$e(n)){if(gre(o.transformation)&&gre(n.transformation))return[new Ih(nQ(n.from,o.from,r),nQ(n.to,o.to,r),new q0(o.transformation.propertySignatureTransformations.concat(n.transformation.propertySignatureTransformations)))]}else return _h([o],[n],r);break}}throw new Error(Bte(n,o,r))})),V$e=x(2,(e,t)=>fo(xW(e.ast,t.ast,[]))),Pre=e=>fo(new Iy(()=>e().ast)),Y$e=Symbol.for("effect/SchemaId/Refine");O$e=(e,t,r)=>{if(hm(e))return e?W():H(new ia(t,r));if(Fo(e))return H(new ia(t,r,e));if(e!==void 0){if("_tag"in e)return H(e);let n=new ia(t,r,e.message);return H(zr(e.path)?new Xo(e.path,r,n):n)}return W()},NFt=(e,t,r)=>{if(_Ue(e))return O$e(e,t,r);if(zr(e)){let n=Yg(e,o=>O$e(o,t,r));if(zr(n))return H(n.length===1?n[0]:new Rn(t,r,n))}return W()};Mre=x(e=>rS(e[0])&&rS(e[1]),(e,t,r)=>Z$e(e,t,new Ih(e.ast,t.ast,new qD(r.decode,r.encode)))),uQ=x(e=>rS(e[0])&&rS(e[1]),(e,t,r)=>Mre(e,t,{strict:!0,decode:(n,o,i,s)=>J0(r.decode(n,s)),encode:(n,o,i,s)=>J0(r.encode(n,s))})),N$e=Symbol.for("effect/SchemaId/Pattern"),PFt=(e,t)=>r=>{let n=e.source;return r.pipe(K$e(o=>(e.lastIndex=0,e.test(o)),{schemaId:N$e,[N$e]:{regex:e},description:`a string matching the pattern ${n}`,jsonSchema:{pattern:n},...t}))},MFt=Symbol.for("effect/SchemaId/UUID"),P$e=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i,M$e=class extends _d.pipe(PFt(P$e,{schemaId:MFt,identifier:"UUID",jsonSchema:{format:"uuid",pattern:P$e.source},description:"a Universally Unique Identifier",arbitrary:()=>t=>t.uuid()})){},FFt=PUe,LFt=e=>t=>t.pipe(K$e(r=>Number.isSafeInteger(r),{schemaId:FFt,title:"int",description:"an integer",jsonSchema:{type:"integer"},...e})),EW=class extends sQ.pipe(LFt({identifier:"Int"})){},UFt=(e,t,r,n)=>g$e(e,{onFailure:o=>new Rn(r,n,o),onSuccess:t}),F$e=NUe,L$e=class extends aQ(KM,{typeConstructor:{_tag:"Date"},identifier:"DateFromSelf",schemaId:F$e,[F$e]:{noInvalidDate:!1},description:"a potentially invalid Date instance",pretty:()=>t=>`new Date(${JSON.stringify(t)})`,arbitrary:()=>t=>t.date({noInvalidDate:!1}),equivalence:()=>uEe}){},$Ft=e=>rS(e)||Hre(e),X$e=e=>Reflect.ownKeys(e).every(t=>$Ft(e[t])),Wre=e=>"fields"in e?e.fields:Wre(e[Y$e]),e2e=e=>X$e(e)?ss(e):rS(e)?e:ss(Wre(e)),t2e=e=>X$e(e)?e:Wre(e),HFt=e=>TFt(BFt(is(e)),()=>e),sS=e=>(t,r,n)=>{class o extends YI{}o.prototype.name=t;let i=t2e(r),s=e2e(r),a={_tag:HFt(t)},c=lW(a,i),u="message"in c;class l extends dW({kind:"TaggedError",identifier:e??t,schema:V$e(s,ss(a)),fields:c,Base:o,annotations:n,disableToString:!0}){static _tag=t}return u||Object.defineProperty(l.prototype,"message",{get(){return`{ ${Reflect.ownKeys(i).map(d=>`${Hg(d)}: ${uc(this[d])}`).join(", ")} }`},enumerable:!1,configurable:!0}),l},lW=(e,t)=>{let r={...e};for(let n of Reflect.ownKeys(t)){if(n in e)throw new Error(WH(n));r[n]=t[n]}return r};U$e=Te("effect/Schema/astCache",()=>new WeakMap),WFt=e=>e===void 0?[]:Array.isArray(e)?e:[e],dW=({Base:e,annotations:t,disableToString:r,fields:n,identifier:o,kind:i,schema:s})=>{let a=Symbol.for(`effect/Schema/${i}/${o}`),[c,u,l]=WFt(t),d=iQ(s),f=d.annotations({identifier:o,...c}),p=d.annotations({[Kb]:`${o} (Type side)`,...c}),m=s.annotations({[Kb]:`${o} (Constructor)`,...c}),g=s.annotations({[Kb]:`${o} (Encoded side)`,...l}),A=s.annotations({...l,...c,...u}),E=b=>se(b,a)&&vre(p)(b),y=class extends e{constructor(b={},w=!1){b={...b},i!=="Class"&&delete b._tag,b=G$e(n,b),jre(w)||(b=rQ(m)(b)),super(b,!0)}static[vy]=Qre;static get ast(){let b=U$e.get(this);if(b)return b;let w=aQ([s],{decode:()=>(I,v,k)=>I instanceof this||E(I)?J0(I):iW(new ia(k,I)),encode:()=>(I,v)=>I instanceof this?J0(I):ja(Ire(p)(I,v),k=>new this(k,!0))},{identifier:o,pretty:I=>v=>`${o}(${I(v)})`,arbitrary:I=>v=>I(v).map(k=>new this(k)),equivalence:be,[GD]:f.ast,...c});return b=uQ(g,w,{strict:!0,decode:I=>new this(I,!0),encode:be}).annotations({[GD]:A.ast,...u}).ast,U$e.set(this,b),b}static pipe(){return Z(this,arguments)}static annotations(b){return fo(this.ast).annotations(b)}static toString(){return`(${String(g)} <-> ${o})`}static make(...b){return new this(...b)}static fields={...n};static identifier=o;static extend(b){return(w,I)=>{let v=t2e(w),k=e2e(w),R=lW(n,v);return dW({kind:i,identifier:b,schema:V$e(s,k),fields:R,Base:this,annotations:I})}}static transformOrFail(b){return(w,I,v)=>{let k=lW(n,w);return dW({kind:i,identifier:b,schema:Mre(s,iQ(ss(k)),I),fields:k,Base:this,annotations:v})}}static transformOrFailFrom(b){return(w,I,v)=>{let k=lW(n,w);return dW({kind:i,identifier:b,schema:Mre(CFt(s),ss(k),I),fields:k,Base:this,annotations:v})}}get[a](){return a}};return r!==!0&&Object.defineProperty(y.prototype,"toString",{value(){return`${o}({ ${Reflect.ownKeys(n).map(b=>`${Hg(b)}: ${uc(this[b])}`).join(", ")} })`},configurable:!0,writable:!0}),y},jFt=ss({_tag:is("None")}).annotations({identifier:"FiberIdNoneEncoded"}),qFt=ss({_tag:is("Runtime"),id:EW,startTimeMillis:EW}).annotations({identifier:"FiberIdRuntimeEncoded"}),GFt=ss({_tag:is("Composite"),left:Pre(()=>Fre),right:Pre(()=>Fre)}).annotations({identifier:"FiberIdCompositeEncoded"}),Fre=cQ(jFt,qFt,GFt).annotations({identifier:"FiberIdEncoded"}),zFt=e=>e.letrec(t=>({None:e.record({_tag:e.constant("None")}),Runtime:e.record({_tag:e.constant("Runtime"),id:e.integer(),startTimeMillis:e.integer()}),Composite:e.record({_tag:e.constant("Composite"),left:t("FiberId"),right:t("FiberId")}),FiberId:e.oneof(t("None"),t("Runtime"),t("Composite"))})).FiberId.map(bW),Lre=e=>{switch(e._tag){case"None":return"FiberId.none";case"Runtime":return`FiberId.runtime(${e.id}, ${e.startTimeMillis})`;case"Composite":return`FiberId.composite(${Lre(e.right)}, ${Lre(e.left)})`}},bW=e=>{switch(e._tag){case"None":return ai;case"Runtime":return GSe(e.id,e.startTimeMillis);case"Composite":return zSe(bW(e.left),bW(e.right))}},VFt=e=>ss({_tag:is("Die"),defect:e}),YFt=ss({_tag:is("Empty")}),JFt=e=>ss({_tag:is("Fail"),error:e}),KFt=ss({_tag:is("Interrupt"),fiberId:Fre}),ZFt=0,Ure=(e,t)=>{let r=e,n=t,o=Pre(()=>i),i=cQ(YFt,JFt(r),VFt(n),KFt,ss({_tag:is("Sequential"),left:o,right:o}),ss({_tag:is("Parallel"),left:o,right:o})).annotations({title:`CauseEncoded<${SFt(e)}>`,[GH]:`CauseEncoded${ZFt++}`});return i},XFt=(e,t)=>r=>r.letrec(n=>({Empty:r.record({_tag:r.constant("Empty")}),Fail:r.record({_tag:r.constant("Fail"),error:e(r)}),Die:r.record({_tag:r.constant("Die"),defect:t(r)}),Interrupt:r.record({_tag:r.constant("Interrupt"),fiberId:zFt(r)}),Sequential:r.record({_tag:r.constant("Sequential"),left:n("Cause"),right:n("Cause")}),Parallel:r.record({_tag:r.constant("Parallel"),left:n("Cause"),right:n("Cause")}),Cause:r.oneof(n("Empty"),n("Fail"),n("Die"),n("Interrupt"),n("Sequential"),n("Parallel"))})).Cause.map(tS),eLt=e=>t=>{let r=n=>{switch(n._tag){case"Empty":return"Cause.empty";case"Fail":return`Cause.fail(${e(n.error)})`;case"Die":return`Cause.die(${VL(n)})`;case"Interrupt":return`Cause.interrupt(${Lre(n.fiberId)})`;case"Sequential":return`Cause.sequential(${r(n.left)}, ${r(n.right)})`;case"Parallel":return`Cause.parallel(${r(n.left)}, ${r(n.right)})`}};return r(t)},$$e=e=>(t,r,n)=>zwe(t)?UFt(e(K0(t),r),tS,n,t):iW(new ia(n,t)),tLt=({defect:e,error:t})=>aQ([t,e],{decode:(r,n)=>$$e(E$e(Ure(r,n))),encode:(r,n)=>$$e(Ire(Ure(r,n)))},{typeConstructor:{_tag:"effect/Cause"},title:`Cause<${t.ast}>`,pretty:eLt,arbitrary:XFt});r2e=({defect:e,error:t})=>{let r=t,n=e;return uQ(Ure(r,n),tLt({error:iQ(r),defect:iQ(n)}),{strict:!1,decode:i=>tS(i),encode:i=>K0(i)})},ip=class extends uQ(mW,mW,{strict:!0,decode:t=>{if(yi(t)&&"message"in t&&typeof t.message=="string"){let r=new Error(t.message,{cause:t});return"name"in t&&typeof t.name=="string"&&(r.name=t.name),r.stack="stack"in t&&typeof t.stack=="string"?t.stack:"",r}return HF(t)},encode:t=>t instanceof Error?{name:t.name,message:t.message}:HF(t)}).annotations({identifier:"Defect"}){}});var SW,CW,n2e,_s,rLt,Bh,Th=h(()=>{lh();X0();SW=Symbol.for("@effect/platform/Error"),CW=(e,t)=>{class r extends YI{_tag=t}return r.prototype[e]=e,r.prototype.name=t,r},n2e=is("Clipboard","Command","FileSystem","KeyValueStore","Path","Stream","Terminal"),_s=class extends sS("@effect/platform/Error/BadArgument")("BadArgument",{module:n2e,method:_d,description:iS(_d),cause:iS(ip)}){[SW]=SW;get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}},rLt=is("AlreadyExists","BadResource","Busy","InvalidData","NotFound","PermissionDenied","TimedOut","UnexpectedEof","Unknown","WouldBlock","WriteZero"),Bh=class extends sS("@effect/platform/Error/SystemError")("SystemError",{reason:rLt,module:n2e,method:_d,description:iS(_d),syscall:iS(_d),pathOrDescriptor:iS(cQ(_d,sQ)),cause:iS(ip)}){[SW]=SW;get message(){return`${this.reason}: ${this.module}.${this.method}${this.pathOrDescriptor!==void 0?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}});function a2e(e){let t={},r=e.length,n=0,o=0;for(;o!==r;){o=e.indexOf(";",n),o===-1&&(o=r);let i=e.indexOf("=",n);if(i===-1)break;if(i>o){n=o+1;continue}let s=e.substring(n,i++).trim();if(t[s]===void 0){let a=e.charCodeAt(i)===34?e.substring(i+1,o-1).trim():e.substring(i,o).trim();t[s]=a.indexOf("%")!==-1?aLt(a):a}n=o+1}return t}var o2e,i2e,oLt,iLt,sLt,s2e,Y8r,aLt,IW=h(()=>{ht();Me();E_();o2e=Symbol.for("@effect/platform/Cookies"),i2e=Symbol.for("@effect/platform/Cookies/Cookie"),oLt={[o2e]:o2e,...Am,toJSON(){return{_id:"@effect/platform/Cookies",cookies:Sm(this.cookies,e=>e.toJSON())}},pipe(){return Z(this,arguments)}},iLt=e=>{let t=Object.create(oLt);return t.cookies=e,t},sLt=e=>{let t={};for(let r of e)t[r.name]=r;return iLt(t)},s2e=sLt([]),Y8r={[i2e]:i2e,...Am,toJSON(){return{_id:"@effect/platform/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};aLt=e=>{try{return decodeURIComponent(e)}catch{return e}}});var c2e,Gre,zre,kW,cLt,uLt,vW=h(()=>{g0();mI();oe();yn();ht();Tre();c2e=Symbol.for("@effect/platform/Headers"),Gre=Object.assign(Object.create(null),{[c2e]:c2e,[d_](e){return cLt(this,d1(e,uLt))}}),zre=Object.create(Gre),kW=e=>{if(e===void 0)return zre;if(Symbol.iterator in e){let r=Object.create(Gre);for(let[n,o]of e)r[n.toLowerCase()]=o;return r}let t=Object.create(Gre);for(let[r,n]of Object.entries(e))Array.isArray(n)?t[r.toLowerCase()]=n.join(", "):n!==void 0&&(t[r.toLowerCase()]=n);return t},cLt=x(2,(e,t)=>{let r={...e},n=o=>{if(typeof o=="string"){let i=o.toLowerCase();i in e&&(r[i]=Bre(e[i]))}else for(let i in e)o.test(i)&&(r[i]=Bre(e[i]))};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),uLt=Te("@effect/platform/Headers/currentRedactedNames",()=>h0(["authorization","cookie","set-cookie","x-api-key"]))});var u2e=h(()=>{});var l2e,dQ,RW=h(()=>{Ei();it();l2e=Symbol.for("effect/Brand/Refined"),dQ=()=>Object.assign(e=>e,{[l2e]:l2e,option:e=>H(e),either:e=>Le(e),is:e=>!0})});var _W,fQ,d2e,Jre,Bd,f2e,p2e,m2e,h2e,g2e,ek,A2e,Ry,_y,pQ,aS=h(()=>{wD();Ob();_W=EPe,fQ=fD,d2e=xD,Jre=In,Bd=Et,f2e=nn,p2e=Vn,m2e=ea,h2e=q2,g2e=Yu,ek=Ju,A2e=Jf,Ry=rs,_y=cr,pQ=Kf});var y2e,x2e,E2e,b2e,S2e,C2e,rk=h(()=>{x7();y2e=h7,x2e=g7,E2e=jPe,b2e=J2,S2e=A7,C2e=qPe});var BW,sp,w2e,I2e,k2e,v2e,hQ,dLt,R2e,_2e,po,Kre,B2e,fLt,T2e=h(()=>{aS();vr();sr();nr();oe();zu();it();rk();wd();Th();BW=Jt("@effect/platform/FileSystem"),sp=e=>typeof e=="bigint"?e:BigInt(e),w2e=e=>sp(e*1024),I2e=e=>sp(e*1024*1024),k2e=e=>sp(e*1024*1024*1024),v2e=e=>sp(e*1024*1024*1024*1024),hQ=BigInt(1024),dLt=hQ*hQ*hQ*hQ*hQ,R2e=e=>sp(BigInt(e)*dLt),_2e=e=>BW.of({...e,exists:t=>C(e.access(t),ju(!0),W$("SystemError",r=>r.reason==="NotFound"?nt(!1):$e(r))),readFileString:(t,r)=>zT(e.readFile(t),{try:n=>new TextDecoder(r).decode(n),catch:n=>new _s({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:n})}),stream:(t,r)=>C(e.open(t,{flag:"r"}),r?.offset?Ri(n=>n.seek(r.offset,"start")):be,De(n=>fLt(n,r)),fy),sink:(t,r)=>C(e.open(t,{flag:"w",...r}),De(n=>b2e(o=>n.writeAll(o))),C2e),writeFileString:(t,r,n)=>Ee(Wu({try:()=>new TextEncoder().encode(r),catch:o=>new _s({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:o})}),o=>e.writeFile(t,o,n))}),po=(e,t)=>new Bh({module:"FileSystem",method:e,reason:"NotFound",description:"No such file or directory",pathOrDescriptor:t}),Kre=e=>({access(t){return $e(po("access",t))},chmod(t){return $e(po("chmod",t))},chown(t){return $e(po("chown",t))},copy(t){return $e(po("copy",t))},copyFile(t){return $e(po("copyFile",t))},exists(){return nt(!1)},link(t){return $e(po("link",t))},makeDirectory(){return Ua("not implemented")},makeTempDirectory(){return Ua("not implemented")},makeTempDirectoryScoped(){return Ua("not implemented")},makeTempFile(){return Ua("not implemented")},makeTempFileScoped(){return Ua("not implemented")},open(t){return $e(po("open",t))},readDirectory(t){return $e(po("readDirectory",t))},readFile(t){return $e(po("readFile",t))},readFileString(t){return $e(po("readFileString",t))},readLink(t){return $e(po("readLink",t))},realPath(t){return $e(po("realPath",t))},remove(){return ve},rename(t){return $e(po("rename",t))},sink(t){return x2e(po("sink",t))},stat(t){return $e(po("stat",t))},stream(t){return kD(po("stream",t))},symlink(t){return $e(po("symlink",t))},truncate(t){return $e(po("truncate",t))},utimes(t){return $e(po("utimes",t))},watch(t){return kD(po("watch",t))},writeFile(t){return $e(po("writeFile",t))},writeFileString(t){return $e(po("writeFileString",t))},...e}),B2e=e=>Ed(BW,Kre(e)),fLt=(e,{bufferSize:t=16,bytesToRead:r,chunkSize:n=sp(64*1024)}={})=>{let o=r!==void 0?sp(r):void 0,i=sp(n);function s(a){if(o!==void 0&&o<=a)return Ry;let c=o!==void 0&&o-a<i?o-a:i;return Bd(e.readAlloc(c),wt({onNone:()=>Ry,onSome:u=>Bd(_y(Dt(u)),l=>s(a+BigInt(u.length)))}))}return wMe(dy(s(BigInt(0))),{capacity:t})}});var mo={};tr(mo,{FileDescriptor:()=>Xre,FileSystem:()=>By,FileTypeId:()=>nk,GiB:()=>gLt,KiB:()=>mLt,MiB:()=>hLt,PiB:()=>yLt,Size:()=>Dh,TiB:()=>ALt,WatchBackend:()=>gQ,WatchEventCreate:()=>ene,WatchEventRemove:()=>rne,WatchEventUpdate:()=>tne,isFile:()=>bLt,layerNoop:()=>ELt,make:()=>Zre,makeNoop:()=>xLt});var Dh,mLt,hLt,gLt,ALt,yLt,By,Zre,xLt,ELt,nk,bLt,Xre,ene,tne,rne,gQ,AQ=h(()=>{RW();sr();lh();T2e();Dh=sp,mLt=w2e,hLt=I2e,gLt=k2e,ALt=v2e,yLt=R2e,By=BW,Zre=_2e,xLt=Kre,ELt=B2e,nk=Symbol.for("@effect/platform/FileSystem/File"),bLt=e=>typeof e=="object"&&e!==null&&nk in e,Xre=dQ(),ene=VI("Create"),tne=VI("Update"),rne=VI("Remove"),gQ=class extends Hw("@effect/platform/FileSystem/WatchBackend")(){}});var D2e,Q2e,nne=h(()=>{wr();D2e=e=>{let t=Q2e(e),r=[];for(let n=0;n<t.length;n++)if(Array.isArray(t[n][0])){let[o,i]=t[n];r.push([`${o[0]}[${o.slice(1).join("][")}]`,i])}else r.push(t[n]);return r},Q2e=e=>{let t=Symbol.iterator in e?_e(e):Object.entries(e),r=[];for(let[n,o]of t)if(Array.isArray(o))for(let i=0;i<o.length;i++)o[i]!==void 0&&r.push([n,String(o[i])]);else if(typeof o=="object"){let i=Q2e(o);for(let[s,a]of i)r.push([[n,...typeof s=="string"?[s]:s],a])}else o!==void 0&&r.push([n,String(o)]);return r}});var DW,TW,N2e,QW=h(()=>{sr();nr();ht();it();DW=Symbol.for("@effect/platform/HttpIncomingMessage"),TW=class extends si()("@effect/platform/HttpIncomingMessage/MaxBodySize",{defaultValue:W}){},N2e=(e,t)=>{let r=e.headers["content-type"]??"",n;if(r.includes("application/json"))try{n=xd(e.json)}catch{}else if(r.includes("text/")||r.includes("urlencoded"))try{n=xd(e.text)}catch{}let o={...t,headers:xw(e.headers),remoteAddress:e.remoteAddress.toJSON()};return n!==void 0&&(o.body=n),o}});var P2e=h(()=>{});var ine,sne,ane,M2e,F2e=h(()=>{ht();ine=Symbol.for("@effect/platform/HttpBody"),sne=class{[ine];constructor(){this[ine]=ine}[Ce](){return this.toJSON()}toString(){return Fe(this)}},ane=class extends sne{_tag="Empty";toJSON(){return{_id:"@effect/platform/HttpBody",_tag:"Empty"}}},M2e=new ane});var L2e=h(()=>{});var U2e=h(()=>{});var $2e=h(()=>{});var H2e=h(()=>{});var W2e=h(()=>{});var OW,_Lt,cne,j2e,q2e,G2e=h(()=>{nr();id();ht();IW();vW();F2e();OW=Symbol.for("@effect/platform/HttpServerResponse"),_Lt=Symbol.for("@effect/platform/HttpServerRespondable"),cne=class extends dI{status;statusText;cookies;body;[OW];headers;constructor(t,r,n,o,i){if(super(),this.status=t,this.statusText=r,this.cookies=o,this.body=i,this[OW]=OW,i.contentType||i.contentLength){let s={...n};i.contentType&&(s["content-type"]=i.contentType),i.contentLength&&(s["content-length"]=i.contentLength.toString()),this.headers=s}else this.headers=n}commit(){return nt(this)}[_Lt](){return nt(this)}[Ce](){return this.toJSON()}toString(){return Fe(this)}toJSON(){return{_id:"@effect/platform/HttpServerResponse",status:this.status,statusText:this.statusText,headers:xw(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}},j2e=e=>typeof e=="object"&&e!==null&&OW in e,q2e=e=>new cne(e?.status??204,e?.statusText,e?.headers?kW(e.headers):zre,e?.cookies??s2e,M2e)});var z2e,yQ,NW=h(()=>{G2e();z2e=j2e,yQ=q2e});var xQ,lne,PW=h(()=>{nr();NW();xQ=Symbol.for("@effect/platform/HttpServerRespondable"),lne=e=>z2e(e)?nt(e):Yf(e[xQ]())});var V2e,Y2e=h(()=>{V2e=Symbol.for("@effect/platform/HttpServerError")});var fne,ap,MW,J2e,FW=h(()=>{Th();PW();NW();Y2e();fne=V2e,ap=class extends CW(fne,"RequestError"){[xQ](){return yQ({status:400})}get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return this.description?`${this.reason}: ${this.description} (${this.methodAndUrl})`:`${this.reason} error (${this.methodAndUrl})`}},MW=class extends CW(fne,"RouteNotFound"){constructor(t){super(t),this.stack=`${this.name}: ${this.message}`}[xQ](){return yQ({status:404})}get message(){return`${this.request.method} ${this.request.url} not found`}},J2e=class extends CW(fne,"ResponseError"){[xQ](){return yQ({status:500})}get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return this.description?`${this.description} (${t})`:`${this.reason} error (${t})`}}});var $W,mne,cS,K2e,LW,UW,Z2e,hne,X2e,eHe,tHe=h(()=>{wr();Vs();vr();id();ht();it();Me();wD();Ob();vt();$W=Symbol.for("effect/Mailbox"),mne=Symbol.for("effect/Mailbox/ReadonlyMailbox"),cS=Ut(),K2e=Vt(cS),LW=Vt(!1),UW=Vt(!0),Z2e=[cS,!0],hne=class extends Ys{scheduler;capacity;strategy;[$W]=$W;[mne]=mne;state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set};messages=[];messagesChunk=Ut();constructor(t,r,n){super(),this.scheduler=t,this.capacity=r,this.strategy=n}offer(t){return ye(()=>{if(this.state._tag!=="Open")return LW;if(this.messages.length+this.messagesChunk.length>=this.capacity)switch(this.strategy){case"dropping":return LW;case"suspend":return this.capacity<=0&&this.state.takers.size>0?(this.messages.push(t),this.releaseTaker(),UW):this.offerRemainingSingle(t);case"sliding":return this.unsafeTake(),this.messages.push(t),UW}return this.messages.push(t),this.scheduleReleaseTaker(),UW})}unsafeOffer(t){return this.state._tag!=="Open"?!1:this.messages.length+this.messagesChunk.length>=this.capacity?this.strategy==="sliding"?(this.unsafeTake(),this.messages.push(t),!0):this.capacity<=0&&this.state.takers.size>0?(this.messages.push(t),this.releaseTaker(),!0):!1:(this.messages.push(t),this.scheduleReleaseTaker(),!0)}offerAll(t){return ye(()=>{if(this.state._tag!=="Open")return M(Co(t));let r=this.unsafeOfferAllArray(t);return r.length===0?K2e:this.strategy==="dropping"?M(ln(r)):this.offerRemainingArray(r)})}unsafeOfferAll(t){return ln(this.unsafeOfferAllArray(t))}unsafeOfferAllArray(t){if(this.state._tag!=="Open")return _e(t);if(this.capacity===Number.POSITIVE_INFINITY||this.strategy==="sliding")return this.messages.length>0&&(this.messagesChunk=Ir(this.messagesChunk,ln(this.messages))),this.strategy==="sliding"?this.messagesChunk=this.messagesChunk.pipe(Ir(Co(t)),w6(this.capacity)):S_(t)?this.messagesChunk=Ir(this.messagesChunk,t):this.messages=_e(t),this.scheduleReleaseTaker(),[];let r=this.capacity<=0?this.state.takers.size:this.capacity-this.messages.length-this.messagesChunk.length;if(r===0)return _e(t);let n=[],o=0;for(let i of t)o<r?this.messages.push(i):n.push(i),o++;return this.scheduleReleaseTaker(),n}fail(t){return this.done(nd(t))}failCause(t){return this.done($t(t))}unsafeDone(t){return this.state._tag!=="Open"?!1:this.state.offers.size===0&&this.messages.length===0&&this.messagesChunk.length===0?(this.finalize(t),!0):(this.state={...this.state,_tag:"Closing",exit:t},!0)}shutdown=V(()=>{if(this.state._tag==="Done")return!0;this.messages=[],this.messagesChunk=cS;let t=this.state.offers;if(this.finalize(this.state._tag==="Open"?Pn:this.state.exit),t.size>0){for(let r of t)r._tag==="Single"?r.resume(LW):r.resume(Vt(ln(r.remaining.slice(r.offset))));t.clear()}return!0});done(t){return V(()=>this.unsafeDone(t))}end=this.done(Pn);clear=ye(()=>{if(this.state._tag==="Done")return qE(this.state.exit,cS);let t=this.unsafeTakeAll();return this.releaseCapacity(),M(t)});takeAll=ye(()=>{if(this.state._tag==="Done")return qE(this.state.exit,Z2e);let t=this.unsafeTakeAll();return t.length===0?je(this.awaitTake,this.takeAll):M([t,this.releaseCapacity()])});takeN(t){return ye(()=>{if(this.state._tag==="Done")return qE(this.state.exit,Z2e);if(t<=0)return M([cS,!1]);t=Math.min(t,this.capacity);let r;if(t<=this.messagesChunk.length)r=Bw(this.messagesChunk,t),this.messagesChunk=jl(this.messagesChunk,t);else if(t<=this.messages.length+this.messagesChunk.length)this.messagesChunk=Ir(this.messagesChunk,ln(this.messages)),this.messages=[],r=Bw(this.messagesChunk,t),this.messagesChunk=jl(this.messagesChunk,t);else return je(this.awaitTake,this.takeN(t));return M([r,this.releaseCapacity()])})}unsafeTake(){if(this.state._tag==="Done")return $L(this.state.exit,nd(new Zwe));let t;if(this.messagesChunk.length>0)t=w_(this.messagesChunk),this.messagesChunk=jl(this.messagesChunk,1);else if(this.messages.length>0)t=this.messages[0],this.messagesChunk=jl(ln(this.messages),1),this.messages=[];else return this.capacity<=0&&this.state.offers.size>0?(this.capacity=1,this.releaseCapacity(),this.capacity=0,this.messages.length>0?Vt(this.messages.pop()):void 0):void 0;return this.releaseCapacity(),Vt(t)}take=ye(()=>this.unsafeTake()??je(this.awaitTake,this.take));await=_f(t=>this.state._tag==="Done"?t(this.state.exit):(this.state.awaiters.add(t),V(()=>{this.state._tag!=="Done"&&this.state.awaiters.delete(t)})));unsafeSize(){let t=this.messages.length+this.messagesChunk.length;return this.state._tag==="Done"?W():H(t)}size=V(()=>this.unsafeSize());commit(){return this.takeAll}pipe(){return Z(this,arguments)}toJSON(){return{_id:"effect/Mailbox",state:this.state._tag,size:this.unsafeSize().toJSON()}}toString(){return Fe(this)}[Ce](){return Fe(this)}offerRemainingSingle(t){return _f(r=>{if(this.state._tag!=="Open")return r(LW);let n={_tag:"Single",message:t,resume:r};return this.state.offers.add(n),V(()=>{this.state._tag==="Open"&&this.state.offers.delete(n)})})}offerRemainingArray(t){return _f(r=>{if(this.state._tag!=="Open")return r(Vt(ln(t)));let n={_tag:"Array",remaining:t,offset:0,resume:r};return this.state.offers.add(n),V(()=>{this.state._tag==="Open"&&this.state.offers.delete(n)})})}releaseCapacity(){if(this.state._tag==="Done")return this.state.exit._tag==="Success";if(this.state.offers.size===0)return this.state._tag==="Closing"&&this.messages.length===0&&this.messagesChunk.length===0?(this.finalize(this.state.exit),this.state.exit._tag==="Success"):!1;let t=this.capacity-this.messages.length-this.messagesChunk.length;for(let r of this.state.offers){if(t===0)return!1;if(r._tag==="Single")this.messages.push(r.message),t--,r.resume(UW),this.state.offers.delete(r);else{for(;r.offset<r.remaining.length;r.offset++){if(t===0)return!1;this.messages.push(r.remaining[r.offset]),t--}r.resume(K2e),this.state.offers.delete(r)}}return!1}awaitTake=_f(t=>this.state._tag==="Done"?t(this.state.exit):(this.state.takers.add(t),V(()=>{this.state._tag!=="Done"&&this.state.takers.delete(t)})));scheduleRunning=!1;scheduleReleaseTaker(){this.scheduleRunning||(this.scheduleRunning=!0,this.scheduler.scheduleTask(this.releaseTaker,0))}releaseTaker=()=>{if(this.scheduleRunning=!1,this.state._tag!=="Done"&&this.state.takers.size!==0){for(let t of this.state.takers)if(this.state.takers.delete(t),t(Pn),this.messages.length+this.messagesChunk.length===0)break}};unsafeTakeAll(){if(this.messagesChunk.length>0){let t=this.messages.length>0?Ir(this.messagesChunk,ln(this.messages)):this.messagesChunk;return this.messagesChunk=cS,this.messages=[],t}else if(this.messages.length>0){let t=ln(this.messages);return this.messages=[],t}else if(this.state._tag!=="Done"&&this.state.offers.size>0)return this.capacity=1,this.releaseCapacity(),this.capacity=0,Dt(this.messages.pop());return cS}finalize(t){if(this.state._tag==="Done")return;let r=this.state;this.state={_tag:"Done",exit:t};for(let n of r.takers)n(t);r.takers.clear();for(let n of r.awaiters)n(t);r.awaiters.clear()}},X2e=e=>st(t=>M(new hne(t.currentScheduler,typeof e=="number"?e:e?.capacity??Number.POSITIVE_INFINITY,typeof e=="number"?"suspend":e?.strategy??"suspend"))),eHe=e=>{let t=Et(e.takeAll,([r,n])=>n?r.length===0?rs:cr(r):Kf(cr(r),t));return t}});var QLt,rHe,ok,nHe,EQ=h(()=>{tHe();ct();QLt=$W,rHe=e=>se(e,QLt),ok=X2e,nHe=eHe});function jW(e,t=!1){if(typeof e!="string")return WW;let r=e.indexOf(";"),n=r!==-1?e.slice(0,r).trim():e.trim();if((t?NLt:OLt).test(n)===!1)return WW;let i={value:n.toLowerCase(),parameters:Object.create(null)};if(r===-1)return i;let s,a,c;for(oHe.lastIndex=r;a=oHe.exec(e);){if(a.index!==r)return WW;r+=a[0].length,s=a[1].toLowerCase(),c=a[2],c[0]==='"'&&(c=c.slice(1,c.length-1),!t&&iHe.test(c)&&(c=c.replace(iHe,"$1"))),i.parameters[s]=c}return r!==e.length?WW:i}var oHe,iHe,OLt,NLt,WW,sHe=h(()=>{oHe=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu,iHe=/\\([\v\u0020-\u00ff])/gu,OLt=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,NLt=/^[!#$%&'*+.^\w|~-]+$/u,WW={value:"",parameters:Object.create(null)}});function aHe(){let e=new TextDecoder,t={state:sl.key,headers:Object.create(null),key:"",value:void 0,crlf:0,previousChunk:void 0,pairs:0,size:0};function r(i){return t.state=sl.key,t.headers=Object.create(null),t.key="",t.value=void 0,t.crlf=0,t.previousChunk=void 0,t.pairs=0,t.size=0,i}function n(i,s){let a=new Uint8Array(i.length+s.length);return a.set(i),a.set(s,i.length),a}function o(i){return r({_tag:"Failure",reason:i,headers:t.headers})}return function(s,a){let c=0,u;if(t.previousChunk!==void 0){c=t.previousChunk.length,u=c;let d=new Uint8Array(s.length+c);d.set(t.previousChunk),d.set(s,c),t.previousChunk=void 0,s=d}let l=s.length;e:for(;a<l;){if(t.state===sl.key){let d=a;for(;d<l;d++){if(t.size++>16384)return o("HeaderTooLarge");if(s[d]===58){if(t.key+=e.decode(s.subarray(a,d)).toLowerCase(),t.key.length===0)return o("InvalidHeaderName");s[d+1]===32&&s[d+2]!==32&&s[d+2]!==9?(a=d+2,t.state=sl.value,t.size++):s[d+1]!==32&&s[d+1]!==9?(a=d+1,t.state=sl.value):(a=d+1,t.state=sl.whitespace);break}else if(MLt[s[d]]!==1)return o("InvalidHeaderName")}if(d===l)return t.key+=e.decode(s.subarray(a,l)).toLowerCase(),bQ}if(t.state===sl.whitespace){for(;a<l;a++){if(t.size++>16384)return o("HeaderTooLarge");if(s[a]!==32&&s[a]!==9){t.state=sl.value;break}}if(a===l)return bQ}if(t.state===sl.value){let d=a;for(u!==void 0&&(d=u,u=void 0);d<l;d++){if(t.size++>16384)return o("HeaderTooLarge");if(s[d]===13||t.crlf>0){let f=s[d];if(f===13&&t.crlf===0&&(t.crlf=1,d++,t.size++,f=s[d]),f===10&&t.crlf===1&&(t.crlf=2,d++,t.size++,f=s[d]),f===13&&t.crlf===2&&(t.crlf=3,d++,t.size++,f=s[d]),f===10&&t.crlf===3&&(t.crlf=4,d++,t.size++),t.crlf<4&&d>=l)return t.previousChunk=s.subarray(a),bQ;if(t.crlf>=2){t.value=t.value===void 0?s.subarray(a,d-t.crlf):n(t.value,s.subarray(a,d-t.crlf));let p=e.decode(t.value);if(t.headers[t.key]===void 0?t.headers[t.key]=p:typeof t.headers[t.key]=="string"?t.headers[t.key]=[t.headers[t.key],p]:t.headers[t.key].push(p),a=d,t.size--,t.crlf!==4&&t.pairs===100)return o("TooManyHeaders");if(t.crlf===3)return o("InvalidHeaderValue");if(t.crlf===4)return r({_tag:"Headers",headers:t.headers,endPosition:a-c});t.pairs++,t.key="",t.value=void 0,t.crlf=0,t.state=sl.key;continue e}}else if(FLt[s[d]]!==1)return o("InvalidHeaderValue")}if(d===l)return t.value=t.value===void 0?s.subarray(a,l):n(t.value,s.subarray(a,l)),bQ}}return a>l&&(t.size+=l-a),bQ}}var sl,bQ,MLt,FLt,cHe=h(()=>{(function(e){e[e.key=0]="key",e[e.whitespace=1]="whitespace",e[e.value=2]="value"})(sl||(sl={}));bQ={_tag:"Continue"},MLt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1],FLt=[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]});function ULt(e){let t=new TextEncoder().encode(e),r=t.length,n={};for(let o=0;o<r;o++){let i=t[o];n[i]===void 0&&(n[i]=[]),n[i].push(o)}return{needle:t,needleLength:r,indexes:n,firstByte:t[0],previousChunk:void 0,previousChunkLength:0,matchIndex:0}}function uHe(e,t,r){let n=ULt(e);r!==void 0&&(n.previousChunk=r,n.previousChunkLength=r.length);function o(){if("Buffer"in globalThis&&!("Bun"in globalThis||"Deno"in globalThis))return function(u,l,d){return Buffer.prototype.indexOf.call(u,l,d)};let c=new Uint8Array(256).fill(n.needle.length);for(let u=0,l=n.needle.length-1;u<l;++u)c[n.needle[u]]=l-u;return function(u,l,d){let f=u.length,p=d+n.needleLength-1;for(;p<f;){for(let m=n.needleLength-1,g=p;m>=0&&u[g]===l[m];m--,g--)if(m===0)return g;p+=c[u[p]]}return-1}}let i=o();function s(c){let u=c.length;if(n.previousChunk!==void 0){let d=new Uint8Array(n.previousChunkLength+u);d.set(n.previousChunk),d.set(c,n.previousChunkLength),c=d,u=n.previousChunkLength+u,n.previousChunk=void 0}if(u<n.needleLength){n.previousChunk=c,n.previousChunkLength=u;return}let l=0;for(;l<u;){let d=i(c,n.needle,l);if(d>-1){d>l&&t(n.matchIndex,c.subarray(l,d)),n.matchIndex+=1,l=d+n.needleLength;continue}else if(c[u-1]in n.indexes){let f=n.indexes[c[u-1]],p=-1;for(let m=0,g=f.length;m<g;m++){let A=f[m];c[u-1-A]===n.firstByte&&m>p&&(p=A)}p===-1?l===0?t(n.matchIndex,c):t(n.matchIndex,c.subarray(l)):(u-1-p>l&&t(n.matchIndex,c.subarray(l,u-1-p)),n.previousChunk=c.subarray(u-1-p),n.previousChunkLength=p+1)}else l===0?t(n.matchIndex,c):t(n.matchIndex,c.subarray(l));break}}function a(){n.previousChunk!==void 0&&n.previousChunk!==r&&t(n.matchIndex,n.previousChunk),n.previousChunk=r,n.previousChunkLength=r?.length??0,n.matchIndex=0}return{write:s,end:a}}var lHe=h(()=>{});function gne(e){return e.filename!==void 0||e.contentType==="application/octet-stream"}function VLt(e){return jW(e["content-type"]).parameters.boundary}function qW(e){}function pHe({headers:e,onFile:t,onField:r,onError:n,onDone:o,isFile:i=gne,maxParts:s=1/0,maxTotalSize:a=1/0,maxPartSize:c=1/0,maxFieldSize:u=1024*1024}){let l=VLt(e);if(l===void 0)return n({_tag:"InvalidBoundary"}),{write:qW,end(){}};let d={state:Qh.headers,index:0,parts:0,onChunk:qW,info:void 0,headerSkip:0,partSize:0,totalSize:0,isFile:!1,fieldChunks:[],fieldSize:0};function f(){d.state=Qh.body,d.isFile=!0,d.onChunk=qW}let p=aHe(),m=uHe(`\r
68
+ schema (${n._tag}): ${n}`),o},Bte=(e,t,r)=>wy("Unsupported schema or overlapping types",`cannot extend ${e} with ${t}`,r),BUe=e=>wy("Unsupported key schema",void 0,void 0,e),TUe=e=>wy("Unsupported literal",`literal value: ${uc(e)}`),Tte=e=>wy("Duplicate index signature",`${e} index signature`),DUe=wy("Unsupported index signature parameter","An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),QUe=wy("Invalid element","A required element cannot follow an optional element. ts(1257)"),Dte=e=>wy("Duplicate property signature transformation",`Duplicate key ${uc(e)}`),WH=e=>wy("Duplicate property signature",`Duplicate key ${uc(e)}`)});var NUe,PUe,MUe=h(()=>{NUe=Symbol.for("effect/SchemaId/DateFromSelf"),PUe=Symbol.for("effect/SchemaId/Int")});function ol(e,t){let r=!1,n=bE(e.length);for(let o=0;o<e.length;o++){let i=e[o],s=t(i);s!==i&&(r=!0),n[o]=s}return r?n:e}function iFt(e){return wt(jUe(e),{onNone:()=>"",onSome:t=>t.map(r=>` & Brand<${uc(r)}>`).join("")})}var LUe,UUe,$Ue,Vte,qH,G0,Wa,Kb,kh,Yte,Jte,Kte,Zte,Xte,ere,HUe,tre,rre,nre,ore,ire,GD,WUe,Rs,jUe,qUe,GUe,sre,are,z0,cre,zUe,VUe,YUe,JUe,KUe,ure,WMt,lre,GH,jMt,qMt,zb,vh,Vb,Zb,WD,Nte,zH,Pte,ZUe,Mte,VH,Fte,dre,Lte,XUe,Ute,YH,JH,$te,KH,fre,Hte,pre,mre,Wte,GMt,jte,zMt,e$e,qte,VMt,j0,wh,t$e,jD,YMt,To,r$e,Yb,il,FUe,JMt,hre,KMt,ZMt,n$e,XMt,os,o$e,ZH,V0,Ote,Iy,Jb,ky,XH,Ih,i$e,qD,eFt,Gte,s$e,jH,q0,gre,zD,tFt,rFt,a$e,nFt,c$e,u$e,Are,yre,l$e,oFt,lo,zte,np,VD,Yn,xre,vd,d$e,op,YD=h(()=>{wr();oe();yn();ht();Qte();HD();Lm();it();bm();ct();KL();LUe=Symbol.for("effect/annotation/TypeConstructor"),UUe=Symbol.for("effect/annotation/Brand"),$Ue=Symbol.for("effect/annotation/SchemaId"),Vte=Symbol.for("effect/annotation/Message"),qH=Symbol.for("effect/annotation/MissingMessage"),G0=Symbol.for("effect/annotation/Identifier"),Wa=Symbol.for("effect/annotation/Title"),Kb=Symbol.for("effect/annotation/AutoTitle"),kh=Symbol.for("effect/annotation/Description"),Yte=Symbol.for("effect/annotation/Examples"),Jte=Symbol.for("effect/annotation/Default"),Kte=Symbol.for("effect/annotation/JSONSchema"),Zte=Symbol.for("effect/annotation/Arbitrary"),Xte=Symbol.for("effect/annotation/Pretty"),ere=Symbol.for("effect/annotation/Equivalence"),HUe=Symbol.for("effect/annotation/Documentation"),tre=Symbol.for("effect/annotation/Concurrency"),rre=Symbol.for("effect/annotation/Batching"),nre=Symbol.for("effect/annotation/ParseIssueTitle"),ore=Symbol.for("effect/annotation/ParseOptions"),ire=Symbol.for("effect/annotation/DecodingFallback"),GD=Symbol.for("effect/annotation/Surrogate"),WUe=Symbol.for("effect/annotation/StableFilter"),Rs=x(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?H(e.annotations[t]):W()),jUe=Rs(UUe),qUe=Rs(Vte),GUe=Rs(qH),sre=Rs(Wa),are=Rs(Kb),z0=Rs(G0),cre=Rs(kh),zUe=Rs(tre),VUe=Rs(rre),YUe=Rs(nre),JUe=Rs(ore),KUe=Rs(ire),ure=Rs(GD),WMt=Rs(WUe),lre=e=>a6(WMt(e),t=>t===!0),GH=Symbol.for("effect/annotation/JSONIdentifier"),jMt=Rs(GH),qMt=e=>lc(jMt(e),()=>z0(e)),zb=class{typeParameters;decodeUnknown;encodeUnknown;annotations;_tag="Declaration";constructor(t,r,n,o={}){this.typeParameters=t,this.decodeUnknown=r,this.encodeUnknown=n,this.annotations=o}toString(){return Nt(op(this),()=>"<declaration schema>")}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map(t=>t.toJSON()),annotations:Yn(this.annotations)}}},vh=e=>t=>t._tag===e,Vb=class{literal;annotations;_tag="Literal";constructor(t,r={}){this.literal=t,this.annotations=r}toString(){return Nt(op(this),()=>uc(this.literal))}toJSON(){return{_tag:this._tag,literal:$g(this.literal)?String(this.literal):this.literal,annotations:Yn(this.annotations)}}},Zb=vh("Literal"),WD=class{symbol;annotations;_tag="UniqueSymbol";constructor(t,r={}){this.symbol=t,this.annotations=r}toString(){return Nt(op(this),()=>uc(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:Yn(this.annotations)}}},Nte=class{annotations;_tag="UndefinedKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},zH=new Nte({[Wa]:"undefined"}),Pte=class{annotations;_tag="VoidKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},ZUe=new Pte({[Wa]:"void"}),Mte=class{annotations;_tag="NeverKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},VH=new Mte({[Wa]:"never"}),Fte=class{annotations;_tag="UnknownKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},dre=new Fte({[Wa]:"unknown"}),Lte=class{annotations;_tag="AnyKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},XUe=new Lte({[Wa]:"any"}),Ute=class{annotations;_tag="StringKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},YH=new Ute({[Wa]:"string",[kh]:"a string"}),JH=vh("StringKeyword"),$te=class{annotations;_tag="NumberKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},KH=new $te({[Wa]:"number",[kh]:"a number"}),fre=vh("NumberKeyword"),Hte=class{annotations;_tag="BooleanKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},pre=new Hte({[Wa]:"boolean",[kh]:"a boolean"}),mre=vh("BooleanKeyword"),Wte=class{annotations;_tag="BigIntKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},GMt=new Wte({[Wa]:"bigint",[kh]:"a bigint"}),jte=class{annotations;_tag="SymbolKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},zMt=new jte({[Wa]:"symbol",[kh]:"a symbol"}),e$e=vh("SymbolKeyword"),qte=class{annotations;_tag="ObjectKeyword";constructor(t={}){this.annotations=t}toString(){return vd(this)}toJSON(){return{_tag:this._tag,annotations:Yn(this.annotations)}}},VMt=new qte({[Wa]:"object",[kh]:"an object in the TypeScript meaning, i.e. the `object` type"}),j0=class{type;annotations;constructor(t,r={}){this.type=t,this.annotations=r}toJSON(){return{type:this.type.toJSON(),annotations:Yn(this.annotations)}}toString(){return String(this.type)}},wh=class extends j0{isOptional;constructor(t,r,n={}){super(t,n),this.isOptional=r}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:Yn(this.annotations)}}toString(){return String(this.type)+(this.isOptional?"?":"")}},t$e=e=>e.map(t=>t.type),jD=class{elements;rest;isReadonly;annotations;_tag="TupleType";constructor(t,r,n,o={}){this.elements=t,this.rest=r,this.isReadonly=n,this.annotations=o;let i=!1,s=!1;for(let a of t)if(a.isOptional)i=!0;else if(i){s=!0;break}if(s||i&&r.length>1)throw new Error(QUe)}toString(){return Nt(op(this),()=>YMt(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map(t=>t.toJSON()),rest:this.rest.map(t=>t.toJSON()),isReadonly:this.isReadonly,annotations:Yn(this.annotations)}}},YMt=e=>{let t=e.elements.map(String).join(", ");return nbe(e.rest,{onEmpty:()=>`readonly [${t}]`,onNonEmpty:(r,n)=>{let o=String(r),i=o.includes(" | ")?`(${o})`:o;if(n.length>0){let s=n.map(String).join(", ");return e.elements.length>0?`readonly [${t}, ...${i}[], ${s}]`:`readonly [...${i}[], ${s}]`}else return e.elements.length>0?`readonly [${t}, ...${i}[]]`:`ReadonlyArray<${o}>`}})},To=class extends wh{name;isReadonly;constructor(t,r,n,o,i){super(r,n,i),this.name=t,this.isReadonly=o}toString(){return(this.isReadonly?"readonly ":"")+String(this.name)+(this.isOptional?"?":"")+": "+this.type}toJSON(){return{name:String(this.name),type:this.type.toJSON(),isOptional:this.isOptional,isReadonly:this.isReadonly,annotations:Yn(this.annotations)}}},r$e=e=>{switch(e._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return!0;case"Refinement":return r$e(e.from)}return!1},Yb=class{type;isReadonly;parameter;constructor(t,r,n){if(this.type=r,this.isReadonly=n,r$e(t))this.parameter=t;else throw new Error(DUe)}toString(){return(this.isReadonly?"readonly ":"")+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}},il=class{annotations;_tag="TypeLiteral";propertySignatures;indexSignatures;constructor(t,r,n={}){this.annotations=n;let o={};for(let s=0;s<t.length;s++){let a=t[s].name;if(Object.prototype.hasOwnProperty.call(o,a))throw new Error(WH(a));o[a]=null}let i={string:!1,symbol:!1};for(let s=0;s<r.length;s++){let a=xre(r[s].parameter);if(JH(a)){if(i.string)throw new Error(Tte("string"));i.string=!0}else if(e$e(a)){if(i.symbol)throw new Error(Tte("symbol"));i.symbol=!0}}this.propertySignatures=t,this.indexSignatures=r}toString(){return Nt(op(this),()=>JMt(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map(t=>t.toJSON()),indexSignatures:this.indexSignatures.map(t=>t.toJSON()),annotations:Yn(this.annotations)}}},FUe=e=>e.map(String).join("; "),JMt=e=>{if(e.propertySignatures.length>0){let t=e.propertySignatures.map(String).join("; ");return e.indexSignatures.length>0?`{ ${t}; ${FUe(e.indexSignatures)} }`:`{ ${t} }`}else return e.indexSignatures.length>0?`{ ${FUe(e.indexSignatures)} }`:"{}"},hre=vh("TypeLiteral"),KMt=Vi(yf(oo,e=>{switch(e._tag){case"AnyKeyword":return 0;case"UnknownKeyword":return 1;case"ObjectKeyword":return 2;case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":return 3}return 4})),ZMt={string:"StringKeyword",number:"NumberKeyword",boolean:"BooleanKeyword",bigint:"BigIntKeyword"},n$e=e=>SE(e,t=>V0(t)?n$e(t.types):[t]),XMt=e=>{let t=KMt(e),r=[],n={},o=[];for(let i of t)switch(i._tag){case"NeverKeyword":break;case"AnyKeyword":return[XUe];case"UnknownKeyword":return[dre];case"ObjectKeyword":case"UndefinedKeyword":case"VoidKeyword":case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":{n[i._tag]||(n[i._tag]=i,r.push(i));break}case"Literal":{let s=typeof i.literal;switch(s){case"string":case"number":case"bigint":case"boolean":{let a=ZMt[s];!n[a]&&!o.includes(i.literal)&&(o.push(i.literal),r.push(i));break}case"object":{o.includes(i.literal)||(o.push(i.literal),r.push(i));break}}break}case"UniqueSymbol":{!n.SymbolKeyword&&!o.includes(i.symbol)&&(o.push(i.symbol),r.push(i));break}case"TupleType":{n.ObjectKeyword||r.push(i);break}case"TypeLiteral":{i.propertySignatures.length===0&&i.indexSignatures.length===0?n["{}"]||(n["{}"]=i,r.push(i)):n.ObjectKeyword||r.push(i);break}default:r.push(i)}return r},os=class e{types;annotations;static make=(t,r)=>ZH(t)?new e(t,r):t.length===1?t[0]:VH;static unify=(t,r)=>e.make(XMt(n$e(t)),r);_tag="Union";constructor(t,r={}){this.types=t,this.annotations=r}toString(){return Nt(op(this),()=>this.types.map(String).join(" | "))}toJSON(){return{_tag:this._tag,types:this.types.map(t=>t.toJSON()),annotations:Yn(this.annotations)}}},o$e=(e,t)=>e.map(t),ZH=e=>e.length>1,V0=vh("Union"),Ote=Te(Symbol.for("effect/Schema/AST/toJSONMemoMap"),()=>new WeakMap),Iy=class{f;annotations;_tag="Suspend";constructor(t,r={}){this.f=t,this.annotations=r,this.f=$D(t)}toString(){return op(this).pipe(lc(()=>Gn(EE(this.f)(),t=>op(t))),Nt(()=>"<suspended schema>"))}toJSON(){let t=this.f(),r=Ote.get(t);return r||(Ote.set(t,{_tag:this._tag}),r={_tag:this._tag,ast:t.toJSON(),annotations:Yn(this.annotations)},Ote.set(t,r),r)}},Jb=class{from;filter;annotations;_tag="Refinement";constructor(t,r,n={}){this.from=t,this.filter=r,this.annotations=n}toString(){return z0(this).pipe(Nt(()=>wt(d$e(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:t=>ky(this.from)?String(this.from)+" & "+t:t})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:Yn(this.annotations)}}},ky=vh("Refinement"),XH={},Ih=class{from;to;transformation;annotations;_tag="Transformation";constructor(t,r,n,o={}){this.from=t,this.to=r,this.transformation=n,this.annotations=o}toString(){return Nt(op(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:Yn(this.annotations)}}},i$e=vh("Transformation"),qD=class{decode;encode;_tag="FinalTransformation";constructor(t,r){this.decode=t,this.encode=r}},eFt=e=>t=>t._tag===e,Gte=class{_tag="ComposeTransformation"},s$e=new Gte,jH=class{from;to;decode;encode;constructor(t,r,n,o){this.from=t,this.to=r,this.decode=n,this.encode=o}},q0=class{propertySignatureTransformations;_tag="TypeLiteralTransformation";constructor(t){this.propertySignatureTransformations=t;let r={},n={};for(let o of t){let i=o.from;if(r[i])throw new Error(Dte(i));r[i]=!0;let s=o.to;if(n[s])throw new Error(Dte(s));n[s]=!0}}},gre=eFt("TypeLiteralTransformation"),zD=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={...e.annotations};delete n[G0];let o={...n,...t},i=ure(e);return pt(i)&&(o[GD]=zD(i.value,t)),r.annotations.value=o,Object.create(Object.getPrototypeOf(e),r)},tFt="[\\s\\S]*?",rFt="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?",a$e=(e,t)=>{switch(e._tag){case"Literal":return aI(String(e.literal));case"StringKeyword":return tFt;case"NumberKeyword":return rFt;case"TemplateLiteral":return c$e(e,t,!1);case"Union":return e.types.map(r=>a$e(r,t)).join("|")}},nFt=(e,t,r,n)=>{if(V0(e)){if(r&&!n)return`(?:${t})`}else if(!r||!n)return t;return`(${t})`},c$e=(e,t,r)=>{let n="";if(e.head!==""){let o=aI(e.head);n+=t&&r?`(${o})`:o}for(let o of e.spans){let i=a$e(o.type,t);if(n+=nFt(o.type,i,t,r),o.literal!==""){let s=aI(o.literal);n+=t&&r?`(${s})`:s}}return n},u$e=e=>new RegExp(`^${c$e(e,!1,!0)}$`),Are=(e,t)=>{let r=[],n=[],o=i=>{switch(i._tag){case"NeverKeyword":break;case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":case"Refinement":n.push(new Yb(i,t,!0));break;case"Literal":if(Fo(i.literal)||Ls(i.literal))r.push(new To(i.literal,t,!1,!0));else throw new Error(TUe(i.literal));break;case"Enums":{for(let[s,a]of i.enums)r.push(new To(a,t,!1,!0));break}case"UniqueSymbol":r.push(new To(i.symbol,t,!1,!0));break;case"Union":i.types.forEach(o);break;default:throw new Error(BUe(i))}};return o(e),{propertySignatures:r,indexSignatures:n}},yre=e=>t=>{let r;for(let n of e)Object.prototype.hasOwnProperty.call(t.annotations,n)&&(r===void 0&&(r={}),r[n]=t.annotations[n]);return r},l$e=e=>t=>{let r={...t.annotations};for(let n of e)delete r[n];return r},oFt=yre([Yte,Jte,Kte,Zte,Xte,ere]),lo=e=>{switch(e._tag){case"Declaration":{let t=ol(e.typeParameters,lo);return t===e.typeParameters?e:new zb(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case"TupleType":{let t=ol(e.elements,o=>{let i=lo(o.type);return i===o.type?o:new wh(i,o.isOptional)}),r=t$e(e.rest),n=ol(r,lo);return t===e.elements&&n===r?e:new jD(t,n.map(o=>new j0(o)),e.isReadonly,e.annotations)}case"TypeLiteral":{let t=ol(e.propertySignatures,n=>{let o=lo(n.type);return o===n.type?n:new To(n.name,o,n.isOptional,n.isReadonly)}),r=ol(e.indexSignatures,n=>{let o=lo(n.type);return o===n.type?n:new Yb(n.parameter,o,n.isReadonly)});return t===e.propertySignatures&&r===e.indexSignatures?e:new il(t,r,e.annotations)}case"Union":{let t=ol(e.types,lo);return t===e.types?e:os.make(t,e.annotations)}case"Suspend":return new Iy(()=>lo(e.f()),e.annotations);case"Refinement":{let t=lo(e.from);return t===e.from?e:new Jb(t,e.filter,e.annotations)}case"Transformation":{let t=oFt(e);return lo(t!==void 0?zD(e.to,t):e.to)}}return e};zte=e=>{switch(e._tag){case"Transformation":return e.from;case"Refinement":return zte(e.from);case"Suspend":return zte(e.f())}},np=(e,t)=>{switch(e._tag){case"Declaration":{let r=ol(e.typeParameters,n=>np(n,t));return r===e.typeParameters?e:new zb(r,e.decodeUnknown,e.encodeUnknown)}case"TupleType":{let r=ol(e.elements,i=>{let s=np(i.type,t);return s===i.type?i:new wh(s,i.isOptional)}),n=t$e(e.rest),o=ol(n,i=>np(i,t));return r===e.elements&&o===n?e:new jD(r,o.map(i=>new j0(i)),e.isReadonly)}case"TypeLiteral":{let r=ol(e.propertySignatures,o=>{let i=np(o.type,t);return i===o.type?o:new To(o.name,i,o.isOptional,o.isReadonly)}),n=ol(e.indexSignatures,o=>{let i=np(o.type,t);return i===o.type?o:new Yb(o.parameter,i,o.isReadonly)});return r===e.propertySignatures&&n===e.indexSignatures?e:new il(r,n)}case"Union":{let r=ol(e.types,n=>np(n,t));return r===e.types?e:os.make(r)}case"Suspend":{let r,n=qMt(e);if(pt(n)){let o=t?"Bound":"";r={[GH]:`${n.value}Encoded${o}`}}return new Iy(()=>np(e.f(),t),r)}case"Refinement":{let r=np(e.from,t);return t?r===e.from?e:zte(e.from)===void 0&&lre(e)?new Jb(r,e.filter,e.annotations):r:r}case"Transformation":return np(e.from,t)}return e},VD=e=>np(e,!1),Yn=e=>{let t={};for(let r of Object.getOwnPropertySymbols(e))t[String(r)]=e[r];return t},xre=e=>{switch(e._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return e;case"Refinement":return xre(e.from)}},vd=e=>Nt(op(e),()=>e._tag);d$e=e=>sre(e).pipe(lc(()=>cre(e)),lc(()=>are(e)),dr(t=>t+iFt(e))),op=e=>lc(z0(e),()=>d$e(e))});function Rd(e){return e.sort(lFt).map(t=>t[1])}function gFt(e){return cre(e).pipe(lc(()=>sre(e)),lc(()=>are(e)),lc(()=>z0(e)),Nt(()=>`{ ${e.from} | filter }`))}function AFt(e){return e.message!==void 0?e.message:`Expected ${ky(e.ast)?gFt(e.ast):String(e.ast)}, actual ${uc(e.actual)}`}var Xo,nW,Xb,Rn,ZD,XD,ia,oW,f$e,Sre,h$e,J0,iW,oa,Rh,ja,rW,g$e,A$e,sW,sFt,wre,y$e,x$e,E$e,b$e,Ire,kre,rQ,vre,Rre,aFt,cFt,Di,Ere,bre,uFt,Dc,JD,S$e,C$e,KD,lFt,dFt,na,eQ,fFt,w$e,pFt,mFt,I$e,Cre,hFt,_re,k$e,p$e,m$e,tQ,v$e,yFt,tW,xFt,EFt,bFt,Y0,aW=h(()=>{wr();Vs();lh();nr();bi();Ro();oe();yn();ht();HD();it();ct();PA();YD();Xo=class{path;actual;issue;_tag="Pointer";constructor(t,r,n){this.path=t,this.actual=r,this.issue=n}},nW=class{actual;message;_tag="Unexpected";constructor(t,r){this.actual=t,this.message=r}},Xb=class{ast;message;_tag="Missing";actual=void 0;constructor(t,r){this.ast=t,this.message=r}},Rn=class{ast;actual;issues;output;_tag="Composite";constructor(t,r,n,o){this.ast=t,this.actual=r,this.issues=n,this.output=o}},ZD=class{ast;actual;kind;issue;_tag="Refinement";constructor(t,r,n,o){this.ast=t,this.actual=r,this.kind=n,this.issue=o}},XD=class{ast;actual;kind;issue;_tag="Transformation";constructor(t,r,n,o){this.ast=t,this.actual=r,this.kind=n,this.issue=o}},ia=class{ast;actual;message;_tag="Type";constructor(t,r,n){this.ast=t,this.actual=r,this.message=n}},oW=class{ast;actual;message;_tag="Forbidden";constructor(t,r,n){this.ast=t,this.actual=r,this.message=n}},f$e=Symbol.for("effect/Schema/ParseErrorTypeId"),Sre=class extends uh("ParseError"){[f$e]=f$e;get message(){return this.toString()}toString(){return eQ.formatIssueSync(this.issue)}toJSON(){return{_id:"ParseError",message:this.toString()}}[Ce](){return this.toJSON()}},h$e=e=>new Sre({issue:e}),J0=Le,iW=Re,oa=MEe,Rh=x(2,(e,t)=>oa(e)?Ei(e,{onLeft:Re,onRight:t}):Ee(e,t)),ja=x(2,(e,t)=>oa(e)?lF(e,t):De(e,t)),rW=x(2,(e,t)=>oa(e)?LEe(e,t):Ha(e,t)),g$e=x(2,(e,t)=>oa(e)?FEe(e,{onLeft:t.onFailure,onRight:t.onSuccess}):VT(e,t)),A$e=x(2,(e,t)=>oa(e)?Ei(e,{onLeft:t,onRight:Le}):s0(e,t)),sW=(e,t)=>t===void 0||Ls(t)?e:e===void 0?t:{...e,...t},sFt=(e,t,r)=>{let n=Di(e,t);return(o,i)=>n(o,sW(r,i))},wre=(e,t,r)=>{let n=sFt(e,t,r);return(o,i)=>y_(n(o,i),h$e)},y$e=(e,t,r)=>{let n=Di(e,t);return(o,i)=>n(o,{...sW(r,i),isEffectAllowed:!0})},x$e=(e,t)=>wre(e.ast,!0,t),E$e=(e,t)=>y$e(e.ast,!0,t),b$e=(e,t)=>wre(e.ast,!1,t),Ire=(e,t)=>y$e(e.ast,!1,t),kre=x$e,rQ=(e,t)=>wre(lo(e.ast),!0,t),vre=(e,t)=>{let r=Di(lo(e.ast),!0);return(n,o)=>si(r(n,{exact:!0,...sW(t,o)}))},Rre=b$e,aFt=Te(Symbol.for("effect/ParseResult/decodeMemoMap"),()=>new WeakMap),cFt=Te(Symbol.for("effect/ParseResult/encodeMemoMap"),()=>new WeakMap),Di=(e,t)=>{let r=t?aFt:cFt,n=r.get(e);if(n)return n;let o=uFt(e,t),i=JUe(e),s=pt(i)?(u,l)=>o(u,sW(l,i.value)):o,a=KUe(e),c=t&&pt(a)?(u,l)=>KD(A$e(s(u,l),a.value),e,u,l):s;return r.set(e,c),c},Ere=e=>Gr(zUe(e)),bre=e=>Gr(VUe(e)),uFt=(e,t)=>{switch(e._tag){case"Refinement":if(t){let r=Di(e.from,!0);return(n,o)=>{o=o??XH;let i=o?.errors==="all",s=Rh(A$e(r(n,o),a=>{let c=new ZD(e,n,"From",a);return i&&lre(e)&&k$e(a)?wt(e.filter(n,o,e),{onNone:()=>Re(c),onSome:u=>Re(new Rn(e,n,[c,new ZD(e,n,"Predicate",u)]))}):Re(c)}),a=>wt(e.filter(a,o,e),{onNone:()=>Le(a),onSome:c=>Re(new ZD(e,n,"Predicate",c))}));return KD(s,e,n,o)}}else{let r=Di(lo(e),!0),n=Di(C$e(e.from),!1);return(o,i)=>KD(Rh(r(o,i),s=>n(s,i)),e,o,i)}case"Transformation":{let r=dFt(e.transformation,t),n=t?Di(e.from,!0):Di(e.to,!1),o=t?Di(e.to,!0):Di(e.from,!1);return(i,s)=>KD(Rh(rW(n(i,s),a=>new XD(e,i,t?"Encoded":"Type",a)),a=>Rh(rW(r(a,s??XH,e,i),c=>new XD(e,i,"Transformation",c)),c=>rW(o(c,s),u=>new XD(e,i,t?"Type":"Encoded",u)))),e,i,s)}case"Declaration":{let r=t?e.decodeUnknown(...e.typeParameters):e.encodeUnknown(...e.typeParameters);return(n,o)=>KD(r(n,o??XH,e),e,n,o)}case"Literal":return Dc(e,r=>r===e.literal);case"UniqueSymbol":return Dc(e,r=>r===e.symbol);case"UndefinedKeyword":return Dc(e,fEe);case"NeverKeyword":return Dc(e,pEe);case"UnknownKeyword":case"AnyKeyword":case"VoidKeyword":return Le;case"StringKeyword":return Dc(e,Fo);case"NumberKeyword":return Dc(e,Ls);case"BooleanKeyword":return Dc(e,hm);case"BigIntKeyword":return Dc(e,$g);case"SymbolKeyword":return Dc(e,fE);case"ObjectKeyword":return Dc(e,xi);case"Enums":return Dc(e,r=>e.enums.some(([n,o])=>o===r));case"TemplateLiteral":{let r=u$e(e);return Dc(e,n=>Fo(n)&&r.test(n))}case"TupleType":{let r=e.elements.map(u=>Di(u.type,t)),n=e.rest.map(u=>Di(u.type,t)),o=e.elements.filter(u=>!u.isOptional);e.rest.length>0&&(o=o.concat(e.rest.slice(1)));let i=o.length,s=e.elements.length>0?e.elements.map((u,l)=>l).join(" | "):"never",a=Ere(e),c=bre(e);return(u,l)=>{if(!m6(u))return Re(new ia(e,u));let d=l?.errors==="all",f=[],p=0,m=[],g=u.length;for(let b=g;b<=i-1;b++){let w=new Xo(b,u,new Xb(o[b-g]));if(d){f.push([p++,w]);continue}else return Re(new Rn(e,u,w,m))}if(e.rest.length===0)for(let b=e.elements.length;b<=g-1;b++){let w=new Xo(b,u,new nW(u[b],`is unexpected, expected: ${s}`));if(d){f.push([p++,w]);continue}else return Re(new Rn(e,u,w,m))}let A=0,E;for(;A<r.length;A++)if(g<A+1){if(e.elements[A].isOptional)continue}else{let b=r[A],w=b(u[A],l);if(oa(w)){if(xr(w)){let I=new Xo(A,u,w.left);if(d){f.push([p++,I]);continue}else return Re(new Rn(e,u,I,Rd(m)))}m.push([p++,w.right])}else{let I=p++,v=A;E||(E=[]),E.push(({es:k,output:R})=>Ee(ny(w),B=>{if(xr(B)){let L=new Xo(v,u,B.left);return d?(k.push([I,L]),ve):Re(new Rn(e,u,L,Rd(R)))}return R.push([I,B.right]),ve}))}}if(zr(n)){let[b,...w]=n;for(;A<g-w.length;A++){let I=b(u[A],l);if(oa(I))if(xr(I)){let v=new Xo(A,u,I.left);if(d){f.push([p++,v]);continue}else return Re(new Rn(e,u,v,Rd(m)))}else m.push([p++,I.right]);else{let v=p++,k=A;E||(E=[]),E.push(({es:R,output:B})=>Ee(ny(I),L=>{if(xr(L)){let D=new Xo(k,u,L.left);return d?(R.push([v,D]),ve):Re(new Rn(e,u,D,Rd(B)))}else return B.push([v,L.right]),ve}))}}for(let I=0;I<w.length;I++){let v=A+I;if(!(g<v+1)){let k=w[I](u[v],l);if(oa(k)){if(xr(k)){let R=new Xo(v,u,k.left);if(d){f.push([p++,R]);continue}else return Re(new Rn(e,u,R,Rd(m)))}m.push([p++,k.right])}else{let R=p++;E||(E=[]),E.push(({es:B,output:L})=>Ee(ny(k),D=>{if(xr(D)){let ee=new Xo(v,u,D.left);return d?(B.push([R,ee]),ve):Re(new Rn(e,u,ee,Rd(L)))}return L.push([R,D.right]),ve}))}}}}let y=({es:b,output:w})=>Cm(b)?Re(new Rn(e,u,Rd(b),Rd(w))):Le(Rd(w));if(E&&E.length>0){let b=E;return Pt(()=>{let w={es:_w(f),output:_w(m)};return Ee(hi(b,I=>I(w),{concurrency:a,batching:c,discard:!0}),()=>y(w))})}return y({output:m,es:f})}}case"TypeLiteral":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return Dc(e,mEe);let r=[],n={},o=[];for(let l of e.propertySignatures)r.push([Di(l.type,t),l]),n[l.name]=null,o.push(l.name);let i=e.indexSignatures.map(l=>[Di(l.parameter,t),Di(l.type,t),l.parameter]),s=os.make(e.indexSignatures.map(l=>l.parameter).concat(o.map(l=>fE(l)?new WD(l):new Vb(l)))),a=Di(s,t),c=Ere(e),u=bre(e);return(l,d)=>{if(!PJ(l))return Re(new ia(e,l));let f=d?.errors==="all",p=[],m=0,g=d?.onExcessProperty==="error",A=d?.onExcessProperty==="preserve",E={},y;if(g||A){y=Reflect.ownKeys(l);for(let v of y){let k=a(v,d);if(oa(k)&&xr(k))if(g){let R=new Xo(v,l,new nW(l[v],`is unexpected, expected: ${String(s)}`));if(f){p.push([m++,R]);continue}else return Re(new Rn(e,l,R,E))}else E[v]=l[v]}}let b,w=d?.exact===!0;for(let v=0;v<r.length;v++){let k=r[v][1],R=k.name,B=Object.prototype.hasOwnProperty.call(l,R);if(!B){if(k.isOptional)continue;if(w){let ee=new Xo(R,l,new Xb(k));if(f){p.push([m++,ee]);continue}else return Re(new Rn(e,l,ee,E))}}let L=r[v][0],D=L(l[R],d);if(oa(D)){if(xr(D)){let ee=new Xo(R,l,B?D.left:new Xb(k));if(f){p.push([m++,ee]);continue}else return Re(new Rn(e,l,ee,E))}E[R]=D.right}else{let ee=m++,F=R;b||(b=[]),b.push(({es:_,output:P})=>Ee(ny(D),$=>{if(xr($)){let N=new Xo(F,l,B?$.left:new Xb(k));return f?(_.push([ee,N]),ve):Re(new Rn(e,l,N,P))}return P[F]=$.right,ve}))}}for(let v=0;v<i.length;v++){let k=i[v],R=k[0],B=k[1],L=Rte(l,k[2]);for(let D of L){let ee=R(D,d);if(oa(ee)&&si(ee)){let F=B(l[D],d);if(oa(F))if(xr(F)){let _=new Xo(D,l,F.left);if(f){p.push([m++,_]);continue}else return Re(new Rn(e,l,_,E))}else Object.prototype.hasOwnProperty.call(n,D)||(E[D]=F.right);else{let _=m++,P=D;b||(b=[]),b.push(({es:$,output:N})=>Ee(ny(F),q=>{if(xr(q)){let re=new Xo(P,l,q.left);return f?($.push([_,re]),ve):Re(new Rn(e,l,re,N))}else return Object.prototype.hasOwnProperty.call(n,D)||(N[D]=q.right),ve}))}}}}let I=({es:v,output:k})=>{if(Cm(v))return Re(new Rn(e,l,Rd(v),k));if(d?.propertyOrder==="original"){let R=y||Reflect.ownKeys(l);for(let L of o)R.indexOf(L)===-1&&R.push(L);let B={};for(let L of R)Object.prototype.hasOwnProperty.call(k,L)&&(B[L]=k[L]);return Le(B)}return Le(k)};if(b&&b.length>0){let v=b;return Pt(()=>{let k={es:_w(p),output:Object.assign({},E)};return Ee(hi(v,R=>R(k),{concurrency:c,batching:u,discard:!0}),()=>I(k))})}return I({es:p,output:E})}}case"Union":{let r=S$e(e.types,t),n=Reflect.ownKeys(r.keys),o=n.length,i=e.types.length,s=new Map;for(let u=0;u<i;u++)s.set(e.types[u],Di(e.types[u],t));let a=Ere(e)??1,c=bre(e);return(u,l)=>{let d=[],f=0,p=[];if(o>0)if(c_(u))for(let A=0;A<o;A++){let E=n[A],y=r.keys[E].buckets;if(Object.prototype.hasOwnProperty.call(u,E)){let b=String(u[E]);if(Object.prototype.hasOwnProperty.call(y,b))p=p.concat(y[b]);else{let{candidates:w,literals:I}=r.keys[E],v=os.make(I),k=w.length===i?new il([new To(E,v,!1,!0)],[]):os.make(w);d.push([f++,new Rn(k,u,new Xo(E,u,new ia(v,u[E])))])}}else{let{candidates:b,literals:w}=r.keys[E],I=new To(E,os.make(w),!1,!0),v=b.length===i?new il([I],[]):os.make(b);d.push([f++,new Rn(v,u,new Xo(E,u,new Xb(I)))])}}else{let A=r.candidates.length===i?e:os.make(r.candidates);d.push([f++,new ia(A,u)])}r.otherwise.length>0&&(p=p.concat(r.otherwise));let m;for(let A=0;A<p.length;A++){let E=p[A],y=s.get(E)(u,l);if(oa(y)&&(!m||m.length===0)){if(si(y))return y;d.push([f++,y.left])}else{let b=f++;m||(m=[]),m.push(w=>Pt(()=>"finalResult"in w?ve:Ee(ny(y),I=>(si(I)?w.finalResult=I:w.es.push([b,I.left]),ve))))}}let g=A=>Cm(A)?A.length===1&&A[0][1]._tag==="Type"?Re(A[0][1]):Re(new Rn(e,u,Rd(A))):Re(new ia(e,u));if(m&&m.length>0){let A=m;return Pt(()=>{let E={es:_w(d)};return Ee(hi(A,y=>y(E),{concurrency:a,batching:c,discard:!0}),()=>"finalResult"in E?E.finalResult:g(E.es))})}return g(d)}}case"Suspend":{let r=$D(()=>Di(e.f(),t));return(n,o)=>r()(n,o)}}},Dc=(e,t)=>r=>t(r)?Le(r):Re(new ia(e,r)),JD=(e,t)=>{switch(e._tag){case"Declaration":{let r=ure(e);if(pt(r))return JD(r.value,t);break}case"TypeLiteral":{let r=[];for(let n=0;n<e.propertySignatures.length;n++){let o=e.propertySignatures[n],i=t?VD(o.type):lo(o.type);Zb(i)&&!o.isOptional&&r.push([o.name,i])}return r}case"TupleType":{let r=[];for(let n=0;n<e.elements.length;n++){let o=e.elements[n],i=t?VD(o.type):lo(o.type);Zb(i)&&!o.isOptional&&r.push([n,i])}return r}case"Refinement":return JD(e.from,t);case"Suspend":return JD(e.f(),t);case"Transformation":return JD(t?e.from:e.to,t)}return[]},S$e=(e,t)=>{let r={},n=[],o=[];for(let i=0;i<e.length;i++){let s=e[i],a=JD(s,t);if(a.length>0){o.push(s);for(let c=0;c<a.length;c++){let[u,l]=a[c],d=String(l.literal);r[u]=r[u]||{buckets:{},literals:[],candidates:[]};let f=r[u].buckets;if(Object.prototype.hasOwnProperty.call(f,d)){if(c<a.length-1)continue;f[d].push(s),r[u].literals.push(l),r[u].candidates.push(s)}else{f[d]=[s],r[u].literals.push(l),r[u].candidates.push(s);break}}}else n.push(s)}return{keys:r,otherwise:n,candidates:o}},C$e=e=>ky(e)?C$e(e.from):e,KD=(e,t,r,n)=>{if(n?.isEffectAllowed===!0||oa(e))return e;let o=new CI,i=m0(e,{scheduler:o});o.flush();let s=i.unsafePoll();if(s){if(Zm(s))return Le(s.value);let a=s.cause;return Vwe(a)?Re(a.error):Re(new oW(t,r,VL(a)))}return Re(new oW(t,r,"cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work"))},lFt=([e],[t])=>e>t?1:e<t?-1:0;dFt=(e,t)=>{switch(e._tag){case"FinalTransformation":return t?e.decode:e.encode;case"ComposeTransformation":return Le;case"TypeLiteralTransformation":return r=>{let n=Le(r);for(let o of e.propertySignatureTransformations){let[i,s]=t?[o.from,o.to]:[o.to,o.from],a=t?o.decode:o.encode;n=ja(n,u=>{let l=a(Object.prototype.hasOwnProperty.call(u,i)?H(u[i]):W());return delete u[i],pt(l)&&(u[s]=l.value),u})}return n}}},na=(e,t=[])=>({value:e,forest:t}),eQ={formatIssue:e=>ja(Y0(e),fFt),formatIssueSync:e=>{let t=eQ.formatIssue(e);return oa(t)?UEe(t):xd(t)},formatError:e=>eQ.formatIssue(e.issue),formatErrorSync:e=>eQ.formatIssueSync(e.issue)},fFt=e=>e.value+w$e(`
69
+ `,e.forest),w$e=(e,t)=>{let r="",n=t.length,o;for(let i=0;i<n;i++){o=t[i];let s=i===n-1;r+=e+(s?"\u2514":"\u251C")+"\u2500 "+o.value,r+=w$e(e+(n>1&&!s?"\u2502 ":" "),o.forest)}return r},pFt=e=>{switch(e){case"Encoded":return"Encoded side transformation failure";case"Transformation":return"Transformation process failure";case"Type":return"Type side transformation failure"}},mFt=e=>{switch(e){case"From":return"From side refinement failure";case"Predicate":return"Predicate refinement failure"}},I$e=e=>"ast"in e?H(e.ast):W(),Cre=Le(void 0),hFt=e=>I$e(e).pipe(Gn(qUe),wt({onNone:()=>Cre,onSome:t=>{let r=t(e);return Fo(r)?Le({message:r,override:!1}):ws(r)?De(r,n=>({message:n,override:!1})):Fo(r.message)?Le({message:r.message,override:r.override}):De(r.message,n=>({message:n,override:r.override}))}})),_re=e=>t=>t._tag===e,k$e=_re("Composite"),p$e=_re("Refinement"),m$e=_re("Transformation"),tQ=e=>Rh(hFt(e),t=>t!==void 0?!t.override&&(k$e(e)||p$e(e)&&e.kind==="From"||m$e(e)&&e.kind!=="Transformation")?m$e(e)||p$e(e)?tQ(e.issue):Cre:Le(t.message):Cre),v$e=e=>I$e(e).pipe(Gn(YUe),o6(t=>t(e)),Gr);yFt=e=>ja(tQ(e),t=>t??v$e(e)??AFt(e)),tW=e=>v$e(e)??String(e.ast),xFt=e=>e.message??"is forbidden",EFt=e=>e.message??"is unexpected",bFt=e=>{let t=GUe(e.ast);if(pt(t)){let r=t.value();return Fo(r)?Le(r):r}return Le(e.message??"is missing")},Y0=e=>{switch(e._tag){case"Type":return ja(yFt(e),na);case"Forbidden":return Le(na(tW(e),[na(xFt(e))]));case"Unexpected":return Le(na(EFt(e)));case"Missing":return ja(bFt(e),na);case"Transformation":return Rh(tQ(e),t=>t!==void 0?Le(na(t)):ja(Y0(e.issue),r=>na(tW(e),[na(pFt(e.kind),[r])])));case"Refinement":return Rh(tQ(e),t=>t!==void 0?Le(na(t)):ja(Y0(e.issue),r=>na(tW(e),[na(mFt(e.kind),[r])])));case"Pointer":return ja(Y0(e.issue),t=>na($H(e.path),[t]));case"Composite":return Rh(tQ(e),t=>{if(t!==void 0)return Le(na(t));let r=tW(e);return _te(e.issues)?ja(hi(e.issues,Y0),n=>na(r,n)):ja(Y0(e.issues),n=>na(r,[n]))})}}});var Bre,Tre=h(()=>{WMe();Bre=HMe});var B$e,cW,uW=h(()=>{oe();ct();B$e=x(e=>xi(e[0]),(e,...t)=>{let r={};for(let n of t)n in e&&(r[n]=e[n]);return r}),cW=x(e=>xi(e[0]),(e,...t)=>{let r={...e};for(let n of t)delete r[n];return r})});function fo(e){return class{[vy]=Qre;static ast=e;static annotations(r){return fo(oS(this.ast,r))}static pipe(){return Z(this,arguments)}static toString(){return String(e)}static Type;static Encoded;static Context;static[vy]=Qre}}function wFt(e){return ZH(e)?os.make(o$e(e,t=>new Vb(t))):new Vb(e[0])}function H$e(e,t=wFt(e)){return class extends fo(t){static annotations(n){return H$e(this.literals,oS(this.ast,n))}static literals=[...e]}}function is(...e){return zr(e)?H$e(e):pW}function $re(e,t){return class extends fo(t){static annotations(n){return $re(this.typeParameters,oS(this.ast,n))}static typeParameters=[...e]}}function W$e(e,t=vFt(e)){return class extends fo(t){static annotations(n){return W$e(this.members,oS(this.ast,n))}static members=[...e]}}function cQ(...e){return ZH(e)?W$e(e):zr(e)?e[0]:pW}function z$e(e,t,r=QFt(e,t)){return class extends fo(r){static annotations(o){return z$e(this.fields,this.records,oS(this.ast,o))}static fields={...e};static records=[...t];static make=(o,i)=>{let s=G$e(e,{...o});return jre(i)?s:rQ(this)(s)};static pick(...o){return ss(B$e(e,...o))}static omit(...o){return ss(cW(e,...o))}}}function ss(e,...t){return z$e(e,t)}function J$e(e,t,r){return class extends fo(r){static annotations(o){return J$e(this.from,this.filter,oS(this.ast,o))}static[Y$e]=e;static from=e;static filter=t;static make=(o,i)=>jre(i)?o:rQ(this)(o)}}function K$e(e,t){return r=>{function n(i,s,a){return NFt(e(i,s,a),a,i)}let o=new Jb(r.ast,n,nS(t));return J$e(r,n,o)}}function Z$e(e,t,r){return class extends fo(r){static annotations(o){return Z$e(this.from,this.to,oS(this.ast,o))}static from=e;static to=t}}function jre(e){return hm(e)?e:e?.disableValidation??!1}function tS(e){switch(e._tag){case"Empty":return jwe;case"Fail":return VE(e.error);case"Die":return od(e.defect);case"Interrupt":return qL(bW(e.fiberId));case"Sequential":return Gwe(tS(e.left),tS(e.right));case"Parallel":return qwe(tS(e.left),tS(e.right))}}function K0(e){switch(e._tag){case"Empty":return{_tag:"Empty"};case"Fail":return{_tag:"Fail",error:e.error};case"Die":return{_tag:"Die",defect:e.defect};case"Interrupt":return{_tag:"Interrupt",fiberId:e.fiberId};case"Sequential":return{_tag:"Sequential",left:K0(e.left),right:K0(e.right)};case"Parallel":return{_tag:"Parallel",left:K0(e.left),right:K0(e.right)}}}var vy,Qre,T$e,nS,oS,SFt,CFt,iQ,rS,IFt,kFt,aQ,Ore,fW,pW,mW,_d,sQ,vFt,RFt,D$e,Nre,Z0,hW,_Ft,gW,j$e,q$e,Hre,AW,Q$e,yW,BFt,TFt,iS,DFt,QFt,G$e,nQ,OFt,oQ,xW,eS,_h,V$e,Pre,Y$e,O$e,NFt,Mre,uQ,N$e,PFt,MFt,P$e,M$e,FFt,LFt,EW,UFt,F$e,L$e,$Ft,X$e,Wre,e2e,t2e,HFt,sS,lW,U$e,WFt,dW,jFt,qFt,GFt,Fre,zFt,Lre,bW,VFt,YFt,JFt,KFt,ZFt,Ure,XFt,eLt,$$e,tLt,r2e,ip,X0=h(()=>{wr();Vs();lh();mm();Zl();oe();yn();ht();Jl();Qte();MUe();HD();it();aW();Me();ct();YD();uW();aW();vy=Symbol.for("effect/Schema");Qre={_A:e=>e,_I:e=>e,_R:e=>e},T$e={typeConstructor:LUe,schemaId:$Ue,message:Vte,missingMessage:qH,identifier:G0,title:Wa,description:kh,examples:Yte,default:Jte,documentation:HUe,jsonSchema:Kte,arbitrary:Zte,pretty:Xte,equivalence:ere,concurrency:tre,batching:rre,parseIssueTitle:nre,parseOptions:ore,decodingFallback:ire},nS=e=>{if(!e)return{};let t={...e};for(let r in T$e)if(r in e){let n=T$e[r];t[n]=e[r],delete t[r]}return t},oS=(e,t)=>zD(e,nS(t)),SFt=e=>String(e.ast),CFt=e=>fo(VD(e.ast)),iQ=e=>fo(lo(e.ast)),rS=e=>se(e,vy)&&xi(e[vy]);IFt=(e,t,r)=>$re(e,new zb(e.map(n=>n.ast),(...n)=>t.decode(...n.map(fo)),(...n)=>t.encode(...n.map(fo)),nS(r))),kFt=(e,t)=>{let r=()=>(o,i,s)=>e(o)?J0(o):iW(new ia(s,o)),n=r;return $re([],new zb([],r,n,nS(t)))};aQ=function(){if(Array.isArray(arguments[0])){let r=arguments[0],n=arguments[1],o=arguments[2];return IFt(r,n,o)}let e=arguments[0],t=arguments[1];return kFt(e,t)},Ore=class extends fo(zH){},fW=class extends fo(ZUe){},pW=class extends fo(VH){},mW=class extends fo(dre){},_d=class extends fo(YH){},sQ=class extends fo(KH){},vFt=e=>os.make(e.map(t=>t.ast));RFt=e=>cQ(e,Ore),D$e=class e{ast;from;[vy];_Token;constructor(t,r){this.ast=t,this.from=r}annotations(t){return new e(new wh(this.ast.type,this.ast.isOptional,{...this.ast.annotations,...nS(t)}),this.from)}toString(){return`${this.ast.type}${this.ast.isOptional?"?":""}`}},Nre=e=>e?'"?:"':'":"',Z0=class extends wh{isReadonly;defaultValue;_tag="PropertySignatureDeclaration";constructor(t,r,n,o,i){super(t,r,o),this.isReadonly=n,this.defaultValue=i}toString(){let t=Nre(this.isOptional),r=String(this.type);return`PropertySignature<${t}, ${r}, never, ${t}, ${r}>`}},hW=class extends wh{isReadonly;defaultValue;constructor(t,r,n,o,i){super(t,r,o),this.isReadonly=n,this.defaultValue=i}},_Ft=e=>e===void 0?"never":Fo(e)?JSON.stringify(e):String(e),gW=class{from;to;decode;encode;_tag="PropertySignatureTransformation";constructor(t,r,n,o){this.from=t,this.to=r,this.decode=n,this.encode=o}toString(){return`PropertySignature<${Nre(this.to.isOptional)}, ${this.to.type}, ${_Ft(this.from.fromKey)}, ${Nre(this.from.isOptional)}, ${this.from.type}>`}},j$e=(e,t)=>{switch(e._tag){case"PropertySignatureDeclaration":return new Z0(e.type,e.isOptional,e.isReadonly,{...e.annotations,...t},e.defaultValue);case"PropertySignatureTransformation":return new gW(e.from,new hW(e.to.type,e.to.isOptional,e.to.isReadonly,{...e.to.annotations,...t},e.to.defaultValue),e.decode,e.encode)}},q$e=Symbol.for("effect/PropertySignature"),Hre=e=>se(e,q$e),AW=class e{ast;[vy];[q$e]=null;_TypeToken;_Key;_EncodedToken;_HasDefault;constructor(t){this.ast=t}pipe(){return Z(this,arguments)}annotations(t){return new e(j$e(this.ast,nS(t)))}toString(){return String(this.ast)}},Q$e=e=>new AW(e),yW=class e extends AW{from;constructor(t,r){super(t),this.from=r}annotations(t){return new e(j$e(this.ast,nS(t)),this.from)}},BFt=e=>new yW(new Z0(e.ast,!1,!0,{},void 0),e),TFt=x(2,(e,t)=>{let r=e.ast;switch(r._tag){case"PropertySignatureDeclaration":return Q$e(new Z0(r.type,r.isOptional,r.isReadonly,r.annotations,t));case"PropertySignatureTransformation":return Q$e(new gW(r.from,new hW(r.to.type,r.to.isOptional,r.to.isReadonly,r.to.annotations,t),r.decode,r.encode))}}),iS=e=>{let t=e.ast===zH||e.ast===VH?zH:RFt(e).ast;return new yW(new Z0(t,!0,!0,{},void 0),e)},DFt=yre([qH]),QFt=(e,t)=>{let r=Reflect.ownKeys(e),n=[];if(r.length>0){let i=[],s=[],a=[];for(let c=0;c<r.length;c++){let u=r[c],l=e[u];if(Hre(l)){let d=l.ast;switch(d._tag){case"PropertySignatureDeclaration":{let f=d.type,p=d.isOptional,m=d.annotations;i.push(new To(u,f,p,!0,DFt(d))),s.push(new To(u,lo(f),p,!0,m)),n.push(new To(u,f,p,!0,m));break}case"PropertySignatureTransformation":{let f=d.from.fromKey??u;i.push(new To(f,d.from.type,d.from.isOptional,!0,d.from.annotations)),s.push(new To(u,d.to.type,d.to.isOptional,!0,d.to.annotations)),a.push(new jH(f,u,d.decode,d.encode));break}}}else i.push(new To(u,l.ast,!1,!0)),s.push(new To(u,lo(l.ast),!1,!0)),n.push(new To(u,l.ast,!1,!0))}if(zr(a)){let c=[],u=[];for(let l of t){let{indexSignatures:d,propertySignatures:f}=Are(l.key.ast,l.value.ast);f.forEach(p=>{i.push(p),s.push(new To(p.name,lo(p.type),p.isOptional,p.isReadonly,p.annotations))}),d.forEach(p=>{c.push(p),u.push(new Yb(p.parameter,lo(p.type),p.isReadonly))})}return new Ih(new il(i,c,{[Kb]:"Struct (Encoded side)"}),new il(s,u,{[Kb]:"Struct (Type side)"}),new q0(a))}}let o=[];for(let i of t){let{indexSignatures:s,propertySignatures:a}=Are(i.key.ast,i.value.ast);a.forEach(c=>n.push(c)),s.forEach(c=>o.push(c))}return new il(n,o)},G$e=(e,t)=>{let r=Reflect.ownKeys(e);for(let n of r){let o=e[n];if(t[n]===void 0&&Hre(o)){let i=o.ast,s=i._tag==="PropertySignatureDeclaration"?i.defaultValue:i.to.defaultValue;s!==void 0&&(t[n]=s())}}return t};nQ=(e,t,r)=>{if(hre(e)&&hre(t)){let n=[...e.propertySignatures];for(let o of t.propertySignatures){let i=o.name,s=n.findIndex(a=>a.name===i);if(s===-1)n.push(o);else{let{isOptional:a,type:c}=n[s];n[s]=new To(i,xW(c,o.type,r.concat(i)),a,!0)}}return new il(n,e.indexSignatures.concat(t.indexSignatures))}throw new Error(Bte(e,t,r))},OFt=l$e([G0]),oQ=(e,t)=>t.map(r=>new Jb(r,e.filter,OFt(e))),xW=(e,t,r)=>os.make(_h([e],[t],r)),eS=e=>V0(e)?e.types:[e],_h=(e,t,r)=>SE(e,n=>SE(t,o=>{switch(o._tag){case"Literal":{if(Fo(o.literal)&&JH(n)||Ls(o.literal)&&fre(n)||hm(o.literal)&&mre(n))return[o];break}case"StringKeyword":{if(o===YH){if(JH(n)||Zb(n)&&Fo(n.literal))return[n];if(ky(n))return oQ(n,_h(eS(n.from),[o],r))}else if(n===YH)return[o];break}case"NumberKeyword":{if(o===KH){if(fre(n)||Zb(n)&&Ls(n.literal))return[n];if(ky(n))return oQ(n,_h(eS(n.from),[o],r))}else if(n===KH)return[o];break}case"BooleanKeyword":{if(o===pre){if(mre(n)||Zb(n)&&hm(n.literal))return[n];if(ky(n))return oQ(n,_h(eS(n.from),[o],r))}else if(n===pre)return[o];break}case"Union":return _h(eS(n),o.types,r);case"Suspend":return[new Iy(()=>xW(n,o.f(),r))];case"Refinement":return oQ(o,_h(eS(n),eS(o.from),r));case"TypeLiteral":{switch(n._tag){case"Union":return _h(n.types,[o],r);case"Suspend":return[new Iy(()=>xW(n.f(),o,r))];case"Refinement":return oQ(n,_h(eS(n.from),[o],r));case"TypeLiteral":return[nQ(n,o,r)];case"Transformation":{let i=n.transformation,s=nQ(n.from,o,r),a=nQ(n.to,lo(o),r);switch(i._tag){case"TypeLiteralTransformation":return[new Ih(s,a,new q0(i.propertySignatureTransformations))];case"ComposeTransformation":return[new Ih(s,a,s$e)];case"FinalTransformation":return[new Ih(s,a,new qD((c,u,l,d)=>ja(i.decode(c,u,l,d),f=>({...c,...f})),(c,u,l,d)=>ja(i.encode(c,u,l,d),f=>({...c,...f}))))]}}}break}case"Transformation":{if(i$e(n)){if(gre(o.transformation)&&gre(n.transformation))return[new Ih(nQ(n.from,o.from,r),nQ(n.to,o.to,r),new q0(o.transformation.propertySignatureTransformations.concat(n.transformation.propertySignatureTransformations)))]}else return _h([o],[n],r);break}}throw new Error(Bte(n,o,r))})),V$e=x(2,(e,t)=>fo(xW(e.ast,t.ast,[]))),Pre=e=>fo(new Iy(()=>e().ast)),Y$e=Symbol.for("effect/SchemaId/Refine");O$e=(e,t,r)=>{if(hm(e))return e?W():H(new ia(t,r));if(Fo(e))return H(new ia(t,r,e));if(e!==void 0){if("_tag"in e)return H(e);let n=new ia(t,r,e.message);return H(zr(e.path)?new Xo(e.path,r,n):n)}return W()},NFt=(e,t,r)=>{if(_Ue(e))return O$e(e,t,r);if(zr(e)){let n=Yg(e,o=>O$e(o,t,r));if(zr(n))return H(n.length===1?n[0]:new Rn(t,r,n))}return W()};Mre=x(e=>rS(e[0])&&rS(e[1]),(e,t,r)=>Z$e(e,t,new Ih(e.ast,t.ast,new qD(r.decode,r.encode)))),uQ=x(e=>rS(e[0])&&rS(e[1]),(e,t,r)=>Mre(e,t,{strict:!0,decode:(n,o,i,s)=>J0(r.decode(n,s)),encode:(n,o,i,s)=>J0(r.encode(n,s))})),N$e=Symbol.for("effect/SchemaId/Pattern"),PFt=(e,t)=>r=>{let n=e.source;return r.pipe(K$e(o=>(e.lastIndex=0,e.test(o)),{schemaId:N$e,[N$e]:{regex:e},description:`a string matching the pattern ${n}`,jsonSchema:{pattern:n},...t}))},MFt=Symbol.for("effect/SchemaId/UUID"),P$e=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i,M$e=class extends _d.pipe(PFt(P$e,{schemaId:MFt,identifier:"UUID",jsonSchema:{format:"uuid",pattern:P$e.source},description:"a Universally Unique Identifier",arbitrary:()=>t=>t.uuid()})){},FFt=PUe,LFt=e=>t=>t.pipe(K$e(r=>Number.isSafeInteger(r),{schemaId:FFt,title:"int",description:"an integer",jsonSchema:{type:"integer"},...e})),EW=class extends sQ.pipe(LFt({identifier:"Int"})){},UFt=(e,t,r,n)=>g$e(e,{onFailure:o=>new Rn(r,n,o),onSuccess:t}),F$e=NUe,L$e=class extends aQ(KM,{typeConstructor:{_tag:"Date"},identifier:"DateFromSelf",schemaId:F$e,[F$e]:{noInvalidDate:!1},description:"a potentially invalid Date instance",pretty:()=>t=>`new Date(${JSON.stringify(t)})`,arbitrary:()=>t=>t.date({noInvalidDate:!1}),equivalence:()=>uEe}){},$Ft=e=>rS(e)||Hre(e),X$e=e=>Reflect.ownKeys(e).every(t=>$Ft(e[t])),Wre=e=>"fields"in e?e.fields:Wre(e[Y$e]),e2e=e=>X$e(e)?ss(e):rS(e)?e:ss(Wre(e)),t2e=e=>X$e(e)?e:Wre(e),HFt=e=>TFt(BFt(is(e)),()=>e),sS=e=>(t,r,n)=>{class o extends YI{}o.prototype.name=t;let i=t2e(r),s=e2e(r),a={_tag:HFt(t)},c=lW(a,i),u="message"in c;class l extends dW({kind:"TaggedError",identifier:e??t,schema:V$e(s,ss(a)),fields:c,Base:o,annotations:n,disableToString:!0}){static _tag=t}return u||Object.defineProperty(l.prototype,"message",{get(){return`{ ${Reflect.ownKeys(i).map(d=>`${Hg(d)}: ${uc(this[d])}`).join(", ")} }`},enumerable:!1,configurable:!0}),l},lW=(e,t)=>{let r={...e};for(let n of Reflect.ownKeys(t)){if(n in e)throw new Error(WH(n));r[n]=t[n]}return r};U$e=Te("effect/Schema/astCache",()=>new WeakMap),WFt=e=>e===void 0?[]:Array.isArray(e)?e:[e],dW=({Base:e,annotations:t,disableToString:r,fields:n,identifier:o,kind:i,schema:s})=>{let a=Symbol.for(`effect/Schema/${i}/${o}`),[c,u,l]=WFt(t),d=iQ(s),f=d.annotations({identifier:o,...c}),p=d.annotations({[Kb]:`${o} (Type side)`,...c}),m=s.annotations({[Kb]:`${o} (Constructor)`,...c}),g=s.annotations({[Kb]:`${o} (Encoded side)`,...l}),A=s.annotations({...l,...c,...u}),E=b=>se(b,a)&&vre(p)(b),y=class extends e{constructor(b={},w=!1){b={...b},i!=="Class"&&delete b._tag,b=G$e(n,b),jre(w)||(b=rQ(m)(b)),super(b,!0)}static[vy]=Qre;static get ast(){let b=U$e.get(this);if(b)return b;let w=aQ([s],{decode:()=>(I,v,k)=>I instanceof this||E(I)?J0(I):iW(new ia(k,I)),encode:()=>(I,v)=>I instanceof this?J0(I):ja(Ire(p)(I,v),k=>new this(k,!0))},{identifier:o,pretty:I=>v=>`${o}(${I(v)})`,arbitrary:I=>v=>I(v).map(k=>new this(k)),equivalence:be,[GD]:f.ast,...c});return b=uQ(g,w,{strict:!0,decode:I=>new this(I,!0),encode:be}).annotations({[GD]:A.ast,...u}).ast,U$e.set(this,b),b}static pipe(){return Z(this,arguments)}static annotations(b){return fo(this.ast).annotations(b)}static toString(){return`(${String(g)} <-> ${o})`}static make(...b){return new this(...b)}static fields={...n};static identifier=o;static extend(b){return(w,I)=>{let v=t2e(w),k=e2e(w),R=lW(n,v);return dW({kind:i,identifier:b,schema:V$e(s,k),fields:R,Base:this,annotations:I})}}static transformOrFail(b){return(w,I,v)=>{let k=lW(n,w);return dW({kind:i,identifier:b,schema:Mre(s,iQ(ss(k)),I),fields:k,Base:this,annotations:v})}}static transformOrFailFrom(b){return(w,I,v)=>{let k=lW(n,w);return dW({kind:i,identifier:b,schema:Mre(CFt(s),ss(k),I),fields:k,Base:this,annotations:v})}}get[a](){return a}};return r!==!0&&Object.defineProperty(y.prototype,"toString",{value(){return`${o}({ ${Reflect.ownKeys(n).map(b=>`${Hg(b)}: ${uc(this[b])}`).join(", ")} })`},configurable:!0,writable:!0}),y},jFt=ss({_tag:is("None")}).annotations({identifier:"FiberIdNoneEncoded"}),qFt=ss({_tag:is("Runtime"),id:EW,startTimeMillis:EW}).annotations({identifier:"FiberIdRuntimeEncoded"}),GFt=ss({_tag:is("Composite"),left:Pre(()=>Fre),right:Pre(()=>Fre)}).annotations({identifier:"FiberIdCompositeEncoded"}),Fre=cQ(jFt,qFt,GFt).annotations({identifier:"FiberIdEncoded"}),zFt=e=>e.letrec(t=>({None:e.record({_tag:e.constant("None")}),Runtime:e.record({_tag:e.constant("Runtime"),id:e.integer(),startTimeMillis:e.integer()}),Composite:e.record({_tag:e.constant("Composite"),left:t("FiberId"),right:t("FiberId")}),FiberId:e.oneof(t("None"),t("Runtime"),t("Composite"))})).FiberId.map(bW),Lre=e=>{switch(e._tag){case"None":return"FiberId.none";case"Runtime":return`FiberId.runtime(${e.id}, ${e.startTimeMillis})`;case"Composite":return`FiberId.composite(${Lre(e.right)}, ${Lre(e.left)})`}},bW=e=>{switch(e._tag){case"None":return ci;case"Runtime":return GSe(e.id,e.startTimeMillis);case"Composite":return zSe(bW(e.left),bW(e.right))}},VFt=e=>ss({_tag:is("Die"),defect:e}),YFt=ss({_tag:is("Empty")}),JFt=e=>ss({_tag:is("Fail"),error:e}),KFt=ss({_tag:is("Interrupt"),fiberId:Fre}),ZFt=0,Ure=(e,t)=>{let r=e,n=t,o=Pre(()=>i),i=cQ(YFt,JFt(r),VFt(n),KFt,ss({_tag:is("Sequential"),left:o,right:o}),ss({_tag:is("Parallel"),left:o,right:o})).annotations({title:`CauseEncoded<${SFt(e)}>`,[GH]:`CauseEncoded${ZFt++}`});return i},XFt=(e,t)=>r=>r.letrec(n=>({Empty:r.record({_tag:r.constant("Empty")}),Fail:r.record({_tag:r.constant("Fail"),error:e(r)}),Die:r.record({_tag:r.constant("Die"),defect:t(r)}),Interrupt:r.record({_tag:r.constant("Interrupt"),fiberId:zFt(r)}),Sequential:r.record({_tag:r.constant("Sequential"),left:n("Cause"),right:n("Cause")}),Parallel:r.record({_tag:r.constant("Parallel"),left:n("Cause"),right:n("Cause")}),Cause:r.oneof(n("Empty"),n("Fail"),n("Die"),n("Interrupt"),n("Sequential"),n("Parallel"))})).Cause.map(tS),eLt=e=>t=>{let r=n=>{switch(n._tag){case"Empty":return"Cause.empty";case"Fail":return`Cause.fail(${e(n.error)})`;case"Die":return`Cause.die(${VL(n)})`;case"Interrupt":return`Cause.interrupt(${Lre(n.fiberId)})`;case"Sequential":return`Cause.sequential(${r(n.left)}, ${r(n.right)})`;case"Parallel":return`Cause.parallel(${r(n.left)}, ${r(n.right)})`}};return r(t)},$$e=e=>(t,r,n)=>zwe(t)?UFt(e(K0(t),r),tS,n,t):iW(new ia(n,t)),tLt=({defect:e,error:t})=>aQ([t,e],{decode:(r,n)=>$$e(E$e(Ure(r,n))),encode:(r,n)=>$$e(Ire(Ure(r,n)))},{typeConstructor:{_tag:"effect/Cause"},title:`Cause<${t.ast}>`,pretty:eLt,arbitrary:XFt});r2e=({defect:e,error:t})=>{let r=t,n=e;return uQ(Ure(r,n),tLt({error:iQ(r),defect:iQ(n)}),{strict:!1,decode:i=>tS(i),encode:i=>K0(i)})},ip=class extends uQ(mW,mW,{strict:!0,decode:t=>{if(xi(t)&&"message"in t&&typeof t.message=="string"){let r=new Error(t.message,{cause:t});return"name"in t&&typeof t.name=="string"&&(r.name=t.name),r.stack="stack"in t&&typeof t.stack=="string"?t.stack:"",r}return HF(t)},encode:t=>t instanceof Error?{name:t.name,message:t.message}:HF(t)}).annotations({identifier:"Defect"}){}});var SW,CW,n2e,_s,rLt,Bh,Th=h(()=>{lh();X0();SW=Symbol.for("@effect/platform/Error"),CW=(e,t)=>{class r extends YI{_tag=t}return r.prototype[e]=e,r.prototype.name=t,r},n2e=is("Clipboard","Command","FileSystem","KeyValueStore","Path","Stream","Terminal"),_s=class extends sS("@effect/platform/Error/BadArgument")("BadArgument",{module:n2e,method:_d,description:iS(_d),cause:iS(ip)}){[SW]=SW;get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}},rLt=is("AlreadyExists","BadResource","Busy","InvalidData","NotFound","PermissionDenied","TimedOut","UnexpectedEof","Unknown","WouldBlock","WriteZero"),Bh=class extends sS("@effect/platform/Error/SystemError")("SystemError",{reason:rLt,module:n2e,method:_d,description:iS(_d),syscall:iS(_d),pathOrDescriptor:iS(cQ(_d,sQ)),cause:iS(ip)}){[SW]=SW;get message(){return`${this.reason}: ${this.module}.${this.method}${this.pathOrDescriptor!==void 0?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}});function a2e(e){let t={},r=e.length,n=0,o=0;for(;o!==r;){o=e.indexOf(";",n),o===-1&&(o=r);let i=e.indexOf("=",n);if(i===-1)break;if(i>o){n=o+1;continue}let s=e.substring(n,i++).trim();if(t[s]===void 0){let a=e.charCodeAt(i)===34?e.substring(i+1,o-1).trim():e.substring(i,o).trim();t[s]=a.indexOf("%")!==-1?aLt(a):a}n=o+1}return t}var o2e,i2e,oLt,iLt,sLt,s2e,Y8r,aLt,IW=h(()=>{ht();Me();E_();o2e=Symbol.for("@effect/platform/Cookies"),i2e=Symbol.for("@effect/platform/Cookies/Cookie"),oLt={[o2e]:o2e,...Am,toJSON(){return{_id:"@effect/platform/Cookies",cookies:Sm(this.cookies,e=>e.toJSON())}},pipe(){return Z(this,arguments)}},iLt=e=>{let t=Object.create(oLt);return t.cookies=e,t},sLt=e=>{let t={};for(let r of e)t[r.name]=r;return iLt(t)},s2e=sLt([]),Y8r={[i2e]:i2e,...Am,toJSON(){return{_id:"@effect/platform/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};aLt=e=>{try{return decodeURIComponent(e)}catch{return e}}});var c2e,Gre,zre,kW,cLt,uLt,vW=h(()=>{g0();mI();oe();yn();ht();Tre();c2e=Symbol.for("@effect/platform/Headers"),Gre=Object.assign(Object.create(null),{[c2e]:c2e,[d_](e){return cLt(this,d1(e,uLt))}}),zre=Object.create(Gre),kW=e=>{if(e===void 0)return zre;if(Symbol.iterator in e){let r=Object.create(Gre);for(let[n,o]of e)r[n.toLowerCase()]=o;return r}let t=Object.create(Gre);for(let[r,n]of Object.entries(e))Array.isArray(n)?t[r.toLowerCase()]=n.join(", "):n!==void 0&&(t[r.toLowerCase()]=n);return t},cLt=x(2,(e,t)=>{let r={...e},n=o=>{if(typeof o=="string"){let i=o.toLowerCase();i in e&&(r[i]=Bre(e[i]))}else for(let i in e)o.test(i)&&(r[i]=Bre(e[i]))};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),uLt=Te("@effect/platform/Headers/currentRedactedNames",()=>h0(["authorization","cookie","set-cookie","x-api-key"]))});var u2e=h(()=>{});var l2e,dQ,RW=h(()=>{bi();it();l2e=Symbol.for("effect/Brand/Refined"),dQ=()=>Object.assign(e=>e,{[l2e]:l2e,option:e=>H(e),either:e=>Le(e),is:e=>!0})});var _W,fQ,d2e,Jre,Bd,f2e,p2e,m2e,h2e,g2e,ek,A2e,Ry,_y,pQ,aS=h(()=>{wD();Ob();_W=EPe,fQ=fD,d2e=xD,Jre=In,Bd=Et,f2e=nn,p2e=Vn,m2e=ea,h2e=q2,g2e=Yu,ek=Ju,A2e=Jf,Ry=rs,_y=cr,pQ=Kf});var y2e,x2e,E2e,b2e,S2e,C2e,rk=h(()=>{x7();y2e=h7,x2e=g7,E2e=jPe,b2e=J2,S2e=A7,C2e=qPe});var BW,sp,w2e,I2e,k2e,v2e,hQ,dLt,R2e,_2e,po,Kre,B2e,fLt,T2e=h(()=>{aS();vr();sr();nr();oe();zu();it();rk();wd();Th();BW=Jt("@effect/platform/FileSystem"),sp=e=>typeof e=="bigint"?e:BigInt(e),w2e=e=>sp(e*1024),I2e=e=>sp(e*1024*1024),k2e=e=>sp(e*1024*1024*1024),v2e=e=>sp(e*1024*1024*1024*1024),hQ=BigInt(1024),dLt=hQ*hQ*hQ*hQ*hQ,R2e=e=>sp(BigInt(e)*dLt),_2e=e=>BW.of({...e,exists:t=>C(e.access(t),ju(!0),W$("SystemError",r=>r.reason==="NotFound"?nt(!1):$e(r))),readFileString:(t,r)=>zT(e.readFile(t),{try:n=>new TextDecoder(r).decode(n),catch:n=>new _s({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:n})}),stream:(t,r)=>C(e.open(t,{flag:"r"}),r?.offset?Ri(n=>n.seek(r.offset,"start")):be,De(n=>fLt(n,r)),fy),sink:(t,r)=>C(e.open(t,{flag:"w",...r}),De(n=>b2e(o=>n.writeAll(o))),C2e),writeFileString:(t,r,n)=>Ee(Wu({try:()=>new TextEncoder().encode(r),catch:o=>new _s({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:o})}),o=>e.writeFile(t,o,n))}),po=(e,t)=>new Bh({module:"FileSystem",method:e,reason:"NotFound",description:"No such file or directory",pathOrDescriptor:t}),Kre=e=>({access(t){return $e(po("access",t))},chmod(t){return $e(po("chmod",t))},chown(t){return $e(po("chown",t))},copy(t){return $e(po("copy",t))},copyFile(t){return $e(po("copyFile",t))},exists(){return nt(!1)},link(t){return $e(po("link",t))},makeDirectory(){return Ua("not implemented")},makeTempDirectory(){return Ua("not implemented")},makeTempDirectoryScoped(){return Ua("not implemented")},makeTempFile(){return Ua("not implemented")},makeTempFileScoped(){return Ua("not implemented")},open(t){return $e(po("open",t))},readDirectory(t){return $e(po("readDirectory",t))},readFile(t){return $e(po("readFile",t))},readFileString(t){return $e(po("readFileString",t))},readLink(t){return $e(po("readLink",t))},realPath(t){return $e(po("realPath",t))},remove(){return ve},rename(t){return $e(po("rename",t))},sink(t){return x2e(po("sink",t))},stat(t){return $e(po("stat",t))},stream(t){return kD(po("stream",t))},symlink(t){return $e(po("symlink",t))},truncate(t){return $e(po("truncate",t))},utimes(t){return $e(po("utimes",t))},watch(t){return kD(po("watch",t))},writeFile(t){return $e(po("writeFile",t))},writeFileString(t){return $e(po("writeFileString",t))},...e}),B2e=e=>Ed(BW,Kre(e)),fLt=(e,{bufferSize:t=16,bytesToRead:r,chunkSize:n=sp(64*1024)}={})=>{let o=r!==void 0?sp(r):void 0,i=sp(n);function s(a){if(o!==void 0&&o<=a)return Ry;let c=o!==void 0&&o-a<i?o-a:i;return Bd(e.readAlloc(c),wt({onNone:()=>Ry,onSome:u=>Bd(_y(Dt(u)),l=>s(a+BigInt(u.length)))}))}return wMe(dy(s(BigInt(0))),{capacity:t})}});var mo={};tr(mo,{FileDescriptor:()=>Xre,FileSystem:()=>By,FileTypeId:()=>nk,GiB:()=>gLt,KiB:()=>mLt,MiB:()=>hLt,PiB:()=>yLt,Size:()=>Dh,TiB:()=>ALt,WatchBackend:()=>gQ,WatchEventCreate:()=>ene,WatchEventRemove:()=>rne,WatchEventUpdate:()=>tne,isFile:()=>bLt,layerNoop:()=>ELt,make:()=>Zre,makeNoop:()=>xLt});var Dh,mLt,hLt,gLt,ALt,yLt,By,Zre,xLt,ELt,nk,bLt,Xre,ene,tne,rne,gQ,AQ=h(()=>{RW();sr();lh();T2e();Dh=sp,mLt=w2e,hLt=I2e,gLt=k2e,ALt=v2e,yLt=R2e,By=BW,Zre=_2e,xLt=Kre,ELt=B2e,nk=Symbol.for("@effect/platform/FileSystem/File"),bLt=e=>typeof e=="object"&&e!==null&&nk in e,Xre=dQ(),ene=VI("Create"),tne=VI("Update"),rne=VI("Remove"),gQ=class extends Hw("@effect/platform/FileSystem/WatchBackend")(){}});var D2e,Q2e,nne=h(()=>{wr();D2e=e=>{let t=Q2e(e),r=[];for(let n=0;n<t.length;n++)if(Array.isArray(t[n][0])){let[o,i]=t[n];r.push([`${o[0]}[${o.slice(1).join("][")}]`,i])}else r.push(t[n]);return r},Q2e=e=>{let t=Symbol.iterator in e?_e(e):Object.entries(e),r=[];for(let[n,o]of t)if(Array.isArray(o))for(let i=0;i<o.length;i++)o[i]!==void 0&&r.push([n,String(o[i])]);else if(typeof o=="object"){let i=Q2e(o);for(let[s,a]of i)r.push([[n,...typeof s=="string"?[s]:s],a])}else o!==void 0&&r.push([n,String(o)]);return r}});var DW,TW,N2e,QW=h(()=>{sr();nr();ht();it();DW=Symbol.for("@effect/platform/HttpIncomingMessage"),TW=class extends ai()("@effect/platform/HttpIncomingMessage/MaxBodySize",{defaultValue:W}){},N2e=(e,t)=>{let r=e.headers["content-type"]??"",n;if(r.includes("application/json"))try{n=xd(e.json)}catch{}else if(r.includes("text/")||r.includes("urlencoded"))try{n=xd(e.text)}catch{}let o={...t,headers:xw(e.headers),remoteAddress:e.remoteAddress.toJSON()};return n!==void 0&&(o.body=n),o}});var P2e=h(()=>{});var ine,sne,ane,M2e,F2e=h(()=>{ht();ine=Symbol.for("@effect/platform/HttpBody"),sne=class{[ine];constructor(){this[ine]=ine}[Ce](){return this.toJSON()}toString(){return Fe(this)}},ane=class extends sne{_tag="Empty";toJSON(){return{_id:"@effect/platform/HttpBody",_tag:"Empty"}}},M2e=new ane});var L2e=h(()=>{});var U2e=h(()=>{});var $2e=h(()=>{});var H2e=h(()=>{});var W2e=h(()=>{});var OW,_Lt,cne,j2e,q2e,G2e=h(()=>{nr();id();ht();IW();vW();F2e();OW=Symbol.for("@effect/platform/HttpServerResponse"),_Lt=Symbol.for("@effect/platform/HttpServerRespondable"),cne=class extends dI{status;statusText;cookies;body;[OW];headers;constructor(t,r,n,o,i){if(super(),this.status=t,this.statusText=r,this.cookies=o,this.body=i,this[OW]=OW,i.contentType||i.contentLength){let s={...n};i.contentType&&(s["content-type"]=i.contentType),i.contentLength&&(s["content-length"]=i.contentLength.toString()),this.headers=s}else this.headers=n}commit(){return nt(this)}[_Lt](){return nt(this)}[Ce](){return this.toJSON()}toString(){return Fe(this)}toJSON(){return{_id:"@effect/platform/HttpServerResponse",status:this.status,statusText:this.statusText,headers:xw(this.headers),cookies:this.cookies.toJSON(),body:this.body.toJSON()}}},j2e=e=>typeof e=="object"&&e!==null&&OW in e,q2e=e=>new cne(e?.status??204,e?.statusText,e?.headers?kW(e.headers):zre,e?.cookies??s2e,M2e)});var z2e,yQ,NW=h(()=>{G2e();z2e=j2e,yQ=q2e});var xQ,lne,PW=h(()=>{nr();NW();xQ=Symbol.for("@effect/platform/HttpServerRespondable"),lne=e=>z2e(e)?nt(e):Yf(e[xQ]())});var V2e,Y2e=h(()=>{V2e=Symbol.for("@effect/platform/HttpServerError")});var fne,ap,MW,J2e,FW=h(()=>{Th();PW();NW();Y2e();fne=V2e,ap=class extends CW(fne,"RequestError"){[xQ](){return yQ({status:400})}get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return this.description?`${this.reason}: ${this.description} (${this.methodAndUrl})`:`${this.reason} error (${this.methodAndUrl})`}},MW=class extends CW(fne,"RouteNotFound"){constructor(t){super(t),this.stack=`${this.name}: ${this.message}`}[xQ](){return yQ({status:404})}get message(){return`${this.request.method} ${this.request.url} not found`}},J2e=class extends CW(fne,"ResponseError"){[xQ](){return yQ({status:500})}get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return this.description?`${this.description} (${t})`:`${this.reason} error (${t})`}}});var $W,mne,cS,K2e,LW,UW,Z2e,hne,X2e,eHe,tHe=h(()=>{wr();Vs();vr();id();ht();it();Me();wD();Ob();vt();$W=Symbol.for("effect/Mailbox"),mne=Symbol.for("effect/Mailbox/ReadonlyMailbox"),cS=Ut(),K2e=Vt(cS),LW=Vt(!1),UW=Vt(!0),Z2e=[cS,!0],hne=class extends Ys{scheduler;capacity;strategy;[$W]=$W;[mne]=mne;state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set};messages=[];messagesChunk=Ut();constructor(t,r,n){super(),this.scheduler=t,this.capacity=r,this.strategy=n}offer(t){return ye(()=>{if(this.state._tag!=="Open")return LW;if(this.messages.length+this.messagesChunk.length>=this.capacity)switch(this.strategy){case"dropping":return LW;case"suspend":return this.capacity<=0&&this.state.takers.size>0?(this.messages.push(t),this.releaseTaker(),UW):this.offerRemainingSingle(t);case"sliding":return this.unsafeTake(),this.messages.push(t),UW}return this.messages.push(t),this.scheduleReleaseTaker(),UW})}unsafeOffer(t){return this.state._tag!=="Open"?!1:this.messages.length+this.messagesChunk.length>=this.capacity?this.strategy==="sliding"?(this.unsafeTake(),this.messages.push(t),!0):this.capacity<=0&&this.state.takers.size>0?(this.messages.push(t),this.releaseTaker(),!0):!1:(this.messages.push(t),this.scheduleReleaseTaker(),!0)}offerAll(t){return ye(()=>{if(this.state._tag!=="Open")return M(Co(t));let r=this.unsafeOfferAllArray(t);return r.length===0?K2e:this.strategy==="dropping"?M(ln(r)):this.offerRemainingArray(r)})}unsafeOfferAll(t){return ln(this.unsafeOfferAllArray(t))}unsafeOfferAllArray(t){if(this.state._tag!=="Open")return _e(t);if(this.capacity===Number.POSITIVE_INFINITY||this.strategy==="sliding")return this.messages.length>0&&(this.messagesChunk=Ir(this.messagesChunk,ln(this.messages))),this.strategy==="sliding"?this.messagesChunk=this.messagesChunk.pipe(Ir(Co(t)),w6(this.capacity)):S_(t)?this.messagesChunk=Ir(this.messagesChunk,t):this.messages=_e(t),this.scheduleReleaseTaker(),[];let r=this.capacity<=0?this.state.takers.size:this.capacity-this.messages.length-this.messagesChunk.length;if(r===0)return _e(t);let n=[],o=0;for(let i of t)o<r?this.messages.push(i):n.push(i),o++;return this.scheduleReleaseTaker(),n}fail(t){return this.done(nd(t))}failCause(t){return this.done($t(t))}unsafeDone(t){return this.state._tag!=="Open"?!1:this.state.offers.size===0&&this.messages.length===0&&this.messagesChunk.length===0?(this.finalize(t),!0):(this.state={...this.state,_tag:"Closing",exit:t},!0)}shutdown=V(()=>{if(this.state._tag==="Done")return!0;this.messages=[],this.messagesChunk=cS;let t=this.state.offers;if(this.finalize(this.state._tag==="Open"?Pn:this.state.exit),t.size>0){for(let r of t)r._tag==="Single"?r.resume(LW):r.resume(Vt(ln(r.remaining.slice(r.offset))));t.clear()}return!0});done(t){return V(()=>this.unsafeDone(t))}end=this.done(Pn);clear=ye(()=>{if(this.state._tag==="Done")return qE(this.state.exit,cS);let t=this.unsafeTakeAll();return this.releaseCapacity(),M(t)});takeAll=ye(()=>{if(this.state._tag==="Done")return qE(this.state.exit,Z2e);let t=this.unsafeTakeAll();return t.length===0?je(this.awaitTake,this.takeAll):M([t,this.releaseCapacity()])});takeN(t){return ye(()=>{if(this.state._tag==="Done")return qE(this.state.exit,Z2e);if(t<=0)return M([cS,!1]);t=Math.min(t,this.capacity);let r;if(t<=this.messagesChunk.length)r=Bw(this.messagesChunk,t),this.messagesChunk=jl(this.messagesChunk,t);else if(t<=this.messages.length+this.messagesChunk.length)this.messagesChunk=Ir(this.messagesChunk,ln(this.messages)),this.messages=[],r=Bw(this.messagesChunk,t),this.messagesChunk=jl(this.messagesChunk,t);else return je(this.awaitTake,this.takeN(t));return M([r,this.releaseCapacity()])})}unsafeTake(){if(this.state._tag==="Done")return $L(this.state.exit,nd(new Zwe));let t;if(this.messagesChunk.length>0)t=w_(this.messagesChunk),this.messagesChunk=jl(this.messagesChunk,1);else if(this.messages.length>0)t=this.messages[0],this.messagesChunk=jl(ln(this.messages),1),this.messages=[];else return this.capacity<=0&&this.state.offers.size>0?(this.capacity=1,this.releaseCapacity(),this.capacity=0,this.messages.length>0?Vt(this.messages.pop()):void 0):void 0;return this.releaseCapacity(),Vt(t)}take=ye(()=>this.unsafeTake()??je(this.awaitTake,this.take));await=_f(t=>this.state._tag==="Done"?t(this.state.exit):(this.state.awaiters.add(t),V(()=>{this.state._tag!=="Done"&&this.state.awaiters.delete(t)})));unsafeSize(){let t=this.messages.length+this.messagesChunk.length;return this.state._tag==="Done"?W():H(t)}size=V(()=>this.unsafeSize());commit(){return this.takeAll}pipe(){return Z(this,arguments)}toJSON(){return{_id:"effect/Mailbox",state:this.state._tag,size:this.unsafeSize().toJSON()}}toString(){return Fe(this)}[Ce](){return Fe(this)}offerRemainingSingle(t){return _f(r=>{if(this.state._tag!=="Open")return r(LW);let n={_tag:"Single",message:t,resume:r};return this.state.offers.add(n),V(()=>{this.state._tag==="Open"&&this.state.offers.delete(n)})})}offerRemainingArray(t){return _f(r=>{if(this.state._tag!=="Open")return r(Vt(ln(t)));let n={_tag:"Array",remaining:t,offset:0,resume:r};return this.state.offers.add(n),V(()=>{this.state._tag==="Open"&&this.state.offers.delete(n)})})}releaseCapacity(){if(this.state._tag==="Done")return this.state.exit._tag==="Success";if(this.state.offers.size===0)return this.state._tag==="Closing"&&this.messages.length===0&&this.messagesChunk.length===0?(this.finalize(this.state.exit),this.state.exit._tag==="Success"):!1;let t=this.capacity-this.messages.length-this.messagesChunk.length;for(let r of this.state.offers){if(t===0)return!1;if(r._tag==="Single")this.messages.push(r.message),t--,r.resume(UW),this.state.offers.delete(r);else{for(;r.offset<r.remaining.length;r.offset++){if(t===0)return!1;this.messages.push(r.remaining[r.offset]),t--}r.resume(K2e),this.state.offers.delete(r)}}return!1}awaitTake=_f(t=>this.state._tag==="Done"?t(this.state.exit):(this.state.takers.add(t),V(()=>{this.state._tag!=="Done"&&this.state.takers.delete(t)})));scheduleRunning=!1;scheduleReleaseTaker(){this.scheduleRunning||(this.scheduleRunning=!0,this.scheduler.scheduleTask(this.releaseTaker,0))}releaseTaker=()=>{if(this.scheduleRunning=!1,this.state._tag!=="Done"&&this.state.takers.size!==0){for(let t of this.state.takers)if(this.state.takers.delete(t),t(Pn),this.messages.length+this.messagesChunk.length===0)break}};unsafeTakeAll(){if(this.messagesChunk.length>0){let t=this.messages.length>0?Ir(this.messagesChunk,ln(this.messages)):this.messagesChunk;return this.messagesChunk=cS,this.messages=[],t}else if(this.messages.length>0){let t=ln(this.messages);return this.messages=[],t}else if(this.state._tag!=="Done"&&this.state.offers.size>0)return this.capacity=1,this.releaseCapacity(),this.capacity=0,Dt(this.messages.pop());return cS}finalize(t){if(this.state._tag==="Done")return;let r=this.state;this.state={_tag:"Done",exit:t};for(let n of r.takers)n(t);r.takers.clear();for(let n of r.awaiters)n(t);r.awaiters.clear()}},X2e=e=>st(t=>M(new hne(t.currentScheduler,typeof e=="number"?e:e?.capacity??Number.POSITIVE_INFINITY,typeof e=="number"?"suspend":e?.strategy??"suspend"))),eHe=e=>{let t=Et(e.takeAll,([r,n])=>n?r.length===0?rs:cr(r):Kf(cr(r),t));return t}});var QLt,rHe,ok,nHe,EQ=h(()=>{tHe();ct();QLt=$W,rHe=e=>se(e,QLt),ok=X2e,nHe=eHe});function jW(e,t=!1){if(typeof e!="string")return WW;let r=e.indexOf(";"),n=r!==-1?e.slice(0,r).trim():e.trim();if((t?NLt:OLt).test(n)===!1)return WW;let i={value:n.toLowerCase(),parameters:Object.create(null)};if(r===-1)return i;let s,a,c;for(oHe.lastIndex=r;a=oHe.exec(e);){if(a.index!==r)return WW;r+=a[0].length,s=a[1].toLowerCase(),c=a[2],c[0]==='"'&&(c=c.slice(1,c.length-1),!t&&iHe.test(c)&&(c=c.replace(iHe,"$1"))),i.parameters[s]=c}return r!==e.length?WW:i}var oHe,iHe,OLt,NLt,WW,sHe=h(()=>{oHe=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu,iHe=/\\([\v\u0020-\u00ff])/gu,OLt=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,NLt=/^[!#$%&'*+.^\w|~-]+$/u,WW={value:"",parameters:Object.create(null)}});function aHe(){let e=new TextDecoder,t={state:sl.key,headers:Object.create(null),key:"",value:void 0,crlf:0,previousChunk:void 0,pairs:0,size:0};function r(i){return t.state=sl.key,t.headers=Object.create(null),t.key="",t.value=void 0,t.crlf=0,t.previousChunk=void 0,t.pairs=0,t.size=0,i}function n(i,s){let a=new Uint8Array(i.length+s.length);return a.set(i),a.set(s,i.length),a}function o(i){return r({_tag:"Failure",reason:i,headers:t.headers})}return function(s,a){let c=0,u;if(t.previousChunk!==void 0){c=t.previousChunk.length,u=c;let d=new Uint8Array(s.length+c);d.set(t.previousChunk),d.set(s,c),t.previousChunk=void 0,s=d}let l=s.length;e:for(;a<l;){if(t.state===sl.key){let d=a;for(;d<l;d++){if(t.size++>16384)return o("HeaderTooLarge");if(s[d]===58){if(t.key+=e.decode(s.subarray(a,d)).toLowerCase(),t.key.length===0)return o("InvalidHeaderName");s[d+1]===32&&s[d+2]!==32&&s[d+2]!==9?(a=d+2,t.state=sl.value,t.size++):s[d+1]!==32&&s[d+1]!==9?(a=d+1,t.state=sl.value):(a=d+1,t.state=sl.whitespace);break}else if(MLt[s[d]]!==1)return o("InvalidHeaderName")}if(d===l)return t.key+=e.decode(s.subarray(a,l)).toLowerCase(),bQ}if(t.state===sl.whitespace){for(;a<l;a++){if(t.size++>16384)return o("HeaderTooLarge");if(s[a]!==32&&s[a]!==9){t.state=sl.value;break}}if(a===l)return bQ}if(t.state===sl.value){let d=a;for(u!==void 0&&(d=u,u=void 0);d<l;d++){if(t.size++>16384)return o("HeaderTooLarge");if(s[d]===13||t.crlf>0){let f=s[d];if(f===13&&t.crlf===0&&(t.crlf=1,d++,t.size++,f=s[d]),f===10&&t.crlf===1&&(t.crlf=2,d++,t.size++,f=s[d]),f===13&&t.crlf===2&&(t.crlf=3,d++,t.size++,f=s[d]),f===10&&t.crlf===3&&(t.crlf=4,d++,t.size++),t.crlf<4&&d>=l)return t.previousChunk=s.subarray(a),bQ;if(t.crlf>=2){t.value=t.value===void 0?s.subarray(a,d-t.crlf):n(t.value,s.subarray(a,d-t.crlf));let p=e.decode(t.value);if(t.headers[t.key]===void 0?t.headers[t.key]=p:typeof t.headers[t.key]=="string"?t.headers[t.key]=[t.headers[t.key],p]:t.headers[t.key].push(p),a=d,t.size--,t.crlf!==4&&t.pairs===100)return o("TooManyHeaders");if(t.crlf===3)return o("InvalidHeaderValue");if(t.crlf===4)return r({_tag:"Headers",headers:t.headers,endPosition:a-c});t.pairs++,t.key="",t.value=void 0,t.crlf=0,t.state=sl.key;continue e}}else if(FLt[s[d]]!==1)return o("InvalidHeaderValue")}if(d===l)return t.value=t.value===void 0?s.subarray(a,l):n(t.value,s.subarray(a,l)),bQ}}return a>l&&(t.size+=l-a),bQ}}var sl,bQ,MLt,FLt,cHe=h(()=>{(function(e){e[e.key=0]="key",e[e.whitespace=1]="whitespace",e[e.value=2]="value"})(sl||(sl={}));bQ={_tag:"Continue"},MLt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1],FLt=[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]});function ULt(e){let t=new TextEncoder().encode(e),r=t.length,n={};for(let o=0;o<r;o++){let i=t[o];n[i]===void 0&&(n[i]=[]),n[i].push(o)}return{needle:t,needleLength:r,indexes:n,firstByte:t[0],previousChunk:void 0,previousChunkLength:0,matchIndex:0}}function uHe(e,t,r){let n=ULt(e);r!==void 0&&(n.previousChunk=r,n.previousChunkLength=r.length);function o(){if("Buffer"in globalThis&&!("Bun"in globalThis||"Deno"in globalThis))return function(u,l,d){return Buffer.prototype.indexOf.call(u,l,d)};let c=new Uint8Array(256).fill(n.needle.length);for(let u=0,l=n.needle.length-1;u<l;++u)c[n.needle[u]]=l-u;return function(u,l,d){let f=u.length,p=d+n.needleLength-1;for(;p<f;){for(let m=n.needleLength-1,g=p;m>=0&&u[g]===l[m];m--,g--)if(m===0)return g;p+=c[u[p]]}return-1}}let i=o();function s(c){let u=c.length;if(n.previousChunk!==void 0){let d=new Uint8Array(n.previousChunkLength+u);d.set(n.previousChunk),d.set(c,n.previousChunkLength),c=d,u=n.previousChunkLength+u,n.previousChunk=void 0}if(u<n.needleLength){n.previousChunk=c,n.previousChunkLength=u;return}let l=0;for(;l<u;){let d=i(c,n.needle,l);if(d>-1){d>l&&t(n.matchIndex,c.subarray(l,d)),n.matchIndex+=1,l=d+n.needleLength;continue}else if(c[u-1]in n.indexes){let f=n.indexes[c[u-1]],p=-1;for(let m=0,g=f.length;m<g;m++){let A=f[m];c[u-1-A]===n.firstByte&&m>p&&(p=A)}p===-1?l===0?t(n.matchIndex,c):t(n.matchIndex,c.subarray(l)):(u-1-p>l&&t(n.matchIndex,c.subarray(l,u-1-p)),n.previousChunk=c.subarray(u-1-p),n.previousChunkLength=p+1)}else l===0?t(n.matchIndex,c):t(n.matchIndex,c.subarray(l));break}}function a(){n.previousChunk!==void 0&&n.previousChunk!==r&&t(n.matchIndex,n.previousChunk),n.previousChunk=r,n.previousChunkLength=r?.length??0,n.matchIndex=0}return{write:s,end:a}}var lHe=h(()=>{});function gne(e){return e.filename!==void 0||e.contentType==="application/octet-stream"}function VLt(e){return jW(e["content-type"]).parameters.boundary}function qW(e){}function pHe({headers:e,onFile:t,onField:r,onError:n,onDone:o,isFile:i=gne,maxParts:s=1/0,maxTotalSize:a=1/0,maxPartSize:c=1/0,maxFieldSize:u=1024*1024}){let l=VLt(e);if(l===void 0)return n({_tag:"InvalidBoundary"}),{write:qW,end(){}};let d={state:Qh.headers,index:0,parts:0,onChunk:qW,info:void 0,headerSkip:0,partSize:0,totalSize:0,isFile:!1,fieldChunks:[],fieldSize:0};function f(){d.state=Qh.body,d.isFile=!0,d.onChunk=qW}let p=aHe(),m=uHe(`\r
70
70
  --${l}`,function(g,A){if(g===0){f();return}else if(g!==d.index){if(d.index>0)if(d.isFile)d.onChunk(null),d.partSize=0;else{if(d.fieldChunks.length===1)r(d.info,d.fieldChunks[0]);else{let E=new Uint8Array(d.fieldSize),y=0;for(let b=0;b<d.fieldChunks.length;b++){let w=d.fieldChunks[b];E.set(w,y),y+=w.length}r(d.info,E)}d.fieldSize=0,d.fieldChunks=[]}if(d.state=Qh.headers,d.index=g,d.headerSkip=2,A[0]===45&&A[1]===45)return o();d.parts++,d.parts>s&&n(jLt)}if((d.partSize+=A.length)>c&&n(GLt),d.state===Qh.headers){let E=p(A,d.headerSkip);if(d.headerSkip=0,E._tag==="Continue")return;if(E._tag==="Failure")return f(),n({_tag:"BadHeaders",error:E});let y=jW(E.headers["content-type"]),b=jW(E.headers["content-disposition"],!0);if(b.value==="form-data"&&!("name"in b.parameters))return f(),n(HLt);let w;if("filename*"in b.parameters){let I=b.parameters["filename*"].split("''");I.length===2&&(w=decodeURIComponent(I[1]))}if(d.info={name:b.parameters.name??"",filename:w??b.parameters.filename,contentType:y.value===""?b.parameters.filename!==void 0?"application/octet-stream":"text/plain":y.value,contentTypeParameters:y.parameters,contentDisposition:b.value,contentDispositionParameters:b.parameters,headers:E.headers},d.state=Qh.body,d.isFile=i(d.info),d.isFile&&(d.onChunk=t(d.info)),E.endPosition<A.length)if(d.isFile)d.onChunk(A.subarray(E.endPosition));else{let I=A.subarray(E.endPosition);(d.fieldSize+=I.length)>u&&n(dHe),d.fieldChunks.push(I)}}else d.isFile?d.onChunk(A):((d.fieldSize+=A.length)>u&&n(dHe),d.fieldChunks.push(A))},zLt);return{write(g){return(d.totalSize+=g.length)>a?n(qLt):m.write(g)},end(){m.end(),d.state===Qh.body&&n(WLt),d.state=Qh.headers,d.index=0,d.parts=0,d.onChunk=qW,d.info=void 0,d.totalSize=0,d.partSize=0,d.fieldChunks=[],d.fieldSize=0}}}function YLt(e){if(e==="utf-8"||e==="utf8"||e==="")return fHe;try{return new TextDecoder(e)}catch{return fHe}}function mHe(e,t){return YLt(e.contentTypeParameters.charset??"utf-8").decode(t)}var Qh,HLt,WLt,jLt,qLt,GLt,dHe,zLt,fHe,hHe=h(()=>{sHe();cHe();lHe();(function(e){e[e.headers=0]="headers",e[e.body=1]="body"})(Qh||(Qh={}));HLt={_tag:"InvalidDisposition"},WLt={_tag:"EndNotReached"},jLt={_tag:"ReachedLimit",limit:"MaxParts"},qLt={_tag:"ReachedLimit",limit:"MaxTotalSize"},GLt={_tag:"ReachedLimit",limit:"MaxPartSize"},dHe={_tag:"ReachedLimit",limit:"MaxFieldSize"},zLt=new TextEncoder().encode(`\r
71
71
  `);fHe=new TextDecoder("utf-8")});var gHe,AHe,yHe,xHe=h(()=>{hHe();gHe=pHe,AHe=gne,yHe=mHe});function EHe(e,t){let r="",n=0,o=-1,i=0,s;for(let a=0;a<=e.length;++a){if(a<e.length)s=e.charCodeAt(a);else{if(s===47)break;s=47}if(s===47){if(!(o===a-1||i===1))if(o!==a-1&&i===2){if(r.length<2||n!==2||r.charCodeAt(r.length-1)!==46||r.charCodeAt(r.length-2)!==46){if(r.length>2){let c=r.lastIndexOf("/");if(c!==r.length-1){c===-1?(r="",n=0):(r=r.slice(0,c),n=r.length-1-r.lastIndexOf("/")),o=a,i=0;continue}}else if(r.length===2||r.length===1){r="",n=0,o=a,i=0;continue}}t&&(r.length>0?r+="/..":r="..",n=2)}else r.length>0?r+="/"+e.slice(o+1,a):r=e.slice(o+1,a),n=a-o-1;o=a,i=0}else s===46&&i!==-1?++i:i=-1}return r}function ZLt(e,t){let r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+e+n:n}function XLt(e){if(e.protocol!=="file:")return $e(new _s({module:"Path",method:"fromFileUrl",description:"URL must be of scheme file"}));if(e.hostname!=="")return $e(new _s({module:"Path",method:"fromFileUrl",description:"Invalid file URL host"}));let t=e.pathname;for(let r=0;r<t.length;r++)if(t[r]==="%"){let n=t.codePointAt(r+2)|32;if(t[r+1]==="2"&&n===102)return $e(new _s({module:"Path",method:"fromFileUrl",description:"must not include encoded / characters"}))}return nt(decodeURIComponent(t))}function t1t(e){let t=new URL("file://"),r=bHe(e);return e.charCodeAt(e.length-1)===e1t&&r[r.length-1]!=="/"&&(r+="/"),t.pathname=a1t(r),nt(t)}function a1t(e){return e.includes("%")&&(e=e.replace(r1t,"%25")),e.includes("\\")&&(e=e.replace(n1t,"%5C")),e.includes(`
72
- `)&&(e=e.replace(o1t,"%0A")),e.includes("\r")&&(e=e.replace(i1t,"%0D")),e.includes(" ")&&(e=e.replace(s1t,"%09")),e}var GW,yne,bHe,e1t,r1t,n1t,o1t,i1t,s1t,Ane,SHe=h(()=>{sr();nr();oe();Th();GW=Symbol.for("@effect/platform/Path"),yne=Jt("@effect/platform/Path");bHe=function(){let t="",r=!1,n;for(let o=arguments.length-1;o>=-1&&!r;o--){let i;if(o>=0)i=arguments[o];else{let s=globalThis.process;n===void 0&&"process"in globalThis&&typeof s=="object"&&s!==null&&typeof s.cwd=="function"&&(n=s.cwd()),i=n}i.length!==0&&(t=i+"/"+t,r=i.charCodeAt(0)===47)}return t=EHe(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},e1t=47;r1t=/%/g,n1t=/\\/g,o1t=/\n/g,i1t=/\r/g,s1t=/\t/g;Ane=yne.of({[GW]:GW,resolve:bHe,normalize(e){if(e.length===0)return".";let t=e.charCodeAt(0)===47,r=e.charCodeAt(e.length-1)===47;return e=EHe(e,!t),e.length===0&&!t&&(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return".";let e;for(let t=0;t<arguments.length;++t){let r=arguments[t];r.length>0&&(e===void 0?e=r:e+="/"+r)}return e===void 0?".":Ane.normalize(e)},relative(e,t){if(e===t||(e=Ane.resolve(e),t=Ane.resolve(t),e===t))return"";let r=1;for(;r<e.length&&e.charCodeAt(r)===47;++r);let n=e.length,o=n-r,i=1;for(;i<t.length&&t.charCodeAt(i)===47;++i);let a=t.length-i,c=o<a?o:a,u=-1,l=0;for(;l<=c;++l){if(l===c){if(a>c){if(t.charCodeAt(i+l)===47)return t.slice(i+l+1);if(l===0)return t.slice(i+l)}else o>c&&(e.charCodeAt(r+l)===47?u=l:l===0&&(u=0));break}let f=e.charCodeAt(r+l),p=t.charCodeAt(i+l);if(f!==p)break;f===47&&(u=l)}let d="";for(l=r+u+1;l<=n;++l)(l===n||e.charCodeAt(l)===47)&&(d.length===0?d+="..":d+="/..");return d.length>0?d+t.slice(i+u):(i+=u,t.charCodeAt(i)===47&&++i,t.slice(i))},dirname(e){if(e.length===0)return".";let t=e.charCodeAt(0),r=t===47,n=-1,o=!0;for(let i=e.length-1;i>=1;--i)if(t=e.charCodeAt(i),t===47){if(!o){n=i;break}}else o=!1;return n===-1?r?"/":".":r&&n===1?"//":e.slice(0,n)},basename(e,t){let r=0,n=-1,o=!0,i;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";let s=t.length-1,a=-1;for(i=e.length-1;i>=0;--i){let c=e.charCodeAt(i);if(c===47){if(!o){r=i+1;break}}else a===-1&&(o=!1,a=i+1),s>=0&&(c===t.charCodeAt(s)?--s===-1&&(n=i):(s=-1,n=a))}return r===n?n=a:n===-1&&(n=e.length),e.slice(r,n)}else{for(i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!o){r=i+1;break}}else n===-1&&(o=!1,n=i+1);return n===-1?"":e.slice(r,n)}},extname(e){let t=-1,r=0,n=-1,o=!0,i=0;for(let s=e.length-1;s>=0;--s){let a=e.charCodeAt(s);if(a===47){if(!o){r=s+1;break}continue}n===-1&&(o=!1,n=s+1),a===46?t===-1?t=s:i!==1&&(i=1):t!==-1&&(i=-1)}return t===-1||n===-1||i===0||i===1&&t===n-1&&t===r+1?"":e.slice(t,n)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return ZLt("/",t)},parse(e){let t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;let r=e.charCodeAt(0),n=r===47,o;n?(t.root="/",o=1):o=0;let i=-1,s=0,a=-1,c=!0,u=e.length-1,l=0;for(;u>=o;--u){if(r=e.charCodeAt(u),r===47){if(!c){s=u+1;break}continue}a===-1&&(c=!1,a=u+1),r===46?i===-1?i=u:l!==1&&(l=1):i!==-1&&(l=-1)}return i===-1||a===-1||l===0||l===1&&i===a-1&&i===s+1?a!==-1&&(s===0&&n?t.base=t.name=e.slice(1,a):t.base=t.name=e.slice(s,a)):(s===0&&n?(t.name=e.slice(1,i),t.base=e.slice(1,a)):(t.name=e.slice(s,i),t.base=e.slice(s,a)),t.ext=e.slice(i,a)),s>0?t.dir=e.slice(0,s-1):n&&(t.dir="/"),t},sep:"/",fromFileUrl:XLt,toFileUrl:t1t,toNamespacedPath:be})});var uS,Oh,zW=h(()=>{SHe();uS=GW,Oh=yne});function l1t(e){switch(e._tag){case"ReachedLimit":switch(e.limit){case"MaxParts":return new Qc({reason:"TooManyParts",cause:e});case"MaxFieldSize":return new Qc({reason:"FieldTooLarge",cause:e});case"MaxPartSize":return new Qc({reason:"FileTooLarge",cause:e});case"MaxTotalSize":return new Qc({reason:"BodyTooLarge",cause:e})}default:return new Qc({reason:"Parse",cause:e})}}var xne,wHe,Qc,u1t,kHe,IHe,SQ,Ene,bne,d1t,f1t,vHe,Sne,Cne,wne,Ine,kne,vne=h(()=>{aS();vr();sr();nr();Ro();oe();ht();EQ();it();X0();wd();xHe();AQ();QW();zW();xne=Symbol.for("@effect/platform/Multipart"),wHe=Symbol.for("@effect/platform/Multipart/MultipartError"),Qc=class extends sS()("MultipartError",{reason:is("FileTooLarge","FieldTooLarge","BodyTooLarge","TooManyParts","InternalError","Parse"),cause:ip}){[wHe]=wHe;get message(){return this.reason}},u1t=e=>$a(t=>{let r=Dr(t.currentContext,kne);return nt({headers:e,maxParts:Gr(Dr(t.currentContext,Cne)),maxFieldSize:Number(Dr(t.currentContext,wne)),maxPartSize:Dr(t.currentContext,Ine).pipe(dr(Number),Gr),maxTotalSize:Dr(t.currentContext,TW).pipe(dr(Number),Gr),isFile:r.length===0?void 0:n=>!gbe(r,o=>n.contentType.includes(o))&&AHe(n)})}),kHe=(e,t=16)=>_W(Ib([u1t(e),ok(t)]),([r,n])=>{let o=[],i=W(),s={awaitRead:()=>ve,emit(l){return n.offer(l)},error(l){return i=H(Mn(l)),n.end},done(l){return n.end}},a=gHe({...r,onField(l,d){o.push(new Ene(l.name,l.contentType,yHe(l,d)))},onFile(l){let d=[],f=!1,p=ek(()=>{if(d.length===0)return f?Ry:pQ(c,p);let m=ln(d);return d=[],f?_y(m):pQ(_y(m),pQ(c,p))});return o.push(new bne(l,p)),function(m){m===null?f=!0:d.push(m)}},onError(l){i=H(Cc(l1t(l)))},onDone(){i=H(wc)}}),c=Bd(n.takeAll,([l,d])=>A2e(()=>{C_(l,C_(a.write)),d&&a.end()})),u=Bd(c,()=>{if(o.length===0)return i._tag==="None"?u:IHe(i.value);let l=ln(o);return o=[],pQ(_y(l),i._tag==="None"?u:IHe(i.value))});return fQ(u,s)},([,r])=>r.shutdown),IHe=e=>e._tag==="Success"?Ry:Jre(e.cause);SQ=class extends Wg{[xne];constructor(){super(),this[xne]=xne}},Ene=class extends SQ{key;contentType;value;_tag="Field";constructor(t,r,n){super(),this.key=t,this.contentType=r,this.value=n}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"Field",key:this.key,contentType:this.contentType,value:this.value}}},bne=class extends SQ{_tag="File";key;name;contentType;content;contentEffect;constructor(t,r){super(),this.key=t.name,this.name=t.filename??t.name,this.contentType=t.contentType,this.content=dy(r),this.contentEffect=r.pipe(p2e(f1t),h2e,Ha(n=>new Qc({reason:"InternalError",cause:n})))}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"File",key:this.key,name:this.name,contentType:this.contentType}}},d1t=(e,t)=>Ee(By,r=>Ha(_0(t.content,r.sink(e)),n=>new Qc({reason:"InternalError",cause:n}))),f1t=ek(()=>{let e=new Uint8Array(0),t=m2e({onInput(r){for(let n of r){let o=new Uint8Array(e.length+n.length);o.set(e,0),o.set(n,e.length),e=o}return t},onFailure:r=>Jre(r),onDone:()=>g2e(e)});return t}),vHe=(e,t=d1t)=>Go(function*(){let r=yield*By,n=yield*Oh,o=yield*r.makeTempDirectoryScoped(),i=Object.create(null);return yield*TMe(e,s=>{if(s._tag==="Field")return s.key in i?typeof i[s.key]=="string"?i[s.key]=[i[s.key],s.value]:i[s.key].push(s.value):i[s.key]=s.value,ve;if(s.name==="")return ve;let a=s,c=n.join(o,n.basename(a.name).slice(-128)),u=new Sne(a.key,a.name,a.contentType,c);return Array.isArray(i[s.key])?i[s.key].push(u):i[s.key]=[u],t(c,a)}),i}).pipe(j$({SystemError:r=>$e(new Qc({reason:"InternalError",cause:r})),BadArgument:r=>$e(new Qc({reason:"InternalError",cause:r}))})),Sne=class extends SQ{key;name;contentType;path;_tag="PersistedFile";constructor(t,r,n,o){super(),this.key=t,this.name=r,this.contentType=n,this.path=o}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"PersistedFile",key:this.key,name:this.name,contentType:this.contentType,path:this.path}}},Cne=class extends si()("@effect/platform/Multipart/MaxParts",{defaultValue:W}){},wne=class extends si()("@effect/platform/Multipart/MaxFieldSize",{defaultValue:fm(Dh(10*1024*1024))}){},Ine=class extends si()("@effect/platform/Multipart/MaxFileSize",{defaultValue:W}){},kne=class extends si()("@effect/platform/Multipart/FieldMimeTypes",{defaultValue:fm(Kg("application/json"))}){}});var Rne,m1t,h1t,g1t,_He,BHe,THe,A1t,DHe,QHe,_ne=h(()=>{Vs();$u();nr();Ro();WI();Zl();oe();dc();ht();x_();Me();ct();Rne=Symbol.for("effect/FiberSet"),m1t=e=>se(e,Rne),h1t={[Rne]:Rne,[Symbol.iterator](){return this.state._tag==="Closed"?gF():this.state.backing[Symbol.iterator]()},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"FiberMap",state:this.state}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},g1t=(e,t)=>{let r=Object.create(h1t);return r.state={_tag:"Open",backing:e},r.deferred=t,r},_He=()=>zo(De(rn(),e=>g1t(new Set,e)),e=>$a(t=>{let r=e.state;if(r._tag==="Closed")return ve;e.state={_tag:"Closed"};let n=r.backing;return w8(n,jw(t.id(),THe)).pipe(f0(e.deferred))})),BHe=-1,THe=YSe(BHe,0),A1t=Kwe(void 0,{emptyCase:Gi,failCase:Gi,dieCase:Gi,interruptCase:(e,t)=>FF(qw(t),BHe),sequentialCase:(e,t,r)=>t||r,parallelCase:(e,t,r)=>t||r}),DHe=x(e=>m1t(e[0]),(e,t,r)=>{if(e.state._tag==="Closed"){t.unsafeInterruptAsFork(jw(r?.interruptAs??ai,THe));return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(n=>{e.state._tag!=="Closed"&&(e.state.backing.delete(t),sd(n)&&(r?.propagateInterruption===!0?!A1t(n.cause):!Ywe(n.cause))&&kc(e.deferred,n))})}),QHe=e=>Ht(e.deferred)});var Bne,NHe,PHe=h(()=>{Bne=Symbol.for("@effect/platform/Socket/CloseEvent"),NHe=class{code;reason;[Bne];constructor(t=1e3,r){this.code=t,this.reason=r,this[Bne]=Bne}toString(){return this.reason?`${this.code}: ${this.reason}`:`${this.code}`}}});var VW,FHe,LHe,MHe,UHe=h(()=>{sr();nr();ht();it();wd();IW();vW();QW();FW();vne();nne();VW=Symbol.for("@effect/platform/HttpServerRequest"),FHe=Jt("@effect/platform/HttpServerRequest"),LHe=Jt("@effect/platform/HttpServerRequest/ParsedSearchParams"),MHe=class e extends Wg{source;url;headersOverride;remoteAddressOverride;[VW];[DW];constructor(t,r,n,o){super(),this.source=t,this.url=r,this.headersOverride=n,this.remoteAddressOverride=o,this[VW]=VW,this[DW]=DW}toJSON(){return N2e(this,{_id:"@effect/platform/HttpServerRequest",method:this.method,url:this.originalUrl})}modify(t){return new e(this.source,t.url??this.url,t.headers??this.headersOverride,t.remoteAddress??this.remoteAddressOverride)}get method(){return this.source.method.toUpperCase()}get originalUrl(){return this.source.url}get remoteAddress(){return this.remoteAddressOverride?H(this.remoteAddressOverride):W()}get headers(){return this.headersOverride??=kW(this.source.headers),this.headersOverride}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=a2e(this.headers.cookie??"")}get stream(){return this.source.body?kMe(()=>this.source.body,t=>new ap({request:this,reason:"Decode",cause:t})):kD(new ap({request:this,reason:"Decode",description:"can not create stream from empty body"}))}textEffect;get text(){return this.textEffect?this.textEffect:(this.textEffect=xd(GT(ey({try:()=>this.source.text(),catch:t=>new ap({request:this,reason:"Decode",cause:t})}))),this.textEffect)}get json(){return zT(this.text,{try:t=>JSON.parse(t),catch:t=>new ap({request:this,reason:"Decode",cause:t})})}get urlParamsBody(){return Ee(this.text,t=>Wu({try:()=>D2e(new URLSearchParams(t)),catch:r=>new ap({request:this,reason:"Decode",cause:r})}))}multipartEffect;get multipart(){return this.multipartEffect?this.multipartEffect:(this.multipartEffect=xd(GT(vHe(this.multipartStream))),this.multipartEffect)}get multipartStream(){return _Me(RMe(this.stream,t=>new Qc({reason:"InternalError",cause:t})),kHe(this.headers))}arrayBufferEffect;get arrayBuffer(){return this.arrayBufferEffect?this.arrayBufferEffect:(this.arrayBufferEffect=xd(GT(ey({try:()=>this.source.arrayBuffer(),catch:t=>new ap({request:this,reason:"Decode",cause:t})}))),this.arrayBufferEffect)}get upgrade(){return $e(new ap({request:this,reason:"Decode",description:"Not an upgradeable ServerRequest"}))}}});var YW,$He,Tne=h(()=>{UHe();YW=FHe,$He=LHe});function qHe(e){let t=new jHe;if(typeof e!="string")return t;let r=e.length,n="",o="",i=-1,s=-1,a=!1,c=!1,u=!1,l=!1,d=!1,f=0;for(let p=0;p<r+1;p++)if(f=p!==r?e.charCodeAt(p):38,f===38){if(d=s>i,d||(s=p),n=e.slice(i+1,s),d||n.length>0){if(u&&(n=n.replace(WHe," ")),a)try{n=decodeURIComponent(n)||n}catch{}if(d&&(o=e.slice(s+1,p),l&&(o=o.replace(WHe," ")),c))try{o=decodeURIComponent(o)||o}catch{}let m=t[n];m===void 0?t[n]=o:m.pop?m.push(o):t[n]=[m,o]}o="",i=p,s=p,a=!1,c=!1,u=!1,l=!1}else f===61?s<=i?s=p:c=!0:f===43?s>i?l=!0:u=!0:f===37&&(s>i?c=!0:a=!0);return t}var WHe,jHe,GHe=h(()=>{WHe=/\+/g,jHe=function(){};jHe.prototype=Object.create(null)});function zHe(e){return e.replace(/\/\/+/g,"/")}function VHe(e){return e.length>1&&e.charCodeAt(e.length-1)===47?e.slice(0,-1):e}function C1t(e){let t=e.length;return function(r){let n={};for(let o=0;o<t;o++)n[e[o]]=r[o];return n}}function w1t(e,t){let r=1;for(;t<e.length;){if(t++,e[t]==="\\"){t++;continue}if(e[t]===")"?r--:e[t]==="("&&r++,!r)return t}throw new TypeError('Invalid regexp expression in "'+e+'"')}function I1t(e){return e.charCodeAt(1)===94&&(e=e.slice(0,1)+e.slice(2)),e.charCodeAt(e.length-2)===36&&(e=e.slice(0,e.length-2)+e.slice(e.length-1)),e}function k1t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function KHe(e,t){if(e===50)return t===53?"%":t===51?"#":t===52?"$":t===54?"&":t===66||t===98?"+":t===67||t===99?",":t===70||t===102?"/":void 0;if(e===51)return t===65||t===97?":":t===66||t===98?";":t===68||t===100?"=":t===70||t===102?"?":void 0;if(e===52&&t===48)return"@"}function v1t(e){let t=!1,r=!1,n="";for(let i=1;i<e.length;i++){let s=e.charCodeAt(i);if(s===37){let a=e.charCodeAt(i+1),c=e.charCodeAt(i+2);KHe(a,c)===void 0?t=!0:(r=!0,a===50&&c===53&&(t=!0,e=e.slice(0,i+1)+"25"+e.slice(i+1),i+=2),i+=2)}else if(s===63||s===59||s===35){n=e.slice(i+1),e=e.slice(0,i);break}}return{path:t?decodeURI(e):e,querystring:n,shouldDecodeParam:r}}function YHe(e){let t=e.indexOf("%");if(t===-1)return e;let r="",n=t;for(let o=t;o<e.length;o++)if(e.charCodeAt(o)===37){let i=e.charCodeAt(o+1),s=e.charCodeAt(o+2),a=KHe(i,s);r+=e.slice(n,o)+a,n=o+3}return e.slice(0,t)+r+e.slice(n)}var b1t,Dne,JHe,Qne,One,JW,KW,CQ,Nne,Pne,S1t,R1t,ZHe=h(()=>{GHe();b1t=/^https?:\/\/.*?\//,Dne=/(\/:[^/()]*?)\?(\/?)/,JHe=(e={})=>new Qne(e),Qne=class{constructor(t={}){this.options={ignoreTrailingSlash:!0,ignoreDuplicateSlashes:!0,caseSensitive:!1,maxParamLength:100,...t}}options;routes=[];trees={};on(t,r,n){let o=r.match(Dne);if(o&&o.index!==void 0){S1t(r.length===o.index+o[0].length,"Optional Parameter needs to be the last parameter of the path");let s=r.replace(Dne,"$1$2"),a=r.replace(Dne,"$2");this.on(t,s,n),this.on(t,a,n);return}this.options.ignoreDuplicateSlashes&&(r=zHe(r)),this.options.ignoreTrailingSlash&&(r=VHe(r));let i=typeof t=="string"?[t]:t;for(let s of i)this._on(s,r,n)}all(t,r){this.on(R1t,t,r)}_on(t,r,n){this.trees[t]===void 0&&(this.trees[t]=new CQ("/"));let o=r;if(o==="*"&&this.trees[t].prefix.length!==0){let u=this.trees[t];this.trees[t]=new CQ(""),this.trees[t].staticChildren["/"]=u}let i=this.trees[t].prefix.length,s=this.trees[t],a=[];for(let u=0;u<=o.length;u++){if(o.charCodeAt(u)===58&&o.charCodeAt(u+1)===58){u++;continue}let l=o.charCodeAt(u)===58&&o.charCodeAt(u+1)!==58,d=o.charCodeAt(u)===42;if(l||d||u===o.length&&u!==i){let f=o.slice(i,u);this.options.caseSensitive||(f=f.toLowerCase()),f=f.split("::").join(":"),f=f.split("%").join("%25"),s=s.createStaticChild(f)}if(l){let f=!1,p=[],m=u+1;for(let g=m;;g++){let A=o.charCodeAt(g),E=A===40,y=A===45||A===46,b=A===47||g===o.length;if(E||y||b){let w=o.slice(m,g);if(a.push(w),f=f||E||y,E){let k=w1t(o,g),R=o.slice(g,k+1);p.push(I1t(R)),g=k+1}else p.push("(.*?)");let I=g;for(;g<o.length;g++){let k=o.charCodeAt(g);if(k===47)break;if(k===58)if(o.charCodeAt(g+1)===58)g++;else break}let v=o.slice(I,g);if(v&&(v=v.split("::").join(":"),v=v.split("%").join("%25"),p.push(k1t(v))),m=g+1,b||o.charCodeAt(g)===47||g===o.length){let k=f?"()"+v:v,R=o.slice(u,g);o=o.slice(0,u+1)+k+o.slice(g),u+=k.length;let B=f?new RegExp("^"+p.join("")+"$"):void 0;s=s.createParametricChild(B,v,R),i=u+1;break}}}}else if(d&&(a.push("*"),s=s.createWildcardChild(),i=u+1,u!==o.length-1))throw new Error("Wildcard must be the last character in the route")}this.options.caseSensitive||(o=o.toLowerCase()),o==="*"&&(o="/*");for(let u of this.routes)if(u.method===t&&u.pattern===o)throw new Error(`Method '${t}' already declared for route '${o}'`);let c={method:t,path:r,pattern:o,params:a,handler:n};this.routes.push(c),s.addRoute(c)}has(t,r){let n=this.trees[t];if(n===void 0)return!1;let o=n.getStaticChild(r);return o===void 0?!1:o.isLeafNode}find(t,r){let n=this.trees[t];if(n===void 0)return;r.charCodeAt(0)!==47&&(r=r.replace(b1t,"/")),this.options.ignoreDuplicateSlashes&&(r=zHe(r));let o,i,s;try{o=v1t(r),r=o.path,i=o.querystring,s=o.shouldDecodeParam}catch{return}this.options.ignoreTrailingSlash&&(r=VHe(r));let a=r;this.options.caseSensitive===!1&&(r=r.toLowerCase());let c=this.options.maxParamLength,u=n.prefix.length,l=[],d=r.length,f=[];for(;;){if(u===d&&n.isLeafNode){let m=n.handlerStorage?.find();if(m!==void 0)return{handler:m.handler,params:m.createParams(l),searchParams:qHe(i)}}let p=n.getNextNode(r,u,f,l.length);if(p===void 0){if(f.length===0)return;let m=f.pop();u=m.brotherPathIndex,l.splice(m.paramsCount),p=m.brotherNode}if(n=p,n._tag==="StaticNode"){u+=n.prefix.length;continue}if(n._tag==="WildcardNode"){let m=a.slice(u);s&&(m=YHe(m)),l.push(m),u=d;continue}if(n._tag==="ParametricNode"){let m=a.indexOf("/",u);m===-1&&(m=d);let g=a.slice(u,m);if(s&&(g=YHe(g)),n.regex!==void 0){let A=n.regex.exec(g);if(A===null)continue;for(let E=1;E<A.length;E++){let y=A[E];if(y.length>c)return;l.push(y)}}else{if(g.length>c)return;l.push(g)}u=m}}}},One=class{handlers=[];unconstrainedHandler;find(){return this.unconstrainedHandler}add(t){let r={params:t.params,handler:t.handler,createParams:C1t(t.params)};this.handlers.push(r),this.unconstrainedHandler=this.handlers[0]}},JW=class{isLeafNode=!1;routes;handlerStorage;addRoute(t){this.routes===void 0?this.routes=[t]:this.routes.push(t),this.handlerStorage===void 0&&(this.handlerStorage=new One),this.isLeafNode=!0,this.handlerStorage.add(t)}},KW=class extends JW{staticChildren={};findStaticMatchingChild(t,r){let n=this.staticChildren[t.charAt(r)];if(!(n===void 0||!n.matchPrefix(t,r)))return n}getStaticChild(t,r=0){if(t.length===r)return this;let n=this.findStaticMatchingChild(t,r);if(n!==void 0)return n.getStaticChild(t,r+n.prefix.length)}createStaticChild(t){if(t.length===0)return this;let r=this.staticChildren[t.charAt(0)];if(r){let o=1;for(;o<r.prefix.length;o++)if(t.charCodeAt(o)!==r.prefix.charCodeAt(o)){r=r.split(this,o);break}return r.createStaticChild(t.slice(o))}let n=t.charAt(0);return this.staticChildren[n]=new CQ(t),this.staticChildren[n]}},CQ=class e extends KW{_tag="StaticNode";constructor(t){super(),this.setPrefix(t)}prefix;matchPrefix;parametricChildren=[];wildcardChild;setPrefix(t){if(this.prefix=t,t.length===1)this.matchPrefix=(r,n)=>!0;else{let r=t.length;this.matchPrefix=function(n,o){for(let i=1;i<r;i++)if(n.charCodeAt(o+i)!==this.prefix.charCodeAt(i))return!1;return!0}}}getParametricChild(t){if(t===void 0)return this.parametricChildren.find(n=>n.isRegex===!1);let r=t.source;return this.parametricChildren.find(n=>n.regex===void 0?!1:n.regex.source===r)}createParametricChild(t,r,n){let o=this.getParametricChild(t);return o!==void 0?(o.nodePaths.add(n),o):(o=new Nne(t,r,n),this.parametricChildren.push(o),this.parametricChildren.sort((i,s)=>i.isRegex?s.isRegex?i.staticSuffix===void 0?1:s.staticSuffix===void 0?-1:s.staticSuffix.endsWith(i.staticSuffix)?1:i.staticSuffix.endsWith(s.staticSuffix)?-1:0:-1:1),o)}createWildcardChild(){return this.wildcardChild===void 0&&(this.wildcardChild=new Pne),this.wildcardChild}split(t,r){let n=this.prefix.slice(0,r),o=this.prefix.slice(r);this.setPrefix(o);let i=new e(n);return i.staticChildren[o.charAt(0)]=this,t.staticChildren[n.charAt(0)]=i,i}getNextNode(t,r,n,o){let i=this.findStaticMatchingChild(t,r),s=0;if(i===void 0){if(this.parametricChildren.length===0)return this.wildcardChild;i=this.parametricChildren[0],s=1}this.wildcardChild!==void 0&&n.push({paramsCount:o,brotherPathIndex:r,brotherNode:this.wildcardChild});for(let a=this.parametricChildren.length-1;a>=s;a--)n.push({paramsCount:o,brotherPathIndex:r,brotherNode:this.parametricChildren[a]});return i}},Nne=class extends KW{regex;staticSuffix;_tag="ParametricNode";constructor(t,r,n){super(),this.regex=t,this.staticSuffix=r,this.isRegex=!!t,this.nodePaths=new Set([n])}isRegex;nodePaths;getNextNode(t,r){return this.findStaticMatchingChild(t,r)}},Pne=class extends JW{_tag="WildcardNode";getNextNode(t,r,n,o){}},S1t=(e,t)=>{if(!e)throw new Error(t)};R1t=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"]});var XHe,Mne=h(()=>{ZHe();XHe=JHe});var tWe=h(()=>{});var T1t,Ty,Fne,rWe,Td,D1t,nWe,wQ=h(()=>{X0();YD();uW();T1t=Symbol.for("@effect/platform/HttpApiSchema/AnnotationStatus"),Ty=e=>{let t=cW(e,"status");return e.status!==void 0&&(t[T1t]=e.status),t},Fne=e=>{function t(n){if(V0(n))for(let o of n.types)t(o);else r.push(n)}let r=[];return t(e),r},rWe=(e,t)=>os.make(Array.from(new Set([...Fne(e),...Fne(t)]))),Td=(e,t)=>fo(rWe(e.ast,t.ast)),D1t=e=>fW.annotations(Ty({status:e})),nWe=D1t(204)});var oWe=h(()=>{});var iWe,O1t,lS,sWe=h(()=>{sr();Me();E_();wQ();iWe=Symbol.for("@effect/platform/HttpApi"),O1t={[iWe]:iWe,pipe(){return Z(this,arguments)},add(e){return lS({identifier:this.identifier,groups:l6(this.groups,e.identifier,e),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},addHttpApi(e){let t={...this.groups};for(let r in e.groups){let n=e.groups[r].annotateContext(ro());n.annotations=wo(e.annotations,n.annotations),n.middlewares=new Set([...e.middlewares,...n.middlewares]),t[r]=n}return lS({identifier:this.identifier,groups:t,errorSchema:Td(this.errorSchema,e.errorSchema),annotations:this.annotations,middlewares:this.middlewares})},addError(e,t){return lS({identifier:this.identifier,groups:this.groups,errorSchema:Td(this.errorSchema,t?.status?e.annotations(Ty({status:t.status})):e),annotations:this.annotations,middlewares:this.middlewares})},prefix(e){return lS({identifier:this.identifier,groups:Sm(this.groups,t=>t.prefix(e)),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return lS({identifier:this.identifier,groups:this.groups,errorSchema:Td(this.errorSchema,e.failure),annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return lS({identifier:this.identifier,groups:this.groups,errorSchema:this.errorSchema,annotations:zt(this.annotations,e,t),middlewares:this.middlewares})},annotateContext(e){return lS({identifier:this.identifier,groups:this.groups,errorSchema:this.errorSchema,annotations:wo(this.annotations,e),middlewares:this.middlewares})}},lS=e=>{function t(){}return Object.setPrototypeOf(t,O1t),t.groups=e.groups,t.errorSchema=e.errorSchema,t.annotations=e.annotations,t.middlewares=e.middlewares,t}});var aWe=h(()=>{});var cWe,uWe,lWe=h(()=>{nr();g0();yn();cWe=Te(Symbol.for("@effect/platform/HttpMiddleware/loggerDisabled"),()=>h0(!1)),uWe=e=>Wt(uNe(cWe,!0),e)});var dWe=h(()=>{});var fWe,Lne=h(()=>{lWe();fWe=uWe});var mWe=h(()=>{});var hWe=h(()=>{});function AWe(e,t){let r=t.length;return e.modify({url:e.url.length<=r?"/":e.url.slice(r)})}var XW,ej,tj,Une,yWe,gWe,xWe,$ne,rj,$1t,EWe,bWe=h(()=>{vr();sr();nr();id();g0();oe();yn();ht();it();MB();Mne();FW();Tne();PW();XW=Symbol.for("@effect/platform/HttpRouter"),ej=Symbol.for("@effect/platform/HttpRouter/Route"),tj=Symbol.for("@effect/platform/HttpRouter/RouteContext"),Une=Jt("@effect/platform/HttpRouter/RouteContext"),yWe=Te("@effect/platform/HttpRouter/currentRouterConfig",()=>h0({})),gWe=class extends dI{routes;mounts;[XW];constructor(t,r){super(),this.routes=t,this.mounts=r,this[XW]=XW,this.httpApp=xWe(this).pipe(Ee(n=>this.httpApp=n))}httpApp;commit(){return this.httpApp}toJSON(){return{_id:"Router",routes:this.routes.toJSON(),mounts:this.mounts.toJSON()}}toString(){return Fe(this)}[Ce](){return this.toJSON()}},xWe=e=>De(cNe(yWe),t=>{let r=XHe(t),n=Uo(e.mounts).map(([i,s,a])=>[i,new rj(new $ne("*",a?.includePrefix?`${i}/*`:"/*",s,a?.includePrefix?W():H(i),!1),{}),a]),o=n.length;return C_(e.routes,i=>{i.method==="*"?r.all(i.path,i):r.on(i.method,i.path,i)}),$a(i=>{let s=iA(new Map(i.getFiberRef(Bb).unsafeMap)),a=_a(s,YW);if(o>0){let f=a.url.indexOf("?"),p=f===-1?a.url:a.url.slice(0,f);for(let m=0;m<o;m++){let[g,A,E]=n[m];if(p===g||p.startsWith(g+"/"))return s.unsafeMap.set(Une.key,A),E?.includePrefix!==!0&&s.unsafeMap.set(YW.key,AWe(a,g)),p0(Ee(A.route.handler,lne),Bb,s)}}let c=r.find(a.method,a.url);if(c===void 0&&a.method==="HEAD"&&(c=r.find("GET",a.url)),c===void 0)return $e(new MW({request:a}));let u=c.handler;u.prefix._tag==="Some"&&s.unsafeMap.set(YW.key,AWe(a,u.prefix.value)),s.unsafeMap.set($He.key,c.searchParams),s.unsafeMap.set(Une.key,new rj(u,c.params));let l=Ji(s,M1);l._tag==="Some"&&l.value._tag==="Span"&&l.value.attribute("http.route",u.path);let d=Ee(u.handler,lne);return p0(u.uninterruptible?d:Bo(d),Bb,s)})});$ne=class extends Wg{method;path;handler;prefix;uninterruptible;[ej];constructor(t,r,n,o=W(),i=!1){super(),this.method=t,this.path=r,this.handler=n,this.prefix=o,this.uninterruptible=i,this[ej]=ej}toJSON(){return{_id:"@effect/platform/HttpRouter/Route",method:this.method,path:this.path,prefix:this.prefix.toJSON()}}},rj=class{route;params;[tj];constructor(t,r){this.route=t,this.params=r,this[tj]=tj}},$1t=e=>e.endsWith("/")?e.slice(0,-1):e,EWe=x(2,(e,t)=>(t=$1t(t),e==="/"?t:t+e))});var SWe,Hne=h(()=>{bWe();SWe=EWe});var wWe=h(()=>{});var IWe=h(()=>{});var kWe=h(()=>{});var G1t,z1t,vWe,RWe=h(()=>{vr();oe();Me();G1t=Symbol.for("@effect/platform/HttpApiBuilder/Handlers"),z1t={[G1t]:{_Endpoints:be},pipe(){return Z(this,arguments)},handle(e,t,r){let n=this.group.endpoints[e];return vWe({group:this.group,handlers:$s(this.handlers,{endpoint:n,handler:t,withFullRequest:!1,uninterruptible:r?.uninterruptible??!1})})},handleRaw(e,t,r){let n=this.group.endpoints[e];return vWe({group:this.group,handlers:$s(this.handlers,{endpoint:n,handler:t,withFullRequest:!0,uninterruptible:r?.uninterruptible??!1})})}},vWe=e=>{let t=Object.create(z1t);return t.group=e.group,t.handlers=e.handlers,t}});var Y1t,J1t,K1t,_We,Z1t,Wne,jne,BWe,X1t,rrn,TWe=h(()=>{wr();sr();nr();zu();ah();Lne();Mne();Y1t=Jt("@effect/platform/HttpLayerRouter"),J1t=Symbol.for("@effect/platform/HttpLayerRouter/Middleware"),K1t=function(){return arguments.length===0?_We:_We(arguments[0],arguments[1])},_We=(e,t)=>t?.global?Rc(Go(function*(){let r=yield*Y1t,n=ws(e)?yield*e:e;yield*r.addGlobalMiddleware(n)})):new jne(ws(e)?e2(De(e,r=>iA(new Map([[Wne,r]])))):iD(iA(new Map([[Wne,e]])))),Z1t=0,Wne="@effect/platform/HttpLayerRouter/MiddlewareFn",jne=class e{layerFn;dependencies;[J1t]={};constructor(t,r){this.layerFn=t,this.dependencies=r;let n=`@effect/platform/HttpLayerRouter/Middleware-${++Z1t}`;this.layer=e2(Go(this,function*(){let o=yield*ty(),i=[o.unsafeMap.get(Wne)];if(this.dependencies){let s=yield*iX,a=Dr(o,FI),c=yield*cX(this.dependencies,s,a);i.push(...X1t(c))}return iA(new Map([[n,i]]))})).pipe(sy(this.layerFn))}layer;combine(t){return new e(this.layerFn,this.dependencies?sD(this.dependencies,t.layer):t.layer)}},BWe=new WeakMap,X1t=e=>{let t=BWe.get(e);if(t)return t;let r=Us(),n=0;for(let[o,i]of e.unsafeMap)o.startsWith("@effect/platform/HttpLayerRouter/Middleware-")&&(r.push(i),i.length>n&&(n=i.length));if(r.length===0)t=[];else{let o=new Set;for(let i=n-1;i>=0;i--)for(let s of r)i<s.length&&o.add(s[i]);t=_e(o).reverse()}return BWe.set(e,t),t},rrn=K1t(fWe).layer});var IQ,DWe,qne=h(()=>{sr();nr();IQ=class extends Hw("@effect/platform/Transferable/Collector")(){},DWe=()=>{let e=[],t=o=>{e.push(...o)},r=()=>e,n=()=>{let o=e;return e=[],o};return IQ.of({unsafeAddAll:t,addAll:o=>ot(()=>t(o)),unsafeRead:r,read:ot(r),unsafeClear:n,clear:ot(n)})}});var OWe=h(()=>{});var NWe,PWe=h(()=>{NWe=Symbol.for("@effect/platform/WorkerError")});var MWe,cp,nj=h(()=>{X0();PWe();MWe=NWe,cp=class extends sS()("WorkerError",{reason:is("spawn","decode","send","unknown","encode"),cause:ip}){[MWe]=MWe;static Cause=r2e({error:this,defect:ip});static encodeCause=Rre(this.Cause);static decodeCause=kre(this.Cause);get message(){switch(this.reason){case"send":return"An error occurred calling .postMessage";case"spawn":return"An error occurred while spawning a worker";case"decode":return"An error occurred during decoding";case"encode":return"An error occurred during encoding";case"unknown":return"An unexpected error occurred"}}}});var Gne,oj,zne,Vne,FWe,LWe,UWe,$We,HWe=h(()=>{aS();sr();$u();nr();Ro();g0();_ne();zu();EQ();it();Y2();lX();ah();wd();MB();qne();nj();Gne=Symbol.for("@effect/platform/Worker/PlatformWorker"),oj=Jt("@effect/platform/Worker/PlatformWorker"),zne=Symbol.for("@effect/platform/Worker/WorkerManager"),Vne=Jt("@effect/platform/Worker/WorkerManager"),FWe=Jt("@effect/platform/Worker/Spawner"),LWe=Go(function*(){let e=yield*oj,t=0;return Vne.of({[zne]:zne,spawn({encode:r,initialMessage:n}){return Go(function*(){let o=t++,i=0,s=new Map,a=DWe(),c=r?A=>Wt(a.clear,d0(r(A),IQ,a)):nt,u=yield*rn(),l=yield*e.spawn(o);yield*l.run(A=>A[0]===0?jT(u,ve):d(A[1])).pipe(JT(A=>pi(s.values(),E=>fh in E?pd(E,A):E.failCause(A))),_b(rX),J5(uX(1e3)),V$({package:"@effect/platform",module:"Worker"}),Bo,l0),yield*YT(()=>Wt(pi(s.values(),A=>fh in A?r0(A):A.end,{discard:!0}),ot(()=>s.clear())));let d=A=>Pt(()=>{let E=s.get(A[0]);if(!E)return ve;switch(A[1]){case 0:return fh in E?di(E,A[2][0]):E.offerAll(A[2]);case 1:return A.length===2?fh in E?r0(E):E.end:fh in E?di(E,A[2][0]):Wt(E.offerAll(A[2]),E.end);case 2:case 3:{if(A[1]===2)return fh in E?D$(E,A[2]):E.fail(A[2]);let y=cp.decodeCause(A[2]);return fh in E?pd(E,y):E.failCause(y)}}}),f=(A,E)=>$a(y=>{let b=y.getFiberRef(Bb),w=Ji(b,M1).pipe(hF(v=>v._tag==="Span")),I=i++;return E.pipe(Ri(v=>(s.set(I,v),c(A).pipe(Ri(k=>l.send([I,0,k,w._tag==="Some"?[w.value.traceId,w.value.spanId,w.value.sampled]:void 0],a.unsafeRead())),Hu(k=>rHe(v)?v.failCause(k):pd(v,k))))),De(v=>({id:I,mailbox:v})))}),p=({id:A},E)=>{let y=ot(()=>s.delete(A));return sd(E)?Wt(Yf(l.send([A,1])),y):y},m=A=>dy(_W(f(A,ok()),({mailbox:E})=>nHe(E),p)),g=A=>c0(f(A,rn()),({mailbox:E})=>Ht(E),p);return yield*Ht(u),n&&(yield*ot(n).pipe(Ee(g),Ha(A=>new cp({reason:"spawn",cause:A})))),{id:o,execute:m,executeEffect:g}})}})}),UWe=iy(Vne,LWe),$We=()=>e=>oj.of({[Gne]:Gne,spawn(t){return Go(function*(){let r=yield*FWe,n,o=[];return{run:a=>vb(c=>Go(function*(){let u=yield*u0,l=yield*e.setup({worker:r(t),scope:u});n=l,yield*sh(u,ot(()=>{n=void 0}));let d=(yield*hh()).pipe(NPe(Z6(FI))),f=yield*_He(),p=f7(d);if(yield*e.listen({port:l,scope:u,emit(m){DHe(f,p(a(m)))},deferred:f.deferred}),o.length>0){for(let[m,g]of o)l.postMessage([0,m],g);o.length=0}return yield*c(QHe(f))}).pipe(Ad)),send:(a,c)=>Wu({try:()=>{n===void 0?o.push([a,c]):n.postMessage([0,a],c)},catch:u=>new cp({reason:"send",cause:u})})}})}})});var WWe,jWe,qWe,Yne=h(()=>{HWe();WWe=$We,jWe=oj,qWe=UWe});var zWe=h(()=>{});function ij(e){try{if(!hn.trusted&&!Dy){let r=gr.sharedLength||0;r<gr.length&&(gr.length=r)}let t;if(hn.randomAccessStructure&&Se[U]<64&&Se[U]>=32&&Zne?(t=Zne(Se,U,Nc,hn),Se=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),U=Nc):t=Do(),mi&&(U=mi.postBundlePosition,mi=null),Dy&&(gr.restoreStructures=null),U==Nc)gr&&gr.restoreStructures&&JWe(),gr=null,Se=null,Ph&&(Ph=null);else{if(U>Nc)throw new Error("Unexpected end of MessagePack data");if(!Dy){let r;try{r=JSON.stringify(t,(n,o)=>typeof o=="bigint"?`${o}n`:o).slice(0,100)}catch(n){r="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+r)}}return t}catch(t){throw gr&&gr.restoreStructures&&JWe(),aj(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||U>Nc)&&(t.incomplete=!0),t}}function JWe(){for(let e in gr.restoreStructures)gr[e]=gr.restoreStructures[e];gr.restoreStructures=null}function Do(){let e=Se[U++];if(e<160)if(e<128){if(e<64)return e;{let t=gr[e&63]||hn.getStructures&&oje()[e&63];return t?(t.read||(t.read=noe(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,hn.mapsAsObjects){let t={};for(let r=0;r<e;r++){let n=fje();n==="__proto__"&&(n="__proto_"),t[n]=Do()}return t}else{let t=new Map;for(let r=0;r<e;r++)t.set(Do(),Do());return t}else{e-=144;let t=new Array(e);for(let r=0;r<e;r++)t[r]=Do();return hn.freezeData?Object.freeze(t):t}else if(e<192){let t=e-160;if(al>=U)return Nh.slice(U-Oc,(U+=t)-Oc);if(al==0&&Nc<140){let r=t<16?ooe(t):dje(t);if(r!=null)return r}return sj(t)}else{let t;switch(e){case 192:return null;case 193:return mi?(t=Do(),t>0?mi[1].slice(mi.position1,mi.position1+=t):mi[0].slice(mi.position0,mi.position0-=t)):roe;case 194:return!1;case 195:return!0;case 196:if(t=Se[U++],t===void 0)throw new Error("Unexpected end of buffer");return Jne(t);case 197:return t=ur.getUint16(U),U+=2,Jne(t);case 198:return t=ur.getUint32(U),U+=4,Jne(t);case 199:return dS(Se[U++]);case 200:return t=ur.getUint16(U),U+=2,dS(t);case 201:return t=ur.getUint32(U),U+=4,dS(t);case 202:if(t=ur.getFloat32(U),hn.useFloat32>2){let r=mS[(Se[U]&127)<<1|Se[U+1]>>7];return U+=4,(r*t+(t>0?.5:-.5)>>0)/r}return U+=4,t;case 203:return t=ur.getFloat64(U),U+=8,t;case 204:return Se[U++];case 205:return t=ur.getUint16(U),U+=2,t;case 206:return t=ur.getUint32(U),U+=4,t;case 207:return hn.int64AsType==="number"?(t=ur.getUint32(U)*4294967296,t+=ur.getUint32(U+4)):hn.int64AsType==="string"?t=ur.getBigUint64(U).toString():hn.int64AsType==="auto"?(t=ur.getBigUint64(U),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ur.getBigUint64(U),U+=8,t;case 208:return ur.getInt8(U++);case 209:return t=ur.getInt16(U),U+=2,t;case 210:return t=ur.getInt32(U),U+=4,t;case 211:return hn.int64AsType==="number"?(t=ur.getInt32(U)*4294967296,t+=ur.getUint32(U+4)):hn.int64AsType==="string"?t=ur.getBigInt64(U).toString():hn.int64AsType==="auto"?(t=ur.getBigInt64(U),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ur.getBigInt64(U),U+=8,t;case 212:if(t=Se[U++],t==114)return rje(Se[U++]&63);{let r=qa[t];if(r)return r.read?(U++,r.read(Do())):r.noBuffer?(U++,r()):r(Se.subarray(U,++U));throw new Error("Unknown extension "+t)}case 213:return t=Se[U],t==114?(U++,rje(Se[U++]&63,Se[U++])):dS(2);case 214:return dS(4);case 215:return dS(8);case 216:return dS(16);case 217:return t=Se[U++],al>=U?Nh.slice(U-Oc,(U+=t)-Oc):ije(t);case 218:return t=ur.getUint16(U),U+=2,al>=U?Nh.slice(U-Oc,(U+=t)-Oc):sje(t);case 219:return t=ur.getUint32(U),U+=4,al>=U?Nh.slice(U-Oc,(U+=t)-Oc):aje(t);case 220:return t=ur.getUint16(U),U+=2,ZWe(t);case 221:return t=ur.getUint32(U),U+=4,ZWe(t);case 222:return t=ur.getUint16(U),U+=2,XWe(t);case 223:return t=ur.getUint32(U),U+=4,XWe(t);default:if(e>=224)return e-256;if(e===void 0){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}throw new Error("Unknown MessagePack token "+e)}}}function noe(e,t){function r(){if(r.count++>YWe){let o;try{o=e.read=new Function("r","return function(){return "+(hn.freezeData?"Object.freeze":"")+"({"+e.map(i=>i==="__proto__"?"__proto_:r()":sUt.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"})}")(Do)}catch{return YWe=1/0,r()}return e.read0=o,e.highByte===0&&(e.read=KWe(t,e.read)),o()}let n={};for(let o=0,i=e.length;o<i;o++){let s=e[o];s==="__proto__"&&(s="__proto_"),n[s]=Do()}return hn.freezeData?Object.freeze(n):n}return r.count=0,e.read0=r,e.highByte===0?KWe(t,r):r}function oje(){let e=mje(()=>(Se=null,hn.getStructures()));return gr=hn._mergeStructures(e,gr)}function uje(e){cje=!0,sj=t(1),ije=t(2),sje=t(3),aje=t(5);function t(r){return function(o){let i=fS[kQ++];if(i==null){if(mi)return pS(o);let a=Se.byteOffset,c=e(U-r+a,Nc+a,Se.buffer);if(typeof c=="string")i=c,fS=toe;else if(fS=c,kQ=1,al=1,i=fS[0],i===void 0)throw new Error("Unexpected end of buffer")}let s=i.length;return s<=o?(U+=o,i):(Nh=i,Oc=U,al=U+s,U+=o,i.slice(0,o))}}}function pS(e){let t;if(e<16&&(t=ooe(e)))return t;if(e>64&&Kne)return Kne.decode(Se.subarray(U,U+=e));let r=U+e,n=[];for(t="";U<r;){let o=Se[U++];if(!(o&128))n.push(o);else if((o&224)===192){let i=Se[U++]&63,s=(o&31)<<6|i;s<128?n.push(65533):n.push(s)}else if((o&240)===224){let i=Se[U++]&63,s=Se[U++]&63,a=(o&31)<<12|i<<6|s;a<2048||a>=55296&&a<=57343?n.push(65533):n.push(a)}else if((o&248)===240){let i=Se[U++]&63,s=Se[U++]&63,a=Se[U++]&63,c=(o&7)<<18|i<<12|s<<6|a;c<65536||c>1114111?n.push(65533):(c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c))}else n.push(65533);n.length>=4096&&(t+=Qi.apply(String,n),n.length=0)}return n.length>0&&(t+=Qi.apply(String,n)),t}function lje(e,t,r){let n=Se;Se=e,U=t;try{return pS(r)}finally{Se=n}}function ZWe(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=Do();return hn.freezeData?Object.freeze(t):t}function XWe(e){if(hn.mapsAsObjects){let t={};for(let r=0;r<e;r++){let n=fje();n==="__proto__"&&(n="__proto_"),t[n]=Do()}return t}else{let t=new Map;for(let r=0;r<e;r++)t.set(Do(),Do());return t}}function dje(e){let t=U,r=new Array(e);for(let n=0;n<e;n++){let o=Se[U++];if((o&128)>0){U=t;return}r[n]=o}return Qi.apply(String,r)}function ooe(e){if(e<4)if(e<2){if(e===0)return"";{let t=Se[U++];if((t&128)>1){U-=1;return}return Qi(t)}}else{let t=Se[U++],r=Se[U++];if((t&128)>0||(r&128)>0){U-=2;return}if(e<3)return Qi(t,r);let n=Se[U++];if((n&128)>0){U-=3;return}return Qi(t,r,n)}else{let t=Se[U++],r=Se[U++],n=Se[U++],o=Se[U++];if((t&128)>0||(r&128)>0||(n&128)>0||(o&128)>0){U-=4;return}if(e<6){if(e===4)return Qi(t,r,n,o);{let i=Se[U++];if((i&128)>0){U-=5;return}return Qi(t,r,n,o,i)}}else if(e<8){let i=Se[U++],s=Se[U++];if((i&128)>0||(s&128)>0){U-=6;return}if(e<7)return Qi(t,r,n,o,i,s);let a=Se[U++];if((a&128)>0){U-=7;return}return Qi(t,r,n,o,i,s,a)}else{let i=Se[U++],s=Se[U++],a=Se[U++],c=Se[U++];if((i&128)>0||(s&128)>0||(a&128)>0||(c&128)>0){U-=8;return}if(e<10){if(e===8)return Qi(t,r,n,o,i,s,a,c);{let u=Se[U++];if((u&128)>0){U-=9;return}return Qi(t,r,n,o,i,s,a,c,u)}}else if(e<12){let u=Se[U++],l=Se[U++];if((u&128)>0||(l&128)>0){U-=10;return}if(e<11)return Qi(t,r,n,o,i,s,a,c,u,l);let d=Se[U++];if((d&128)>0){U-=11;return}return Qi(t,r,n,o,i,s,a,c,u,l,d)}else{let u=Se[U++],l=Se[U++],d=Se[U++],f=Se[U++];if((u&128)>0||(l&128)>0||(d&128)>0||(f&128)>0){U-=12;return}if(e<14){if(e===12)return Qi(t,r,n,o,i,s,a,c,u,l,d,f);{let p=Se[U++];if((p&128)>0){U-=13;return}return Qi(t,r,n,o,i,s,a,c,u,l,d,f,p)}}else{let p=Se[U++],m=Se[U++];if((p&128)>0||(m&128)>0){U-=14;return}if(e<15)return Qi(t,r,n,o,i,s,a,c,u,l,d,f,p,m);let g=Se[U++];if((g&128)>0){U-=15;return}return Qi(t,r,n,o,i,s,a,c,u,l,d,f,p,m,g)}}}}}function eje(){let e=Se[U++],t;if(e<192)t=e-160;else switch(e){case 217:t=Se[U++];break;case 218:t=ur.getUint16(U),U+=2;break;case 219:t=ur.getUint32(U),U+=4;break;default:throw new Error("Expected string")}return pS(t)}function Jne(e){return hn.copyBuffers?Uint8Array.prototype.slice.call(Se,U,U+=e):Se.subarray(U,U+=e)}function dS(e){let t=Se[U++];if(qa[t]){let r;return qa[t](Se.subarray(U,r=U+=e),n=>{U=n;try{return Do()}finally{U=r}})}else throw new Error("Unknown extension type "+t)}function fje(){let e=Se[U++];if(e>=160&&e<192){if(e=e-160,al>=U)return Nh.slice(U-Oc,(U+=e)-Oc);if(!(al==0&&Nc<180))return sj(e)}else return U--,pje(Do());let t=(e<<5^(e>1?ur.getUint16(U):e>0?Se[U]:0))&4095,r=tje[t],n=U,o=U+e-3,i,s=0;if(r&&r.bytes==e){for(;n<o;){if(i=ur.getUint32(n),i!=r[s++]){n=1879048192;break}n+=4}for(o+=3;n<o;)if(i=Se[n++],i!=r[s++]){n=1879048192;break}if(n===o)return U=n,r.string;o-=3,n=U}for(r=[],tje[t]=r,r.bytes=e;n<o;)i=ur.getUint32(n),r.push(i),n+=4;for(o+=3;n<o;)i=Se[n++],r.push(i);let a=e<16?ooe(e):dje(e);return a!=null?r.string=a:r.string=sj(e)}function pje(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(e==null)return e+"";if(hn.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return e.flat().toString();throw new Error(`Invalid property type for record: ${typeof e}`)}function mje(e){eoe&&eoe();let t=Nc,r=U,n=kQ,o=Oc,i=al,s=Nh,a=fS,c=Ph,u=mi,l=new Uint8Array(Se.slice(0,Nc)),d=gr,f=gr.slice(0,gr.length),p=hn,m=Dy,g=e();return Nc=t,U=r,kQ=n,Oc=o,al=i,Nh=s,fS=a,Ph=c,mi=u,Se=l,Dy=m,gr=d,gr.splice(0,gr.length,...f),hn=p,ur=new DataView(Se.buffer,Se.byteOffset,Se.byteLength),g}function aj(){Se=null,Ph=null,gr=null}function gje(e,t,r){Zne=e,Xne=t,eoe=r}var Kne,Se,Nc,U,toe,fS,kQ,hn,gr,Nh,Oc,al,mi,Ph,qa,ur,VWe,vQ,roe,Dy,YWe,Zne,Xne,eoe,Mh,sUt,KWe,sj,ije,sje,aje,cje,Qi,tje,rje,nje,ioe,aUt,cUt,mS,cj,uUt,lUt,hje,uj,dUt,frn,Fh=h(()=>{try{Kne=new TextDecoder}catch{}U=0,toe=[],fS=toe,kQ=0,hn={},Oc=0,al=0,qa=[],VWe={useRecords:!1,mapsAsObjects:!0},vQ=class{},roe=new vQ;roe.name="MessagePack 0xC1";Dy=!1,YWe=2,Mh=class e{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=!1&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,r){if(Se)return mje(()=>(aj(),this?this.unpack(t,r):e.prototype.unpack.call(VWe,t,r)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof r=="object"?(Nc=r.end||t.length,U=r.start||0):(U=0,Nc=r>-1?r:t.length),kQ=0,al=0,Nh=null,fS=toe,mi=null,Se=t;try{ur=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Se=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof e){if(hn=this,this.structures)return gr=this.structures,ij(r);(!gr||gr.length>0)&&(gr=[])}else hn=VWe,(!gr||gr.length>0)&&(gr=[]);return ij(r)}unpackMultiple(t,r){let n,o=0;try{Dy=!0;let i=t.length,s=this?this.unpack(t,i):cj.unpack(t,i);if(r){if(r(s,o,U)===!1)return;for(;U<i;)if(o=U,r(ij(),o,U)===!1)return}else{for(n=[s];U<i;)o=U,n.push(ij());return n}}catch(i){throw i.lastPosition=o,i.values=n,i}finally{Dy=!1,aj()}}_mergeStructures(t,r){Xne&&(t=Xne.call(this,t)),t=t||[],Object.isFrozen(t)&&(t=t.map(n=>n.slice(0)));for(let n=0,o=t.length;n<o;n++){let i=t[n];i&&(i.isShared=!0,n>=32&&(i.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in r||[])if(n>=0){let o=t[n],i=r[n];i&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[n]=o),t[n]=i)}return this.structures=t}decode(t,r){return this.unpack(t,r)}};sUt=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;KWe=(e,t)=>function(){let r=Se[U++];if(r===0)return t();let n=e<32?-(e+(r<<5)):e+(r<<5),o=gr[n]||oje()[n];if(!o)throw new Error("Record id is not defined for "+n);return o.read||(o.read=noe(o,e)),o.read()};sj=pS,ije=pS,sje=pS,aje=pS,cje=!1;Qi=String.fromCharCode;tje=new Array(4096);rje=(e,t)=>{let r=Do().map(pje),n=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,r.highByte=t);let o=gr[e];return o&&(o.isShared||Dy)&&((gr.restoreStructures||(gr.restoreStructures=[]))[e]=o),gr[e]=r,r.read=noe(r,n),(r.read0||r.read)()};qa[0]=()=>{};qa[0].noBuffer=!0;qa[66]=e=>{let t=e.byteLength%8||8,r=BigInt(e[0]&128?e[0]-256:e[0]);for(let n=1;n<t;n++)r<<=BigInt(8),r+=BigInt(e[n]);if(e.byteLength!==t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=(i,s)=>{let a=s-i;if(a<=40){let d=n.getBigUint64(i);for(let f=i+8;f<s;f+=8)d<<=BigInt(64),d|=n.getBigUint64(f);return d}let c=i+(a>>4<<3),u=o(i,c),l=o(c,s);return u<<BigInt((s-c)*8)|l};r=r<<BigInt((n.byteLength-t)*8)|o(t,n.byteLength)}return r};nje={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};qa[101]=()=>{let e=Do();if(!nje[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return nje[e[0]](e[1],{cause:e[2]})};qa[105]=e=>{if(hn.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=ur.getUint32(U-4);Ph||(Ph=new Map);let r=Se[U],n;r>=144&&r<160||r==220||r==221?n=[]:r>=128&&r<144||r==222||r==223?n=new Map:(r>=199&&r<=201||r>=212&&r<=216)&&Se[U+1]===115?n=new Set:n={};let o={target:n};Ph.set(t,o);let i=Do();if(o.used)Object.assign(n,i);else return o.target=i;if(n instanceof Map)for(let[s,a]of i.entries())n.set(s,a);if(n instanceof Set)for(let s of Array.from(i))n.add(s);return n};qa[112]=e=>{if(hn.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=ur.getUint32(U-4),r=Ph.get(t);return r.used=!0,r.target};qa[115]=()=>new Set(Do());ioe=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array"),aUt=typeof globalThis=="object"?globalThis:window;qa[116]=e=>{let t=e[0],r=Uint8Array.prototype.slice.call(e,1).buffer,n=ioe[t];if(!n){if(t===16)return r;if(t===17)return new DataView(r);throw new Error("Could not find typed array for code "+t)}return new aUt[n](r)};qa[120]=()=>{let e=Do();return new RegExp(e[0],e[1])};cUt=[];qa[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],r=U;return U+=t-e.length,mi=cUt,mi=[eje(),eje()],mi.position0=0,mi.position1=0,mi.postBundlePosition=U,U=r,Do()};qa[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");mS=new Array(147);for(let e=0;e<256;e++)mS[e]=+("1e"+Math.floor(45.15-e*.30103));cj=new Mh({useRecords:!1}),uUt=cj.unpack,lUt=cj.unpackMultiple,hje=cj.unpack,uj={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},dUt=new Float32Array(1),frn=new Uint8Array(dUt.buffer,0,4)});function soe(e,t,r,n){let o=e.byteLength;if(o+1<256){var{target:i,position:s}=r(4+o);i[s++]=199,i[s++]=o+1}else if(o+1<65536){var{target:i,position:s}=r(5+o);i[s++]=200,i[s++]=o+1>>8,i[s++]=o+1&255}else{var{target:i,position:s,targetView:a}=r(7+o);i[s++]=201,a.setUint32(s,o+1),s+=4}i[s++]=116,i[s++]=t,e.buffer||(e=new Uint8Array(e)),i.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s)}function aoe(e,t){let r=e.byteLength;var n,o;if(r<256){var{target:n,position:o}=t(r+2);n[o++]=196,n[o++]=r}else if(r<65536){var{target:n,position:o}=t(r+3);n[o++]=197,n[o++]=r>>8,n[o++]=r&255}else{var{target:n,position:o,targetView:i}=t(r+5);n[o++]=198,i.setUint32(o,r),o+=4}n.set(e,o)}function yje(e,t,r,n){let o=e.length;switch(o){case 1:t[r++]=212;break;case 2:t[r++]=213;break;case 4:t[r++]=214;break;case 8:t[r++]=215;break;case 16:t[r++]=216;break;default:o<256?(t[r++]=199,t[r++]=o):o<65536?(t[r++]=200,t[r++]=o>>8,t[r++]=o&255):(t[r++]=201,t[r++]=o>>24,t[r++]=o>>16&255,t[r++]=o>>8&255,t[r++]=o&255)}return t[r++]=n,t.set(e,r),r+=o,r}function mUt(e,t){let r,n=t.length*6,o=e.length-n;for(;r=t.pop();){let i=r.offset,s=r.id;e.copyWithin(i+n,i,o),n-=6;let a=i+n;e[a++]=214,e[a++]=105,e[a++]=s>>24,e[a++]=s>>16&255,e[a++]=s>>8&255,e[a++]=s&255,o=i}return e}function xje(e,t,r){if(Jn.length>0){gn.setUint32(Jn.position+e,G+r-Jn.position-e),Jn.stringsPosition=G-e;let n=Jn;Jn=null,t(n[0]),t(n[1])}}function Sje(e,t){return e.isCompatible=r=>{let n=!r||(t.lastNamedStructuresLength||0)===r.length;return n||t._mergeStructures(r),n},e}function Cje(e,t){bje=e,Sje=t}var dj,coe,uoe,ik,lj,Eje,Aje,K,RQ,gn,G,Bs,Jn,bje,fUt,pUt,Dd,hS,wje,hUt,Ije,gUt,AUt,yUt,xUt,kje,vje,Rje,_Q=h(()=>{Fh();Fh();Fh();try{dj=new TextEncoder}catch{}ik=typeof Buffer<"u",lj=ik?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,Eje=ik?Buffer:Uint8Array,Aje=ik?4294967296:2144337920,G=0,Jn=null,fUt=21760,pUt=/[\u0080-\uFFFF]/,Dd=Symbol("record-id"),hS=class extends Mh{constructor(t){super(t),this.offset=0;let r,n,o,i,s,a=Eje.prototype.utf8Write?function(_,P){return K.utf8Write(_,P,K.byteLength-P)}:dj&&dj.encodeInto?function(_,P){return dj.encodeInto(_,K.subarray(P)).written}:!1,c=this;t||(t={});let u=t&&t.sequential,l=t.structures||t.saveStructures,d=t.maxSharedStructures;if(d==null&&(d=l?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");t.structuredClone&&t.moreTypes==null&&(this.moreTypes=!0);let f=t.maxOwnStructures;f==null&&(f=l?32:64),!this.structures&&t.useRecords!=!1&&(this.structures=[]);let p=d>32||f+d>64,m=d+64,g=d+f+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let A=[],E=0,y=0;this.pack=this.encode=function(_,P){if(K||(K=new lj(8192),gn=K.dataView||(K.dataView=new DataView(K.buffer,0,8192)),G=0),Bs=K.length-10,Bs-G<2048?(K=new lj(K.length),gn=K.dataView||(K.dataView=new DataView(K.buffer,0,K.length)),Bs=K.length-10,G=0):G=G+7&2147483640,n=G,P&Rje&&(G+=P&255),s=c.structuredClone?new Map:null,c.bundleStrings&&typeof _!="string"?(Jn=[],Jn.size=1/0):Jn=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let N=i.sharedLength||0;if(N>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let q=0;q<N;q++){let re=i[q];if(!re)continue;let ie,ue=i.transitions;for(let Oe=0,Ye=re.length;Oe<Ye;Oe++){let T=re[Oe];ie=ue[T],ie||(ie=ue[T]=Object.create(null)),ue=ie}ue[Dd]=q+64}this.lastNamedStructuresLength=N}u||(i.nextId=N+64)}o&&(o=!1);let $;try{c.randomAccessStructure&&!c.readOnlyStructures&&_&&typeof _=="object"?_.constructor===Object?F(_):_.constructor!==Map&&!Array.isArray(_)&&!uoe.some(q=>_ instanceof q)?F(_.toJSON?_.toJSON():_):I(_):I(_);let N=Jn;if(Jn&&xje(n,I,0),s&&s.idsToInsert){let q=s.idsToInsert.sort((Oe,Ye)=>Oe.offset>Ye.offset?1:-1),re=q.length,ie=-1;for(;N&&re>0;){let Oe=q[--re].offset+n;Oe<N.stringsPosition+n&&ie===-1&&(ie=0),Oe>N.position+n?ie>=0&&(ie+=6):(ie>=0&&(gn.setUint32(N.position+n,gn.getUint32(N.position+n)+ie),ie=-1),N=N.previous,re++)}ie>=0&&N&&gn.setUint32(N.position+n,gn.getUint32(N.position+n)+ie),G+=q.length*6,G>Bs&&L(G),c.offset=G;let ue=mUt(K.subarray(n,G),q);return s=null,ue}return c.offset=G,P&kje?(K.start=n,K.end=G,K):K.subarray(n,G)}catch(N){throw $=N,N}finally{if(i&&(b(),o&&c.saveStructures)){let N=i.sharedLength||0,q=K.subarray(n,G),re=Sje(i,c);if(!$)return c.saveStructures(re,re.isCompatible)===!1?(i.uninitialized=!0,c.pack(_,P)):(c.lastNamedStructuresLength=N,K.length>1073741824&&(K=null),q)}K.length>1073741824&&(K=null),P&vje&&(G=n)}};let b=()=>{y<10&&y++;let _=i.sharedLength||0;if(i.length>_&&!u&&(i.length=_),E>1e4)i.transitions=null,y=0,E=0,A.length>0&&(A=[]);else if(A.length>0&&!u){for(let P=0,$=A.length;P<$;P++)A[P][Dd]=0;A=[]}},w=_=>{var P=_.length;P<16?K[G++]=144|P:P<65536?(K[G++]=220,K[G++]=P>>8,K[G++]=P&255):(K[G++]=221,gn.setUint32(G,P),G+=4);for(let $=0;$<P;$++)I(_[$])},I=_=>{G>Bs&&(K=L(G));var P=typeof _,$;if(P==="string"){let N=_.length;if(Jn&&N>=4&&N<4096){if((Jn.size+=N)>fUt){let ue,Oe=(Jn[0]?Jn[0].length*3+Jn[1].length:0)+10;G+Oe>Bs&&(K=L(G+Oe));let Ye;Jn.position?(Ye=Jn,K[G]=200,G+=3,K[G++]=98,ue=G-n,G+=4,xje(n,I,0),gn.setUint16(ue+n-3,G-n-ue)):(K[G++]=214,K[G++]=98,ue=G-n,G+=4),Jn=["",""],Jn.previous=Ye,Jn.size=0,Jn.position=ue}let ie=pUt.test(_);Jn[ie?0:1]+=_,K[G++]=193,I(ie?-N:N);return}let q;N<32?q=1:N<256?q=2:N<65536?q=3:q=5;let re=N*3;if(G+re>Bs&&(K=L(G+re)),N<64||!a){let ie,ue,Oe,Ye=G+q;for(ie=0;ie<N;ie++)ue=_.charCodeAt(ie),ue<128?K[Ye++]=ue:ue<2048?(K[Ye++]=ue>>6|192,K[Ye++]=ue&63|128):(ue&64512)===55296&&((Oe=_.charCodeAt(ie+1))&64512)===56320?(ue=65536+((ue&1023)<<10)+(Oe&1023),ie++,K[Ye++]=ue>>18|240,K[Ye++]=ue>>12&63|128,K[Ye++]=ue>>6&63|128,K[Ye++]=ue&63|128):(K[Ye++]=ue>>12|224,K[Ye++]=ue>>6&63|128,K[Ye++]=ue&63|128);$=Ye-G-q}else $=a(_,G+q);$<32?K[G++]=160|$:$<256?(q<2&&K.copyWithin(G+2,G+1,G+1+$),K[G++]=217,K[G++]=$):$<65536?(q<3&&K.copyWithin(G+3,G+2,G+2+$),K[G++]=218,K[G++]=$>>8,K[G++]=$&255):(q<5&&K.copyWithin(G+5,G+3,G+3+$),K[G++]=219,gn.setUint32(G,$),G+=4),G+=$}else if(P==="number")if(_>>>0===_)_<32||_<128&&this.useRecords===!1||_<64&&!this.randomAccessStructure?K[G++]=_:_<256?(K[G++]=204,K[G++]=_):_<65536?(K[G++]=205,K[G++]=_>>8,K[G++]=_&255):(K[G++]=206,gn.setUint32(G,_),G+=4);else if(_>>0===_)_>=-32?K[G++]=256+_:_>=-128?(K[G++]=208,K[G++]=_+256):_>=-32768?(K[G++]=209,gn.setInt16(G,_),G+=2):(K[G++]=210,gn.setInt32(G,_),G+=4);else{let N;if((N=this.useFloat32)>0&&_<4294967296&&_>=-2147483648){K[G++]=202,gn.setFloat32(G,_);let q;if(N<4||(q=_*mS[(K[G]&127)<<1|K[G+1]>>7])>>0===q){G+=4;return}else G--}K[G++]=203,gn.setFloat64(G,_),G+=8}else if(P==="object"||P==="function")if(!_)K[G++]=192;else{if(s){let q=s.get(_);if(q){if(!q.id){let re=s.idsToInsert||(s.idsToInsert=[]);q.id=re.push(q)}K[G++]=214,K[G++]=112,gn.setUint32(G,q.id),G+=4;return}else s.set(_,{offset:G-n})}let N=_.constructor;if(N===Object)B(_);else if(N===Array)w(_);else if(N===Map)if(this.mapAsEmptyObject)K[G++]=128;else{$=_.size,$<16?K[G++]=128|$:$<65536?(K[G++]=222,K[G++]=$>>8,K[G++]=$&255):(K[G++]=223,gn.setUint32(G,$),G+=4);for(let[q,re]of _)I(q),I(re)}else{for(let q=0,re=coe.length;q<re;q++){let ie=uoe[q];if(_ instanceof ie){let ue=coe[q];if(ue.write){ue.type&&(K[G++]=212,K[G++]=ue.type,K[G++]=0);let Ne=ue.write.call(this,_);Ne===_?Array.isArray(_)?w(_):B(_):I(Ne);return}let Oe=K,Ye=gn,T=G;K=null;let J;try{J=ue.pack.call(this,_,Ne=>(K=Oe,Oe=null,G+=Ne,G>Bs&&L(G),{target:K,targetView:gn,position:G-Ne}),I)}finally{Oe&&(K=Oe,gn=Ye,G=T,Bs=K.length-10)}J&&(J.length+G>Bs&&L(J.length+G),G=yje(J,K,G,ue.type));return}}if(Array.isArray(_))w(_);else{if(_.toJSON){let q=_.toJSON();if(q!==_)return I(q)}if(P==="function")return I(this.writeFunction&&this.writeFunction(_));B(_)}}}else if(P==="boolean")K[G++]=_?195:194;else if(P==="bigint"){if(_<9223372036854776e3&&_>=-9223372036854776e3)K[G++]=211,gn.setBigInt64(G,_);else if(_<18446744073709552e3&&_>0)K[G++]=207,gn.setBigUint64(G,_);else if(this.largeBigIntToFloat)K[G++]=203,gn.setFloat64(G,Number(_));else{if(this.largeBigIntToString)return I(_.toString());if(this.useBigIntExtension||this.moreTypes){let N=_<0?BigInt(-1):BigInt(0),q;if(_>>BigInt(65536)===N){let re=BigInt(18446744073709552e3)-BigInt(1),ie=[];for(;ie.push(_&re),_>>BigInt(63)!==N;)_>>=BigInt(64);q=new Uint8Array(new BigUint64Array(ie).buffer),q.reverse()}else{let re=_<0,ie=(re?~_:_).toString(16);if(ie.length%2?ie="0"+ie:parseInt(ie.charAt(0),16)>=8&&(ie="00"+ie),ik)q=Buffer.from(ie,"hex");else{q=new Uint8Array(ie.length/2);for(let ue=0;ue<q.length;ue++)q[ue]=parseInt(ie.slice(ue*2,ue*2+2),16)}if(re)for(let ue=0;ue<q.length;ue++)q[ue]=~q[ue]}q.length+G>Bs&&L(q.length+G),G=yje(q,K,G,66);return}else throw new RangeError(_+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}G+=8}else if(P==="undefined")this.encodeUndefinedAsNil?K[G++]=192:(K[G++]=212,K[G++]=0,K[G++]=0);else throw new Error("Unknown type: "+P)},v=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?_=>{let P;if(this.skipValues){P=[];for(let q in _)(typeof _.hasOwnProperty!="function"||_.hasOwnProperty(q))&&!this.skipValues.includes(_[q])&&P.push(q)}else P=Object.keys(_);let $=P.length;$<16?K[G++]=128|$:$<65536?(K[G++]=222,K[G++]=$>>8,K[G++]=$&255):(K[G++]=223,gn.setUint32(G,$),G+=4);let N;if(this.coercibleKeyAsNumber)for(let q=0;q<$;q++){N=P[q];let re=Number(N);I(isNaN(re)?N:re),I(_[N])}else for(let q=0;q<$;q++)I(N=P[q]),I(_[N])}:_=>{K[G++]=222;let P=G-n;G+=2;let $=0;for(let N in _)(typeof _.hasOwnProperty!="function"||_.hasOwnProperty(N))&&(I(N),I(_[N]),$++);if($>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');K[P+++n]=$>>8,K[P+n]=$&255},k=this.useRecords===!1?v:t.progressiveRecords&&!p?_=>{let P,$=i.transitions||(i.transitions=Object.create(null)),N=G++-n,q;for(let re in _)if(typeof _.hasOwnProperty!="function"||_.hasOwnProperty(re)){if(P=$[re],P)$=P;else{let ie=Object.keys(_),ue=$;$=i.transitions;let Oe=0;for(let Ye=0,T=ie.length;Ye<T;Ye++){let J=ie[Ye];P=$[J],P||(P=$[J]=Object.create(null),Oe++),$=P}N+n+1==G?(G--,D($,ie,Oe)):ee($,ie,N,Oe),q=!0,$=ue[re]}I(_[re])}if(!q){let re=$[Dd];re?K[N+n]=re:ee($,Object.keys(_),N,0)}}:_=>{let P,$=i.transitions||(i.transitions=Object.create(null)),N=0;for(let re in _)(typeof _.hasOwnProperty!="function"||_.hasOwnProperty(re))&&(P=$[re],P||(P=$[re]=Object.create(null),N++),$=P);let q=$[Dd];q?q>=96&&p?(K[G++]=((q-=96)&31)+96,K[G++]=q>>5):K[G++]=q:D($,$.__keys__||Object.keys(_),N);for(let re in _)(typeof _.hasOwnProperty!="function"||_.hasOwnProperty(re))&&I(_[re])},R=typeof this.useRecords=="function"&&this.useRecords,B=R?_=>{R(_)?k(_):v(_)}:k,L=_=>{let P;if(_>16777216){if(_-n>Aje)throw new Error("Packed buffer would be larger than maximum buffer size");P=Math.min(Aje,Math.round(Math.max((_-n)*(_>67108864?1.25:2),4194304)/4096)*4096)}else P=(Math.max(_-n<<2,K.length-1)>>12)+1<<12;let $=new lj(P);return gn=$.dataView||($.dataView=new DataView($.buffer,0,P)),_=Math.min(_,K.length),K.copy?K.copy($,0,n,_):$.set(K.slice(n,_)),G-=n,n=0,Bs=$.length-10,K=$},D=(_,P,$)=>{let N=i.nextId;N||(N=64),N<m&&this.shouldShareStructure&&!this.shouldShareStructure(P)?(N=i.nextOwnId,N<g||(N=m),i.nextOwnId=N+1):(N>=g&&(N=m),i.nextId=N+1);let q=P.highByte=N>=96&&p?N-96>>5:-1;_[Dd]=N,_.__keys__=P,i[N-64]=P,N<m?(P.isShared=!0,i.sharedLength=N-63,o=!0,q>=0?(K[G++]=(N&31)+96,K[G++]=q):K[G++]=N):(q>=0?(K[G++]=213,K[G++]=114,K[G++]=(N&31)+96,K[G++]=q):(K[G++]=212,K[G++]=114,K[G++]=N),$&&(E+=y*$),A.length>=f&&(A.shift()[Dd]=0),A.push(_),I(P))},ee=(_,P,$,N)=>{let q=K,re=G,ie=Bs,ue=n;K=RQ,G=0,n=0,K||(RQ=K=new lj(8192)),Bs=K.length-10,D(_,P,N),RQ=K;let Oe=G;if(K=q,G=re,Bs=ie,n=ue,Oe>1){let Ye=G+Oe-1;Ye>Bs&&L(Ye);let T=$+n;K.copyWithin(T+Oe,T+1,G),K.set(RQ.slice(0,Oe),T),G=Ye}else K[$+n]=RQ[0]},F=_=>{let P=bje(_,K,n,G,i,L,($,N,q)=>{if(q)return o=!0;G=N;let re=K;return I($),b(),re!==K?{position:G,targetView:gn,target:K}:G},this);if(P===0)return B(_);G=P}}useBuffer(t){K=t,K.dataView||(K.dataView=new DataView(K.buffer,K.byteOffset,K.byteLength)),gn=K.dataView,G=0}set position(t){G=t}get position(){return G}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};uoe=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,vQ];coe=[{pack(e,t,r){let n=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:o,targetView:i,position:s}=t(6);o[s++]=214,o[s++]=255,i.setUint32(s,n)}else if(n>0&&n<4294967296){let{target:o,targetView:i,position:s}=t(10);o[s++]=215,o[s++]=255,i.setUint32(s,e.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),i.setUint32(s+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),r(this.onInvalidDate());let{target:o,targetView:i,position:s}=t(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:i,position:s}=t(15);o[s++]=199,o[s++]=12,o[s++]=255,i.setUint32(s,e.getMilliseconds()*1e6),i.setBigInt64(s+4,BigInt(Math.floor(n)))}}},{pack(e,t,r){if(this.setAsEmptyObject)return t(0),r({});let n=Array.from(e),{target:o,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(o[i++]=212,o[i++]=115,o[i++]=0),r(n)}},{pack(e,t,r){let{target:n,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(n[o++]=212,n[o++]=101,n[o++]=0),r([e.name,e.message,e.cause])}},{pack(e,t,r){let{target:n,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(n[o++]=212,n[o++]=120,n[o++]=0),r([e.source,e.flags])}},{pack(e,t){this.moreTypes?soe(e,16,t):aoe(ik?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let r=e.constructor;r!==Eje&&this.moreTypes?soe(e,ioe.indexOf(r.name),t):aoe(e,t)}},{pack(e,t){this.moreTypes?soe(e,17,t):aoe(ik?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:r,position:n}=t(1);r[n]=193}}];wje=new hS({useRecords:!1}),hUt=wje.pack,Ije=wje.pack,{NEVER:gUt,ALWAYS:AUt,DECIMAL_ROUND:yUt,DECIMAL_FIT:xUt}=uj,kje=512,vje=1024,Rje=2048});function Tje(e,t,r,n,o,i,s,a,c){let u=a.typedStructs||(a.typedStructs=[]),l=a.maxOwnStructures??1/0,d=!c&&u.length>=l,f=t.dataView,p=(u.lastStringStart||100)+n,m=t.length-10,g=n;n>m&&(t=i(n),f=t.dataView,n-=r,g-=r,p-=r,r=0,m=t.length-10);let A,E=p,y=u.transitions||(u.transitions=Object.create(null)),b=u.nextId||u.length,w=b<15?1:b<240?2:b<61440?3:b<15728640?4:0;if(w===0)return 0;n+=w;let I=[],v,k=0;for(let L in e){let D=y[L];if(!D){if(d)return 0;y[L]=D={key:L,parent:y,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null}}let ee=e[L];switch(n>m&&(t=i(n),f=t.dataView,n-=r,g-=r,p-=r,E-=r,r=0,m=t.length-10),typeof ee){case"number":let F=ee;if(b<200||!D.num64){if(F>>0===F&&F<536870912&&F>-520093696){F<246&&F>=0&&(D.num8&&!(b>200&&D.num32)||F<32&&!D.num32)?(y=D.num8||Qd(D,ak,1,d),t[n++]=F):(y=D.num32||Qd(D,ak,4,d),f.setUint32(n,F,!0),n+=4);break}else if(F<4294967296&&F>=-2147483648&&(f.setFloat32(n,F,!0),EUt[t[n+3]>>>5])){let N;if((N=F*mS[(t[n+3]&127)<<1|t[n+2]>>7])>>0===N){y=D.num32||Qd(D,ak,4,d),n+=4;break}}}y=D.num64||Qd(D,ak,8,d),f.setFloat64(n,F,!0),n+=8;break;case"string":let _=ee.length;if(A=E-p,(_<<2)+E>m&&(t=i((_<<2)+E),f=t.dataView,n-=r,g-=r,p-=r,E-=r,r=0,m=t.length-10),_>65280+A>>2){I.push(L,ee,n-g);break}let P,$=E;if(_<64){let N,q,re;for(N=0;N<_;N++)q=ee.charCodeAt(N),q<128?t[E++]=q:q<2048?(P=!0,t[E++]=q>>6|192,t[E++]=q&63|128):(q&64512)===55296&&((re=ee.charCodeAt(N+1))&64512)===56320?(P=!0,q=65536+((q&1023)<<10)+(re&1023),N++,t[E++]=q>>18|240,t[E++]=q>>12&63|128,t[E++]=q>>6&63|128,t[E++]=q&63|128):(P=!0,t[E++]=q>>12|224,t[E++]=q>>6&63|128,t[E++]=q&63|128)}else E+=SUt(t,ee,E),P=E-$>_;if(A<160||A<246&&(D.ascii8||D.string8)){if(P)(y=D.string8)||(u.length>10&&(y=D.ascii8)?(y.__type=BQ,D.ascii8=null,D.string8=y,s(null,0,!0)):y=Qd(D,BQ,1,d));else if(A===0&&!v){v=!0,y=D.ascii0||Qd(D,doe,0,d);break}else!(y=D.ascii8)&&!(u.length>10&&(y=D.string8))&&(y=Qd(D,doe,1,d));t[n++]=A}else y=D.string16||Qd(D,BQ,2,d),f.setUint16(n,A,!0),n+=2;break;case"object":if(ee){ee.constructor===Date?(y=D.date64||Qd(D,poe,8,d),f.setFloat64(n,ee.getTime(),!0),n+=8):I.push(L,ee,k);break}else D=_je(D,n,f,-10),D?(y=D,n=gS):I.push(L,ee,k);break;case"boolean":y=D.num8||D.ascii8||Qd(D,ak,1,d),t[n++]=ee?249:248;break;case"undefined":D=_je(D,n,f,-9),D?(y=D,n=gS):I.push(L,ee,k);break;default:I.push(L,ee,k)}if(y===void 0)return 0;k++}if(!c&&I.length>0&&u.length>=l){let L=y;for(let D=0,ee=I.length;D<ee;D+=3){if(I[D+1]!=null)return 0;let F=L[I[D]];if(!F)return 0;let _=F.object16;if(!_)return 0;L=_}if(L[Dd]==null)return 0}let R=!1;for(let L=0,D=I.length;L<D;){let ee=I[L++],F=I[L++],_=I[L++],P=y[ee];P||(y[ee]=P={key:ee,parent:y,enumerationOffset:_-k,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null});let $;if(F){let N;A=E-p,A<65280?(y=P.object16,y?N=2:(y=P.object32)?N=4:(y=loe(P,fj,2),N=2)):(y=P.object32||loe(P,fj,4),N=4),$=s(F,E),R=!0,typeof $=="object"?(E=$.position,f=$.targetView,t=$.target,p-=r,n-=r,g-=r,r=0):E=$,N===2?(f.setUint16(n,A,!0),n+=2):(f.setUint32(n,A,!0),n+=4)}else y=P.object16||loe(P,fj,2),f.setInt16(n,F===null?-10:-9,!0),n+=2;k++}let B=y[Dd];if(B==null){if(!R&&u.length>=l)return 0;B=a.typedStructs.length;let L=[],D=y,ee,F;for(;(F=D.__type)!==void 0;){let _=D.__size;D=D.__parent,ee=D.key;let P=[F,_,ee];D.enumerationOffset&&P.push(D.enumerationOffset),L.push(P),D=D.parent}L.reverse(),y[Dd]=B,a.typedStructs[B]=L,s(null,0,!0)}switch(w){case 1:if(B>=16)return 0;t[g]=B+32;break;case 2:if(B>=256)return 0;t[g]=56,t[g+1]=B;break;case 3:if(B>=65536)return 0;t[g]=57,f.setUint16(g+1,B,!0);break;case 4:if(B>=16777216)return 0;f.setUint32(g,(B<<8)+58,!0);break}if(n<p){if(p===E)return n;t.copyWithin(n,p,E),E+=n-p,u.lastStringStart=n-g}else if(n>p)return p===E?n:(u.lastStringStart=n-g,Tje(e,t,r,g,o,i,s,a,!0));return E}function _je(e,t,r,n){let o;if(o=e.ascii8||e.num8)return r.setInt8(t,n,!0),gS=t+1,o;if(o=e.string16||e.object16)return r.setInt16(t,n,!0),gS=t+2,o;if(o=e.num32)return r.setUint32(t,3758096640+n,!0),gS=t+4,o;if(o=e.num64)return r.setFloat64(t,NaN,!0),r.setInt8(t,n),gS=t+8,o;gS=t}function Qd(e,t,r,n){let o=moe[t]+(r<<3),i=e[o];if(i)return i;if(!n)return i=e[o]=Object.create(null),i.__type=t,i.__size=r,i.__parent=e,i}function loe(e,t,r){let n=moe[t]+(r<<3),o=e[n];return o||(o=e[n]=Object.create(null),o.__type=t,o.__size=r,o.__parent=e,o)}function CUt(e){if(!(e instanceof Map))return e;let t=e.get("typed")||[];Object.isFrozen(t)&&(t=t.map(o=>o.slice(0)));let r=e.get("named"),n=Object.create(null);for(let o=0,i=t.length;o<i;o++){let s=t[o],a=n;for(let[c,u,l]of s){let d=a[l];d||(a[l]=d={key:l,parent:a,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null}),a=Qd(d,c,u,!1)}a[Dd]=o}return t.transitions=n,this.typedStructs=t,this.lastTypedStructuresLength=t.length,r}function wUt(e,t,r,n){let o=e[t++]-32;if(o>=24)switch(o){case 24:o=e[t++];break;case 25:o=e[t++]+(e[t++]<<8);break;case 26:o=e[t++]+(e[t++]<<8)+(e[t++]<<16);break;case 27:o=e[t++]+(e[t++]<<8)+(e[t++]<<16)+(e[t++]<<24);break}let i=n.typedStructs&&n.typedStructs[o];if(!i){if(e=Uint8Array.prototype.slice.call(e,t,r),r-=t,t=0,!n.getStructures)throw new Error(`Reference to shared structure ${o} without getStructures method`);if(n._mergeStructures(n.getStructures()),!n.typedStructs)throw new Error("Could not find any shared typed structures");if(n.lastTypedStructuresLength=n.typedStructs.length,i=n.typedStructs[o],!i)throw new Error("Could not find typed structure "+o)}var s=i.construct,a=i.fullConstruct;if(!s){s=i.construct=function(){},a=i.fullConstruct=function(){},a.prototype=n.structPrototype||{};var c=s.prototype=n.structPrototype?Object.create(n.structPrototype):{};let l=[],d=0,f;for(let p=0,m=i.length;p<m;p++){let g=i[p],[A,E,y,b]=g;y==="__proto__"&&(y="__proto_");let w={key:y,offset:d};b?l.splice(p+b,0,w):l.push(w);let I;switch(E){case 0:I=()=>0;break;case 1:I=(k,R)=>{let B=k.bytes[R+w.offset];return B>=246?sk(B):B};break;case 2:I=(k,R)=>{let B=k.bytes,D=(B.dataView||(B.dataView=new DataView(B.buffer,B.byteOffset,B.byteLength))).getUint16(R+w.offset,!0);return D>=65280?sk(D&255):D};break;case 4:I=(k,R)=>{let B=k.bytes,D=(B.dataView||(B.dataView=new DataView(B.buffer,B.byteOffset,B.byteLength))).getUint32(R+w.offset,!0);return D>=4294967040?sk(D&255):D};break}w.getRef=I,d+=E;let v;switch(A){case doe:f&&!f.next&&(f.next=w),f=w,w.multiGetCount=0,v=function(k){let R=k.bytes,B=k.position,L=d+B,D=I(k,B);if(typeof D!="number")return D;let ee,F=w.next;for(;F&&(ee=F.getRef(k,B),typeof ee!="number");)ee=null,F=F.next;return ee==null&&(ee=k.bytesEnd-L),k.srcString?k.srcString.slice(D,ee):lje(R,D+L,ee-D)};break;case BQ:case fj:f&&!f.next&&(f.next=w),f=w,v=function(k){let R=k.position,B=d+R,L=I(k,R);if(typeof L!="number")return L;let D=k.bytes,ee,F=w.next;for(;F&&(ee=F.getRef(k,R),typeof ee!="number");)ee=null,F=F.next;if(ee==null&&(ee=k.bytesEnd-B),A===BQ)return D.toString("utf8",L+B,ee+B);up=k;try{return n.unpack(D,{start:L+B,end:ee+B})}finally{up=null}};break;case ak:switch(E){case 4:v=function(k){let R=k.bytes,B=R.dataView||(R.dataView=new DataView(R.buffer,R.byteOffset,R.byteLength)),L=k.position+w.offset,D=B.getInt32(L,!0);if(D<536870912){if(D>-520093696)return D;if(D>-536870912)return sk(D&255)}let ee=B.getFloat32(L,!0),F=mS[(R[L+3]&127)<<1|R[L+2]>>7];return(F*ee+(ee>0?.5:-.5)>>0)/F};break;case 8:v=function(k){let R=k.bytes,L=(R.dataView||(R.dataView=new DataView(R.buffer,R.byteOffset,R.byteLength))).getFloat64(k.position+w.offset,!0);if(isNaN(L)){let D=R[k.position+w.offset];if(D>=246)return sk(D)}return L};break;case 1:v=function(k){let B=k.bytes[k.position+w.offset];return B<246?B:sk(B)};break}break;case poe:v=function(k){let R=k.bytes,B=R.dataView||(R.dataView=new DataView(R.buffer,R.byteOffset,R.byteLength));return new Date(B.getFloat64(k.position+w.offset,!0))};break}w.get=v}if(Bje){let p=[],m=[],g=0,A;for(let y of l){if(n.alwaysLazyProperty&&n.alwaysLazyProperty(y.key)){A=!0;continue}Object.defineProperty(c,y.key,{get:IUt(y.get),enumerable:!0});let b="v"+g++;m.push(b),p.push("o["+JSON.stringify(y.key)+"]="+b+"(s)")}A&&p.push("__proto__:this");let E=new Function(...m,"var c=this;return function(s){var o=new c();"+p.join(";")+";return o;}").apply(a,l.map(y=>y.get));Object.defineProperty(c,"toJSON",{value(y){return E.call(this,this[foe])}})}else Object.defineProperty(c,"toJSON",{value(p){let m={};for(let g=0,A=l.length;g<A;g++){let E=l[g].key;m[E]=this[E]}return m}})}var u=new s;return u[foe]={bytes:e,position:t,srcString:"",bytesEnd:r},u}function sk(e){switch(e){case 246:return null;case 247:return;case 248:return!1;case 249:return!0}throw new Error("Unknown constant")}function IUt(e){return function(){return e(this[foe])}}function kUt(){up&&(up.bytes=Uint8Array.prototype.slice.call(up.bytes,up.position,up.bytesEnd),up.position=0,up.bytesEnd=up.bytes.length)}function vUt(e,t){if(t.typedStructs){let n=new Map;n.set("named",e),n.set("typed",t.typedStructs),e=n}let r=t.lastTypedStructuresLength||0;return e.isCompatible=n=>{let o=!0;return n instanceof Map?((n.get("named")||[]).length!==(t.lastNamedStructuresLength||0)&&(o=!1),(n.get("typed")||[]).length!==r&&(o=!1)):(n instanceof Array||Array.isArray(n))&&n.length!==(t.lastNamedStructuresLength||0)&&(o=!1),o||t._mergeStructures(n),o},t.lastTypedStructuresLength=t.typedStructs&&t.typedStructs.length,e}var doe,ak,BQ,fj,poe,moe,EUt,Bje,gS,bUt,pj,up,SUt,Srn,Crn,foe,Dje=h(()=>{_Q();Fh();doe=3,ak=0,BQ=2,fj=1,poe=16,moe=["num","object","string","ascii"];moe[poe]="date";EUt=[!1,!0,!0,!1,!1,!0,!0,!1];try{new Function(""),Bje=!0}catch{}bUt=typeof Buffer<"u";try{pj=new TextEncoder}catch{}SUt=bUt?function(e,t,r){return e.utf8Write(t,r,e.byteLength-r)}:pj&&pj.encodeInto?function(e,t,r){return pj.encodeInto(t,e.subarray(r)).written}:!1,Srn=Symbol("type"),Crn=Symbol("parent");Cje(Tje,vUt);foe=Symbol.for("source");gje(wUt,CUt,kUt)});var Qje=h(()=>{_Q();Fh()});var Oje=h(()=>{_Q();Fh()});var Mje=ne((Brn,Pje)=>{"use strict";var Nje=()=>process.platform==="linux",mj=null,RUt=()=>{if(!mj)if(Nje()&&process.report){let e=process.report.excludeNetwork;process.report.excludeNetwork=!0,mj=process.report.getReport(),process.report.excludeNetwork=e}else mj={};return mj};Pje.exports={isLinux:Nje,getReport:RUt}});var Lje=ne((Trn,Fje)=>{"use strict";var ck=Y("fs"),_Ut="/usr/bin/ldd",BUt="/proc/self/exe",hj=2048,TUt=e=>{let t=ck.openSync(e,"r"),r=Buffer.alloc(hj),n=ck.readSync(t,r,0,hj,0);return ck.close(t,()=>{}),r.subarray(0,n)},DUt=e=>new Promise((t,r)=>{ck.open(e,"r",(n,o)=>{if(n)r(n);else{let i=Buffer.alloc(hj);ck.read(o,i,0,hj,0,(s,a)=>{t(i.subarray(0,a)),ck.close(o,()=>{})})}})});Fje.exports={LDD_PATH:_Ut,SELF_PATH:BUt,readFileSync:TUt,readFile:DUt}});var $je=ne((Drn,Uje)=>{"use strict";var QUt=e=>{if(e.length<64||e.readUInt32BE(0)!==2135247942||e.readUInt8(4)!==2||e.readUInt8(5)!==1)return null;let t=e.readUInt32LE(32),r=e.readUInt16LE(54),n=e.readUInt16LE(56);for(let o=0;o<n;o++){let i=t+o*r;if(e.readUInt32LE(i)===3){let a=e.readUInt32LE(i+8),c=e.readUInt32LE(i+32);return e.subarray(a,a+c).toString().replace(/\0.*$/g,"")}}return null};Uje.exports={interpreterPath:QUt}});var sqe=ne((Qrn,iqe)=>{"use strict";var Wje=Y("child_process"),{isLinux:uk,getReport:jje}=Mje(),{LDD_PATH:gj,SELF_PATH:qje,readFile:hoe,readFileSync:goe}=Lje(),{interpreterPath:Gje}=$je(),lp,dp,fp,zje="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",Qy="",Vje=()=>Qy||new Promise(e=>{Wje.exec(zje,(t,r)=>{Qy=t?" ":r,e(Qy)})}),Yje=()=>{if(!Qy)try{Qy=Wje.execSync(zje,{encoding:"utf8"})}catch{Qy=" "}return Qy},Lh="glibc",Jje=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,AS="musl",OUt=e=>e.includes("libc.musl-")||e.includes("ld-musl-"),Kje=()=>{let e=jje();return e.header&&e.header.glibcVersionRuntime?Lh:Array.isArray(e.sharedObjects)&&e.sharedObjects.some(OUt)?AS:null},Zje=e=>{let[t,r]=e.split(/[\r\n]+/);return t&&t.includes(Lh)?Lh:r&&r.includes(AS)?AS:null},Xje=e=>{if(e){if(e.includes("/ld-musl-"))return AS;if(e.includes("/ld-linux-"))return Lh}return null},eqe=e=>(e=e.toString(),e.includes("musl")?AS:e.includes("GNU C Library")?Lh:null),NUt=async()=>{if(dp!==void 0)return dp;dp=null;try{let e=await hoe(gj);dp=eqe(e)}catch{}return dp},PUt=()=>{if(dp!==void 0)return dp;dp=null;try{let e=goe(gj);dp=eqe(e)}catch{}return dp},MUt=async()=>{if(lp!==void 0)return lp;lp=null;try{let e=await hoe(qje),t=Gje(e);lp=Xje(t)}catch{}return lp},FUt=()=>{if(lp!==void 0)return lp;lp=null;try{let e=goe(qje),t=Gje(e);lp=Xje(t)}catch{}return lp},tqe=async()=>{let e=null;if(uk()&&(e=await MUt(),!e&&(e=await NUt(),e||(e=Kje()),!e))){let t=await Vje();e=Zje(t)}return e},rqe=()=>{let e=null;if(uk()&&(e=FUt(),!e&&(e=PUt(),e||(e=Kje()),!e))){let t=Yje();e=Zje(t)}return e},LUt=async()=>uk()&&await tqe()!==Lh,UUt=()=>uk()&&rqe()!==Lh,$Ut=async()=>{if(fp!==void 0)return fp;fp=null;try{let t=(await hoe(gj)).match(Jje);t&&(fp=t[1])}catch{}return fp},HUt=()=>{if(fp!==void 0)return fp;fp=null;try{let t=goe(gj).match(Jje);t&&(fp=t[1])}catch{}return fp},nqe=()=>{let e=jje();return e.header&&e.header.glibcVersionRuntime?e.header.glibcVersionRuntime:null},Hje=e=>e.trim().split(/\s+/)[1],oqe=e=>{let[t,r,n]=e.split(/[\r\n]+/);return t&&t.includes(Lh)?Hje(t):r&&n&&r.includes(AS)?Hje(n):null},WUt=async()=>{let e=null;if(uk()&&(e=await $Ut(),e||(e=nqe()),!e)){let t=await Vje();e=oqe(t)}return e},jUt=()=>{let e=null;if(uk()&&(e=HUt(),e||(e=nqe()),!e)){let t=Yje();e=oqe(t)}return e};iqe.exports={GLIBC:Lh,MUSL:AS,family:tqe,familySync:rqe,isNonGlibcLinux:LUt,isNonGlibcLinuxSync:UUt,version:WUt,versionSync:jUt}});var Eqe=ne((Orn,xqe)=>{var qUt=Y("fs"),Od=Y("path"),GUt=Y("url"),uqe=Y("os"),lqe=typeof __webpack_require__=="function"?__non_webpack_require__:Y,zUt=process.config&&process.config.variables||{},VUt=!!process.env.PREBUILDS_ONLY,boe=process.versions,yoe=boe.modules;(boe.deno||process.isBun)&&(yoe="unsupported");var Aoe=KUt()?"electron":JUt()?"node-webkit":"node",Aj=process.env.npm_config_arch||uqe.arch(),yj=process.env.npm_config_platform||uqe.platform(),dqe=process.env.LIBC||(ZUt(yj)?"musl":"glibc"),xoe=process.env.ARM_VERSION||(Aj==="arm64"?"8":zUt.arm_version)||"",fqe=(boe.uv||"").split(".")[0];xqe.exports=pp;function pp(e){return lqe(pp.resolve(e))}pp.resolve=pp.path=function(e){e=Od.resolve(e||".");var t="",r;try{t=lqe(Od.join(e,"package.json")).name;var n=t.toUpperCase().replace(/-/g,"_");process.env[n+"_PREBUILD"]&&(e=process.env[n+"_PREBUILD"])}catch(g){r=g}if(!VUt){var o=aqe(Od.join(e,"build/Release"),cqe);if(o)return o;var i=aqe(Od.join(e,"build/Debug"),cqe);if(i)return i}var s=p(e);if(s)return s;var a=p(Od.dirname(process.execPath));if(a)return a;var c=(t[0]=="@"?"":"@"+t+"/")+t+"-"+yj+"-"+Aj,u;try{var l=Od.dirname(Y("module").createRequire(GUt.pathToFileURL(Od.join(e,"package.json"))).resolve(c));return m(l)}catch(g){u=g}var d=["platform="+yj,"arch="+Aj,"runtime="+Aoe,"abi="+yoe,"uv="+fqe,xoe?"armv="+xoe:"","libc="+dqe,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__=="function"?"webpack=true":""].filter(Boolean).join(" ");let f="No native build was found for "+d+`
72
+ `)&&(e=e.replace(o1t,"%0A")),e.includes("\r")&&(e=e.replace(i1t,"%0D")),e.includes(" ")&&(e=e.replace(s1t,"%09")),e}var GW,yne,bHe,e1t,r1t,n1t,o1t,i1t,s1t,Ane,SHe=h(()=>{sr();nr();oe();Th();GW=Symbol.for("@effect/platform/Path"),yne=Jt("@effect/platform/Path");bHe=function(){let t="",r=!1,n;for(let o=arguments.length-1;o>=-1&&!r;o--){let i;if(o>=0)i=arguments[o];else{let s=globalThis.process;n===void 0&&"process"in globalThis&&typeof s=="object"&&s!==null&&typeof s.cwd=="function"&&(n=s.cwd()),i=n}i.length!==0&&(t=i+"/"+t,r=i.charCodeAt(0)===47)}return t=EHe(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},e1t=47;r1t=/%/g,n1t=/\\/g,o1t=/\n/g,i1t=/\r/g,s1t=/\t/g;Ane=yne.of({[GW]:GW,resolve:bHe,normalize(e){if(e.length===0)return".";let t=e.charCodeAt(0)===47,r=e.charCodeAt(e.length-1)===47;return e=EHe(e,!t),e.length===0&&!t&&(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return".";let e;for(let t=0;t<arguments.length;++t){let r=arguments[t];r.length>0&&(e===void 0?e=r:e+="/"+r)}return e===void 0?".":Ane.normalize(e)},relative(e,t){if(e===t||(e=Ane.resolve(e),t=Ane.resolve(t),e===t))return"";let r=1;for(;r<e.length&&e.charCodeAt(r)===47;++r);let n=e.length,o=n-r,i=1;for(;i<t.length&&t.charCodeAt(i)===47;++i);let a=t.length-i,c=o<a?o:a,u=-1,l=0;for(;l<=c;++l){if(l===c){if(a>c){if(t.charCodeAt(i+l)===47)return t.slice(i+l+1);if(l===0)return t.slice(i+l)}else o>c&&(e.charCodeAt(r+l)===47?u=l:l===0&&(u=0));break}let f=e.charCodeAt(r+l),p=t.charCodeAt(i+l);if(f!==p)break;f===47&&(u=l)}let d="";for(l=r+u+1;l<=n;++l)(l===n||e.charCodeAt(l)===47)&&(d.length===0?d+="..":d+="/..");return d.length>0?d+t.slice(i+u):(i+=u,t.charCodeAt(i)===47&&++i,t.slice(i))},dirname(e){if(e.length===0)return".";let t=e.charCodeAt(0),r=t===47,n=-1,o=!0;for(let i=e.length-1;i>=1;--i)if(t=e.charCodeAt(i),t===47){if(!o){n=i;break}}else o=!1;return n===-1?r?"/":".":r&&n===1?"//":e.slice(0,n)},basename(e,t){let r=0,n=-1,o=!0,i;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";let s=t.length-1,a=-1;for(i=e.length-1;i>=0;--i){let c=e.charCodeAt(i);if(c===47){if(!o){r=i+1;break}}else a===-1&&(o=!1,a=i+1),s>=0&&(c===t.charCodeAt(s)?--s===-1&&(n=i):(s=-1,n=a))}return r===n?n=a:n===-1&&(n=e.length),e.slice(r,n)}else{for(i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!o){r=i+1;break}}else n===-1&&(o=!1,n=i+1);return n===-1?"":e.slice(r,n)}},extname(e){let t=-1,r=0,n=-1,o=!0,i=0;for(let s=e.length-1;s>=0;--s){let a=e.charCodeAt(s);if(a===47){if(!o){r=s+1;break}continue}n===-1&&(o=!1,n=s+1),a===46?t===-1?t=s:i!==1&&(i=1):t!==-1&&(i=-1)}return t===-1||n===-1||i===0||i===1&&t===n-1&&t===r+1?"":e.slice(t,n)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return ZLt("/",t)},parse(e){let t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;let r=e.charCodeAt(0),n=r===47,o;n?(t.root="/",o=1):o=0;let i=-1,s=0,a=-1,c=!0,u=e.length-1,l=0;for(;u>=o;--u){if(r=e.charCodeAt(u),r===47){if(!c){s=u+1;break}continue}a===-1&&(c=!1,a=u+1),r===46?i===-1?i=u:l!==1&&(l=1):i!==-1&&(l=-1)}return i===-1||a===-1||l===0||l===1&&i===a-1&&i===s+1?a!==-1&&(s===0&&n?t.base=t.name=e.slice(1,a):t.base=t.name=e.slice(s,a)):(s===0&&n?(t.name=e.slice(1,i),t.base=e.slice(1,a)):(t.name=e.slice(s,i),t.base=e.slice(s,a)),t.ext=e.slice(i,a)),s>0?t.dir=e.slice(0,s-1):n&&(t.dir="/"),t},sep:"/",fromFileUrl:XLt,toFileUrl:t1t,toNamespacedPath:be})});var uS,Oh,zW=h(()=>{SHe();uS=GW,Oh=yne});function l1t(e){switch(e._tag){case"ReachedLimit":switch(e.limit){case"MaxParts":return new Qc({reason:"TooManyParts",cause:e});case"MaxFieldSize":return new Qc({reason:"FieldTooLarge",cause:e});case"MaxPartSize":return new Qc({reason:"FileTooLarge",cause:e});case"MaxTotalSize":return new Qc({reason:"BodyTooLarge",cause:e})}default:return new Qc({reason:"Parse",cause:e})}}var xne,wHe,Qc,u1t,kHe,IHe,SQ,Ene,bne,d1t,f1t,vHe,Sne,Cne,wne,Ine,kne,vne=h(()=>{aS();vr();sr();nr();Ro();oe();ht();EQ();it();X0();wd();xHe();AQ();QW();zW();xne=Symbol.for("@effect/platform/Multipart"),wHe=Symbol.for("@effect/platform/Multipart/MultipartError"),Qc=class extends sS()("MultipartError",{reason:is("FileTooLarge","FieldTooLarge","BodyTooLarge","TooManyParts","InternalError","Parse"),cause:ip}){[wHe]=wHe;get message(){return this.reason}},u1t=e=>$a(t=>{let r=Dr(t.currentContext,kne);return nt({headers:e,maxParts:Gr(Dr(t.currentContext,Cne)),maxFieldSize:Number(Dr(t.currentContext,wne)),maxPartSize:Dr(t.currentContext,Ine).pipe(dr(Number),Gr),maxTotalSize:Dr(t.currentContext,TW).pipe(dr(Number),Gr),isFile:r.length===0?void 0:n=>!gbe(r,o=>n.contentType.includes(o))&&AHe(n)})}),kHe=(e,t=16)=>_W(Ib([u1t(e),ok(t)]),([r,n])=>{let o=[],i=W(),s={awaitRead:()=>ve,emit(l){return n.offer(l)},error(l){return i=H(Mn(l)),n.end},done(l){return n.end}},a=gHe({...r,onField(l,d){o.push(new Ene(l.name,l.contentType,yHe(l,d)))},onFile(l){let d=[],f=!1,p=ek(()=>{if(d.length===0)return f?Ry:pQ(c,p);let m=ln(d);return d=[],f?_y(m):pQ(_y(m),pQ(c,p))});return o.push(new bne(l,p)),function(m){m===null?f=!0:d.push(m)}},onError(l){i=H(Cc(l1t(l)))},onDone(){i=H(wc)}}),c=Bd(n.takeAll,([l,d])=>A2e(()=>{C_(l,C_(a.write)),d&&a.end()})),u=Bd(c,()=>{if(o.length===0)return i._tag==="None"?u:IHe(i.value);let l=ln(o);return o=[],pQ(_y(l),i._tag==="None"?u:IHe(i.value))});return fQ(u,s)},([,r])=>r.shutdown),IHe=e=>e._tag==="Success"?Ry:Jre(e.cause);SQ=class extends Wg{[xne];constructor(){super(),this[xne]=xne}},Ene=class extends SQ{key;contentType;value;_tag="Field";constructor(t,r,n){super(),this.key=t,this.contentType=r,this.value=n}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"Field",key:this.key,contentType:this.contentType,value:this.value}}},bne=class extends SQ{_tag="File";key;name;contentType;content;contentEffect;constructor(t,r){super(),this.key=t.name,this.name=t.filename??t.name,this.contentType=t.contentType,this.content=dy(r),this.contentEffect=r.pipe(p2e(f1t),h2e,Ha(n=>new Qc({reason:"InternalError",cause:n})))}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"File",key:this.key,name:this.name,contentType:this.contentType}}},d1t=(e,t)=>Ee(By,r=>Ha(_0(t.content,r.sink(e)),n=>new Qc({reason:"InternalError",cause:n}))),f1t=ek(()=>{let e=new Uint8Array(0),t=m2e({onInput(r){for(let n of r){let o=new Uint8Array(e.length+n.length);o.set(e,0),o.set(n,e.length),e=o}return t},onFailure:r=>Jre(r),onDone:()=>g2e(e)});return t}),vHe=(e,t=d1t)=>Go(function*(){let r=yield*By,n=yield*Oh,o=yield*r.makeTempDirectoryScoped(),i=Object.create(null);return yield*TMe(e,s=>{if(s._tag==="Field")return s.key in i?typeof i[s.key]=="string"?i[s.key]=[i[s.key],s.value]:i[s.key].push(s.value):i[s.key]=s.value,ve;if(s.name==="")return ve;let a=s,c=n.join(o,n.basename(a.name).slice(-128)),u=new Sne(a.key,a.name,a.contentType,c);return Array.isArray(i[s.key])?i[s.key].push(u):i[s.key]=[u],t(c,a)}),i}).pipe(j$({SystemError:r=>$e(new Qc({reason:"InternalError",cause:r})),BadArgument:r=>$e(new Qc({reason:"InternalError",cause:r}))})),Sne=class extends SQ{key;name;contentType;path;_tag="PersistedFile";constructor(t,r,n,o){super(),this.key=t,this.name=r,this.contentType=n,this.path=o}toJSON(){return{_id:"@effect/platform/Multipart/Part",_tag:"PersistedFile",key:this.key,name:this.name,contentType:this.contentType,path:this.path}}},Cne=class extends ai()("@effect/platform/Multipart/MaxParts",{defaultValue:W}){},wne=class extends ai()("@effect/platform/Multipart/MaxFieldSize",{defaultValue:fm(Dh(10*1024*1024))}){},Ine=class extends ai()("@effect/platform/Multipart/MaxFileSize",{defaultValue:W}){},kne=class extends ai()("@effect/platform/Multipart/FieldMimeTypes",{defaultValue:fm(Kg("application/json"))}){}});var Rne,m1t,h1t,g1t,_He,BHe,THe,A1t,DHe,QHe,_ne=h(()=>{Vs();$u();nr();Ro();WI();Zl();oe();dc();ht();x_();Me();ct();Rne=Symbol.for("effect/FiberSet"),m1t=e=>se(e,Rne),h1t={[Rne]:Rne,[Symbol.iterator](){return this.state._tag==="Closed"?gF():this.state.backing[Symbol.iterator]()},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"FiberMap",state:this.state}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},g1t=(e,t)=>{let r=Object.create(h1t);return r.state={_tag:"Open",backing:e},r.deferred=t,r},_He=()=>zo(De(rn(),e=>g1t(new Set,e)),e=>$a(t=>{let r=e.state;if(r._tag==="Closed")return ve;e.state={_tag:"Closed"};let n=r.backing;return w8(n,jw(t.id(),THe)).pipe(f0(e.deferred))})),BHe=-1,THe=YSe(BHe,0),A1t=Kwe(void 0,{emptyCase:Gi,failCase:Gi,dieCase:Gi,interruptCase:(e,t)=>FF(qw(t),BHe),sequentialCase:(e,t,r)=>t||r,parallelCase:(e,t,r)=>t||r}),DHe=x(e=>m1t(e[0]),(e,t,r)=>{if(e.state._tag==="Closed"){t.unsafeInterruptAsFork(jw(r?.interruptAs??ci,THe));return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(n=>{e.state._tag!=="Closed"&&(e.state.backing.delete(t),sd(n)&&(r?.propagateInterruption===!0?!A1t(n.cause):!Ywe(n.cause))&&kc(e.deferred,n))})}),QHe=e=>Ht(e.deferred)});var Bne,NHe,PHe=h(()=>{Bne=Symbol.for("@effect/platform/Socket/CloseEvent"),NHe=class{code;reason;[Bne];constructor(t=1e3,r){this.code=t,this.reason=r,this[Bne]=Bne}toString(){return this.reason?`${this.code}: ${this.reason}`:`${this.code}`}}});var VW,FHe,LHe,MHe,UHe=h(()=>{sr();nr();ht();it();wd();IW();vW();QW();FW();vne();nne();VW=Symbol.for("@effect/platform/HttpServerRequest"),FHe=Jt("@effect/platform/HttpServerRequest"),LHe=Jt("@effect/platform/HttpServerRequest/ParsedSearchParams"),MHe=class e extends Wg{source;url;headersOverride;remoteAddressOverride;[VW];[DW];constructor(t,r,n,o){super(),this.source=t,this.url=r,this.headersOverride=n,this.remoteAddressOverride=o,this[VW]=VW,this[DW]=DW}toJSON(){return N2e(this,{_id:"@effect/platform/HttpServerRequest",method:this.method,url:this.originalUrl})}modify(t){return new e(this.source,t.url??this.url,t.headers??this.headersOverride,t.remoteAddress??this.remoteAddressOverride)}get method(){return this.source.method.toUpperCase()}get originalUrl(){return this.source.url}get remoteAddress(){return this.remoteAddressOverride?H(this.remoteAddressOverride):W()}get headers(){return this.headersOverride??=kW(this.source.headers),this.headersOverride}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=a2e(this.headers.cookie??"")}get stream(){return this.source.body?kMe(()=>this.source.body,t=>new ap({request:this,reason:"Decode",cause:t})):kD(new ap({request:this,reason:"Decode",description:"can not create stream from empty body"}))}textEffect;get text(){return this.textEffect?this.textEffect:(this.textEffect=xd(GT(ey({try:()=>this.source.text(),catch:t=>new ap({request:this,reason:"Decode",cause:t})}))),this.textEffect)}get json(){return zT(this.text,{try:t=>JSON.parse(t),catch:t=>new ap({request:this,reason:"Decode",cause:t})})}get urlParamsBody(){return Ee(this.text,t=>Wu({try:()=>D2e(new URLSearchParams(t)),catch:r=>new ap({request:this,reason:"Decode",cause:r})}))}multipartEffect;get multipart(){return this.multipartEffect?this.multipartEffect:(this.multipartEffect=xd(GT(vHe(this.multipartStream))),this.multipartEffect)}get multipartStream(){return _Me(RMe(this.stream,t=>new Qc({reason:"InternalError",cause:t})),kHe(this.headers))}arrayBufferEffect;get arrayBuffer(){return this.arrayBufferEffect?this.arrayBufferEffect:(this.arrayBufferEffect=xd(GT(ey({try:()=>this.source.arrayBuffer(),catch:t=>new ap({request:this,reason:"Decode",cause:t})}))),this.arrayBufferEffect)}get upgrade(){return $e(new ap({request:this,reason:"Decode",description:"Not an upgradeable ServerRequest"}))}}});var YW,$He,Tne=h(()=>{UHe();YW=FHe,$He=LHe});function qHe(e){let t=new jHe;if(typeof e!="string")return t;let r=e.length,n="",o="",i=-1,s=-1,a=!1,c=!1,u=!1,l=!1,d=!1,f=0;for(let p=0;p<r+1;p++)if(f=p!==r?e.charCodeAt(p):38,f===38){if(d=s>i,d||(s=p),n=e.slice(i+1,s),d||n.length>0){if(u&&(n=n.replace(WHe," ")),a)try{n=decodeURIComponent(n)||n}catch{}if(d&&(o=e.slice(s+1,p),l&&(o=o.replace(WHe," ")),c))try{o=decodeURIComponent(o)||o}catch{}let m=t[n];m===void 0?t[n]=o:m.pop?m.push(o):t[n]=[m,o]}o="",i=p,s=p,a=!1,c=!1,u=!1,l=!1}else f===61?s<=i?s=p:c=!0:f===43?s>i?l=!0:u=!0:f===37&&(s>i?c=!0:a=!0);return t}var WHe,jHe,GHe=h(()=>{WHe=/\+/g,jHe=function(){};jHe.prototype=Object.create(null)});function zHe(e){return e.replace(/\/\/+/g,"/")}function VHe(e){return e.length>1&&e.charCodeAt(e.length-1)===47?e.slice(0,-1):e}function C1t(e){let t=e.length;return function(r){let n={};for(let o=0;o<t;o++)n[e[o]]=r[o];return n}}function w1t(e,t){let r=1;for(;t<e.length;){if(t++,e[t]==="\\"){t++;continue}if(e[t]===")"?r--:e[t]==="("&&r++,!r)return t}throw new TypeError('Invalid regexp expression in "'+e+'"')}function I1t(e){return e.charCodeAt(1)===94&&(e=e.slice(0,1)+e.slice(2)),e.charCodeAt(e.length-2)===36&&(e=e.slice(0,e.length-2)+e.slice(e.length-1)),e}function k1t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function KHe(e,t){if(e===50)return t===53?"%":t===51?"#":t===52?"$":t===54?"&":t===66||t===98?"+":t===67||t===99?",":t===70||t===102?"/":void 0;if(e===51)return t===65||t===97?":":t===66||t===98?";":t===68||t===100?"=":t===70||t===102?"?":void 0;if(e===52&&t===48)return"@"}function v1t(e){let t=!1,r=!1,n="";for(let i=1;i<e.length;i++){let s=e.charCodeAt(i);if(s===37){let a=e.charCodeAt(i+1),c=e.charCodeAt(i+2);KHe(a,c)===void 0?t=!0:(r=!0,a===50&&c===53&&(t=!0,e=e.slice(0,i+1)+"25"+e.slice(i+1),i+=2),i+=2)}else if(s===63||s===59||s===35){n=e.slice(i+1),e=e.slice(0,i);break}}return{path:t?decodeURI(e):e,querystring:n,shouldDecodeParam:r}}function YHe(e){let t=e.indexOf("%");if(t===-1)return e;let r="",n=t;for(let o=t;o<e.length;o++)if(e.charCodeAt(o)===37){let i=e.charCodeAt(o+1),s=e.charCodeAt(o+2),a=KHe(i,s);r+=e.slice(n,o)+a,n=o+3}return e.slice(0,t)+r+e.slice(n)}var b1t,Dne,JHe,Qne,One,JW,KW,CQ,Nne,Pne,S1t,R1t,ZHe=h(()=>{GHe();b1t=/^https?:\/\/.*?\//,Dne=/(\/:[^/()]*?)\?(\/?)/,JHe=(e={})=>new Qne(e),Qne=class{constructor(t={}){this.options={ignoreTrailingSlash:!0,ignoreDuplicateSlashes:!0,caseSensitive:!1,maxParamLength:100,...t}}options;routes=[];trees={};on(t,r,n){let o=r.match(Dne);if(o&&o.index!==void 0){S1t(r.length===o.index+o[0].length,"Optional Parameter needs to be the last parameter of the path");let s=r.replace(Dne,"$1$2"),a=r.replace(Dne,"$2");this.on(t,s,n),this.on(t,a,n);return}this.options.ignoreDuplicateSlashes&&(r=zHe(r)),this.options.ignoreTrailingSlash&&(r=VHe(r));let i=typeof t=="string"?[t]:t;for(let s of i)this._on(s,r,n)}all(t,r){this.on(R1t,t,r)}_on(t,r,n){this.trees[t]===void 0&&(this.trees[t]=new CQ("/"));let o=r;if(o==="*"&&this.trees[t].prefix.length!==0){let u=this.trees[t];this.trees[t]=new CQ(""),this.trees[t].staticChildren["/"]=u}let i=this.trees[t].prefix.length,s=this.trees[t],a=[];for(let u=0;u<=o.length;u++){if(o.charCodeAt(u)===58&&o.charCodeAt(u+1)===58){u++;continue}let l=o.charCodeAt(u)===58&&o.charCodeAt(u+1)!==58,d=o.charCodeAt(u)===42;if(l||d||u===o.length&&u!==i){let f=o.slice(i,u);this.options.caseSensitive||(f=f.toLowerCase()),f=f.split("::").join(":"),f=f.split("%").join("%25"),s=s.createStaticChild(f)}if(l){let f=!1,p=[],m=u+1;for(let g=m;;g++){let A=o.charCodeAt(g),E=A===40,y=A===45||A===46,b=A===47||g===o.length;if(E||y||b){let w=o.slice(m,g);if(a.push(w),f=f||E||y,E){let k=w1t(o,g),R=o.slice(g,k+1);p.push(I1t(R)),g=k+1}else p.push("(.*?)");let I=g;for(;g<o.length;g++){let k=o.charCodeAt(g);if(k===47)break;if(k===58)if(o.charCodeAt(g+1)===58)g++;else break}let v=o.slice(I,g);if(v&&(v=v.split("::").join(":"),v=v.split("%").join("%25"),p.push(k1t(v))),m=g+1,b||o.charCodeAt(g)===47||g===o.length){let k=f?"()"+v:v,R=o.slice(u,g);o=o.slice(0,u+1)+k+o.slice(g),u+=k.length;let B=f?new RegExp("^"+p.join("")+"$"):void 0;s=s.createParametricChild(B,v,R),i=u+1;break}}}}else if(d&&(a.push("*"),s=s.createWildcardChild(),i=u+1,u!==o.length-1))throw new Error("Wildcard must be the last character in the route")}this.options.caseSensitive||(o=o.toLowerCase()),o==="*"&&(o="/*");for(let u of this.routes)if(u.method===t&&u.pattern===o)throw new Error(`Method '${t}' already declared for route '${o}'`);let c={method:t,path:r,pattern:o,params:a,handler:n};this.routes.push(c),s.addRoute(c)}has(t,r){let n=this.trees[t];if(n===void 0)return!1;let o=n.getStaticChild(r);return o===void 0?!1:o.isLeafNode}find(t,r){let n=this.trees[t];if(n===void 0)return;r.charCodeAt(0)!==47&&(r=r.replace(b1t,"/")),this.options.ignoreDuplicateSlashes&&(r=zHe(r));let o,i,s;try{o=v1t(r),r=o.path,i=o.querystring,s=o.shouldDecodeParam}catch{return}this.options.ignoreTrailingSlash&&(r=VHe(r));let a=r;this.options.caseSensitive===!1&&(r=r.toLowerCase());let c=this.options.maxParamLength,u=n.prefix.length,l=[],d=r.length,f=[];for(;;){if(u===d&&n.isLeafNode){let m=n.handlerStorage?.find();if(m!==void 0)return{handler:m.handler,params:m.createParams(l),searchParams:qHe(i)}}let p=n.getNextNode(r,u,f,l.length);if(p===void 0){if(f.length===0)return;let m=f.pop();u=m.brotherPathIndex,l.splice(m.paramsCount),p=m.brotherNode}if(n=p,n._tag==="StaticNode"){u+=n.prefix.length;continue}if(n._tag==="WildcardNode"){let m=a.slice(u);s&&(m=YHe(m)),l.push(m),u=d;continue}if(n._tag==="ParametricNode"){let m=a.indexOf("/",u);m===-1&&(m=d);let g=a.slice(u,m);if(s&&(g=YHe(g)),n.regex!==void 0){let A=n.regex.exec(g);if(A===null)continue;for(let E=1;E<A.length;E++){let y=A[E];if(y.length>c)return;l.push(y)}}else{if(g.length>c)return;l.push(g)}u=m}}}},One=class{handlers=[];unconstrainedHandler;find(){return this.unconstrainedHandler}add(t){let r={params:t.params,handler:t.handler,createParams:C1t(t.params)};this.handlers.push(r),this.unconstrainedHandler=this.handlers[0]}},JW=class{isLeafNode=!1;routes;handlerStorage;addRoute(t){this.routes===void 0?this.routes=[t]:this.routes.push(t),this.handlerStorage===void 0&&(this.handlerStorage=new One),this.isLeafNode=!0,this.handlerStorage.add(t)}},KW=class extends JW{staticChildren={};findStaticMatchingChild(t,r){let n=this.staticChildren[t.charAt(r)];if(!(n===void 0||!n.matchPrefix(t,r)))return n}getStaticChild(t,r=0){if(t.length===r)return this;let n=this.findStaticMatchingChild(t,r);if(n!==void 0)return n.getStaticChild(t,r+n.prefix.length)}createStaticChild(t){if(t.length===0)return this;let r=this.staticChildren[t.charAt(0)];if(r){let o=1;for(;o<r.prefix.length;o++)if(t.charCodeAt(o)!==r.prefix.charCodeAt(o)){r=r.split(this,o);break}return r.createStaticChild(t.slice(o))}let n=t.charAt(0);return this.staticChildren[n]=new CQ(t),this.staticChildren[n]}},CQ=class e extends KW{_tag="StaticNode";constructor(t){super(),this.setPrefix(t)}prefix;matchPrefix;parametricChildren=[];wildcardChild;setPrefix(t){if(this.prefix=t,t.length===1)this.matchPrefix=(r,n)=>!0;else{let r=t.length;this.matchPrefix=function(n,o){for(let i=1;i<r;i++)if(n.charCodeAt(o+i)!==this.prefix.charCodeAt(i))return!1;return!0}}}getParametricChild(t){if(t===void 0)return this.parametricChildren.find(n=>n.isRegex===!1);let r=t.source;return this.parametricChildren.find(n=>n.regex===void 0?!1:n.regex.source===r)}createParametricChild(t,r,n){let o=this.getParametricChild(t);return o!==void 0?(o.nodePaths.add(n),o):(o=new Nne(t,r,n),this.parametricChildren.push(o),this.parametricChildren.sort((i,s)=>i.isRegex?s.isRegex?i.staticSuffix===void 0?1:s.staticSuffix===void 0?-1:s.staticSuffix.endsWith(i.staticSuffix)?1:i.staticSuffix.endsWith(s.staticSuffix)?-1:0:-1:1),o)}createWildcardChild(){return this.wildcardChild===void 0&&(this.wildcardChild=new Pne),this.wildcardChild}split(t,r){let n=this.prefix.slice(0,r),o=this.prefix.slice(r);this.setPrefix(o);let i=new e(n);return i.staticChildren[o.charAt(0)]=this,t.staticChildren[n.charAt(0)]=i,i}getNextNode(t,r,n,o){let i=this.findStaticMatchingChild(t,r),s=0;if(i===void 0){if(this.parametricChildren.length===0)return this.wildcardChild;i=this.parametricChildren[0],s=1}this.wildcardChild!==void 0&&n.push({paramsCount:o,brotherPathIndex:r,brotherNode:this.wildcardChild});for(let a=this.parametricChildren.length-1;a>=s;a--)n.push({paramsCount:o,brotherPathIndex:r,brotherNode:this.parametricChildren[a]});return i}},Nne=class extends KW{regex;staticSuffix;_tag="ParametricNode";constructor(t,r,n){super(),this.regex=t,this.staticSuffix=r,this.isRegex=!!t,this.nodePaths=new Set([n])}isRegex;nodePaths;getNextNode(t,r){return this.findStaticMatchingChild(t,r)}},Pne=class extends JW{_tag="WildcardNode";getNextNode(t,r,n,o){}},S1t=(e,t)=>{if(!e)throw new Error(t)};R1t=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"]});var XHe,Mne=h(()=>{ZHe();XHe=JHe});var tWe=h(()=>{});var T1t,Ty,Fne,rWe,Td,D1t,nWe,wQ=h(()=>{X0();YD();uW();T1t=Symbol.for("@effect/platform/HttpApiSchema/AnnotationStatus"),Ty=e=>{let t=cW(e,"status");return e.status!==void 0&&(t[T1t]=e.status),t},Fne=e=>{function t(n){if(V0(n))for(let o of n.types)t(o);else r.push(n)}let r=[];return t(e),r},rWe=(e,t)=>os.make(Array.from(new Set([...Fne(e),...Fne(t)]))),Td=(e,t)=>fo(rWe(e.ast,t.ast)),D1t=e=>fW.annotations(Ty({status:e})),nWe=D1t(204)});var oWe=h(()=>{});var iWe,O1t,lS,sWe=h(()=>{sr();Me();E_();wQ();iWe=Symbol.for("@effect/platform/HttpApi"),O1t={[iWe]:iWe,pipe(){return Z(this,arguments)},add(e){return lS({identifier:this.identifier,groups:l6(this.groups,e.identifier,e),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},addHttpApi(e){let t={...this.groups};for(let r in e.groups){let n=e.groups[r].annotateContext(ro());n.annotations=wo(e.annotations,n.annotations),n.middlewares=new Set([...e.middlewares,...n.middlewares]),t[r]=n}return lS({identifier:this.identifier,groups:t,errorSchema:Td(this.errorSchema,e.errorSchema),annotations:this.annotations,middlewares:this.middlewares})},addError(e,t){return lS({identifier:this.identifier,groups:this.groups,errorSchema:Td(this.errorSchema,t?.status?e.annotations(Ty({status:t.status})):e),annotations:this.annotations,middlewares:this.middlewares})},prefix(e){return lS({identifier:this.identifier,groups:Sm(this.groups,t=>t.prefix(e)),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return lS({identifier:this.identifier,groups:this.groups,errorSchema:Td(this.errorSchema,e.failure),annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return lS({identifier:this.identifier,groups:this.groups,errorSchema:this.errorSchema,annotations:zt(this.annotations,e,t),middlewares:this.middlewares})},annotateContext(e){return lS({identifier:this.identifier,groups:this.groups,errorSchema:this.errorSchema,annotations:wo(this.annotations,e),middlewares:this.middlewares})}},lS=e=>{function t(){}return Object.setPrototypeOf(t,O1t),t.groups=e.groups,t.errorSchema=e.errorSchema,t.annotations=e.annotations,t.middlewares=e.middlewares,t}});var aWe=h(()=>{});var cWe,uWe,lWe=h(()=>{nr();g0();yn();cWe=Te(Symbol.for("@effect/platform/HttpMiddleware/loggerDisabled"),()=>h0(!1)),uWe=e=>Wt(uNe(cWe,!0),e)});var dWe=h(()=>{});var fWe,Lne=h(()=>{lWe();fWe=uWe});var mWe=h(()=>{});var hWe=h(()=>{});function AWe(e,t){let r=t.length;return e.modify({url:e.url.length<=r?"/":e.url.slice(r)})}var XW,ej,tj,Une,yWe,gWe,xWe,$ne,rj,$1t,EWe,bWe=h(()=>{vr();sr();nr();id();g0();oe();yn();ht();it();MB();Mne();FW();Tne();PW();XW=Symbol.for("@effect/platform/HttpRouter"),ej=Symbol.for("@effect/platform/HttpRouter/Route"),tj=Symbol.for("@effect/platform/HttpRouter/RouteContext"),Une=Jt("@effect/platform/HttpRouter/RouteContext"),yWe=Te("@effect/platform/HttpRouter/currentRouterConfig",()=>h0({})),gWe=class extends dI{routes;mounts;[XW];constructor(t,r){super(),this.routes=t,this.mounts=r,this[XW]=XW,this.httpApp=xWe(this).pipe(Ee(n=>this.httpApp=n))}httpApp;commit(){return this.httpApp}toJSON(){return{_id:"Router",routes:this.routes.toJSON(),mounts:this.mounts.toJSON()}}toString(){return Fe(this)}[Ce](){return this.toJSON()}},xWe=e=>De(cNe(yWe),t=>{let r=XHe(t),n=Uo(e.mounts).map(([i,s,a])=>[i,new rj(new $ne("*",a?.includePrefix?`${i}/*`:"/*",s,a?.includePrefix?W():H(i),!1),{}),a]),o=n.length;return C_(e.routes,i=>{i.method==="*"?r.all(i.path,i):r.on(i.method,i.path,i)}),$a(i=>{let s=iA(new Map(i.getFiberRef(Bb).unsafeMap)),a=_a(s,YW);if(o>0){let f=a.url.indexOf("?"),p=f===-1?a.url:a.url.slice(0,f);for(let m=0;m<o;m++){let[g,A,E]=n[m];if(p===g||p.startsWith(g+"/"))return s.unsafeMap.set(Une.key,A),E?.includePrefix!==!0&&s.unsafeMap.set(YW.key,AWe(a,g)),p0(Ee(A.route.handler,lne),Bb,s)}}let c=r.find(a.method,a.url);if(c===void 0&&a.method==="HEAD"&&(c=r.find("GET",a.url)),c===void 0)return $e(new MW({request:a}));let u=c.handler;u.prefix._tag==="Some"&&s.unsafeMap.set(YW.key,AWe(a,u.prefix.value)),s.unsafeMap.set($He.key,c.searchParams),s.unsafeMap.set(Une.key,new rj(u,c.params));let l=Ji(s,M1);l._tag==="Some"&&l.value._tag==="Span"&&l.value.attribute("http.route",u.path);let d=Ee(u.handler,lne);return p0(u.uninterruptible?d:Bo(d),Bb,s)})});$ne=class extends Wg{method;path;handler;prefix;uninterruptible;[ej];constructor(t,r,n,o=W(),i=!1){super(),this.method=t,this.path=r,this.handler=n,this.prefix=o,this.uninterruptible=i,this[ej]=ej}toJSON(){return{_id:"@effect/platform/HttpRouter/Route",method:this.method,path:this.path,prefix:this.prefix.toJSON()}}},rj=class{route;params;[tj];constructor(t,r){this.route=t,this.params=r,this[tj]=tj}},$1t=e=>e.endsWith("/")?e.slice(0,-1):e,EWe=x(2,(e,t)=>(t=$1t(t),e==="/"?t:t+e))});var SWe,Hne=h(()=>{bWe();SWe=EWe});var wWe=h(()=>{});var IWe=h(()=>{});var kWe=h(()=>{});var G1t,z1t,vWe,RWe=h(()=>{vr();oe();Me();G1t=Symbol.for("@effect/platform/HttpApiBuilder/Handlers"),z1t={[G1t]:{_Endpoints:be},pipe(){return Z(this,arguments)},handle(e,t,r){let n=this.group.endpoints[e];return vWe({group:this.group,handlers:$s(this.handlers,{endpoint:n,handler:t,withFullRequest:!1,uninterruptible:r?.uninterruptible??!1})})},handleRaw(e,t,r){let n=this.group.endpoints[e];return vWe({group:this.group,handlers:$s(this.handlers,{endpoint:n,handler:t,withFullRequest:!0,uninterruptible:r?.uninterruptible??!1})})}},vWe=e=>{let t=Object.create(z1t);return t.group=e.group,t.handlers=e.handlers,t}});var Y1t,J1t,K1t,_We,Z1t,Wne,jne,BWe,X1t,rrn,TWe=h(()=>{wr();sr();nr();zu();ah();Lne();Mne();Y1t=Jt("@effect/platform/HttpLayerRouter"),J1t=Symbol.for("@effect/platform/HttpLayerRouter/Middleware"),K1t=function(){return arguments.length===0?_We:_We(arguments[0],arguments[1])},_We=(e,t)=>t?.global?Rc(Go(function*(){let r=yield*Y1t,n=ws(e)?yield*e:e;yield*r.addGlobalMiddleware(n)})):new jne(ws(e)?e2(De(e,r=>iA(new Map([[Wne,r]])))):iD(iA(new Map([[Wne,e]])))),Z1t=0,Wne="@effect/platform/HttpLayerRouter/MiddlewareFn",jne=class e{layerFn;dependencies;[J1t]={};constructor(t,r){this.layerFn=t,this.dependencies=r;let n=`@effect/platform/HttpLayerRouter/Middleware-${++Z1t}`;this.layer=e2(Go(this,function*(){let o=yield*ty(),i=[o.unsafeMap.get(Wne)];if(this.dependencies){let s=yield*iX,a=Dr(o,FI),c=yield*cX(this.dependencies,s,a);i.push(...X1t(c))}return iA(new Map([[n,i]]))})).pipe(sy(this.layerFn))}layer;combine(t){return new e(this.layerFn,this.dependencies?sD(this.dependencies,t.layer):t.layer)}},BWe=new WeakMap,X1t=e=>{let t=BWe.get(e);if(t)return t;let r=Us(),n=0;for(let[o,i]of e.unsafeMap)o.startsWith("@effect/platform/HttpLayerRouter/Middleware-")&&(r.push(i),i.length>n&&(n=i.length));if(r.length===0)t=[];else{let o=new Set;for(let i=n-1;i>=0;i--)for(let s of r)i<s.length&&o.add(s[i]);t=_e(o).reverse()}return BWe.set(e,t),t},rrn=K1t(fWe).layer});var IQ,DWe,qne=h(()=>{sr();nr();IQ=class extends Hw("@effect/platform/Transferable/Collector")(){},DWe=()=>{let e=[],t=o=>{e.push(...o)},r=()=>e,n=()=>{let o=e;return e=[],o};return IQ.of({unsafeAddAll:t,addAll:o=>ot(()=>t(o)),unsafeRead:r,read:ot(r),unsafeClear:n,clear:ot(n)})}});var OWe=h(()=>{});var NWe,PWe=h(()=>{NWe=Symbol.for("@effect/platform/WorkerError")});var MWe,cp,nj=h(()=>{X0();PWe();MWe=NWe,cp=class extends sS()("WorkerError",{reason:is("spawn","decode","send","unknown","encode"),cause:ip}){[MWe]=MWe;static Cause=r2e({error:this,defect:ip});static encodeCause=Rre(this.Cause);static decodeCause=kre(this.Cause);get message(){switch(this.reason){case"send":return"An error occurred calling .postMessage";case"spawn":return"An error occurred while spawning a worker";case"decode":return"An error occurred during decoding";case"encode":return"An error occurred during encoding";case"unknown":return"An unexpected error occurred"}}}});var Gne,oj,zne,Vne,FWe,LWe,UWe,$We,HWe=h(()=>{aS();sr();$u();nr();Ro();g0();_ne();zu();EQ();it();Y2();lX();ah();wd();MB();qne();nj();Gne=Symbol.for("@effect/platform/Worker/PlatformWorker"),oj=Jt("@effect/platform/Worker/PlatformWorker"),zne=Symbol.for("@effect/platform/Worker/WorkerManager"),Vne=Jt("@effect/platform/Worker/WorkerManager"),FWe=Jt("@effect/platform/Worker/Spawner"),LWe=Go(function*(){let e=yield*oj,t=0;return Vne.of({[zne]:zne,spawn({encode:r,initialMessage:n}){return Go(function*(){let o=t++,i=0,s=new Map,a=DWe(),c=r?A=>Wt(a.clear,d0(r(A),IQ,a)):nt,u=yield*rn(),l=yield*e.spawn(o);yield*l.run(A=>A[0]===0?jT(u,ve):d(A[1])).pipe(JT(A=>hi(s.values(),E=>fh in E?pd(E,A):E.failCause(A))),_b(rX),J5(uX(1e3)),V$({package:"@effect/platform",module:"Worker"}),Bo,l0),yield*YT(()=>Wt(hi(s.values(),A=>fh in A?r0(A):A.end,{discard:!0}),ot(()=>s.clear())));let d=A=>Pt(()=>{let E=s.get(A[0]);if(!E)return ve;switch(A[1]){case 0:return fh in E?pi(E,A[2][0]):E.offerAll(A[2]);case 1:return A.length===2?fh in E?r0(E):E.end:fh in E?pi(E,A[2][0]):Wt(E.offerAll(A[2]),E.end);case 2:case 3:{if(A[1]===2)return fh in E?D$(E,A[2]):E.fail(A[2]);let y=cp.decodeCause(A[2]);return fh in E?pd(E,y):E.failCause(y)}}}),f=(A,E)=>$a(y=>{let b=y.getFiberRef(Bb),w=Ji(b,M1).pipe(hF(v=>v._tag==="Span")),I=i++;return E.pipe(Ri(v=>(s.set(I,v),c(A).pipe(Ri(k=>l.send([I,0,k,w._tag==="Some"?[w.value.traceId,w.value.spanId,w.value.sampled]:void 0],a.unsafeRead())),Hu(k=>rHe(v)?v.failCause(k):pd(v,k))))),De(v=>({id:I,mailbox:v})))}),p=({id:A},E)=>{let y=ot(()=>s.delete(A));return sd(E)?Wt(Yf(l.send([A,1])),y):y},m=A=>dy(_W(f(A,ok()),({mailbox:E})=>nHe(E),p)),g=A=>c0(f(A,rn()),({mailbox:E})=>Ht(E),p);return yield*Ht(u),n&&(yield*ot(n).pipe(Ee(g),Ha(A=>new cp({reason:"spawn",cause:A})))),{id:o,execute:m,executeEffect:g}})}})}),UWe=iy(Vne,LWe),$We=()=>e=>oj.of({[Gne]:Gne,spawn(t){return Go(function*(){let r=yield*FWe,n,o=[];return{run:a=>vb(c=>Go(function*(){let u=yield*u0,l=yield*e.setup({worker:r(t),scope:u});n=l,yield*sh(u,ot(()=>{n=void 0}));let d=(yield*hh()).pipe(NPe(Z6(FI))),f=yield*_He(),p=f7(d);if(yield*e.listen({port:l,scope:u,emit(m){DHe(f,p(a(m)))},deferred:f.deferred}),o.length>0){for(let[m,g]of o)l.postMessage([0,m],g);o.length=0}return yield*c(QHe(f))}).pipe(Ad)),send:(a,c)=>Wu({try:()=>{n===void 0?o.push([a,c]):n.postMessage([0,a],c)},catch:u=>new cp({reason:"send",cause:u})})}})}})});var WWe,jWe,qWe,Yne=h(()=>{HWe();WWe=$We,jWe=oj,qWe=UWe});var zWe=h(()=>{});function ij(e){try{if(!hn.trusted&&!Dy){let r=gr.sharedLength||0;r<gr.length&&(gr.length=r)}let t;if(hn.randomAccessStructure&&Se[U]<64&&Se[U]>=32&&Zne?(t=Zne(Se,U,Nc,hn),Se=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),U=Nc):t=Do(),gi&&(U=gi.postBundlePosition,gi=null),Dy&&(gr.restoreStructures=null),U==Nc)gr&&gr.restoreStructures&&JWe(),gr=null,Se=null,Ph&&(Ph=null);else{if(U>Nc)throw new Error("Unexpected end of MessagePack data");if(!Dy){let r;try{r=JSON.stringify(t,(n,o)=>typeof o=="bigint"?`${o}n`:o).slice(0,100)}catch(n){r="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+r)}}return t}catch(t){throw gr&&gr.restoreStructures&&JWe(),aj(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||U>Nc)&&(t.incomplete=!0),t}}function JWe(){for(let e in gr.restoreStructures)gr[e]=gr.restoreStructures[e];gr.restoreStructures=null}function Do(){let e=Se[U++];if(e<160)if(e<128){if(e<64)return e;{let t=gr[e&63]||hn.getStructures&&oje()[e&63];return t?(t.read||(t.read=noe(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,hn.mapsAsObjects){let t={};for(let r=0;r<e;r++){let n=fje();n==="__proto__"&&(n="__proto_"),t[n]=Do()}return t}else{let t=new Map;for(let r=0;r<e;r++)t.set(Do(),Do());return t}else{e-=144;let t=new Array(e);for(let r=0;r<e;r++)t[r]=Do();return hn.freezeData?Object.freeze(t):t}else if(e<192){let t=e-160;if(al>=U)return Nh.slice(U-Oc,(U+=t)-Oc);if(al==0&&Nc<140){let r=t<16?ooe(t):dje(t);if(r!=null)return r}return sj(t)}else{let t;switch(e){case 192:return null;case 193:return gi?(t=Do(),t>0?gi[1].slice(gi.position1,gi.position1+=t):gi[0].slice(gi.position0,gi.position0-=t)):roe;case 194:return!1;case 195:return!0;case 196:if(t=Se[U++],t===void 0)throw new Error("Unexpected end of buffer");return Jne(t);case 197:return t=ur.getUint16(U),U+=2,Jne(t);case 198:return t=ur.getUint32(U),U+=4,Jne(t);case 199:return dS(Se[U++]);case 200:return t=ur.getUint16(U),U+=2,dS(t);case 201:return t=ur.getUint32(U),U+=4,dS(t);case 202:if(t=ur.getFloat32(U),hn.useFloat32>2){let r=mS[(Se[U]&127)<<1|Se[U+1]>>7];return U+=4,(r*t+(t>0?.5:-.5)>>0)/r}return U+=4,t;case 203:return t=ur.getFloat64(U),U+=8,t;case 204:return Se[U++];case 205:return t=ur.getUint16(U),U+=2,t;case 206:return t=ur.getUint32(U),U+=4,t;case 207:return hn.int64AsType==="number"?(t=ur.getUint32(U)*4294967296,t+=ur.getUint32(U+4)):hn.int64AsType==="string"?t=ur.getBigUint64(U).toString():hn.int64AsType==="auto"?(t=ur.getBigUint64(U),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ur.getBigUint64(U),U+=8,t;case 208:return ur.getInt8(U++);case 209:return t=ur.getInt16(U),U+=2,t;case 210:return t=ur.getInt32(U),U+=4,t;case 211:return hn.int64AsType==="number"?(t=ur.getInt32(U)*4294967296,t+=ur.getUint32(U+4)):hn.int64AsType==="string"?t=ur.getBigInt64(U).toString():hn.int64AsType==="auto"?(t=ur.getBigInt64(U),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ur.getBigInt64(U),U+=8,t;case 212:if(t=Se[U++],t==114)return rje(Se[U++]&63);{let r=qa[t];if(r)return r.read?(U++,r.read(Do())):r.noBuffer?(U++,r()):r(Se.subarray(U,++U));throw new Error("Unknown extension "+t)}case 213:return t=Se[U],t==114?(U++,rje(Se[U++]&63,Se[U++])):dS(2);case 214:return dS(4);case 215:return dS(8);case 216:return dS(16);case 217:return t=Se[U++],al>=U?Nh.slice(U-Oc,(U+=t)-Oc):ije(t);case 218:return t=ur.getUint16(U),U+=2,al>=U?Nh.slice(U-Oc,(U+=t)-Oc):sje(t);case 219:return t=ur.getUint32(U),U+=4,al>=U?Nh.slice(U-Oc,(U+=t)-Oc):aje(t);case 220:return t=ur.getUint16(U),U+=2,ZWe(t);case 221:return t=ur.getUint32(U),U+=4,ZWe(t);case 222:return t=ur.getUint16(U),U+=2,XWe(t);case 223:return t=ur.getUint32(U),U+=4,XWe(t);default:if(e>=224)return e-256;if(e===void 0){let r=new Error("Unexpected end of MessagePack data");throw r.incomplete=!0,r}throw new Error("Unknown MessagePack token "+e)}}}function noe(e,t){function r(){if(r.count++>YWe){let o;try{o=e.read=new Function("r","return function(){return "+(hn.freezeData?"Object.freeze":"")+"({"+e.map(i=>i==="__proto__"?"__proto_:r()":sUt.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"})}")(Do)}catch{return YWe=1/0,r()}return e.read0=o,e.highByte===0&&(e.read=KWe(t,e.read)),o()}let n={};for(let o=0,i=e.length;o<i;o++){let s=e[o];s==="__proto__"&&(s="__proto_"),n[s]=Do()}return hn.freezeData?Object.freeze(n):n}return r.count=0,e.read0=r,e.highByte===0?KWe(t,r):r}function oje(){let e=mje(()=>(Se=null,hn.getStructures()));return gr=hn._mergeStructures(e,gr)}function uje(e){cje=!0,sj=t(1),ije=t(2),sje=t(3),aje=t(5);function t(r){return function(o){let i=fS[kQ++];if(i==null){if(gi)return pS(o);let a=Se.byteOffset,c=e(U-r+a,Nc+a,Se.buffer);if(typeof c=="string")i=c,fS=toe;else if(fS=c,kQ=1,al=1,i=fS[0],i===void 0)throw new Error("Unexpected end of buffer")}let s=i.length;return s<=o?(U+=o,i):(Nh=i,Oc=U,al=U+s,U+=o,i.slice(0,o))}}}function pS(e){let t;if(e<16&&(t=ooe(e)))return t;if(e>64&&Kne)return Kne.decode(Se.subarray(U,U+=e));let r=U+e,n=[];for(t="";U<r;){let o=Se[U++];if(!(o&128))n.push(o);else if((o&224)===192){let i=Se[U++]&63,s=(o&31)<<6|i;s<128?n.push(65533):n.push(s)}else if((o&240)===224){let i=Se[U++]&63,s=Se[U++]&63,a=(o&31)<<12|i<<6|s;a<2048||a>=55296&&a<=57343?n.push(65533):n.push(a)}else if((o&248)===240){let i=Se[U++]&63,s=Se[U++]&63,a=Se[U++]&63,c=(o&7)<<18|i<<12|s<<6|a;c<65536||c>1114111?n.push(65533):(c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c))}else n.push(65533);n.length>=4096&&(t+=Qi.apply(String,n),n.length=0)}return n.length>0&&(t+=Qi.apply(String,n)),t}function lje(e,t,r){let n=Se;Se=e,U=t;try{return pS(r)}finally{Se=n}}function ZWe(e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=Do();return hn.freezeData?Object.freeze(t):t}function XWe(e){if(hn.mapsAsObjects){let t={};for(let r=0;r<e;r++){let n=fje();n==="__proto__"&&(n="__proto_"),t[n]=Do()}return t}else{let t=new Map;for(let r=0;r<e;r++)t.set(Do(),Do());return t}}function dje(e){let t=U,r=new Array(e);for(let n=0;n<e;n++){let o=Se[U++];if((o&128)>0){U=t;return}r[n]=o}return Qi.apply(String,r)}function ooe(e){if(e<4)if(e<2){if(e===0)return"";{let t=Se[U++];if((t&128)>1){U-=1;return}return Qi(t)}}else{let t=Se[U++],r=Se[U++];if((t&128)>0||(r&128)>0){U-=2;return}if(e<3)return Qi(t,r);let n=Se[U++];if((n&128)>0){U-=3;return}return Qi(t,r,n)}else{let t=Se[U++],r=Se[U++],n=Se[U++],o=Se[U++];if((t&128)>0||(r&128)>0||(n&128)>0||(o&128)>0){U-=4;return}if(e<6){if(e===4)return Qi(t,r,n,o);{let i=Se[U++];if((i&128)>0){U-=5;return}return Qi(t,r,n,o,i)}}else if(e<8){let i=Se[U++],s=Se[U++];if((i&128)>0||(s&128)>0){U-=6;return}if(e<7)return Qi(t,r,n,o,i,s);let a=Se[U++];if((a&128)>0){U-=7;return}return Qi(t,r,n,o,i,s,a)}else{let i=Se[U++],s=Se[U++],a=Se[U++],c=Se[U++];if((i&128)>0||(s&128)>0||(a&128)>0||(c&128)>0){U-=8;return}if(e<10){if(e===8)return Qi(t,r,n,o,i,s,a,c);{let u=Se[U++];if((u&128)>0){U-=9;return}return Qi(t,r,n,o,i,s,a,c,u)}}else if(e<12){let u=Se[U++],l=Se[U++];if((u&128)>0||(l&128)>0){U-=10;return}if(e<11)return Qi(t,r,n,o,i,s,a,c,u,l);let d=Se[U++];if((d&128)>0){U-=11;return}return Qi(t,r,n,o,i,s,a,c,u,l,d)}else{let u=Se[U++],l=Se[U++],d=Se[U++],f=Se[U++];if((u&128)>0||(l&128)>0||(d&128)>0||(f&128)>0){U-=12;return}if(e<14){if(e===12)return Qi(t,r,n,o,i,s,a,c,u,l,d,f);{let p=Se[U++];if((p&128)>0){U-=13;return}return Qi(t,r,n,o,i,s,a,c,u,l,d,f,p)}}else{let p=Se[U++],m=Se[U++];if((p&128)>0||(m&128)>0){U-=14;return}if(e<15)return Qi(t,r,n,o,i,s,a,c,u,l,d,f,p,m);let g=Se[U++];if((g&128)>0){U-=15;return}return Qi(t,r,n,o,i,s,a,c,u,l,d,f,p,m,g)}}}}}function eje(){let e=Se[U++],t;if(e<192)t=e-160;else switch(e){case 217:t=Se[U++];break;case 218:t=ur.getUint16(U),U+=2;break;case 219:t=ur.getUint32(U),U+=4;break;default:throw new Error("Expected string")}return pS(t)}function Jne(e){return hn.copyBuffers?Uint8Array.prototype.slice.call(Se,U,U+=e):Se.subarray(U,U+=e)}function dS(e){let t=Se[U++];if(qa[t]){let r;return qa[t](Se.subarray(U,r=U+=e),n=>{U=n;try{return Do()}finally{U=r}})}else throw new Error("Unknown extension type "+t)}function fje(){let e=Se[U++];if(e>=160&&e<192){if(e=e-160,al>=U)return Nh.slice(U-Oc,(U+=e)-Oc);if(!(al==0&&Nc<180))return sj(e)}else return U--,pje(Do());let t=(e<<5^(e>1?ur.getUint16(U):e>0?Se[U]:0))&4095,r=tje[t],n=U,o=U+e-3,i,s=0;if(r&&r.bytes==e){for(;n<o;){if(i=ur.getUint32(n),i!=r[s++]){n=1879048192;break}n+=4}for(o+=3;n<o;)if(i=Se[n++],i!=r[s++]){n=1879048192;break}if(n===o)return U=n,r.string;o-=3,n=U}for(r=[],tje[t]=r,r.bytes=e;n<o;)i=ur.getUint32(n),r.push(i),n+=4;for(o+=3;n<o;)i=Se[n++],r.push(i);let a=e<16?ooe(e):dje(e);return a!=null?r.string=a:r.string=sj(e)}function pje(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(e==null)return e+"";if(hn.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return e.flat().toString();throw new Error(`Invalid property type for record: ${typeof e}`)}function mje(e){eoe&&eoe();let t=Nc,r=U,n=kQ,o=Oc,i=al,s=Nh,a=fS,c=Ph,u=gi,l=new Uint8Array(Se.slice(0,Nc)),d=gr,f=gr.slice(0,gr.length),p=hn,m=Dy,g=e();return Nc=t,U=r,kQ=n,Oc=o,al=i,Nh=s,fS=a,Ph=c,gi=u,Se=l,Dy=m,gr=d,gr.splice(0,gr.length,...f),hn=p,ur=new DataView(Se.buffer,Se.byteOffset,Se.byteLength),g}function aj(){Se=null,Ph=null,gr=null}function gje(e,t,r){Zne=e,Xne=t,eoe=r}var Kne,Se,Nc,U,toe,fS,kQ,hn,gr,Nh,Oc,al,gi,Ph,qa,ur,VWe,vQ,roe,Dy,YWe,Zne,Xne,eoe,Mh,sUt,KWe,sj,ije,sje,aje,cje,Qi,tje,rje,nje,ioe,aUt,cUt,mS,cj,uUt,lUt,hje,uj,dUt,frn,Fh=h(()=>{try{Kne=new TextDecoder}catch{}U=0,toe=[],fS=toe,kQ=0,hn={},Oc=0,al=0,qa=[],VWe={useRecords:!1,mapsAsObjects:!0},vQ=class{},roe=new vQ;roe.name="MessagePack 0xC1";Dy=!1,YWe=2,Mh=class e{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=!1&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,r){if(Se)return mje(()=>(aj(),this?this.unpack(t,r):e.prototype.unpack.call(VWe,t,r)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof r=="object"?(Nc=r.end||t.length,U=r.start||0):(U=0,Nc=r>-1?r:t.length),kQ=0,al=0,Nh=null,fS=toe,gi=null,Se=t;try{ur=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw Se=null,t instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof e){if(hn=this,this.structures)return gr=this.structures,ij(r);(!gr||gr.length>0)&&(gr=[])}else hn=VWe,(!gr||gr.length>0)&&(gr=[]);return ij(r)}unpackMultiple(t,r){let n,o=0;try{Dy=!0;let i=t.length,s=this?this.unpack(t,i):cj.unpack(t,i);if(r){if(r(s,o,U)===!1)return;for(;U<i;)if(o=U,r(ij(),o,U)===!1)return}else{for(n=[s];U<i;)o=U,n.push(ij());return n}}catch(i){throw i.lastPosition=o,i.values=n,i}finally{Dy=!1,aj()}}_mergeStructures(t,r){Xne&&(t=Xne.call(this,t)),t=t||[],Object.isFrozen(t)&&(t=t.map(n=>n.slice(0)));for(let n=0,o=t.length;n<o;n++){let i=t[n];i&&(i.isShared=!0,n>=32&&(i.highByte=n-32>>5))}t.sharedLength=t.length;for(let n in r||[])if(n>=0){let o=t[n],i=r[n];i&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[n]=o),t[n]=i)}return this.structures=t}decode(t,r){return this.unpack(t,r)}};sUt=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;KWe=(e,t)=>function(){let r=Se[U++];if(r===0)return t();let n=e<32?-(e+(r<<5)):e+(r<<5),o=gr[n]||oje()[n];if(!o)throw new Error("Record id is not defined for "+n);return o.read||(o.read=noe(o,e)),o.read()};sj=pS,ije=pS,sje=pS,aje=pS,cje=!1;Qi=String.fromCharCode;tje=new Array(4096);rje=(e,t)=>{let r=Do().map(pje),n=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,r.highByte=t);let o=gr[e];return o&&(o.isShared||Dy)&&((gr.restoreStructures||(gr.restoreStructures=[]))[e]=o),gr[e]=r,r.read=noe(r,n),(r.read0||r.read)()};qa[0]=()=>{};qa[0].noBuffer=!0;qa[66]=e=>{let t=e.byteLength%8||8,r=BigInt(e[0]&128?e[0]-256:e[0]);for(let n=1;n<t;n++)r<<=BigInt(8),r+=BigInt(e[n]);if(e.byteLength!==t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),o=(i,s)=>{let a=s-i;if(a<=40){let d=n.getBigUint64(i);for(let f=i+8;f<s;f+=8)d<<=BigInt(64),d|=n.getBigUint64(f);return d}let c=i+(a>>4<<3),u=o(i,c),l=o(c,s);return u<<BigInt((s-c)*8)|l};r=r<<BigInt((n.byteLength-t)*8)|o(t,n.byteLength)}return r};nje={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};qa[101]=()=>{let e=Do();if(!nje[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return nje[e[0]](e[1],{cause:e[2]})};qa[105]=e=>{if(hn.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=ur.getUint32(U-4);Ph||(Ph=new Map);let r=Se[U],n;r>=144&&r<160||r==220||r==221?n=[]:r>=128&&r<144||r==222||r==223?n=new Map:(r>=199&&r<=201||r>=212&&r<=216)&&Se[U+1]===115?n=new Set:n={};let o={target:n};Ph.set(t,o);let i=Do();if(o.used)Object.assign(n,i);else return o.target=i;if(n instanceof Map)for(let[s,a]of i.entries())n.set(s,a);if(n instanceof Set)for(let s of Array.from(i))n.add(s);return n};qa[112]=e=>{if(hn.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=ur.getUint32(U-4),r=Ph.get(t);return r.used=!0,r.target};qa[115]=()=>new Set(Do());ioe=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array"),aUt=typeof globalThis=="object"?globalThis:window;qa[116]=e=>{let t=e[0],r=Uint8Array.prototype.slice.call(e,1).buffer,n=ioe[t];if(!n){if(t===16)return r;if(t===17)return new DataView(r);throw new Error("Could not find typed array for code "+t)}return new aUt[n](r)};qa[120]=()=>{let e=Do();return new RegExp(e[0],e[1])};cUt=[];qa[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],r=U;return U+=t-e.length,gi=cUt,gi=[eje(),eje()],gi.position0=0,gi.position1=0,gi.postBundlePosition=U,U=r,Do()};qa[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");mS=new Array(147);for(let e=0;e<256;e++)mS[e]=+("1e"+Math.floor(45.15-e*.30103));cj=new Mh({useRecords:!1}),uUt=cj.unpack,lUt=cj.unpackMultiple,hje=cj.unpack,uj={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},dUt=new Float32Array(1),frn=new Uint8Array(dUt.buffer,0,4)});function soe(e,t,r,n){let o=e.byteLength;if(o+1<256){var{target:i,position:s}=r(4+o);i[s++]=199,i[s++]=o+1}else if(o+1<65536){var{target:i,position:s}=r(5+o);i[s++]=200,i[s++]=o+1>>8,i[s++]=o+1&255}else{var{target:i,position:s,targetView:a}=r(7+o);i[s++]=201,a.setUint32(s,o+1),s+=4}i[s++]=116,i[s++]=t,e.buffer||(e=new Uint8Array(e)),i.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),s)}function aoe(e,t){let r=e.byteLength;var n,o;if(r<256){var{target:n,position:o}=t(r+2);n[o++]=196,n[o++]=r}else if(r<65536){var{target:n,position:o}=t(r+3);n[o++]=197,n[o++]=r>>8,n[o++]=r&255}else{var{target:n,position:o,targetView:i}=t(r+5);n[o++]=198,i.setUint32(o,r),o+=4}n.set(e,o)}function yje(e,t,r,n){let o=e.length;switch(o){case 1:t[r++]=212;break;case 2:t[r++]=213;break;case 4:t[r++]=214;break;case 8:t[r++]=215;break;case 16:t[r++]=216;break;default:o<256?(t[r++]=199,t[r++]=o):o<65536?(t[r++]=200,t[r++]=o>>8,t[r++]=o&255):(t[r++]=201,t[r++]=o>>24,t[r++]=o>>16&255,t[r++]=o>>8&255,t[r++]=o&255)}return t[r++]=n,t.set(e,r),r+=o,r}function mUt(e,t){let r,n=t.length*6,o=e.length-n;for(;r=t.pop();){let i=r.offset,s=r.id;e.copyWithin(i+n,i,o),n-=6;let a=i+n;e[a++]=214,e[a++]=105,e[a++]=s>>24,e[a++]=s>>16&255,e[a++]=s>>8&255,e[a++]=s&255,o=i}return e}function xje(e,t,r){if(Jn.length>0){gn.setUint32(Jn.position+e,G+r-Jn.position-e),Jn.stringsPosition=G-e;let n=Jn;Jn=null,t(n[0]),t(n[1])}}function Sje(e,t){return e.isCompatible=r=>{let n=!r||(t.lastNamedStructuresLength||0)===r.length;return n||t._mergeStructures(r),n},e}function Cje(e,t){bje=e,Sje=t}var dj,coe,uoe,ik,lj,Eje,Aje,K,RQ,gn,G,Bs,Jn,bje,fUt,pUt,Dd,hS,wje,hUt,Ije,gUt,AUt,yUt,xUt,kje,vje,Rje,_Q=h(()=>{Fh();Fh();Fh();try{dj=new TextEncoder}catch{}ik=typeof Buffer<"u",lj=ik?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,Eje=ik?Buffer:Uint8Array,Aje=ik?4294967296:2144337920,G=0,Jn=null,fUt=21760,pUt=/[\u0080-\uFFFF]/,Dd=Symbol("record-id"),hS=class extends Mh{constructor(t){super(t),this.offset=0;let r,n,o,i,s,a=Eje.prototype.utf8Write?function(_,P){return K.utf8Write(_,P,K.byteLength-P)}:dj&&dj.encodeInto?function(_,P){return dj.encodeInto(_,K.subarray(P)).written}:!1,c=this;t||(t={});let u=t&&t.sequential,l=t.structures||t.saveStructures,d=t.maxSharedStructures;if(d==null&&(d=l?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");t.structuredClone&&t.moreTypes==null&&(this.moreTypes=!0);let f=t.maxOwnStructures;f==null&&(f=l?32:64),!this.structures&&t.useRecords!=!1&&(this.structures=[]);let p=d>32||f+d>64,m=d+64,g=d+f+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let A=[],E=0,y=0;this.pack=this.encode=function(_,P){if(K||(K=new lj(8192),gn=K.dataView||(K.dataView=new DataView(K.buffer,0,8192)),G=0),Bs=K.length-10,Bs-G<2048?(K=new lj(K.length),gn=K.dataView||(K.dataView=new DataView(K.buffer,0,K.length)),Bs=K.length-10,G=0):G=G+7&2147483640,n=G,P&Rje&&(G+=P&255),s=c.structuredClone?new Map:null,c.bundleStrings&&typeof _!="string"?(Jn=[],Jn.size=1/0):Jn=null,i=c.structures,i){i.uninitialized&&(i=c._mergeStructures(c.getStructures()));let N=i.sharedLength||0;if(N>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let q=0;q<N;q++){let re=i[q];if(!re)continue;let ie,ue=i.transitions;for(let Oe=0,Ye=re.length;Oe<Ye;Oe++){let T=re[Oe];ie=ue[T],ie||(ie=ue[T]=Object.create(null)),ue=ie}ue[Dd]=q+64}this.lastNamedStructuresLength=N}u||(i.nextId=N+64)}o&&(o=!1);let $;try{c.randomAccessStructure&&!c.readOnlyStructures&&_&&typeof _=="object"?_.constructor===Object?F(_):_.constructor!==Map&&!Array.isArray(_)&&!uoe.some(q=>_ instanceof q)?F(_.toJSON?_.toJSON():_):I(_):I(_);let N=Jn;if(Jn&&xje(n,I,0),s&&s.idsToInsert){let q=s.idsToInsert.sort((Oe,Ye)=>Oe.offset>Ye.offset?1:-1),re=q.length,ie=-1;for(;N&&re>0;){let Oe=q[--re].offset+n;Oe<N.stringsPosition+n&&ie===-1&&(ie=0),Oe>N.position+n?ie>=0&&(ie+=6):(ie>=0&&(gn.setUint32(N.position+n,gn.getUint32(N.position+n)+ie),ie=-1),N=N.previous,re++)}ie>=0&&N&&gn.setUint32(N.position+n,gn.getUint32(N.position+n)+ie),G+=q.length*6,G>Bs&&L(G),c.offset=G;let ue=mUt(K.subarray(n,G),q);return s=null,ue}return c.offset=G,P&kje?(K.start=n,K.end=G,K):K.subarray(n,G)}catch(N){throw $=N,N}finally{if(i&&(b(),o&&c.saveStructures)){let N=i.sharedLength||0,q=K.subarray(n,G),re=Sje(i,c);if(!$)return c.saveStructures(re,re.isCompatible)===!1?(i.uninitialized=!0,c.pack(_,P)):(c.lastNamedStructuresLength=N,K.length>1073741824&&(K=null),q)}K.length>1073741824&&(K=null),P&vje&&(G=n)}};let b=()=>{y<10&&y++;let _=i.sharedLength||0;if(i.length>_&&!u&&(i.length=_),E>1e4)i.transitions=null,y=0,E=0,A.length>0&&(A=[]);else if(A.length>0&&!u){for(let P=0,$=A.length;P<$;P++)A[P][Dd]=0;A=[]}},w=_=>{var P=_.length;P<16?K[G++]=144|P:P<65536?(K[G++]=220,K[G++]=P>>8,K[G++]=P&255):(K[G++]=221,gn.setUint32(G,P),G+=4);for(let $=0;$<P;$++)I(_[$])},I=_=>{G>Bs&&(K=L(G));var P=typeof _,$;if(P==="string"){let N=_.length;if(Jn&&N>=4&&N<4096){if((Jn.size+=N)>fUt){let ue,Oe=(Jn[0]?Jn[0].length*3+Jn[1].length:0)+10;G+Oe>Bs&&(K=L(G+Oe));let Ye;Jn.position?(Ye=Jn,K[G]=200,G+=3,K[G++]=98,ue=G-n,G+=4,xje(n,I,0),gn.setUint16(ue+n-3,G-n-ue)):(K[G++]=214,K[G++]=98,ue=G-n,G+=4),Jn=["",""],Jn.previous=Ye,Jn.size=0,Jn.position=ue}let ie=pUt.test(_);Jn[ie?0:1]+=_,K[G++]=193,I(ie?-N:N);return}let q;N<32?q=1:N<256?q=2:N<65536?q=3:q=5;let re=N*3;if(G+re>Bs&&(K=L(G+re)),N<64||!a){let ie,ue,Oe,Ye=G+q;for(ie=0;ie<N;ie++)ue=_.charCodeAt(ie),ue<128?K[Ye++]=ue:ue<2048?(K[Ye++]=ue>>6|192,K[Ye++]=ue&63|128):(ue&64512)===55296&&((Oe=_.charCodeAt(ie+1))&64512)===56320?(ue=65536+((ue&1023)<<10)+(Oe&1023),ie++,K[Ye++]=ue>>18|240,K[Ye++]=ue>>12&63|128,K[Ye++]=ue>>6&63|128,K[Ye++]=ue&63|128):(K[Ye++]=ue>>12|224,K[Ye++]=ue>>6&63|128,K[Ye++]=ue&63|128);$=Ye-G-q}else $=a(_,G+q);$<32?K[G++]=160|$:$<256?(q<2&&K.copyWithin(G+2,G+1,G+1+$),K[G++]=217,K[G++]=$):$<65536?(q<3&&K.copyWithin(G+3,G+2,G+2+$),K[G++]=218,K[G++]=$>>8,K[G++]=$&255):(q<5&&K.copyWithin(G+5,G+3,G+3+$),K[G++]=219,gn.setUint32(G,$),G+=4),G+=$}else if(P==="number")if(_>>>0===_)_<32||_<128&&this.useRecords===!1||_<64&&!this.randomAccessStructure?K[G++]=_:_<256?(K[G++]=204,K[G++]=_):_<65536?(K[G++]=205,K[G++]=_>>8,K[G++]=_&255):(K[G++]=206,gn.setUint32(G,_),G+=4);else if(_>>0===_)_>=-32?K[G++]=256+_:_>=-128?(K[G++]=208,K[G++]=_+256):_>=-32768?(K[G++]=209,gn.setInt16(G,_),G+=2):(K[G++]=210,gn.setInt32(G,_),G+=4);else{let N;if((N=this.useFloat32)>0&&_<4294967296&&_>=-2147483648){K[G++]=202,gn.setFloat32(G,_);let q;if(N<4||(q=_*mS[(K[G]&127)<<1|K[G+1]>>7])>>0===q){G+=4;return}else G--}K[G++]=203,gn.setFloat64(G,_),G+=8}else if(P==="object"||P==="function")if(!_)K[G++]=192;else{if(s){let q=s.get(_);if(q){if(!q.id){let re=s.idsToInsert||(s.idsToInsert=[]);q.id=re.push(q)}K[G++]=214,K[G++]=112,gn.setUint32(G,q.id),G+=4;return}else s.set(_,{offset:G-n})}let N=_.constructor;if(N===Object)B(_);else if(N===Array)w(_);else if(N===Map)if(this.mapAsEmptyObject)K[G++]=128;else{$=_.size,$<16?K[G++]=128|$:$<65536?(K[G++]=222,K[G++]=$>>8,K[G++]=$&255):(K[G++]=223,gn.setUint32(G,$),G+=4);for(let[q,re]of _)I(q),I(re)}else{for(let q=0,re=coe.length;q<re;q++){let ie=uoe[q];if(_ instanceof ie){let ue=coe[q];if(ue.write){ue.type&&(K[G++]=212,K[G++]=ue.type,K[G++]=0);let Ne=ue.write.call(this,_);Ne===_?Array.isArray(_)?w(_):B(_):I(Ne);return}let Oe=K,Ye=gn,T=G;K=null;let J;try{J=ue.pack.call(this,_,Ne=>(K=Oe,Oe=null,G+=Ne,G>Bs&&L(G),{target:K,targetView:gn,position:G-Ne}),I)}finally{Oe&&(K=Oe,gn=Ye,G=T,Bs=K.length-10)}J&&(J.length+G>Bs&&L(J.length+G),G=yje(J,K,G,ue.type));return}}if(Array.isArray(_))w(_);else{if(_.toJSON){let q=_.toJSON();if(q!==_)return I(q)}if(P==="function")return I(this.writeFunction&&this.writeFunction(_));B(_)}}}else if(P==="boolean")K[G++]=_?195:194;else if(P==="bigint"){if(_<9223372036854776e3&&_>=-9223372036854776e3)K[G++]=211,gn.setBigInt64(G,_);else if(_<18446744073709552e3&&_>0)K[G++]=207,gn.setBigUint64(G,_);else if(this.largeBigIntToFloat)K[G++]=203,gn.setFloat64(G,Number(_));else{if(this.largeBigIntToString)return I(_.toString());if(this.useBigIntExtension||this.moreTypes){let N=_<0?BigInt(-1):BigInt(0),q;if(_>>BigInt(65536)===N){let re=BigInt(18446744073709552e3)-BigInt(1),ie=[];for(;ie.push(_&re),_>>BigInt(63)!==N;)_>>=BigInt(64);q=new Uint8Array(new BigUint64Array(ie).buffer),q.reverse()}else{let re=_<0,ie=(re?~_:_).toString(16);if(ie.length%2?ie="0"+ie:parseInt(ie.charAt(0),16)>=8&&(ie="00"+ie),ik)q=Buffer.from(ie,"hex");else{q=new Uint8Array(ie.length/2);for(let ue=0;ue<q.length;ue++)q[ue]=parseInt(ie.slice(ue*2,ue*2+2),16)}if(re)for(let ue=0;ue<q.length;ue++)q[ue]=~q[ue]}q.length+G>Bs&&L(q.length+G),G=yje(q,K,G,66);return}else throw new RangeError(_+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}G+=8}else if(P==="undefined")this.encodeUndefinedAsNil?K[G++]=192:(K[G++]=212,K[G++]=0,K[G++]=0);else throw new Error("Unknown type: "+P)},v=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?_=>{let P;if(this.skipValues){P=[];for(let q in _)(typeof _.hasOwnProperty!="function"||_.hasOwnProperty(q))&&!this.skipValues.includes(_[q])&&P.push(q)}else P=Object.keys(_);let $=P.length;$<16?K[G++]=128|$:$<65536?(K[G++]=222,K[G++]=$>>8,K[G++]=$&255):(K[G++]=223,gn.setUint32(G,$),G+=4);let N;if(this.coercibleKeyAsNumber)for(let q=0;q<$;q++){N=P[q];let re=Number(N);I(isNaN(re)?N:re),I(_[N])}else for(let q=0;q<$;q++)I(N=P[q]),I(_[N])}:_=>{K[G++]=222;let P=G-n;G+=2;let $=0;for(let N in _)(typeof _.hasOwnProperty!="function"||_.hasOwnProperty(N))&&(I(N),I(_[N]),$++);if($>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');K[P+++n]=$>>8,K[P+n]=$&255},k=this.useRecords===!1?v:t.progressiveRecords&&!p?_=>{let P,$=i.transitions||(i.transitions=Object.create(null)),N=G++-n,q;for(let re in _)if(typeof _.hasOwnProperty!="function"||_.hasOwnProperty(re)){if(P=$[re],P)$=P;else{let ie=Object.keys(_),ue=$;$=i.transitions;let Oe=0;for(let Ye=0,T=ie.length;Ye<T;Ye++){let J=ie[Ye];P=$[J],P||(P=$[J]=Object.create(null),Oe++),$=P}N+n+1==G?(G--,D($,ie,Oe)):ee($,ie,N,Oe),q=!0,$=ue[re]}I(_[re])}if(!q){let re=$[Dd];re?K[N+n]=re:ee($,Object.keys(_),N,0)}}:_=>{let P,$=i.transitions||(i.transitions=Object.create(null)),N=0;for(let re in _)(typeof _.hasOwnProperty!="function"||_.hasOwnProperty(re))&&(P=$[re],P||(P=$[re]=Object.create(null),N++),$=P);let q=$[Dd];q?q>=96&&p?(K[G++]=((q-=96)&31)+96,K[G++]=q>>5):K[G++]=q:D($,$.__keys__||Object.keys(_),N);for(let re in _)(typeof _.hasOwnProperty!="function"||_.hasOwnProperty(re))&&I(_[re])},R=typeof this.useRecords=="function"&&this.useRecords,B=R?_=>{R(_)?k(_):v(_)}:k,L=_=>{let P;if(_>16777216){if(_-n>Aje)throw new Error("Packed buffer would be larger than maximum buffer size");P=Math.min(Aje,Math.round(Math.max((_-n)*(_>67108864?1.25:2),4194304)/4096)*4096)}else P=(Math.max(_-n<<2,K.length-1)>>12)+1<<12;let $=new lj(P);return gn=$.dataView||($.dataView=new DataView($.buffer,0,P)),_=Math.min(_,K.length),K.copy?K.copy($,0,n,_):$.set(K.slice(n,_)),G-=n,n=0,Bs=$.length-10,K=$},D=(_,P,$)=>{let N=i.nextId;N||(N=64),N<m&&this.shouldShareStructure&&!this.shouldShareStructure(P)?(N=i.nextOwnId,N<g||(N=m),i.nextOwnId=N+1):(N>=g&&(N=m),i.nextId=N+1);let q=P.highByte=N>=96&&p?N-96>>5:-1;_[Dd]=N,_.__keys__=P,i[N-64]=P,N<m?(P.isShared=!0,i.sharedLength=N-63,o=!0,q>=0?(K[G++]=(N&31)+96,K[G++]=q):K[G++]=N):(q>=0?(K[G++]=213,K[G++]=114,K[G++]=(N&31)+96,K[G++]=q):(K[G++]=212,K[G++]=114,K[G++]=N),$&&(E+=y*$),A.length>=f&&(A.shift()[Dd]=0),A.push(_),I(P))},ee=(_,P,$,N)=>{let q=K,re=G,ie=Bs,ue=n;K=RQ,G=0,n=0,K||(RQ=K=new lj(8192)),Bs=K.length-10,D(_,P,N),RQ=K;let Oe=G;if(K=q,G=re,Bs=ie,n=ue,Oe>1){let Ye=G+Oe-1;Ye>Bs&&L(Ye);let T=$+n;K.copyWithin(T+Oe,T+1,G),K.set(RQ.slice(0,Oe),T),G=Ye}else K[$+n]=RQ[0]},F=_=>{let P=bje(_,K,n,G,i,L,($,N,q)=>{if(q)return o=!0;G=N;let re=K;return I($),b(),re!==K?{position:G,targetView:gn,target:K}:G},this);if(P===0)return B(_);G=P}}useBuffer(t){K=t,K.dataView||(K.dataView=new DataView(K.buffer,K.byteOffset,K.byteLength)),gn=K.dataView,G=0}set position(t){G=t}get position(){return G}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};uoe=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,vQ];coe=[{pack(e,t,r){let n=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:o,targetView:i,position:s}=t(6);o[s++]=214,o[s++]=255,i.setUint32(s,n)}else if(n>0&&n<4294967296){let{target:o,targetView:i,position:s}=t(10);o[s++]=215,o[s++]=255,i.setUint32(s,e.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),i.setUint32(s+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return t(0),r(this.onInvalidDate());let{target:o,targetView:i,position:s}=t(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:i,position:s}=t(15);o[s++]=199,o[s++]=12,o[s++]=255,i.setUint32(s,e.getMilliseconds()*1e6),i.setBigInt64(s+4,BigInt(Math.floor(n)))}}},{pack(e,t,r){if(this.setAsEmptyObject)return t(0),r({});let n=Array.from(e),{target:o,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(o[i++]=212,o[i++]=115,o[i++]=0),r(n)}},{pack(e,t,r){let{target:n,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(n[o++]=212,n[o++]=101,n[o++]=0),r([e.name,e.message,e.cause])}},{pack(e,t,r){let{target:n,position:o}=t(this.moreTypes?3:0);this.moreTypes&&(n[o++]=212,n[o++]=120,n[o++]=0),r([e.source,e.flags])}},{pack(e,t){this.moreTypes?soe(e,16,t):aoe(ik?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let r=e.constructor;r!==Eje&&this.moreTypes?soe(e,ioe.indexOf(r.name),t):aoe(e,t)}},{pack(e,t){this.moreTypes?soe(e,17,t):aoe(ik?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:r,position:n}=t(1);r[n]=193}}];wje=new hS({useRecords:!1}),hUt=wje.pack,Ije=wje.pack,{NEVER:gUt,ALWAYS:AUt,DECIMAL_ROUND:yUt,DECIMAL_FIT:xUt}=uj,kje=512,vje=1024,Rje=2048});function Tje(e,t,r,n,o,i,s,a,c){let u=a.typedStructs||(a.typedStructs=[]),l=a.maxOwnStructures??1/0,d=!c&&u.length>=l,f=t.dataView,p=(u.lastStringStart||100)+n,m=t.length-10,g=n;n>m&&(t=i(n),f=t.dataView,n-=r,g-=r,p-=r,r=0,m=t.length-10);let A,E=p,y=u.transitions||(u.transitions=Object.create(null)),b=u.nextId||u.length,w=b<15?1:b<240?2:b<61440?3:b<15728640?4:0;if(w===0)return 0;n+=w;let I=[],v,k=0;for(let L in e){let D=y[L];if(!D){if(d)return 0;y[L]=D={key:L,parent:y,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null}}let ee=e[L];switch(n>m&&(t=i(n),f=t.dataView,n-=r,g-=r,p-=r,E-=r,r=0,m=t.length-10),typeof ee){case"number":let F=ee;if(b<200||!D.num64){if(F>>0===F&&F<536870912&&F>-520093696){F<246&&F>=0&&(D.num8&&!(b>200&&D.num32)||F<32&&!D.num32)?(y=D.num8||Qd(D,ak,1,d),t[n++]=F):(y=D.num32||Qd(D,ak,4,d),f.setUint32(n,F,!0),n+=4);break}else if(F<4294967296&&F>=-2147483648&&(f.setFloat32(n,F,!0),EUt[t[n+3]>>>5])){let N;if((N=F*mS[(t[n+3]&127)<<1|t[n+2]>>7])>>0===N){y=D.num32||Qd(D,ak,4,d),n+=4;break}}}y=D.num64||Qd(D,ak,8,d),f.setFloat64(n,F,!0),n+=8;break;case"string":let _=ee.length;if(A=E-p,(_<<2)+E>m&&(t=i((_<<2)+E),f=t.dataView,n-=r,g-=r,p-=r,E-=r,r=0,m=t.length-10),_>65280+A>>2){I.push(L,ee,n-g);break}let P,$=E;if(_<64){let N,q,re;for(N=0;N<_;N++)q=ee.charCodeAt(N),q<128?t[E++]=q:q<2048?(P=!0,t[E++]=q>>6|192,t[E++]=q&63|128):(q&64512)===55296&&((re=ee.charCodeAt(N+1))&64512)===56320?(P=!0,q=65536+((q&1023)<<10)+(re&1023),N++,t[E++]=q>>18|240,t[E++]=q>>12&63|128,t[E++]=q>>6&63|128,t[E++]=q&63|128):(P=!0,t[E++]=q>>12|224,t[E++]=q>>6&63|128,t[E++]=q&63|128)}else E+=SUt(t,ee,E),P=E-$>_;if(A<160||A<246&&(D.ascii8||D.string8)){if(P)(y=D.string8)||(u.length>10&&(y=D.ascii8)?(y.__type=BQ,D.ascii8=null,D.string8=y,s(null,0,!0)):y=Qd(D,BQ,1,d));else if(A===0&&!v){v=!0,y=D.ascii0||Qd(D,doe,0,d);break}else!(y=D.ascii8)&&!(u.length>10&&(y=D.string8))&&(y=Qd(D,doe,1,d));t[n++]=A}else y=D.string16||Qd(D,BQ,2,d),f.setUint16(n,A,!0),n+=2;break;case"object":if(ee){ee.constructor===Date?(y=D.date64||Qd(D,poe,8,d),f.setFloat64(n,ee.getTime(),!0),n+=8):I.push(L,ee,k);break}else D=_je(D,n,f,-10),D?(y=D,n=gS):I.push(L,ee,k);break;case"boolean":y=D.num8||D.ascii8||Qd(D,ak,1,d),t[n++]=ee?249:248;break;case"undefined":D=_je(D,n,f,-9),D?(y=D,n=gS):I.push(L,ee,k);break;default:I.push(L,ee,k)}if(y===void 0)return 0;k++}if(!c&&I.length>0&&u.length>=l){let L=y;for(let D=0,ee=I.length;D<ee;D+=3){if(I[D+1]!=null)return 0;let F=L[I[D]];if(!F)return 0;let _=F.object16;if(!_)return 0;L=_}if(L[Dd]==null)return 0}let R=!1;for(let L=0,D=I.length;L<D;){let ee=I[L++],F=I[L++],_=I[L++],P=y[ee];P||(y[ee]=P={key:ee,parent:y,enumerationOffset:_-k,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null});let $;if(F){let N;A=E-p,A<65280?(y=P.object16,y?N=2:(y=P.object32)?N=4:(y=loe(P,fj,2),N=2)):(y=P.object32||loe(P,fj,4),N=4),$=s(F,E),R=!0,typeof $=="object"?(E=$.position,f=$.targetView,t=$.target,p-=r,n-=r,g-=r,r=0):E=$,N===2?(f.setUint16(n,A,!0),n+=2):(f.setUint32(n,A,!0),n+=4)}else y=P.object16||loe(P,fj,2),f.setInt16(n,F===null?-10:-9,!0),n+=2;k++}let B=y[Dd];if(B==null){if(!R&&u.length>=l)return 0;B=a.typedStructs.length;let L=[],D=y,ee,F;for(;(F=D.__type)!==void 0;){let _=D.__size;D=D.__parent,ee=D.key;let P=[F,_,ee];D.enumerationOffset&&P.push(D.enumerationOffset),L.push(P),D=D.parent}L.reverse(),y[Dd]=B,a.typedStructs[B]=L,s(null,0,!0)}switch(w){case 1:if(B>=16)return 0;t[g]=B+32;break;case 2:if(B>=256)return 0;t[g]=56,t[g+1]=B;break;case 3:if(B>=65536)return 0;t[g]=57,f.setUint16(g+1,B,!0);break;case 4:if(B>=16777216)return 0;f.setUint32(g,(B<<8)+58,!0);break}if(n<p){if(p===E)return n;t.copyWithin(n,p,E),E+=n-p,u.lastStringStart=n-g}else if(n>p)return p===E?n:(u.lastStringStart=n-g,Tje(e,t,r,g,o,i,s,a,!0));return E}function _je(e,t,r,n){let o;if(o=e.ascii8||e.num8)return r.setInt8(t,n,!0),gS=t+1,o;if(o=e.string16||e.object16)return r.setInt16(t,n,!0),gS=t+2,o;if(o=e.num32)return r.setUint32(t,3758096640+n,!0),gS=t+4,o;if(o=e.num64)return r.setFloat64(t,NaN,!0),r.setInt8(t,n),gS=t+8,o;gS=t}function Qd(e,t,r,n){let o=moe[t]+(r<<3),i=e[o];if(i)return i;if(!n)return i=e[o]=Object.create(null),i.__type=t,i.__size=r,i.__parent=e,i}function loe(e,t,r){let n=moe[t]+(r<<3),o=e[n];return o||(o=e[n]=Object.create(null),o.__type=t,o.__size=r,o.__parent=e,o)}function CUt(e){if(!(e instanceof Map))return e;let t=e.get("typed")||[];Object.isFrozen(t)&&(t=t.map(o=>o.slice(0)));let r=e.get("named"),n=Object.create(null);for(let o=0,i=t.length;o<i;o++){let s=t[o],a=n;for(let[c,u,l]of s){let d=a[l];d||(a[l]=d={key:l,parent:a,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null}),a=Qd(d,c,u,!1)}a[Dd]=o}return t.transitions=n,this.typedStructs=t,this.lastTypedStructuresLength=t.length,r}function wUt(e,t,r,n){let o=e[t++]-32;if(o>=24)switch(o){case 24:o=e[t++];break;case 25:o=e[t++]+(e[t++]<<8);break;case 26:o=e[t++]+(e[t++]<<8)+(e[t++]<<16);break;case 27:o=e[t++]+(e[t++]<<8)+(e[t++]<<16)+(e[t++]<<24);break}let i=n.typedStructs&&n.typedStructs[o];if(!i){if(e=Uint8Array.prototype.slice.call(e,t,r),r-=t,t=0,!n.getStructures)throw new Error(`Reference to shared structure ${o} without getStructures method`);if(n._mergeStructures(n.getStructures()),!n.typedStructs)throw new Error("Could not find any shared typed structures");if(n.lastTypedStructuresLength=n.typedStructs.length,i=n.typedStructs[o],!i)throw new Error("Could not find typed structure "+o)}var s=i.construct,a=i.fullConstruct;if(!s){s=i.construct=function(){},a=i.fullConstruct=function(){},a.prototype=n.structPrototype||{};var c=s.prototype=n.structPrototype?Object.create(n.structPrototype):{};let l=[],d=0,f;for(let p=0,m=i.length;p<m;p++){let g=i[p],[A,E,y,b]=g;y==="__proto__"&&(y="__proto_");let w={key:y,offset:d};b?l.splice(p+b,0,w):l.push(w);let I;switch(E){case 0:I=()=>0;break;case 1:I=(k,R)=>{let B=k.bytes[R+w.offset];return B>=246?sk(B):B};break;case 2:I=(k,R)=>{let B=k.bytes,D=(B.dataView||(B.dataView=new DataView(B.buffer,B.byteOffset,B.byteLength))).getUint16(R+w.offset,!0);return D>=65280?sk(D&255):D};break;case 4:I=(k,R)=>{let B=k.bytes,D=(B.dataView||(B.dataView=new DataView(B.buffer,B.byteOffset,B.byteLength))).getUint32(R+w.offset,!0);return D>=4294967040?sk(D&255):D};break}w.getRef=I,d+=E;let v;switch(A){case doe:f&&!f.next&&(f.next=w),f=w,w.multiGetCount=0,v=function(k){let R=k.bytes,B=k.position,L=d+B,D=I(k,B);if(typeof D!="number")return D;let ee,F=w.next;for(;F&&(ee=F.getRef(k,B),typeof ee!="number");)ee=null,F=F.next;return ee==null&&(ee=k.bytesEnd-L),k.srcString?k.srcString.slice(D,ee):lje(R,D+L,ee-D)};break;case BQ:case fj:f&&!f.next&&(f.next=w),f=w,v=function(k){let R=k.position,B=d+R,L=I(k,R);if(typeof L!="number")return L;let D=k.bytes,ee,F=w.next;for(;F&&(ee=F.getRef(k,R),typeof ee!="number");)ee=null,F=F.next;if(ee==null&&(ee=k.bytesEnd-B),A===BQ)return D.toString("utf8",L+B,ee+B);up=k;try{return n.unpack(D,{start:L+B,end:ee+B})}finally{up=null}};break;case ak:switch(E){case 4:v=function(k){let R=k.bytes,B=R.dataView||(R.dataView=new DataView(R.buffer,R.byteOffset,R.byteLength)),L=k.position+w.offset,D=B.getInt32(L,!0);if(D<536870912){if(D>-520093696)return D;if(D>-536870912)return sk(D&255)}let ee=B.getFloat32(L,!0),F=mS[(R[L+3]&127)<<1|R[L+2]>>7];return(F*ee+(ee>0?.5:-.5)>>0)/F};break;case 8:v=function(k){let R=k.bytes,L=(R.dataView||(R.dataView=new DataView(R.buffer,R.byteOffset,R.byteLength))).getFloat64(k.position+w.offset,!0);if(isNaN(L)){let D=R[k.position+w.offset];if(D>=246)return sk(D)}return L};break;case 1:v=function(k){let B=k.bytes[k.position+w.offset];return B<246?B:sk(B)};break}break;case poe:v=function(k){let R=k.bytes,B=R.dataView||(R.dataView=new DataView(R.buffer,R.byteOffset,R.byteLength));return new Date(B.getFloat64(k.position+w.offset,!0))};break}w.get=v}if(Bje){let p=[],m=[],g=0,A;for(let y of l){if(n.alwaysLazyProperty&&n.alwaysLazyProperty(y.key)){A=!0;continue}Object.defineProperty(c,y.key,{get:IUt(y.get),enumerable:!0});let b="v"+g++;m.push(b),p.push("o["+JSON.stringify(y.key)+"]="+b+"(s)")}A&&p.push("__proto__:this");let E=new Function(...m,"var c=this;return function(s){var o=new c();"+p.join(";")+";return o;}").apply(a,l.map(y=>y.get));Object.defineProperty(c,"toJSON",{value(y){return E.call(this,this[foe])}})}else Object.defineProperty(c,"toJSON",{value(p){let m={};for(let g=0,A=l.length;g<A;g++){let E=l[g].key;m[E]=this[E]}return m}})}var u=new s;return u[foe]={bytes:e,position:t,srcString:"",bytesEnd:r},u}function sk(e){switch(e){case 246:return null;case 247:return;case 248:return!1;case 249:return!0}throw new Error("Unknown constant")}function IUt(e){return function(){return e(this[foe])}}function kUt(){up&&(up.bytes=Uint8Array.prototype.slice.call(up.bytes,up.position,up.bytesEnd),up.position=0,up.bytesEnd=up.bytes.length)}function vUt(e,t){if(t.typedStructs){let n=new Map;n.set("named",e),n.set("typed",t.typedStructs),e=n}let r=t.lastTypedStructuresLength||0;return e.isCompatible=n=>{let o=!0;return n instanceof Map?((n.get("named")||[]).length!==(t.lastNamedStructuresLength||0)&&(o=!1),(n.get("typed")||[]).length!==r&&(o=!1)):(n instanceof Array||Array.isArray(n))&&n.length!==(t.lastNamedStructuresLength||0)&&(o=!1),o||t._mergeStructures(n),o},t.lastTypedStructuresLength=t.typedStructs&&t.typedStructs.length,e}var doe,ak,BQ,fj,poe,moe,EUt,Bje,gS,bUt,pj,up,SUt,Srn,Crn,foe,Dje=h(()=>{_Q();Fh();doe=3,ak=0,BQ=2,fj=1,poe=16,moe=["num","object","string","ascii"];moe[poe]="date";EUt=[!1,!0,!0,!1,!1,!0,!0,!1];try{new Function(""),Bje=!0}catch{}bUt=typeof Buffer<"u";try{pj=new TextEncoder}catch{}SUt=bUt?function(e,t,r){return e.utf8Write(t,r,e.byteLength-r)}:pj&&pj.encodeInto?function(e,t,r){return pj.encodeInto(t,e.subarray(r)).written}:!1,Srn=Symbol("type"),Crn=Symbol("parent");Cje(Tje,vUt);foe=Symbol.for("source");gje(wUt,CUt,kUt)});var Qje=h(()=>{_Q();Fh()});var Oje=h(()=>{_Q();Fh()});var Mje=ne((Brn,Pje)=>{"use strict";var Nje=()=>process.platform==="linux",mj=null,RUt=()=>{if(!mj)if(Nje()&&process.report){let e=process.report.excludeNetwork;process.report.excludeNetwork=!0,mj=process.report.getReport(),process.report.excludeNetwork=e}else mj={};return mj};Pje.exports={isLinux:Nje,getReport:RUt}});var Lje=ne((Trn,Fje)=>{"use strict";var ck=Y("fs"),_Ut="/usr/bin/ldd",BUt="/proc/self/exe",hj=2048,TUt=e=>{let t=ck.openSync(e,"r"),r=Buffer.alloc(hj),n=ck.readSync(t,r,0,hj,0);return ck.close(t,()=>{}),r.subarray(0,n)},DUt=e=>new Promise((t,r)=>{ck.open(e,"r",(n,o)=>{if(n)r(n);else{let i=Buffer.alloc(hj);ck.read(o,i,0,hj,0,(s,a)=>{t(i.subarray(0,a)),ck.close(o,()=>{})})}})});Fje.exports={LDD_PATH:_Ut,SELF_PATH:BUt,readFileSync:TUt,readFile:DUt}});var $je=ne((Drn,Uje)=>{"use strict";var QUt=e=>{if(e.length<64||e.readUInt32BE(0)!==2135247942||e.readUInt8(4)!==2||e.readUInt8(5)!==1)return null;let t=e.readUInt32LE(32),r=e.readUInt16LE(54),n=e.readUInt16LE(56);for(let o=0;o<n;o++){let i=t+o*r;if(e.readUInt32LE(i)===3){let a=e.readUInt32LE(i+8),c=e.readUInt32LE(i+32);return e.subarray(a,a+c).toString().replace(/\0.*$/g,"")}}return null};Uje.exports={interpreterPath:QUt}});var sqe=ne((Qrn,iqe)=>{"use strict";var Wje=Y("child_process"),{isLinux:uk,getReport:jje}=Mje(),{LDD_PATH:gj,SELF_PATH:qje,readFile:hoe,readFileSync:goe}=Lje(),{interpreterPath:Gje}=$je(),lp,dp,fp,zje="getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",Qy="",Vje=()=>Qy||new Promise(e=>{Wje.exec(zje,(t,r)=>{Qy=t?" ":r,e(Qy)})}),Yje=()=>{if(!Qy)try{Qy=Wje.execSync(zje,{encoding:"utf8"})}catch{Qy=" "}return Qy},Lh="glibc",Jje=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,AS="musl",OUt=e=>e.includes("libc.musl-")||e.includes("ld-musl-"),Kje=()=>{let e=jje();return e.header&&e.header.glibcVersionRuntime?Lh:Array.isArray(e.sharedObjects)&&e.sharedObjects.some(OUt)?AS:null},Zje=e=>{let[t,r]=e.split(/[\r\n]+/);return t&&t.includes(Lh)?Lh:r&&r.includes(AS)?AS:null},Xje=e=>{if(e){if(e.includes("/ld-musl-"))return AS;if(e.includes("/ld-linux-"))return Lh}return null},eqe=e=>(e=e.toString(),e.includes("musl")?AS:e.includes("GNU C Library")?Lh:null),NUt=async()=>{if(dp!==void 0)return dp;dp=null;try{let e=await hoe(gj);dp=eqe(e)}catch{}return dp},PUt=()=>{if(dp!==void 0)return dp;dp=null;try{let e=goe(gj);dp=eqe(e)}catch{}return dp},MUt=async()=>{if(lp!==void 0)return lp;lp=null;try{let e=await hoe(qje),t=Gje(e);lp=Xje(t)}catch{}return lp},FUt=()=>{if(lp!==void 0)return lp;lp=null;try{let e=goe(qje),t=Gje(e);lp=Xje(t)}catch{}return lp},tqe=async()=>{let e=null;if(uk()&&(e=await MUt(),!e&&(e=await NUt(),e||(e=Kje()),!e))){let t=await Vje();e=Zje(t)}return e},rqe=()=>{let e=null;if(uk()&&(e=FUt(),!e&&(e=PUt(),e||(e=Kje()),!e))){let t=Yje();e=Zje(t)}return e},LUt=async()=>uk()&&await tqe()!==Lh,UUt=()=>uk()&&rqe()!==Lh,$Ut=async()=>{if(fp!==void 0)return fp;fp=null;try{let t=(await hoe(gj)).match(Jje);t&&(fp=t[1])}catch{}return fp},HUt=()=>{if(fp!==void 0)return fp;fp=null;try{let t=goe(gj).match(Jje);t&&(fp=t[1])}catch{}return fp},nqe=()=>{let e=jje();return e.header&&e.header.glibcVersionRuntime?e.header.glibcVersionRuntime:null},Hje=e=>e.trim().split(/\s+/)[1],oqe=e=>{let[t,r,n]=e.split(/[\r\n]+/);return t&&t.includes(Lh)?Hje(t):r&&n&&r.includes(AS)?Hje(n):null},WUt=async()=>{let e=null;if(uk()&&(e=await $Ut(),e||(e=nqe()),!e)){let t=await Vje();e=oqe(t)}return e},jUt=()=>{let e=null;if(uk()&&(e=HUt(),e||(e=nqe()),!e)){let t=Yje();e=oqe(t)}return e};iqe.exports={GLIBC:Lh,MUSL:AS,family:tqe,familySync:rqe,isNonGlibcLinux:LUt,isNonGlibcLinuxSync:UUt,version:WUt,versionSync:jUt}});var Eqe=ne((Orn,xqe)=>{var qUt=Y("fs"),Od=Y("path"),GUt=Y("url"),uqe=Y("os"),lqe=typeof __webpack_require__=="function"?__non_webpack_require__:Y,zUt=process.config&&process.config.variables||{},VUt=!!process.env.PREBUILDS_ONLY,boe=process.versions,yoe=boe.modules;(boe.deno||process.isBun)&&(yoe="unsupported");var Aoe=KUt()?"electron":JUt()?"node-webkit":"node",Aj=process.env.npm_config_arch||uqe.arch(),yj=process.env.npm_config_platform||uqe.platform(),dqe=process.env.LIBC||(ZUt(yj)?"musl":"glibc"),xoe=process.env.ARM_VERSION||(Aj==="arm64"?"8":zUt.arm_version)||"",fqe=(boe.uv||"").split(".")[0];xqe.exports=pp;function pp(e){return lqe(pp.resolve(e))}pp.resolve=pp.path=function(e){e=Od.resolve(e||".");var t="",r;try{t=lqe(Od.join(e,"package.json")).name;var n=t.toUpperCase().replace(/-/g,"_");process.env[n+"_PREBUILD"]&&(e=process.env[n+"_PREBUILD"])}catch(g){r=g}if(!VUt){var o=aqe(Od.join(e,"build/Release"),cqe);if(o)return o;var i=aqe(Od.join(e,"build/Debug"),cqe);if(i)return i}var s=p(e);if(s)return s;var a=p(Od.dirname(process.execPath));if(a)return a;var c=(t[0]=="@"?"":"@"+t+"/")+t+"-"+yj+"-"+Aj,u;try{var l=Od.dirname(Y("module").createRequire(GUt.pathToFileURL(Od.join(e,"package.json"))).resolve(c));return m(l)}catch(g){u=g}var d=["platform="+yj,"arch="+Aj,"runtime="+Aoe,"abi="+yoe,"uv="+fqe,xoe?"armv="+xoe:"","libc="+dqe,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__=="function"?"webpack=true":""].filter(Boolean).join(" ");let f="No native build was found for "+d+`
73
73
  attempted loading from: `+e+" and package: "+c+`
74
74
  `;throw r&&(f+="Error finding package.json: "+r.message+`
75
75
  `),u&&(f+="Error resolving package: "+u.message+`
@@ -209,7 +209,7 @@ ${t.format(r)}`.trim())}};V6e.exports=mce});var gce=ne((tin,Z6e)=>{"use strict";
209
209
  ${i}`;break;case"retry":b9e(i)&&(r[o]=i);break;case"id":S9e(i)&&(r[o]=i);break;case"event":i.length>0&&(r[o]=i);break}}processEvent(t){t.retry&&b9e(t.retry)&&(this.state.reconnectionTime=parseInt(t.retry,10)),t.id!==void 0&&S9e(t.id)&&(this.state.lastEventId=t.id),t.data!==void 0&&this.push({type:t.event||"message",options:{data:t.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}};C9e.exports={EventSourceStream:Iue}});var D9e=ne((Yin,T9e)=>{"use strict";var{pipeline:$8t}=Y("node:stream"),{fetching:H8t}=NO(),{makeRequest:W8t}=Vk(),{webidl:la}=as(),{EventSourceStream:j8t}=w9e(),{parseMIMEType:q8t}=dl(),{createFastMessageEvent:G8t}=AG(),{isNetworkError:I9e}=DO(),{kEnumerableProperty:tC}=Bt(),{environmentSettingsObject:k9e}=Lc(),v9e=!1,R9e=3e3,HO=0,_9e=1,WO=2,z8t="anonymous",V8t="use-credentials",ov=class e extends EventTarget{#e={open:null,error:null,message:null};#t;#r=!1;#n=HO;#i=null;#o=null;#c;#s;constructor(t,r={}){super(),la.util.markAsUncloneable(this);let n="EventSource constructor";la.argumentLengthCheck(arguments,1,n),v9e||(v9e=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),t=la.converters.USVString(t),r=la.converters.EventSourceInitDict(r,n,"eventSourceInitDict"),this.#c=r.node.dispatcher||r.dispatcher,this.#s={lastEventId:"",reconnectionTime:r.node.reconnectionTime};let o=k9e,i;try{i=new URL(t,o.settingsObject.baseUrl),this.#s.origin=i.origin}catch(c){throw new DOMException(c,"SyntaxError")}this.#t=i.href;let s=z8t;r.withCredentials===!0&&(s=V8t,this.#r=!0);let a={redirect:"follow",keepalive:!0,mode:"cors",credentials:s==="anonymous"?"same-origin":"omit",referrer:"no-referrer"};a.client=k9e.settingsObject,a.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],a.cache="no-store",a.initiator="other",a.urlList=[new URL(this.#t)],this.#i=W8t(a),this.#a()}get readyState(){return this.#n}get url(){return this.#t}get withCredentials(){return this.#r}#a(){if(this.#n===WO)return;this.#n=HO;let t={request:this.#i,dispatcher:this.#c},r=n=>{if(!I9e(n))return this.#u()};t.processResponseEndOfBody=r,t.processResponse=n=>{if(I9e(n))if(n.aborted){this.close(),this.dispatchEvent(new Event("error"));return}else{this.#u();return}let o=n.headersList.get("content-type",!0),i=o!==null?q8t(o):"failure",s=i!=="failure"&&i.essence==="text/event-stream";if(n.status!==200||s===!1){this.close(),this.dispatchEvent(new Event("error"));return}this.#n=_9e,this.dispatchEvent(new Event("open")),this.#s.origin=n.urlList[n.urlList.length-1].origin;let a=new j8t({eventSourceSettings:this.#s,push:c=>{this.dispatchEvent(G8t(c.type,c.options))}});$8t(n.body.stream,a,c=>{c?.aborted===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},this.#o=H8t(t)}#u(){this.#n!==WO&&(this.#n=HO,this.dispatchEvent(new Event("error")),setTimeout(()=>{this.#n===HO&&(this.#s.lastEventId.length&&this.#i.headersList.set("last-event-id",this.#s.lastEventId,!0),this.#a())},this.#s.reconnectionTime)?.unref())}close(){la.brandCheck(this,e),this.#n!==WO&&(this.#n=WO,this.#o.abort(),this.#i=null)}get onopen(){return this.#e.open}set onopen(t){this.#e.open&&this.removeEventListener("open",this.#e.open);let r=la.converters.EventHandlerNonNull(t);r!==null?(this.addEventListener("open",r),this.#e.open=t):this.#e.open=null}get onmessage(){return this.#e.message}set onmessage(t){this.#e.message&&this.removeEventListener("message",this.#e.message);let r=la.converters.EventHandlerNonNull(t);r!==null?(this.addEventListener("message",r),this.#e.message=t):this.#e.message=null}get onerror(){return this.#e.error}set onerror(t){this.#e.error&&this.removeEventListener("error",this.#e.error);let r=la.converters.EventHandlerNonNull(t);r!==null?(this.addEventListener("error",r),this.#e.error=t):this.#e.error=null}},B9e={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:HO,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:_9e,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:WO,writable:!1}};Object.defineProperties(ov,B9e);Object.defineProperties(ov.prototype,B9e);Object.defineProperties(ov.prototype,{close:tC,onerror:tC,onmessage:tC,onopen:tC,readyState:tC,url:tC,withCredentials:tC});la.converters.EventSourceInitDict=la.dictionaryConverter([{key:"withCredentials",converter:la.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:la.converters.any},{key:"node",converter:la.dictionaryConverter([{key:"reconnectionTime",converter:la.converters["unsigned long"],defaultValue:()=>R9e},{key:"dispatcher",converter:la.converters.any}]),defaultValue:()=>({})}]);T9e.exports={EventSource:ov,defaultReconnectionTime:R9e}});var kue=ne((Jin,Qe)=>{"use strict";var Y8t=zy(),O9e=$Q(),J8t=QS(),K8t=QYe(),Z8t=MYe(),X8t=PS(),e5t=yae(),t5t=mae(),r5t=bJe(),n5t=vJe(),o5t=BJe(),N9e=bt(),BG=Bt(),{InvalidArgumentError:_G}=N9e,iv=d6e(),i5t=kS(),s5t=nce(),{MockCallHistory:a5t,MockCallHistoryLog:c5t}=sce(),u5t=hce(),l5t=lce(),d5t=l3e(),f5t=Uae(),p5t=kq(),{getGlobalDispatcher:P9e,setGlobalDispatcher:m5t}=$q(),h5t=Wk(),g5t=Cce();Object.assign(O9e.prototype,iv);Qe.exports.Dispatcher=O9e;Qe.exports.Client=Y8t;Qe.exports.Pool=J8t;Qe.exports.BalancedPool=K8t;Qe.exports.RoundRobinPool=Z8t;Qe.exports.Agent=X8t;Qe.exports.ProxyAgent=e5t;Qe.exports.Socks5ProxyAgent=t5t;Qe.exports.EnvHttpProxyAgent=r5t;Qe.exports.RetryAgent=n5t;Qe.exports.H2CClient=o5t;Qe.exports.RetryHandler=p5t;Qe.exports.DecoratorHandler=h5t;Qe.exports.RedirectHandler=g5t;Qe.exports.interceptors={redirect:b3e(),responseError:C3e(),retry:I3e(),dump:v3e(),dns:T3e(),cache:V3e(),decompress:X3e(),deduplicate:oKe()};Qe.exports.cacheStores={MemoryCacheStore:Dce()};var A5t=aKe();Qe.exports.cacheStores.SqliteCacheStore=A5t;Qe.exports.buildConnector=i5t;Qe.exports.errors=N9e;Qe.exports.util={parseHeaders:BG.parseHeaders,headerNameToString:BG.headerNameToString};function jO(e){return(t,r,n)=>{if(typeof r=="function"&&(n=r,r=null),!t||typeof t!="string"&&typeof t!="object"&&!(t instanceof URL))throw new _G("invalid url");if(r!=null&&typeof r!="object")throw new _G("invalid opts");if(r&&r.path!=null){if(typeof r.path!="string")throw new _G("invalid opts.path");let s=r.path;r.path.startsWith("/")||(s=`/${s}`),t=new URL(BG.parseOrigin(t).origin+s)}else r||(r=typeof t=="object"?t:{}),t=BG.parseURL(t);let{agent:o,dispatcher:i=P9e()}=r;if(o)throw new _G("unsupported opts.agent. Did you mean opts.client?");return e.call(i,{...r,origin:t.origin,path:t.search?`${t.pathname}${t.search}`:t.pathname,method:r.method||(r.body?"PUT":"GET")},n)}}Qe.exports.setGlobalDispatcher=m5t;Qe.exports.getGlobalDispatcher=P9e;var y5t=NO().fetch,Q9e=typeof __filename<"u"?__filename:void 0;function M9e(e,t){if(!e||typeof e!="object")return;let r=typeof e.stack=="string"?e.stack:"",n=t.replace(/\\/g,"/");if(r&&(r.includes(t)||r.includes(n)))return;let o={};if(Error.captureStackTrace(o,M9e),!o.stack)return;let i=o.stack.split(`
210
210
  `).slice(1).join(`
211
211
  `);e.stack=r?`${r}
212
- ${i}`:o.stack}Qe.exports.fetch=function(t,r=void 0){return y5t(t,r).catch(n=>{throw Q9e?M9e(n,Q9e):n&&typeof n=="object"&&Error.captureStackTrace(n,Qe.exports.fetch),n})};Qe.exports.Headers=zS().Headers;Qe.exports.Response=DO().Response;Qe.exports.Request=Vk().Request;Qe.exports.FormData=Xj().FormData;var{setGlobalOrigin:x5t,getGlobalOrigin:E5t}=nse();Qe.exports.setGlobalOrigin=x5t;Qe.exports.getGlobalOrigin=E5t;var{CacheStorage:b5t}=AZe(),{kConstruct:S5t}=Kr();Qe.exports.caches=new b5t(S5t);var{deleteCookie:C5t,getCookies:w5t,getSetCookies:I5t,setCookie:k5t,parseCookie:v5t}=BZe();Qe.exports.deleteCookie=C5t;Qe.exports.getCookies=w5t;Qe.exports.getSetCookies=I5t;Qe.exports.setCookie=k5t;Qe.exports.parseCookie=v5t;var{parseMIMEType:R5t,serializeAMimeType:_5t}=dl();Qe.exports.parseMIMEType=R5t;Qe.exports.serializeAMimeType=_5t;var{CloseEvent:B5t,ErrorEvent:T5t,MessageEvent:D5t}=AG(),{WebSocket:Q5t,ping:O5t}=l9e();Qe.exports.WebSocket=Q5t;Qe.exports.CloseEvent=B5t;Qe.exports.ErrorEvent=T5t;Qe.exports.MessageEvent=D5t;Qe.exports.ping=O5t;Qe.exports.WebSocketStream=y9e().WebSocketStream;Qe.exports.WebSocketError=Eue().WebSocketError;Qe.exports.request=jO(iv.request);Qe.exports.stream=jO(iv.stream);Qe.exports.pipeline=jO(iv.pipeline);Qe.exports.connect=jO(iv.connect);Qe.exports.upgrade=jO(iv.upgrade);Qe.exports.MockClient=s5t;Qe.exports.MockCallHistory=a5t;Qe.exports.MockCallHistoryLog=c5t;Qe.exports.MockPool=l5t;Qe.exports.MockAgent=u5t;Qe.exports.SnapshotAgent=d5t;Qe.exports.mockErrors=f5t;var{EventSource:N5t}=D9e();Qe.exports.EventSource=N5t;function P5t(){globalThis.fetch=Qe.exports.fetch,globalThis.Headers=Qe.exports.Headers,globalThis.Response=Qe.exports.Response,globalThis.Request=Qe.exports.Request,globalThis.FormData=Qe.exports.FormData,globalThis.WebSocket=Qe.exports.WebSocket,globalThis.CloseEvent=Qe.exports.CloseEvent,globalThis.ErrorEvent=Qe.exports.ErrorEvent,globalThis.MessageEvent=Qe.exports.MessageEvent,globalThis.EventSource=Qe.exports.EventSource}Qe.exports.install=P5t});var sv={};tr(sv,{default:()=>F9e.default});var F9e,L9e=h(()=>{F9e=su(kue(),1);AM(sv,su(kue(),1))});var U9e=h(()=>{});var $9e=h(()=>{});var H9e=h(()=>{});var vue,W9e,j9e,q9e,G9e,z9e,L5t,V9e=h(()=>{RW();vr();sr();nr();oe();rk();wd();vue=Symbol.for("@effect/platform/CommandExecutor"),W9e=Symbol.for("@effect/platform/Process"),j9e=dQ(),q9e=dQ(),G9e=Jt("@effect/platform/CommandExecutor"),z9e=e=>{let t=n=>fy(De(e(n),o=>o.stdout)),r=(n,o)=>{let i=new TextDecoder(o);return DMe(vMe(t(n),xf(s=>i.decode(s))))};return{[vue]:vue,start:e,exitCode:n=>Ad(Ee(e(n),o=>o.exitCode)),stream:t,string:(n,o="utf-8")=>{let i=new TextDecoder(o);return C(e(n),Ee(s=>_0(s.stdout,L5t)),De(s=>i.decode(s)),Ad)},lines:(n,o="utf-8")=>C(r(n,o),BMe,De(mbe)),streamLines:r}},L5t=E2e(new Uint8Array,(e,t)=>I_(t,e,(r,n)=>{let o=new Uint8Array(r.length+n.length);return o.set(r),o.set(n,r.length),o}))});var Rue,Y9e,_ue,J9e,$5t,H5t,W5t,j5t,Bue,K9e=h(()=>{vr();oe();ht();Me();Rue=Symbol.for("@effect/platform/Command"),Y9e=e=>Array.from(_ue(e)),_ue=e=>{switch(e._tag){case"StandardCommand":return Dt(e);case"PipedCommand":return Ir(_ue(e.left),_ue(e.right))}},J9e={[Rue]:Rue,pipe(){return Z(this,arguments)},...Am},$5t={...J9e,_tag:"StandardCommand",toJSON(){return{_id:"@effect/platform/Command",_tag:this._tag,command:this.command,args:this.args,env:Object.fromEntries(this.env),cwd:this.cwd.toJSON(),shell:this.shell,gid:this.gid.toJSON(),uid:this.uid.toJSON()}}},H5t=e=>Object.assign(Object.create($5t),e),W5t={...J9e,_tag:"PipedCommand",toJSON(){return{_id:"@effect/platform/Command",_tag:this._tag,left:this.left.toJSON(),right:this.right.toJSON()}}},j5t=e=>Object.assign(Object.create(W5t),e),Bue=x(2,(e,t)=>{switch(e._tag){case"StandardCommand":return H5t({...e,stdin:t});case"PipedCommand":return j5t({...e,left:Bue(e.left,t)})}})});var Tue,Due,Que=h(()=>{K9e();Tue=Y9e,Due=Bue});var X9e,Oue,e8e,t8e,r8e,Nue=h(()=>{V9e();X9e=G9e,Oue=W9e,e8e=j9e,t8e=q9e,r8e=z9e});import*as TG from"node:child_process";var G5t,o8e,qO,sx,z5t,GO,i8e,s8e=h(()=>{Que();Nue();AQ();$u();nr();oe();ht();zu();it();rk();wd();Voe();uze();eie();G5t=e=>typeof e=="string"?e:"pipe",o8e=e=>typeof e=="string"?e:"pipe",qO=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),sx=(e,t,r)=>{let n=Tue(r).reduce((o,i)=>{let s=`${i.command} ${i.args.join(" ")}`;return o.length===0?s:`${o} | ${s}`},"");return Jr("Command",e)(t,[n])},z5t={[Oue]:Oue,...Am,toJSON(){return{_id:"@effect/platform/CommandExecutor/Process",pid:this.pid}}},GO=e=>t=>{switch(t._tag){case"StandardCommand":{let r=Ee(rn(),i=>Zs(s=>{let a=TG.spawn(t.command,t.args,{stdio:[G5t(t.stdin),o8e(t.stdout),o8e(t.stderr)],cwd:Nt(t.cwd,hw),shell:t.shell,env:{...process.env,...Object.fromEntries(t.env)},detached:process.platform!=="win32"});return a.on("error",c=>{s($e(sx("spawn",c,t)))}),a.on("exit",(...c)=>{kc(i,nt(c))}),a.on("spawn",()=>{s(nt([a,i]))}),ot(()=>{a.kill("SIGTERM")})})),n=process.platform==="win32"?(i,s)=>Zs(a=>{TG.exec(`taskkill /pid ${i.pid} /T /F`,c=>{a(c?$e(sx("kill",qO(c),t)):ve)})}):(i,s)=>Wu({try:()=>process.kill(-i.pid,s),catch:a=>sx("kill",qO(a),t)}),o=(i,s)=>Pt(()=>i.kill(s)?ve:$e(sx("kill",new globalThis.Error("Failed to kill process"),t)));return C(wt(t.cwd,{onNone:()=>ve,onSome:i=>e.access(i)}),Wt(zo(r,([i,s])=>Ee(ph(s),a=>a?Ee(Ht(s),([c])=>c!==0&&c!==null?n(i,"SIGTERM").pipe(a0):ve):n(i,"SIGTERM").pipe(nD(()=>o(i,"SIGTERM")),Wt(Ht(s)),a0)))),De(([i,s])=>{let a=y2e;i.stdin!==null&&(a=cze(()=>i.stdin,m=>sx("toWritable",qO(m),t)));let c=Ee(Ht(s),([m,g])=>m!==null?nt(e8e(m)):$e(sx("exitCode",new globalThis.Error(`Process interrupted due to receipt of signal: ${g}`),t))),u=K5(ph(s)),l=(m="SIGTERM")=>n(i,m).pipe(nD(()=>o(i,m)),Wt(gd(Ht(s)))),d=t8e(i.pid),f=Xoe(()=>i.stderr,m=>sx("fromReadable(stderr)",qO(m),t)),p=Xoe(()=>i.stdout,m=>sx("fromReadable(stdout)",qO(m),t));return typeof t.stdout!="string"&&(p=QMe(p,t.stdout)),Object.assign(Object.create(z5t),{pid:d,exitCode:c,isRunning:u,kill:l,stdin:a,stderr:f,stdout:p})}),typeof t.stdin=="string"?be:Ri(i=>Rb(_0(t.stdin,i.stdin))))}case"PipedCommand":{let r=Tue(t);if(r.length===1)return C(r[0],GO(e));let n=r[0],o=r.slice(1),i=o.slice(0,o.length-1),s=o[o.length-1],a=i.reduce((c,u)=>C(Due(u,c),GO(e),De(l=>l.stdout),fy),C(GO(e)(n),De(c=>c.stdout),fy));return C(Due(s,a),GO(e))}}},i8e=iy(X9e,C(By,De(e=>r8e(GO(e)))))});var a8e,c8e=h(()=>{s8e();a8e=i8e});import*as zO from"node:path";import*as DG from"node:url";var Pue,Mue,J5t,K5t,u8e,l8e=h(()=>{Th();zW();nr();zu();Pue=e=>Wu({try:()=>DG.fileURLToPath(e),catch:t=>new _s({module:"Path",method:"fromFileUrl",description:`Invalid file URL: ${e}`,cause:t})}),Mue=e=>Wu({try:()=>DG.pathToFileURL(e),catch:t=>new _s({module:"Path",method:"toFileUrl",description:`Invalid path: ${e}`,cause:t})}),J5t=Ed(Oh,Oh.of({[uS]:uS,...zO.posix,fromFileUrl:Pue,toFileUrl:Mue})),K5t=Ed(Oh,Oh.of({[uS]:uS,...zO.win32,fromFileUrl:Pue,toFileUrl:Mue})),u8e=Ed(Oh,Oh.of({[uS]:uS,...zO,fromFileUrl:Pue,toFileUrl:Mue}))});var d8e,f8e=h(()=>{l8e();d8e=u8e});var p8e,m8e=h(()=>{sr();p8e=Jt("@effect/platform/Terminal")});var Fue,Lue=h(()=>{m8e();Fue=p8e});import*as QG from"node:readline";var g8e,A8e,y8e,x8e=h(()=>{Th();Lue();nr();Ro();zu();EQ();it();d7();g8e=e=>e.key.ctrl&&(e.key.name==="c"||e.key.name==="d"),A8e=Z$(function*(e=g8e){let t=process.stdin,r=process.stdout,n=yield*DPe({acquire:zo(ot(()=>{let l=QG.createInterface({input:t,escapeCodeTimeout:50});return QG.emitKeypressEvents(t,l),t.isTTY&&t.setRawMode(!0),l}),l=>ot(()=>{t.isTTY&&t.setRawMode(!1),l.close()}))}),o=ot(()=>r.columns??0),i=ot(()=>r.rows??0),s=ot(()=>!!r.isTTY),a=Go(function*(){yield*l7(n);let l=yield*ok(),d=(f,p)=>{let m={input:en(f),key:{name:p.name??"",ctrl:!!p.ctrl,meta:!!p.meta,shift:!!p.shift}};l.unsafeOffer(m),e(m)&&l.unsafeDone(wc)};return yield*YT(()=>ot(()=>t.off("keypress",d))),t.on("keypress",d),l}),c=l7(n).pipe(Ee(l=>Zs(d=>{let f=p=>d(nt(p));return l.once("line",f),ot(()=>l.off("line",f))})),Ad),u=l=>hd(Zs(d=>{r.write(l,f=>d(f?$e(new _s({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:f})):ve))}));return Fue.of({columns:o,rows:i,isTTY:s,readInput:a,readLine:c,display:u})}),y8e=X$(Fue,A8e(g8e))});var E8e,b8e=h(()=>{x8e();E8e=y8e});var nXt,S8e,C8e,w8e=h(()=>{Yne();nj();$u();nr();Ro();zu();ah();nXt=WWe()({setup({scope:e,worker:t}){return Ee(rn(),r=>{let n="postMessage"in t?{postMessage(o,i){t.postMessage(o,i)},kill:()=>t.terminate(),worker:t}:{postMessage(o,i){t.send(o)},kill:()=>t.kill("SIGKILL"),worker:t};return t.on("exit",()=>{kc(r,wc)}),ju(sh(e,Pt(()=>(n.postMessage([1]),Ht(r))).pipe(Bo,X5(5e3),Hu(()=>ot(()=>n.kill())))),n)})},listen({deferred:e,emit:t,port:r}){return r.worker.on("message",n=>{t(n)}),r.worker.on("messageerror",n=>{kc(e,new cp({reason:"decode",cause:n}))}),r.worker.on("error",n=>{kc(e,new cp({reason:"unknown",cause:n}))}),r.worker.on("exit",n=>{kc(e,new cp({reason:"unknown",cause:new Error(`exited with code ${n}`)}))}),ve}}),S8e=Ed(jWe,nXt),C8e=sy(qWe,S8e)});var I8e,Uue=h(()=>{w8e();I8e=C8e});var us={};tr(us,{layer:()=>iXt});var iXt,v8e=h(()=>{c8e();Zoe();f8e();b8e();oe();zu();Uue();iXt=C(aX(d8e,a8e,E8e,I8e),sD(Qj))});var R8e=h(()=>{});var _8e=h(()=>{});var B8e=h(()=>{Goe();Hqe()});var T8e=h(()=>{});var D8e=h(()=>{});var Q8e=h(()=>{});var O8e=h(()=>{});var N8e=h(()=>{});var P8e=h(()=>{});var M8e=h(()=>{H9e()});var F8e=h(()=>{});var L8e=h(()=>{});var U8e=h(()=>{});var $8e=h(()=>{});var H8e=h(()=>{YGe()});var W8e=h(()=>{});var j8e=h(()=>{});var VO=h(()=>{T8e();$9e();D8e();v8e();sze();U9e();Q8e();_8e();O8e();P8e();M8e();F8e();$8e();dze();B8e();H8e();pze();W8e();Uue();j8e();L9e()});var q8e=h(()=>{});var G8e=h(()=>{});var z8e=h(()=>{});var V8e=h(()=>{});var Y8e=h(()=>{});var J8e=h(()=>{});var K8e,_Xt,BXt,Z8e=h(()=>{nr();N5();zu();Me();K8e=pOe,_Xt={[K8e]:K8e,get withRequirements(){let e=this;return ZT(t=>BXt(e.steps.map(r=>({...r,provide:sX(r.provide)?sy(r.provide,iD(t)):r.provide}))))},pipe(){return Z(this,arguments)}},BXt=e=>{let t=Object.create(_Xt);return t.steps=e,t}});var $ue,Fsn,DXt,X8e=h(()=>{mt();ir();ht();Me();$ue="~effect/Graph",Fsn={[$ue]:$ue,[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[Ce](){return this.toJSON()},[me](e){if(DXt(e)){if(this.nodes.size!==e.nodes.size||this.edges.size!==e.edges.size||this.type!==e.type)return!1;for(let[t,r]of this.nodes){if(!e.nodes.has(t))return!1;let n=e.nodes.get(t);if(!ce(r,n))return!1}for(let[t,r]of this.edges){if(!e.edges.has(t))return!1;let n=e.edges.get(t);if(!ce(r,n))return!1}return!0}return!1},[he](){let e=Lt("Graph");e=e^Lt(this.type),e=e^hu(this.nodes.size),e=e^hu(this.edges.size);for(let[t,r]of this.nodes)e=e^ae(t)+ae(r);for(let[t,r]of this.edges)e=e^ae(t)+ae(r);return e},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return Fe(this)},pipe(){return Z(this,arguments)}},DXt=e=>typeof e=="object"&&e!==null&&$ue in e});var e5e=h(()=>{});var t5e=h(()=>{});var r5e=h(()=>{});var n5e=h(()=>{});var o5e=h(()=>{});var i5e=h(()=>{});var s5e=h(()=>{});var a5e=h(()=>{});var c5e=h(()=>{});var u5e=h(()=>{});var l5e=h(()=>{});var d5e=h(()=>{});var f5e=h(()=>{});var p5e=h(()=>{});var m5e=h(()=>{});var h5e=h(()=>{});var g5e=h(()=>{});var A5e=h(()=>{});var y5e=h(()=>{});var x5e=h(()=>{});var E5e=h(()=>{});var b5e=h(()=>{});var S5e=h(()=>{});var C5e=h(()=>{});var w5e=h(()=>{});var I5e=h(()=>{});var k5e=h(()=>{});var v5e=h(()=>{});var R5e=h(()=>{});var _5e=h(()=>{});var B5e=h(()=>{});var T5e,Wsn,l7t,D5e=h(()=>{mt();oe();ir();ht();Me();ct();T5e=Symbol.for("effect/SortedMap"),Wsn={[T5e]:{_K:e=>e,_V:e=>e},[he](){return C(ae(this.tree),we(ae("effect/SortedMap")),We(this))},[me](e){return l7t(e)&&ce(this.tree,e.tree)},[Symbol.iterator](){return this.tree[Symbol.iterator]()},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"SortedMap",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},l7t=e=>se(e,T5e)});var Q5e=h(()=>{});var f7t,O5e,N5e=h(()=>{Me();wd();f7t={_R:e=>e,_E:e=>e,_A:e=>e},O5e=class{[B7]=f7t;pipe(){return Z(this,arguments)}get channel(){return IMe(this.toStream())}}});var P5e,Gsn,M5e=h(()=>{Me();bI();P5e=Symbol.for("effect/Subscribable"),Gsn={[Na]:Na,[P5e]:P5e,pipe(){return Z(this,arguments)}}});var F5e=h(()=>{});var L5e=h(()=>{});var A7t,U5e,$5e=h(()=>{vt();OI();A7t=WA,U5e=class{onStart(t,r,n,o){}onEnd(t,r){}onEffect(t,r){}onSuspend(t){}onResume(t){}map(t){return new $A(this,te(this.value,t))}zip(t){return new HA(this,t)}onRun(t,r){return t()}[A7t]=mb}});var H5e=h(()=>{});var W5e=h(()=>{});var j5e=h(()=>{});var q5e=h(()=>{});var G5e=h(()=>{});var z5e=h(()=>{});var V5e=h(()=>{});var Y5e=h(()=>{});var J5e=h(()=>{});var K5e=h(()=>{});var Z5e=h(()=>{});var X5e=h(()=>{});var eXe,tXe,Hue,T7t,D7t,Q7t,rXe,Wue=h(()=>{vr();Ei();mt();oe();ir();gw();ct();eXe="effect/TestAnnotation",tXe=Symbol.for(eXe),Hue=class{identifier;initial;combine;[tXe]={_A:t=>t};constructor(t,r,n){this.identifier=t,this.initial=r,this.combine=n}[he](){return C(ae(eXe),we(ae(this.identifier)),We(this))}[me](t){return T7t(t)&&this.identifier===t.identifier}},T7t=e=>se(e,tXe),D7t=(e,t,r)=>new Hue(e,t,r),Q7t=(e,t)=>{if(xr(e)&&xr(t))return Re(e.left+t.left);if(ii(e)&&ii(t))return Le(C(e.right,Ir(t.right)));if(ii(e)&&xr(t)||xr(e)&&ii(t))return t;throw new Error(Fl("TestAnnotation.compose"))},rXe=D7t("fibers",Re(0),Q7t)});var oXe,jue,O7t,N7t,P7t,iXe,sXe,que=h(()=>{oe();kf();oXe=Symbol.for("effect/TestAnnotationMap"),jue=class{map;[oXe]=oXe;constructor(t){this.map=t}},O7t=e=>new jue(e),N7t=x(3,(e,t,r)=>O7t(ko(e.map,t,r))),P7t=x(3,(e,t,r)=>{let n=t.initial;return f3(e.map,t)&&(n=d3(e.map,t)),N7t(e,t,r(n))}),iXe=x(2,(e,t)=>f3(e.map,t)?d3(e.map,t):t.initial),sXe=x(3,(e,t,r)=>P7t(e,t,n=>t.combine(n,r)))});var cXe,uXe,lXe=h(()=>{wr();mt();oe();$f();vt();tT();Kl();NA();AU();Wue();que();cXe=Symbol.for("effect/TestAnnotations"),uXe=class{ref;[cXe]=cXe;constructor(t){this.ref=t}get(t){return te(Sc(this.ref),iXe(t))}annotate(t,r){return OA(this.ref,sXe(t,r))}get supervisedFibers(){return vI(t=>O(this.get(rXe),r=>{switch(r._tag){case"Left":return M(dT(XB));case"Right":return C(r.right,Wo(n=>V(()=>Qr(n))),te(yu(dT(XB),(n,o)=>I_e(n,o))),te(C_e(n=>!ce(n.id(),t.id))))}}))}}});var dXe,fXe,F7t,pXe,mXe,hXe,gXe,AXe,yXe=h(()=>{dXe="Start",fXe="Pending",F7t="Done",pXe={_tag:dXe},mXe=e=>({_tag:fXe,fiber:e}),hXe={_tag:F7t},gXe=e=>e._tag===dXe,AXe=e=>e._tag===fXe});var U7t,xXe,$7t,EXe,Gue,zue,bXe,SXe=h(()=>{U7t="Start",xXe="Pending",$7t="Done",EXe=e=>({_tag:xXe,fiber:e}),Gue={_tag:$7t},zue=e=>e._tag===U7t,bXe=e=>e._tag===xXe});var CXe,wXe,IXe=h(()=>{sr();vt();Mf();CXe=Symbol.for("effect/TestLive"),wXe=class{services;[CXe]=CXe;constructor(t){this.services=t}provide(t){return no(mn,wo(this.services))(t)}}});var Vue,j7t,q7t,kXe,vXe=h(()=>{vr();Ws();mt();BB();oe();kf();JE();$f();vt();La();SI();D8();yXe();SXe();Lm();it();bm();Vue=(e,t)=>({instant:e,sleeps:t}),j7t="Warning: A test is using time, but is not advancing the test clock, which may result in the test hanging. Use TestClock.adjust to manually advance the time.",q7t="Warning: A test is advancing the test clock, but a fiber is not suspending, which may result in the test hanging. Use TestAspect.diagnose to identity the fiber that is not suspending.",kXe=class{clockState;live;annotations;warningState;suspendedWarningState;[YE]=YE;constructor(t,r,n,o,i){this.clockState=t,this.live=r,this.annotations=n,this.warningState=o,this.suspendedWarningState=i,this.currentTimeMillis=te(io(this.clockState),s=>s.instant),this.currentTimeNanos=te(io(this.clockState),s=>BigInt(s.instant*1e6))}unsafeCurrentTimeMillis(){return F0e(this.clockState).instant}unsafeCurrentTimeNanos(){return BigInt(Math.floor(this.unsafeCurrentTimeMillis()*1e6))}currentTimeMillis;currentTimeNanos;get save(){return te(io(this.clockState),t=>Pa(this.clockState,t))}setTime(t){return je(this.warningDone(),this.run(()=>t))}sleep(t){let r=At(t);return O(Ci(),n=>C(nb(this.clockState,o=>{let i=o.instant+Io(r);return i>o.instant?[!0,Vue(o.instant,C(o.sleeps,fr([i,n])))]:[!1,o]}),O(o=>o?C(this.warningStart(),je(Cn(n))):C(Mm(n,void 0),$r))))}get sleeps(){return te(io(this.clockState),t=>xf(t.sleeps,r=>r[0]))}adjust(t){let r=At(t);return je(this.warningDone(),this.run(n=>n+Io(r)))}adjustWith(t){let r=At(t);return n=>vU(n,this.adjust(r),{concurrent:!0})}supervisedFibers(){return this.annotations.supervisedFibers}freeze(){return O(this.supervisedFibers(),t=>C(t,G1(If(),(r,n)=>C(n.status,O(o=>hI(o)?M(ko(r,n.id(),o)):y1(o)?M(ko(r,n.id(),o)):ut(void 0))))))}warningStart(){return IT(this.warningState,t=>zue(t)?H(C(this.live.provide(C(jB(j7t),FB(sA(5)))),Qa,Ou,te(r=>EXe(r)))):W())}warningDone(){return IT(this.warningState,t=>zue(t)?H(M(Gue)):bXe(t)?H(C(gc(t.fiber),Zt(Gue))):W())}yieldTimer=bi(t=>{let r=setTimeout(()=>{t(Ue)},0);return V(()=>clearTimeout(r))});suspended(){return C(this.freeze(),Nm(C(this.yieldTimer,je(this.freeze()))),O(([t,r])=>ce(t,r)?M(t):ut(void 0)))}awaitSuspended(){return C(this.suspendedWarningStart(),je(C(this.suspended(),Zi(C(this.yieldTimer,je(this.suspended())),ce),H1(be,Ai),$B)),je(this.suspendedWarningDone()))}suspendedWarningStart(){return IT(this.suspendedWarningState,t=>gXe(t)?H(C(this.live.provide(C(jB(q7t),je(Pa(this.suspendedWarningState,hXe)),FB(sA(5)))),Qa,Ou,te(r=>mXe(r)))):W())}suspendedWarningDone(){return IT(this.suspendedWarningState,t=>AXe(t)?H(C(gc(t.fiber),Zt(pXe))):W())}run(t){return C(this.awaitSuspended(),je(C(nb(this.clockState,r=>{let n=t(r.instant),o=C(r.sleeps,hbe(C(oo,yf(i=>i[0]))));if(kr(o)){let[i,s]=Gt(o);if(i<=n)return[H([n,s]),Vue(i,Ur(o))]}return[W(),Vue(n,r.sleeps)]}),O(r=>{switch(r._tag){case"None":return Ue;case"Some":{let[n,o]=r.value;return C(Mm(o,void 0),je(ku()),je(this.run(()=>n)))}}}))))}}});var RXe=h(()=>{});var _Xe,BXe,TXe=h(()=>{vt();_Xe=Symbol.for("effect/TestSized"),BXe=class{fiberRef;[_Xe]=_Xe;constructor(t){this.fiberRef=t}get size(){return Xi(this.fiberRef)}withSize(t){return r=>tn(this.fiberRef,t)(r)}}});var DXe=h(()=>{});var QXe=h(()=>{});var OXe=h(()=>{});var NXe=h(()=>{});var PXe=h(()=>{});var MXe=h(()=>{});var Dn=h(()=>{q8e();wr();MMe();FMe();TK();RW();G8e();Vs();aS();z8e();vr();II();jMe();LMe();Bqe();V8e();Y8e();sr();t5();lh();qMe();J8e();$u();q9();Ws();nr();id();Ei();GMe();mt();mm();Z8e();a1();Ro();vUe();WI();$qe();Zl();Qqe();g0();mI();m1();_ne();BB();oe();yn();X8e();e5e();t5e();ir();kf();Nqe();dc();ht();x_();wWe();r5e();zu();n5e();Gw();E1();wZ();L8e();EQ();o5e();i5e();RPe();s5e();a5e();Fqe();c5e();u5e();l5e();d5e();f5e();p5e();m5e();h5e();g5e();dZ();A5e();iT();Mqe();F5();L$();Kl();y5e();Lm();it();bm();x5e();aW();E5e();Me();OWe();ct();Lqe();zWe();PNe();a2();h$();b5e();_qe();d7();bI();E_();M9();Tre();NA();KL();S5e();G5();C5e();w5e();I5e();Y2();Rqe();xL();k5e();lX();FU();QU();xT();PA();X0();YD();ah();v5e();R5e();_5e();B5e();rk();D5e();AU();wd();Q5e();PPe();N5e();J8();uW();M5e();L5e();$5e();H5e();F5e();W5e();j5e();q5e();G5e();zPe();VPe();z5e();V5e();Y5e();J5e();K5e();Z5e();X5e();Wue();que();lXe();vXe();RXe();QXe();IXe();DXe();TXe();MB();OXe();c6();NXe();tWe();PXe();MXe();mu()});var FXe=h(()=>{});var LXe=h(()=>{});var UXe=h(()=>{});var $Xe,ner,Bp,HXe=h(()=>{sr();it();Me();wQ();Hne();$Xe=Symbol.for("@effect/platform/HttpApiEndpoint"),ner={[$Xe]:$Xe,pipe(){return Z(this,arguments)},addSuccess(e,t){return e=t?.status?e.annotations(Ty({status:t.status})):e,Bp({...this,successSchema:this.successSchema===nWe?e:Td(this.successSchema,e)})},addError(e,t){return Bp({...this,errorSchema:Td(this.errorSchema,t?.status?e.annotations(Ty({status:t.status})):e)})},setPayload(e){return Bp({...this,payloadSchema:H(e)})},setPath(e){return Bp({...this,pathSchema:H(e)})},setUrlParams(e){return Bp({...this,urlParamsSchema:H(e)})},setHeaders(e){return Bp({...this,headersSchema:H(e)})},prefix(e){return Bp({...this,path:SWe(this.path,e)})},middleware(e){return Bp({...this,errorSchema:Td(this.errorSchema,e.failure),middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return Bp({...this,annotations:zt(this.annotations,e,t)})},annotateContext(e){return Bp({...this,annotations:wo(this.annotations,e)})}},Bp=e=>Object.assign(Object.create(ner),e)});var WXe,ier,og,jXe=h(()=>{sr();Me();E_();wQ();WXe=Symbol.for("@effect/platform/HttpApiGroup"),ier={[WXe]:WXe,add(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:{...this.endpoints,[e.name]:e},errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},addError(e,t){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,errorSchema:Td(this.errorSchema,t?.status?e.annotations(Ty({status:t.status})):e),annotations:this.annotations,middlewares:this.middlewares})},prefix(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:Sm(this.endpoints,t=>t.prefix(e)),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,errorSchema:Td(this.errorSchema,e.failure),annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},middlewareEndpoints(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:Sm(this.endpoints,t=>t.middleware(e)),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},annotateContext(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,errorSchema:this.errorSchema,annotations:wo(this.annotations,e),middlewares:this.middlewares})},annotate(e,t){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,errorSchema:this.errorSchema,annotations:zt(this.annotations,e,t),middlewares:this.middlewares})},annotateEndpointsContext(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:Sm(this.endpoints,t=>t.annotateContext(e)),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},annotateEndpoints(e,t){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:Sm(this.endpoints,r=>r.annotate(e,t)),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},pipe(){return Z(this,arguments)}},og=e=>{function t(){}return Object.setPrototypeOf(t,ier),Object.assign(t,e)}});var qXe=h(()=>{});var GXe,lan,zXe=h(()=>{Me();GXe=Symbol.for("@effect/platform/HttpApiSecurity"),lan={[GXe]:GXe,pipe(){return Z(this,arguments)}}});var VXe=h(()=>{});var YXe=h(()=>{});var JXe,KXe,ZXe=h(()=>{lh();woe();woe();JXe=Symbol.for("@effect/platform/MsgPack/MsgPackError"),KXe=class extends uh("MsgPackError"){[JXe]=JXe;get message(){return this.reason}}});var XXe=h(()=>{});var e7e=h(()=>{});var t7e=h(()=>{});var r7e=h(()=>{});var rC=h(()=>{FXe();Que();Nue();IW();zoe();Th();mWe();LXe();AQ();vW();sWe();RWe();UXe();HXe();oWe();jXe();aWe();qXe();wQ();zXe();VXe();dWe();H2e();L2e();u2e();U2e();Tqe();QW();TWe();$2e();Lne();YXe();R8e();Hne();hWe();FW();Tne();PW();NW();P2e();N8e();ZXe();vne();XXe();kWe();IWe();zW();e7e();t7e();U8e();PHe();kqe();W2e();Lue();qne();r7e();nne();Yne();nj();vqe()});import{resolve as n7e}from"node:path";var nC,ax,oC=h(()=>{"use strict";rC();Dn();nC=class extends pr.TaggedError("CwdError"){},ax=e=>S.gen(function*(){let t=e!==void 0?n7e(process.cwd(),e):n7e(process.cwd());return(yield*(yield*mo.FileSystem).stat(t).pipe(S.mapError(()=>new nC({message:`cwd does not exist: ${t}`,cwd:t})))).type!=="Directory"?yield*new nC({message:`cwd is not a directory: ${t}`,cwd:t}):t})});var av,OG=h(()=>{"use strict";av=async e=>{let{provider:t,sandboxTag:r,hostRepoDir:n,resumeSession:o}=e;if(!t.sessionStorage)throw new Error(`${t.name} does not support resumeSession`);if(r==="none"){let s=await t.sessionStorage.findByIdOnHost(o);if(!s.path)throw new Error(`resumeSession "${o}" not found under ${s.searchedRoot}`);return}if(!await t.sessionStorage.existsOnHost(n,o)){let s=t.sessionStorage.hostSessionFilePath(n,o);throw new Error(s?`resumeSession "${o}" not found: expected session file at ${s}`:`resumeSession "${o}" not found`)}}});var o7e,i7e,s7e,a7e=h(()=>{o7e=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let r=0;for(e.lastIndex=0;e.test(t);)r+=1;return t.length-r}})(),i7e=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,s7e=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141});var ger,Aer,c7e,yer,u7e,xer,Eer,ber,l7e,d7e,f7e=h(()=>{a7e();ger=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Aer=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,c7e=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,yer=/\t{1,1000}/y,u7e=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),xer=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Eer=new RegExp("\\p{M}+","gu"),ber={limit:1/0,ellipsis:""},l7e=(e,t={},r={})=>{let n=t.limit??1/0,o=t.ellipsis??"",i=t?.ellipsisWidth??(o?l7e(o,ber,r).width:0),s=0,a=r.controlWidth??0,c=r.tabWidth??8,u=r.emojiWidth??2,l=2,d=r.regularWidth??1,f=r.wideWidth??l,p=[[xer,d],[ger,s],[Aer,a],[yer,c],[u7e,u],[c7e,f]],m=0,g=0,A=e.length,E=0,y=!1,b=A,w=Math.max(0,n-i),I=0,v=0,k=0,R=0;e:for(;;){if(v>I||g>=A&&g>m){let B=e.slice(I,v)||e.slice(m,g);E=0;for(let L of B.replaceAll(Eer,"")){let D=L.codePointAt(0)||0;if(i7e(D)?R=l:s7e(D)?R=f:R=d,k+R>w&&(b=Math.min(b,Math.max(I,m)+E)),k+R>n){y=!0;break e}E+=L.length,k+=R}I=v=0}if(g>=A)break e;for(let B=0,L=p.length;B<L;B++){let[D,ee]=p[B];if(D.lastIndex=g,D.test(e)){if(E=D===c7e?o7e(e.slice(g,D.lastIndex)):D===u7e?1:D.lastIndex-g,R=E*ee,k+R>w&&(b=Math.min(b,g+Math.floor((w-k)/ee))),k+R>n){y=!0;break e}k+=R,I=m,v=g,g=m=D.lastIndex;continue e}}g+=1}return{width:y?w:k,index:y?b:A,truncated:y,ellipsed:y&&n>=i}},d7e=l7e});var Ser,Cer,da,Yue=h(()=>{f7e();Ser={limit:1/0,ellipsis:"",ellipsisWidth:0},Cer=(e,t={})=>d7e(e,Ser,t).width,da=Cer});function cx(e,t,r){return String(e).normalize().split(Rer).map(n=>ver(n,t,r)).join(`
212
+ ${i}`:o.stack}Qe.exports.fetch=function(t,r=void 0){return y5t(t,r).catch(n=>{throw Q9e?M9e(n,Q9e):n&&typeof n=="object"&&Error.captureStackTrace(n,Qe.exports.fetch),n})};Qe.exports.Headers=zS().Headers;Qe.exports.Response=DO().Response;Qe.exports.Request=Vk().Request;Qe.exports.FormData=Xj().FormData;var{setGlobalOrigin:x5t,getGlobalOrigin:E5t}=nse();Qe.exports.setGlobalOrigin=x5t;Qe.exports.getGlobalOrigin=E5t;var{CacheStorage:b5t}=AZe(),{kConstruct:S5t}=Kr();Qe.exports.caches=new b5t(S5t);var{deleteCookie:C5t,getCookies:w5t,getSetCookies:I5t,setCookie:k5t,parseCookie:v5t}=BZe();Qe.exports.deleteCookie=C5t;Qe.exports.getCookies=w5t;Qe.exports.getSetCookies=I5t;Qe.exports.setCookie=k5t;Qe.exports.parseCookie=v5t;var{parseMIMEType:R5t,serializeAMimeType:_5t}=dl();Qe.exports.parseMIMEType=R5t;Qe.exports.serializeAMimeType=_5t;var{CloseEvent:B5t,ErrorEvent:T5t,MessageEvent:D5t}=AG(),{WebSocket:Q5t,ping:O5t}=l9e();Qe.exports.WebSocket=Q5t;Qe.exports.CloseEvent=B5t;Qe.exports.ErrorEvent=T5t;Qe.exports.MessageEvent=D5t;Qe.exports.ping=O5t;Qe.exports.WebSocketStream=y9e().WebSocketStream;Qe.exports.WebSocketError=Eue().WebSocketError;Qe.exports.request=jO(iv.request);Qe.exports.stream=jO(iv.stream);Qe.exports.pipeline=jO(iv.pipeline);Qe.exports.connect=jO(iv.connect);Qe.exports.upgrade=jO(iv.upgrade);Qe.exports.MockClient=s5t;Qe.exports.MockCallHistory=a5t;Qe.exports.MockCallHistoryLog=c5t;Qe.exports.MockPool=l5t;Qe.exports.MockAgent=u5t;Qe.exports.SnapshotAgent=d5t;Qe.exports.mockErrors=f5t;var{EventSource:N5t}=D9e();Qe.exports.EventSource=N5t;function P5t(){globalThis.fetch=Qe.exports.fetch,globalThis.Headers=Qe.exports.Headers,globalThis.Response=Qe.exports.Response,globalThis.Request=Qe.exports.Request,globalThis.FormData=Qe.exports.FormData,globalThis.WebSocket=Qe.exports.WebSocket,globalThis.CloseEvent=Qe.exports.CloseEvent,globalThis.ErrorEvent=Qe.exports.ErrorEvent,globalThis.MessageEvent=Qe.exports.MessageEvent,globalThis.EventSource=Qe.exports.EventSource}Qe.exports.install=P5t});var sv={};tr(sv,{default:()=>F9e.default});var F9e,L9e=h(()=>{F9e=su(kue(),1);AM(sv,su(kue(),1))});var U9e=h(()=>{});var $9e=h(()=>{});var H9e=h(()=>{});var vue,W9e,j9e,q9e,G9e,z9e,L5t,V9e=h(()=>{RW();vr();sr();nr();oe();rk();wd();vue=Symbol.for("@effect/platform/CommandExecutor"),W9e=Symbol.for("@effect/platform/Process"),j9e=dQ(),q9e=dQ(),G9e=Jt("@effect/platform/CommandExecutor"),z9e=e=>{let t=n=>fy(De(e(n),o=>o.stdout)),r=(n,o)=>{let i=new TextDecoder(o);return DMe(vMe(t(n),xf(s=>i.decode(s))))};return{[vue]:vue,start:e,exitCode:n=>Ad(Ee(e(n),o=>o.exitCode)),stream:t,string:(n,o="utf-8")=>{let i=new TextDecoder(o);return C(e(n),Ee(s=>_0(s.stdout,L5t)),De(s=>i.decode(s)),Ad)},lines:(n,o="utf-8")=>C(r(n,o),BMe,De(mbe)),streamLines:r}},L5t=E2e(new Uint8Array,(e,t)=>I_(t,e,(r,n)=>{let o=new Uint8Array(r.length+n.length);return o.set(r),o.set(n,r.length),o}))});var Rue,Y9e,_ue,J9e,$5t,H5t,W5t,j5t,Bue,K9e=h(()=>{vr();oe();ht();Me();Rue=Symbol.for("@effect/platform/Command"),Y9e=e=>Array.from(_ue(e)),_ue=e=>{switch(e._tag){case"StandardCommand":return Dt(e);case"PipedCommand":return Ir(_ue(e.left),_ue(e.right))}},J9e={[Rue]:Rue,pipe(){return Z(this,arguments)},...Am},$5t={...J9e,_tag:"StandardCommand",toJSON(){return{_id:"@effect/platform/Command",_tag:this._tag,command:this.command,args:this.args,env:Object.fromEntries(this.env),cwd:this.cwd.toJSON(),shell:this.shell,gid:this.gid.toJSON(),uid:this.uid.toJSON()}}},H5t=e=>Object.assign(Object.create($5t),e),W5t={...J9e,_tag:"PipedCommand",toJSON(){return{_id:"@effect/platform/Command",_tag:this._tag,left:this.left.toJSON(),right:this.right.toJSON()}}},j5t=e=>Object.assign(Object.create(W5t),e),Bue=x(2,(e,t)=>{switch(e._tag){case"StandardCommand":return H5t({...e,stdin:t});case"PipedCommand":return j5t({...e,left:Bue(e.left,t)})}})});var Tue,Due,Que=h(()=>{K9e();Tue=Y9e,Due=Bue});var X9e,Oue,e8e,t8e,r8e,Nue=h(()=>{V9e();X9e=G9e,Oue=W9e,e8e=j9e,t8e=q9e,r8e=z9e});import*as TG from"node:child_process";var G5t,o8e,qO,sx,z5t,GO,i8e,s8e=h(()=>{Que();Nue();AQ();$u();nr();oe();ht();zu();it();rk();wd();Voe();uze();eie();G5t=e=>typeof e=="string"?e:"pipe",o8e=e=>typeof e=="string"?e:"pipe",qO=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),sx=(e,t,r)=>{let n=Tue(r).reduce((o,i)=>{let s=`${i.command} ${i.args.join(" ")}`;return o.length===0?s:`${o} | ${s}`},"");return Jr("Command",e)(t,[n])},z5t={[Oue]:Oue,...Am,toJSON(){return{_id:"@effect/platform/CommandExecutor/Process",pid:this.pid}}},GO=e=>t=>{switch(t._tag){case"StandardCommand":{let r=Ee(rn(),i=>Zs(s=>{let a=TG.spawn(t.command,t.args,{stdio:[G5t(t.stdin),o8e(t.stdout),o8e(t.stderr)],cwd:Nt(t.cwd,hw),shell:t.shell,env:{...process.env,...Object.fromEntries(t.env)},detached:process.platform!=="win32"});return a.on("error",c=>{s($e(sx("spawn",c,t)))}),a.on("exit",(...c)=>{kc(i,nt(c))}),a.on("spawn",()=>{s(nt([a,i]))}),ot(()=>{a.kill("SIGTERM")})})),n=process.platform==="win32"?(i,s)=>Zs(a=>{TG.exec(`taskkill /pid ${i.pid} /T /F`,c=>{a(c?$e(sx("kill",qO(c),t)):ve)})}):(i,s)=>Wu({try:()=>process.kill(-i.pid,s),catch:a=>sx("kill",qO(a),t)}),o=(i,s)=>Pt(()=>i.kill(s)?ve:$e(sx("kill",new globalThis.Error("Failed to kill process"),t)));return C(wt(t.cwd,{onNone:()=>ve,onSome:i=>e.access(i)}),Wt(zo(r,([i,s])=>Ee(ph(s),a=>a?Ee(Ht(s),([c])=>c!==0&&c!==null?n(i,"SIGTERM").pipe(a0):ve):n(i,"SIGTERM").pipe(nD(()=>o(i,"SIGTERM")),Wt(Ht(s)),a0)))),De(([i,s])=>{let a=y2e;i.stdin!==null&&(a=cze(()=>i.stdin,m=>sx("toWritable",qO(m),t)));let c=Ee(Ht(s),([m,g])=>m!==null?nt(e8e(m)):$e(sx("exitCode",new globalThis.Error(`Process interrupted due to receipt of signal: ${g}`),t))),u=K5(ph(s)),l=(m="SIGTERM")=>n(i,m).pipe(nD(()=>o(i,m)),Wt(gd(Ht(s)))),d=t8e(i.pid),f=Xoe(()=>i.stderr,m=>sx("fromReadable(stderr)",qO(m),t)),p=Xoe(()=>i.stdout,m=>sx("fromReadable(stdout)",qO(m),t));return typeof t.stdout!="string"&&(p=QMe(p,t.stdout)),Object.assign(Object.create(z5t),{pid:d,exitCode:c,isRunning:u,kill:l,stdin:a,stderr:f,stdout:p})}),typeof t.stdin=="string"?be:Ri(i=>Rb(_0(t.stdin,i.stdin))))}case"PipedCommand":{let r=Tue(t);if(r.length===1)return C(r[0],GO(e));let n=r[0],o=r.slice(1),i=o.slice(0,o.length-1),s=o[o.length-1],a=i.reduce((c,u)=>C(Due(u,c),GO(e),De(l=>l.stdout),fy),C(GO(e)(n),De(c=>c.stdout),fy));return C(Due(s,a),GO(e))}}},i8e=iy(X9e,C(By,De(e=>r8e(GO(e)))))});var a8e,c8e=h(()=>{s8e();a8e=i8e});import*as zO from"node:path";import*as DG from"node:url";var Pue,Mue,J5t,K5t,u8e,l8e=h(()=>{Th();zW();nr();zu();Pue=e=>Wu({try:()=>DG.fileURLToPath(e),catch:t=>new _s({module:"Path",method:"fromFileUrl",description:`Invalid file URL: ${e}`,cause:t})}),Mue=e=>Wu({try:()=>DG.pathToFileURL(e),catch:t=>new _s({module:"Path",method:"toFileUrl",description:`Invalid path: ${e}`,cause:t})}),J5t=Ed(Oh,Oh.of({[uS]:uS,...zO.posix,fromFileUrl:Pue,toFileUrl:Mue})),K5t=Ed(Oh,Oh.of({[uS]:uS,...zO.win32,fromFileUrl:Pue,toFileUrl:Mue})),u8e=Ed(Oh,Oh.of({[uS]:uS,...zO,fromFileUrl:Pue,toFileUrl:Mue}))});var d8e,f8e=h(()=>{l8e();d8e=u8e});var p8e,m8e=h(()=>{sr();p8e=Jt("@effect/platform/Terminal")});var Fue,Lue=h(()=>{m8e();Fue=p8e});import*as QG from"node:readline";var g8e,A8e,y8e,x8e=h(()=>{Th();Lue();nr();Ro();zu();EQ();it();d7();g8e=e=>e.key.ctrl&&(e.key.name==="c"||e.key.name==="d"),A8e=Z$(function*(e=g8e){let t=process.stdin,r=process.stdout,n=yield*DPe({acquire:zo(ot(()=>{let l=QG.createInterface({input:t,escapeCodeTimeout:50});return QG.emitKeypressEvents(t,l),t.isTTY&&t.setRawMode(!0),l}),l=>ot(()=>{t.isTTY&&t.setRawMode(!1),l.close()}))}),o=ot(()=>r.columns??0),i=ot(()=>r.rows??0),s=ot(()=>!!r.isTTY),a=Go(function*(){yield*l7(n);let l=yield*ok(),d=(f,p)=>{let m={input:en(f),key:{name:p.name??"",ctrl:!!p.ctrl,meta:!!p.meta,shift:!!p.shift}};l.unsafeOffer(m),e(m)&&l.unsafeDone(wc)};return yield*YT(()=>ot(()=>t.off("keypress",d))),t.on("keypress",d),l}),c=l7(n).pipe(Ee(l=>Zs(d=>{let f=p=>d(nt(p));return l.once("line",f),ot(()=>l.off("line",f))})),Ad),u=l=>hd(Zs(d=>{r.write(l,f=>d(f?$e(new _s({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:f})):ve))}));return Fue.of({columns:o,rows:i,isTTY:s,readInput:a,readLine:c,display:u})}),y8e=X$(Fue,A8e(g8e))});var E8e,b8e=h(()=>{x8e();E8e=y8e});var nXt,S8e,C8e,w8e=h(()=>{Yne();nj();$u();nr();Ro();zu();ah();nXt=WWe()({setup({scope:e,worker:t}){return Ee(rn(),r=>{let n="postMessage"in t?{postMessage(o,i){t.postMessage(o,i)},kill:()=>t.terminate(),worker:t}:{postMessage(o,i){t.send(o)},kill:()=>t.kill("SIGKILL"),worker:t};return t.on("exit",()=>{kc(r,wc)}),ju(sh(e,Pt(()=>(n.postMessage([1]),Ht(r))).pipe(Bo,X5(5e3),Hu(()=>ot(()=>n.kill())))),n)})},listen({deferred:e,emit:t,port:r}){return r.worker.on("message",n=>{t(n)}),r.worker.on("messageerror",n=>{kc(e,new cp({reason:"decode",cause:n}))}),r.worker.on("error",n=>{kc(e,new cp({reason:"unknown",cause:n}))}),r.worker.on("exit",n=>{kc(e,new cp({reason:"unknown",cause:new Error(`exited with code ${n}`)}))}),ve}}),S8e=Ed(jWe,nXt),C8e=sy(qWe,S8e)});var I8e,Uue=h(()=>{w8e();I8e=C8e});var us={};tr(us,{layer:()=>iXt});var iXt,v8e=h(()=>{c8e();Zoe();f8e();b8e();oe();zu();Uue();iXt=C(aX(d8e,a8e,E8e,I8e),sD(Qj))});var R8e=h(()=>{});var _8e=h(()=>{});var B8e=h(()=>{Goe();Hqe()});var T8e=h(()=>{});var D8e=h(()=>{});var Q8e=h(()=>{});var O8e=h(()=>{});var N8e=h(()=>{});var P8e=h(()=>{});var M8e=h(()=>{H9e()});var F8e=h(()=>{});var L8e=h(()=>{});var U8e=h(()=>{});var $8e=h(()=>{});var H8e=h(()=>{YGe()});var W8e=h(()=>{});var j8e=h(()=>{});var VO=h(()=>{T8e();$9e();D8e();v8e();sze();U9e();Q8e();_8e();O8e();P8e();M8e();F8e();$8e();dze();B8e();H8e();pze();W8e();Uue();j8e();L9e()});var q8e=h(()=>{});var G8e=h(()=>{});var z8e=h(()=>{});var V8e=h(()=>{});var Y8e=h(()=>{});var J8e=h(()=>{});var K8e,_Xt,BXt,Z8e=h(()=>{nr();N5();zu();Me();K8e=pOe,_Xt={[K8e]:K8e,get withRequirements(){let e=this;return ZT(t=>BXt(e.steps.map(r=>({...r,provide:sX(r.provide)?sy(r.provide,iD(t)):r.provide}))))},pipe(){return Z(this,arguments)}},BXt=e=>{let t=Object.create(_Xt);return t.steps=e,t}});var $ue,Fsn,DXt,X8e=h(()=>{mt();ir();ht();Me();$ue="~effect/Graph",Fsn={[$ue]:$ue,[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[Ce](){return this.toJSON()},[me](e){if(DXt(e)){if(this.nodes.size!==e.nodes.size||this.edges.size!==e.edges.size||this.type!==e.type)return!1;for(let[t,r]of this.nodes){if(!e.nodes.has(t))return!1;let n=e.nodes.get(t);if(!ce(r,n))return!1}for(let[t,r]of this.edges){if(!e.edges.has(t))return!1;let n=e.edges.get(t);if(!ce(r,n))return!1}return!0}return!1},[he](){let e=Lt("Graph");e=e^Lt(this.type),e=e^hu(this.nodes.size),e=e^hu(this.edges.size);for(let[t,r]of this.nodes)e=e^ae(t)+ae(r);for(let[t,r]of this.edges)e=e^ae(t)+ae(r);return e},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return Fe(this)},pipe(){return Z(this,arguments)}},DXt=e=>typeof e=="object"&&e!==null&&$ue in e});var e5e=h(()=>{});var t5e=h(()=>{});var r5e=h(()=>{});var n5e=h(()=>{});var o5e=h(()=>{});var i5e=h(()=>{});var s5e=h(()=>{});var a5e=h(()=>{});var c5e=h(()=>{});var u5e=h(()=>{});var l5e=h(()=>{});var d5e=h(()=>{});var f5e=h(()=>{});var p5e=h(()=>{});var m5e=h(()=>{});var h5e=h(()=>{});var g5e=h(()=>{});var A5e=h(()=>{});var y5e=h(()=>{});var x5e=h(()=>{});var E5e=h(()=>{});var b5e=h(()=>{});var S5e=h(()=>{});var C5e=h(()=>{});var w5e=h(()=>{});var I5e=h(()=>{});var k5e=h(()=>{});var v5e=h(()=>{});var R5e=h(()=>{});var _5e=h(()=>{});var B5e=h(()=>{});var T5e,Wsn,l7t,D5e=h(()=>{mt();oe();ir();ht();Me();ct();T5e=Symbol.for("effect/SortedMap"),Wsn={[T5e]:{_K:e=>e,_V:e=>e},[he](){return C(ae(this.tree),we(ae("effect/SortedMap")),We(this))},[me](e){return l7t(e)&&ce(this.tree,e.tree)},[Symbol.iterator](){return this.tree[Symbol.iterator]()},toString(){return Fe(this.toJSON())},toJSON(){return{_id:"SortedMap",values:Array.from(this).map(xt)}},[Ce](){return this.toJSON()},pipe(){return Z(this,arguments)}},l7t=e=>se(e,T5e)});var Q5e=h(()=>{});var f7t,O5e,N5e=h(()=>{Me();wd();f7t={_R:e=>e,_E:e=>e,_A:e=>e},O5e=class{[B7]=f7t;pipe(){return Z(this,arguments)}get channel(){return IMe(this.toStream())}}});var P5e,Gsn,M5e=h(()=>{Me();bI();P5e=Symbol.for("effect/Subscribable"),Gsn={[Na]:Na,[P5e]:P5e,pipe(){return Z(this,arguments)}}});var F5e=h(()=>{});var L5e=h(()=>{});var A7t,U5e,$5e=h(()=>{vt();OI();A7t=WA,U5e=class{onStart(t,r,n,o){}onEnd(t,r){}onEffect(t,r){}onSuspend(t){}onResume(t){}map(t){return new $A(this,te(this.value,t))}zip(t){return new HA(this,t)}onRun(t,r){return t()}[A7t]=mb}});var H5e=h(()=>{});var W5e=h(()=>{});var j5e=h(()=>{});var q5e=h(()=>{});var G5e=h(()=>{});var z5e=h(()=>{});var V5e=h(()=>{});var Y5e=h(()=>{});var J5e=h(()=>{});var K5e=h(()=>{});var Z5e=h(()=>{});var X5e=h(()=>{});var eXe,tXe,Hue,T7t,D7t,Q7t,rXe,Wue=h(()=>{vr();bi();mt();oe();ir();gw();ct();eXe="effect/TestAnnotation",tXe=Symbol.for(eXe),Hue=class{identifier;initial;combine;[tXe]={_A:t=>t};constructor(t,r,n){this.identifier=t,this.initial=r,this.combine=n}[he](){return C(ae(eXe),we(ae(this.identifier)),We(this))}[me](t){return T7t(t)&&this.identifier===t.identifier}},T7t=e=>se(e,tXe),D7t=(e,t,r)=>new Hue(e,t,r),Q7t=(e,t)=>{if(xr(e)&&xr(t))return Re(e.left+t.left);if(si(e)&&si(t))return Le(C(e.right,Ir(t.right)));if(si(e)&&xr(t)||xr(e)&&si(t))return t;throw new Error(Fl("TestAnnotation.compose"))},rXe=D7t("fibers",Re(0),Q7t)});var oXe,jue,O7t,N7t,P7t,iXe,sXe,que=h(()=>{oe();kf();oXe=Symbol.for("effect/TestAnnotationMap"),jue=class{map;[oXe]=oXe;constructor(t){this.map=t}},O7t=e=>new jue(e),N7t=x(3,(e,t,r)=>O7t(ko(e.map,t,r))),P7t=x(3,(e,t,r)=>{let n=t.initial;return f3(e.map,t)&&(n=d3(e.map,t)),N7t(e,t,r(n))}),iXe=x(2,(e,t)=>f3(e.map,t)?d3(e.map,t):t.initial),sXe=x(3,(e,t,r)=>P7t(e,t,n=>t.combine(n,r)))});var cXe,uXe,lXe=h(()=>{wr();mt();oe();$f();vt();tT();Kl();NA();AU();Wue();que();cXe=Symbol.for("effect/TestAnnotations"),uXe=class{ref;[cXe]=cXe;constructor(t){this.ref=t}get(t){return te(Sc(this.ref),iXe(t))}annotate(t,r){return OA(this.ref,sXe(t,r))}get supervisedFibers(){return vI(t=>O(this.get(rXe),r=>{switch(r._tag){case"Left":return M(dT(XB));case"Right":return C(r.right,Wo(n=>V(()=>Qr(n))),te(yu(dT(XB),(n,o)=>I_e(n,o))),te(C_e(n=>!ce(n.id(),t.id))))}}))}}});var dXe,fXe,F7t,pXe,mXe,hXe,gXe,AXe,yXe=h(()=>{dXe="Start",fXe="Pending",F7t="Done",pXe={_tag:dXe},mXe=e=>({_tag:fXe,fiber:e}),hXe={_tag:F7t},gXe=e=>e._tag===dXe,AXe=e=>e._tag===fXe});var U7t,xXe,$7t,EXe,Gue,zue,bXe,SXe=h(()=>{U7t="Start",xXe="Pending",$7t="Done",EXe=e=>({_tag:xXe,fiber:e}),Gue={_tag:$7t},zue=e=>e._tag===U7t,bXe=e=>e._tag===xXe});var CXe,wXe,IXe=h(()=>{sr();vt();Mf();CXe=Symbol.for("effect/TestLive"),wXe=class{services;[CXe]=CXe;constructor(t){this.services=t}provide(t){return no(mn,wo(this.services))(t)}}});var Vue,j7t,q7t,kXe,vXe=h(()=>{vr();Ws();mt();BB();oe();kf();JE();$f();vt();La();SI();D8();yXe();SXe();Lm();it();bm();Vue=(e,t)=>({instant:e,sleeps:t}),j7t="Warning: A test is using time, but is not advancing the test clock, which may result in the test hanging. Use TestClock.adjust to manually advance the time.",q7t="Warning: A test is advancing the test clock, but a fiber is not suspending, which may result in the test hanging. Use TestAspect.diagnose to identity the fiber that is not suspending.",kXe=class{clockState;live;annotations;warningState;suspendedWarningState;[YE]=YE;constructor(t,r,n,o,i){this.clockState=t,this.live=r,this.annotations=n,this.warningState=o,this.suspendedWarningState=i,this.currentTimeMillis=te(io(this.clockState),s=>s.instant),this.currentTimeNanos=te(io(this.clockState),s=>BigInt(s.instant*1e6))}unsafeCurrentTimeMillis(){return F0e(this.clockState).instant}unsafeCurrentTimeNanos(){return BigInt(Math.floor(this.unsafeCurrentTimeMillis()*1e6))}currentTimeMillis;currentTimeNanos;get save(){return te(io(this.clockState),t=>Pa(this.clockState,t))}setTime(t){return je(this.warningDone(),this.run(()=>t))}sleep(t){let r=At(t);return O(wi(),n=>C(nb(this.clockState,o=>{let i=o.instant+Io(r);return i>o.instant?[!0,Vue(o.instant,C(o.sleeps,fr([i,n])))]:[!1,o]}),O(o=>o?C(this.warningStart(),je(Cn(n))):C(Mm(n,void 0),$r))))}get sleeps(){return te(io(this.clockState),t=>xf(t.sleeps,r=>r[0]))}adjust(t){let r=At(t);return je(this.warningDone(),this.run(n=>n+Io(r)))}adjustWith(t){let r=At(t);return n=>vU(n,this.adjust(r),{concurrent:!0})}supervisedFibers(){return this.annotations.supervisedFibers}freeze(){return O(this.supervisedFibers(),t=>C(t,G1(If(),(r,n)=>C(n.status,O(o=>hI(o)?M(ko(r,n.id(),o)):y1(o)?M(ko(r,n.id(),o)):ut(void 0))))))}warningStart(){return IT(this.warningState,t=>zue(t)?H(C(this.live.provide(C(jB(j7t),FB(sA(5)))),Qa,Ou,te(r=>EXe(r)))):W())}warningDone(){return IT(this.warningState,t=>zue(t)?H(M(Gue)):bXe(t)?H(C(gc(t.fiber),Zt(Gue))):W())}yieldTimer=Si(t=>{let r=setTimeout(()=>{t(Ue)},0);return V(()=>clearTimeout(r))});suspended(){return C(this.freeze(),Nm(C(this.yieldTimer,je(this.freeze()))),O(([t,r])=>ce(t,r)?M(t):ut(void 0)))}awaitSuspended(){return C(this.suspendedWarningStart(),je(C(this.suspended(),Zi(C(this.yieldTimer,je(this.suspended())),ce),H1(be,yi),$B)),je(this.suspendedWarningDone()))}suspendedWarningStart(){return IT(this.suspendedWarningState,t=>gXe(t)?H(C(this.live.provide(C(jB(q7t),je(Pa(this.suspendedWarningState,hXe)),FB(sA(5)))),Qa,Ou,te(r=>mXe(r)))):W())}suspendedWarningDone(){return IT(this.suspendedWarningState,t=>AXe(t)?H(C(gc(t.fiber),Zt(pXe))):W())}run(t){return C(this.awaitSuspended(),je(C(nb(this.clockState,r=>{let n=t(r.instant),o=C(r.sleeps,hbe(C(oo,yf(i=>i[0]))));if(kr(o)){let[i,s]=Gt(o);if(i<=n)return[H([n,s]),Vue(i,Ur(o))]}return[W(),Vue(n,r.sleeps)]}),O(r=>{switch(r._tag){case"None":return Ue;case"Some":{let[n,o]=r.value;return C(Mm(o,void 0),je(ku()),je(this.run(()=>n)))}}}))))}}});var RXe=h(()=>{});var _Xe,BXe,TXe=h(()=>{vt();_Xe=Symbol.for("effect/TestSized"),BXe=class{fiberRef;[_Xe]=_Xe;constructor(t){this.fiberRef=t}get size(){return Xi(this.fiberRef)}withSize(t){return r=>tn(this.fiberRef,t)(r)}}});var DXe=h(()=>{});var QXe=h(()=>{});var OXe=h(()=>{});var NXe=h(()=>{});var PXe=h(()=>{});var MXe=h(()=>{});var Dn=h(()=>{q8e();wr();MMe();FMe();TK();RW();G8e();Vs();aS();z8e();vr();II();jMe();LMe();Bqe();V8e();Y8e();sr();t5();lh();qMe();J8e();$u();q9();Ws();nr();id();bi();GMe();mt();mm();Z8e();a1();Ro();vUe();WI();$qe();Zl();Qqe();g0();mI();m1();_ne();BB();oe();yn();X8e();e5e();t5e();ir();kf();Nqe();dc();ht();x_();wWe();r5e();zu();n5e();Gw();E1();wZ();L8e();EQ();o5e();i5e();RPe();s5e();a5e();Fqe();c5e();u5e();l5e();d5e();f5e();p5e();m5e();h5e();g5e();dZ();A5e();iT();Mqe();F5();L$();Kl();y5e();Lm();it();bm();x5e();aW();E5e();Me();OWe();ct();Lqe();zWe();PNe();a2();h$();b5e();_qe();d7();bI();E_();M9();Tre();NA();KL();S5e();G5();C5e();w5e();I5e();Y2();Rqe();xL();k5e();lX();FU();QU();xT();PA();X0();YD();ah();v5e();R5e();_5e();B5e();rk();D5e();AU();wd();Q5e();PPe();N5e();J8();uW();M5e();L5e();$5e();H5e();F5e();W5e();j5e();q5e();G5e();zPe();VPe();z5e();V5e();Y5e();J5e();K5e();Z5e();X5e();Wue();que();lXe();vXe();RXe();QXe();IXe();DXe();TXe();MB();OXe();c6();NXe();tWe();PXe();MXe();mu()});var FXe=h(()=>{});var LXe=h(()=>{});var UXe=h(()=>{});var $Xe,ner,Bp,HXe=h(()=>{sr();it();Me();wQ();Hne();$Xe=Symbol.for("@effect/platform/HttpApiEndpoint"),ner={[$Xe]:$Xe,pipe(){return Z(this,arguments)},addSuccess(e,t){return e=t?.status?e.annotations(Ty({status:t.status})):e,Bp({...this,successSchema:this.successSchema===nWe?e:Td(this.successSchema,e)})},addError(e,t){return Bp({...this,errorSchema:Td(this.errorSchema,t?.status?e.annotations(Ty({status:t.status})):e)})},setPayload(e){return Bp({...this,payloadSchema:H(e)})},setPath(e){return Bp({...this,pathSchema:H(e)})},setUrlParams(e){return Bp({...this,urlParamsSchema:H(e)})},setHeaders(e){return Bp({...this,headersSchema:H(e)})},prefix(e){return Bp({...this,path:SWe(this.path,e)})},middleware(e){return Bp({...this,errorSchema:Td(this.errorSchema,e.failure),middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return Bp({...this,annotations:zt(this.annotations,e,t)})},annotateContext(e){return Bp({...this,annotations:wo(this.annotations,e)})}},Bp=e=>Object.assign(Object.create(ner),e)});var WXe,ier,og,jXe=h(()=>{sr();Me();E_();wQ();WXe=Symbol.for("@effect/platform/HttpApiGroup"),ier={[WXe]:WXe,add(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:{...this.endpoints,[e.name]:e},errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},addError(e,t){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,errorSchema:Td(this.errorSchema,t?.status?e.annotations(Ty({status:t.status})):e),annotations:this.annotations,middlewares:this.middlewares})},prefix(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:Sm(this.endpoints,t=>t.prefix(e)),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,errorSchema:Td(this.errorSchema,e.failure),annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},middlewareEndpoints(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:Sm(this.endpoints,t=>t.middleware(e)),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},annotateContext(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,errorSchema:this.errorSchema,annotations:wo(this.annotations,e),middlewares:this.middlewares})},annotate(e,t){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,errorSchema:this.errorSchema,annotations:zt(this.annotations,e,t),middlewares:this.middlewares})},annotateEndpointsContext(e){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:Sm(this.endpoints,t=>t.annotateContext(e)),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},annotateEndpoints(e,t){return og({identifier:this.identifier,topLevel:this.topLevel,endpoints:Sm(this.endpoints,r=>r.annotate(e,t)),errorSchema:this.errorSchema,annotations:this.annotations,middlewares:this.middlewares})},pipe(){return Z(this,arguments)}},og=e=>{function t(){}return Object.setPrototypeOf(t,ier),Object.assign(t,e)}});var qXe=h(()=>{});var GXe,lan,zXe=h(()=>{Me();GXe=Symbol.for("@effect/platform/HttpApiSecurity"),lan={[GXe]:GXe,pipe(){return Z(this,arguments)}}});var VXe=h(()=>{});var YXe=h(()=>{});var JXe,KXe,ZXe=h(()=>{lh();woe();woe();JXe=Symbol.for("@effect/platform/MsgPack/MsgPackError"),KXe=class extends uh("MsgPackError"){[JXe]=JXe;get message(){return this.reason}}});var XXe=h(()=>{});var e7e=h(()=>{});var t7e=h(()=>{});var r7e=h(()=>{});var rC=h(()=>{FXe();Que();Nue();IW();zoe();Th();mWe();LXe();AQ();vW();sWe();RWe();UXe();HXe();oWe();jXe();aWe();qXe();wQ();zXe();VXe();dWe();H2e();L2e();u2e();U2e();Tqe();QW();TWe();$2e();Lne();YXe();R8e();Hne();hWe();FW();Tne();PW();NW();P2e();N8e();ZXe();vne();XXe();kWe();IWe();zW();e7e();t7e();U8e();PHe();kqe();W2e();Lue();qne();r7e();nne();Yne();nj();vqe()});import{resolve as n7e}from"node:path";var nC,ax,oC=h(()=>{"use strict";rC();Dn();nC=class extends pr.TaggedError("CwdError"){},ax=e=>S.gen(function*(){let t=e!==void 0?n7e(process.cwd(),e):n7e(process.cwd());return(yield*(yield*mo.FileSystem).stat(t).pipe(S.mapError(()=>new nC({message:`cwd does not exist: ${t}`,cwd:t})))).type!=="Directory"?yield*new nC({message:`cwd is not a directory: ${t}`,cwd:t}):t})});var av,OG=h(()=>{"use strict";av=async e=>{let{provider:t,sandboxTag:r,hostRepoDir:n,resumeSession:o}=e;if(!t.sessionStorage)throw new Error(`${t.name} does not support resumeSession`);if(r==="none"){let s=await t.sessionStorage.findByIdOnHost(o);if(!s.path)throw new Error(`resumeSession "${o}" not found under ${s.searchedRoot}`);return}if(!await t.sessionStorage.existsOnHost(n,o)){let s=t.sessionStorage.hostSessionFilePath(n,o);throw new Error(s?`resumeSession "${o}" not found: expected session file at ${s}`:`resumeSession "${o}" not found`)}}});var o7e,i7e,s7e,a7e=h(()=>{o7e=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let r=0;for(e.lastIndex=0;e.test(t);)r+=1;return t.length-r}})(),i7e=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,s7e=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141});var ger,Aer,c7e,yer,u7e,xer,Eer,ber,l7e,d7e,f7e=h(()=>{a7e();ger=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Aer=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,c7e=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,yer=/\t{1,1000}/y,u7e=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),xer=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Eer=new RegExp("\\p{M}+","gu"),ber={limit:1/0,ellipsis:""},l7e=(e,t={},r={})=>{let n=t.limit??1/0,o=t.ellipsis??"",i=t?.ellipsisWidth??(o?l7e(o,ber,r).width:0),s=0,a=r.controlWidth??0,c=r.tabWidth??8,u=r.emojiWidth??2,l=2,d=r.regularWidth??1,f=r.wideWidth??l,p=[[xer,d],[ger,s],[Aer,a],[yer,c],[u7e,u],[c7e,f]],m=0,g=0,A=e.length,E=0,y=!1,b=A,w=Math.max(0,n-i),I=0,v=0,k=0,R=0;e:for(;;){if(v>I||g>=A&&g>m){let B=e.slice(I,v)||e.slice(m,g);E=0;for(let L of B.replaceAll(Eer,"")){let D=L.codePointAt(0)||0;if(i7e(D)?R=l:s7e(D)?R=f:R=d,k+R>w&&(b=Math.min(b,Math.max(I,m)+E)),k+R>n){y=!0;break e}E+=L.length,k+=R}I=v=0}if(g>=A)break e;for(let B=0,L=p.length;B<L;B++){let[D,ee]=p[B];if(D.lastIndex=g,D.test(e)){if(E=D===c7e?o7e(e.slice(g,D.lastIndex)):D===u7e?1:D.lastIndex-g,R=E*ee,k+R>w&&(b=Math.min(b,g+Math.floor((w-k)/ee))),k+R>n){y=!0;break e}k+=R,I=m,v=g,g=m=D.lastIndex;continue e}}g+=1}return{width:y?w:k,index:y?b:A,truncated:y,ellipsed:y&&n>=i}},d7e=l7e});var Ser,Cer,da,Yue=h(()=>{f7e();Ser={limit:1/0,ellipsis:"",ellipsisWidth:0},Cer=(e,t={})=>d7e(e,Ser,t).width,da=Cer});function cx(e,t,r){return String(e).normalize().split(Rer).map(n=>ver(n,t,r)).join(`
213
213
  `)}var NG,A7e,wer,Kue,y7e,Ier,x7e,Zue,p7e,m7e,h7e,g7e,Jue,ker,ver,Rer,Xue=h(()=>{Yue();NG="\x1B",A7e="\x9B",wer=39,Kue="\x07",y7e="[",Ier="]",x7e="m",Zue=`${Ier}8;;`,p7e=new RegExp(`(?:\\${y7e}(?<code>\\d+)m|\\${Zue}(?<uri>.*)${Kue})`,"y"),m7e=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},h7e=e=>`${NG}${y7e}${e}${x7e}`,g7e=e=>`${NG}${Zue}${e}${Kue}`,Jue=(e,t,r)=>{let n=t[Symbol.iterator](),o=!1,i=!1,s=e.at(-1),a=s===void 0?0:da(s),c=n.next(),u=n.next(),l=0;for(;!c.done;){let d=c.value,f=da(d);a+f<=r?e[e.length-1]+=d:(e.push(d),a=0),(d===NG||d===A7e)&&(o=!0,i=t.startsWith(Zue,l+1)),o?i?d===Kue&&(o=!1,i=!1):d===x7e&&(o=!1):(a+=f,a===r&&!u.done&&(e.push(""),a=0)),c=u,u=n.next(),l+=d.length}s=e.at(-1),!a&&s!==void 0&&s.length&&e.length>1&&(e[e.length-2]+=e.pop())},ker=e=>{let t=e.split(" "),r=t.length;for(;r&&!da(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},ver=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",o,i,s=e.split(" "),a=[""],c=0;for(let d=0;d<s.length;d++){let f=s[d];if(r.trim!==!1){let m=a.at(-1)??"",g=m.trimStart();m.length!==g.length&&(a[a.length-1]=g,c=da(g))}d!==0&&(c>=t&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),c=0),(c||r.trim===!1)&&(a[a.length-1]+=" ",c++));let p=da(f);if(r.hard&&p>t){let m=t-c,g=1+Math.floor((p-m-1)/t);Math.floor((p-1)/t)<g&&a.push(""),Jue(a,f,t),c=da(a.at(-1)??"");continue}if(c+p>t&&c&&p){if(r.wordWrap===!1&&c<t){Jue(a,f,t),c=da(a.at(-1)??"");continue}a.push(""),c=0}if(c+p>t&&r.wordWrap===!1){Jue(a,f,t),c=da(a.at(-1)??"");continue}a[a.length-1]+=f,c+=p}r.trim!==!1&&(a=a.map(d=>ker(d)));let u=a.join(`
214
214
  `),l=!1;for(let d=0;d<u.length;d++){let f=u[d];if(n+=f,l)l=!1;else if(l=f>="\uD800"&&f<="\uDBFF",l)continue;if(f===NG||f===A7e){p7e.lastIndex=d+1;let m=p7e.exec(u)?.groups;if(m?.code!==void 0){let g=Number.parseFloat(m.code);o=g===wer?void 0:g}else m?.uri!==void 0&&(i=m.uri.length===0?void 0:m.uri)}if(u[d+1]===`
215
215
  `){i&&(n+=g7e(""));let p=o?m7e(o):void 0;o&&p&&(n+=h7e(p))}else f===`
@@ -220,10 +220,10 @@ ${i}`:o.stack}Qe.exports.fetch=function(t,r=void 0){return y5t(t,r).catch(n=>{th
220
220
  `).length-1;this.output.write(fa.cursor.move(-999,t*-1))}render(){let t=cx(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(fa.cursor.hide);else{let r=Per(this._prevFrame,t),n=I7e(this.output);if(this.restoreCursor(),r){let o=Math.max(0,r.numLinesAfter-n),i=Math.max(0,r.numLinesBefore-n),s=r.lines.find(a=>a>=o);if(s===void 0){this._prevFrame=t;return}if(r.lines.length===1){this.output.write(fa.cursor.move(0,s-i)),this.output.write(fa.erase.lines(1));let a=t.split(`
221
221
  `);this.output.write(a[s]),this._prevFrame=t,this.output.write(fa.cursor.move(0,a.length-s-1));return}else if(r.lines.length>1){if(o<i)s=o;else{let c=s-i;c>0&&this.output.write(fa.cursor.move(0,c))}this.output.write(fa.erase.down());let a=t.split(`
222
222
  `).slice(s);this.output.write(a.join(`
223
- `)),this._prevFrame=t;return}}this.output.write(fa.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}},MG=class extends ole{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;let r=t.slice(0,this.cursor),[n,...o]=t.slice(this.cursor);return`${r}${Der("inverse",n)}${o.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",r=>{this._setValue(r)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}});import{styleText as Rt,stripVTControlCharacters as qan}from"node:util";import El from"node:process";function Fer(){return El.platform!=="win32"?El.env.TERM!=="linux":!!El.env.CI||!!El.env.WT_SESSION||!!El.env.TERMINUS_SUBLIME||El.env.ConEmuTask==="{cmd::Cmder}"||El.env.TERM_PROGRAM==="Terminus-Sublime"||El.env.TERM_PROGRAM==="vscode"||El.env.TERM==="xterm-256color"||El.env.TERM==="alacritty"||El.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var cv,ale,R7e,Ler,sn,Uer,_7e,B7e,YO,$er,Jc,cle,Yan,Jan,Kan,Zan,Xan,ecn,tcn,rcn,v7e,Her,Wer,jer,qer,ncn,Ger,zer,Ver,Yer,Jer,hi,T7e,D7e,Ker,Zer,Q7e,Xer,O7e,ocn,icn,etr,N7e,P7e,ule=h(()=>{sle();sle();Xue();Yue();cv=su(rle(),1);ale=Fer(),R7e=()=>process.env.CI==="true",Ler=e=>e.isTTY===!0,sn=(e,t)=>ale?e:t,Uer=sn("\u25C6","*"),_7e=sn("\u25A0","x"),B7e=sn("\u25B2","x"),YO=sn("\u25C7","o"),$er=sn("\u250C","T"),Jc=sn("\u2502","|"),cle=sn("\u2514","\u2014"),Yan=sn("\u2510","T"),Jan=sn("\u2518","\u2014"),Kan=sn("\u25CF",">"),Zan=sn("\u25CB"," "),Xan=sn("\u25FB","[\u2022]"),ecn=sn("\u25FC","[+]"),tcn=sn("\u25FB","[ ]"),rcn=sn("\u25AA","\u2022"),v7e=sn("\u2500","-"),Her=sn("\u256E","+"),Wer=sn("\u251C","+"),jer=sn("\u256F","+"),qer=sn("\u2570","+"),ncn=sn("\u256D","+"),Ger=sn("\u25CF","\u2022"),zer=sn("\u25C6","*"),Ver=sn("\u25B2","!"),Yer=sn("\u25A0","x"),Jer=e=>{switch(e){case"initial":case"active":return Rt("cyan",Uer);case"cancel":return Rt("red",_7e);case"error":return Rt("yellow",B7e);case"submit":return Rt("green",YO)}},hi={message:(e=[],{symbol:t=Rt("gray",Jc),secondarySymbol:r=Rt("gray",Jc),output:n=process.stdout,spacing:o=1,withGuide:i}={})=>{let s=[],a=i??ec.withGuide,c=a?r:"",u=a?`${t} `:"",l=a?`${r} `:"";for(let f=0;f<o;f++)s.push(c);let d=Array.isArray(e)?e:e.split(`
223
+ `)),this._prevFrame=t;return}}this.output.write(fa.erase.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}},MG=class extends ole{get userInputWithCursor(){if(this.state==="submit")return this.userInput;let t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;let r=t.slice(0,this.cursor),[n,...o]=t.slice(this.cursor);return`${r}${Der("inverse",n)}${o.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",r=>{this._setValue(r)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}});import{styleText as Rt,stripVTControlCharacters as qan}from"node:util";import El from"node:process";function Fer(){return El.platform!=="win32"?El.env.TERM!=="linux":!!El.env.CI||!!El.env.WT_SESSION||!!El.env.TERMINUS_SUBLIME||El.env.ConEmuTask==="{cmd::Cmder}"||El.env.TERM_PROGRAM==="Terminus-Sublime"||El.env.TERM_PROGRAM==="vscode"||El.env.TERM==="xterm-256color"||El.env.TERM==="alacritty"||El.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var cv,ale,R7e,Ler,sn,Uer,_7e,B7e,YO,$er,Jc,cle,Yan,Jan,Kan,Zan,Xan,ecn,tcn,rcn,v7e,Her,Wer,jer,qer,ncn,Ger,zer,Ver,Yer,Jer,ti,T7e,D7e,Ker,Zer,Q7e,Xer,O7e,ocn,icn,etr,N7e,P7e,ule=h(()=>{sle();sle();Xue();Yue();cv=su(rle(),1);ale=Fer(),R7e=()=>process.env.CI==="true",Ler=e=>e.isTTY===!0,sn=(e,t)=>ale?e:t,Uer=sn("\u25C6","*"),_7e=sn("\u25A0","x"),B7e=sn("\u25B2","x"),YO=sn("\u25C7","o"),$er=sn("\u250C","T"),Jc=sn("\u2502","|"),cle=sn("\u2514","\u2014"),Yan=sn("\u2510","T"),Jan=sn("\u2518","\u2014"),Kan=sn("\u25CF",">"),Zan=sn("\u25CB"," "),Xan=sn("\u25FB","[\u2022]"),ecn=sn("\u25FC","[+]"),tcn=sn("\u25FB","[ ]"),rcn=sn("\u25AA","\u2022"),v7e=sn("\u2500","-"),Her=sn("\u256E","+"),Wer=sn("\u251C","+"),jer=sn("\u256F","+"),qer=sn("\u2570","+"),ncn=sn("\u256D","+"),Ger=sn("\u25CF","\u2022"),zer=sn("\u25C6","*"),Ver=sn("\u25B2","!"),Yer=sn("\u25A0","x"),Jer=e=>{switch(e){case"initial":case"active":return Rt("cyan",Uer);case"cancel":return Rt("red",_7e);case"error":return Rt("yellow",B7e);case"submit":return Rt("green",YO)}},ti={message:(e=[],{symbol:t=Rt("gray",Jc),secondarySymbol:r=Rt("gray",Jc),output:n=process.stdout,spacing:o=1,withGuide:i}={})=>{let s=[],a=i??ec.withGuide,c=a?r:"",u=a?`${t} `:"",l=a?`${r} `:"";for(let f=0;f<o;f++)s.push(c);let d=Array.isArray(e)?e:e.split(`
224
224
  `);if(d.length>0){let[f,...p]=d;f.length>0?s.push(`${u}${f}`):s.push(a?t:"");for(let m of p)m.length>0?s.push(`${l}${m}`):s.push(a?r:"")}n.write(`${s.join(`
225
225
  `)}
226
- `)},info:(e,t)=>{hi.message(e,{...t,symbol:Rt("blue",Ger)})},success:(e,t)=>{hi.message(e,{...t,symbol:Rt("green",zer)})},step:(e,t)=>{hi.message(e,{...t,symbol:Rt("green",YO)})},warn:(e,t)=>{hi.message(e,{...t,symbol:Rt("yellow",Ver)})},warning:(e,t)=>{hi.warn(e,t)},error:(e,t)=>{hi.message(e,{...t,symbol:Rt("red",Yer)})}},T7e=(e="",t)=>{let r=t?.output??process.stdout,n=t?.withGuide??ec.withGuide?`${Rt("gray",cle)} `:"";r.write(`${n}${Rt("red",e)}
226
+ `)},info:(e,t)=>{ti.message(e,{...t,symbol:Rt("blue",Ger)})},success:(e,t)=>{ti.message(e,{...t,symbol:Rt("green",zer)})},step:(e,t)=>{ti.message(e,{...t,symbol:Rt("green",YO)})},warn:(e,t)=>{ti.message(e,{...t,symbol:Rt("yellow",Ver)})},warning:(e,t)=>{ti.warn(e,t)},error:(e,t)=>{ti.message(e,{...t,symbol:Rt("red",Yer)})}},T7e=(e="",t)=>{let r=t?.output??process.stdout,n=t?.withGuide??ec.withGuide?`${Rt("gray",cle)} `:"";r.write(`${n}${Rt("red",e)}
227
227
 
228
228
  `)},D7e=(e="",t)=>{let r=t?.output??process.stdout,n=t?.withGuide??ec.withGuide?`${Rt("gray",$er)} `:"";r.write(`${n}${e}
229
229
  `)},Ker=e=>Rt("dim",e),Zer=(e,t,r)=>{let n={hard:!0,trim:!1},o=cx(e,t,n).split(`
@@ -244,14 +244,14 @@ ${Rt("gray",d+v7e.repeat(c+2)+jer)}
244
244
  `);let c=[{value:"",full:""}],u=!1,l=A=>{if(c.length===0)return;let E=0;A&&(E+=o+2);for(let y of c){let{value:b,result:w}=y,I=w?.message??b;if(I.length===0)continue;w===void 0&&y.header!==void 0&&y.header!==""&&(I+=`
245
245
  ${y.header}`);let v=I.split(`
246
246
  `).reduce((k,R)=>R===""?k+1:k+Math.ceil((R.length+i)/r),0);E+=v}E>0&&(E+=1,t.write(cv.erase.lines(E)))},d=(A,E,y)=>{let b=y?`${A.full}
247
- ${A.value}`:A.value;A.header!==void 0&&A.header!==""&&hi.message(A.header.split(`
248
- `).map(w=>Rt("bold",w)),{output:t,secondarySymbol:n,symbol:n,spacing:0}),hi.message(b.split(`
247
+ ${A.value}`:A.value;A.header!==void 0&&A.header!==""&&ti.message(A.header.split(`
248
+ `).map(w=>Rt("bold",w)),{output:t,secondarySymbol:n,symbol:n,spacing:0}),ti.message(b.split(`
249
249
  `).map(w=>Rt("dim",w)),{output:t,secondarySymbol:n,symbol:n,spacing:E??o})},f=()=>{for(let A of c){let{header:E,value:y,full:b}=A;(E===void 0||E.length===0)&&y.length===0||d(A,void 0,s===!0&&b.length>0)}},p=(A,E,y)=>{if(l(!1),(y?.raw!==!0||!u)&&A.value!==""&&(A.value+=`
250
250
  `),A.value+=etr(E),u=y?.raw===!0,e.limit!==void 0){let b=A.value.split(`
251
251
  `),w=b.length-e.limit;if(w>0){let I=b.splice(0,w);s&&(A.full+=(A.full===""?"":`
252
252
  `)+I.join(`
253
253
  `))}A.value=b.join(`
254
- `)}a&&m()},m=()=>{for(let A of c)A.result?A.result.status==="error"?hi.error(A.result.message,{output:t,secondarySymbol:n,spacing:0}):hi.success(A.result.message,{output:t,secondarySymbol:n,spacing:0}):A.value!==""&&d(A,0)},g=(A,E)=>{l(!1),A.result=E,a&&m()};return{message(A,E){p(c[0],A,E)},group(A){let E={header:A,value:"",full:""};return c.push(E),{message(y,b){p(E,y,b)},error(y){g(E,{status:"error",message:y})},success(y){g(E,{status:"success",message:y})}}},error(A,E){l(!0),hi.error(A,{output:t,secondarySymbol:n,spacing:1}),E?.showLog!==!1&&f(),c.splice(1,c.length-1),c[0].value="",c[0].full=""},success(A,E){l(!0),hi.success(A,{output:t,secondarySymbol:n,spacing:1}),E?.showLog===!0&&f(),c.splice(1,c.length-1),c[0].value="",c[0].full=""}}},P7e=e=>new MG({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??ec.withGuide,r=`${`${t?`${Rt("gray",Jc)}
254
+ `)}a&&m()},m=()=>{for(let A of c)A.result?A.result.status==="error"?ti.error(A.result.message,{output:t,secondarySymbol:n,spacing:0}):ti.success(A.result.message,{output:t,secondarySymbol:n,spacing:0}):A.value!==""&&d(A,0)},g=(A,E)=>{l(!1),A.result=E,a&&m()};return{message(A,E){p(c[0],A,E)},group(A){let E={header:A,value:"",full:""};return c.push(E),{message(y,b){p(E,y,b)},error(y){g(E,{status:"error",message:y})},success(y){g(E,{status:"success",message:y})}}},error(A,E){l(!0),ti.error(A,{output:t,secondarySymbol:n,spacing:1}),E?.showLog!==!1&&f(),c.splice(1,c.length-1),c[0].value="",c[0].full=""},success(A,E){l(!0),ti.success(A,{output:t,secondarySymbol:n,spacing:1}),E?.showLog===!0&&f(),c.splice(1,c.length-1),c[0].value="",c[0].full=""}}},P7e=e=>new MG({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??ec.withGuide,r=`${`${t?`${Rt("gray",Jc)}
255
255
  `:""}${Jer(this.state)} `}${e.message}
256
256
  `,n=e.placeholder?Rt("inverse",e.placeholder[0])+Rt("dim",e.placeholder.slice(1)):Rt(["inverse","hidden"],"_"),o=this.userInput?this.userInputWithCursor:n,i=this.value??"";switch(this.state){case"error":{let s=this.error?` ${Rt("yellow",this.error)}`:"",a=t?`${Rt("yellow",Jc)} `:"",c=t?Rt("yellow",cle):"";return`${r.trim()}
257
257
  ${a}${o}
@@ -259,15 +259,17 @@ ${c}${s}
259
259
  `}case"submit":{let s=i?` ${Rt("dim",i)}`:"",a=t?Rt("gray",Jc):"";return`${r}${a}${s}`}case"cancel":{let s=i?` ${Rt(["strikethrough","dim"],i)}`:"",a=t?Rt("gray",Jc):"";return`${r}${a}${s}${i.trim()?`
260
260
  ${a}`:""}`}default:{let s=t?`${Rt("cyan",Jc)} `:"",a=t?Rt("cyan",cle):"";return`${r}${s}${o}
261
261
  ${a}
262
- `}}}}).prompt()});import{dirname as ttr}from"node:path";import{styleText as uv}from"node:util";var En,F7e,lv,rtr,UG,Tp,Wd=h(()=>{"use strict";ule();rC();Dn();En=class extends Kt.Tag("Display")(){},F7e={layer:e=>Er.succeed(En,{intro:t=>Ii.update(e,r=>[...r,{_tag:"intro",title:t}]),status:(t,r)=>Ii.update(e,n=>[...n,{_tag:"status",message:t,severity:r}]),spinner:(t,r)=>S.flatMap(Ii.update(e,n=>[...n,{_tag:"spinner",message:t}]),()=>r),summary:(t,r)=>Ii.update(e,n=>[...n,{_tag:"summary",title:t,rows:r}]),taskLog:(t,r)=>{let n=[];return S.flatMap(r(o=>n.push(o)),o=>S.map(Ii.update(e,i=>[...i,{_tag:"taskLog",title:t,messages:[...n]}]),()=>o))},text:t=>Ii.update(e,r=>[...r,{_tag:"text",message:t}]),toolCall:(t,r)=>Ii.update(e,n=>[...n,{_tag:"toolCall",name:t,formattedArgs:r}])})},lv={layer:e=>Er.effect(En,S.gen(function*(){let t=yield*mo.FileSystem;yield*t.makeDirectory(ttr(e),{recursive:!0}).pipe(S.orDie);let r=`
262
+ `}}}}).prompt()});import{dirname as ttr}from"node:path";import{styleText as uv}from"node:util";var En,F7e,lv,rtr,UG,Tp,Wd=h(()=>{"use strict";ule();rC();Dn();En=class extends Kt.Tag("Display")(){},F7e={layer:e=>Er.succeed(En,{intro:t=>di.update(e,r=>[...r,{_tag:"intro",title:t}]),status:(t,r)=>di.update(e,n=>[...n,{_tag:"status",message:t,severity:r}]),spinner:(t,r)=>S.flatMap(di.update(e,n=>[...n,{_tag:"spinner",message:t}]),()=>r),summary:(t,r)=>di.update(e,n=>[...n,{_tag:"summary",title:t,rows:r}]),taskLog:(t,r)=>{let n=[];return S.flatMap(r(o=>n.push(o)),o=>S.map(di.update(e,i=>[...i,{_tag:"taskLog",title:t,messages:[...n]}]),()=>o))},text:t=>di.update(e,r=>[...r,{_tag:"text",message:t}]),textChunk:t=>di.update(e,r=>[...r,{_tag:"textChunk",message:t}]),toolCall:(t,r)=>di.update(e,n=>[...n,{_tag:"toolCall",name:t,formattedArgs:r}])})},lv={layer:e=>Er.effect(En,S.gen(function*(){let t=yield*mo.FileSystem;yield*t.makeDirectory(ttr(e),{recursive:!0}).pipe(S.orDie);let r=`
263
263
  --- Run started: ${new Date().toISOString()} ---
264
- `;yield*t.writeFileString(e,r,{flag:"a"}).pipe(S.orDie);let n=o=>t.writeFileString(e,o+`
265
- `,{flag:"a"}).pipe(S.ignore);return{intro:()=>S.void,status:(o,i)=>n(o.replace(/^\[[^\]]+\] /,"")),spinner:(o,i)=>S.gen(function*(){yield*n(`${o}...`);let s=Date.now(),a=yield*i,c=((Date.now()-s)/1e3).toFixed(1);return yield*n(`${o} done (${c}s)`),a}),summary:(o,i)=>{let s=Object.entries(i).map(([a,c])=>` ${a}: ${c}`).join(`
266
- `);return n(`${o}
267
- ${s}`)},taskLog:(o,i)=>S.gen(function*(){yield*n(o);let s=Date.now(),a=[],c=yield*i(l=>{a.push(l)}),u=((Date.now()-s)/1e3).toFixed(1);for(let l of a)yield*n(` ${l}`);return yield*n(`${o} done (${u}s)`),c}),text:o=>n(o),toolCall:(o,i)=>n(`${o}(${i})`)}}))},rtr={info:hi.info,success:hi.success,warn:hi.warning,error:hi.error},UG={status:e=>uv("bold",e),summaryTitle:e=>uv("bold",e),summaryRow:(e,t)=>`${uv("bold",e)}: ${uv("dim",t)}`,toolCall:e=>uv("dim",e)},Tp={layer:Er.succeed(En,{intro:e=>S.sync(()=>D7e(uv("inverse",` ${e} `))),status:(e,t)=>S.sync(()=>rtr[t](UG.status(e))),spinner:(e,t)=>S.acquireUseRelease(S.sync(()=>{let r=O7e();return r.start(e),r}),()=>t,(r,n)=>S.sync(()=>{n._tag==="Success"?r.stop(e):r.stop(`${e} (failed)`)})),summary:(e,t)=>S.sync(()=>{let r=Object.entries(t).map(([n,o])=>UG.summaryRow(n,o)).join(`
268
- `);Q7e(r,UG.summaryTitle(e))}),taskLog:(e,t)=>S.acquireUseRelease(S.sync(()=>N7e({title:e})),r=>t(n=>r.message(n)),(r,n)=>S.sync(()=>{n._tag==="Success"?r.success(e,{showLog:!0}):r.error(e,{showLog:!0})})),text:e=>S.sync(()=>hi.message(e)),toolCall:(e,t)=>S.sync(()=>hi.step(UG.toolCall(`${e}(${t})`)))})}});var JO,dv,KO=h(()=>{"use strict";Dn();JO=class extends Kt.Tag("AgentStreamEmitter")(){},dv=e=>Er.succeed(JO,{emit:e?t=>S.sync(()=>{try{e(t)}catch{}}):()=>S.void})});var Dp,L7e,lx,ZO,U7e,Wn,ti,Kc,iC,$7e,H7e,sC,XO,eN,fv,$G,HG,pv,WG,jG,tN,qG,Mi,mv,rN,pa=h(()=>{"use strict";Dn();oC();Dp=class extends pr.TaggedError("ExecError"){},L7e=class extends pr.TaggedError("ExecHostError"){},lx=class extends pr.TaggedError("CopyError"){},ZO=class extends pr.TaggedError("DockerError"){},U7e=class extends pr.TaggedError("PodmanError"){},Wn=class extends pr.TaggedError("SyncError"){},ti=class extends pr.TaggedError("WorktreeError"){},Kc=class extends pr.TaggedError("PromptError"){},iC=class extends pr.TaggedError("AgentError"){},$7e=class extends pr.TaggedError("ConfigDirError"){},H7e=class extends pr.TaggedError("InitError"){},sC=class extends pr.TaggedError("AgentIdleTimeoutError"){},XO=class extends pr.TaggedError("WorktreeTimeoutError"){},eN=class extends pr.TaggedError("ContainerStartTimeoutError"){},fv=class extends pr.TaggedError("CopyToWorktreeTimeoutError"){},$G=class extends pr.TaggedError("CopyToWorktreeError"){},HG=class extends pr.TaggedError("SyncInTimeoutError"){},pv=class extends pr.TaggedError("HookTimeoutError"){},WG=class extends pr.TaggedError("GitSetupTimeoutError"){},jG=class extends pr.TaggedError("PromptExpansionTimeoutError"){},tN=class extends pr.TaggedError("CommitCollectionTimeoutError"){},qG=class extends pr.TaggedError("MergeToHostTimeoutError"){},Mi=(e,t)=>r=>r.pipe(S.timeoutFail({duration:Nn.millis(e),onTimeout:t})),mv=class extends pr.TaggedError("WorktreeLockError"){},rN=class extends pr.TaggedError("SessionCaptureError"){}});var W7e,aC,ntr,dx,hv=h(()=>{"use strict";Dn();Wd();pa();W7e=3e4,aC="",ntr=new RegExp(`!${aC}\`([^\`]+)\``,"g"),dx=(e,t,r)=>{let n=[...e.matchAll(ntr)];return n.length===0?S.succeed(e.replaceAll(aC,"")):S.gen(function*(){return yield*(yield*En).taskLog("Expanding shell expressions",i=>S.gen(function*(){let s=yield*S.all(n.map(c=>{let u=c[1];return S.gen(function*(){let l=yield*Vm.currentTimeMillis,d=yield*t.exec(u,{cwd:r}).pipe(S.timeoutOption(Nn.millis(W7e)));if(Ke.isNone(d)){let p=(yield*Vm.currentTimeMillis)-l;return yield*S.fail(new jG({message:`Shell expression \`${u}\` timed out after ${p}ms`,timeoutMs:W7e,expression:u,elapsedMs:p}))}let f=d.value;return f.exitCode!==0?yield*S.fail(new Kc({message:`Command \`${u}\` exited with code ${f.exitCode}: ${f.stderr}`,exitCode:f.exitCode})):f.stdout.trimEnd()})}),{concurrency:"unbounded"});for(let c=0;c<n.length;c++){let u=n[c][1],l=Math.ceil(s[c].length/4);i(`${u} \u2192 ~${l} tokens`)}let a=e;for(let c=n.length-1;c>=0;c--){let u=n[c],l=u.index;a=a.slice(0,l)+s[c]+a.slice(l+u[0].length)}return a.replaceAll(aC,"")}))})}});import{constants as lle,mkdir as otr,open as j7e,readdir as itr,readFile as dle,rm as nN}from"node:fs/promises";import{join as fle}from"node:path";var q7e,G7e,str,ple,GG,z7e,mle=h(()=>{"use strict";pa();q7e=e=>{try{return process.kill(e,0),!0}catch{return!1}},G7e=lle.O_WRONLY|lle.O_CREAT|lle.O_EXCL,str=async(e,t)=>{await nN(e,{force:!0});try{return await j7e(e,G7e)}catch(r){if(r.code!=="EEXIST")throw r;try{let n=await dle(e,"utf-8"),o=JSON.parse(n);throw new mv({message:`Worktree is in use by process ${o.pid} (branch '${o.branch}', acquired at ${o.acquiredAt})`,owningPid:o.pid,branch:o.branch,timestamp:o.acquiredAt})}catch(n){throw n instanceof mv?n:new Error(`Worktree lock already held for '${t}' (lock file: ${e})`)}}},ple=async(e,t,r)=>{await otr(e,{recursive:!0});let n=fle(e,`${t}.lock`),o;try{o=await j7e(n,G7e)}catch(s){if(s.code!=="EEXIST")throw s;let a;try{let c=await dle(n,"utf-8");a=JSON.parse(c)}catch{}if(a&&q7e(a.pid))throw new mv({message:`Worktree is in use by process ${a.pid} (branch '${a.branch}', acquired at ${a.acquiredAt})`,owningPid:a.pid,branch:a.branch,timestamp:a.acquiredAt});o=await str(n,t)}let i={pid:process.pid,branch:r,acquiredAt:new Date().toISOString()};try{await o.writeFile(JSON.stringify(i,null,2))}finally{await o.close()}},GG=async(e,t)=>{let r=fle(e,`${t}.lock`);try{await nN(r)}catch(n){if(n.code==="ENOENT")return;throw n}},z7e=async(e,t)=>{let r;try{r=await itr(e)}catch(n){if(n.code==="ENOENT")return;throw n}for(let n of r){if(!n.endsWith(".lock"))continue;let o=n.slice(0,-5),i=fle(e,n);if(!t.has(o)){await nN(i,{force:!0});continue}try{let s=await dle(i,"utf-8"),a=JSON.parse(s);q7e(a.pid)||await nN(i,{force:!0})}catch{await nN(i,{force:!0})}}}});import{execFile as atr}from"node:child_process";import{randomBytes as ctr}from"node:crypto";import{basename as utr,join as gv,normalize as ltr}from"node:path";var Av,yv,oN,V7e,Y7e,J7e,tc,zG,cC,dtr,ftr,ptr,mtr,htr,Qp,ig,bl,fx,uC=h(()=>{"use strict";Dn();rC();pa();mle();Av=3e4,yv=e=>e.replace(/\\/g,"/"),oN=["-c","branch.autoSetupMerge=false","-c","push.autoSetupRemote=false"],V7e=e=>{let t=r=>String(r).padStart(2,"0");return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`},Y7e=()=>ctr(3).toString("hex"),J7e=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"-"),tc=(e,t)=>S.async(r=>{atr("git",e,{cwd:t,env:{...process.env,LC_ALL:"C"}},(n,o,i)=>{r(n?S.fail(new ti({message:i?.trim()||n.message})):S.succeed(o))})}),zG=e=>{let t=V7e(new Date),r=Y7e();return e?`sandcastle/${J7e(e)}/${t}-${r}`:`sandcastle/${t}-${r}`},cC=e=>tc(["rev-parse","--abbrev-ref","HEAD"],e).pipe(S.map(t=>t.trim())),dtr=(e,t,r)=>e.find(n=>n.branch===t)??e.find(n=>yv(n.path)===yv(r)),ftr=(e,t)=>yv(e).startsWith(yv(t)),ptr=(e,t)=>{let r=yv(e);for(let n of t)if(yv(n)===r)return!1;return!0},mtr=e=>tc(["worktree","list","--porcelain"],e).pipe(S.map(t=>{let r=[],n=null,o=null;for(let i of t.split(`
269
- `))i.startsWith("worktree ")?(n!==null&&r.push({path:n,branch:o}),n=i.slice(9).trim(),o=null):i.startsWith("branch ")&&(o=i.slice(18).trim());return n!==null&&r.push({path:n,branch:o}),r})),htr=(e,t)=>S.gen(function*(){if((yield*tc(["symbolic-ref","--quiet","HEAD"],e).pipe(S.map(a=>a.trim()),S.orElseSucceed(()=>"")))!==`refs/heads/${t}`){console.log(`Reusing worktree at ${e} (branch '${t}') \u2014 HEAD is not on '${t}', skipping origin refresh`);return}if((yield*S.either(tc([...oN,"fetch","origin",t],e)))._tag==="Left"){console.log(`Could not fetch from origin (reusing worktree at ${e} as-is, branch '${t}')`);return}let o=yield*tc(["rev-parse","HEAD"],e).pipe(S.map(a=>a.trim()),S.orElseSucceed(()=>""));if((yield*S.either(tc([...oN,"merge","--ff-only",`origin/${t}`],e)))._tag==="Left"){console.log(`Branch '${t}' has diverged from origin (reusing worktree at ${e} as-is)`);return}let s=yield*tc(["rev-parse","HEAD"],e).pipe(S.map(a=>a.trim()),S.orElseSucceed(()=>""));console.log(o&&s&&o!==s?`Fast-forwarded worktree at ${e} (branch '${t}') to origin/${t}`:`Reusing existing worktree at ${e} (branch '${t}')`)}),Qp=(e,t)=>S.gen(function*(){let r=yield*mo.FileSystem,n=gv(e,".sandcastle","worktrees");yield*r.makeDirectory(n,{recursive:!0}).pipe(S.mapError(a=>new ti({message:a.message})));let o,i;if(t?.branch)o=t.branch,i=o.replace(/\//g,"-");else{let a=V7e(new Date),c=Y7e();if(t?.name){let u=J7e(t.name);o=`sandcastle/${u}/${a}-${c}`,i=`sandcastle-${u}-${a}-${c}`}else o=`sandcastle/${a}-${c}`,i=`sandcastle-${a}-${c}`}let s=gv(n,i);if(t?.branch){let a=yield*mtr(e),c=dtr(a,o,s);if(c){if(ftr(c.path,n))return(yield*ig(c.path))?console.warn(`Reusing worktree at ${c.path} (branch '${o}') \u2014 worktree has uncommitted changes`):yield*htr(c.path,o),{path:ltr(c.path),branch:o};yield*S.fail(new ti({message:`Branch '${o}' is already checked out in worktree at '${c.path}'. Sandcastle's branch and merge-to-head strategies run the agent in a git worktree under .sandcastle/worktrees/, and git refuses to check out the same branch in two worktrees at once (HEAD would become ambiguous). Pick a different branch, or switch the main working tree to a different branch before re-running.`}))}yield*tc([...oN,"worktree","add",s,o],e).pipe(S.catchAll(u=>u.message.includes("invalid reference")?tc([...oN,"worktree","add","-b",o,s,t?.baseBranch??"HEAD"],e):S.fail(u)))}else yield*tc([...oN,"worktree","add","-b",o,s,"HEAD"],e).pipe(S.catchAll(a=>a.message.includes("already checked out")||a.message.includes("already exists")?S.fail(new ti({message:`Branch '${o}' is already checked out in another worktree. Use a different branch name, or wait for the other run to finish.`})):S.fail(a)));return{path:s,branch:o}}).pipe(Mi(Av,()=>new XO({message:`Worktree creation timed out after ${Av}ms`,timeoutMs:Av,path:e,operation:"create"}))),ig=e=>tc(["status","--porcelain"],e).pipe(S.map(t=>t.trim().length>0)),bl=e=>{let t=gv(e,"..","..","..");return tc(["worktree","remove","--force",e],t).pipe(S.asVoid)},fx=e=>S.gen(function*(){let t=yield*mo.FileSystem;yield*tc(["worktree","prune"],e);let r=yield*tc(["worktree","list","--porcelain"],e),n=new Set(r.split(`
270
- `).filter(c=>c.startsWith("worktree ")).map(c=>c.slice(9).trim())),o=gv(e,".sandcastle","worktrees"),i=yield*t.readDirectory(o).pipe(S.map(c=>c),S.catchSome(c=>c._tag==="SystemError"&&c.reason==="NotFound"?Ke.some(S.succeed(null)):Ke.none()),S.mapError(c=>new ti({message:c.message})));if(i!==null){let c=yield*t.realPath(o).pipe(S.catchAll(()=>S.succeed(o)));for(let u of i){let l=gv(c,u);(yield*t.stat(l).pipe(S.map(f=>f.type==="Directory"),S.catchAll(()=>S.succeed(!1))))&&ptr(l,n)&&(yield*t.remove(l,{recursive:!0,force:!0}).pipe(S.mapError(f=>new ti({message:`Failed to remove ${l}: ${f.message}`}))))}}let s=gv(e,".sandcastle","locks"),a=new Set([...n].map(c=>utr(c)));yield*S.promise(()=>z7e(s,a))}).pipe(Mi(Av,()=>new XO({message:`Worktree prune timed out after ${Av}ms`,timeoutMs:Av,path:e,operation:"prune"})))});import{existsSync as gtr,constants as Atr}from"node:fs";import{copyFile as ytr,lstat as xtr,mkdir as Etr,readdir as btr,readlink as Str,symlink as Ctr}from"node:fs/promises";import{join as YG}from"node:path";var wtr,K7e,Op,iN=h(()=>{"use strict";Dn();pa();wtr=6e4,K7e=async(e,t)=>{let r;try{r=await xtr(e)}catch(n){let o=n?.code;if(o==="EACCES"||o==="EINVAL")return;throw n}if(r.isDirectory()){await Etr(t,{recursive:!0});let n=await btr(e);await Promise.all(n.map(o=>K7e(YG(e,o),YG(t,o))));return}if(r.isSymbolicLink()){let n=await Str(e);try{await Ctr(n,t)}catch(o){if(o?.code!=="EEXIST")throw o}return}if(r.isFile()){await ytr(e,t,Atr.COPYFILE_FICLONE);return}},Op=(e,t,r,n)=>{let o=n??wtr;return S.gen(function*(){for(let i of e){let s=YG(t,i);if(!gtr(s))continue;let a=YG(r,i);yield*S.tryPromise({try:()=>K7e(s,a),catch:c=>{let u=c,l=u?.message??String(c);return new $G({message:`Failed to copy ${i} to worktree: ${l}`,path:i,stderr:l,exitCode:typeof u?.errno=="number"?u.errno:null})}})}}).pipe(Mi(o,()=>new fv({message:`Copying files to worktree timed out after ${o}ms`,timeoutMs:o,paths:e})))}});var X7e,Z7e,hle,eet=h(()=>{"use strict";X7e=e=>{let{patchDir:t,failedStep:r,hasCommits:n,hasDiff:o,hasUntracked:i,branch:s}=e,a=s?`../../${t}`:t,c=[];n&&c.push({key:"commits",label:"committed changes",has:!0}),o&&c.push({key:"diff",label:"uncommitted changes",has:!0}),i&&c.push({key:"untracked",label:"untracked files",has:!0});let u=c.findIndex(p=>p.key===r),l=c[u],d=u+1,f=[];if(f.push(`Patch application failed at step ${d} (${l.label}).`),f.push(""),s&&(f.push("Set up worktree, then resolve:"),f.push(hle([`git worktree add .sandcastle/worktree ${s}`,"cd .sandcastle/worktree"])),f.push("")),r==="commits"){f.push("Resolve conflicts, then continue with:"),f.push(" git am --continue");let p=Z7e(a,c.slice(u+1));p.length>0&&(f.push(""),f.push("After all commits are applied, run the remaining steps:"),f.push(hle(p)))}else{let p=Z7e(a,c.slice(u));p.length>0&&(f.push("Run the remaining steps:"),f.push(hle(p)))}return f.join(`
264
+ `;yield*t.writeFileString(e,r,{flag:"a"}).pipe(S.orDie);let n=!1,o=s=>S.suspend(()=>{let a=n?`
265
+ `:"";return n=!1,t.writeFileString(e,`${a}${s}
266
+ `,{flag:"a"}).pipe(S.ignore)}),i=s=>S.suspend(()=>s.length===0?S.void:(n=!s.endsWith(`
267
+ `),t.writeFileString(e,s,{flag:"a"}).pipe(S.ignore)));return{intro:()=>S.void,status:(s,a)=>o(s.replace(/^\[[^\]]+\] /,"")),spinner:(s,a)=>S.gen(function*(){yield*o(`${s}...`);let c=Date.now(),u=yield*a,l=((Date.now()-c)/1e3).toFixed(1);return yield*o(`${s} done (${l}s)`),u}),summary:(s,a)=>{let c=Object.entries(a).map(([u,l])=>` ${u}: ${l}`).join(`
268
+ `);return o(`${s}
269
+ ${c}`)},taskLog:(s,a)=>S.gen(function*(){yield*o(s);let c=Date.now(),u=[],l=yield*a(f=>{u.push(f)}),d=((Date.now()-c)/1e3).toFixed(1);for(let f of u)yield*o(` ${f}`);return yield*o(`${s} done (${d}s)`),l}),text:s=>o(s),textChunk:s=>i(s),toolCall:(s,a)=>o(`${s}(${a})`)}}))},rtr={info:ti.info,success:ti.success,warn:ti.warning,error:ti.error},UG={status:e=>uv("bold",e),summaryTitle:e=>uv("bold",e),summaryRow:(e,t)=>`${uv("bold",e)}: ${uv("dim",t)}`,toolCall:e=>uv("dim",e)},Tp={layer:Er.succeed(En,{intro:e=>S.sync(()=>D7e(uv("inverse",` ${e} `))),status:(e,t)=>S.sync(()=>rtr[t](UG.status(e))),spinner:(e,t)=>S.acquireUseRelease(S.sync(()=>{let r=O7e();return r.start(e),r}),()=>t,(r,n)=>S.sync(()=>{n._tag==="Success"?r.stop(e):r.stop(`${e} (failed)`)})),summary:(e,t)=>S.sync(()=>{let r=Object.entries(t).map(([n,o])=>UG.summaryRow(n,o)).join(`
270
+ `);Q7e(r,UG.summaryTitle(e))}),taskLog:(e,t)=>S.acquireUseRelease(S.sync(()=>N7e({title:e})),r=>t(n=>r.message(n)),(r,n)=>S.sync(()=>{n._tag==="Success"?r.success(e,{showLog:!0}):r.error(e,{showLog:!0})})),text:e=>S.sync(()=>ti.message(e)),textChunk:e=>S.sync(()=>ti.message(e)),toolCall:(e,t)=>S.sync(()=>ti.step(UG.toolCall(`${e}(${t})`)))})}});var JO,dv,KO=h(()=>{"use strict";Dn();JO=class extends Kt.Tag("AgentStreamEmitter")(){},dv=e=>Er.succeed(JO,{emit:e?t=>S.sync(()=>{try{e(t)}catch{}}):()=>S.void})});var Dp,L7e,lx,ZO,U7e,Wn,ri,Kc,iC,$7e,H7e,sC,XO,eN,fv,$G,HG,pv,WG,jG,tN,qG,Mi,mv,rN,pa=h(()=>{"use strict";Dn();oC();Dp=class extends pr.TaggedError("ExecError"){},L7e=class extends pr.TaggedError("ExecHostError"){},lx=class extends pr.TaggedError("CopyError"){},ZO=class extends pr.TaggedError("DockerError"){},U7e=class extends pr.TaggedError("PodmanError"){},Wn=class extends pr.TaggedError("SyncError"){},ri=class extends pr.TaggedError("WorktreeError"){},Kc=class extends pr.TaggedError("PromptError"){},iC=class extends pr.TaggedError("AgentError"){},$7e=class extends pr.TaggedError("ConfigDirError"){},H7e=class extends pr.TaggedError("InitError"){},sC=class extends pr.TaggedError("AgentIdleTimeoutError"){},XO=class extends pr.TaggedError("WorktreeTimeoutError"){},eN=class extends pr.TaggedError("ContainerStartTimeoutError"){},fv=class extends pr.TaggedError("CopyToWorktreeTimeoutError"){},$G=class extends pr.TaggedError("CopyToWorktreeError"){},HG=class extends pr.TaggedError("SyncInTimeoutError"){},pv=class extends pr.TaggedError("HookTimeoutError"){},WG=class extends pr.TaggedError("GitSetupTimeoutError"){},jG=class extends pr.TaggedError("PromptExpansionTimeoutError"){},tN=class extends pr.TaggedError("CommitCollectionTimeoutError"){},qG=class extends pr.TaggedError("MergeToHostTimeoutError"){},Mi=(e,t)=>r=>r.pipe(S.timeoutFail({duration:Nn.millis(e),onTimeout:t})),mv=class extends pr.TaggedError("WorktreeLockError"){},rN=class extends pr.TaggedError("SessionCaptureError"){}});var W7e,aC,ntr,dx,hv=h(()=>{"use strict";Dn();Wd();pa();W7e=3e4,aC="",ntr=new RegExp(`!${aC}\`([^\`]+)\``,"g"),dx=(e,t,r)=>{let n=[...e.matchAll(ntr)];return n.length===0?S.succeed(e.replaceAll(aC,"")):S.gen(function*(){return yield*(yield*En).taskLog("Expanding shell expressions",i=>S.gen(function*(){let s=yield*S.all(n.map(c=>{let u=c[1];return S.gen(function*(){let l=yield*Vm.currentTimeMillis,d=yield*t.exec(u,{cwd:r}).pipe(S.timeoutOption(Nn.millis(W7e)));if(Ke.isNone(d)){let p=(yield*Vm.currentTimeMillis)-l;return yield*S.fail(new jG({message:`Shell expression \`${u}\` timed out after ${p}ms`,timeoutMs:W7e,expression:u,elapsedMs:p}))}let f=d.value;return f.exitCode!==0?yield*S.fail(new Kc({message:`Command \`${u}\` exited with code ${f.exitCode}: ${f.stderr}`,exitCode:f.exitCode})):f.stdout.trimEnd()})}),{concurrency:"unbounded"});for(let c=0;c<n.length;c++){let u=n[c][1],l=Math.ceil(s[c].length/4);i(`${u} \u2192 ~${l} tokens`)}let a=e;for(let c=n.length-1;c>=0;c--){let u=n[c],l=u.index;a=a.slice(0,l)+s[c]+a.slice(l+u[0].length)}return a.replaceAll(aC,"")}))})}});import{constants as lle,mkdir as otr,open as j7e,readdir as itr,readFile as dle,rm as nN}from"node:fs/promises";import{join as fle}from"node:path";var q7e,G7e,str,ple,GG,z7e,mle=h(()=>{"use strict";pa();q7e=e=>{try{return process.kill(e,0),!0}catch{return!1}},G7e=lle.O_WRONLY|lle.O_CREAT|lle.O_EXCL,str=async(e,t)=>{await nN(e,{force:!0});try{return await j7e(e,G7e)}catch(r){if(r.code!=="EEXIST")throw r;try{let n=await dle(e,"utf-8"),o=JSON.parse(n);throw new mv({message:`Worktree is in use by process ${o.pid} (branch '${o.branch}', acquired at ${o.acquiredAt})`,owningPid:o.pid,branch:o.branch,timestamp:o.acquiredAt})}catch(n){throw n instanceof mv?n:new Error(`Worktree lock already held for '${t}' (lock file: ${e})`)}}},ple=async(e,t,r)=>{await otr(e,{recursive:!0});let n=fle(e,`${t}.lock`),o;try{o=await j7e(n,G7e)}catch(s){if(s.code!=="EEXIST")throw s;let a;try{let c=await dle(n,"utf-8");a=JSON.parse(c)}catch{}if(a&&q7e(a.pid))throw new mv({message:`Worktree is in use by process ${a.pid} (branch '${a.branch}', acquired at ${a.acquiredAt})`,owningPid:a.pid,branch:a.branch,timestamp:a.acquiredAt});o=await str(n,t)}let i={pid:process.pid,branch:r,acquiredAt:new Date().toISOString()};try{await o.writeFile(JSON.stringify(i,null,2))}finally{await o.close()}},GG=async(e,t)=>{let r=fle(e,`${t}.lock`);try{await nN(r)}catch(n){if(n.code==="ENOENT")return;throw n}},z7e=async(e,t)=>{let r;try{r=await itr(e)}catch(n){if(n.code==="ENOENT")return;throw n}for(let n of r){if(!n.endsWith(".lock"))continue;let o=n.slice(0,-5),i=fle(e,n);if(!t.has(o)){await nN(i,{force:!0});continue}try{let s=await dle(i,"utf-8"),a=JSON.parse(s);q7e(a.pid)||await nN(i,{force:!0})}catch{await nN(i,{force:!0})}}}});import{execFile as atr}from"node:child_process";import{randomBytes as ctr}from"node:crypto";import{basename as utr,join as gv,normalize as ltr}from"node:path";var Av,yv,oN,V7e,Y7e,J7e,tc,zG,cC,dtr,ftr,ptr,mtr,htr,Qp,ig,bl,fx,uC=h(()=>{"use strict";Dn();rC();pa();mle();Av=3e4,yv=e=>e.replace(/\\/g,"/"),oN=["-c","branch.autoSetupMerge=false","-c","push.autoSetupRemote=false"],V7e=e=>{let t=r=>String(r).padStart(2,"0");return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`},Y7e=()=>ctr(3).toString("hex"),J7e=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"-"),tc=(e,t)=>S.async(r=>{atr("git",e,{cwd:t,env:{...process.env,LC_ALL:"C"}},(n,o,i)=>{r(n?S.fail(new ri({message:i?.trim()||n.message})):S.succeed(o))})}),zG=e=>{let t=V7e(new Date),r=Y7e();return e?`sandcastle/${J7e(e)}/${t}-${r}`:`sandcastle/${t}-${r}`},cC=e=>tc(["rev-parse","--abbrev-ref","HEAD"],e).pipe(S.map(t=>t.trim())),dtr=(e,t,r)=>e.find(n=>n.branch===t)??e.find(n=>yv(n.path)===yv(r)),ftr=(e,t)=>yv(e).startsWith(yv(t)),ptr=(e,t)=>{let r=yv(e);for(let n of t)if(yv(n)===r)return!1;return!0},mtr=e=>tc(["worktree","list","--porcelain"],e).pipe(S.map(t=>{let r=[],n=null,o=null;for(let i of t.split(`
271
+ `))i.startsWith("worktree ")?(n!==null&&r.push({path:n,branch:o}),n=i.slice(9).trim(),o=null):i.startsWith("branch ")&&(o=i.slice(18).trim());return n!==null&&r.push({path:n,branch:o}),r})),htr=(e,t)=>S.gen(function*(){if((yield*tc(["symbolic-ref","--quiet","HEAD"],e).pipe(S.map(a=>a.trim()),S.orElseSucceed(()=>"")))!==`refs/heads/${t}`){console.log(`Reusing worktree at ${e} (branch '${t}') \u2014 HEAD is not on '${t}', skipping origin refresh`);return}if((yield*S.either(tc([...oN,"fetch","origin",t],e)))._tag==="Left"){console.log(`Could not fetch from origin (reusing worktree at ${e} as-is, branch '${t}')`);return}let o=yield*tc(["rev-parse","HEAD"],e).pipe(S.map(a=>a.trim()),S.orElseSucceed(()=>""));if((yield*S.either(tc([...oN,"merge","--ff-only",`origin/${t}`],e)))._tag==="Left"){console.log(`Branch '${t}' has diverged from origin (reusing worktree at ${e} as-is)`);return}let s=yield*tc(["rev-parse","HEAD"],e).pipe(S.map(a=>a.trim()),S.orElseSucceed(()=>""));console.log(o&&s&&o!==s?`Fast-forwarded worktree at ${e} (branch '${t}') to origin/${t}`:`Reusing existing worktree at ${e} (branch '${t}')`)}),Qp=(e,t)=>S.gen(function*(){let r=yield*mo.FileSystem,n=gv(e,".sandcastle","worktrees");yield*r.makeDirectory(n,{recursive:!0}).pipe(S.mapError(a=>new ri({message:a.message})));let o,i;if(t?.branch)o=t.branch,i=o.replace(/\//g,"-");else{let a=V7e(new Date),c=Y7e();if(t?.name){let u=J7e(t.name);o=`sandcastle/${u}/${a}-${c}`,i=`sandcastle-${u}-${a}-${c}`}else o=`sandcastle/${a}-${c}`,i=`sandcastle-${a}-${c}`}let s=gv(n,i);if(t?.branch){let a=yield*mtr(e),c=dtr(a,o,s);if(c){if(ftr(c.path,n))return(yield*ig(c.path))?console.warn(`Reusing worktree at ${c.path} (branch '${o}') \u2014 worktree has uncommitted changes`):yield*htr(c.path,o),{path:ltr(c.path),branch:o};yield*S.fail(new ri({message:`Branch '${o}' is already checked out in worktree at '${c.path}'. Sandcastle's branch and merge-to-head strategies run the agent in a git worktree under .sandcastle/worktrees/, and git refuses to check out the same branch in two worktrees at once (HEAD would become ambiguous). Pick a different branch, or switch the main working tree to a different branch before re-running.`}))}yield*tc([...oN,"worktree","add",s,o],e).pipe(S.catchAll(u=>u.message.includes("invalid reference")?tc([...oN,"worktree","add","-b",o,s,t?.baseBranch??"HEAD"],e):S.fail(u)))}else yield*tc([...oN,"worktree","add","-b",o,s,"HEAD"],e).pipe(S.catchAll(a=>a.message.includes("already checked out")||a.message.includes("already exists")?S.fail(new ri({message:`Branch '${o}' is already checked out in another worktree. Use a different branch name, or wait for the other run to finish.`})):S.fail(a)));return{path:s,branch:o}}).pipe(Mi(Av,()=>new XO({message:`Worktree creation timed out after ${Av}ms`,timeoutMs:Av,path:e,operation:"create"}))),ig=e=>tc(["status","--porcelain"],e).pipe(S.map(t=>t.trim().length>0)),bl=e=>{let t=gv(e,"..","..","..");return tc(["worktree","remove","--force",e],t).pipe(S.asVoid)},fx=e=>S.gen(function*(){let t=yield*mo.FileSystem;yield*tc(["worktree","prune"],e);let r=yield*tc(["worktree","list","--porcelain"],e),n=new Set(r.split(`
272
+ `).filter(c=>c.startsWith("worktree ")).map(c=>c.slice(9).trim())),o=gv(e,".sandcastle","worktrees"),i=yield*t.readDirectory(o).pipe(S.map(c=>c),S.catchSome(c=>c._tag==="SystemError"&&c.reason==="NotFound"?Ke.some(S.succeed(null)):Ke.none()),S.mapError(c=>new ri({message:c.message})));if(i!==null){let c=yield*t.realPath(o).pipe(S.catchAll(()=>S.succeed(o)));for(let u of i){let l=gv(c,u);(yield*t.stat(l).pipe(S.map(f=>f.type==="Directory"),S.catchAll(()=>S.succeed(!1))))&&ptr(l,n)&&(yield*t.remove(l,{recursive:!0,force:!0}).pipe(S.mapError(f=>new ri({message:`Failed to remove ${l}: ${f.message}`}))))}}let s=gv(e,".sandcastle","locks"),a=new Set([...n].map(c=>utr(c)));yield*S.promise(()=>z7e(s,a))}).pipe(Mi(Av,()=>new XO({message:`Worktree prune timed out after ${Av}ms`,timeoutMs:Av,path:e,operation:"prune"})))});import{existsSync as gtr,constants as Atr}from"node:fs";import{copyFile as ytr,lstat as xtr,mkdir as Etr,readdir as btr,readlink as Str,symlink as Ctr}from"node:fs/promises";import{join as YG}from"node:path";var wtr,K7e,Op,iN=h(()=>{"use strict";Dn();pa();wtr=6e4,K7e=async(e,t)=>{let r;try{r=await xtr(e)}catch(n){let o=n?.code;if(o==="EACCES"||o==="EINVAL")return;throw n}if(r.isDirectory()){await Etr(t,{recursive:!0});let n=await btr(e);await Promise.all(n.map(o=>K7e(YG(e,o),YG(t,o))));return}if(r.isSymbolicLink()){let n=await Str(e);try{await Ctr(n,t)}catch(o){if(o?.code!=="EEXIST")throw o}return}if(r.isFile()){await ytr(e,t,Atr.COPYFILE_FICLONE);return}},Op=(e,t,r,n)=>{let o=n??wtr;return S.gen(function*(){for(let i of e){let s=YG(t,i);if(!gtr(s))continue;let a=YG(r,i);yield*S.tryPromise({try:()=>K7e(s,a),catch:c=>{let u=c,l=u?.message??String(c);return new $G({message:`Failed to copy ${i} to worktree: ${l}`,path:i,stderr:l,exitCode:typeof u?.errno=="number"?u.errno:null})}})}}).pipe(Mi(o,()=>new fv({message:`Copying files to worktree timed out after ${o}ms`,timeoutMs:o,paths:e})))}});var X7e,Z7e,hle,eet=h(()=>{"use strict";X7e=e=>{let{patchDir:t,failedStep:r,hasCommits:n,hasDiff:o,hasUntracked:i,branch:s}=e,a=s?`../../${t}`:t,c=[];n&&c.push({key:"commits",label:"committed changes",has:!0}),o&&c.push({key:"diff",label:"uncommitted changes",has:!0}),i&&c.push({key:"untracked",label:"untracked files",has:!0});let u=c.findIndex(p=>p.key===r),l=c[u],d=u+1,f=[];if(f.push(`Patch application failed at step ${d} (${l.label}).`),f.push(""),s&&(f.push("Set up worktree, then resolve:"),f.push(hle([`git worktree add .sandcastle/worktree ${s}`,"cd .sandcastle/worktree"])),f.push("")),r==="commits"){f.push("Resolve conflicts, then continue with:"),f.push(" git am --continue");let p=Z7e(a,c.slice(u+1));p.length>0&&(f.push(""),f.push("After all commits are applied, run the remaining steps:"),f.push(hle(p)))}else{let p=Z7e(a,c.slice(u));p.length>0&&(f.push("Run the remaining steps:"),f.push(hle(p)))}return f.join(`
271
273
  `)},Z7e=(e,t)=>{let r=[];for(let n of t)n.has&&(n.key==="commits"?r.push(`git am --3way ${e}/*.patch`):n.key==="diff"?r.push(`git apply ${e}/changes.patch`):n.key==="untracked"&&r.push(`cp -r ${e}/untracked/* .`));return r},hle=e=>e.length===1?` ${e[0]}`:e.map((t,r)=>r<e.length-1?` ${t} && \\`:` ${t}`).join(`
272
274
  `)});import{existsSync as Itr}from"node:fs";import{mkdir as ZG,readdir as ktr,readFile as oet,rm as tet,stat as vtr,writeFile as ret}from"node:fs/promises";import{basename as Rtr,dirname as net,join as Zc}from"node:path";var gle,JG,sN,KG,_tr,Btr,iet,Np,xv=h(()=>{"use strict";Dn();eet();pa();gle="refs/sandcastle/sync-base",JG=(e,t)=>S.tryPromise({try:async()=>{let{exec:r}=await import("node:child_process"),{promisify:n}=await import("node:util"),o=n(r),{stdout:i}=await o(e,{cwd:t,maxBuffer:10*1024*1024});return i},catch:r=>new Wn({message:`Host command failed: ${e}
273
275
  ${r instanceof Error?r.message:String(r)}`})}),sN=(e,t,r)=>S.tryPromise({try:()=>e.exec(t,r),catch:n=>new Wn({message:`Sandbox exec failed: ${t}
@@ -284,14 +286,14 @@ ${N instanceof Error?N.message:String(N)}`})}).pipe(Mi($,()=>new pv({message:`Ho
284
286
  `).map(B=>({sha:B})):[]}catch{return[]}}).pipe(Mi(l,()=>new tN({message:`Commit collection timed out after ${l}ms`,timeoutMs:l})))),v=y;return{result:w,branch:v,commits:I}})});import{mkdtemp as Utr,rm as $tr}from"node:fs/promises";import{tmpdir as Htr}from"node:os";import{join as set}from"node:path";var xle,aN,aet,cet=h(()=>{"use strict";Dn();pa();xle=(e,t)=>S.tryPromise({try:async()=>{let{exec:r}=await import("node:child_process"),{promisify:n}=await import("node:util"),o=n(r),{stdout:i}=await o(e,{cwd:t,maxBuffer:10*1024*1024});return i},catch:r=>new Wn({message:`Host command failed: ${e}
285
287
  ${r instanceof Error?r.message:String(r)}`})}),aN=(e,t,r)=>S.tryPromise({try:()=>e.exec(t,r),catch:n=>new Wn({message:`Sandbox exec failed: ${t}
286
288
  ${n instanceof Error?n.message:String(n)}`})}).pipe(S.flatMap(n=>n.exitCode!==0?S.fail(new Wn({message:`Sandbox command failed (exit ${n.exitCode}): ${t}
287
- ${n.stderr}`})):S.succeed(n))),aet=(e,t)=>S.gen(function*(){let r=(yield*xle("git rev-parse --abbrev-ref HEAD",e)).trim(),n=yield*S.tryPromise({try:()=>Utr(set(Htr(),"sandcastle-bundle-")),catch:i=>new Wn({message:`Failed to create temp dir: ${i instanceof Error?i.message:String(i)}`})}),o=set(n,"repo.bundle");return yield*S.ensuring(S.gen(function*(){yield*xle(`git bundle create "${o}" --all`,e);let s=(yield*aN(t,"mktemp -d -t sandcastle-XXXXXX")).stdout.trim(),a=`${s}/repo.bundle`;yield*S.tryPromise({try:()=>t.copyIn(o,a),catch:d=>new Wn({message:`Failed to copy bundle into sandbox: ${d instanceof Error?d.message:String(d)}`})});let c=t.worktreePath;yield*aN(t,`git clone "${a}" "${c}_clone"`),yield*aN(t,`rm -rf "${c}" && mv "${c}_clone" "${c}"`),yield*aN(t,`git checkout "${r}"`,{cwd:c}),yield*S.tryPromise({try:()=>t.exec(`rm -rf "${s}"`),catch:()=>new Wn({message:"Failed to clean up sandbox temp dir"})});let u=(yield*xle("git rev-parse HEAD",e)).trim(),l=(yield*aN(t,"git rev-parse HEAD",{cwd:c})).stdout.trim();u!==l&&(yield*S.fail(new Wn({message:`HEAD mismatch after sync-in: host=${u} sandbox=${l}`})))}),S.promise(()=>$tr(n,{recursive:!0,force:!0}))),{branch:r}})});import{existsSync as Wtr,statSync as jtr}from"node:fs";import{tmpdir as qtr,homedir as Gtr}from"node:os";import{isAbsolute as det,resolve as fet,join as Ele,dirname as ztr}from"node:path";import{mkdtemp as Vtr,writeFile as Ytr}from"node:fs/promises";var uet,bv,pet,Jtr,Ktr,ez,met,Ztr,qd,tz,rz,sg=h(()=>{"use strict";Dn();mx();pa();uet="/.sandcastle-parent-git",bv=e=>`sandcastle:${(e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"local").toLowerCase().replace(/[^a-z0-9_.-]/g,"-")||"local"}`,pet=(e,t)=>{let r=t??Gtr();return e==="~"?r:e.startsWith("~/")||e.startsWith("~\\")?r+"/"+e.slice(2):e},Jtr=e=>{let t=pet(e);return det(t)?t:fet(process.cwd(),t)},Ktr=(e,t)=>{let r=e==="~"||e.startsWith("~/")||e.startsWith("~\\");if(r&&t===void 0)throw new Error(`sandboxPath "${e}" contains a tilde but the provider has no sandboxHomedir set`);let n=r?pet(e,t):e;return det(n)?n:fet(Oo,n)},ez=(e,t)=>e.map(r=>{let n=Jtr(r.hostPath);if(!Wtr(n))throw new Error(`Mount hostPath does not exist: ${r.hostPath}`+(r.hostPath!==n?` (resolved to ${n})`:""));return{hostPath:n,sandboxPath:Ktr(r.sandboxPath,t),...r.readonly?{readonly:!0}:{}}}),met=(e,t,r,n=process.platform)=>{if(n!=="win32")return e;let o=t.replace(/\\/g,"/");return e.map(i=>{let s=i.hostPath.replace(/\\/g,"/"),a=i.sandboxPath;if(/^[A-Za-z]:[/\\]/.test(a)||a.includes("\\")){let c=a.replace(/\\/g,"/");if(c.startsWith(o+"/")){let u=c.slice(o.length);a=r+u}else c===o?a=r:a=c}return{...i,hostPath:s,sandboxPath:a}})},Ztr=e=>{let r=e.replace(/\\/g,"/").replace(/\/+$/,"").split("/"),n=r.pop();r.pop();let o=r.join("/");return{worktreeName:n,parentGitDir:o}},qd=(e,t,r,n,o,i=process.platform)=>S.gen(function*(){if(i!=="win32")return e;let s=n??(async v=>{let{readFile:k}=await import("node:fs/promises");return k(v,"utf-8")}),a=o??(async v=>{let{stat:k}=await import("node:fs/promises");return(await k(v)).isDirectory()?"directory":"file"}),c=Ele(t,".git"),u=yield*S.tryPromise({try:()=>a(c),catch:()=>null}).pipe(S.catchAll(()=>S.succeed(null)));if(u===null||u==="directory")return e;let l=yield*S.tryPromise({try:()=>s(c),catch:()=>null}).pipe(S.map(v=>v.trim()),S.catchAll(()=>S.succeed(null)));if(l===null)return e;let d=l.match(/^gitdir:\s*(.+)$/);if(!d)return e;let f=d[1],{parentGitDir:p,worktreeName:m}=Ztr(f),g=`${uet}/worktrees/${m}`,A=yield*S.tryPromise({try:()=>Vtr(Ele(qtr(),"sandcastle-git-")),catch:v=>new ti({message:`Failed to create temp dir for git override: ${v instanceof Error?v.message:String(v)}`})}),E=Ele(A,"git-override");yield*S.tryPromise({try:()=>Ytr(E,`gitdir: ${g}
288
- `),catch:v=>new ti({message:`Failed to write git override file: ${v instanceof Error?v.message:String(v)}`})});let y=p.replace(/\\/g,"/"),b=c.replace(/\\/g,"/"),w=[],I=!1;for(let v of e){let k=v.hostPath.replace(/\\/g,"/");k===y?w.push({...v,sandboxPath:uet}):k===b?(w.push({...v,hostPath:E,sandboxPath:`${r}/.git`}),I=!0):w.push(v)}return I||w.push({hostPath:E,sandboxPath:`${r}/.git`}),w}),tz=(e,t)=>{let r=`${e.hostPath}:${e.sandboxPath}`,n=[e.readonly?"ro":void 0,t||void 0].filter(o=>o!==void 0).join(",");return n?`${r}:${n}`:r},rz=(e,t,r=jtr)=>{let n=new Set;for(let o of e){let i;try{i=r(o.hostPath).isFile()}catch{continue}if(!i)continue;let s=ztr(o.sandboxPath);if(s!==t){if(!s.startsWith(t+"/"))throw new Error(`Cannot mount file to '${o.sandboxPath}': parent directory '${s}' is outside the sandbox home directory ('${t}'). Mount the parent directory instead, or rebuild the image with '${s}' pre-created.`);n.add(s)}}return[...n]}});import{existsSync as Xtr}from"node:fs";import{join as err,posix as trr}from"node:path";var Sv,ble,Sle,xo,rrr,nrr,orr,cN=h(()=>{"use strict";Dn();pa();mx();cet();sg();Sv=12e4,ble=12e4,Sle=12e4,xo=e=>e.provider.tag==="bind-mount"?nrr(e):e.provider.tag==="none"?rrr(e):orr(e),rrr=e=>S.tryPromise({try:()=>e.provider.create({worktreePath:e.worktreeOrRepoPath,env:e.env}),catch:t=>new ti({message:`Provider '${e.provider.name}' create failed: ${t instanceof Error?t.message:String(t)}`})}).pipe(S.map(t=>({handle:t,sandbox:ag(t),worktreePath:t.worktreePath}))),nrr=e=>S.tryPromise({try:()=>{let t=[{hostPath:e.worktreeOrRepoPath,sandboxPath:e.repoDir},...e.gitMounts],r=met(t,e.worktreeOrRepoPath,Oo),n=process.platform==="win32"?e.worktreeOrRepoPath.replace(/\\/g,"/"):e.worktreeOrRepoPath;return e.provider.create({worktreePath:n,hostRepoPath:e.hostRepoDir,mounts:r,env:e.env})},catch:t=>new ti({message:`Provider '${e.provider.name}' create failed: ${t instanceof Error?t.message:String(t)}`})}).pipe(S.map(t=>({handle:t,sandbox:ag(t),worktreePath:t.worktreePath})),Mi(Sv,()=>new eN({message:`Sandbox container start timed out after ${Sv}ms`,timeoutMs:Sv}))),orr=e=>S.gen(function*(){let t=yield*S.tryPromise({try:()=>e.provider.create({env:e.env}),catch:r=>new ti({message:`Isolated provider '${e.provider.name}' setup failed: ${r instanceof Error?r.message:String(r)}`})}).pipe(Mi(Sv,()=>new eN({message:`Isolated sandbox container start timed out after ${Sv}ms`,timeoutMs:Sv})));if(yield*aet(e.hostRepoDir,t).pipe(Mi(ble,()=>new HG({message:`Sync-in timed out after ${ble}ms`,timeoutMs:ble}))),e.copyPaths&&e.copyPaths.length>0){let r=e.copyPaths;yield*S.gen(function*(){for(let n of r){let o=err(e.hostRepoDir,n);if(!Xtr(o))continue;let i=trr.join(t.worktreePath,n);yield*S.tryPromise({try:()=>t.copyIn(o,i),catch:s=>new ti({message:`Failed to copy ${n} into sandbox: ${s instanceof Error?s.message:String(s)}`})})}}).pipe(Mi(Sle,()=>new fv({message:`Copying paths to worktree timed out after ${Sle}ms`,timeoutMs:Sle,paths:r})))}return{handle:t,sandbox:ag(t),worktreePath:t.worktreePath}})});import{join as het,resolve as irr}from"node:path";var srr,ag,Oo,cg,uN,arr,Cle,wle,Pp,get,mx=h(()=>{"use strict";Dn();rC();pa();uC();iN();Wd();Ev();cN();xv();sg();srr=e=>"copyIn"in e?(t,r)=>S.tryPromise({try:()=>e.copyIn(t,r),catch:n=>new lx({message:`copyIn failed: ${n instanceof Error?n.message:String(n)}`})}):"copyFileIn"in e?(t,r)=>S.tryPromise({try:()=>e.copyFileIn(t,r),catch:n=>new lx({message:`copyFileIn failed: ${n instanceof Error?n.message:String(n)}`})}):()=>S.fail(new lx({message:"copyIn is not supported for this sandbox provider"})),ag=e=>({exec:(t,r)=>S.tryPromise({try:()=>e.exec(t,r),catch:n=>new Dp({command:t,message:`exec failed: ${n instanceof Error?n.message:String(n)}`})}),copyIn:srr(e),copyFileOut:"copyFileOut"in e?(t,r)=>S.tryPromise({try:()=>e.copyFileOut(t,r),catch:n=>new lx({message:`copyFileOut failed: ${n instanceof Error?n.message:String(n)}`})}):()=>S.fail(new lx({message:"copyFileOut is not supported for this sandbox provider"}))}),Oo="/home/agent/workspace",cg=class extends Kt.Tag("SandboxFactory")(){},uN=class extends Kt.Tag("SandboxConfig")(){},arr=(e,t)=>{console.error(`
289
+ ${n.stderr}`})):S.succeed(n))),aet=(e,t)=>S.gen(function*(){let r=(yield*xle("git rev-parse --abbrev-ref HEAD",e)).trim(),n=yield*S.tryPromise({try:()=>Utr(set(Htr(),"sandcastle-bundle-")),catch:i=>new Wn({message:`Failed to create temp dir: ${i instanceof Error?i.message:String(i)}`})}),o=set(n,"repo.bundle");return yield*S.ensuring(S.gen(function*(){yield*xle(`git bundle create "${o}" --all`,e);let s=(yield*aN(t,"mktemp -d -t sandcastle-XXXXXX")).stdout.trim(),a=`${s}/repo.bundle`;yield*S.tryPromise({try:()=>t.copyIn(o,a),catch:d=>new Wn({message:`Failed to copy bundle into sandbox: ${d instanceof Error?d.message:String(d)}`})});let c=t.worktreePath;yield*aN(t,`git clone "${a}" "${c}_clone"`),yield*aN(t,`rm -rf "${c}" && mv "${c}_clone" "${c}"`),yield*aN(t,`git checkout "${r}"`,{cwd:c}),yield*S.tryPromise({try:()=>t.exec(`rm -rf "${s}"`),catch:()=>new Wn({message:"Failed to clean up sandbox temp dir"})});let u=(yield*xle("git rev-parse HEAD",e)).trim(),l=(yield*aN(t,"git rev-parse HEAD",{cwd:c})).stdout.trim();u!==l&&(yield*S.fail(new Wn({message:`HEAD mismatch after sync-in: host=${u} sandbox=${l}`})))}),S.promise(()=>$tr(n,{recursive:!0,force:!0}))),{branch:r}})});import{existsSync as Wtr,statSync as jtr}from"node:fs";import{tmpdir as qtr,homedir as Gtr}from"node:os";import{isAbsolute as det,resolve as fet,join as Ele,dirname as ztr}from"node:path";import{mkdtemp as Vtr,writeFile as Ytr}from"node:fs/promises";var uet,bv,pet,Jtr,Ktr,ez,met,Ztr,qd,tz,rz,sg=h(()=>{"use strict";Dn();mx();pa();uet="/.sandcastle-parent-git",bv=e=>`sandcastle:${(e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"local").toLowerCase().replace(/[^a-z0-9_.-]/g,"-")||"local"}`,pet=(e,t)=>{let r=t??Gtr();return e==="~"?r:e.startsWith("~/")||e.startsWith("~\\")?r+"/"+e.slice(2):e},Jtr=e=>{let t=pet(e);return det(t)?t:fet(process.cwd(),t)},Ktr=(e,t)=>{let r=e==="~"||e.startsWith("~/")||e.startsWith("~\\");if(r&&t===void 0)throw new Error(`sandboxPath "${e}" contains a tilde but the provider has no sandboxHomedir set`);let n=r?pet(e,t):e;return det(n)?n:fet(Oo,n)},ez=(e,t)=>e.map(r=>{let n=Jtr(r.hostPath);if(!Wtr(n))throw new Error(`Mount hostPath does not exist: ${r.hostPath}`+(r.hostPath!==n?` (resolved to ${n})`:""));return{hostPath:n,sandboxPath:Ktr(r.sandboxPath,t),...r.readonly?{readonly:!0}:{}}}),met=(e,t,r,n=process.platform)=>{if(n!=="win32")return e;let o=t.replace(/\\/g,"/");return e.map(i=>{let s=i.hostPath.replace(/\\/g,"/"),a=i.sandboxPath;if(/^[A-Za-z]:[/\\]/.test(a)||a.includes("\\")){let c=a.replace(/\\/g,"/");if(c.startsWith(o+"/")){let u=c.slice(o.length);a=r+u}else c===o?a=r:a=c}return{...i,hostPath:s,sandboxPath:a}})},Ztr=e=>{let r=e.replace(/\\/g,"/").replace(/\/+$/,"").split("/"),n=r.pop();r.pop();let o=r.join("/");return{worktreeName:n,parentGitDir:o}},qd=(e,t,r,n,o,i=process.platform)=>S.gen(function*(){if(i!=="win32")return e;let s=n??(async v=>{let{readFile:k}=await import("node:fs/promises");return k(v,"utf-8")}),a=o??(async v=>{let{stat:k}=await import("node:fs/promises");return(await k(v)).isDirectory()?"directory":"file"}),c=Ele(t,".git"),u=yield*S.tryPromise({try:()=>a(c),catch:()=>null}).pipe(S.catchAll(()=>S.succeed(null)));if(u===null||u==="directory")return e;let l=yield*S.tryPromise({try:()=>s(c),catch:()=>null}).pipe(S.map(v=>v.trim()),S.catchAll(()=>S.succeed(null)));if(l===null)return e;let d=l.match(/^gitdir:\s*(.+)$/);if(!d)return e;let f=d[1],{parentGitDir:p,worktreeName:m}=Ztr(f),g=`${uet}/worktrees/${m}`,A=yield*S.tryPromise({try:()=>Vtr(Ele(qtr(),"sandcastle-git-")),catch:v=>new ri({message:`Failed to create temp dir for git override: ${v instanceof Error?v.message:String(v)}`})}),E=Ele(A,"git-override");yield*S.tryPromise({try:()=>Ytr(E,`gitdir: ${g}
290
+ `),catch:v=>new ri({message:`Failed to write git override file: ${v instanceof Error?v.message:String(v)}`})});let y=p.replace(/\\/g,"/"),b=c.replace(/\\/g,"/"),w=[],I=!1;for(let v of e){let k=v.hostPath.replace(/\\/g,"/");k===y?w.push({...v,sandboxPath:uet}):k===b?(w.push({...v,hostPath:E,sandboxPath:`${r}/.git`}),I=!0):w.push(v)}return I||w.push({hostPath:E,sandboxPath:`${r}/.git`}),w}),tz=(e,t)=>{let r=`${e.hostPath}:${e.sandboxPath}`,n=[e.readonly?"ro":void 0,t||void 0].filter(o=>o!==void 0).join(",");return n?`${r}:${n}`:r},rz=(e,t,r=jtr)=>{let n=new Set;for(let o of e){let i;try{i=r(o.hostPath).isFile()}catch{continue}if(!i)continue;let s=ztr(o.sandboxPath);if(s!==t){if(!s.startsWith(t+"/"))throw new Error(`Cannot mount file to '${o.sandboxPath}': parent directory '${s}' is outside the sandbox home directory ('${t}'). Mount the parent directory instead, or rebuild the image with '${s}' pre-created.`);n.add(s)}}return[...n]}});import{existsSync as Xtr}from"node:fs";import{join as err,posix as trr}from"node:path";var Sv,ble,Sle,xo,rrr,nrr,orr,cN=h(()=>{"use strict";Dn();pa();mx();cet();sg();Sv=12e4,ble=12e4,Sle=12e4,xo=e=>e.provider.tag==="bind-mount"?nrr(e):e.provider.tag==="none"?rrr(e):orr(e),rrr=e=>S.tryPromise({try:()=>e.provider.create({worktreePath:e.worktreeOrRepoPath,env:e.env}),catch:t=>new ri({message:`Provider '${e.provider.name}' create failed: ${t instanceof Error?t.message:String(t)}`})}).pipe(S.map(t=>({handle:t,sandbox:ag(t),worktreePath:t.worktreePath}))),nrr=e=>S.tryPromise({try:()=>{let t=[{hostPath:e.worktreeOrRepoPath,sandboxPath:e.repoDir},...e.gitMounts],r=met(t,e.worktreeOrRepoPath,Oo),n=process.platform==="win32"?e.worktreeOrRepoPath.replace(/\\/g,"/"):e.worktreeOrRepoPath;return e.provider.create({worktreePath:n,hostRepoPath:e.hostRepoDir,mounts:r,env:e.env})},catch:t=>new ri({message:`Provider '${e.provider.name}' create failed: ${t instanceof Error?t.message:String(t)}`})}).pipe(S.map(t=>({handle:t,sandbox:ag(t),worktreePath:t.worktreePath})),Mi(Sv,()=>new eN({message:`Sandbox container start timed out after ${Sv}ms`,timeoutMs:Sv}))),orr=e=>S.gen(function*(){let t=yield*S.tryPromise({try:()=>e.provider.create({env:e.env}),catch:r=>new ri({message:`Isolated provider '${e.provider.name}' setup failed: ${r instanceof Error?r.message:String(r)}`})}).pipe(Mi(Sv,()=>new eN({message:`Isolated sandbox container start timed out after ${Sv}ms`,timeoutMs:Sv})));if(yield*aet(e.hostRepoDir,t).pipe(Mi(ble,()=>new HG({message:`Sync-in timed out after ${ble}ms`,timeoutMs:ble}))),e.copyPaths&&e.copyPaths.length>0){let r=e.copyPaths;yield*S.gen(function*(){for(let n of r){let o=err(e.hostRepoDir,n);if(!Xtr(o))continue;let i=trr.join(t.worktreePath,n);yield*S.tryPromise({try:()=>t.copyIn(o,i),catch:s=>new ri({message:`Failed to copy ${n} into sandbox: ${s instanceof Error?s.message:String(s)}`})})}}).pipe(Mi(Sle,()=>new fv({message:`Copying paths to worktree timed out after ${Sle}ms`,timeoutMs:Sle,paths:r})))}return{handle:t,sandbox:ag(t),worktreePath:t.worktreePath}})});import{join as het,resolve as irr}from"node:path";var srr,ag,Oo,cg,uN,arr,Cle,wle,Pp,get,mx=h(()=>{"use strict";Dn();rC();pa();uC();iN();Wd();Ev();cN();xv();sg();srr=e=>"copyIn"in e?(t,r)=>S.tryPromise({try:()=>e.copyIn(t,r),catch:n=>new lx({message:`copyIn failed: ${n instanceof Error?n.message:String(n)}`})}):"copyFileIn"in e?(t,r)=>S.tryPromise({try:()=>e.copyFileIn(t,r),catch:n=>new lx({message:`copyFileIn failed: ${n instanceof Error?n.message:String(n)}`})}):()=>S.fail(new lx({message:"copyIn is not supported for this sandbox provider"})),ag=e=>({exec:(t,r)=>S.tryPromise({try:()=>e.exec(t,r),catch:n=>new Dp({command:t,message:`exec failed: ${n instanceof Error?n.message:String(n)}`})}),copyIn:srr(e),copyFileOut:"copyFileOut"in e?(t,r)=>S.tryPromise({try:()=>e.copyFileOut(t,r),catch:n=>new lx({message:`copyFileOut failed: ${n instanceof Error?n.message:String(n)}`})}):()=>S.fail(new lx({message:"copyFileOut is not supported for this sandbox provider"}))}),Oo="/home/agent/workspace",cg=class extends Kt.Tag("SandboxFactory")(){},uN=class extends Kt.Tag("SandboxConfig")(){},arr=(e,t)=>{console.error(`
289
291
  ${t}`),console.error(` To review: cd ${e}`),console.error(` To clean up: git worktree remove --force ${e}`)},Cle=(e,t)=>ig(e).pipe(S.catchAll(()=>S.succeed(!1)),S.flatMap(r=>r?(arr(e,Fn.isSuccess(t)?`Run succeeded but worktree has uncommitted changes at ${e}`:`Worktree preserved at ${e}`),S.succeed(e)):(Fn.isSuccess(t)||console.error(`
290
- Worktree removed (no uncommitted changes)`),bl(e).pipe(S.map(()=>{}))))),wle=(e,t)=>{if(e!==void 0){if(t instanceof sC)return new sC({message:t.message,timeoutMs:t.timeoutMs,preservedWorktreePath:e});if(t instanceof iC)return new iC({message:t.message,preservedWorktreePath:e})}return t},Pp=e=>S.gen(function*(){let t=yield*mo.FileSystem;if((yield*t.stat(e)).type==="Directory")return[{hostPath:e,sandboxPath:e}];let o=(yield*t.readFileString(e)).trim().match(/^gitdir:\s*(.+)$/);if(!o)return[{hostPath:e,sandboxPath:e}];let i=o[1],s=irr(i,"..","..");return[{hostPath:e,sandboxPath:e},{hostPath:s,sandboxPath:s}]}),get={layer:Er.effect(cg,S.gen(function*(){let{env:e,hostRepoDir:t,copyToWorktree:r,name:n,sandboxProvider:o,branchStrategy:i,hooks:s,signal:a,timeouts:c}=yield*uN,u=i.type==="head",l=i.type==="branch"?i.branch:void 0,d=i.type==="branch"?i.baseBranch:void 0,f=yield*mo.FileSystem,p=yield*En,m=()=>fx(t).pipe(S.catchAll(g=>S.sync(()=>{console.error("[sandcastle] Warning: failed to prune stale worktrees:",g.message)})),S.andThen(l?Qp(t,{branch:l,baseBranch:d}):Qp(t,{name:n})),S.provideService(mo.FileSystem,f));return{withSandbox:g=>{if(o.tag==="none"){let E;return u?(s?.host?.onWorktreeReady?.length?ma(s.host.onWorktreeReady,t,a):S.void).pipe(S.andThen(S.acquireUseRelease(xo({provider:o,hostRepoDir:t,env:e,worktreeOrRepoPath:t}),({sandbox:y,worktreePath:b})=>g({hostWorktreePath:t,sandboxRepoPath:b},y),({handle:y})=>S.tryPromise({try:()=>y.close(),catch:()=>{}}).pipe(S.orDie)).pipe(S.map(y=>({value:y,preservedWorktreePath:void 0}))))):S.acquireUseRelease(m(),y=>(r&&r.length>0?p.spinner("Copying to worktree",Op(r,t,y.path,c?.copyToWorktreeMs)):S.succeed(void 0)).pipe(S.andThen(s?.host?.onWorktreeReady?.length?ma(s.host.onWorktreeReady,y.path,a):S.void),S.andThen(S.acquireUseRelease(xo({provider:o,hostRepoDir:t,env:e,worktreeOrRepoPath:y.path}),({sandbox:b,worktreePath:w})=>g({hostWorktreePath:y.path,sandboxRepoPath:w},b),({handle:b})=>S.tryPromise({try:()=>b.close(),catch:()=>{}}).pipe(S.orDie)))),(y,b)=>Cle(y.path,b).pipe(S.tap(w=>{E=w}),S.asVoid,S.orDie)).pipe(S.map(y=>({value:y,preservedWorktreePath:E})),S.mapError(y=>wle(E,y)))}if(o.tag==="isolated"){let E;return S.acquireUseRelease(m(),y=>(s?.host?.onWorktreeReady?.length?ma(s.host.onWorktreeReady,y.path,a):S.void).pipe(S.andThen(S.acquireUseRelease(xo({provider:o,hostRepoDir:y.path,env:e,copyPaths:r}),({sandbox:b,worktreePath:w,handle:I})=>g({hostWorktreePath:y.path,sandboxRepoPath:w,applyToHost:()=>Np(y.path,I)},b),({handle:b})=>S.tryPromise({try:()=>b.close(),catch:()=>{}}).pipe(S.orDie)))),(y,b)=>Cle(y.path,b).pipe(S.tap(w=>{E=w}),S.asVoid,S.orDie)).pipe(S.map(y=>({value:y,preservedWorktreePath:E})),S.mapError(y=>wle(E,y)))}if(u){let E=het(t,".git");return(s?.host?.onWorktreeReady?.length?ma(s.host.onWorktreeReady,t,a):S.void).pipe(S.andThen(Pp(E)),S.provideService(mo.FileSystem,f),S.mapError(y=>new ti({message:`Failed to resolve git mounts: ${y}`})),S.flatMap(y=>qd(y,t,Oo)),S.flatMap(y=>S.acquireUseRelease(xo({provider:o,hostRepoDir:t,env:e,worktreeOrRepoPath:t,gitMounts:y,repoDir:Oo}),({sandbox:b,worktreePath:w,handle:I})=>g({hostWorktreePath:t,sandboxRepoPath:w,bindMountHandle:I},b),({handle:b})=>S.tryPromise({try:()=>b.close(),catch:()=>{}}).pipe(S.orDie)).pipe(S.map(b=>({value:b,preservedWorktreePath:void 0})))))}let A;return S.acquireUseRelease(m(),E=>(r&&r.length>0?p.spinner("Copying to worktree",Op(r,t,E.path,c?.copyToWorktreeMs)):S.succeed(void 0)).pipe(S.andThen(s?.host?.onWorktreeReady?.length?ma(s.host.onWorktreeReady,E.path,a):S.void),S.andThen(Pp(het(t,".git")).pipe(S.provideService(mo.FileSystem,f),S.mapError(y=>new ti({message:`Failed to resolve git mounts: ${y}`})))),S.flatMap(y=>qd(y,E.path,Oo)),S.flatMap(y=>S.acquireUseRelease(xo({provider:o,hostRepoDir:t,env:e,worktreeOrRepoPath:E.path,gitMounts:y,repoDir:Oo}),({sandbox:b,worktreePath:w,handle:I})=>g({hostWorktreePath:E.path,sandboxRepoPath:w,bindMountHandle:I},b),({handle:b})=>S.tryPromise({try:()=>b.close(),catch:()=>{}}).pipe(S.orDie)))),(E,y)=>Cle(E.path,y).pipe(S.tap(b=>{A=b}),S.asVoid,S.orDie)).pipe(S.map(E=>({value:E,preservedWorktreePath:A})),S.mapError(E=>wle(A,E)))}}}))}});var crr,nz,Aet=h(()=>{"use strict";crr=/[.!?] $/,nz=class{buffer="";timer=null;onFlush;constructor(t){this.onFlush=t}write(t){if(t.length!==0){if(this.buffer+=t,this.clearTimer(),this.shouldFlush()){this.doFlush();return}this.timer=setTimeout(()=>{this.doFlush()},50)}}flush(){this.clearTimer(),this.doFlush()}dispose(){this.flush()}shouldFlush(){return!!(this.buffer.includes(`
292
+ Worktree removed (no uncommitted changes)`),bl(e).pipe(S.map(()=>{}))))),wle=(e,t)=>{if(e!==void 0){if(t instanceof sC)return new sC({message:t.message,timeoutMs:t.timeoutMs,preservedWorktreePath:e});if(t instanceof iC)return new iC({message:t.message,preservedWorktreePath:e})}return t},Pp=e=>S.gen(function*(){let t=yield*mo.FileSystem;if((yield*t.stat(e)).type==="Directory")return[{hostPath:e,sandboxPath:e}];let o=(yield*t.readFileString(e)).trim().match(/^gitdir:\s*(.+)$/);if(!o)return[{hostPath:e,sandboxPath:e}];let i=o[1],s=irr(i,"..","..");return[{hostPath:e,sandboxPath:e},{hostPath:s,sandboxPath:s}]}),get={layer:Er.effect(cg,S.gen(function*(){let{env:e,hostRepoDir:t,copyToWorktree:r,name:n,sandboxProvider:o,branchStrategy:i,hooks:s,signal:a,timeouts:c}=yield*uN,u=i.type==="head",l=i.type==="branch"?i.branch:void 0,d=i.type==="branch"?i.baseBranch:void 0,f=yield*mo.FileSystem,p=yield*En,m=()=>fx(t).pipe(S.catchAll(g=>S.sync(()=>{console.error("[sandcastle] Warning: failed to prune stale worktrees:",g.message)})),S.andThen(l?Qp(t,{branch:l,baseBranch:d}):Qp(t,{name:n})),S.provideService(mo.FileSystem,f));return{withSandbox:g=>{if(o.tag==="none"){let E;return u?(s?.host?.onWorktreeReady?.length?ma(s.host.onWorktreeReady,t,a):S.void).pipe(S.andThen(S.acquireUseRelease(xo({provider:o,hostRepoDir:t,env:e,worktreeOrRepoPath:t}),({sandbox:y,worktreePath:b})=>g({hostWorktreePath:t,sandboxRepoPath:b},y),({handle:y})=>S.tryPromise({try:()=>y.close(),catch:()=>{}}).pipe(S.orDie)).pipe(S.map(y=>({value:y,preservedWorktreePath:void 0}))))):S.acquireUseRelease(m(),y=>(r&&r.length>0?p.spinner("Copying to worktree",Op(r,t,y.path,c?.copyToWorktreeMs)):S.succeed(void 0)).pipe(S.andThen(s?.host?.onWorktreeReady?.length?ma(s.host.onWorktreeReady,y.path,a):S.void),S.andThen(S.acquireUseRelease(xo({provider:o,hostRepoDir:t,env:e,worktreeOrRepoPath:y.path}),({sandbox:b,worktreePath:w})=>g({hostWorktreePath:y.path,sandboxRepoPath:w},b),({handle:b})=>S.tryPromise({try:()=>b.close(),catch:()=>{}}).pipe(S.orDie)))),(y,b)=>Cle(y.path,b).pipe(S.tap(w=>{E=w}),S.asVoid,S.orDie)).pipe(S.map(y=>({value:y,preservedWorktreePath:E})),S.mapError(y=>wle(E,y)))}if(o.tag==="isolated"){let E;return S.acquireUseRelease(m(),y=>(s?.host?.onWorktreeReady?.length?ma(s.host.onWorktreeReady,y.path,a):S.void).pipe(S.andThen(S.acquireUseRelease(xo({provider:o,hostRepoDir:y.path,env:e,copyPaths:r}),({sandbox:b,worktreePath:w,handle:I})=>g({hostWorktreePath:y.path,sandboxRepoPath:w,applyToHost:()=>Np(y.path,I)},b),({handle:b})=>S.tryPromise({try:()=>b.close(),catch:()=>{}}).pipe(S.orDie)))),(y,b)=>Cle(y.path,b).pipe(S.tap(w=>{E=w}),S.asVoid,S.orDie)).pipe(S.map(y=>({value:y,preservedWorktreePath:E})),S.mapError(y=>wle(E,y)))}if(u){let E=het(t,".git");return(s?.host?.onWorktreeReady?.length?ma(s.host.onWorktreeReady,t,a):S.void).pipe(S.andThen(Pp(E)),S.provideService(mo.FileSystem,f),S.mapError(y=>new ri({message:`Failed to resolve git mounts: ${y}`})),S.flatMap(y=>qd(y,t,Oo)),S.flatMap(y=>S.acquireUseRelease(xo({provider:o,hostRepoDir:t,env:e,worktreeOrRepoPath:t,gitMounts:y,repoDir:Oo}),({sandbox:b,worktreePath:w,handle:I})=>g({hostWorktreePath:t,sandboxRepoPath:w,bindMountHandle:I},b),({handle:b})=>S.tryPromise({try:()=>b.close(),catch:()=>{}}).pipe(S.orDie)).pipe(S.map(b=>({value:b,preservedWorktreePath:void 0})))))}let A;return S.acquireUseRelease(m(),E=>(r&&r.length>0?p.spinner("Copying to worktree",Op(r,t,E.path,c?.copyToWorktreeMs)):S.succeed(void 0)).pipe(S.andThen(s?.host?.onWorktreeReady?.length?ma(s.host.onWorktreeReady,E.path,a):S.void),S.andThen(Pp(het(t,".git")).pipe(S.provideService(mo.FileSystem,f),S.mapError(y=>new ri({message:`Failed to resolve git mounts: ${y}`})))),S.flatMap(y=>qd(y,E.path,Oo)),S.flatMap(y=>S.acquireUseRelease(xo({provider:o,hostRepoDir:t,env:e,worktreeOrRepoPath:E.path,gitMounts:y,repoDir:Oo}),({sandbox:b,worktreePath:w,handle:I})=>g({hostWorktreePath:E.path,sandboxRepoPath:w,bindMountHandle:I},b),({handle:b})=>S.tryPromise({try:()=>b.close(),catch:()=>{}}).pipe(S.orDie)))),(E,y)=>Cle(E.path,y).pipe(S.tap(b=>{A=b}),S.asVoid,S.orDie)).pipe(S.map(E=>({value:E,preservedWorktreePath:A})),S.mapError(E=>wle(A,E)))}}}))}});var crr,nz,Aet=h(()=>{"use strict";crr=/[.!?] $/,nz=class{buffer="";timer=null;onFlush;constructor(t){this.onFlush=t}write(t){if(t.length!==0){if(this.buffer+=t,this.clearTimer(),this.shouldFlush()){this.doFlush();return}this.timer=setTimeout(()=>{this.doFlush()},50)}}flush(){this.clearTimer(),this.doFlush()}dispose(){this.flush()}shouldFlush(){return!!(this.buffer.includes(`
291
293
  `)||crr.test(this.buffer)||this.buffer.length>=80)}doFlush(){if(this.buffer.length===0)return;let t=this.buffer;this.buffer="",this.onFlush(t)}clearTimer(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}}});var yet,xet,Eet,Ile,kle=h(()=>{"use strict";yet=Symbol.for("@ai-hero/sandcastle/run-abort-metadata"),xet=e=>typeof e=="object"&&e!==null,Eet=(e,t)=>{xet(e)&&Object.defineProperty(e,yet,{value:t,configurable:!0,enumerable:!1,writable:!0})},Ile=e=>{if(!xet(e))return;let t=e[yet];if(typeof t=="object"&&t!==null&&Array.isArray(t.iterations))return t}});var urr,lrr,drr,frr,prr,mrr,Cv,oz=h(()=>{"use strict";Dn();KO();Wd();hv();pa();mx();Ev();Aet();kle();urr=6e4,lrr=(e,t,r,n,o,i,s,a,c,u,l,d,f=urr,p,m,g,A,E,y,b,w)=>S.gen(function*(){let I="",v,k,R="",B=yield*Or.make(),L=yield*Or.make(),D=null,ee=!1,F=null,_=0,P=Oe=>{Oe!==null&&S.runFork(VA.interrupt(Oe))},$=()=>{P(F),_=0,F=S.runFork(S.gen(function*(){for(;;)yield*S.sleep(Nn.millis(f)),_++,l(_)}))},N=()=>{P(D),ee?D=S.runFork(S.gen(function*(){yield*S.sleep(Nn.millis(i)),d(i),yield*Or.succeed(L,{result:I||R,sessionId:v,usage:k})})):(D=S.runFork(S.gen(function*(){yield*S.sleep(Nn.millis(o)),yield*Or.fail(B,new sC({message:`Agent idle for ${o/1e3} seconds \u2014 no output received. Consider increasing the idle timeout with --idle-timeout.`,timeoutMs:o}))})),$())},q=yield*Or.make(),re=null;if(g){if(g.aborted)return yield*S.die(g.reason);let Oe=()=>{S.runFork(Or.die(q,g.reason))};g.addEventListener("abort",Oe,{once:!0}),re=()=>g.removeEventListener("abort",Oe)}N();let ie=S.gen(function*(){let Oe=n.buildPrintCommand({prompt:r,dangerouslySkipPermissions:!0,resumeSession:p,forkSession:m,systemPrompt:E}),Ye=yield*e.exec(Oe.command,{onLine:T=>{try{u(T)}catch{}for(let J of n.parseStreamLine(T))J.type==="text"?(a(J.text),R+=J.text):J.type==="result"?(I=J.result,R+=J.result,b?.(J.result)):J.type==="tool_call"?c(J.name,J.args):J.type==="reasoning"?A?.(J.text??"",J.tokens):J.type==="session_id"?(v=J.sessionId,w?.(J.sessionId)):J.type==="usage"&&(k=J.usage,y?.(J.usage));!ee&&s.some(J=>R.includes(J))&&(ee=!0,P(F),F=null),N()},cwd:t,stdin:Oe.stdin});if(Ye.exitCode!==0){let T=Ye.stderr;return T.trim()||(T=I),T.trim()||(T=Ye.stdout.split(`
292
294
  `).filter(Ne=>Ne.trim()).slice(-20).join(`
293
295
  `)),yield*S.fail(new iC({message:`${n.name} exited with code ${Ye.exitCode}:
294
- ${T}`}))}return{result:I||Ye.stdout,sessionId:v,usage:k}}).pipe(S.ensuring(S.sync(()=>{P(D),D=null,P(F),F=null}))),ue=S.raceFirst(ie,Or.await(B));return ue=S.raceFirst(ue,Or.await(L)),g&&(ue=S.raceFirst(ue,Or.await(q))),yield*ue.pipe(S.ensuring(S.sync(()=>{re?.(),P(D),D=null,P(F),F=null})))}),drr="<promise>COMPLETE</promise>",frr=10*60,prr=60,mrr=(e,t)=>{Eet(e,{iterations:t})},Cv=e=>{let t=(e.idleTimeoutSeconds??frr)*1e3,r=(e.completionTimeoutSeconds??prr)*1e3;return S.gen(function*(){let n=yield*cg,o=yield*En,i=yield*JO,{hostRepoDir:s,iterations:a,hooks:c,prompt:u,branch:l,provider:d}=e,f;e.completionSignal===void 0?f=[drr]:Array.isArray(e.completionSignal)?f=e.completionSignal:f=[e.completionSignal];let p=I=>e.name?`[${e.name}] ${I}`:I,m=[],g=[],A="",E="",y,b=()=>e.signal?.aborted?S.die(e.signal.reason):S.void,w=e.resumeSession;for(let I=1;I<=a;I++){yield*b(),yield*o.status(p(`Iteration ${I}/${a}`),"info");let v=yield*n.withSandbox(({hostWorktreePath:R,sandboxRepoPath:B,applyToHost:L,bindMountHandle:D},ee)=>px({hostRepoDir:s,sandboxRepoDir:B,hooks:c,branch:l,hostWorktreePath:R,applyToHost:L,signal:e.signal,timeouts:e.timeouts,keepSourceBranch:e.keepSourceBranch},ee,F=>S.gen(function*(){let _=e.allowIterResume?w:I===1?e.resumeSession:void 0,P=I===1?e.forkSession:void 0;_&&D&&d.sessionStorage&&(yield*o.status(p("Resuming session"),"info"),yield*S.tryPromise({try:()=>d.sessionStorage.resumeIntoSandbox({hostCwd:s,sandboxCwd:F.sandboxRepoDir,sessionId:_,handle:D}),catch:at=>new rN({message:`Session resume failed: ${at instanceof Error?at.message:String(at)}`,sessionId:_})}));let $=e.skipPromptExpansion?u:yield*dx(u,F.sandbox,F.sandboxRepoDir);yield*o.status(p("Agent started"),"success");let N=(at,Fr,jn)=>S.gen(function*(){let Mo,Ui=jn;if(!d.captureSessions||!d.sessionStorage||!D)return{sessionFilePath:Mo,usage:Ui};if(Fr||(yield*o.status(p("Capturing session"),"info")),yield*S.tryPromise({try:()=>d.sessionStorage.captureToHost({hostCwd:s,sandboxCwd:F.sandboxRepoDir,sessionId:at,handle:D}),catch:$i=>new rN({message:`Session capture failed: ${$i instanceof Error?$i.message:String($i)}`,sessionId:at})}),Mo=d.sessionStorage.hostSessionFilePath(s,at),d.parseSessionUsage){let $i=yield*S.promise(()=>d.sessionStorage.readHostSession(s,at).catch(()=>{}));if($i){let Ms=d.parseSessionUsage($i);Ms&&(Ui=Ms)}}return{sessionFilePath:Mo,usage:Ui}}),q=new nz(at=>{S.runPromise(o.text(at)),S.runPromise(i.emit({type:"text",message:at,iteration:I,timestamp:new Date}))}),re=at=>{q.write(at)},ie=(at,Fr)=>{q.flush(),S.runPromise(o.toolCall(at,Fr)),S.runPromise(i.emit({type:"toolCall",name:at,formattedArgs:Fr,iteration:I,timestamp:new Date}))},ue=at=>{S.runPromise(i.emit({type:"raw",line:at,iteration:I,timestamp:new Date}))},Oe=(at,Fr)=>{S.runPromise(i.emit({type:"reasoning",message:at,...Fr!==void 0?{tokens:Fr}:{},iteration:I,timestamp:new Date}))},Ye=at=>{S.runPromise(i.emit({type:"usage",inputTokens:at.inputTokens,outputTokens:at.outputTokens,cacheReadInputTokens:at.cacheReadInputTokens,cacheCreationInputTokens:at.cacheCreationInputTokens,...at.reasoningTokens!==void 0?{reasoningTokens:at.reasoningTokens}:{},...at.costUsd!==void 0?{costUsd:at.costUsd}:{},iteration:I,timestamp:new Date}))},T=at=>{q.flush(),S.runPromise(i.emit({type:"result",result:at,iteration:I,timestamp:new Date}))},J,Ne=at=>{J=at,S.runPromise(i.emit({type:"sessionId",sessionId:at,iteration:I,timestamp:new Date}))},Cr=at=>{let Fr=at===1?"Agent idle for 1 minute":`Agent idle for ${at} minutes`;S.runPromise(o.status(p(Fr),"warn"))},Li=at=>{S.runPromise(o.status(p(`Completion signal seen but agent process is hanging \u2014 force-completing after ${at/1e3}s grace window.`),"warn"))};return yield*S.gen(function*(){let{result:at,sessionId:Fr,usage:jn}=yield*lrr(F.sandbox,F.sandboxRepoDir,$,d,t,r,f,re,ie,ue,Cr,Li,e._idleWarningIntervalMs,_,P,e.signal,Oe,e.systemPrompt,Ye,T,Ne);q.dispose(),yield*o.status(p("Agent stopped"),"info");let{sessionFilePath:Mo,usage:Ui}=Fr?yield*N(Fr,!1,jn):{sessionFilePath:void 0,usage:jn};return{completionSignal:f.find(Ms=>at.includes(Ms)),stdout:at,sessionId:Fr,sessionFilePath:Mo,usage:Ui}}).pipe(S.catchAllCause(at=>S.gen(function*(){if(q.dispose(),e.signal?.aborted){let Fr=J,jn=Fr?yield*N(Fr,!0).pipe(S.catchAll(()=>S.succeed({sessionFilePath:void 0,usage:void 0}))):{sessionFilePath:void 0,usage:void 0};mrr(e.signal.reason,[...g,{sessionId:Fr,sessionFilePath:jn.sessionFilePath,usage:jn.usage}])}return yield*S.failCause(at)})))}))),k=v.value;if(y=v.preservedWorktreePath,m.push(...k.commits),A+=k.result.stdout,E=k.branch,g.push({sessionId:k.result.sessionId,sessionFilePath:k.result.sessionFilePath,usage:k.result.usage}),e.allowIterResume&&k.result.sessionId&&(w=k.result.sessionId),k.result.completionSignal!==void 0)return yield*o.status(p(`Agent signaled completion after ${I} iteration(s).`),"success"),{iterations:g,completionSignal:k.result.completionSignal,stdout:A,commits:m,branch:E,preservedWorktreePath:y}}return yield*o.status(p(`Reached max iterations (${a}).`),"info"),{iterations:g,completionSignal:void 0,stdout:A,commits:m,branch:E,preservedWorktreePath:y}})}});var Mp,lN=h(()=>{"use strict";rC();Dn();pa();Mp=e=>{let{prompt:t,promptFile:r}=e;return t!==void 0&&r!==void 0?S.fail(new Kc({message:"Cannot provide both --prompt and --prompt-file"})):t!==void 0?S.succeed({text:t,source:"inline"}):r===void 0?S.fail(new Kc({message:"Must provide either prompt or promptFile. Pass prompt: '...' or promptFile: './.sandcastle/prompt.md' to run()."})):S.gen(function*(){return{text:yield*(yield*mo.FileSystem).readFileString(r).pipe(S.catchAll(i=>S.fail(new Kc({message:`Failed to read prompt from ${r}: ${i}`})))),source:"template"}})}});import{join as hrr}from"node:path";var grr,Fp,dN=h(()=>{"use strict";rC();Dn();grr=e=>S.gen(function*(){let r=yield*(yield*mo.FileSystem).readFileString(e).pipe(S.catchAll(()=>S.succeed(null)));if(r===null)return{};let n={};for(let o of r.split(`
296
+ ${T}`}))}return{result:I||Ye.stdout,sessionId:v,usage:k}}).pipe(S.ensuring(S.sync(()=>{P(D),D=null,P(F),F=null}))),ue=S.raceFirst(ie,Or.await(B));return ue=S.raceFirst(ue,Or.await(L)),g&&(ue=S.raceFirst(ue,Or.await(q))),yield*ue.pipe(S.ensuring(S.sync(()=>{re?.(),P(D),D=null,P(F),F=null})))}),drr="<promise>COMPLETE</promise>",frr=10*60,prr=60,mrr=(e,t)=>{Eet(e,{iterations:t})},Cv=e=>{let t=(e.idleTimeoutSeconds??frr)*1e3,r=(e.completionTimeoutSeconds??prr)*1e3;return S.gen(function*(){let n=yield*cg,o=yield*En,i=yield*JO,{hostRepoDir:s,iterations:a,hooks:c,prompt:u,branch:l,provider:d}=e,f;e.completionSignal===void 0?f=[drr]:Array.isArray(e.completionSignal)?f=e.completionSignal:f=[e.completionSignal];let p=I=>e.name?`[${e.name}] ${I}`:I,m=[],g=[],A="",E="",y,b=()=>e.signal?.aborted?S.die(e.signal.reason):S.void,w=e.resumeSession;for(let I=1;I<=a;I++){yield*b(),yield*o.status(p(`Iteration ${I}/${a}`),"info");let v=yield*n.withSandbox(({hostWorktreePath:R,sandboxRepoPath:B,applyToHost:L,bindMountHandle:D},ee)=>px({hostRepoDir:s,sandboxRepoDir:B,hooks:c,branch:l,hostWorktreePath:R,applyToHost:L,signal:e.signal,timeouts:e.timeouts,keepSourceBranch:e.keepSourceBranch},ee,F=>S.gen(function*(){let _=e.allowIterResume?w:I===1?e.resumeSession:void 0,P=I===1?e.forkSession:void 0;_&&D&&d.sessionStorage&&(yield*o.status(p("Resuming session"),"info"),yield*S.tryPromise({try:()=>d.sessionStorage.resumeIntoSandbox({hostCwd:s,sandboxCwd:F.sandboxRepoDir,sessionId:_,handle:D}),catch:at=>new rN({message:`Session resume failed: ${at instanceof Error?at.message:String(at)}`,sessionId:_})}));let $=e.skipPromptExpansion?u:yield*dx(u,F.sandbox,F.sandboxRepoDir);yield*o.status(p("Agent started"),"success");let N=(at,Fr,jn)=>S.gen(function*(){let Mo,Ui=jn;if(!d.captureSessions||!d.sessionStorage||!D)return{sessionFilePath:Mo,usage:Ui};if(Fr||(yield*o.status(p("Capturing session"),"info")),yield*S.tryPromise({try:()=>d.sessionStorage.captureToHost({hostCwd:s,sandboxCwd:F.sandboxRepoDir,sessionId:at,handle:D}),catch:$i=>new rN({message:`Session capture failed: ${$i instanceof Error?$i.message:String($i)}`,sessionId:at})}),Mo=d.sessionStorage.hostSessionFilePath(s,at),d.parseSessionUsage){let $i=yield*S.promise(()=>d.sessionStorage.readHostSession(s,at).catch(()=>{}));if($i){let Ms=d.parseSessionUsage($i);Ms&&(Ui=Ms)}}return{sessionFilePath:Mo,usage:Ui}}),q=new nz(at=>{S.runPromise(o.textChunk(at)),S.runPromise(i.emit({type:"text",message:at,iteration:I,timestamp:new Date}))}),re=at=>{q.write(at)},ie=(at,Fr)=>{q.flush(),S.runPromise(o.toolCall(at,Fr)),S.runPromise(i.emit({type:"toolCall",name:at,formattedArgs:Fr,iteration:I,timestamp:new Date}))},ue=at=>{S.runPromise(i.emit({type:"raw",line:at,iteration:I,timestamp:new Date}))},Oe=(at,Fr)=>{S.runPromise(i.emit({type:"reasoning",message:at,...Fr!==void 0?{tokens:Fr}:{},iteration:I,timestamp:new Date}))},Ye=at=>{S.runPromise(i.emit({type:"usage",inputTokens:at.inputTokens,outputTokens:at.outputTokens,cacheReadInputTokens:at.cacheReadInputTokens,cacheCreationInputTokens:at.cacheCreationInputTokens,...at.reasoningTokens!==void 0?{reasoningTokens:at.reasoningTokens}:{},...at.costUsd!==void 0?{costUsd:at.costUsd}:{},iteration:I,timestamp:new Date}))},T=at=>{q.flush(),S.runPromise(i.emit({type:"result",result:at,iteration:I,timestamp:new Date}))},J,Ne=at=>{J=at,S.runPromise(i.emit({type:"sessionId",sessionId:at,iteration:I,timestamp:new Date}))},Cr=at=>{let Fr=at===1?"Agent idle for 1 minute":`Agent idle for ${at} minutes`;S.runPromise(o.status(p(Fr),"warn"))},Li=at=>{S.runPromise(o.status(p(`Completion signal seen but agent process is hanging \u2014 force-completing after ${at/1e3}s grace window.`),"warn"))};return yield*S.gen(function*(){let{result:at,sessionId:Fr,usage:jn}=yield*lrr(F.sandbox,F.sandboxRepoDir,$,d,t,r,f,re,ie,ue,Cr,Li,e._idleWarningIntervalMs,_,P,e.signal,Oe,e.systemPrompt,Ye,T,Ne);q.dispose(),yield*o.status(p("Agent stopped"),"info");let{sessionFilePath:Mo,usage:Ui}=Fr?yield*N(Fr,!1,jn):{sessionFilePath:void 0,usage:jn};return{completionSignal:f.find(Ms=>at.includes(Ms)),stdout:at,sessionId:Fr,sessionFilePath:Mo,usage:Ui}}).pipe(S.catchAllCause(at=>S.gen(function*(){if(q.dispose(),e.signal?.aborted){let Fr=J,jn=Fr?yield*N(Fr,!0).pipe(S.catchAll(()=>S.succeed({sessionFilePath:void 0,usage:void 0}))):{sessionFilePath:void 0,usage:void 0};mrr(e.signal.reason,[...g,{sessionId:Fr,sessionFilePath:jn.sessionFilePath,usage:jn.usage}])}return yield*S.failCause(at)})))}))),k=v.value;if(y=v.preservedWorktreePath,m.push(...k.commits),A+=k.result.stdout,E=k.branch,g.push({sessionId:k.result.sessionId,sessionFilePath:k.result.sessionFilePath,usage:k.result.usage}),e.allowIterResume&&k.result.sessionId&&(w=k.result.sessionId),k.result.completionSignal!==void 0)return yield*o.status(p(`Agent signaled completion after ${I} iteration(s).`),"success"),{iterations:g,completionSignal:k.result.completionSignal,stdout:A,commits:m,branch:E,preservedWorktreePath:y}}return yield*o.status(p(`Reached max iterations (${a}).`),"info"),{iterations:g,completionSignal:void 0,stdout:A,commits:m,branch:E,preservedWorktreePath:y}})}});var Mp,lN=h(()=>{"use strict";rC();Dn();pa();Mp=e=>{let{prompt:t,promptFile:r}=e;return t!==void 0&&r!==void 0?S.fail(new Kc({message:"Cannot provide both --prompt and --prompt-file"})):t!==void 0?S.succeed({text:t,source:"inline"}):r===void 0?S.fail(new Kc({message:"Must provide either prompt or promptFile. Pass prompt: '...' or promptFile: './.sandcastle/prompt.md' to run()."})):S.gen(function*(){return{text:yield*(yield*mo.FileSystem).readFileString(r).pipe(S.catchAll(i=>S.fail(new Kc({message:`Failed to read prompt from ${r}: ${i}`})))),source:"template"}})}});import{join as hrr}from"node:path";var grr,Fp,dN=h(()=>{"use strict";rC();Dn();grr=e=>S.gen(function*(){let r=yield*(yield*mo.FileSystem).readFileString(e).pipe(S.catchAll(()=>S.succeed(null)));if(r===null)return{};let n={};for(let o of r.split(`
295
297
  `)){let i=o.trim();if(!i||i.startsWith("#"))continue;let s=i.indexOf("=");if(s===-1)continue;let a=i.slice(0,s).trim(),c=i.slice(s+1).trim(),u=c.length>=2&&c[0]==='"'&&c[c.length-1]==='"',l=c.length>=2&&c[0]==="'"&&c[c.length-1]==="'";(u||l)&&(c=c.slice(1,-1)),u&&(c=c.replace(/\\([nrt\\])/g,(d,f)=>({n:`
296
298
  `,r:"\r",t:" ","\\":"\\"})[f]??f)),n[a]=c}return n}),Fp=e=>S.gen(function*(){let t=yield*grr(hrr(e,".sandcastle",".env")),r={};for(let n of Object.keys(t)){let o=t[n]||process.env[n];o&&(r[n]=o)}return r})});var bet,Cet=h(()=>{"use strict";Wd();bet=e=>{switch(e._tag){case"ExecError":return`Command failed in sandbox (${e.command}): ${e.message}`;case"ExecHostError":return`Command failed on host (${e.command}): ${e.message}`;case"CopyError":return`File copy failed: ${e.message}`;case"DockerError":return`Docker operation failed: ${e.message}. Is Docker running?`;case"PodmanError":return`Podman operation failed: ${e.message}. Is Podman running?`;case"SyncError":return`Git sync failed: ${e.message}`;case"WorktreeError":return`Git worktree operation failed: ${e.message}`;case"PromptError":return`Failed to resolve prompt: ${e.message}`;case"AgentError":return`Agent invocation failed: ${e.message}`;case"ConfigDirError":return`${e.message}`;case"InitError":return`${e.message}`;case"AgentIdleTimeoutError":case"WorktreeTimeoutError":case"ContainerStartTimeoutError":case"CopyToWorktreeTimeoutError":case"CopyToWorktreeError":case"SyncInTimeoutError":case"HookTimeoutError":case"GitSetupTimeoutError":case"PromptExpansionTimeoutError":case"CommitCollectionTimeoutError":case"MergeToHostTimeoutError":case"SessionCaptureError":case"CwdError":case"WorktreeLockError":return e.message}}});var Lp,fN=h(()=>{"use strict";Lp=e=>{let{resolvedEnv:t,agentProviderEnv:r,sandboxProviderEnv:n}=e,o=Object.keys(r),i=new Set(Object.keys(n)),s=o.filter(a=>i.has(a));if(s.length>0)throw new Error(`Overlapping env keys between agent provider and sandbox provider: ${s.join(", ")}`);return{...t,...n,...r}}});var Arr,Sl,vle,Up,$p,wet,Hp,pN=h(()=>{"use strict";Dn();Wd();pa();hv();Arr=/(?<![A-Za-z0-9_`])!`([^`]+)`/g,Sl=["SOURCE_BRANCH","TARGET_BRANCH"],vle=/\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g,Up=e=>Object.keys(e).length===0?S.void:S.fail(new Kc({message:'promptArgs is only supported with promptFile. Inline prompts (prompt: "...") are passed to the agent as-is \u2014 interpolate values directly in JavaScript, or switch to promptFile to use {{KEY}} substitution.'})),$p=e=>{for(let t of Sl)if(t in e)return S.fail(new Kc({message:`"${t}" is a built-in prompt argument and cannot be overridden via promptArgs`}));return S.void},wet=(e,t)=>{let r=[...e.matchAll(vle)],n=new Set(Sl),o=new Set,i=[];for(let s of r){let a=s[1];o.has(a)||(o.add(a),!n.has(a)&&(a in t&&t[a]!=null||i.push(a)))}return i},Hp=(e,t,r)=>{let n=e.replaceAll(aC,"").replace(Arr,`!${aC}\`$1\``),o=Object.fromEntries(Object.entries(t).map(([s,a])=>[s,typeof a=="string"?a.replaceAll(aC,""):a])),i=[...n.matchAll(vle)];return i.length===0&&Object.keys(o).length===0?S.succeed(n):S.gen(function*(){let s=yield*En,a=new Set(i.map(u=>u[1]));for(let u of a){if(!(u in o))return yield*S.fail(new Kc({message:`Prompt argument "{{${u}}}" has no matching value in promptArgs`}));let l=o[u];if(l==null)return yield*S.fail(new Kc({message:`Prompt argument "{{${u}}}" has value ${l===null?"null":"undefined"} in promptArgs`}))}for(let u of Object.keys(o))!a.has(u)&&!r?.has(u)&&(yield*s.status(`Prompt argument "${u}" was provided but not referenced in the prompt`,"warn"));return n.replace(vle,(u,l)=>o[l].toString())})}});var Wp,Gd,mN=h(()=>{"use strict";Wp={object:e=>({_tag:"object",tag:e.tag,schema:e.schema,maxRetries:e.maxRetries}),string:e=>({_tag:"string",tag:e.tag,maxRetries:e.maxRetries})},Gd=class extends Error{tag;rawMatched;cause;commits;branch;preservedWorktreePath;sessionId;sessionFilePath;constructor(t,r){super(t),this.name="StructuredOutputError",this.tag=r.tag,this.rawMatched=r.rawMatched,this.cause=r.cause,this.commits=r.commits,this.branch=r.branch,this.preservedWorktreePath=r.preservedWorktreePath,this.sessionId=r.sessionId,this.sessionFilePath=r.sessionFilePath}}});var Iet,yrr,xrr,ket,Err,vet=h(()=>{"use strict";mN();Iet=async(e,t,r)=>t._tag==="object"?yrr(e,t,r):xrr(e,t,r),yrr=async(e,t,r)=>{let n=ket(e,t.tag);if(n===void 0)throw new Gd(`Structured output tag <${t.tag}> not found in agent output`,{tag:t.tag,rawMatched:void 0,...r});let o=Err(n.trim()),i;try{i=JSON.parse(o)}catch(a){throw new Gd(`Structured output tag <${t.tag}> contains invalid JSON`,{tag:t.tag,rawMatched:n,cause:a,...r})}let s=await t.schema["~standard"].validate(i);if(s.issues)throw new Gd(`Structured output tag <${t.tag}> failed schema validation`,{tag:t.tag,rawMatched:n,cause:s.issues,...r});return s.value},xrr=(e,t,r)=>{let n=ket(e,t.tag);if(n===void 0)throw new Gd(`Structured output tag <${t.tag}> not found in agent output`,{tag:t.tag,rawMatched:void 0,...r});return n.trim()},ket=(e,t)=>{let r=`<${t}>`,n=`</${t}>`,o,i=0;for(;;){let s=e.indexOf(r,i);if(s===-1)break;let a=s+r.length,c=e.indexOf(n,a);if(c===-1)break;o=e.slice(a,c),i=c+n.length}return o},Err=e=>{let t=e.match(/^```(?:json)?\s*\n([\s\S]*?)\n\s*```\s*$/);return t?t[1].trim():e}});import{appendFileSync as brr,mkdirSync as Srr}from"node:fs";import Bet,{join as Crr}from"node:path";import{styleText as Ret}from"node:util";async function hN(e){e.signal?.throwIfAborted();let{prompt:t,promptFile:r,maxIterations:n=Irr,hooks:o,agent:i}=e,s=e.branchStrategy??(e.sandbox.tag==="isolated"?{type:"merge-to-head"}:{type:"head"}),a=s.type;if(a==="head"&&e.sandbox.tag==="isolated")throw new Error("head branch strategy is not supported with isolated providers");if(a==="head"&&e.copyToWorktree&&e.copyToWorktree.length>0)throw new Error("copyToWorktree is not supported with head branch strategy. In head mode the host working directory is bind-mounted directly.");if(e.resumeSession&&n>1&&!e.allowIterResume)throw new Error("resumeSession cannot be combined with maxIterations > 1. Resume applies to iteration 1 only; multi-iteration resume semantics are not supported. Set allowIterResume: true to chain sessions across iterations.");if(e.forkSession&&!e.resumeSession)throw new Error("forkSession requires resumeSession. Use RunResult.fork(prompt) to fork the last captured session.");if(e.output&&n!==1)throw new Error("output requires maxIterations to be 1. Structured output is only supported for single-iteration runs.");let c=e.output?.maxRetries??0;if(c<0||!Number.isInteger(c))throw new Error(`output.maxRetries must be a non-negative integer. Received: ${c}`);if(c>0&&!i.sessionStorage)throw new Error(`output.maxRetries requires an agent provider that supports session resumption. The "${i.name}" provider does not. Use claudeCode, codex, or pi, or set maxRetries to 0.`);let u=s.type==="branch"?s.branch:void 0,l=await S.runPromise(ax(e.cwd).pipe(S.provide(us.layer)));e.resumeSession&&await av({provider:i,sandboxTag:e.sandbox.tag,hostRepoDir:l,resumeSession:e.resumeSession});let d=await S.runPromise(Mp({prompt:t,promptFile:r}).pipe(S.provide(us.layer))),f=d.text,p=d.source==="inline";if(e.output){let F=`<${e.output.tag}>`;if(!f.includes(F))throw new Error(`output tag <${e.output.tag}> not found in the resolved prompt. The caller must instruct the agent to emit the configured tag.`)}let m=i.name,g=await S.runPromise(Fp(l).pipe(S.provide(us.layer))),A=Lp({resolvedEnv:g,agentProviderEnv:i.env,sandboxProviderEnv:e.sandbox.env}),E=await S.runPromise(cC(l)),y=a==="head"?E:u??zG(e.name),b=a==="merge-to-head"?E:void 0,w=e.logging??{type:"file",path:Crr(l,".sandcastle","logs",AN(y,b,e.name))},I=w.type==="file"?(gN({logPath:w.path,agentName:e.name,branch:y,hostRepoDir:l}),Er.provide(lv.layer(w.path),sa.layer)):Tp.layer,v=Er.provide(get.layer,Er.mergeAll(Er.succeed(uN,{env:A,hostRepoDir:l,copyToWorktree:e.copyToWorktree,name:e.name,sandboxProvider:e.sandbox,branchStrategy:s,hooks:o,signal:e.signal,timeouts:e.timeouts}),sa.layer,I)),k=dv(EN(w)),R=Er.mergeAll(v,I,k),B=S.gen(function*(){let F=yield*En;yield*F.intro(e.name??"sandcastle");let _=krr({name:e.name,agentName:m,sandboxName:e.sandbox.name,maxIterations:n,branch:y});yield*F.summary("Sandcastle Run",_);let P=e.promptArgs??{},$;if(p)yield*Up(P),$=f;else{yield*$p(P);let ie={SOURCE_BRANCH:y,TARGET_BRANCH:E,...P},ue=new Set(Sl);$=yield*Hp(f,ie,ue)}let q=yield*Cv({hostRepoDir:l,iterations:n,hooks:o,prompt:$,branch:a==="head"?E:u,provider:i,systemPrompt:e.systemPrompt,completionSignal:e.completionSignal,idleTimeoutSeconds:e.idleTimeoutSeconds,completionTimeoutSeconds:e.completionTimeoutSeconds,name:e.name,resumeSession:e.resumeSession,forkSession:e.forkSession,allowIterResume:e.allowIterResume,signal:e.signal,skipPromptExpansion:p,timeouts:e.timeouts}),re=yN(q.completionSignal,q.iterations.length);yield*F.status(re.message,re.severity);for(let ie of xN(q.iterations))yield*F.text(ie);return q}),L=w.type==="file"?B.pipe(S.tapError(F=>S.gen(function*(){yield*(yield*En).status(bet(F),"error")}))):B,D;try{D=await S.runPromise(L.pipe(S.provide(R)))}catch(F){throw e.signal?.throwIfAborted(),F}let ee={...D,logFilePath:w.type==="file"?w.path:void 0,resume:async(F,_)=>{let P=D.iterations.at(-1);if(!P?.sessionId)throw new Error("Cannot resume: no sessionId was captured");return hN({...e,..._,prompt:F,promptFile:void 0,maxIterations:1,resumeSession:P.sessionId})},fork:async(F,_)=>{let P=D.iterations.at(-1);if(!P?.sessionId)throw new Error("Cannot fork: no sessionId was captured");return hN({...e,..._,prompt:F,promptFile:void 0,maxIterations:1,resumeSession:P.sessionId,forkSession:!0})}};if(e.output){let F=ee.iterations.at(-1);try{let _=await Iet(ee.stdout,e.output,{commits:ee.commits,branch:ee.branch,preservedWorktreePath:ee.preservedWorktreePath,sessionId:F?.sessionId,sessionFilePath:F?.sessionFilePath});return{...ee,output:_}}catch(_){if(_ instanceof Gd&&c>0&&_.sessionId!==void 0){let P=c-1,$={...e.output,maxRetries:P};return hN({...e,prompt:wrr(_,P),promptFile:void 0,promptArgs:void 0,resumeSession:_.sessionId,forkSession:!1,output:$})}throw _}}return ee}var wrr,Irr,_et,gN,AN,krr,yN,vrr,xN,EN,Rrr,_rr,Brr,bN=h(()=>{"use strict";VO();Dn();oC();OG();Wd();oz();lN();mx();dN();Cet();KO();fN();uC();pN();mN();vet();kle();wrr=(e,t)=>{let r=e.rawMatched===void 0?"(no matching tag was emitted)":e.rawMatched,n=e.cause===void 0?"(no parser detail)":typeof e.cause=="string"?e.cause:JSON.stringify(e.cause,null,2);return`Your previous response did not produce valid structured output.
297
299
 
@@ -309,7 +311,7 @@ ${r}
309
311
  Emit only a corrected <${e.tag}> block. Do not change files or run commands.`},Irr=1,_et=e=>e.replace(/[/\\:*?"<>|]/g,"-"),gN=e=>{let t=e.agentName??"Agent",r=Ret("bold",`[${t}]`),n=e.branch?` on branch ${e.branch}`:"",i=(e.hostRepoDir??process.cwd())===process.cwd()?Bet.relative(process.cwd(),e.logPath):e.logPath;console.log(`${r} Started${n}`),console.log(Ret("dim",` tail -f ${i}`))},AN=(e,t,r)=>{let n=_et(e),o=r?`-${r.toLowerCase().replace(/[^a-z0-9_.-]/g,"-")}`:"";return t?`${_et(t)}-${n}${o}.log`:`${n}${o}.log`},krr=e=>({Agent:e.name??e.agentName,Sandbox:e.sandboxName,"Max iterations":String(e.maxIterations),Branch:e.branch}),yN=(e,t)=>e!==void 0?{message:`Run complete: agent finished after ${t} iteration(s).`,severity:"success"}:{message:`Run complete: reached ${t} iteration(s) without completion signal.`,severity:"warn"},vrr=e=>{let t=e.inputTokens+e.cacheCreationInputTokens+e.cacheReadInputTokens;return`${Math.ceil(t/1e3)}k`},xN=e=>e.filter(t=>t.usage!==void 0).map(t=>`Context window: ${vrr(t.usage)}`),EN=e=>{let t=e.type==="file"?e.onAgentStreamEvent:void 0,r=e.verbose?Brr(e):void 0;if(!t&&!r)return;let n=e.type==="file"&&e.redactLine?Rrr(e.redactLine):void 0;return o=>{let i=n?_rr(o,n):o;if(t)try{t(i)}catch{}r&&i.type==="raw"&&r(i.line)}},Rrr=e=>t=>{try{return e(t)}catch{return t}},_rr=(e,t)=>{switch(e.type){case"raw":return{...e,line:t(e.line)};case"text":return{...e,message:t(e.message)};case"reasoning":return{...e,message:t(e.message)};case"result":return{...e,result:t(e.result)};case"toolCall":return{...e,formattedArgs:t(e.formattedArgs)};default:return e}},Brr=e=>{if(e.type==="file"){let t=e.path;try{Srr(Bet.dirname(t),{recursive:!0})}catch{}return r=>{try{brr(t,r+`
310
312
  `)}catch{}}}return t=>{process.stdout.write(t+`
311
313
  `)}}});var zd,iz=h(()=>{"use strict";zd=class{items=[];totalChars=0;maxChars;separator;constructor(t=65536,r=""){this.maxChars=t,this.separator=r}push(t){let r=t.length>this.maxChars?t.slice(t.length-this.maxChars):t;for(this.totalChars+=r.length+(this.items.length>0?this.separator.length:0),this.items.push(r);this.totalChars>this.maxChars&&this.items.length>1;){let n=this.items.shift();this.totalChars-=n.length+this.separator.length}}toString(){return this.items.join(this.separator)}}});var Qet={};tr(Qet,{noSandbox:()=>CN,pickAllowedEnv:()=>Det});import{spawn as Tet}from"node:child_process";import{createInterface as Trr}from"node:readline";var Det,CN,sz=h(()=>{"use strict";iz();Det=(e,t)=>{let r=new Set,n=[];for(let i of t)i.endsWith("*")?n.push(i.slice(0,-1)):r.add(i);let o={};for(let[i,s]of Object.entries(e))s!==void 0&&(r.has(i)||n.some(a=>i.startsWith(a)))&&(o[i]=s);return o},CN=e=>({tag:"none",name:"no-sandbox",env:e?.env??{},create:async t=>{let r=t.worktreePath,o={...e?.hostEnvAllowlist?Det(process.env,e.hostEnvAllowlist):process.env,...t.env},i=e?.maxOutputTailChars??65536;return{worktreePath:r,exec:(a,c)=>{let u=c?.cwd??r,l=process.platform==="win32",d=l?"cmd.exe":"sh",f=l?["/d","/s","/c",a]:["-c",a];return new Promise((p,m)=>{let g=Tet(d,f,{cwd:u,env:o,stdio:[c?.stdin!==void 0?"pipe":"ignore","pipe","pipe"],windowsVerbatimArguments:l});if(c?.stdin!==void 0&&(g.stdin.write(c.stdin),g.stdin.end()),g.on("error",A=>{m(new Error(`exec failed: ${A.message}`))}),c?.onLine){let A=c.onLine,E=new zd(i,`
312
- `),y=new zd(i,"");Trr({input:g.stdout}).on("line",w=>{E.push(w),A(w)}),g.stderr.on("data",w=>{y.push(w.toString())}),g.on("close",w=>{p({stdout:E.toString(),stderr:y.toString(),exitCode:w??0})})}else{let A=[],E=[];g.stdout.on("data",y=>{A.push(y.toString())}),g.stderr.on("data",y=>{E.push(y.toString())}),g.on("close",y=>{p({stdout:A.join(""),stderr:E.join(""),exitCode:y??0})})}})},interactiveExec:(a,c)=>new Promise((u,l)=>{let[d,...f]=a,p=Tet(d,f,{cwd:c.cwd??r,env:o,stdio:[c.stdin,c.stdout,c.stderr],shell:process.platform==="win32"});p.on("error",m=>{l(new Error(`exec failed: ${m.message}`))}),p.on("close",m=>{u({exitCode:m??0})})}),close:async()=>{}}}})});var az,Rle=h(()=>{"use strict";Dn();az=(e,t)=>t?S.gen(function*(){if(t.aborted)return yield*S.die(t.reason);let r=yield*Or.make(),n=()=>{S.runPromise(Or.die(r,t.reason)).catch(()=>{})};return t.addEventListener("abort",n,{once:!0}),yield*S.raceFirst(e,Or.await(r)).pipe(S.ensuring(S.sync(()=>t.removeEventListener("abort",n))))}):e});import{join as Drr}from"node:path";var Oet,Net=h(()=>{"use strict";VO();ule();Dn();Wd();hv();lN();mx();sg();Ev();dN();fN();iN();cN();xv();uC();uC();pN();sz();Rle();oC();Oet=async e=>{e.signal?.throwIfAborted();let{prompt:t,promptFile:r,hooks:n,agent:o}=e,i=e.sandbox??CN(),s=e.branchStrategy??(i.tag==="isolated"?{type:"merge-to-head"}:{type:"head"});if(s.type==="head"&&i.tag==="isolated")throw new Error("head branch strategy is not supported with isolated providers");if(s.type==="head"&&e.copyToWorktree&&e.copyToWorktree.length>0)throw new Error("copyToWorktree is not supported with head branch strategy. In head mode the host working directory is bind-mounted directly.");if(!o.buildInteractiveArgs)throw new Error(`Agent provider "${o.name}" does not support buildInteractiveArgs, required for interactive sessions.`);let a=s.type==="branch"?s.branch:void 0,c=s.type==="head",u=i,l=S.gen(function*(){let f=yield*ax(e.cwd),p=yield*En,m=t!==void 0||r!==void 0,g=m?yield*Mp({prompt:t,promptFile:r}):void 0,A=g?.text??"",E=g?.source==="inline",y=yield*Fp(f),w={...Lp({resolvedEnv:y,agentProviderEnv:o.env,sandboxProviderEnv:u.env}),...e.env??{}},I=yield*cC(f),v=s.type==="head"?I:a??zG(e.name),k=A;if(m&&!E){let D=e.promptArgs??{};yield*$p(D);let ee=wet(A,D),F={};for(let N of ee){let q=yield*S.promise(()=>P7e({message:`Enter value for {{${N}}}`,validate:re=>{if(!re)return`A value is required for {{${N}}}`}}));if(FG(q))return T7e("Prompt arg collection cancelled."),yield*S.fail(new Error("User cancelled prompt arg collection"));F[N]=q}let _={...D,...F},P={SOURCE_BRANCH:v,TARGET_BRANCH:I,..._},$=new Set(Sl);k=yield*Hp(A,P,$)}else if(E){let D=e.promptArgs??{};yield*Up(D)}let R=c?I:a;yield*p.intro(e.name??"sandcastle interactive"),yield*p.summary("Interactive Session",{Agent:e.name??o.name,Sandbox:u.name,Branch:v});let B;c||(B=yield*p.taskLog("Creating worktree",()=>fx(f).pipe(S.catchAll(()=>S.void),S.andThen(a?Qp(f,{branch:a}):Qp(f,{name:e.name})))));let L=yield*S.gen(function*(){if(c?n?.host?.onWorktreeReady?.length&&(yield*ma(n.host.onWorktreeReady,f)):((u.tag==="bind-mount"||u.tag==="none")&&e.copyToWorktree&&e.copyToWorktree.length>0&&(yield*p.taskLog("Copying files to worktree",()=>Op(e.copyToWorktree,f,B.path,e.timeouts?.copyToWorktreeMs))),n?.host?.onWorktreeReady?.length&&(yield*ma(n.host.onWorktreeReady,B.path))),u.tag==="none"){let D=c?f:B.path;return yield*S.promise(()=>u.create({worktreePath:D,env:w}))}else{if(u.tag==="isolated")return(yield*p.taskLog("Starting sandbox",()=>xo({provider:u,hostRepoDir:B.path,env:w,copyPaths:e.copyToWorktree}))).handle;{let D=Drr(f,".git"),ee=yield*Pp(D),F=c?f:B.path,_=yield*qd(ee,F,Oo);return(yield*p.taskLog("Starting sandbox",()=>xo({provider:u,hostRepoDir:f,env:w,worktreeOrRepoPath:F,gitMounts:_,repoDir:Oo}))).handle}}}).pipe(S.tapError(()=>B?bl(B.path).pipe(S.catchAll(()=>S.void)):S.void));return yield*S.gen(function*(){if(!L.interactiveExec)throw new Error("Sandbox provider does not support interactiveExec. The provider must implement the optional interactiveExec method to use interactive().");let D=L.interactiveExec.bind(L),ee=ag(L),F=L.worktreePath,_=u.tag==="isolated"&&B?()=>Np(B.path,L):()=>S.void,$=yield*px({hostRepoDir:f,sandboxRepoDir:F,hooks:n,branch:R,hostWorktreePath:c?f:B?.path,applyToHost:_,timeouts:e.timeouts},ee,re=>S.gen(function*(){let ie=!m||E?k:yield*dx(k,re.sandbox,re.sandboxRepoDir),ue=o.buildInteractiveArgs({prompt:ie,dangerouslySkipPermissions:u.tag!=="none"});return(yield*az(S.promise(()=>D(ue,{stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,cwd:F})),e.signal)).exitCode})),N=$.result,q;return B&&(yield*ig(B.path).pipe(S.catchAll(()=>S.succeed(!1))))&&(q=B.path),B&&!q&&(yield*bl(B.path).pipe(S.catchAll(()=>S.void))),yield*p.summary("Session Complete",{Commits:String($.commits.length),Branch:$.branch,"Exit code":String(N),...q?{"Preserved worktree":q}:{}}),{commits:$.commits,branch:$.branch,preservedWorktreePath:q,exitCode:N}}).pipe(S.tapError(()=>B?bl(B.path).pipe(S.catchAll(()=>S.void)):S.void),S.ensuring(S.promise(()=>L.close().catch(()=>{}))))}),d;try{d=await S.runPromise(l.pipe(S.provide(Tp.layer),S.provide(us.layer),S.provide(sa.layer)))}catch(f){throw e.signal?.throwIfAborted(),f}return d}});var cz,uz,Pet,Met,lz,Qrr,Fet,wv,dz=h(()=>{"use strict";cz=new Set,uz=!1,Pet=()=>{for(let e of cz)try{e()}catch{}},Met=()=>{Pet()},lz=()=>{Fet(),Pet(),process.exit(1)},Qrr=()=>{uz||(uz=!0,process.on("exit",Met),process.on("SIGINT",lz),process.on("SIGTERM",lz))},Fet=()=>{uz&&(uz=!1,process.removeListener("exit",Met),process.removeListener("SIGINT",lz),process.removeListener("SIGTERM",lz))},wv=e=>{cz.add(e),Qrr();let t=!0;return()=>{t&&(t=!1,cz.delete(e),cz.size===0&&Fet())}}});import{join as _le}from"node:path";var Let,Uet,$et,Ble=h(()=>{"use strict";VO();Dn();Wd();dN();fN();oz();KO();pN();lN();hv();bN();Ev();mx();cN();xv();uC();iN();oC();sg();OG();dz();Let=(e,t)=>{let{branch:r,worktreePath:n,hostRepoDir:o,sandboxRepoDir:i,sandbox:s,providerHandle:a,bindMountHandle:c,applyToHost:u,timeouts:l,branchStrategy:d}=e,f=d?.type==="merge-to-head",p={branch:r,worktreePath:n,run:async m=>{m.signal?.throwIfAborted();let{agent:g,prompt:A,promptFile:E,maxIterations:y=1}=m;if(m.resumeSession&&y>1)throw new Error("resumeSession cannot be combined with maxIterations > 1. Resume applies to iteration 1 only; multi-iteration resume semantics are not supported.");if(m.forkSession&&!m.resumeSession)throw new Error("forkSession requires resumeSession. Use sandboxRunResult.fork(prompt) to fork the most recent captured session.");m.resumeSession&&await av({provider:g,sandboxTag:e.providerTag,hostRepoDir:o,resumeSession:m.resumeSession});let b=await S.runPromise(Mp({prompt:A,promptFile:E}).pipe(S.provide(us.layer))),w=b.text,I=b.source==="inline",v=m.promptArgs??{},k=await S.runPromise(cC(o)),R=Ii.unsafeMake([]),B=F7e.layer(R),L=await S.runPromise(S.gen(function*(){if(I)return yield*Up(v),w;yield*$p(v);let re={SOURCE_BRANCH:r,TARGET_BRANCH:k,...v},ie=new Set(Sl);return yield*Hp(w,re,ie)}).pipe(S.provide(B))),D=m.logging??{type:"file",path:_le(o,".sandcastle","logs",AN(r,void 0,m.name))},ee=D.type==="file"?(gN({logPath:D.path,agentName:m.name,branch:r}),Er.provide(lv.layer(D.path),sa.layer)):B,F=Er.succeed(cg,{withSandbox:re=>re({hostWorktreePath:n,sandboxRepoPath:i,applyToHost:u,bindMountHandle:c},s).pipe(S.map(ie=>({value:ie,preservedWorktreePath:void 0})))}),_=dv(EN(D)),P=Er.mergeAll(F,ee,_),$;try{$=await S.runPromise(S.gen(function*(){let re=yield*En;yield*re.intro(m.name??"sandcastle");let ie=yield*Cv({hostRepoDir:o,iterations:y,prompt:L,branch:f?void 0:r,provider:g,completionSignal:m.completionSignal,idleTimeoutSeconds:m.idleTimeoutSeconds,completionTimeoutSeconds:m.completionTimeoutSeconds,name:m.name,resumeSession:m.resumeSession,forkSession:m.forkSession,signal:m.signal,skipPromptExpansion:I,timeouts:l,keepSourceBranch:f}),ue=yN(ie.completionSignal,ie.iterations.length);yield*re.status(ue.message,ue.severity);for(let Oe of xN(ie.iterations))yield*re.text(Oe);return ie}).pipe(S.provide(P)))}catch(re){throw m.signal?.throwIfAborted(),re}let N={iterations:$.iterations,completionSignal:$.completionSignal,stdout:$.stdout,commits:$.commits,logFilePath:D.type==="file"?D.path:void 0},q=$.iterations.at(-1);if(g.sessionStorage&&q?.sessionId){let re=q.sessionId;return{...N,resume:(ie,ue)=>p.run({...m,...ue,prompt:ie,promptFile:void 0,maxIterations:1,resumeSession:re}),fork:(ie,ue)=>p.run({...m,...ue,prompt:ie,promptFile:void 0,maxIterations:1,resumeSession:re,forkSession:!0})}}return N},interactive:async m=>{m.signal?.throwIfAborted();let{agent:g,prompt:A,promptFile:E}=m;if(!g.buildInteractiveArgs)throw new Error(`Agent provider "${g.name}" does not support buildInteractiveArgs, required for interactive sessions.`);if(!a?.interactiveExec)throw new Error("Sandbox provider does not support interactiveExec. The provider must implement the optional interactiveExec method to use interactive().");let y=a.interactiveExec.bind(a),b;try{b=await S.runPromise(S.gen(function*(){let w=yield*Mp({prompt:A,promptFile:E}),I=w.text,v=w.source==="inline",k=m.promptArgs??{},R=yield*cC(o),B;if(v)yield*Up(k),B=I;else{yield*$p(k);let L={SOURCE_BRANCH:r,TARGET_BRANCH:R,...k},D=new Set(Sl);B=yield*Hp(I,L,D)}return yield*px({hostRepoDir:o,sandboxRepoDir:i,branch:f?void 0:r,hostWorktreePath:n,applyToHost:u,timeouts:l,keepSourceBranch:f},s,L=>S.gen(function*(){let D=v?B:yield*dx(B,L.sandbox,L.sandboxRepoDir),ee=g.buildInteractiveArgs({prompt:D,dangerouslySkipPermissions:!0}),F=y(ee,{stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,cwd:i}),_=m.signal;return(yield*S.promise(()=>_?_.aborted?Promise.reject(_.reason):new Promise(($,N)=>{let q=()=>N(_.reason);_.addEventListener("abort",q,{once:!0}),F.then(re=>{_.removeEventListener("abort",q),$(re)},re=>{_.removeEventListener("abort",q),N(re)})}):F)).exitCode}))}).pipe(S.provide(Tp.layer),S.provide(us.layer)))}catch(w){throw m.signal?.throwIfAborted(),w}return{commits:b.commits,exitCode:b.result}},exec:async(m,g)=>{let A={cwd:i,...g};return a?a.exec(m,A):S.runPromise(s.exec(m,A))},close:async()=>t(),[Symbol.asyncDispose]:async()=>{await p.close()}};return p},Uet=async e=>{let{branch:t,worktreePath:r,hostRepoDir:n}=e,o=!!e._test?.buildSandbox;e.copyToWorktree&&e.copyToWorktree.length>0&&e.sandbox.tag!=="isolated"&&await S.runPromise(Op(e.copyToWorktree,n,r,e.timeouts?.copyToWorktreeMs));let i,s,a,c=e.sandbox.tag==="isolated";if(o)s=e._test.buildSandbox(r),a=r,i=e._test.bindMountHandle;else{let m=await S.runPromise(Fp(n).pipe(S.provide(us.layer))),g=Lp({resolvedEnv:m,agentProviderEnv:{},sandboxProviderEnv:e.sandbox.env}),A=e.sandbox,E;A.tag==="isolated"?E=xo({provider:A,hostRepoDir:r,env:g,copyPaths:e.copyToWorktree}):A.tag==="none"?E=xo({provider:A,hostRepoDir:n,env:g,worktreeOrRepoPath:r}):E=Pp(_le(n,".git")).pipe(S.provide(sa.layer),S.catchAll(()=>S.succeed([])),S.flatMap(b=>qd(b,r,Oo)),S.flatMap(b=>xo({provider:A,hostRepoDir:n,env:g,worktreeOrRepoPath:r,gitMounts:b,repoDir:Oo})));let y=await S.runPromise(E);i=y.handle,s=y.sandbox,a=y.worktreePath}let u=e.hooks?.sandbox?.onSandboxReady,l=e.hooks?.host?.onSandboxReady;(u?.length||l?.length)&&await S.runPromise(S.gen(function*(){yield*s.exec(`git config --global --add safe.directory "${a}"`);let g=[...(u??[]).map(A=>s.exec(A.command,{cwd:a,sudo:A.sudo}))];l?.length&&g.push(ma(l,r)),yield*S.all(g,{concurrency:"unbounded"})}));let d=c&&i?()=>Np(r,i):()=>S.void,f=!1,p=e.sandbox.tag==="bind-mount"?i:void 0;return Let({branch:t,worktreePath:r,hostRepoDir:n,sandboxRepoDir:a,sandbox:s,providerHandle:i,bindMountHandle:p,providerTag:e.sandbox.tag,applyToHost:d,timeouts:e.timeouts,branchStrategy:e.branchStrategy},async()=>f?{preservedWorktreePath:void 0}:(f=!0,i&&await i.close(),{preservedWorktreePath:void 0}))},$et=async e=>{let{branch:t}=e,r=!!e._test?.buildSandbox,n=e.sandbox.tag==="isolated",{hostRepoDir:o,worktreePath:i,providerHandle:s,sandbox:a,sandboxRepoDir:c}=await S.runPromise(S.gen(function*(){let g=yield*ax(e.cwd);yield*fx(g).pipe(S.catchAll(()=>S.void));let{path:A}=yield*Qp(g,{branch:t,baseBranch:e.baseBranch}),E=yield*S.gen(function*(){e.copyToWorktree&&e.copyToWorktree.length>0&&e.sandbox.tag!=="isolated"&&(yield*Op(e.copyToWorktree,g,A,e.timeouts?.copyToWorktreeMs)),e.hooks?.host?.onWorktreeReady?.length&&(yield*ma(e.hooks.host.onWorktreeReady,A));let y,b,w;if(r)b=e._test.buildSandbox(A),w=A,y=e._test.bindMountHandle;else{let k=yield*Fp(g),R=Lp({resolvedEnv:k,agentProviderEnv:{},sandboxProviderEnv:e.sandbox.env}),B=e.sandbox,L=yield*B.tag==="isolated"?xo({provider:B,hostRepoDir:A,env:R,copyPaths:e.copyToWorktree}):B.tag==="none"?xo({provider:B,hostRepoDir:g,env:R,worktreeOrRepoPath:A}):Pp(_le(g,".git")).pipe(S.provide(sa.layer),S.catchAll(()=>S.succeed([])),S.flatMap(D=>qd(D,A,Oo)),S.flatMap(D=>xo({provider:B,hostRepoDir:g,env:R,worktreeOrRepoPath:A,gitMounts:D,repoDir:Oo})));y=L.handle,b=L.sandbox,w=L.worktreePath}let I=e.hooks?.sandbox?.onSandboxReady,v=e.hooks?.host?.onSandboxReady;return(I?.length||v?.length)&&(yield*S.gen(function*(){yield*b.exec(`git config --global --add safe.directory "${w}"`);let R=[...(I??[]).map(B=>b.exec(B.command,{cwd:w,sudo:B.sudo}))];v?.length&&R.push(ma(v,A)),yield*S.all(R,{concurrency:"unbounded"})}).pipe(S.onError(()=>y?S.promise(()=>y.close().catch(()=>{})):S.void))),{providerHandle:y,sandbox:b,sandboxRepoDir:w}}).pipe(S.onError(()=>bl(A).pipe(S.catchAll(()=>S.void))));return{hostRepoDir:g,worktreePath:A,...E}}).pipe(S.provide(us.layer))),u=n&&s?()=>Np(i,s):()=>S.void,l=!1,f=wv(()=>{console.error(`
314
+ `),y=new zd(i,"");Trr({input:g.stdout}).on("line",w=>{E.push(w),A(w)}),g.stderr.on("data",w=>{y.push(w.toString())}),g.on("close",w=>{p({stdout:E.toString(),stderr:y.toString(),exitCode:w??0})})}else{let A=[],E=[];g.stdout.on("data",y=>{A.push(y.toString())}),g.stderr.on("data",y=>{E.push(y.toString())}),g.on("close",y=>{p({stdout:A.join(""),stderr:E.join(""),exitCode:y??0})})}})},interactiveExec:(a,c)=>new Promise((u,l)=>{let[d,...f]=a,p=Tet(d,f,{cwd:c.cwd??r,env:o,stdio:[c.stdin,c.stdout,c.stderr],shell:process.platform==="win32"});p.on("error",m=>{l(new Error(`exec failed: ${m.message}`))}),p.on("close",m=>{u({exitCode:m??0})})}),close:async()=>{}}}})});var az,Rle=h(()=>{"use strict";Dn();az=(e,t)=>t?S.gen(function*(){if(t.aborted)return yield*S.die(t.reason);let r=yield*Or.make(),n=()=>{S.runPromise(Or.die(r,t.reason)).catch(()=>{})};return t.addEventListener("abort",n,{once:!0}),yield*S.raceFirst(e,Or.await(r)).pipe(S.ensuring(S.sync(()=>t.removeEventListener("abort",n))))}):e});import{join as Drr}from"node:path";var Oet,Net=h(()=>{"use strict";VO();ule();Dn();Wd();hv();lN();mx();sg();Ev();dN();fN();iN();cN();xv();uC();uC();pN();sz();Rle();oC();Oet=async e=>{e.signal?.throwIfAborted();let{prompt:t,promptFile:r,hooks:n,agent:o}=e,i=e.sandbox??CN(),s=e.branchStrategy??(i.tag==="isolated"?{type:"merge-to-head"}:{type:"head"});if(s.type==="head"&&i.tag==="isolated")throw new Error("head branch strategy is not supported with isolated providers");if(s.type==="head"&&e.copyToWorktree&&e.copyToWorktree.length>0)throw new Error("copyToWorktree is not supported with head branch strategy. In head mode the host working directory is bind-mounted directly.");if(!o.buildInteractiveArgs)throw new Error(`Agent provider "${o.name}" does not support buildInteractiveArgs, required for interactive sessions.`);let a=s.type==="branch"?s.branch:void 0,c=s.type==="head",u=i,l=S.gen(function*(){let f=yield*ax(e.cwd),p=yield*En,m=t!==void 0||r!==void 0,g=m?yield*Mp({prompt:t,promptFile:r}):void 0,A=g?.text??"",E=g?.source==="inline",y=yield*Fp(f),w={...Lp({resolvedEnv:y,agentProviderEnv:o.env,sandboxProviderEnv:u.env}),...e.env??{}},I=yield*cC(f),v=s.type==="head"?I:a??zG(e.name),k=A;if(m&&!E){let D=e.promptArgs??{};yield*$p(D);let ee=wet(A,D),F={};for(let N of ee){let q=yield*S.promise(()=>P7e({message:`Enter value for {{${N}}}`,validate:re=>{if(!re)return`A value is required for {{${N}}}`}}));if(FG(q))return T7e("Prompt arg collection cancelled."),yield*S.fail(new Error("User cancelled prompt arg collection"));F[N]=q}let _={...D,...F},P={SOURCE_BRANCH:v,TARGET_BRANCH:I,..._},$=new Set(Sl);k=yield*Hp(A,P,$)}else if(E){let D=e.promptArgs??{};yield*Up(D)}let R=c?I:a;yield*p.intro(e.name??"sandcastle interactive"),yield*p.summary("Interactive Session",{Agent:e.name??o.name,Sandbox:u.name,Branch:v});let B;c||(B=yield*p.taskLog("Creating worktree",()=>fx(f).pipe(S.catchAll(()=>S.void),S.andThen(a?Qp(f,{branch:a}):Qp(f,{name:e.name})))));let L=yield*S.gen(function*(){if(c?n?.host?.onWorktreeReady?.length&&(yield*ma(n.host.onWorktreeReady,f)):((u.tag==="bind-mount"||u.tag==="none")&&e.copyToWorktree&&e.copyToWorktree.length>0&&(yield*p.taskLog("Copying files to worktree",()=>Op(e.copyToWorktree,f,B.path,e.timeouts?.copyToWorktreeMs))),n?.host?.onWorktreeReady?.length&&(yield*ma(n.host.onWorktreeReady,B.path))),u.tag==="none"){let D=c?f:B.path;return yield*S.promise(()=>u.create({worktreePath:D,env:w}))}else{if(u.tag==="isolated")return(yield*p.taskLog("Starting sandbox",()=>xo({provider:u,hostRepoDir:B.path,env:w,copyPaths:e.copyToWorktree}))).handle;{let D=Drr(f,".git"),ee=yield*Pp(D),F=c?f:B.path,_=yield*qd(ee,F,Oo);return(yield*p.taskLog("Starting sandbox",()=>xo({provider:u,hostRepoDir:f,env:w,worktreeOrRepoPath:F,gitMounts:_,repoDir:Oo}))).handle}}}).pipe(S.tapError(()=>B?bl(B.path).pipe(S.catchAll(()=>S.void)):S.void));return yield*S.gen(function*(){if(!L.interactiveExec)throw new Error("Sandbox provider does not support interactiveExec. The provider must implement the optional interactiveExec method to use interactive().");let D=L.interactiveExec.bind(L),ee=ag(L),F=L.worktreePath,_=u.tag==="isolated"&&B?()=>Np(B.path,L):()=>S.void,$=yield*px({hostRepoDir:f,sandboxRepoDir:F,hooks:n,branch:R,hostWorktreePath:c?f:B?.path,applyToHost:_,timeouts:e.timeouts},ee,re=>S.gen(function*(){let ie=!m||E?k:yield*dx(k,re.sandbox,re.sandboxRepoDir),ue=o.buildInteractiveArgs({prompt:ie,dangerouslySkipPermissions:u.tag!=="none"});return(yield*az(S.promise(()=>D(ue,{stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,cwd:F})),e.signal)).exitCode})),N=$.result,q;return B&&(yield*ig(B.path).pipe(S.catchAll(()=>S.succeed(!1))))&&(q=B.path),B&&!q&&(yield*bl(B.path).pipe(S.catchAll(()=>S.void))),yield*p.summary("Session Complete",{Commits:String($.commits.length),Branch:$.branch,"Exit code":String(N),...q?{"Preserved worktree":q}:{}}),{commits:$.commits,branch:$.branch,preservedWorktreePath:q,exitCode:N}}).pipe(S.tapError(()=>B?bl(B.path).pipe(S.catchAll(()=>S.void)):S.void),S.ensuring(S.promise(()=>L.close().catch(()=>{}))))}),d;try{d=await S.runPromise(l.pipe(S.provide(Tp.layer),S.provide(us.layer),S.provide(sa.layer)))}catch(f){throw e.signal?.throwIfAborted(),f}return d}});var cz,uz,Pet,Met,lz,Qrr,Fet,wv,dz=h(()=>{"use strict";cz=new Set,uz=!1,Pet=()=>{for(let e of cz)try{e()}catch{}},Met=()=>{Pet()},lz=()=>{Fet(),Pet(),process.exit(1)},Qrr=()=>{uz||(uz=!0,process.on("exit",Met),process.on("SIGINT",lz),process.on("SIGTERM",lz))},Fet=()=>{uz&&(uz=!1,process.removeListener("exit",Met),process.removeListener("SIGINT",lz),process.removeListener("SIGTERM",lz))},wv=e=>{cz.add(e),Qrr();let t=!0;return()=>{t&&(t=!1,cz.delete(e),cz.size===0&&Fet())}}});import{join as _le}from"node:path";var Let,Uet,$et,Ble=h(()=>{"use strict";VO();Dn();Wd();dN();fN();oz();KO();pN();lN();hv();bN();Ev();mx();cN();xv();uC();iN();oC();sg();OG();dz();Let=(e,t)=>{let{branch:r,worktreePath:n,hostRepoDir:o,sandboxRepoDir:i,sandbox:s,providerHandle:a,bindMountHandle:c,applyToHost:u,timeouts:l,branchStrategy:d}=e,f=d?.type==="merge-to-head",p={branch:r,worktreePath:n,run:async m=>{m.signal?.throwIfAborted();let{agent:g,prompt:A,promptFile:E,maxIterations:y=1}=m;if(m.resumeSession&&y>1)throw new Error("resumeSession cannot be combined with maxIterations > 1. Resume applies to iteration 1 only; multi-iteration resume semantics are not supported.");if(m.forkSession&&!m.resumeSession)throw new Error("forkSession requires resumeSession. Use sandboxRunResult.fork(prompt) to fork the most recent captured session.");m.resumeSession&&await av({provider:g,sandboxTag:e.providerTag,hostRepoDir:o,resumeSession:m.resumeSession});let b=await S.runPromise(Mp({prompt:A,promptFile:E}).pipe(S.provide(us.layer))),w=b.text,I=b.source==="inline",v=m.promptArgs??{},k=await S.runPromise(cC(o)),R=di.unsafeMake([]),B=F7e.layer(R),L=await S.runPromise(S.gen(function*(){if(I)return yield*Up(v),w;yield*$p(v);let re={SOURCE_BRANCH:r,TARGET_BRANCH:k,...v},ie=new Set(Sl);return yield*Hp(w,re,ie)}).pipe(S.provide(B))),D=m.logging??{type:"file",path:_le(o,".sandcastle","logs",AN(r,void 0,m.name))},ee=D.type==="file"?(gN({logPath:D.path,agentName:m.name,branch:r}),Er.provide(lv.layer(D.path),sa.layer)):B,F=Er.succeed(cg,{withSandbox:re=>re({hostWorktreePath:n,sandboxRepoPath:i,applyToHost:u,bindMountHandle:c},s).pipe(S.map(ie=>({value:ie,preservedWorktreePath:void 0})))}),_=dv(EN(D)),P=Er.mergeAll(F,ee,_),$;try{$=await S.runPromise(S.gen(function*(){let re=yield*En;yield*re.intro(m.name??"sandcastle");let ie=yield*Cv({hostRepoDir:o,iterations:y,prompt:L,branch:f?void 0:r,provider:g,completionSignal:m.completionSignal,idleTimeoutSeconds:m.idleTimeoutSeconds,completionTimeoutSeconds:m.completionTimeoutSeconds,name:m.name,resumeSession:m.resumeSession,forkSession:m.forkSession,signal:m.signal,skipPromptExpansion:I,timeouts:l,keepSourceBranch:f}),ue=yN(ie.completionSignal,ie.iterations.length);yield*re.status(ue.message,ue.severity);for(let Oe of xN(ie.iterations))yield*re.text(Oe);return ie}).pipe(S.provide(P)))}catch(re){throw m.signal?.throwIfAborted(),re}let N={iterations:$.iterations,completionSignal:$.completionSignal,stdout:$.stdout,commits:$.commits,logFilePath:D.type==="file"?D.path:void 0},q=$.iterations.at(-1);if(g.sessionStorage&&q?.sessionId){let re=q.sessionId;return{...N,resume:(ie,ue)=>p.run({...m,...ue,prompt:ie,promptFile:void 0,maxIterations:1,resumeSession:re}),fork:(ie,ue)=>p.run({...m,...ue,prompt:ie,promptFile:void 0,maxIterations:1,resumeSession:re,forkSession:!0})}}return N},interactive:async m=>{m.signal?.throwIfAborted();let{agent:g,prompt:A,promptFile:E}=m;if(!g.buildInteractiveArgs)throw new Error(`Agent provider "${g.name}" does not support buildInteractiveArgs, required for interactive sessions.`);if(!a?.interactiveExec)throw new Error("Sandbox provider does not support interactiveExec. The provider must implement the optional interactiveExec method to use interactive().");let y=a.interactiveExec.bind(a),b;try{b=await S.runPromise(S.gen(function*(){let w=yield*Mp({prompt:A,promptFile:E}),I=w.text,v=w.source==="inline",k=m.promptArgs??{},R=yield*cC(o),B;if(v)yield*Up(k),B=I;else{yield*$p(k);let L={SOURCE_BRANCH:r,TARGET_BRANCH:R,...k},D=new Set(Sl);B=yield*Hp(I,L,D)}return yield*px({hostRepoDir:o,sandboxRepoDir:i,branch:f?void 0:r,hostWorktreePath:n,applyToHost:u,timeouts:l,keepSourceBranch:f},s,L=>S.gen(function*(){let D=v?B:yield*dx(B,L.sandbox,L.sandboxRepoDir),ee=g.buildInteractiveArgs({prompt:D,dangerouslySkipPermissions:!0}),F=y(ee,{stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,cwd:i}),_=m.signal;return(yield*S.promise(()=>_?_.aborted?Promise.reject(_.reason):new Promise(($,N)=>{let q=()=>N(_.reason);_.addEventListener("abort",q,{once:!0}),F.then(re=>{_.removeEventListener("abort",q),$(re)},re=>{_.removeEventListener("abort",q),N(re)})}):F)).exitCode}))}).pipe(S.provide(Tp.layer),S.provide(us.layer)))}catch(w){throw m.signal?.throwIfAborted(),w}return{commits:b.commits,exitCode:b.result}},exec:async(m,g)=>{let A={cwd:i,...g};return a?a.exec(m,A):S.runPromise(s.exec(m,A))},close:async()=>t(),[Symbol.asyncDispose]:async()=>{await p.close()}};return p},Uet=async e=>{let{branch:t,worktreePath:r,hostRepoDir:n}=e,o=!!e._test?.buildSandbox;e.copyToWorktree&&e.copyToWorktree.length>0&&e.sandbox.tag!=="isolated"&&await S.runPromise(Op(e.copyToWorktree,n,r,e.timeouts?.copyToWorktreeMs));let i,s,a,c=e.sandbox.tag==="isolated";if(o)s=e._test.buildSandbox(r),a=r,i=e._test.bindMountHandle;else{let m=await S.runPromise(Fp(n).pipe(S.provide(us.layer))),g=Lp({resolvedEnv:m,agentProviderEnv:{},sandboxProviderEnv:e.sandbox.env}),A=e.sandbox,E;A.tag==="isolated"?E=xo({provider:A,hostRepoDir:r,env:g,copyPaths:e.copyToWorktree}):A.tag==="none"?E=xo({provider:A,hostRepoDir:n,env:g,worktreeOrRepoPath:r}):E=Pp(_le(n,".git")).pipe(S.provide(sa.layer),S.catchAll(()=>S.succeed([])),S.flatMap(b=>qd(b,r,Oo)),S.flatMap(b=>xo({provider:A,hostRepoDir:n,env:g,worktreeOrRepoPath:r,gitMounts:b,repoDir:Oo})));let y=await S.runPromise(E);i=y.handle,s=y.sandbox,a=y.worktreePath}let u=e.hooks?.sandbox?.onSandboxReady,l=e.hooks?.host?.onSandboxReady;(u?.length||l?.length)&&await S.runPromise(S.gen(function*(){yield*s.exec(`git config --global --add safe.directory "${a}"`);let g=[...(u??[]).map(A=>s.exec(A.command,{cwd:a,sudo:A.sudo}))];l?.length&&g.push(ma(l,r)),yield*S.all(g,{concurrency:"unbounded"})}));let d=c&&i?()=>Np(r,i):()=>S.void,f=!1,p=e.sandbox.tag==="bind-mount"?i:void 0;return Let({branch:t,worktreePath:r,hostRepoDir:n,sandboxRepoDir:a,sandbox:s,providerHandle:i,bindMountHandle:p,providerTag:e.sandbox.tag,applyToHost:d,timeouts:e.timeouts,branchStrategy:e.branchStrategy},async()=>f?{preservedWorktreePath:void 0}:(f=!0,i&&await i.close(),{preservedWorktreePath:void 0}))},$et=async e=>{let{branch:t}=e,r=!!e._test?.buildSandbox,n=e.sandbox.tag==="isolated",{hostRepoDir:o,worktreePath:i,providerHandle:s,sandbox:a,sandboxRepoDir:c}=await S.runPromise(S.gen(function*(){let g=yield*ax(e.cwd);yield*fx(g).pipe(S.catchAll(()=>S.void));let{path:A}=yield*Qp(g,{branch:t,baseBranch:e.baseBranch}),E=yield*S.gen(function*(){e.copyToWorktree&&e.copyToWorktree.length>0&&e.sandbox.tag!=="isolated"&&(yield*Op(e.copyToWorktree,g,A,e.timeouts?.copyToWorktreeMs)),e.hooks?.host?.onWorktreeReady?.length&&(yield*ma(e.hooks.host.onWorktreeReady,A));let y,b,w;if(r)b=e._test.buildSandbox(A),w=A,y=e._test.bindMountHandle;else{let k=yield*Fp(g),R=Lp({resolvedEnv:k,agentProviderEnv:{},sandboxProviderEnv:e.sandbox.env}),B=e.sandbox,L=yield*B.tag==="isolated"?xo({provider:B,hostRepoDir:A,env:R,copyPaths:e.copyToWorktree}):B.tag==="none"?xo({provider:B,hostRepoDir:g,env:R,worktreeOrRepoPath:A}):Pp(_le(g,".git")).pipe(S.provide(sa.layer),S.catchAll(()=>S.succeed([])),S.flatMap(D=>qd(D,A,Oo)),S.flatMap(D=>xo({provider:B,hostRepoDir:g,env:R,worktreeOrRepoPath:A,gitMounts:D,repoDir:Oo})));y=L.handle,b=L.sandbox,w=L.worktreePath}let I=e.hooks?.sandbox?.onSandboxReady,v=e.hooks?.host?.onSandboxReady;return(I?.length||v?.length)&&(yield*S.gen(function*(){yield*b.exec(`git config --global --add safe.directory "${w}"`);let R=[...(I??[]).map(B=>b.exec(B.command,{cwd:w,sudo:B.sudo}))];v?.length&&R.push(ma(v,A)),yield*S.all(R,{concurrency:"unbounded"})}).pipe(S.onError(()=>y?S.promise(()=>y.close().catch(()=>{})):S.void))),{providerHandle:y,sandbox:b,sandboxRepoDir:w}}).pipe(S.onError(()=>bl(A).pipe(S.catchAll(()=>S.void))));return{hostRepoDir:g,worktreePath:A,...E}}).pipe(S.provide(us.layer))),u=n&&s?()=>Np(i,s):()=>S.void,l=!1,f=wv(()=>{console.error(`
313
315
  Worktree preserved at ${i}`),console.error(` To review: cd ${i}`),console.error(` To clean up: git worktree remove --force ${i}`)}),p=async()=>l?{preservedWorktreePath:void 0}:(l=!0,S.runPromise(S.gen(function*(){return s&&(yield*S.promise(()=>s.close())),(yield*ig(i).pipe(S.catchAll(()=>S.succeed(!1))))?{preservedWorktreePath:i}:(yield*bl(i).pipe(S.catchAll(()=>S.void)),{preservedWorktreePath:void 0})}))),m=e.sandbox.tag==="bind-mount"?s:void 0;return Let({branch:t,worktreePath:i,hostRepoDir:o,sandboxRepoDir:c,sandbox:a,providerHandle:s,bindMountHandle:m,providerTag:e.sandbox.tag,applyToHost:u,timeouts:e.timeouts},async()=>(f(),p()))}});import{basename as Tle,join as wN}from"node:path";var Het,Wet=h(()=>{"use strict";VO();Dn();Wd();hv();lN();mx();sg();Ev();Ble();bN();oz();KO();dN();fN();cN();xv();uC();mle();iN();oC();OG();pN();sz();Rle();Het=async e=>{let t=e.branchStrategy.type==="branch"?e.branchStrategy.branch:void 0,r=e.branchStrategy.type==="branch"?e.branchStrategy.baseBranch:void 0,n=e.branchStrategy.type==="merge-to-head",{hostRepoDir:o,worktreeInfo:i}=await S.gen(function*(){let p=yield*ax(e.cwd);yield*fx(p).pipe(S.catchAll(()=>S.void));let m=wN(p,".sandcastle","locks");if(t){let b=t.replace(/\//g,"-");yield*S.promise(()=>ple(m,b,t))}let g=Qp(p,{branch:t,baseBranch:r}),A=yield*t?g.pipe(S.tapError(()=>S.promise(()=>GG(m,t.replace(/\//g,"-")).catch(()=>{})))):g;t||(yield*S.promise(()=>ple(m,Tle(A.path),A.branch)));let E=Tle(A.path),y=S.tapErrorCause(()=>S.gen(function*(){yield*S.promise(()=>GG(m,E)).pipe(S.catchAll(()=>S.void)),yield*bl(A.path).pipe(S.catchAll(()=>S.void))}));return e.copyToWorktree&&e.copyToWorktree.length>0&&(yield*Op(e.copyToWorktree,p,A.path,e.timeouts?.copyToWorktreeMs).pipe(y)),e.hooks?.host?.onWorktreeReady?.length&&(yield*ma(e.hooks.host.onWorktreeReady,A.path).pipe(y)),{hostRepoDir:p,worktreeInfo:A}}).pipe(S.provide(us.layer),S.runPromise),s=!1,a=wN(o,".sandcastle","locks"),c=Tle(i.path),u=async()=>s?{preservedWorktreePath:void 0}:(s=!0,await GG(a,c).catch(()=>{}),S.gen(function*(){return(yield*ig(i.path).pipe(S.catchAll(()=>S.succeed(!1))))?{preservedWorktreePath:i.path}:(yield*bl(i.path).pipe(S.catchAll(()=>S.void)),{preservedWorktreePath:void 0})}).pipe(S.runPromise)),l=async p=>{p.signal?.throwIfAborted();let{prompt:m,promptFile:g,hooks:A,agent:E}=p,y=p.sandbox??CN();if(!E.buildInteractiveArgs)throw new Error(`Agent provider "${E.name}" does not support buildInteractiveArgs, required for interactive sessions.`);let b=S.gen(function*(){let w=yield*En,I=m!==void 0||g!==void 0,v=I?yield*Mp({prompt:m,promptFile:g}):void 0,k=v?.text??"",R=v?.source==="inline",B=yield*Fp(o),D={...Lp({resolvedEnv:B,agentProviderEnv:E.env,sandboxProviderEnv:y.env}),...p.env??{}},ee=k;if(I&&!R){let _=p.promptArgs??{};yield*$p(_);let P={SOURCE_BRANCH:i.branch,TARGET_BRANCH:i.branch,..._},$=new Set(Sl);ee=yield*Hp(k,P,$)}else R&&(yield*Up(p.promptArgs??{}));yield*w.intro(p.name??"sandcastle interactive"),yield*w.summary("Interactive Session",{Agent:p.name??E.name,Sandbox:y.name,Branch:i.branch});let F;if(y.tag==="none")F=yield*S.promise(()=>y.create({worktreePath:i.path,env:D}));else if(y.tag==="isolated")F=(yield*w.taskLog("Starting sandbox",()=>xo({provider:y,hostRepoDir:i.path,env:D}))).handle;else{let _=wN(o,".git"),P=yield*Pp(_),$=yield*qd(P,i.path,Oo);F=(yield*w.taskLog("Starting sandbox",()=>xo({provider:y,hostRepoDir:o,env:D,worktreeOrRepoPath:i.path,gitMounts:$,repoDir:Oo}))).handle}return yield*S.gen(function*(){if(!F.interactiveExec)throw new Error("Sandbox provider does not support interactiveExec. The provider must implement the optional interactiveExec method to use interactive().");let _=F.interactiveExec.bind(F),P=ag(F),$=F.worktreePath,N=y.tag==="isolated"?()=>Np(i.path,F):()=>S.void,re=yield*px({hostRepoDir:o,sandboxRepoDir:$,hooks:A,branch:n?void 0:i.branch,hostWorktreePath:i.path,applyToHost:N,timeouts:e.timeouts,keepSourceBranch:n},P,ue=>S.gen(function*(){let Oe=!I||R?ee:yield*dx(ee,ue.sandbox,ue.sandboxRepoDir),Ye=E.buildInteractiveArgs({prompt:Oe,dangerouslySkipPermissions:y.tag!=="none"});return(yield*az(S.promise(()=>_(Ye,{stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,cwd:$})),p.signal)).exitCode})),ie=re.result;return yield*w.summary("Session Complete",{Commits:String(re.commits.length),Branch:re.branch,"Exit code":String(ie)}),{commits:re.commits,branch:re.branch,preservedWorktreePath:void 0,exitCode:ie}}).pipe(S.ensuring(S.promise(()=>F.close().catch(()=>{}))))});try{return await S.runPromise(b.pipe(S.provide(Tp.layer),S.provide(us.layer),S.provide(sa.layer)))}catch(w){throw p.signal?.throwIfAborted(),w}},d=async p=>{p.signal?.throwIfAborted();let{prompt:m,promptFile:g,hooks:A,agent:E}=p,y=p.sandbox,b=p.maxIterations??1;if(p.resumeSession&&b>1)throw new Error("resumeSession cannot be combined with maxIterations > 1. Resume applies to iteration 1 only; multi-iteration resume semantics are not supported.");p.resumeSession&&await av({provider:E,sandboxTag:y.tag,hostRepoDir:o,resumeSession:p.resumeSession});let w=S.gen(function*(){let I=yield*Mp({prompt:m,promptFile:g}),v=I.text,k=I.source==="inline",R=yield*Fp(o),L={...Lp({resolvedEnv:R,agentProviderEnv:E.env,sandboxProviderEnv:y.env}),...p.env??{}},D=p.promptArgs??{},ee;if(k)yield*Up(D),ee=v;else{yield*$p(D);let T={SOURCE_BRANCH:i.branch,TARGET_BRANCH:i.branch,...D},J=new Set(Sl);ee=yield*Hp(v,T,J)}let F,_;if(y.tag==="isolated"){let T=yield*xo({provider:y,hostRepoDir:i.path,env:L});F=T.handle,_=T.worktreePath}else if(y.tag==="none"){let T=yield*xo({provider:y,hostRepoDir:o,env:L,worktreeOrRepoPath:i.path});F=T.handle,_=T.worktreePath}else{let T=wN(o,".git"),J=yield*Pp(T),Ne=yield*qd(J,i.path,Oo),Cr=yield*xo({provider:y,hostRepoDir:o,env:L,worktreeOrRepoPath:i.path,gitMounts:Ne,repoDir:Oo});F=Cr.handle,_=Cr.worktreePath}let P=ag(F),$=y.tag==="isolated"?()=>Np(i.path,F):()=>S.void,N=p.logging??{type:"file",path:wN(o,".sandcastle","logs",AN(i.branch,void 0,p.name))},q=N.type==="file"?(gN({logPath:N.path,agentName:p.name,branch:i.branch}),Er.provide(lv.layer(N.path),sa.layer)):Tp.layer,re=y.tag==="bind-mount"?F:void 0,ie=Er.succeed(cg,{withSandbox:T=>T({hostWorktreePath:i.path,sandboxRepoPath:_,applyToHost:$,bindMountHandle:re},P).pipe(S.map(J=>({value:J,preservedWorktreePath:void 0})))}),ue=dv(EN(N)),Oe=Er.mergeAll(ie,q,ue),Ye=yield*S.gen(function*(){let T=yield*En;yield*T.intro(p.name??"sandcastle");let J=yield*Cv({hostRepoDir:o,iterations:b,hooks:A,prompt:ee,branch:n?void 0:i.branch,provider:E,completionSignal:p.completionSignal,idleTimeoutSeconds:p.idleTimeoutSeconds,completionTimeoutSeconds:p.completionTimeoutSeconds,name:p.name,resumeSession:p.resumeSession,signal:p.signal,skipPromptExpansion:k,timeouts:e.timeouts,keepSourceBranch:n}),Ne=yN(J.completionSignal,J.iterations.length);yield*T.status(Ne.message,Ne.severity);for(let Cr of xN(J.iterations))yield*T.text(Cr);return J}).pipe(S.provide(Oe),S.ensuring(S.promise(()=>F.close().catch(()=>{}))));return{iterations:Ye.iterations,completionSignal:Ye.completionSignal,stdout:Ye.stdout,commits:Ye.commits,branch:Ye.branch,logFilePath:N.type==="file"?N.path:void 0}});try{return await S.runPromise(w.pipe(S.provide(Tp.layer),S.provide(us.layer),S.provide(sa.layer)))}catch(I){throw p.signal?.throwIfAborted(),I}},f=async p=>Uet({branch:i.branch,worktreePath:i.path,hostRepoDir:o,sandbox:p.sandbox,hooks:p.hooks,copyToWorktree:p.copyToWorktree,timeouts:p.timeouts,branchStrategy:e.branchStrategy,_test:p._test});return{branch:i.branch,worktreePath:i.path,run:d,interactive:l,createSandbox:f,close:u,async[Symbol.asyncDispose](){await u()}}}});import{access as Orr,readdir as fz}from"node:fs/promises";import{join as Qs,posix as Dle,relative as Nrr}from"node:path";var Prr,IN,hx,pz,jet,qet,Get,mz,zet,kN,Mrr,Vet,Iv,Yet,Jet,vN,Qle,Ole,Frr,Ket,hz,Zet,Xet,Nle,Ple=h(()=>{"use strict";Prr=async e=>{try{return await Orr(e),!0}catch{return!1}},IN=e=>(e==="/"||/^[A-Za-z]:[\\/]?$/.test(e)?e:e.replace(/[\\/]+$/,"")).replace(/^([A-Za-z]):/,"$1").replace(/[\\/]/g,"-"),hx=(e,t,r)=>{let n=r??Qs(process.env.HOME??"~",".claude","projects");return Qs(n,IN(e),`${t}.jsonl`)},pz=(e,t,r)=>Dle.join(r,IN(e),`${t}.jsonl`),jet=(e,t,r)=>{let n=r??Qs(process.env.HOME??"~",".claude","projects");return Qs(n,IN(e),t,"subagents")},qet=async(e,t)=>{let r=await t.exec(`find ${JSON.stringify(e)} -type f -name ${JSON.stringify("agent-*.jsonl")} 2>/dev/null`);if(r.exitCode!==0)return[];let n=r.stdout.trim();return n===""?[]:n.split(`
314
316
  `).filter(o=>o!=="")},Get=async(e,t,r)=>{let n=await t.exec(`find ${JSON.stringify(r)} -type f -name ${JSON.stringify(`${e}.jsonl`)} -print -quit`),o=n.stdout.trim().split(`
315
317
  `)[0];if(n.exitCode!==0||!o)throw new Error(`session ${e} not found under ${r}`);return o},mz=async(e,t)=>{let r=t??Qs(process.env.HOME??"~",".claude","projects"),n;try{n=await fz(r,{withFileTypes:!0})}catch{return{path:void 0,searchedRoot:r}}for(let o of n){if(!o.isDirectory())continue;let i=Qs(r,o.name,`${e}.jsonl`);if(await Prr(i))return{path:i,searchedRoot:r}}return{path:void 0,searchedRoot:r}},zet=(e,t,r)=>e===""?"":e.split(`
@@ -385,11 +387,11 @@ Worktree preserved at ${i}`),console.error(` To review: cd ${i}`),console.error
385
387
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1&&e.reused==="ref"){i(s);continue}}}function Ix(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),a._zod.parent===d)for(let A in u)A==="$ref"||A==="allOf"||A in l||delete u[A];if(m.$ref&&p.def)for(let A in u)A==="$ref"||A==="allOf"||A in p.def&&JSON.stringify(u[A])===JSON.stringify(p.def[A])&&delete u[A]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())n(a[0]);let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Vv(t,"input",e.processors),output:Vv(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function ya(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return ya(n.element,r);if(n.type==="set")return ya(n.valueType,r);if(n.type==="lazy")return ya(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return ya(n.innerType,r);if(n.type==="intersection")return ya(n.left,r)||ya(n.right,r);if(n.type==="record"||n.type==="map")return ya(n.keyType,r)||ya(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ya(n.in,r)||ya(n.out,r);if(n.type==="object"){for(let o in n.shape)if(ya(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(ya(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(ya(o,r))return!0;return!!(n.rest&&ya(n.rest,r))}return!1}var eme,Vv,VN=h(()=>{qN();eme=(e,t={})=>r=>{let n=Cx({...r,processors:t});return Wr(e,n),wx(n,e),Ix(n,e)},Vv=(e,t,r={})=>n=>{let{libraryOptions:o,target:i}=n??{},s=Cx({...o??{},target:i,io:t,processors:r});return Wr(e,s),wx(s,e),Ix(s,e)}});function SV(e,t){if("_idmap"in e){let n=e,o=Cx({...t,processors:xV}),i={};for(let c of n._idmap.entries()){let[u,l]=c;Wr(l,o)}let s={},a={registry:n,uri:t?.uri,defs:i};o.external=a;for(let c of n._idmap.entries()){let[u,l]=c;wx(o,l),s[u]=Ix(o,l)}if(Object.keys(i).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let r=Cx({...t,processors:xV});return Wr(e,r),wx(r,e),Ix(r,e)}var mir,tme,rme,nme,ome,ime,sme,ame,cme,ume,lme,dme,fme,pme,mme,hme,gme,Ame,yme,xme,Eme,bme,Sme,Cme,wme,Ime,EV,kme,vme,Rme,_me,Bme,Tme,Dme,Qme,Ome,Nme,Pme,bV,Mme,xV,YN=h(()=>{VN();Ge();mir={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},tme=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=mir[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},rme=(e,t,r,n)=>{let o=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";let d=typeof l=="number"&&l>=(i??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(s??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";d?p?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof i=="number"&&(o.minimum=i),f?p?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof s=="number"&&(o.maximum=s),typeof c=="number"&&(o.multipleOf=c)},nme=(e,t,r,n)=>{r.type="boolean"},ome=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},ime=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},sme=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},ame=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},cme=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},ume=(e,t,r,n)=>{r.not={}},lme=(e,t,r,n)=>{},dme=(e,t,r,n)=>{},fme=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},pme=(e,t,r,n)=>{let o=e._zod.def,i=_N(o.entries);i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),r.enum=i},mme=(e,t,r,n)=>{let o=e._zod.def,i=[];for(let s of o.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){let s=i[0];r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[s]:r.const=s}else i.every(s=>typeof s=="number")&&(r.type="number"),i.every(s=>typeof s=="string")&&(r.type="string"),i.every(s=>typeof s=="boolean")&&(r.type="boolean"),i.every(s=>s===null)&&(r.type="null"),r.enum=i},hme=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},gme=(e,t,r,n)=>{let o=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},Ame=(e,t,r,n)=>{let o=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=e._zod.bag;s!==void 0&&(i.minLength=s),a!==void 0&&(i.maxLength=a),c?c.length===1?(i.contentMediaType=c[0],Object.assign(o,i)):(Object.assign(o,i),o.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(o,i)},yme=(e,t,r,n)=>{r.type="boolean"},xme=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Eme=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},bme=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Sme=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Cme=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},wme=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=Wr(i.element,t,{...n,path:[...n.path,"items"]})},Ime=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object",o.properties={};let s=i.shape;for(let u in s)o.properties[u]=Wr(s[u],t,{...n,path:[...n.path,"properties",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter(u=>{let l=i.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=Wr(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},EV=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>Wr(a,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=s:r.anyOf=s},kme=(e,t,r,n)=>{let o=e._zod.def,i=Wr(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=Wr(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c},vme=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((f,p)=>Wr(f,t,{...n,path:[...n.path,s,p]})),u=i.rest?Wr(i.rest,t,{...n,path:[...n.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(o.prefixItems=c,u&&(o.items=u)):t.target==="openapi-3.0"?(o.items={anyOf:c},u&&o.items.anyOf.push(u),o.minItems=c.length,u||(o.maxItems=c.length)):(o.items=c,u&&(o.additionalItems=u));let{minimum:l,maximum:d}=e._zod.bag;typeof l=="number"&&(o.minItems=l),typeof d=="number"&&(o.maxItems=d)},Rme=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let l=Wr(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=Wr(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=Wr(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=s._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},_me=(e,t,r,n)=>{let o=e._zod.def,i=Wr(o.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Bme=(e,t,r,n)=>{let o=e._zod.def;Wr(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Tme=(e,t,r,n)=>{let o=e._zod.def;Wr(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Dme=(e,t,r,n)=>{let o=e._zod.def;Wr(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Qme=(e,t,r,n)=>{let o=e._zod.def;Wr(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s},Ome=(e,t,r,n)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;Wr(s,t,n);let a=t.seen.get(e);a.ref=s},Nme=(e,t,r,n)=>{let o=e._zod.def;Wr(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},Pme=(e,t,r,n)=>{let o=e._zod.def;Wr(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},bV=(e,t,r,n)=>{let o=e._zod.def;Wr(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Mme=(e,t,r,n)=>{let o=e._zod.innerType;Wr(o,t,n);let i=t.seen.get(e);i.ref=o},xV={string:tme,number:rme,boolean:nme,bigint:ome,symbol:ime,null:sme,undefined:ame,void:cme,never:ume,any:lme,unknown:dme,date:fme,enum:pme,literal:mme,nan:hme,template_literal:gme,file:Ame,success:yme,custom:xme,function:Eme,transform:bme,map:Sme,set:Cme,array:wme,object:Ime,union:EV,intersection:kme,tuple:vme,record:Rme,nullable:_me,nonoptional:Bme,default:Tme,prefault:Dme,catch:Qme,pipe:Ome,readonly:Nme,promise:Pme,optional:bV,lazy:Mme}});var CV,Rnt=h(()=>{YN();VN();CV=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Cx({processors:xV,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return Wr(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),wx(this.ctx,t);let n=Ix(this.ctx,t),{"~standard":o,...i}=n;return i}}});var _nt={};var Bnt=h(()=>{});var dg={};tr(dg,{$ZodAny:()=>Bfe,$ZodArray:()=>Nfe,$ZodAsyncError:()=>Vd,$ZodBase64:()=>Efe,$ZodBase64URL:()=>bfe,$ZodBigInt:()=>Lz,$ZodBigIntFormat:()=>kfe,$ZodBoolean:()=>UN,$ZodCIDRv4:()=>Afe,$ZodCIDRv6:()=>yfe,$ZodCUID:()=>ife,$ZodCUID2:()=>sfe,$ZodCatch:()=>Xfe,$ZodCheck:()=>An,$ZodCheckBigIntFormat:()=>Qde,$ZodCheckEndsWith:()=>qde,$ZodCheckGreaterThan:()=>Dz,$ZodCheckIncludes:()=>Wde,$ZodCheckLengthEquals:()=>Lde,$ZodCheckLessThan:()=>Tz,$ZodCheckLowerCase:()=>$de,$ZodCheckMaxLength:()=>Mde,$ZodCheckMaxSize:()=>Ode,$ZodCheckMimeType:()=>zde,$ZodCheckMinLength:()=>Fde,$ZodCheckMinSize:()=>Nde,$ZodCheckMultipleOf:()=>Tde,$ZodCheckNumberFormat:()=>Dde,$ZodCheckOverwrite:()=>Vde,$ZodCheckProperty:()=>Gde,$ZodCheckRegex:()=>Ude,$ZodCheckSizeEquals:()=>Pde,$ZodCheckStartsWith:()=>jde,$ZodCheckStringFormat:()=>Qv,$ZodCheckUpperCase:()=>Hde,$ZodCodec:()=>HN,$ZodCustom:()=>ape,$ZodCustomStringFormat:()=>wfe,$ZodDate:()=>Ofe,$ZodDefault:()=>Yfe,$ZodDiscriminatedUnion:()=>Ffe,$ZodE164:()=>Sfe,$ZodEmail:()=>tfe,$ZodEmoji:()=>nfe,$ZodEncodeError:()=>gx,$ZodEnum:()=>Wfe,$ZodError:()=>ON,$ZodExactOptional:()=>zfe,$ZodFile:()=>qfe,$ZodFunction:()=>ope,$ZodGUID:()=>Xde,$ZodIPv4:()=>mfe,$ZodIPv6:()=>hfe,$ZodISODate:()=>dfe,$ZodISODateTime:()=>lfe,$ZodISODuration:()=>pfe,$ZodISOTime:()=>ffe,$ZodIntersection:()=>Lfe,$ZodJWT:()=>Cfe,$ZodKSUID:()=>ufe,$ZodLazy:()=>spe,$ZodLiteral:()=>jfe,$ZodMAC:()=>gfe,$ZodMap:()=>$fe,$ZodNaN:()=>epe,$ZodNanoID:()=>ofe,$ZodNever:()=>Dfe,$ZodNonOptional:()=>Kfe,$ZodNull:()=>_fe,$ZodNullable:()=>Vfe,$ZodNumber:()=>Fz,$ZodNumberFormat:()=>Ife,$ZodObject:()=>Btt,$ZodObjectJIT:()=>Pfe,$ZodOptional:()=>$z,$ZodPipe:()=>Hz,$ZodPrefault:()=>Jfe,$ZodPreprocess:()=>tpe,$ZodPromise:()=>ipe,$ZodReadonly:()=>rpe,$ZodRealError:()=>nc,$ZodRecord:()=>Ufe,$ZodRegistry:()=>Gz,$ZodSet:()=>Hfe,$ZodString:()=>mC,$ZodStringFormat:()=>an,$ZodSuccess:()=>Zfe,$ZodSymbol:()=>vfe,$ZodTemplateLiteral:()=>npe,$ZodTransform:()=>Gfe,$ZodTuple:()=>Uz,$ZodType:()=>It,$ZodULID:()=>afe,$ZodURL:()=>rfe,$ZodUUID:()=>efe,$ZodUndefined:()=>Rfe,$ZodUnion:()=>$N,$ZodUnknown:()=>Tfe,$ZodVoid:()=>Qfe,$ZodXID:()=>cfe,$ZodXor:()=>Mfe,$brand:()=>Fle,$constructor:()=>j,$input:()=>mpe,$output:()=>ppe,Doc:()=>LN,JSONSchema:()=>_nt,JSONSchemaGenerator:()=>CV,NEVER:()=>Mle,TimePrecision:()=>ype,_any:()=>Lpe,_array:()=>Gpe,_base64:()=>lV,_base64url:()=>dV,_bigint:()=>Dpe,_boolean:()=>Bpe,_catch:()=>cir,_check:()=>knt,_cidrv4:()=>cV,_cidrv6:()=>uV,_coercedBigint:()=>Qpe,_coercedBoolean:()=>Tpe,_coercedDate:()=>jpe,_coercedNumber:()=>wpe,_coercedString:()=>gpe,_cuid:()=>tV,_cuid2:()=>rV,_custom:()=>Vpe,_date:()=>Wpe,_decode:()=>bz,_decodeAsync:()=>Cz,_default:()=>iir,_discriminatedUnion:()=>zor,_e164:()=>fV,_email:()=>Vz,_emoji:()=>Xz,_encode:()=>Ez,_encodeAsync:()=>Sz,_endsWith:()=>Uv,_enum:()=>Xor,_file:()=>zpe,_float32:()=>kpe,_float64:()=>vpe,_gt:()=>qp,_gte:()=>Aa,_guid:()=>GN,_includes:()=>Fv,_int:()=>Ipe,_int32:()=>Rpe,_int64:()=>Ope,_intersection:()=>Vor,_ipv4:()=>sV,_ipv6:()=>aV,_isoDate:()=>Epe,_isoDateTime:()=>xpe,_isoDuration:()=>Spe,_isoTime:()=>bpe,_jwt:()=>pV,_ksuid:()=>iV,_lazy:()=>fir,_length:()=>AC,_literal:()=>tir,_lowercase:()=>Pv,_lt:()=>jp,_lte:()=>eu,_mac:()=>Ape,_map:()=>Kor,_max:()=>eu,_maxLength:()=>gC,_maxSize:()=>Sx,_mime:()=>$v,_min:()=>Aa,_minLength:()=>lg,_minSize:()=>Gp,_multipleOf:()=>bx,_nan:()=>qpe,_nanoid:()=>eV,_nativeEnum:()=>eir,_negative:()=>hV,_never:()=>$pe,_nonnegative:()=>AV,_nonoptional:()=>sir,_nonpositive:()=>gV,_normalize:()=>Hv,_null:()=>Fpe,_nullable:()=>oir,_number:()=>Cpe,_optional:()=>nir,_overwrite:()=>Yd,_parse:()=>_v,_parseAsync:()=>Bv,_pipe:()=>uir,_positive:()=>mV,_promise:()=>pir,_property:()=>yV,_readonly:()=>lir,_record:()=>Jor,_refine:()=>Ype,_regex:()=>Nv,_safeDecode:()=>Iz,_safeDecodeAsync:()=>vz,_safeEncode:()=>wz,_safeEncodeAsync:()=>kz,_safeParse:()=>Tv,_safeParseAsync:()=>Dv,_set:()=>Zor,_size:()=>hC,_slugify:()=>Gv,_startsWith:()=>Lv,_string:()=>hpe,_stringFormat:()=>zv,_stringbool:()=>Xpe,_success:()=>air,_superRefine:()=>Jpe,_symbol:()=>Ppe,_templateLiteral:()=>dir,_toLowerCase:()=>jv,_toUpperCase:()=>qv,_transform:()=>rir,_trim:()=>Wv,_tuple:()=>Yor,_uint32:()=>_pe,_uint64:()=>Npe,_ulid:()=>nV,_undefined:()=>Mpe,_union:()=>qor,_unknown:()=>Upe,_uppercase:()=>Mv,_url:()=>zN,_uuid:()=>Yz,_uuidv4:()=>Jz,_uuidv6:()=>Kz,_uuidv7:()=>Zz,_void:()=>Hpe,_xid:()=>oV,_xor:()=>Gor,clone:()=>ha,config:()=>Eo,createStandardJSONSchemaMethod:()=>Vv,createToJSONSchemaMethod:()=>eme,decode:()=>fnr,decodeAsync:()=>mnr,describe:()=>Kpe,encode:()=>dnr,encodeAsync:()=>pnr,extractDefs:()=>wx,finalize:()=>Ix,flattenError:()=>NN,formatError:()=>PN,globalConfig:()=>lC,globalRegistry:()=>ls,initializeContext:()=>Cx,isValidBase64:()=>xfe,isValidBase64URL:()=>ktt,isValidJWT:()=>vtt,locales:()=>jN,meta:()=>Zpe,parse:()=>yz,parseAsync:()=>xz,prettifyError:()=>Kle,process:()=>Wr,regexes:()=>Xc,registry:()=>zz,safeDecode:()=>gnr,safeDecodeAsync:()=>ynr,safeEncode:()=>hnr,safeEncodeAsync:()=>Anr,safeParse:()=>Xle,safeParseAsync:()=>ede,toDotPath:()=>itt,toJSONSchema:()=>SV,treeifyError:()=>Jle,util:()=>fe,version:()=>Jde});var tu=h(()=>{dC();tde();Zle();cpe();Qz();Kde();Ge();Bz();fpe();qN();Yde();vnt();VN();YN();Rnt();Bnt()});var wV={};tr(wV,{endsWith:()=>Uv,gt:()=>qp,gte:()=>Aa,includes:()=>Fv,length:()=>AC,lowercase:()=>Pv,lt:()=>jp,lte:()=>eu,maxLength:()=>gC,maxSize:()=>Sx,mime:()=>$v,minLength:()=>lg,minSize:()=>Gp,multipleOf:()=>bx,negative:()=>hV,nonnegative:()=>AV,nonpositive:()=>gV,normalize:()=>Hv,overwrite:()=>Yd,positive:()=>mV,property:()=>yV,regex:()=>Nv,size:()=>hC,slugify:()=>Gv,startsWith:()=>Lv,toLowerCase:()=>jv,toUpperCase:()=>qv,trim:()=>Wv,uppercase:()=>Mv});var IV=h(()=>{tu()});var Yv={};tr(Yv,{ZodISODate:()=>vV,ZodISODateTime:()=>kV,ZodISODuration:()=>_V,ZodISOTime:()=>RV,date:()=>Lme,datetime:()=>Fme,duration:()=>$me,time:()=>Ume});function Fme(e){return xpe(kV,e)}function Lme(e){return Epe(vV,e)}function Ume(e){return bpe(RV,e)}function $me(e){return Spe(_V,e)}var kV,vV,RV,_V,JN=h(()=>{tu();ZN();kV=j("ZodISODateTime",(e,t)=>{lfe.init(e,t),cn.init(e,t)});vV=j("ZodISODate",(e,t)=>{dfe.init(e,t),cn.init(e,t)});RV=j("ZodISOTime",(e,t)=>{ffe.init(e,t),cn.init(e,t)});_V=j("ZodISODuration",(e,t)=>{pfe.init(e,t),cn.init(e,t)})});var Tnt,gir,oc,Hme=h(()=>{tu();tu();Ge();Tnt=(e,t)=>{ON.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>PN(e,r)},flatten:{value:r=>NN(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,kv,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,kv,2)}},isEmpty:{get(){return e.issues.length===0}}})},gir=j("ZodError",Tnt),oc=j("ZodError",Tnt,{Parent:Error})});var Wme,jme,qme,Gme,zme,Vme,Yme,Jme,Kme,Zme,Xme,ehe,the=h(()=>{tu();Hme();Wme=_v(oc),jme=Bv(oc),qme=Tv(oc),Gme=Dv(oc),zme=Ez(oc),Vme=bz(oc),Yme=Sz(oc),Jme=Cz(oc),Kme=wz(oc),Zme=Iz(oc),Xme=kz(oc),ehe=vz(oc)});var KN={};tr(KN,{ZodAny:()=>uhe,ZodArray:()=>phe,ZodBase64:()=>qV,ZodBase64URL:()=>GV,ZodBigInt:()=>rR,ZodBigIntFormat:()=>YV,ZodBoolean:()=>tR,ZodCIDRv4:()=>WV,ZodCIDRv6:()=>jV,ZodCUID:()=>PV,ZodCUID2:()=>MV,ZodCatch:()=>Nhe,ZodCodec:()=>lP,ZodCustom:()=>dP,ZodCustomStringFormat:()=>Xv,ZodDate:()=>iP,ZodDefault:()=>_he,ZodDiscriminatedUnion:()=>hhe,ZodE164:()=>zV,ZodEmail:()=>QV,ZodEmoji:()=>OV,ZodEnum:()=>Kv,ZodExactOptional:()=>khe,ZodFile:()=>whe,ZodFunction:()=>qhe,ZodGUID:()=>eP,ZodIPv4:()=>$V,ZodIPv6:()=>HV,ZodIntersection:()=>ghe,ZodJWT:()=>VV,ZodKSUID:()=>UV,ZodLazy:()=>Hhe,ZodLiteral:()=>Che,ZodMAC:()=>rhe,ZodMap:()=>bhe,ZodNaN:()=>Mhe,ZodNanoID:()=>NV,ZodNever:()=>dhe,ZodNonOptional:()=>t4,ZodNull:()=>ahe,ZodNullable:()=>Rhe,ZodNumber:()=>eR,ZodNumberFormat:()=>xC,ZodObject:()=>aP,ZodOptional:()=>e4,ZodPipe:()=>uP,ZodPrefault:()=>The,ZodPreprocess:()=>Fhe,ZodPromise:()=>jhe,ZodReadonly:()=>Lhe,ZodRecord:()=>Jv,ZodSet:()=>She,ZodString:()=>Zv,ZodStringFormat:()=>cn,ZodSuccess:()=>Ohe,ZodSymbol:()=>ihe,ZodTemplateLiteral:()=>$he,ZodTransform:()=>Ihe,ZodTuple:()=>yhe,ZodType:()=>Mt,ZodULID:()=>FV,ZodURL:()=>oP,ZodUUID:()=>zp,ZodUndefined:()=>she,ZodUnion:()=>cP,ZodUnknown:()=>lhe,ZodVoid:()=>fhe,ZodXID:()=>LV,ZodXor:()=>mhe,_ZodString:()=>DV,_default:()=>Bhe,_function:()=>Lot,any:()=>got,array:()=>sP,base64:()=>Xnt,base64url:()=>eot,bigint:()=>dot,boolean:()=>ohe,catch:()=>Phe,check:()=>Uot,cidrv4:()=>Knt,cidrv6:()=>Znt,codec:()=>Not,cuid:()=>Wnt,cuid2:()=>jnt,custom:()=>$ot,date:()=>yot,describe:()=>Hot,discriminatedUnion:()=>wot,e164:()=>tot,email:()=>Qnt,emoji:()=>$nt,enum:()=>ZV,exactOptional:()=>vhe,file:()=>Tot,float32:()=>aot,float64:()=>cot,function:()=>Lot,guid:()=>Ont,hash:()=>sot,hex:()=>iot,hostname:()=>oot,httpUrl:()=>Unt,instanceof:()=>jot,int:()=>BV,int32:()=>uot,int64:()=>fot,intersection:()=>Ahe,invertCodec:()=>Pot,ipv4:()=>Vnt,ipv6:()=>Jnt,json:()=>Got,jwt:()=>rot,keyof:()=>xot,ksuid:()=>znt,lazy:()=>Whe,literal:()=>Bot,looseObject:()=>Sot,looseRecord:()=>kot,mac:()=>Ynt,map:()=>vot,meta:()=>Wot,nan:()=>Oot,nanoid:()=>Hnt,nativeEnum:()=>_ot,never:()=>JV,nonoptional:()=>Qhe,null:()=>che,nullable:()=>rP,nullish:()=>Dot,number:()=>nhe,object:()=>Eot,optional:()=>tP,partialRecord:()=>Iot,pipe:()=>TV,prefault:()=>Dhe,preprocess:()=>zot,promise:()=>Fot,readonly:()=>Uhe,record:()=>Ehe,refine:()=>Ghe,set:()=>Rot,strictObject:()=>bot,string:()=>XN,stringFormat:()=>not,stringbool:()=>qot,success:()=>Qot,superRefine:()=>zhe,symbol:()=>mot,templateLiteral:()=>Mot,transform:()=>XV,tuple:()=>xhe,uint32:()=>lot,uint64:()=>pot,ulid:()=>qnt,undefined:()=>hot,union:()=>KV,unknown:()=>yC,url:()=>Lnt,uuid:()=>Nnt,uuidv4:()=>Pnt,uuidv6:()=>Mnt,uuidv7:()=>Fnt,void:()=>Aot,xid:()=>Gnt,xor:()=>Cot});function nP(e,t,r){let n=Object.getPrototypeOf(e),o=Dnt.get(n);if(o||(o=new Set,Dnt.set(n,o)),!o.has(t)){o.add(t);for(let i in r){let s=r[i];Object.defineProperty(n,i,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}function XN(e){return hpe(Zv,e)}function Qnt(e){return Vz(QV,e)}function Ont(e){return GN(eP,e)}function Nnt(e){return Yz(zp,e)}function Pnt(e){return Jz(zp,e)}function Mnt(e){return Kz(zp,e)}function Fnt(e){return Zz(zp,e)}function Lnt(e){return zN(oP,e)}function Unt(e){return zN(oP,{protocol:Xc.httpProtocol,hostname:Xc.domain,...fe.normalizeParams(e)})}function $nt(e){return Xz(OV,e)}function Hnt(e){return eV(NV,e)}function Wnt(e){return tV(PV,e)}function jnt(e){return rV(MV,e)}function qnt(e){return nV(FV,e)}function Gnt(e){return oV(LV,e)}function znt(e){return iV(UV,e)}function Vnt(e){return sV($V,e)}function Ynt(e){return Ape(rhe,e)}function Jnt(e){return aV(HV,e)}function Knt(e){return cV(WV,e)}function Znt(e){return uV(jV,e)}function Xnt(e){return lV(qV,e)}function eot(e){return dV(GV,e)}function tot(e){return fV(zV,e)}function rot(e){return pV(VV,e)}function not(e,t,r={}){return zv(Xv,e,t,r)}function oot(e){return zv(Xv,"hostname",Xc.hostname,e)}function iot(e){return zv(Xv,"hex",Xc.hex,e)}function sot(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,o=Xc[n];if(!o)throw new Error(`Unrecognized hash format: ${n}`);return zv(Xv,n,o,t)}function nhe(e){return Cpe(eR,e)}function BV(e){return Ipe(xC,e)}function aot(e){return kpe(xC,e)}function cot(e){return vpe(xC,e)}function uot(e){return Rpe(xC,e)}function lot(e){return _pe(xC,e)}function ohe(e){return Bpe(tR,e)}function dot(e){return Dpe(rR,e)}function fot(e){return Ope(YV,e)}function pot(e){return Npe(YV,e)}function mot(e){return Ppe(ihe,e)}function hot(e){return Mpe(she,e)}function che(e){return Fpe(ahe,e)}function got(){return Lpe(uhe)}function yC(){return Upe(lhe)}function JV(e){return $pe(dhe,e)}function Aot(e){return Hpe(fhe,e)}function yot(e){return Wpe(iP,e)}function sP(e,t){return Gpe(phe,e,t)}function xot(e){let t=e._zod.def.shape;return ZV(Object.keys(t))}function Eot(e,t){let r={type:"object",shape:e??{},...fe.normalizeParams(t)};return new aP(r)}function bot(e,t){return new aP({type:"object",shape:e,catchall:JV(),...fe.normalizeParams(t)})}function Sot(e,t){return new aP({type:"object",shape:e,catchall:yC(),...fe.normalizeParams(t)})}function KV(e,t){return new cP({type:"union",options:e,...fe.normalizeParams(t)})}function Cot(e,t){return new mhe({type:"union",options:e,inclusive:!1,...fe.normalizeParams(t)})}function wot(e,t,r){return new hhe({type:"union",options:t,discriminator:e,...fe.normalizeParams(r)})}function Ahe(e,t){return new ghe({type:"intersection",left:e,right:t})}function xhe(e,t,r){let n=t instanceof It,o=n?r:t,i=n?t:null;return new yhe({type:"tuple",items:e,rest:i,...fe.normalizeParams(o)})}function Ehe(e,t,r){return!t||!t._zod?new Jv({type:"record",keyType:XN(),valueType:e,...fe.normalizeParams(t)}):new Jv({type:"record",keyType:e,valueType:t,...fe.normalizeParams(r)})}function Iot(e,t,r){let n=ha(e);return n._zod.values=void 0,new Jv({type:"record",keyType:n,valueType:t,...fe.normalizeParams(r)})}function kot(e,t,r){return new Jv({type:"record",keyType:e,valueType:t,mode:"loose",...fe.normalizeParams(r)})}function vot(e,t,r){return new bhe({type:"map",keyType:e,valueType:t,...fe.normalizeParams(r)})}function Rot(e,t){return new She({type:"set",valueType:e,...fe.normalizeParams(t)})}function ZV(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Kv({type:"enum",entries:r,...fe.normalizeParams(t)})}function _ot(e,t){return new Kv({type:"enum",entries:e,...fe.normalizeParams(t)})}function Bot(e,t){return new Che({type:"literal",values:Array.isArray(e)?e:[e],...fe.normalizeParams(t)})}function Tot(e){return zpe(whe,e)}function XV(e){return new Ihe({type:"transform",transform:e})}function tP(e){return new e4({type:"optional",innerType:e})}function vhe(e){return new khe({type:"optional",innerType:e})}function rP(e){return new Rhe({type:"nullable",innerType:e})}function Dot(e){return tP(rP(e))}function Bhe(e,t){return new _he({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():fe.shallowClone(t)}})}function Dhe(e,t){return new The({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():fe.shallowClone(t)}})}function Qhe(e,t){return new t4({type:"nonoptional",innerType:e,...fe.normalizeParams(t)})}function Qot(e){return new Ohe({type:"success",innerType:e})}function Phe(e,t){return new Nhe({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}function Oot(e){return qpe(Mhe,e)}function TV(e,t){return new uP({type:"pipe",in:e,out:t})}function Not(e,t,r){return new lP({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function Pot(e){let t=e._zod.def;return new lP({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}function Uhe(e){return new Lhe({type:"readonly",innerType:e})}function Mot(e,t){return new $he({type:"template_literal",parts:e,...fe.normalizeParams(t)})}function Whe(e){return new Hhe({type:"lazy",getter:e})}function Fot(e){return new jhe({type:"promise",innerType:e})}function Lot(e){return new qhe({type:"function",input:Array.isArray(e?.input)?xhe(e?.input):e?.input??sP(yC()),output:e?.output??yC()})}function Uot(e){let t=new An({check:"custom"});return t._zod.check=e,t}function $ot(e,t){return Vpe(dP,e??(()=>!0),t)}function Ghe(e,t={}){return Ype(dP,e,t)}function zhe(e,t){return Jpe(e,t)}function jot(e,t={}){let r=new dP({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...fe.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}function Got(e){let t=Whe(()=>KV([XN(e),nhe(),ohe(),che(),sP(t),Ehe(XN(),t)]));return t}function zot(e,t){return new Fhe({type:"pipe",in:XV(e),out:t})}var Dnt,Mt,DV,Zv,cn,QV,eP,zp,oP,OV,NV,PV,MV,FV,LV,UV,$V,rhe,HV,WV,jV,qV,GV,zV,VV,Xv,eR,xC,tR,rR,YV,ihe,she,ahe,uhe,lhe,dhe,fhe,iP,phe,aP,cP,mhe,hhe,ghe,yhe,Jv,bhe,She,Kv,Che,whe,Ihe,e4,khe,Rhe,_he,The,t4,Ohe,Nhe,Mhe,uP,lP,Fhe,Lhe,$he,Hhe,jhe,qhe,dP,Hot,Wot,qot,ZN=h(()=>{tu();tu();YN();VN();IV();JN();the();Dnt=new WeakMap;Mt=j("ZodType",(e,t)=>(It.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Vv(e,"input"),output:Vv(e,"output")}}),e.toJSONSchema=eme(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>Wme(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>qme(e,r,n),e.parseAsync=async(r,n)=>jme(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Gme(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>zme(e,r,n),e.decode=(r,n)=>Vme(e,r,n),e.encodeAsync=async(r,n)=>Yme(e,r,n),e.decodeAsync=async(r,n)=>Jme(e,r,n),e.safeEncode=(r,n)=>Kme(e,r,n),e.safeDecode=(r,n)=>Zme(e,r,n),e.safeEncodeAsync=async(r,n)=>Xme(e,r,n),e.safeDecodeAsync=async(r,n)=>ehe(e,r,n),nP(e,"ZodType",{check(...r){let n=this.def;return this.clone(fe.mergeDefs(n,{checks:[...n.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return ha(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(Ghe(r,n))},superRefine(r,n){return this.check(zhe(r,n))},overwrite(r){return this.check(Yd(r))},optional(){return tP(this)},exactOptional(){return vhe(this)},nullable(){return rP(this)},nullish(){return tP(rP(this))},nonoptional(r){return Qhe(this,r)},array(){return sP(this)},or(r){return KV([this,r])},and(r){return Ahe(this,r)},transform(r){return TV(this,XV(r))},default(r){return Bhe(this,r)},prefault(r){return Dhe(this,r)},catch(r){return Phe(this,r)},pipe(r){return TV(this,r)},readonly(){return Uhe(this)},describe(r){let n=this.clone();return ls.add(n,{description:r}),n},meta(...r){if(r.length===0)return ls.get(this);let n=this.clone();return ls.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return ls.get(e)?.description},configurable:!0}),e)),DV=j("_ZodString",(e,t)=>{mC.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,o,i)=>tme(e,n,o,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,nP(e,"_ZodString",{regex(...n){return this.check(Nv(...n))},includes(...n){return this.check(Fv(...n))},startsWith(...n){return this.check(Lv(...n))},endsWith(...n){return this.check(Uv(...n))},min(...n){return this.check(lg(...n))},max(...n){return this.check(gC(...n))},length(...n){return this.check(AC(...n))},nonempty(...n){return this.check(lg(1,...n))},lowercase(n){return this.check(Pv(n))},uppercase(n){return this.check(Mv(n))},trim(){return this.check(Wv())},normalize(...n){return this.check(Hv(...n))},toLowerCase(){return this.check(jv())},toUpperCase(){return this.check(qv())},slugify(){return this.check(Gv())}})}),Zv=j("ZodString",(e,t)=>{mC.init(e,t),DV.init(e,t),e.email=r=>e.check(Vz(QV,r)),e.url=r=>e.check(zN(oP,r)),e.jwt=r=>e.check(pV(VV,r)),e.emoji=r=>e.check(Xz(OV,r)),e.guid=r=>e.check(GN(eP,r)),e.uuid=r=>e.check(Yz(zp,r)),e.uuidv4=r=>e.check(Jz(zp,r)),e.uuidv6=r=>e.check(Kz(zp,r)),e.uuidv7=r=>e.check(Zz(zp,r)),e.nanoid=r=>e.check(eV(NV,r)),e.guid=r=>e.check(GN(eP,r)),e.cuid=r=>e.check(tV(PV,r)),e.cuid2=r=>e.check(rV(MV,r)),e.ulid=r=>e.check(nV(FV,r)),e.base64=r=>e.check(lV(qV,r)),e.base64url=r=>e.check(dV(GV,r)),e.xid=r=>e.check(oV(LV,r)),e.ksuid=r=>e.check(iV(UV,r)),e.ipv4=r=>e.check(sV($V,r)),e.ipv6=r=>e.check(aV(HV,r)),e.cidrv4=r=>e.check(cV(WV,r)),e.cidrv6=r=>e.check(uV(jV,r)),e.e164=r=>e.check(fV(zV,r)),e.datetime=r=>e.check(Fme(r)),e.date=r=>e.check(Lme(r)),e.time=r=>e.check(Ume(r)),e.duration=r=>e.check($me(r))});cn=j("ZodStringFormat",(e,t)=>{an.init(e,t),DV.init(e,t)}),QV=j("ZodEmail",(e,t)=>{tfe.init(e,t),cn.init(e,t)});eP=j("ZodGUID",(e,t)=>{Xde.init(e,t),cn.init(e,t)});zp=j("ZodUUID",(e,t)=>{efe.init(e,t),cn.init(e,t)});oP=j("ZodURL",(e,t)=>{rfe.init(e,t),cn.init(e,t)});OV=j("ZodEmoji",(e,t)=>{nfe.init(e,t),cn.init(e,t)});NV=j("ZodNanoID",(e,t)=>{ofe.init(e,t),cn.init(e,t)});PV=j("ZodCUID",(e,t)=>{ife.init(e,t),cn.init(e,t)});MV=j("ZodCUID2",(e,t)=>{sfe.init(e,t),cn.init(e,t)});FV=j("ZodULID",(e,t)=>{afe.init(e,t),cn.init(e,t)});LV=j("ZodXID",(e,t)=>{cfe.init(e,t),cn.init(e,t)});UV=j("ZodKSUID",(e,t)=>{ufe.init(e,t),cn.init(e,t)});$V=j("ZodIPv4",(e,t)=>{mfe.init(e,t),cn.init(e,t)});rhe=j("ZodMAC",(e,t)=>{gfe.init(e,t),cn.init(e,t)});HV=j("ZodIPv6",(e,t)=>{hfe.init(e,t),cn.init(e,t)});WV=j("ZodCIDRv4",(e,t)=>{Afe.init(e,t),cn.init(e,t)});jV=j("ZodCIDRv6",(e,t)=>{yfe.init(e,t),cn.init(e,t)});qV=j("ZodBase64",(e,t)=>{Efe.init(e,t),cn.init(e,t)});GV=j("ZodBase64URL",(e,t)=>{bfe.init(e,t),cn.init(e,t)});zV=j("ZodE164",(e,t)=>{Sfe.init(e,t),cn.init(e,t)});VV=j("ZodJWT",(e,t)=>{Cfe.init(e,t),cn.init(e,t)});Xv=j("ZodCustomStringFormat",(e,t)=>{wfe.init(e,t),cn.init(e,t)});eR=j("ZodNumber",(e,t)=>{Fz.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,o,i)=>rme(e,n,o,i),nP(e,"ZodNumber",{gt(n,o){return this.check(qp(n,o))},gte(n,o){return this.check(Aa(n,o))},min(n,o){return this.check(Aa(n,o))},lt(n,o){return this.check(jp(n,o))},lte(n,o){return this.check(eu(n,o))},max(n,o){return this.check(eu(n,o))},int(n){return this.check(BV(n))},safe(n){return this.check(BV(n))},positive(n){return this.check(qp(0,n))},nonnegative(n){return this.check(Aa(0,n))},negative(n){return this.check(jp(0,n))},nonpositive(n){return this.check(eu(0,n))},multipleOf(n,o){return this.check(bx(n,o))},step(n,o){return this.check(bx(n,o))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});xC=j("ZodNumberFormat",(e,t)=>{Ife.init(e,t),eR.init(e,t)});tR=j("ZodBoolean",(e,t)=>{UN.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nme(e,r,n,o)});rR=j("ZodBigInt",(e,t)=>{Lz.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,o,i)=>ome(e,n,o,i),e.gte=(n,o)=>e.check(Aa(n,o)),e.min=(n,o)=>e.check(Aa(n,o)),e.gt=(n,o)=>e.check(qp(n,o)),e.gte=(n,o)=>e.check(Aa(n,o)),e.min=(n,o)=>e.check(Aa(n,o)),e.lt=(n,o)=>e.check(jp(n,o)),e.lte=(n,o)=>e.check(eu(n,o)),e.max=(n,o)=>e.check(eu(n,o)),e.positive=n=>e.check(qp(BigInt(0),n)),e.negative=n=>e.check(jp(BigInt(0),n)),e.nonpositive=n=>e.check(eu(BigInt(0),n)),e.nonnegative=n=>e.check(Aa(BigInt(0),n)),e.multipleOf=(n,o)=>e.check(bx(n,o));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});YV=j("ZodBigIntFormat",(e,t)=>{kfe.init(e,t),rR.init(e,t)});ihe=j("ZodSymbol",(e,t)=>{vfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ime(e,r,n,o)});she=j("ZodUndefined",(e,t)=>{Rfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ame(e,r,n,o)});ahe=j("ZodNull",(e,t)=>{_fe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sme(e,r,n,o)});uhe=j("ZodAny",(e,t)=>{Bfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lme(e,r,n,o)});lhe=j("ZodUnknown",(e,t)=>{Tfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dme(e,r,n,o)});dhe=j("ZodNever",(e,t)=>{Dfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ume(e,r,n,o)});fhe=j("ZodVoid",(e,t)=>{Qfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cme(e,r,n,o)});iP=j("ZodDate",(e,t)=>{Ofe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,o,i)=>fme(e,n,o,i),e.min=(n,o)=>e.check(Aa(n,o)),e.max=(n,o)=>e.check(eu(n,o));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});phe=j("ZodArray",(e,t)=>{Nfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wme(e,r,n,o),e.element=t.element,nP(e,"ZodArray",{min(r,n){return this.check(lg(r,n))},nonempty(r){return this.check(lg(1,r))},max(r,n){return this.check(gC(r,n))},length(r,n){return this.check(AC(r,n))},unwrap(){return this.element}})});aP=j("ZodObject",(e,t)=>{Pfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ime(e,r,n,o),fe.defineLazy(e,"shape",()=>t.shape),nP(e,"ZodObject",{keyof(){return ZV(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:yC()})},loose(){return this.clone({...this._zod.def,catchall:yC()})},strict(){return this.clone({...this._zod.def,catchall:JV()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return fe.extend(this,r)},safeExtend(r){return fe.safeExtend(this,r)},merge(r){return fe.merge(this,r)},pick(r){return fe.pick(this,r)},omit(r){return fe.omit(this,r)},partial(...r){return fe.partial(e4,this,r[0])},required(...r){return fe.required(t4,this,r[0])}})});cP=j("ZodUnion",(e,t)=>{$N.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>EV(e,r,n,o),e.options=t.options});mhe=j("ZodXor",(e,t)=>{cP.init(e,t),Mfe.init(e,t),e._zod.processJSONSchema=(r,n,o)=>EV(e,r,n,o),e.options=t.options});hhe=j("ZodDiscriminatedUnion",(e,t)=>{cP.init(e,t),Ffe.init(e,t)});ghe=j("ZodIntersection",(e,t)=>{Lfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>kme(e,r,n,o)});yhe=j("ZodTuple",(e,t)=>{Uz.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vme(e,r,n,o),e.rest=r=>e.clone({...e._zod.def,rest:r})});Jv=j("ZodRecord",(e,t)=>{Ufe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rme(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});bhe=j("ZodMap",(e,t)=>{$fe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sme(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Gp(...r)),e.nonempty=r=>e.check(Gp(1,r)),e.max=(...r)=>e.check(Sx(...r)),e.size=(...r)=>e.check(hC(...r))});She=j("ZodSet",(e,t)=>{Hfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Cme(e,r,n,o),e.min=(...r)=>e.check(Gp(...r)),e.nonempty=r=>e.check(Gp(1,r)),e.max=(...r)=>e.check(Sx(...r)),e.size=(...r)=>e.check(hC(...r))});Kv=j("ZodEnum",(e,t)=>{Wfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(n,o,i)=>pme(e,n,o,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let i={};for(let s of n)if(r.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Kv({...t,checks:[],...fe.normalizeParams(o),entries:i})},e.exclude=(n,o)=>{let i={...t.entries};for(let s of n)if(r.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Kv({...t,checks:[],...fe.normalizeParams(o),entries:i})}});Che=j("ZodLiteral",(e,t)=>{jfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mme(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});whe=j("ZodFile",(e,t)=>{qfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ame(e,r,n,o),e.min=(r,n)=>e.check(Gp(r,n)),e.max=(r,n)=>e.check(Sx(r,n)),e.mime=(r,n)=>e.check($v(Array.isArray(r)?r:[r],n))});Ihe=j("ZodTransform",(e,t)=>{Gfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bme(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new gx(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(fe.issue(i,r.value,t));else{let s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(fe.issue(s))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r.fallback=!0,r)):(r.value=o,r.fallback=!0,r)}});e4=j("ZodOptional",(e,t)=>{$z.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bV(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});khe=j("ZodExactOptional",(e,t)=>{zfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bV(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});Rhe=j("ZodNullable",(e,t)=>{Vfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_me(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});_he=j("ZodDefault",(e,t)=>{Yfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tme(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});The=j("ZodPrefault",(e,t)=>{Jfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Dme(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});t4=j("ZodNonOptional",(e,t)=>{Kfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bme(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});Ohe=j("ZodSuccess",(e,t)=>{Zfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yme(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});Nhe=j("ZodCatch",(e,t)=>{Xfe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qme(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});Mhe=j("ZodNaN",(e,t)=>{epe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hme(e,r,n,o)});uP=j("ZodPipe",(e,t)=>{Hz.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ome(e,r,n,o),e.in=t.in,e.out=t.out});lP=j("ZodCodec",(e,t)=>{uP.init(e,t),HN.init(e,t)});Fhe=j("ZodPreprocess",(e,t)=>{uP.init(e,t),tpe.init(e,t)}),Lhe=j("ZodReadonly",(e,t)=>{rpe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Nme(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});$he=j("ZodTemplateLiteral",(e,t)=>{npe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gme(e,r,n,o)});Hhe=j("ZodLazy",(e,t)=>{spe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mme(e,r,n,o),e.unwrap=()=>e._zod.def.getter()});jhe=j("ZodPromise",(e,t)=>{ipe.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pme(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});qhe=j("ZodFunction",(e,t)=>{ope.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Eme(e,r,n,o)});dP=j("ZodCustom",(e,t)=>{ape.init(e,t),Mt.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xme(e,r,n,o)});Hot=Kpe,Wot=Zpe;qot=(...e)=>Xpe({Codec:lP,Boolean:tR,String:Zv},...e)});function xir(e){Eo({customError:e})}function Eir(){return Eo().customError}var yir,Vhe,Vot=h(()=>{tu();yir={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};Vhe||(Vhe={})});function Sir(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Cir(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let n=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===n){let o=r[1];if(!o||!t.defs[o])throw new Error(`Reference not found: ${e}`);return t.defs[o]}throw new Error(`Reference not found: ${e}`)}function Yot(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return ke.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let o=e.$ref;if(t.refs.has(o))return t.refs.get(o);if(t.processing.has(o))return ke.lazy(()=>{if(!t.refs.has(o))throw new Error(`Circular reference not resolved: ${o}`);return t.refs.get(o)});t.processing.add(o);let i=Cir(o,t),s=Os(i,t);return t.refs.set(o,s),t.processing.delete(o),s}if(e.enum!==void 0){let o=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&o.length===1&&o[0]===null)return ke.null();if(o.length===0)return ke.never();if(o.length===1)return ke.literal(o[0]);if(o.every(s=>typeof s=="string"))return ke.enum(o);let i=o.map(s=>ke.literal(s));return i.length<2?i[0]:ke.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return ke.literal(e.const);let r=e.type;if(Array.isArray(r)){let o=r.map(i=>{let s={...e,type:i};return Yot(s,t)});return o.length===0?ke.never():o.length===1?o[0]:ke.union(o)}if(!r)return ke.any();let n;switch(r){case"string":{let o=ke.string();if(e.format){let i=e.format;i==="email"?o=o.check(ke.email()):i==="uri"||i==="uri-reference"?o=o.check(ke.url()):i==="uuid"||i==="guid"?o=o.check(ke.uuid()):i==="date-time"?o=o.check(ke.iso.datetime()):i==="date"?o=o.check(ke.iso.date()):i==="time"?o=o.check(ke.iso.time()):i==="duration"?o=o.check(ke.iso.duration()):i==="ipv4"?o=o.check(ke.ipv4()):i==="ipv6"?o=o.check(ke.ipv6()):i==="mac"?o=o.check(ke.mac()):i==="cidr"?o=o.check(ke.cidrv4()):i==="cidr-v6"?o=o.check(ke.cidrv6()):i==="base64"?o=o.check(ke.base64()):i==="base64url"?o=o.check(ke.base64url()):i==="e164"?o=o.check(ke.e164()):i==="jwt"?o=o.check(ke.jwt()):i==="emoji"?o=o.check(ke.emoji()):i==="nanoid"?o=o.check(ke.nanoid()):i==="cuid"?o=o.check(ke.cuid()):i==="cuid2"?o=o.check(ke.cuid2()):i==="ulid"?o=o.check(ke.ulid()):i==="xid"?o=o.check(ke.xid()):i==="ksuid"&&(o=o.check(ke.ksuid()))}typeof e.minLength=="number"&&(o=o.min(e.minLength)),typeof e.maxLength=="number"&&(o=o.max(e.maxLength)),e.pattern&&(o=o.regex(new RegExp(e.pattern))),n=o;break}case"number":case"integer":{let o=r==="integer"?ke.number().int():ke.number();typeof e.minimum=="number"&&(o=o.min(e.minimum)),typeof e.maximum=="number"&&(o=o.max(e.maximum)),typeof e.exclusiveMinimum=="number"?o=o.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(o=o.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?o=o.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(o=o.lt(e.maximum)),typeof e.multipleOf=="number"&&(o=o.multipleOf(e.multipleOf)),n=o;break}case"boolean":{n=ke.boolean();break}case"null":{n=ke.null();break}case"object":{let o={},i=e.properties||{},s=new Set(e.required||[]);for(let[c,u]of Object.entries(i)){let l=Os(u,t);o[c]=s.has(c)?l:l.optional()}if(e.propertyNames){let c=Os(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?Os(e.additionalProperties,t):ke.any();if(Object.keys(o).length===0){n=ke.record(c,u);break}let l=ke.object(o).passthrough(),d=ke.looseRecord(c,u);n=ke.intersection(l,d);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let f of u){let p=Os(c[f],t),m=ke.string().regex(new RegExp(f));l.push(ke.looseRecord(m,p))}let d=[];if(Object.keys(o).length>0&&d.push(ke.object(o).passthrough()),d.push(...l),d.length===0)n=ke.object({}).passthrough();else if(d.length===1)n=d[0];else{let f=ke.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=ke.intersection(f,d[p]);n=f}break}let a=ke.object(o);e.additionalProperties===!1?n=a.strict():typeof e.additionalProperties=="object"?n=a.catchall(Os(e.additionalProperties,t)):n=a.passthrough();break}case"array":{let o=e.prefixItems,i=e.items;if(o&&Array.isArray(o)){let s=o.map(c=>Os(c,t)),a=i&&typeof i=="object"&&!Array.isArray(i)?Os(i,t):void 0;a?n=ke.tuple(s).rest(a):n=ke.tuple(s),typeof e.minItems=="number"&&(n=n.check(ke.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(ke.maxLength(e.maxItems)))}else if(Array.isArray(i)){let s=i.map(c=>Os(c,t)),a=e.additionalItems&&typeof e.additionalItems=="object"?Os(e.additionalItems,t):void 0;a?n=ke.tuple(s).rest(a):n=ke.tuple(s),typeof e.minItems=="number"&&(n=n.check(ke.minLength(e.minItems))),typeof e.maxItems=="number"&&(n=n.check(ke.maxLength(e.maxItems)))}else if(i!==void 0){let s=Os(i,t),a=ke.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),n=a}else n=ke.array(ke.any());break}default:throw new Error(`Unsupported type: ${r}`)}return n}function Os(e,t){if(typeof e=="boolean")return e?ke.any():ke.never();let r=Yot(e,t),n=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(u=>Os(u,t)),c=ke.union(a);r=n?ke.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(u=>Os(u,t)),c=ke.xor(a);r=n?ke.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=n?r:ke.any();else{let a=n?r:Os(e.allOf[0],t),c=n?0:1;for(let u=c;u<e.allOf.length;u++)a=ke.intersection(a,Os(e.allOf[u],t));r=a}e.nullable===!0&&t.version==="openapi-3.0"&&(r=ke.nullable(r)),e.readOnly===!0&&(r=ke.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let o={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of i)a in e&&(o[a]=e[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in e&&(o[a]=e[a]);for(let a of Object.keys(e))bir.has(a)||(o[a]=e[a]);return Object.keys(o).length>0&&t.registry.add(r,o),e.description&&(r=r.describe(e.description)),r}function Jot(e,t){if(typeof e=="boolean")return e?ke.any():ke.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let n=Sir(r,t?.defaultTarget),o=r.$defs||r.definitions||{},i={version:n,defs:o,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??ls};return Os(r,i)}var ke,bir,Kot=h(()=>{qN();IV();JN();ZN();ke={...KN,...wV,iso:Yv},bir=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"])});var Yhe={};tr(Yhe,{bigint:()=>vir,boolean:()=>kir,date:()=>Rir,number:()=>Iir,string:()=>wir});function wir(e){return gpe(Zv,e)}function Iir(e){return wpe(eR,e)}function kir(e){return Tpe(tR,e)}function vir(e){return Qpe(rR,e)}function Rir(e){return jpe(iP,e)}var Zot=h(()=>{tu();ZN()});var Jd={};tr(Jd,{$brand:()=>Fle,$input:()=>mpe,$output:()=>ppe,NEVER:()=>Mle,TimePrecision:()=>ype,ZodAny:()=>uhe,ZodArray:()=>phe,ZodBase64:()=>qV,ZodBase64URL:()=>GV,ZodBigInt:()=>rR,ZodBigIntFormat:()=>YV,ZodBoolean:()=>tR,ZodCIDRv4:()=>WV,ZodCIDRv6:()=>jV,ZodCUID:()=>PV,ZodCUID2:()=>MV,ZodCatch:()=>Nhe,ZodCodec:()=>lP,ZodCustom:()=>dP,ZodCustomStringFormat:()=>Xv,ZodDate:()=>iP,ZodDefault:()=>_he,ZodDiscriminatedUnion:()=>hhe,ZodE164:()=>zV,ZodEmail:()=>QV,ZodEmoji:()=>OV,ZodEnum:()=>Kv,ZodError:()=>gir,ZodExactOptional:()=>khe,ZodFile:()=>whe,ZodFirstPartyTypeKind:()=>Vhe,ZodFunction:()=>qhe,ZodGUID:()=>eP,ZodIPv4:()=>$V,ZodIPv6:()=>HV,ZodISODate:()=>vV,ZodISODateTime:()=>kV,ZodISODuration:()=>_V,ZodISOTime:()=>RV,ZodIntersection:()=>ghe,ZodIssueCode:()=>yir,ZodJWT:()=>VV,ZodKSUID:()=>UV,ZodLazy:()=>Hhe,ZodLiteral:()=>Che,ZodMAC:()=>rhe,ZodMap:()=>bhe,ZodNaN:()=>Mhe,ZodNanoID:()=>NV,ZodNever:()=>dhe,ZodNonOptional:()=>t4,ZodNull:()=>ahe,ZodNullable:()=>Rhe,ZodNumber:()=>eR,ZodNumberFormat:()=>xC,ZodObject:()=>aP,ZodOptional:()=>e4,ZodPipe:()=>uP,ZodPrefault:()=>The,ZodPreprocess:()=>Fhe,ZodPromise:()=>jhe,ZodReadonly:()=>Lhe,ZodRealError:()=>oc,ZodRecord:()=>Jv,ZodSet:()=>She,ZodString:()=>Zv,ZodStringFormat:()=>cn,ZodSuccess:()=>Ohe,ZodSymbol:()=>ihe,ZodTemplateLiteral:()=>$he,ZodTransform:()=>Ihe,ZodTuple:()=>yhe,ZodType:()=>Mt,ZodULID:()=>FV,ZodURL:()=>oP,ZodUUID:()=>zp,ZodUndefined:()=>she,ZodUnion:()=>cP,ZodUnknown:()=>lhe,ZodVoid:()=>fhe,ZodXID:()=>LV,ZodXor:()=>mhe,_ZodString:()=>DV,_default:()=>Bhe,_function:()=>Lot,any:()=>got,array:()=>sP,base64:()=>Xnt,base64url:()=>eot,bigint:()=>dot,boolean:()=>ohe,catch:()=>Phe,check:()=>Uot,cidrv4:()=>Knt,cidrv6:()=>Znt,clone:()=>ha,codec:()=>Not,coerce:()=>Yhe,config:()=>Eo,core:()=>dg,cuid:()=>Wnt,cuid2:()=>jnt,custom:()=>$ot,date:()=>yot,decode:()=>Vme,decodeAsync:()=>Jme,describe:()=>Hot,discriminatedUnion:()=>wot,e164:()=>tot,email:()=>Qnt,emoji:()=>$nt,encode:()=>zme,encodeAsync:()=>Yme,endsWith:()=>Uv,enum:()=>ZV,exactOptional:()=>vhe,file:()=>Tot,flattenError:()=>NN,float32:()=>aot,float64:()=>cot,formatError:()=>PN,fromJSONSchema:()=>Jot,function:()=>Lot,getErrorMap:()=>Eir,globalRegistry:()=>ls,gt:()=>qp,gte:()=>Aa,guid:()=>Ont,hash:()=>sot,hex:()=>iot,hostname:()=>oot,httpUrl:()=>Unt,includes:()=>Fv,instanceof:()=>jot,int:()=>BV,int32:()=>uot,int64:()=>fot,intersection:()=>Ahe,invertCodec:()=>Pot,ipv4:()=>Vnt,ipv6:()=>Jnt,iso:()=>Yv,json:()=>Got,jwt:()=>rot,keyof:()=>xot,ksuid:()=>znt,lazy:()=>Whe,length:()=>AC,literal:()=>Bot,locales:()=>jN,looseObject:()=>Sot,looseRecord:()=>kot,lowercase:()=>Pv,lt:()=>jp,lte:()=>eu,mac:()=>Ynt,map:()=>vot,maxLength:()=>gC,maxSize:()=>Sx,meta:()=>Wot,mime:()=>$v,minLength:()=>lg,minSize:()=>Gp,multipleOf:()=>bx,nan:()=>Oot,nanoid:()=>Hnt,nativeEnum:()=>_ot,negative:()=>hV,never:()=>JV,nonnegative:()=>AV,nonoptional:()=>Qhe,nonpositive:()=>gV,normalize:()=>Hv,null:()=>che,nullable:()=>rP,nullish:()=>Dot,number:()=>nhe,object:()=>Eot,optional:()=>tP,overwrite:()=>Yd,parse:()=>Wme,parseAsync:()=>jme,partialRecord:()=>Iot,pipe:()=>TV,positive:()=>mV,prefault:()=>Dhe,preprocess:()=>zot,prettifyError:()=>Kle,promise:()=>Fot,property:()=>yV,readonly:()=>Uhe,record:()=>Ehe,refine:()=>Ghe,regex:()=>Nv,regexes:()=>Xc,registry:()=>zz,safeDecode:()=>Zme,safeDecodeAsync:()=>ehe,safeEncode:()=>Kme,safeEncodeAsync:()=>Xme,safeParse:()=>qme,safeParseAsync:()=>Gme,set:()=>Rot,setErrorMap:()=>xir,size:()=>hC,slugify:()=>Gv,startsWith:()=>Lv,strictObject:()=>bot,string:()=>XN,stringFormat:()=>not,stringbool:()=>qot,success:()=>Qot,superRefine:()=>zhe,symbol:()=>mot,templateLiteral:()=>Mot,toJSONSchema:()=>SV,toLowerCase:()=>jv,toUpperCase:()=>qv,transform:()=>XV,treeifyError:()=>Jle,trim:()=>Wv,tuple:()=>xhe,uint32:()=>lot,uint64:()=>pot,ulid:()=>qnt,undefined:()=>hot,union:()=>KV,unknown:()=>yC,uppercase:()=>Mv,url:()=>Lnt,util:()=>fe,uuid:()=>Nnt,uuidv4:()=>Pnt,uuidv6:()=>Mnt,uuidv7:()=>Fnt,void:()=>Aot,xid:()=>Gnt,xor:()=>Cot});var Jhe=h(()=>{tu();ZN();IV();Hme();the();Vot();tu();upe();tu();YN();Kot();fpe();JN();JN();Zot();Eo(Wz())});var Xot=h(()=>{Jhe();Jhe()});function n4(e){let t=_ir(e,kx);if(t===void 0)return{ok:!1,reason:"missing"};let r;try{r=JSON.parse(Bir(t.trim()))}catch(o){return{ok:!1,reason:"invalid-json",detail:o instanceof Error?o.message:String(o)}}let n=r4.safeParse(r);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:"schema",detail:n.error.message}}function _ir(e,t){let r=`<${t}>`,n=`</${t}>`,o,i=0;for(;;){let s=e.indexOf(r,i);if(s===-1)break;let a=s+r.length,c=e.indexOf(n,a);if(c===-1)break;o=e.slice(a,c),i=c+n.length}return o}function Bir(e){let t=e.match(/^```(?:json)?\s*\n([\s\S]*?)\n\s*```\s*$/);return t?t[1].trim():e}var kx,r4,eit,tit=h(()=>{"use strict";Xot();mN();kx="agent-output",r4=Jd.object({success:Jd.boolean(),summary:Jd.string(),key_changes_made:Jd.array(Jd.string()),key_learnings:Jd.array(Jd.string()),should_fully_stop:Jd.boolean()}),eit=Wp.object({tag:kx,schema:r4})});var rit,nit=h(()=>{"use strict";oC();rit=nC});import{appendFile as Tir,mkdir as Dir,readFile as Qir}from"node:fs/promises";import{dirname as Oir}from"node:path";function fg(e){let t=[];for(let r of e.split(`
386
388
  `)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);typeof o.at=="number"&&typeof o.kind=="string"&&t.push({at:o.at,kind:o.kind})}catch{}}return t}async function Khe(e){try{let t=await Qir(e,"utf-8");return fg(t)}catch(t){if(t.code==="ENOENT")return[];throw t}}async function oit(e){let t=await Khe(e);if(t.length!==0)return t.reduce((r,n)=>n.at>r?n.at:r,t[0].at)}function iit(e){let{lane:t,onAgentStreamEvent:r}=e;return{iterationStart:()=>t.record("iteration-start"),iterationEnd:()=>t.record("iteration-end"),toolStart:()=>t.record("tool-start"),toolEnd:()=>t.record("tool-end"),observeAgentStreamEvent:n=>{if(r)try{r(n)}catch{}}}}var Vp,o4,sit=h(()=>{"use strict";Vp="liveness.lane.jsonl",o4=class{path;clock;ensuredDir=!1;constructor(t){this.path=t.path,this.clock=t.clock??(()=>Date.now())}async record(t){let r={at:this.clock(),kind:t};return this.ensuredDir||(await Dir(Oir(this.path),{recursive:!0}),this.ensuredDir=!0),await Tir(this.path,JSON.stringify(r)+`
387
389
  `),r}}});import{execFileSync as Nir}from"node:child_process";function vx(e){return{crossCheckArmed:e.sandboxTag==="none"}}function Rx(e){let{laneRecencyMs:t,now:r,laneIdleMs:n,crossCheckArmed:o}=e,i=t===void 0?void 0:Math.max(0,r-t);if(i!==void 0&&i<=n)return{status:"alive",laneFresh:!0,laneAgeMs:i,crossCheckArmed:o,reason:`lane fresh (${i}ms <= ${n}ms idle threshold)`};let a=i===void 0?"lane empty":`lane idle (${i}ms > ${n}ms)`;return o?(e.hasLiveDescendants?e.hasLiveDescendants():!1)?{status:"alive",laneFresh:!1,laneAgeMs:i,crossCheckArmed:!0,liveDescendants:!0,reason:`${a} but live agent descendants (substrate may be wedged)`}:{status:"stalled",laneFresh:!1,laneAgeMs:i,crossCheckArmed:!0,liveDescendants:!1,reason:`${a} and no live agent descendants`}:{status:"unknown",laneFresh:!1,laneAgeMs:i,crossCheckArmed:!1,reason:`${a}; process cross-check disarmed under container isolation`}}function Zhe(e){let t=[];for(let r of e.split(`
388
- `)){let n=r.trim().split(/\s+/);if(n.length<2)continue;let o=Number(n[0]),i=Number(n[1]);Number.isInteger(o)&&Number.isInteger(i)&&t.push({pid:o,ppid:i})}return t}function Xhe(e,t){let r=new Map;for(let{pid:o,ppid:i}of t){let s=r.get(i);s?s.push(o):r.set(i,[o])}return[...r.get(e)??[]].length>0}function _x(e){let t=e.snapshot??Pir;return()=>{try{return Xhe(e.agentPid,Zhe(t()))}catch{return!1}}}var Pir,ait=h(()=>{"use strict";Pir=()=>Nir("ps",["-eo","pid=,ppid="],{encoding:"utf-8"})});import{mkdir as ege,readFile as EC,rm as fit,writeFile as i4,access as Mir}from"node:fs/promises";import{dirname as tge,join as nR,posix as pg}from"node:path";import{tmpdir as pit}from"node:os";function Lir(e){let t=Buffer.byteLength(e,"utf8");if(t>uit)throw new Error(`Cursor print-mode prompt is ${t} bytes (max ${uit} bytes). The Cursor CLI accepts the prompt only as a command-line argument; shorten the prompt or split the work. Other Sandcastle providers use stdin for large prompts.`)}function Jir(e){let t=Buffer.byteLength(e,"utf8");if(t>dit)throw new Error(`Copilot print-mode prompt is ${t} bytes (max ${dit} bytes). This provider passes the prompt as a command-line argument; shorten the prompt or split the work. Other Sandcastle providers use stdin for large prompts.`)}var cit,gi,mit,rge,s4,Fir,hit,uit,Uir,$ir,nge,oge,lit,Hir,Wir,jir,qir,git,Gir,zir,Ait,yit,Vir,Yir,xit,dit,Kir,Eit,Zir,bit,Sit,Cit=h(()=>{"use strict";Ple();cit=async e=>{try{return await Mir(e),!0}catch{return!1}},gi=e=>"'"+e.replace(/'/g,"'\\''")+"'",mit=(e,t)=>e&&e.length>0?`${e}
390
+ `)){let n=r.trim().split(/\s+/);if(n.length<2)continue;let o=Number(n[0]),i=Number(n[1]);Number.isInteger(o)&&Number.isInteger(i)&&t.push({pid:o,ppid:i})}return t}function Xhe(e,t){let r=new Map;for(let{pid:o,ppid:i}of t){let s=r.get(i);s?s.push(o):r.set(i,[o])}return[...r.get(e)??[]].length>0}function _x(e){let t=e.snapshot??Pir;return()=>{try{return Xhe(e.agentPid,Zhe(t()))}catch{return!1}}}var Pir,ait=h(()=>{"use strict";Pir=()=>Nir("ps",["-eo","pid=,ppid="],{encoding:"utf-8"})});import{mkdir as ege,readFile as EC,rm as fit,writeFile as i4,access as Mir}from"node:fs/promises";import{dirname as tge,join as nR,posix as pg}from"node:path";import{tmpdir as pit}from"node:os";function Lir(e){let t=Buffer.byteLength(e,"utf8");if(t>uit)throw new Error(`Cursor print-mode prompt is ${t} bytes (max ${uit} bytes). The Cursor CLI accepts the prompt only as a command-line argument; shorten the prompt or split the work. Other Sandcastle providers use stdin for large prompts.`)}function Jir(e){let t=Buffer.byteLength(e,"utf8");if(t>dit)throw new Error(`Copilot print-mode prompt is ${t} bytes (max ${dit} bytes). This provider passes the prompt as a command-line argument; shorten the prompt or split the work. Other Sandcastle providers use stdin for large prompts.`)}var cit,Ai,mit,rge,s4,Fir,hit,uit,Uir,$ir,nge,oge,lit,Hir,Wir,jir,qir,git,Gir,zir,Ait,yit,Vir,Yir,xit,dit,Kir,Eit,Zir,bit,Sit,Cit=h(()=>{"use strict";Ple();cit=async e=>{try{return await Mir(e),!0}catch{return!1}},Ai=e=>"'"+e.replace(/'/g,"'\\''")+"'",mit=(e,t)=>e&&e.length>0?`${e}
389
391
 
390
392
  ---
391
393
 
392
- ${t}`:t,rge={Bash:"command",WebSearch:"query",WebFetch:"url",Agent:"description"},s4=e=>{let t=e.error;if(typeof t=="string")return t;if(typeof t=="object"&&t!==null){if(typeof t.message=="string")return t.message;if(typeof t.data?.message=="string")return t.data.message}if(typeof e.message=="string")return e.message},Fir=e=>{let t=e.usage;if(!(typeof t!="object"||t===null)&&!(typeof t.input_tokens!="number"||typeof t.output_tokens!="number"))return{inputTokens:t.input_tokens,cacheCreationInputTokens:typeof t.cache_creation_input_tokens=="number"?t.cache_creation_input_tokens:0,cacheReadInputTokens:typeof t.cache_read_input_tokens=="number"?t.cache_read_input_tokens:0,outputTokens:t.output_tokens,...typeof e.total_cost_usd=="number"?{costUsd:e.total_cost_usd}:{}}},hit=e=>{if(!e.startsWith("{"))return[];try{let t=JSON.parse(e);if(t.type==="assistant"&&Array.isArray(t.message?.content)){let r=[],n=[];for(let o of t.message.content)if(o.type==="text"&&typeof o.text=="string")n.push(o.text);else if(o.type==="thinking"&&typeof o.thinking=="string")n.length>0&&(r.push({type:"text",text:n.join("")}),n.length=0),r.push({type:"reasoning",text:o.thinking});else if(o.type==="tool_use"&&typeof o.name=="string"&&o.input!==void 0){let i=rge[o.name];if(i===void 0)continue;let s=o.input[i];if(typeof s!="string")continue;n.length>0&&(r.push({type:"text",text:n.join("")}),n.length=0),r.push({type:"tool_call",name:o.name,args:s})}return n.length>0&&r.push({type:"text",text:n.join("")}),r}if(t.type==="result"&&typeof t.result=="string"){let r=Fir(t);return r?[{type:"result",result:t.result},{type:"usage",usage:r}]:[{type:"result",result:t.result}]}if(t.type==="system"&&t.subtype==="init"&&typeof t.session_id=="string")return[{type:"session_id",sessionId:t.session_id}]}catch{}return[]},uit=120*1024;Uir=e=>{if(e.type!=="tool_call"||e.subtype!=="started")return[];let t=e.tool_call;if(!t||typeof t!="object")return[];let r=t,n=r.readToolCall;if(n?.args&&typeof n.args.path=="string")return[{type:"tool_call",name:"Read",args:n.args.path}];let o=r.writeToolCall;if(o?.args&&typeof o.args.path=="string")return[{type:"tool_call",name:"Write",args:o.args.path}];let i=r.function;if(i&&typeof i.name=="string"){let s=typeof i.arguments=="string"?i.arguments:"";if(s){try{let a=JSON.parse(s);if(typeof a.command=="string")return[{type:"tool_call",name:"Bash",args:a.command}]}catch{}return[{type:"tool_call",name:i.name,args:s}]}return[{type:"tool_call",name:i.name,args:""}]}return[]},$ir=e=>{if(!e.startsWith("{"))return[];let t;try{t=JSON.parse(e)}catch{return[]}return t.type==="tool_call"?Uir(t):hit(e)},nge=async(e,t,r)=>{let n=nR(pit(),`sandcastle-${r}-${Date.now()}-${Math.random().toString(36).slice(2)}.jsonl`);await e.copyFileOut(t,n);try{return await EC(n,"utf-8")}finally{await fit(n,{force:!0}).catch(()=>{})}},oge=async(e,t,r,n)=>{let o=nR(pit(),`sandcastle-${n}-${Date.now()}-${Math.random().toString(36).slice(2)}.jsonl`);await i4(o,r);try{await e.exec(`mkdir -p ${JSON.stringify(pg.dirname(t))}`),await e.copyFileIn(o,t)}finally{await fit(o,{force:!0}).catch(()=>{})}},lit=async({handle:e,sourcePath:t,fromCwd:r,toCwd:n,destPath:o,tag:i})=>{let s=await nge(e,t,i),a=kN(s,r,n);await ege(tge(o),{recursive:!0}),await i4(o,a)},Hir=e=>{let t=e?.sessionStorage?.hostProjectsDir,r=e?.sessionStorage?.sandboxProjectsDir??"/home/agent/.claude/projects";return{hostSessionFilePath:(n,o)=>hx(n,o,t),existsOnHost:(n,o)=>cit(hx(n,o,t)),readHostSession:async(n,o)=>{let i=hx(n,o,t);if(await cit(i))return EC(i,"utf-8")},captureToHost:async({hostCwd:n,sandboxCwd:o,sessionId:i,handle:s})=>{let a=await Get(i,s,r);await lit({handle:s,sourcePath:a,fromCwd:o,toCwd:n,destPath:hx(n,i,t),tag:"claude-cap"});let c=await qet(pg.join(pg.dirname(a),i,"subagents"),s),u=jet(n,i,t);for(let l of c)try{await lit({handle:s,sourcePath:l,fromCwd:o,toCwd:n,destPath:nR(u,pg.basename(l)),tag:"claude-sub"})}catch(d){console.error(`sandcastle: failed to capture Claude subagent transcript ${l}: ${d instanceof Error?d.message:String(d)}`)}},resumeIntoSandbox:async({hostCwd:n,sandboxCwd:o,sessionId:i,handle:s})=>{let a=hx(n,i,t),c=await EC(a,"utf-8"),u=kN(c,n,o),l=pz(o,i,r);await oge(s,l,u,"claude-res")},findByIdOnHost:n=>mz(n,t)}},Wir=e=>{let t=e?.sessionStorage?.hostSessionsDir,r=e?.sessionStorage?.sandboxSessionsDir??pg.join("/home/agent",".codex","sessions"),n=new Map;return{hostSessionFilePath:(o,i)=>n.get(i),existsOnHost:async(o,i)=>(await Iv(i,t)).path!==void 0,readHostSession:async(o,i)=>{let s=await Iv(i,t);if(s.path)return EC(s.path,"utf-8")},captureToHost:async({hostCwd:o,sandboxCwd:i,sessionId:s,handle:a})=>{let c=await Jet(s,a,r),u=await nge(a,c.path,"codex-cap"),l=vN(u,i,o),d=t??nR(process.env.HOME??"~",".codex","sessions"),f=nR(d,c.relativePath);await ege(tge(f),{recursive:!0}),await i4(f,l),n.set(s,f)},resumeIntoSandbox:async({hostCwd:o,sandboxCwd:i,sessionId:s,handle:a})=>{let c=await Yet(s,t),u=await EC(c.path,"utf-8"),l=vN(u,o,i),d=pg.join(r,c.relativePath);await oge(a,d,l,"codex-res")},findByIdOnHost:o=>Iv(o,t)}},jir=e=>{let t=e?.sessionStorage?.hostSessionsDir,r=e?.sessionStorage?.sandboxSessionsDir??pg.join("/home/agent",".pi","agent","sessions");return{hostSessionFilePath:(n,o)=>Ole(n,t),existsOnHost:async(n,o)=>(await hz(o,t)).path!==void 0,readHostSession:async(n,o)=>{let i=await hz(o,t);if(i.path)return EC(i.path,"utf-8")},captureToHost:async({hostCwd:n,sandboxCwd:o,sessionId:i,handle:s})=>{let a=await Xet(i,s,r),c=await nge(s,a.path,"pi-cap"),u=Nle(c,o,n),l=pg.basename(a.path),d=nR(Ole(n,t),l);await ege(tge(d),{recursive:!0}),await i4(d,u)},resumeIntoSandbox:async({hostCwd:n,sandboxCwd:o,sessionId:i,handle:s})=>{let a=await Zet(i,t),c=await EC(a.path,"utf-8"),u=Nle(c,n,o),l=a.relativePath.split(/[\\/]/).pop(),d=pg.join(r,Qle(o),l);await oge(s,d,u,"pi-res")},findByIdOnHost:n=>hz(n,t)}},qir=e=>{if(!e.startsWith("{"))return[];try{let t=JSON.parse(e);if(t.type==="session"&&typeof t.id=="string")return[{type:"session_id",sessionId:t.id}];if(t.type==="message_update"&&t.assistantMessageEvent){let r=t.assistantMessageEvent;return r.type==="text_delta"&&typeof r.delta=="string"?[{type:"text",text:r.delta}]:[]}if(t.type==="tool_execution_start"){let r=t.toolName;if(typeof r!="string")return[];let n=rge[r];if(n===void 0)return[];let o=t.args;if(!o)return[];let i=o[n];return typeof i!="string"?[]:[{type:"tool_call",name:r,args:i}]}if(t.type==="agent_error"||t.type==="error"){let r=s4(t);return r?[{type:"result",result:r}]:[]}if(t.type==="agent_end"&&Array.isArray(t.messages)){let r=t.messages;for(let n=r.length-1;n>=0;n--){let o=r[n];if(o?.role==="assistant"){let i=[];for(let s of o.content)s.type==="text"&&typeof s.text=="string"&&i.push(s.text);if(i.length>0)return[{type:"result",result:i.join("")}];break}}return[]}}catch{}return[]},git=(e,t)=>({name:"pi",env:t?.env??{},captureSessions:t?.captureSessions??!0,sessionStorage:jir(t),buildPrintCommand({prompt:r,resumeSession:n}){let o=t?.thinking?` --thinking ${t.thinking}`:"",i=n?` --session ${gi(n)}`:"";return{command:`pi -p --mode json --model ${gi(e)}${o}${i}`,stdin:r}},buildInteractiveArgs({prompt:r}){let n=["pi","--model",e];return r&&n.push(r),n},parseStreamLine(r){return qir(r)}}),Gir=e=>{if(typeof e!="object"||e===null)return;let t=e;if(typeof t.input_tokens!="number"||typeof t.cached_input_tokens!="number"||typeof t.output_tokens!="number")return;let r=typeof t.reasoning_output_tokens=="number"?t.reasoning_output_tokens:void 0;return{inputTokens:t.input_tokens-t.cached_input_tokens,cacheCreationInputTokens:0,cacheReadInputTokens:t.cached_input_tokens,outputTokens:t.output_tokens,...r!==void 0?{reasoningTokens:r}:{}}},zir=e=>{if(!e.startsWith("{"))return[];try{let t=JSON.parse(e);if(t.type==="thread.started"&&typeof t.thread_id=="string")return[{type:"session_id",sessionId:t.thread_id}];if(t.type==="item.completed"&&t.item?.type==="agent_message"&&typeof t.item.text=="string"){let r=t.item.text;return[{type:"text",text:r},{type:"result",result:r}]}if(t.type==="item.started"&&t.item?.type==="command_execution"&&typeof t.item.command=="string")return[{type:"tool_call",name:"Bash",args:t.item.command}];if(t.type==="error"){let r=s4(t);return r?[{type:"result",result:r}]:[]}if(t.type==="turn.completed"){let r=Gir(t.usage),n=r?[{type:"usage",usage:r}]:[],o=t.usage?.reasoning_output_tokens;return typeof o=="number"&&o>0&&n.push({type:"reasoning",tokens:o}),n}}catch{}return[]},Ait=(e,t)=>({name:"codex",env:t?.env??{},captureSessions:t?.captureSessions??!0,sessionStorage:Wir(t),buildPrintCommand({prompt:r,resumeSession:n,forkSession:o,systemPrompt:i}){let s=t?.effort?` -c ${gi(`model_reasoning_effort="${t.effort}"`)}`:"",a=t?.approvalsReviewer==="auto_review"?` -a on-request -s danger-full-access -c ${gi('approvals_reviewer="auto_review"')}`:" --dangerously-bypass-approvals-and-sandbox",c;n&&o?c=`codex exec fork ${gi(n)}`:n?c=`codex exec resume ${gi(n)}`:c="codex exec";let u=n?" -":"";return{command:`${c} --json${a} -m ${gi(e)}${s}${u}`,stdin:mit(i,r)}},buildInteractiveArgs({prompt:r}){let n=["codex","--model",e];return r&&n.push(r),n},parseStreamLine(r){return zir(r)}}),yit=(e,t)=>({name:"cursor",env:t?.env??{},captureSessions:!1,buildPrintCommand({prompt:r,dangerouslySkipPermissions:n}){Lir(r);let o=n?" --force":"";return{command:`agent --print --output-format stream-json --model ${gi(e)} ${o} ${gi(r)}`}},buildInteractiveArgs({prompt:r,dangerouslySkipPermissions:n}){let o=["agent","--model",e];return n&&o.push("--force"),r&&o.push(r),o},parseStreamLine(r){return $ir(r)}}),Vir={bash:"command",webfetch:"url",task:"description"},Yir=e=>{if(!e.startsWith("{"))return[];try{let t=JSON.parse(e),r=t.part;if(t.type==="step_start"&&typeof t.sessionID=="string")return[{type:"session_id",sessionId:t.sessionID}];if(t.type==="text"&&r?.type==="text"&&typeof r.text=="string")return[{type:"text",text:r.text},{type:"result",result:r.text}];if(t.type==="tool_use"&&r?.type==="tool"){if(typeof r.tool!="string")return[];let n=r.state;if(n?.status!=="completed")return[];let o=n.input;if(!o)return[];let i=Vir[r.tool],s=i!==void 0?o[i]:void 0,a=typeof s=="string"?s:JSON.stringify(o);return[{type:"tool_call",name:r.tool,args:a}]}if(t.type==="error"){let n=s4(t);return n?[{type:"result",result:n}]:[]}if(t.type==="step_finish"&&r?.type==="step-finish"){let n=r.tokens,o=a=>typeof a=="number"?a:0,i=n?.reasoning,s=[];return typeof i=="number"&&i>0&&s.push({type:"reasoning",tokens:i}),n&&(typeof n.input=="number"||typeof n.output=="number")&&s.push({type:"usage",usage:{inputTokens:o(n.input),cacheCreationInputTokens:o(n.cache?.write),cacheReadInputTokens:o(n.cache?.read),outputTokens:o(n.output),...typeof i=="number"?{reasoningTokens:i}:{}}}),s}}catch{}return[]},xit=(e,t)=>({name:"opencode",env:t?.env??{},captureSessions:!1,buildPrintCommand({prompt:r,dangerouslySkipPermissions:n,systemPrompt:o}){let i=t?.variant?` --variant ${gi(t.variant)}`:"",s=t?.agent?` --agent ${gi(t.agent)}`:"",a=n?" --dangerously-skip-permissions":"";return{command:`opencode run --format json --model ${gi(e)}${i}${s}${a} ${gi(mit(o,r))}`}},buildInteractiveArgs({prompt:r}){let n=["opencode","--model",e];return t?.agent&&n.push("--agent",t.agent),r&&n.push("--prompt",r),n},parseStreamLine(r){return Yir(r)}}),dit=120*1024;Kir=e=>{if(!e.startsWith("{"))return[];try{let t=JSON.parse(e);if(t.type==="assistant.message_delta"&&typeof t.data?.deltaContent=="string")return[{type:"text",text:t.data.deltaContent}];if(t.type==="tool.execution_start"){let r=t.data?.toolName;if(typeof r!="string")return[];let n=r==="bash"?"Bash":r,o=rge[n];if(o===void 0)return[];let i=t.data?.arguments;if(!i)return[];let s=i[o];return typeof s!="string"?[]:[{type:"tool_call",name:n,args:s}]}if(t.type==="assistant.message"&&typeof t.data?.content=="string"&&t.data.content.length>0)return[{type:"result",result:t.data.content}];if(t.type==="result"&&typeof t.sessionId=="string")return[{type:"session_id",sessionId:t.sessionId}];if(t.type==="error"||t.type==="agent_error"){let r=s4(t);return r?[{type:"result",result:r}]:[]}}catch{}return[]},Eit=(e,t)=>({name:"copilot",env:t?.env??{},captureSessions:!1,buildPrintCommand({prompt:r,dangerouslySkipPermissions:n}){Jir(r);let o=n?" --allow-all-tools":"",i=t?.effort?` --effort ${t.effort}`:"";return{command:`copilot -p ${gi(r)} --output-format json --model ${gi(e)}${o}${i}`}},buildInteractiveArgs({prompt:r}){let n=["copilot","--model",e];return r&&n.push("-i",r),n},parseStreamLine(r){return Kir(r)}}),Zir=e=>e.trim()?e.startsWith("[log] ")?[{type:"tool_call",name:"log",args:e.slice(6)}]:[{type:"text",text:e}]:[],bit=(e,t)=>({name:"devin",env:t?.env??{},captureSessions:!1,buildPrintCommand({prompt:r,dangerouslySkipPermissions:n}){let o=n?" --permission-mode dangerous":"";return{command:`mkdir -p ~/.local/share/devin && printf 'windsurf_api_key = "%s"\\napi_server_url = "https://server.codeium.com"\\ndevin_webapp_host = "app.devin.ai"\\ndevin_api_url = "https://api.devin.ai"\\n' "$DEVIN_SESSION_TOKEN" > ~/.local/share/devin/credentials.toml && PROMPT_FILE=$(mktemp) && trap 'rm -f "$PROMPT_FILE"' EXIT && cat > "$PROMPT_FILE" && devin-wrapper -p --prompt-file "$PROMPT_FILE" --model ${gi(e)}${o}`,stdin:r}},buildInteractiveArgs({prompt:r}){let n=["devin","--model",e];return r&&n.push("--",r),n},parseStreamLine(r){return Zir(r)}}),Sit=(e,t)=>({name:"claude-code",env:t?.env??{},captureSessions:t?.captureSessions??!0,sessionStorage:Hir(t),buildPrintCommand({prompt:r,dangerouslySkipPermissions:n,resumeSession:o,forkSession:i,systemPrompt:s}){let a=t?.permissionMode?` --permission-mode ${t.permissionMode}`:n?" --dangerously-skip-permissions":"",c=t?.effort?` --effort ${t.effort}`:"",u=s?` --append-system-prompt ${gi(s)}`:"",l=o?` --resume ${gi(o)}`:"",d=o&&i?" --fork-session":"";return{command:`claude --print --verbose${a} --output-format stream-json --model ${gi(e)}${c}${u}${l}${d} -p -`,stdin:r}},buildInteractiveArgs({prompt:r,dangerouslySkipPermissions:n}){let o=["claude"];return t?.permissionMode?o.push("--permission-mode",t.permissionMode):n&&o.push("--dangerously-skip-permissions"),o.push("--model",e),t?.effort&&o.push("--effort",t.effort),r&&o.push(r),o},parseStreamLine(r){return hit(r)},parseSessionUsage(r){let n=r.split(`
394
+ ${t}`:t,rge={Bash:"command",WebSearch:"query",WebFetch:"url",Agent:"description"},s4=e=>{let t=e.error;if(typeof t=="string")return t;if(typeof t=="object"&&t!==null){if(typeof t.message=="string")return t.message;if(typeof t.data?.message=="string")return t.data.message}if(typeof e.message=="string")return e.message},Fir=e=>{let t=e.usage;if(!(typeof t!="object"||t===null)&&!(typeof t.input_tokens!="number"||typeof t.output_tokens!="number"))return{inputTokens:t.input_tokens,cacheCreationInputTokens:typeof t.cache_creation_input_tokens=="number"?t.cache_creation_input_tokens:0,cacheReadInputTokens:typeof t.cache_read_input_tokens=="number"?t.cache_read_input_tokens:0,outputTokens:t.output_tokens,...typeof e.total_cost_usd=="number"?{costUsd:e.total_cost_usd}:{}}},hit=e=>{if(!e.startsWith("{"))return[];try{let t=JSON.parse(e);if(t.type==="assistant"&&Array.isArray(t.message?.content)){let r=[],n=[];for(let o of t.message.content)if(o.type==="text"&&typeof o.text=="string")n.push(o.text);else if(o.type==="thinking"&&typeof o.thinking=="string")n.length>0&&(r.push({type:"text",text:n.join("")}),n.length=0),r.push({type:"reasoning",text:o.thinking});else if(o.type==="tool_use"&&typeof o.name=="string"&&o.input!==void 0){let i=rge[o.name];if(i===void 0)continue;let s=o.input[i];if(typeof s!="string")continue;n.length>0&&(r.push({type:"text",text:n.join("")}),n.length=0),r.push({type:"tool_call",name:o.name,args:s})}return n.length>0&&r.push({type:"text",text:n.join("")}),r}if(t.type==="result"&&typeof t.result=="string"){let r=Fir(t);return r?[{type:"result",result:t.result},{type:"usage",usage:r}]:[{type:"result",result:t.result}]}if(t.type==="system"&&t.subtype==="init"&&typeof t.session_id=="string")return[{type:"session_id",sessionId:t.session_id}]}catch{}return[]},uit=120*1024;Uir=e=>{if(e.type!=="tool_call"||e.subtype!=="started")return[];let t=e.tool_call;if(!t||typeof t!="object")return[];let r=t,n=r.readToolCall;if(n?.args&&typeof n.args.path=="string")return[{type:"tool_call",name:"Read",args:n.args.path}];let o=r.writeToolCall;if(o?.args&&typeof o.args.path=="string")return[{type:"tool_call",name:"Write",args:o.args.path}];let i=r.function;if(i&&typeof i.name=="string"){let s=typeof i.arguments=="string"?i.arguments:"";if(s){try{let a=JSON.parse(s);if(typeof a.command=="string")return[{type:"tool_call",name:"Bash",args:a.command}]}catch{}return[{type:"tool_call",name:i.name,args:s}]}return[{type:"tool_call",name:i.name,args:""}]}return[]},$ir=e=>{if(!e.startsWith("{"))return[];let t;try{t=JSON.parse(e)}catch{return[]}return t.type==="tool_call"?Uir(t):hit(e)},nge=async(e,t,r)=>{let n=nR(pit(),`sandcastle-${r}-${Date.now()}-${Math.random().toString(36).slice(2)}.jsonl`);await e.copyFileOut(t,n);try{return await EC(n,"utf-8")}finally{await fit(n,{force:!0}).catch(()=>{})}},oge=async(e,t,r,n)=>{let o=nR(pit(),`sandcastle-${n}-${Date.now()}-${Math.random().toString(36).slice(2)}.jsonl`);await i4(o,r);try{await e.exec(`mkdir -p ${JSON.stringify(pg.dirname(t))}`),await e.copyFileIn(o,t)}finally{await fit(o,{force:!0}).catch(()=>{})}},lit=async({handle:e,sourcePath:t,fromCwd:r,toCwd:n,destPath:o,tag:i})=>{let s=await nge(e,t,i),a=kN(s,r,n);await ege(tge(o),{recursive:!0}),await i4(o,a)},Hir=e=>{let t=e?.sessionStorage?.hostProjectsDir,r=e?.sessionStorage?.sandboxProjectsDir??"/home/agent/.claude/projects";return{hostSessionFilePath:(n,o)=>hx(n,o,t),existsOnHost:(n,o)=>cit(hx(n,o,t)),readHostSession:async(n,o)=>{let i=hx(n,o,t);if(await cit(i))return EC(i,"utf-8")},captureToHost:async({hostCwd:n,sandboxCwd:o,sessionId:i,handle:s})=>{let a=await Get(i,s,r);await lit({handle:s,sourcePath:a,fromCwd:o,toCwd:n,destPath:hx(n,i,t),tag:"claude-cap"});let c=await qet(pg.join(pg.dirname(a),i,"subagents"),s),u=jet(n,i,t);for(let l of c)try{await lit({handle:s,sourcePath:l,fromCwd:o,toCwd:n,destPath:nR(u,pg.basename(l)),tag:"claude-sub"})}catch(d){console.error(`sandcastle: failed to capture Claude subagent transcript ${l}: ${d instanceof Error?d.message:String(d)}`)}},resumeIntoSandbox:async({hostCwd:n,sandboxCwd:o,sessionId:i,handle:s})=>{let a=hx(n,i,t),c=await EC(a,"utf-8"),u=kN(c,n,o),l=pz(o,i,r);await oge(s,l,u,"claude-res")},findByIdOnHost:n=>mz(n,t)}},Wir=e=>{let t=e?.sessionStorage?.hostSessionsDir,r=e?.sessionStorage?.sandboxSessionsDir??pg.join("/home/agent",".codex","sessions"),n=new Map;return{hostSessionFilePath:(o,i)=>n.get(i),existsOnHost:async(o,i)=>(await Iv(i,t)).path!==void 0,readHostSession:async(o,i)=>{let s=await Iv(i,t);if(s.path)return EC(s.path,"utf-8")},captureToHost:async({hostCwd:o,sandboxCwd:i,sessionId:s,handle:a})=>{let c=await Jet(s,a,r),u=await nge(a,c.path,"codex-cap"),l=vN(u,i,o),d=t??nR(process.env.HOME??"~",".codex","sessions"),f=nR(d,c.relativePath);await ege(tge(f),{recursive:!0}),await i4(f,l),n.set(s,f)},resumeIntoSandbox:async({hostCwd:o,sandboxCwd:i,sessionId:s,handle:a})=>{let c=await Yet(s,t),u=await EC(c.path,"utf-8"),l=vN(u,o,i),d=pg.join(r,c.relativePath);await oge(a,d,l,"codex-res")},findByIdOnHost:o=>Iv(o,t)}},jir=e=>{let t=e?.sessionStorage?.hostSessionsDir,r=e?.sessionStorage?.sandboxSessionsDir??pg.join("/home/agent",".pi","agent","sessions");return{hostSessionFilePath:(n,o)=>Ole(n,t),existsOnHost:async(n,o)=>(await hz(o,t)).path!==void 0,readHostSession:async(n,o)=>{let i=await hz(o,t);if(i.path)return EC(i.path,"utf-8")},captureToHost:async({hostCwd:n,sandboxCwd:o,sessionId:i,handle:s})=>{let a=await Xet(i,s,r),c=await nge(s,a.path,"pi-cap"),u=Nle(c,o,n),l=pg.basename(a.path),d=nR(Ole(n,t),l);await ege(tge(d),{recursive:!0}),await i4(d,u)},resumeIntoSandbox:async({hostCwd:n,sandboxCwd:o,sessionId:i,handle:s})=>{let a=await Zet(i,t),c=await EC(a.path,"utf-8"),u=Nle(c,n,o),l=a.relativePath.split(/[\\/]/).pop(),d=pg.join(r,Qle(o),l);await oge(s,d,u,"pi-res")},findByIdOnHost:n=>hz(n,t)}},qir=e=>{if(!e.startsWith("{"))return[];try{let t=JSON.parse(e);if(t.type==="session"&&typeof t.id=="string")return[{type:"session_id",sessionId:t.id}];if(t.type==="message_update"&&t.assistantMessageEvent){let r=t.assistantMessageEvent;return r.type==="text_delta"&&typeof r.delta=="string"?[{type:"text",text:r.delta}]:[]}if(t.type==="tool_execution_start"){let r=t.toolName;if(typeof r!="string")return[];let n=rge[r];if(n===void 0)return[];let o=t.args;if(!o)return[];let i=o[n];return typeof i!="string"?[]:[{type:"tool_call",name:r,args:i}]}if(t.type==="agent_error"||t.type==="error"){let r=s4(t);return r?[{type:"result",result:r}]:[]}if(t.type==="agent_end"&&Array.isArray(t.messages)){let r=t.messages;for(let n=r.length-1;n>=0;n--){let o=r[n];if(o?.role==="assistant"){let i=[];for(let s of o.content)s.type==="text"&&typeof s.text=="string"&&i.push(s.text);if(i.length>0)return[{type:"result",result:i.join("")}];break}}return[]}}catch{}return[]},git=(e,t)=>({name:"pi",env:t?.env??{},captureSessions:t?.captureSessions??!0,sessionStorage:jir(t),buildPrintCommand({prompt:r,resumeSession:n}){let o=t?.thinking?` --thinking ${t.thinking}`:"",i=n?` --session ${Ai(n)}`:"";return{command:`pi -p --mode json --model ${Ai(e)}${o}${i}`,stdin:r}},buildInteractiveArgs({prompt:r}){let n=["pi","--model",e];return r&&n.push(r),n},parseStreamLine(r){return qir(r)}}),Gir=e=>{if(typeof e!="object"||e===null)return;let t=e;if(typeof t.input_tokens!="number"||typeof t.cached_input_tokens!="number"||typeof t.output_tokens!="number")return;let r=typeof t.reasoning_output_tokens=="number"?t.reasoning_output_tokens:void 0;return{inputTokens:t.input_tokens-t.cached_input_tokens,cacheCreationInputTokens:0,cacheReadInputTokens:t.cached_input_tokens,outputTokens:t.output_tokens,...r!==void 0?{reasoningTokens:r}:{}}},zir=e=>{if(!e.startsWith("{"))return[];try{let t=JSON.parse(e);if(t.type==="thread.started"&&typeof t.thread_id=="string")return[{type:"session_id",sessionId:t.thread_id}];if(t.type==="item.completed"&&t.item?.type==="agent_message"&&typeof t.item.text=="string"){let r=t.item.text;return[{type:"text",text:r},{type:"result",result:r}]}if(t.type==="item.started"&&t.item?.type==="command_execution"&&typeof t.item.command=="string")return[{type:"tool_call",name:"Bash",args:t.item.command}];if(t.type==="error"){let r=s4(t);return r?[{type:"result",result:r}]:[]}if(t.type==="turn.completed"){let r=Gir(t.usage),n=r?[{type:"usage",usage:r}]:[],o=t.usage?.reasoning_output_tokens;return typeof o=="number"&&o>0&&n.push({type:"reasoning",tokens:o}),n}}catch{}return[]},Ait=(e,t)=>({name:"codex",env:t?.env??{},captureSessions:t?.captureSessions??!0,sessionStorage:Wir(t),buildPrintCommand({prompt:r,resumeSession:n,forkSession:o,systemPrompt:i}){let s=t?.effort?` -c ${Ai(`model_reasoning_effort="${t.effort}"`)}`:"",a=t?.approvalsReviewer==="auto_review"?` -a on-request -s danger-full-access -c ${Ai('approvals_reviewer="auto_review"')}`:" --dangerously-bypass-approvals-and-sandbox",c;n&&o?c=`codex exec fork ${Ai(n)}`:n?c=`codex exec resume ${Ai(n)}`:c="codex exec";let u=n?" -":"";return{command:`${c} --json${a} -m ${Ai(e)}${s}${u}`,stdin:mit(i,r)}},buildInteractiveArgs({prompt:r}){let n=["codex","--model",e];return r&&n.push(r),n},parseStreamLine(r){return zir(r)}}),yit=(e,t)=>({name:"cursor",env:t?.env??{},captureSessions:!1,buildPrintCommand({prompt:r,dangerouslySkipPermissions:n}){Lir(r);let o=n?" --force":"";return{command:`agent --print --output-format stream-json --model ${Ai(e)} ${o} ${Ai(r)}`}},buildInteractiveArgs({prompt:r,dangerouslySkipPermissions:n}){let o=["agent","--model",e];return n&&o.push("--force"),r&&o.push(r),o},parseStreamLine(r){return $ir(r)}}),Vir={bash:"command",webfetch:"url",task:"description"},Yir=e=>{if(!e.startsWith("{"))return[];try{let t=JSON.parse(e),r=t.part;if(t.type==="step_start"&&typeof t.sessionID=="string")return[{type:"session_id",sessionId:t.sessionID}];if(t.type==="text"&&r?.type==="text"&&typeof r.text=="string")return[{type:"text",text:r.text},{type:"result",result:r.text}];if(t.type==="tool_use"&&r?.type==="tool"){if(typeof r.tool!="string")return[];let n=r.state;if(n?.status!=="completed")return[];let o=n.input;if(!o)return[];let i=Vir[r.tool],s=i!==void 0?o[i]:void 0,a=typeof s=="string"?s:JSON.stringify(o);return[{type:"tool_call",name:r.tool,args:a}]}if(t.type==="error"){let n=s4(t);return n?[{type:"result",result:n}]:[]}if(t.type==="step_finish"&&r?.type==="step-finish"){let n=r.tokens,o=a=>typeof a=="number"?a:0,i=n?.reasoning,s=[];return typeof i=="number"&&i>0&&s.push({type:"reasoning",tokens:i}),n&&(typeof n.input=="number"||typeof n.output=="number")&&s.push({type:"usage",usage:{inputTokens:o(n.input),cacheCreationInputTokens:o(n.cache?.write),cacheReadInputTokens:o(n.cache?.read),outputTokens:o(n.output),...typeof i=="number"?{reasoningTokens:i}:{}}}),s}}catch{}return[]},xit=(e,t)=>({name:"opencode",env:t?.env??{},captureSessions:!1,buildPrintCommand({prompt:r,dangerouslySkipPermissions:n,systemPrompt:o}){let i=t?.variant?` --variant ${Ai(t.variant)}`:"",s=t?.agent?` --agent ${Ai(t.agent)}`:"",a=n?" --dangerously-skip-permissions":"";return{command:`opencode run --format json --model ${Ai(e)}${i}${s}${a} ${Ai(mit(o,r))}`}},buildInteractiveArgs({prompt:r}){let n=["opencode","--model",e];return t?.agent&&n.push("--agent",t.agent),r&&n.push("--prompt",r),n},parseStreamLine(r){return Yir(r)}}),dit=120*1024;Kir=e=>{if(!e.startsWith("{"))return[];try{let t=JSON.parse(e);if(t.type==="assistant.message_delta"&&typeof t.data?.deltaContent=="string")return[{type:"text",text:t.data.deltaContent}];if(t.type==="tool.execution_start"){let r=t.data?.toolName;if(typeof r!="string")return[];let n=r==="bash"?"Bash":r,o=rge[n];if(o===void 0)return[];let i=t.data?.arguments;if(!i)return[];let s=i[o];return typeof s!="string"?[]:[{type:"tool_call",name:n,args:s}]}if(t.type==="assistant.message"&&typeof t.data?.content=="string"&&t.data.content.length>0)return[{type:"result",result:t.data.content}];if(t.type==="result"&&typeof t.sessionId=="string")return[{type:"session_id",sessionId:t.sessionId}];if(t.type==="error"||t.type==="agent_error"){let r=s4(t);return r?[{type:"result",result:r}]:[]}}catch{}return[]},Eit=(e,t)=>({name:"copilot",env:t?.env??{},captureSessions:!1,buildPrintCommand({prompt:r,dangerouslySkipPermissions:n}){Jir(r);let o=n?" --allow-all-tools":"",i=t?.effort?` --effort ${t.effort}`:"";return{command:`copilot -p ${Ai(r)} --output-format json --model ${Ai(e)}${o}${i}`}},buildInteractiveArgs({prompt:r}){let n=["copilot","--model",e];return r&&n.push("-i",r),n},parseStreamLine(r){return Kir(r)}}),Zir=e=>e.trim()?e.startsWith("[log] ")?[{type:"tool_call",name:"log",args:e.slice(6)}]:[{type:"text",text:e}]:[],bit=(e,t)=>({name:"devin",env:t?.env??{},captureSessions:!1,buildPrintCommand({prompt:r,dangerouslySkipPermissions:n}){let o=n?" --permission-mode dangerous":"";return{command:`mkdir -p ~/.local/share/devin && printf 'windsurf_api_key = "%s"\\napi_server_url = "https://server.codeium.com"\\ndevin_webapp_host = "app.devin.ai"\\ndevin_api_url = "https://api.devin.ai"\\n' "$DEVIN_SESSION_TOKEN" > ~/.local/share/devin/credentials.toml && PROMPT_FILE=$(mktemp) && trap 'rm -f "$PROMPT_FILE"' EXIT && cat > "$PROMPT_FILE" && devin-wrapper -p --prompt-file "$PROMPT_FILE" --model ${Ai(e)}${o}`,stdin:r}},buildInteractiveArgs({prompt:r}){let n=["devin","--model",e];return r&&n.push("--",r),n},parseStreamLine(r){return Zir(r)}}),Sit=(e,t)=>({name:"claude-code",env:t?.env??{},captureSessions:t?.captureSessions??!0,sessionStorage:Hir(t),buildPrintCommand({prompt:r,dangerouslySkipPermissions:n,resumeSession:o,forkSession:i,systemPrompt:s}){let a=t?.permissionMode?` --permission-mode ${t.permissionMode}`:n?" --dangerously-skip-permissions":"",c=t?.effort?` --effort ${t.effort}`:"",u=s?` --append-system-prompt ${Ai(s)}`:"",l=o?` --resume ${Ai(o)}`:"",d=o&&i?" --fork-session":"";return{command:`claude --print --verbose${a} --output-format stream-json --model ${Ai(e)}${c}${u}${l}${d} -p -`,stdin:r}},buildInteractiveArgs({prompt:r,dangerouslySkipPermissions:n}){let o=["claude"];return t?.permissionMode?o.push("--permission-mode",t.permissionMode):n&&o.push("--dangerously-skip-permissions"),o.push("--model",e),t?.effort&&o.push("--effort",t.effort),r&&o.push(r),o},parseStreamLine(r){return hit(r)},parseSessionUsage(r){let n=r.split(`
393
395
  `);for(let o=n.length-1;o>=0;o--){let i=n[o];if(i.startsWith("{"))try{let s=JSON.parse(i);if(s.type==="assistant"&&s.message?.usage){let a=s.message.usage;if(typeof a.input_tokens=="number"&&typeof a.cache_creation_input_tokens=="number"&&typeof a.cache_read_input_tokens=="number"&&typeof a.output_tokens=="number")return{inputTokens:a.input_tokens,cacheCreationInputTokens:a.cache_creation_input_tokens,cacheReadInputTokens:a.cache_read_input_tokens,outputTokens:a.output_tokens}}}catch{}}}})});var oR,wit,a4=h(()=>{"use strict";oR=e=>({tag:"bind-mount",name:e.name,env:e.env??{},sandboxHomedir:e.sandboxHomedir,create:e.create}),wit=e=>({tag:"isolated",name:e.name,env:e.env??{},create:e.create})});var Iit={};tr(Iit,{AGENT_OUTPUT_TAG:()=>kx,CwdError:()=>rit,LIVENESS_LANE_FILENAME:()=>Vp,LivenessLane:()=>o4,Output:()=>Wp,StructuredOutputError:()=>Gd,agentOutput:()=>eit,agentOutputSchema:()=>r4,claudeCode:()=>Sit,claudeHostSessionPath:()=>hx,claudeSandboxSessionPath:()=>pz,codex:()=>Ait,copilot:()=>Eit,createBindMountSandboxProvider:()=>oR,createIsolatedSandboxProvider:()=>wit,createLivenessTracker:()=>iit,createProcessDescendantProbe:()=>_x,createSandbox:()=>$et,createWorktree:()=>Het,cursor:()=>yit,devin:()=>bit,encodeProjectPath:()=>IN,evaluateLiveness:()=>Rx,extractAgentOutput:()=>n4,findClaudeSessionOnHost:()=>mz,findCodexSessionOnHost:()=>Iv,getAbortMetadata:()=>Ile,hasDescendantInSnapshot:()=>Xhe,interactive:()=>Oet,opencode:()=>xit,parseLivenessRecords:()=>fg,parsePsSnapshot:()=>Zhe,pi:()=>git,readLivenessRecency:()=>oit,readLivenessRecords:()=>Khe,resolveLivenessCrossCheckArming:()=>vx,run:()=>hN,transferClaudeSession:()=>kN,transferCodexSession:()=>vN});var Kd=h(()=>{"use strict";bN();bN();Net();Ble();Wet();Ple();mN();tit();nit();sit();ait();Cit();a4()});import{homedir as kit,hostname as vit,userInfo as Xir}from"node:os";function nsr(e){return!e||e.length<4?!1:!rsr.has(e.toLowerCase())}function osr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function c4(e,t,r){return!t||t===r||!e.includes(t)?e:e.split(t).join(r)}function isr(e){return!e||e.length<8?!1:!tsr.has(e.trim().toLowerCase())}function _it(e){let t=new Set;for(let[r,n]of Object.entries(e))esr.test(r)&&isr(n)&&t.add(n);return[...t].sort((r,n)=>n.length-r.length)}function ige(e,t,r){if(t.length<3||t===r)return e;let n=new RegExp(`(?<![A-Za-z0-9_-])${osr(t)}(?![A-Za-z0-9_-])`,"g");return e.replace(n,r)}function Bit(){try{return bJ()}catch{return"[REDACTED_HOST]"}}function Tit(e){let t=String.raw`[A-Za-z0-9_.-]*(?:TOKEN|SECRET|KEY|PASSWORD|PASS|AUTH|BEARER|COOKIE|SESSION|ANTHROPIC|OPENAI|MINIMAX|OPENROUTER|AWS_|GOOGLE_|SLACK_|NPM_|GH_|GITHUB_)[A-Za-z0-9_.-]*`,r=new RegExp(`\\b(${t})(\\s*=\\s*)([^\\s"'\\\`]+)`,"gi"),n=new RegExp(`(["']?${t}["']?\\s*:\\s*["'])([^"'\\n\\r]{8,})(["'])`,"gi");return e.replace(r,(o,i,s,a)=>a==="[REDACTED_SECRET]"?`${i}${s}${a}`:`${i}${s}[REDACTED_SECRET]`).replace(n,(o,i,s,a)=>s==="[REDACTED_SECRET]"?`${i}${s}${a}`:`${i}[REDACTED_SECRET]${a}`)}function ssr(e,t){let r=e,n=t.homeDir||kit();return n&&(r=c4(r,n,"[REDACTED_HOME]")),r=r.replace(/\/home\/([A-Za-z0-9._-]+)(?![A-Za-z0-9._-])/g,"/home/[REDACTED_USER]"),r=r.replace(/\/Users\/([A-Za-z0-9._-]+)(?![A-Za-z0-9._-])/g,"/Users/[REDACTED_USER]"),r}function jr(e,t={}){try{let r=typeof e=="string"?e:String(e??"");r=r.replace(Rit,"[REDACTED_CLAUDE_SESSION]");for(let i of _it(t.env??process.env))r=c4(r,i,"[REDACTED_SECRET]");r=Tit(r),r=ssr(r,t);let n=t.hostname??vit();r=ige(r,n,t.hostReplacement??Bit());let o=t.username;if(o===void 0)try{o=Xir().username}catch{o=void 0}return nsr(o)&&(r=ige(r,o,"[REDACTED_USER]")),r}catch{return typeof e=="string"?e:String(e??"")}}function Dit(e={}){let t=[],r="",n="",o="[REDACTED_HOST]";try{t=_it(e.env??process.env),r=e.homeDir||kit(),n=e.hostname??vit(),o=e.hostReplacement??Bit()}catch{}return i=>{try{let s=i.replace(Rit,"[REDACTED_CLAUDE_SESSION]");for(let a of t)s=c4(s,a,"[REDACTED_SECRET]");return s=Tit(s),r&&(s=c4(s,r,"[REDACTED_HOME]")),s=s.replace(/\/home\/([A-Za-z0-9._-]+)(?![A-Za-z0-9._-])/g,"/home/[REDACTED_USER]"),s=s.replace(/\/Users\/([A-Za-z0-9._-]+)(?![A-Za-z0-9._-])/g,"/Users/[REDACTED_USER]"),n&&(s=ige(s,n,o)),s}catch{return i}}}var Rit,esr,tsr,rsr,Bx=h(()=>{"use strict";TM();Rit=/https:\/\/claude\.ai\/code\/session_[A-Za-z0-9_-]+/g,esr=/(?:TOKEN|SECRET|KEY|PASSWORD|PASS|AUTH|BEARER|COOKIE|SESSION|ANTHROPIC|OPENAI|MINIMAX|OPENROUTER|AWS_|GOOGLE_|SLACK_|NPM_|GH_|GITHUB_)/i,tsr=new Set(["true","false","null","0","1"]),rsr=new Set(["runner","root","user","admin","ubuntu","debian","node","dev","ci","build","agent","worker","actions","git"])});function Oit(e=process.env){let r=(e.RED_AFK_HOST_ENV_ALLOW??"").split(",").map(n=>n.trim()).filter(Boolean);if(!r.includes("*"))return r.length>0?[...Qit,...r]:Qit}var Qit,Nit=h(()=>{"use strict";Qit=["PATH","HOME","SHELL","USER","LOGNAME","PWD","TMPDIR","TMP","TEMP","TERM","COLORTERM","LANG","LANGUAGE","LC_*","TZ","EDITOR","PAGER","CI","XDG_*","SSH_*","GIT_*","GH_*","GITHUB_*","CLAUDE*","ANTHROPIC*","CODEX*","OPENAI*","OPENCODE*","MINIMAX*","OPENROUTER*","RED_*","RTK_*","NODE*","NVM_*","ASDF*","NPM*","PNPM*","COREPACK*","BUN*","YARN*","TURBO*","VITEST*","CARGO*","RUSTUP*","RUST*","GOPATH","GOROOT","GOBIN","GOCACHE","GOMODCACHE","GOFLAGS","GOPROXY","GOPRIVATE","GONOSUMDB","GOTOOLCHAIN","PYTHON*","PIP*","UV_*","VIRTUAL_ENV","PYENV*","JAVA*","GRADLE*","MAVEN*","M2_*","SDKMAN*","KOTLIN*","PHP*","COMPOSER*","DOTNET*","NUGET*","DART*","PUB_*","FLUTTER*","ZIG*","CC","CXX","MAKEFLAGS","PKG_CONFIG*","LD_*"]});function Pit(e){return e?["---- SPECIAL USER REQUEST ------",e,"-------------------------------"].join(`
394
396
  `):null}function Mit(e){return{command:"claude",args:["--model","opus","--effort","medium","--permission-mode","bypassPermissions","--output-format","stream-json","--verbose","--print",e.prompt]}}function Fit(e){return{command:"codex",args:["exec",...[...e.model?["--model",e.model]:[],...e.effort?["-c",`model_reasoning_effort=${e.effort}`]:[]],"--json","-C",e.worktree,"--sandbox","danger-full-access","--dangerously-bypass-approvals-and-sandbox","--output-last-message",e.lastMessagePath,e.prompt]}}function sge(e){return asr.test(e)}var asr,age=h(()=>{"use strict";asr=/usage limit|weekly (limit|cap)|session (limit|exhausted)|quota|rate_limit_error|try again later|\bbalance\b|\b429\b|insufficient.credit/i});function cge(e=process.env){let t=(i,s)=>{let a=e[i];return a!==void 0&&/^[0-9]+$/.test(a)?Number(a):s},r=t("RED_AFK_STALL_THRESHOLD_S",Lr.stallThresholdS),n=t("RED_AFK_STALL_KILL_THRESHOLD_S",Lr.stallKillThresholdS);xJ({stallThresholdS:r,stallKillThresholdS:n});let o=t("RED_AFK_STALL_POLL_S",u4)||u4;return{stallThresholdS:r,stallKillThresholdS:n,stallPollS:o}}function Lit(e){let t=!1;return{stop:e.schedule(()=>{if(t)return;let n=e.now(),o=n-e.spawnEpoch;if(!(e.spawnEpoch>0)||!(o>=e.stallThresholdS)){e.onTick?.({idleSeconds:0,stalled:!1,verdict:"not-candidate",nowS:n});return}let i=e.livenessVerdict(),s=i!==null&&i.status==="stalled",a=i?.laneAgeMs!==void 0?Math.round(i.laneAgeMs/1e3):0,c="not-candidate";if(s){let u=a>0?a:o;if(u>=e.stallKillThresholdS){let l=VC(e.inspectTree()),d=xM({idleSeconds:u,idleThresholdSeconds:e.stallKillThresholdS,activeDescendant:l.activeDescendant,cpuPct:l.cpuPct});c=d==="kill"?"kill":"no-kill",d==="kill"&&(t=!0,e.abort())}else c="no-kill"}e.onTick?.({idleSeconds:a,stalled:s,verdict:c,nowS:n})},e.intervalMs),firedReap:()=>t}}var u4,uge=h(()=>{"use strict";iw();EM();u4=30});function $it(e){let t=usr(e,lge);if(t===void 0)return;let r;try{r=JSON.parse(lsr(t.trim()))}catch{return}let n=csr.safeParse(r);return n.success?n.data:void 0}function usr(e,t){let r=`<${t}>`,n=`</${t}>`,o,i=0;for(;;){let s=e.indexOf(r,i);if(s===-1)break;let a=s+r.length,c=e.indexOf(n,a);if(c===-1)break;o=e.slice(a,c),i=c+n.length}return o}function lsr(e){let t=e.match(/^```(?:json)?\s*\n([\s\S]*?)\n\s*```\s*$/);return t?t[1].trim():e}var lge,Phn,Uit,csr,Hit=h(()=>{"use strict";LM();lge="agent-output",Phn=`<${lge}>`,Uit=`</${lge}>`,csr=Ae.object({success:Ae.boolean(),summary:Ae.string(),key_changes_made:Ae.array(Ae.string()),key_learnings:Ae.array(Ae.string()),should_fully_stop:Ae.boolean()})});import{execFile as Wit}from"node:child_process";var l4,Hhn,jit,qit,Git=h(()=>{"use strict";Dn();pa();sg();l4=e=>S.async(t=>{Wit("docker",e,{maxBuffer:10*1024*1024},(r,n,o)=>{t(r?S.fail(new ZO({message:`docker ${e[0]} failed: ${o?.toString()||r.message}`})):S.succeed(n.toString()))})}),Hhn=S.async(e=>{Wit("docker",["info","--format","{{.ServerVersion}}"],{maxBuffer:1024*1024},t=>{if(!t){e(S.succeed("ok"));return}let r=t.code;e(S.succeed(r==="ENOENT"?"not-installed":"not-running"))})}),jit=(e,t,r,n)=>S.gen(function*(){(yield*l4(["ps","-a","--filter",`name=^${e}$`,"--format","{{.Names}}"])).trim()===e&&(yield*S.fail(new ZO({message:`Container '${e}' already exists. Run cleanup first.`})));let i=Object.entries(r).flatMap(([g,A])=>["-e",`${g}=${A}`]),s=n?.selinuxLabel??"z",a=(n?.volumeMounts??[]).flatMap(g=>["-v",tz(g,s)]),c=n?.workdir?["-w",n.workdir]:[],u=n?.user?["--user",n.user]:[],d=(n?.network?Array.isArray(n.network)?n.network:[n.network]:[]).flatMap(g=>["--network",g]),f=(n?.groups??[]).flatMap(g=>["--group-add",String(g)]),p=(n?.devices??[]).flatMap(g=>["--device",g]),m=n?.cpus!==void 0?["--cpus",String(n.cpus)]:[];yield*l4(["run","-d","--name",e,...i,...a,...c,...u,...d,...f,...p,...m,t])}),qit=e=>S.gen(function*(){yield*S.ignore(l4(["stop",e])),yield*S.ignore(l4(["rm",e]))})});var Vit={};tr(Vit,{defaultImageName:()=>bv,docker:()=>msr});import{execFile as d4,execFileSync as dsr,spawn as zit}from"node:child_process";import{randomUUID as fsr}from"node:crypto";import{createInterface as psr}from"node:readline";var msr,hsr,Yit=h(()=>{"use strict";Dn();Git();a4();sg();iz();dz();msr=e=>{let t=e?.imageName,r=e?.selinuxLabel??"z",n=e?.maxOutputTailChars??65536,o="/home/agent",i=e?.mounts?ez(e.mounts,o):[],s=rz(i,o);return oR({name:"docker",env:e?.env,sandboxHomedir:o,create:async a=>{let c=`sandcastle-${fsr()}`,u=a.mounts.find(y=>y.hostPath===a.worktreePath)?.sandboxPath??"/home/agent/workspace",d=[...a.mounts,...i].map(y=>({hostPath:y.hostPath,sandboxPath:y.sandboxPath,readonly:y.readonly})),f=t??bv(a.hostRepoPath),p=e?.containerUid??process.getuid?.()??1e3,m=e?.containerGid??process.getgid?.()??1e3;await hsr(f,p),await S.runPromise(jit(c,f,{...a.env,HOME:"/home/agent"},{volumeMounts:d,workdir:u,user:`${p}:${m}`,network:e?.network,groups:e?.groups,devices:e?.devices,cpus:e?.cpus,selinuxLabel:r}));for(let y of s)await new Promise((b,w)=>{d4("docker",["exec","--user","0:0",c,"sh","-c",'mkdir -p "$1" && chown "$2" "$1"',"sh",y,`${p}:${m}`],I=>{I?w(new Error(`Failed to create parent directory '${y}' in container: ${I.message}`)):b()})});let A=wv(()=>{try{dsr("docker",["rm","-f",c],{stdio:"ignore"})}catch{}});return{worktreePath:u,exec:(y,b)=>{let w=b?.sudo?`sudo ${y}`:y,I=["exec"];return b?.stdin!==void 0&&I.push("-i"),b?.cwd&&I.push("-w",b.cwd),I.push(c,"sh","-c",w),new Promise((v,k)=>{let R=zit("docker",I,{stdio:[b?.stdin!==void 0?"pipe":"ignore","pipe","pipe"]});if(b?.stdin!==void 0&&(R.stdin.write(b.stdin),R.stdin.end()),R.on("error",B=>{k(new Error(`docker exec failed: ${B.message}`))}),b?.onLine){let B=b.onLine,L=new zd(n,`
395
397
  `),D=new zd(n,"");psr({input:R.stdout}).on("line",F=>{L.push(F),B(F)}),R.stderr.on("data",F=>{D.push(F.toString())}),R.on("close",F=>{v({stdout:L.toString(),stderr:D.toString(),exitCode:F??0})})}else{let B=[],L=[];R.stdout.on("data",D=>{B.push(D.toString())}),R.stderr.on("data",D=>{L.push(D.toString())}),R.on("close",D=>{v({stdout:B.join(""),stderr:L.join(""),exitCode:D??0})})}})},interactiveExec:(y,b)=>new Promise((w,I)=>{let v=["exec"];"isTTY"in b.stdin&&b.stdin.isTTY?v.push("-it"):v.push("-i"),b.cwd&&v.push("-w",b.cwd),v.push(c,...y);let k=zit("docker",v,{stdio:[b.stdin,b.stdout,b.stderr]});k.on("error",R=>{I(new Error(`docker exec failed: ${R.message}`))}),k.on("close",R=>{w({exitCode:R??0})})}),copyFileIn:(y,b)=>new Promise((w,I)=>{d4("docker",["cp",y,`${c}:${b}`],v=>{v?I(new Error(`docker cp (in) failed: ${v.message}`)):w()})}),copyFileOut:(y,b)=>new Promise((w,I)=>{d4("docker",["cp",`${c}:${y}`,b],v=>{v?I(new Error(`docker cp (out) failed: ${v.message}`)):w()})}),close:async()=>{A(),await S.runPromise(qit(c))}}}})},hsr=(e,t)=>new Promise((r,n)=>{d4("docker",["image","inspect",e,"--format","{{.Config.User}}"],(o,i)=>{if(o){n(new Error(`Image '${e}' not found locally. Build it first with 'sandcastle docker build-image'.`));return}let s=(i??"").toString().trim();if(!s){r();return}let a=s.split(":")[0],c=parseInt(a,10);if(isNaN(c)){r();return}c!==t?n(new Error(`UID mismatch: image '${e}' was built with UID ${c}, but the expected UID is ${t}. Rebuild the image with 'sandcastle docker build-image', or pass containerUid: ${c} to docker() to match the image.`)):r()})})});var Kit={};tr(Kit,{defaultImageName:()=>bv,podman:()=>xsr});import{execFile as bC,execFileSync as gsr,spawn as Jit}from"node:child_process";import{randomUUID as Asr}from"node:crypto";import{createInterface as ysr}from"node:readline";var xsr,Esr,dge,bsr,Zit=h(()=>{"use strict";a4();sg();iz();dz();xsr=e=>{let t=e?.imageName,r=e?.selinuxLabel??"z",n=e?.userns??"keep-id",o=e?.containerUid??1e3,i=e?.containerGid??1e3,s=e?.maxOutputTailChars??65536,a="/home/agent",c=e?.mounts?ez(e.mounts,a):[],u=rz(c,a);return oR({name:"podman",env:e?.env,sandboxHomedir:a,create:async l=>{let d=`sandcastle-${Asr()}`,f=l.mounts.find(F=>F.hostPath===l.worktreePath)?.sandboxPath??"/home/agent/workspace",m=[...l.mounts,...c].map(F=>tz(F,r)),g=t??bv(l.hostRepoPath);(process.platform==="darwin"||process.platform==="win32")&&await bsr(),await Esr(g);let A={...l.env,HOME:"/home/agent"},E=Object.entries(A).flatMap(([F,_])=>["-e",`${F}=${_}`]),y=m.flatMap(F=>["-v",F]),b=n?[`--userns=keep-id:uid=${o},gid=${i}`]:[],w=["--user",`${o}:${i}`],v=(e?.network?Array.isArray(e.network)?e.network:[e.network]:[]).flatMap(F=>["--network",F]),k=(e?.groups??[]).flatMap(F=>["--group-add",String(F)]),R=(e?.devices??[]).flatMap(F=>["--device",F]),B=e?.cpus!==void 0?["--cpus",String(e.cpus)]:[];await new Promise((F,_)=>{bC("podman",["run","-d","--name",d,...w,...b,...v,...k,...R,...B,"-w",f,...E,...y,"--entrypoint","sleep",g,"infinity"],P=>{P?_(new Error(`podman run failed: ${P.message}`)):F()})});for(let F of u)await new Promise((_,P)=>{bC("podman",["exec","--user","0:0",d,"sh","-c",'mkdir -p "$1" && chown "$2" "$1"',"sh",F,`${o}:${i}`],$=>{$?P(new Error(`Failed to create parent directory '${F}' in container: ${$.message}`)):_()})});let D=wv(()=>{try{gsr("podman",["rm","-f",d],{stdio:"ignore",timeout:5e3})}catch{}}),ee={worktreePath:f,exec:(F,_)=>{let P=_?.sudo?`sudo ${F}`:F,$=["exec"];return _?.stdin!==void 0&&$.push("-i"),_?.cwd&&$.push("-w",_.cwd),$.push(d,"sh","-c",P),new Promise((N,q)=>{let re=Jit("podman",$,{stdio:[_?.stdin!==void 0?"pipe":"ignore","pipe","pipe"]});if(_?.stdin!==void 0&&(re.stdin.write(_.stdin),re.stdin.end()),re.on("error",ie=>{q(new Error(`podman exec failed: ${ie.message}`))}),_?.onLine){let ie=_.onLine,ue=new zd(s,`
@@ -405,8 +407,8 @@ ${t}`:t,rge={Bash:"command",WebSearch:"query",WebFetch:"url",Agent:"description"
405
407
  `);return{command:`sh -c ${fP(e)}`}}function ust(e,t){let r={type:"branch",branch:t.branch,...t.base?{baseBranch:t.base}:{}},n=[cst(),ast()];t.continuousPush&&n.push(sst(t.branch,t.remote??tst));let o={host:{onWorktreeReady:n}},i=t.logPath?{type:"file",path:t.logPath,redactLine:Dit(),...t.onAgentEvent?{onAgentStreamEvent:t.onAgentEvent}:{}}:void 0;return{agent:e.agentFor(t.runner,t.model,{effort:t.effort}),sandbox:e.sandboxFor(t.sandboxMode??"none",t.cwd?{mountPath:t.cwd}:void 0),...t.cwd?{cwd:t.cwd}:{},prompt:t.handoffContent,...t.systemPrompt?{systemPrompt:t.systemPrompt}:{},branchStrategy:r,completionSignal:t.runner==="claude"?[...fge,Uit]:[...fge],maxIterations:t.maxIterations??f4,idleTimeoutSeconds:t.idleTimeoutSeconds??est,...o?{hooks:o}:{},...i?{logging:i}:{}}}function lst(e){if(e==null)return!1;let t=[];return hge(e,t,new Set,0),t.some(r=>sge(r))}function dst(e){if(e==null)return!1;let t=[];return hge(e,t,new Set,0),t.some(r=>_sr.test(r))}function hge(e,t,r,n){if(n>5)return;if(typeof e=="string"){t.push(e);return}if(typeof e!="object"||e===null||r.has(e))return;r.add(e);let o=String(e);o&&o!=="[object Object]"&&t.push(o);for(let i of Object.values(e))hge(i,t,r,n+1)}function Bsr(e,t){let r=setInterval(e,t);return r.unref?.(),()=>clearInterval(r)}function fst(e,t){if(t.maxTotalTokens!==void 0&&e.inputTokens+e.outputTokens>=t.maxTotalTokens)return"tokens";if(t.maxCostUsd!==void 0&&e.costUsd>=t.maxCostUsd)return"cost";if(t.maxToolCalls!==void 0&&e.toolsCalled>=t.maxToolCalls)return"tool-calls";if(t.maxWaitingWindows!==void 0&&e.waiting>=t.maxWaitingWindows)return"waiting-windows"}function pst(e){let t=e.now(),r=e.now(),n,o,i,s,a=!1,c=!1,u=!1,l=!1;return{stop:e.schedule(()=>{(async()=>{if(c)return;if(e.goalProbe){let B;try{B=await e.goalProbe()}catch{B=void 0}if(c)return;if(B===!0){c=!0,u=!0,e.abort("goal-moot");return}}if(e.budget&&e.budgetUsage&&fst(e.budgetUsage(),e.budget)!==void 0){c=!0,l=!0,e.abort("budget");return}let f;if(e.activityUsage)try{let B=e.activityUsage();f=B.inputTokens+B.outputTokens+B.toolsCalled+B.waiting+(B.textChunks??0)+(B.reasoningCount??0)}catch{f=void 0}let p=!1;if(e.activeDescendantProbe)try{p=e.activeDescendantProbe()}catch{p=!1}let m,g=!0;try{m=await e.headProbe()}catch{g=!1}if(c)return;let A;if(e.progressProbe)try{A=await e.progressProbe()}catch{A=void 0}if(c)return;let E=g&&m!==void 0&&m!==n,y=A!==void 0&&o!==void 0&&A!==o,b=A!==void 0&&s!==void 0&&A>s,w=f!==void 0&&i!==void 0&&f>i,I=p||w;E?(t=e.now(),r=e.now(),a=!1):b?(t=e.now(),a=!1):I?t=e.now():y&&!b&&(a=!0);let k=!E&&!b&&!I&&e.now()-t>=e.capMs,R=!E&&e.hardCapMs!==void 0&&e.now()-r>=e.hardCapMs;(k||R)&&(c=!0,e.abort(R&&!k?"hard-cap":a?"edit-loop-stall":"stalled")),g&&m!==void 0&&(n=m),A!==void 0&&(o=A,s=s===void 0?A:Math.max(s,A)),f!==void 0&&(i=f),e.onTick?.({head:m??n,lastProgressMs:t,nowMs:e.now()})})()},e.intervalMs),firedTimeout:()=>c&&!u&&!l,firedGoalMoot:()=>u,firedBudget:()=>l}}async function Tsr(e,t){let r=e.warn??(m=>console.warn(m));t.continuousPush&&(t.sandboxMode==="docker"||t.sandboxMode==="podman")&&r(`[afk] warn: continuous-push is unavailable under ${t.sandboxMode} isolation; intermediate commits are not backed up mid-run \u2014 final sync only.`);for(let[m,g]of Object.entries(t.env??{}))process.env[m]=g;let n=e.now??(()=>Date.now()),o=e.makeAbortController??(()=>new AbortController),i=e.schedule??Bsr,s,a,c,u;if(t.attemptTimeoutSeconds&&t.attemptTimeoutSeconds>0&&t.headProbe){let m=t.attemptTimeoutSeconds*1e3;u=o();let g=t.attemptTimeoutSeconds,A=t.attemptHardCapSeconds;s=pst({capMs:m,intervalMs:Math.min(m,6e4),headProbe:t.headProbe,...t.progressProbe?{progressProbe:t.progressProbe}:{},...A&&A>0?{hardCapMs:A*1e3}:{},now:n,schedule:i,...t.goalProbe?{goalProbe:t.goalProbe}:{},...t.budget&&t.budgetUsage?{budget:t.budget,budgetUsage:t.budgetUsage}:{},...t.budgetUsage?{activityUsage:t.budgetUsage}:{},...t.inspectTree?{activeDescendantProbe:()=>VC(t.inspectTree()).activeDescendant}:{},abort:E=>{(E==="stalled"||E==="edit-loop-stall"||E==="hard-cap")&&(a=E),u?.abort(new Error(E==="goal-moot"?"afk: attempt mooted \u2014 the claimed issue is already CLOSED (goal predicate, ADR 0057)":E==="budget"?"afk: attempt aborted \u2014 per-attempt resource budget exceeded (#908)":E==="hard-cap"?`afk: attempt aborted \u2014 no new commit within ${A}s despite worktree edits (hard cap, stalled)`:E==="edit-loop-stall"?`afk: attempt aborted \u2014 worktree diff kept changing without new high-water progress within ${g}s (edit-loop-stall)`:`afk: attempt aborted \u2014 no new commit within ${g}s (stalled)`))},...t.onHeartbeat?{onTick:t.onHeartbeat}:{}})}if(t.laneIdleThresholdSeconds&&t.laneIdleThresholdSeconds>0&&t.laneIdleKillThresholdSeconds&&t.laneIdleKillThresholdSeconds>0&&t.livenessVerdictProbe&&t.inspectTree){u||(u=o());let m=u,g=t.laneIdlePollSeconds&&t.laneIdlePollSeconds>0?t.laneIdlePollSeconds:u4;c=Lit({spawnEpoch:Math.floor(n()/1e3),stallThresholdS:t.laneIdleThresholdSeconds,stallKillThresholdS:t.laneIdleKillThresholdSeconds,intervalMs:g*1e3,livenessVerdict:t.livenessVerdictProbe,inspectTree:t.inspectTree,now:()=>Math.floor(n()/1e3),schedule:i,abort:()=>m.abort(new Error(`afk: attempt reaped \u2014 agent lane idle past ${t.laneIdleKillThresholdSeconds}s with no active build/test (stalled)`))})}let l;try{let m=ust(e,t);l=await e.run(u?{...m,signal:u.signal}:m)}catch(m){if(c?.firedReap())return{outcome:"no-sentinel",branch:t.branch,commits:[],stdout:`afk: attempt reaped \u2014 agent lane idle past ${t.laneIdleKillThresholdSeconds}s with no active build/test (stalled)`};if(s?.firedGoalMoot())return{outcome:"goal-moot",branch:t.branch,commits:[],stdout:"afk: attempt mooted \u2014 the claimed issue is already CLOSED (goal predicate, ADR 0057)"};if(s?.firedBudget())return{outcome:"budget-exceeded",branch:t.branch,commits:[],stdout:"afk: attempt aborted \u2014 per-attempt resource budget exceeded (#908)"};if(s?.firedTimeout())return{outcome:"timeout",branch:t.branch,commits:[],timeoutReason:a??"stalled",stdout:a==="edit-loop-stall"?`afk: attempt aborted \u2014 worktree diff kept changing without new high-water progress within ${t.attemptTimeoutSeconds}s (edit-loop-stall)`:a==="hard-cap"?`afk: attempt aborted \u2014 no new commit within ${t.attemptHardCapSeconds}s despite worktree edits (hard cap, stalled)`:`afk: attempt aborted \u2014 no new commit within ${t.attemptTimeoutSeconds}s (stalled)`};if(lst(m))return{outcome:"exhausted",branch:t.branch,commits:[],stdout:""};if(dst(m))return{outcome:"runner-transient",branch:t.branch,commits:[],stdout:m instanceof Error?m.message:String(m)};let g=Xit(m);return g?{outcome:"signal-killed",branch:t.branch,commits:[],stdout:`afk: inner agent killed by ${g.signal} (exit code ${g.exitCode})`}:{outcome:"no-sentinel",branch:t.branch,commits:[],stdout:m instanceof Error?m.message:String(m)}}finally{s?.stop(),c?.stop()}if(l.completionSignal===void 0&&sge(l.stdout??""))return{outcome:"exhausted",branch:l.branch,commits:l.commits,stdout:l.stdout};let d=$it(l.stdout??""),f=ost(d,l.completionSignal),p=ist(t.runner,f,l.stdout??"");return p.rejectedReason&&r(`[afk] warn: AgentOutput ${p.rejectedReason} \u2014 downgraded to ${p.outcome}`),{outcome:p.outcome,branch:l.branch,commits:l.commits,completionSignal:l.completionSignal,...d?{agentOutput:d}:{},stdout:l.stdout}}async function SC(){let[e,t,r,n]=await Promise.all([Promise.resolve().then(()=>(Kd(),Iit)),Promise.resolve().then(()=>(sz(),Qet)),Promise.resolve().then(()=>(Yit(),Vit)),Promise.resolve().then(()=>(Zit(),Kit))]),o=c=>console.warn(c),i={claudeCode:(c,u)=>e.claudeCode(c,u),codex:(c,u)=>e.codex(c,u),opencode:(c,u)=>e.opencode(c,u)},s=(c,u,l)=>rst(i,c,u,l,process.env,o),a=(c,u)=>{let l=u?.mountPath?[{hostPath:u.mountPath,sandboxPath:u.mountPath}]:void 0;if(c==="docker")return r.docker(l?{mounts:l}:void 0);if(c==="podman")return n.podman(l?{mounts:l}:void 0);let d=Oit(process.env);return t.noSandbox(d?{hostEnvAllowlist:d}:void 0)};return{run:e.run,agentFor:s,sandboxFor:a,warn:o}}var pge,mge,fge,Ssr,est,Csr,wsr,f4,tst,Rsr,_sr,CC=h(()=>{"use strict";Kd();Bx();Nit();age();uge();EM();s_();Hit();s_();pge="<promise>DONE</promise>",mge="<promise>BLOCKED</promise>",fge=[pge,mge],Ssr={1:"SIGHUP",2:"SIGINT",3:"SIGQUIT",9:"SIGKILL",11:"SIGSEGV",13:"SIGPIPE",15:"SIGTERM"};est=600,Csr=2700;wsr=5400;f4=20;tst="origin";Rsr="OPENROUTER_API_KEY";_sr=/failed to connect to websocket|HTTP error:\s*502 Bad Gateway|HTTP error:\s*503 Service Unavailable|\b529\b|overloaded|wss:\/\/chatgpt\.com\/backend-api\/codex\/responses|thread\/start failed|failed to load configuration|spawn sh ENOENT|cwd does not exist|ECONNREFUSED|ENOTFOUND|ETIMEDOUT|ECONNRESET/i});var gge={};tr(gge,{DEFAULT_SNAPSHOT_GRACE_S:()=>Fsr,attemptIssueFromBranch:()=>Ast,branchesToKeep:()=>qsr,branchesToReap:()=>mg,classifyIssueState:()=>yst,liveIssueFromBranch:()=>m4,planAttemptSnapshotCleanup:()=>gP,planLiveBranchCleanup:()=>iR,planLocalBranchCleanup:()=>AP,resolveSnapshotGraceS:()=>hP});function Hsr(e){return typeof e=="number"&&Number.isFinite(e)}function hP(e=process.env){let t=e.RED_AFK_ATTEMPT_SNAPSHOT_GRACE_S;return t!==void 0&&gst.test(t)?Number(t):604800}function m4(e){let t=Usr.exec(e);return t?Number(t[1]):null}function Ast(e){let t=$sr.exec(e);return t?Number(t[1]):null}function yst(e,t,r){if(e===void 0)return"unresolved-transient";if(e===null)return"not-found";switch(e.state){case"OPEN":return"open";case"CLOSED":{let n=e.closedAt;if(!n)return"unresolved-transient";let o=Math.floor(Date.parse(n)/1e3);return Number.isFinite(o)?t-o>r?"closed-past-grace":"closed-within-grace":"unresolved-transient"}default:return"unresolved-transient"}}function Wsr(e,t,r,n){return e==="closed-past-grace"||e==="not-found"&&Hsr(n)&&t-n>r?"reap":"keep"}function jsr(e){return e==="closed-within-grace"||e==="closed-past-grace"?"reap":"keep"}function xst(e,t,r,n,o,i){let s=gst.test(String(o))&&o>=0?o:604800,a=Number.isFinite(n)?n:0,c=new Map,u=[];for(let l of e){let d=t(l.branch);if(d===null)continue;let f=c.get(d);if(f===void 0){let m=yst(r(d),a,s);f=Lsr.includes(m)?m:"unresolved-transient",c.set(d,f)}let p=i(f,a,s,l.commitS);u.push({action:p,branch:l.branch,issue:d,state:f})}return u}function gP(e,t,r,n){return xst(e,Ast,t,r,n,Wsr)}function iR(e,t,r){return xst(e,m4,t,r,0,n=>jsr(n))}function AP(e,t,r){return iR(e,t,r)}function mg(e){return e.filter(t=>t.action==="reap")}function qsr(e){return e.filter(t=>t.action==="keep")}var Fsr,Lsr,gst,Usr,$sr,sR=h(()=>{"use strict";Fsr=604800,Lsr=["open","closed-within-grace","closed-past-grace","not-found","unresolved-transient"],gst=/^[0-9]+$/,Usr=/^afk\/[^/]+\/([0-9]+)-[a-z0-9-]+$/,$sr=/^afk-attempts\/[^/]+\/([0-9]+)-/});var hg={};tr(hg,{KILLED_EXIT_CODE:()=>aR,MAXBUFFER_EXIT_CODE:()=>Est,execTool:()=>jt,gh:()=>Ysr,git:()=>Vsr,pnpm:()=>Age});import{execFile as Gsr}from"node:child_process";function jt(e,t,r={}){return new Promise(n=>{let o=Gsr(e,[...t],{cwd:r.cwd,env:r.env??process.env,timeout:r.timeoutMs??0,maxBuffer:r.maxBuffer??zsr,encoding:"utf8"},(i,s,a)=>{if(i&&i.code==="ERR_CHILD_PROCESS_STDIO_MAXBUFFER"){n({code:Est,stdout:String(s??""),stderr:`command output exceeded the capture ceiling (maxBuffer length exceeded); ${String(i.message)}`});return}if(i&&typeof i.code=="string"){n({code:127,stdout:String(s??""),stderr:String(i.message)});return}if(i&&(i.killed||i.signal!=null)){n({code:aR,stdout:String(s??""),stderr:String(a??"")||String(i.message)});return}let c=i&&typeof i.code=="number"?i.code:0;n({code:c,stdout:String(s??""),stderr:String(a??"")})});r.input!==void 0&&o.stdin&&o.stdin.end(r.input)})}function Vsr(e,t={}){return jt("git",e,t)}function Ysr(e,t={}){return jt("gh",e,t)}function Age(e,t={}){return jt("pnpm",e,t)}var zsr,Est,aR,bn=h(()=>{"use strict";zsr=64*1024*1024,Est=126,aR=124});function cR(e){if(e.isBot)return"automation";let t=(e.authorAssociation??"").trim().toUpperCase();if(yP.has(t))return"trusted";let r=e.trustVerdict;return r?.executable&&r.basis!==void 0&&Jsr.has(r.basis)||e.maintainerThumbsUp?"trusted":"dubious"}function yge(e){return e===void 0||e==="trusted"}var yP,Jsr,h4=h(()=>{"use strict";yP=new Set(["OWNER","MEMBER","COLLABORATOR"]),Jsr=new Set(["allowlist","write-access","codeowners"])});function bst(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort()}function Zsr(e){let r=bst(e).map(n=>`- ${n}`).join(`
406
408
  `);return[Ksr,"","## Summary","","The AFK feedback baseline probe found pre-existing failures on main. Repair main before relying on the feedback gate as a branch verdict.","","## Failing checks","",r||"- (none)","","## Source","","Auto-filed by the AFK feedback baseline probe."].join(`
407
409
  `)}function Sst(e,t){let r=bst(e);if(r.length===0)return t?{action:"close",issue:t.number,comment:"\u{1F916} /afk baseline probe: main is green again; closing the auto-filed repair issue."}:{action:"noop"};let n=Zsr(r),o=[Je,zR,ixe];return t?{action:"update",issue:t.number,title:uR,body:n,labels:o}:{action:"create",title:uR,body:n,labels:o}}function Cst(e){return e.mainRed?e.openRepairIssue?{ok:!0}:{ok:!1,message:`Refusing admin-merge onto red main because no open main-red repair issue exists. Restore the tracked-red visibility gate by letting syncMainRedRepairIssue auto-file "${uR}" from the AFK feedback baseline probe before landing.`}:{ok:!0}}var uR,Ksr,g4=h(()=>{"use strict";un();uR="main-red repair: baseline probe failures on main",Ksr="<!-- red-skills:main-red-repair v1 -->"});function Xsr(e){return{cwd:e.cwd}}function er(e,t){return(e.exec??jt)("gh",t,Xsr(e))}function qr(e){return e.repo?["--repo",e.repo]:[]}async function Ist(e){return(await er(e,["--version"])).code!==127}async function kst(e){let t=await er(e,["auth","status"]);if(t.code===0)return!0;let r=`${t.stdout}
408
- ${t.stderr}`;return tar.test(r)?!0:(ear.test(r),!1)}async function vst(e,t=Je){let r=await er(e,["issue","list",...qr(e),"--label",t,"--state","open","--limit","200","--json","number,title,labels,body"]);if(r.code!==0)return[];let n;try{n=JSON.parse(r.stdout||"[]")}catch{return[]}return Array.isArray(n)?n.map(o=>{let i=o;return{number:Number(i.number??0),title:String(i.title??""),body:String(i.body??""),labels:Array.isArray(i.labels)?i.labels.map(s=>String(s.name??"")):[]}}):[]}async function y4(e){let t=new Map,r=await er(e,["issue","list",...qr(e),"--state","all","--limit","500","--json","number,state,labels,closedAt"]);if(r.code!==0)return t;let n;try{n=JSON.parse(r.stdout||"[]")}catch{return t}if(!Array.isArray(n))return t;for(let o of n){let i=o,s=Number(i.number??0);s&&t.set(s,{state:String(i.state??"OPEN"),labels:Array.isArray(i.labels)?i.labels.map(a=>String(a.name??"")):[],closedAt:i.closedAt??null})}return t}async function wC(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","labels"]);if(r.code!==0)return[];try{let n=JSON.parse(r.stdout);return Array.isArray(n.labels)?n.labels.map(o=>String(o.name??"")):[]}catch{return[]}}async function xa(e,t,r,n){let o=["issue","edit",String(t),...qr(e)];for(let s of r)o.push("--remove-label",s);for(let s of n)o.push("--add-label",s);return(await er(e,o)).code===0}async function ri(e,t,r){await er(e,["issue","comment",String(t),...qr(e),"--body",jr(r)])}function x4(e,t){return e.repo?`repos/${e.repo}/${t}`:t}async function xP(e,t,r){let n=await er(e,["api","-X","POST",x4(e,`issues/${t}/comments`),"-f",`body=${jr(r)}`,"--jq",".id"]),o=Number((n.stdout??"").trim());if(n.code!==0||!Number.isFinite(o))throw new Error(`gh: failed to post claim comment on #${t} (code ${n.code})`);return o}async function lR(e,t){let r=await er(e,["api","--paginate",x4(e,`issues/${t}/comments`),"--jq",".[] | {id: .id, body: .body, createdAt: .created_at}"]);if(r.code!==0)return[];let n=[];for(let o of(r.stdout??"").split(`
409
- `)){let i=o.trim();if(i)try{let s=JSON.parse(i);typeof s.id=="number"&&typeof s.body=="string"&&n.push({id:s.id,body:s.body,createdAt:s.createdAt})}catch{}}return n}async function EP(e,t,r){return(await er(e,["issue","edit",String(t),...qr(e),"--body",jr(r)])).code===0}async function E4(e,t){let r=(t.labels??[]).flatMap(s=>["--label",s]),n=await er(e,["issue","create",...qr(e),"--title",jr(t.title),"--body",jr(t.body),...r]),o=(n.stdout??"").match(/\/issues\/(\d+)\b/),i=o?Number(o[1]):NaN;if(n.code!==0||!Number.isInteger(i)||i<=0)throw new Error(`gh: failed to create issue (code ${n.code}): ${(n.stdout||n.stderr||"").trim()}`);return i}async function Rst(e){let t=await er(e,["issue","list",...qr(e),"--state","open","--limit","50","--search",`"${uR}" in:title`,"--json","number,title,body,labels"]);if(t.code!==0)return null;try{let r=JSON.parse(t.stdout||"[]");if(!Array.isArray(r))return null;let n=r.filter(o=>String(o.title??"")===uR).sort((o,i)=>Number(o.number??0)-Number(i.number??0))[0];return!n||!Number(n.number)?null:{number:Number(n.number),title:String(n.title??""),body:String(n.body??""),labels:Array.isArray(n.labels)?n.labels.map(o=>String(o.name??"")):[]}}catch{return null}}async function _st(e,t){return E4(e,t)}async function Bst(e,t,r){let n=["issue","edit",String(t),...qr(e),"--title",jr(r.title),"--body",jr(r.body)];for(let o of r.labels)n.push("--add-label",o);await er(e,n)}async function Tst(e,t,r){await ri(e,t,r),await Tx(e,t)}async function Dst(e){await er(e,["label","create","runner-error",...qr(e),"--color","B60205","--description","AFK supervisor circuit-tripped; runner was misconfigured"])}async function wl(e,t){await er(e,["label","create",t,...qr(e),"--color","5319E7","--description","AFK terminal-failure reason (observability)"])}async function Tx(e,t){await er(e,["issue","close",String(t),...qr(e),"--reason","completed"])}async function b4(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","number,title,body,labels"]);if(r.code!==0)return null;try{let n=JSON.parse(r.stdout);return{number:Number(n.number??t),title:String(n.title??""),body:String(n.body??""),labels:Array.isArray(n.labels)?n.labels.map(o=>String(o.name??"")):[]}}catch{return null}}async function Ege(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","body"]);if(r.code===0)try{return String(JSON.parse(r.stdout).body??"")}catch{return}}async function Qst(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","url"]);if(r.code!==0)return"";try{return String(JSON.parse(r.stdout).url??"")}catch{return""}}async function gg(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","number,title,url"]);if(r.code===0)try{let n=JSON.parse(r.stdout);return{number:Number(n.number??t),title:String(n.title??""),url:String(n.url??"")}}catch{return}}function rar(e){let t=[];for(let r of e.reactionGroups??[])if(String(r.content??"").toUpperCase()==="THUMBS_UP")for(let n of r.users?.nodes??[]){let o=String(n.login??"").trim();o&&t.push(o)}return t}function nar(e){return e?.executable===!0&&(e.basis==="write-access"||e.basis==="codeowners")}async function oar(e,t){let r=new Map,n=async i=>{if(!i||!t)return;if(r.has(i))return r.get(i);let s;try{s=await t(i)}catch{s=void 0}return r.set(i,s),s},o=[];for(let i of e){let s=i.author?.login?String(i.author.login):void 0,a=i.author?.is_bot===!0,c=i.authorAssociation?String(i.authorAssociation):void 0,u=yP.has((c??"").trim().toUpperCase()),l=a||u?void 0:await n(s),d=(await Promise.all(rar(i).map(f=>n(f)))).some(nar);o.push({body:String(i.body??""),author:s,createdAt:i.createdAt?String(i.createdAt):void 0,sourceTrust:cR({authorAssociation:c,isBot:a,trustVerdict:l,maintainerThumbsUp:d})})}return o}async function S4(e,t,r){let n=await er(e,["issue","view",String(t),...qr(e),"--json","comments"]);if(n.code!==0)return[];let o;try{o=JSON.parse(n.stdout)}catch{return[]}return Array.isArray(o.comments)?oar(o.comments,r):[]}async function Ost(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","state,labels"]);if(r.code!==0)return{ghOk:!1,state:"OPEN",label:null,envelopePosted:!1};try{let n=JSON.parse(r.stdout),o=Array.isArray(n.labels)?n.labels.map(s=>String(s.name??"")):[],i=o.includes(rt)?rt:o.includes(ze)?ze:null;return{ghOk:!0,state:String(n.state??"OPEN"),label:i,envelopePosted:!1}}catch{return{ghOk:!1,state:"OPEN",label:null,envelopePosted:!1}}}async function Nst(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","state,labels,comments"]);if(r.code!==0)return{ghOk:!1,stillRunning:!1,envelopePosted:!1};try{let n=JSON.parse(r.stdout),o=Array.isArray(n.labels)?n.labels.map(a=>String(a.name??"")):[],i=String(n.state??"OPEN")!=="CLOSED"&&o.includes(ze),s=Array.isArray(n.comments)?n.comments.some(a=>String(a.body??"").includes("data-attempt-status")):!1;return{ghOk:!0,stillRunning:i,envelopePosted:s}}catch{return{ghOk:!1,stillRunning:!1,envelopePosted:!1}}}async function bge(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","state"]);if(r.code===0)try{return String(JSON.parse(r.stdout).state??"")||void 0}catch{return}}async function C4(e,t){let r=await er(e,["issue","list",...qr(e),"--state","open","--limit","500","--json","number",...t]);if(r.code!==0)return 0;try{let n=JSON.parse(r.stdout);return Array.isArray(n)?n.length:0}catch{return 0}}function wst(e,t){return`repo:${e} is:issue is:open label:"${t}"`}async function Sge(e){if(!e.repo)return{queue:0,human:0};let r=await er(e,["api","graphql","-f",`query=
410
+ ${t.stderr}`;return tar.test(r)?!0:(ear.test(r),!1)}async function vst(e,t=Je){let r=await er(e,["issue","list",...qr(e),"--label",t,"--state","open","--limit","200","--json","number,title,labels,body"]);if(r.code!==0)return[];let n;try{n=JSON.parse(r.stdout||"[]")}catch{return[]}return Array.isArray(n)?n.map(o=>{let i=o;return{number:Number(i.number??0),title:String(i.title??""),body:String(i.body??""),labels:Array.isArray(i.labels)?i.labels.map(s=>String(s.name??"")):[]}}):[]}async function y4(e){let t=new Map,r=await er(e,["issue","list",...qr(e),"--state","all","--limit","500","--json","number,state,labels,closedAt"]);if(r.code!==0)return t;let n;try{n=JSON.parse(r.stdout||"[]")}catch{return t}if(!Array.isArray(n))return t;for(let o of n){let i=o,s=Number(i.number??0);s&&t.set(s,{state:String(i.state??"OPEN"),labels:Array.isArray(i.labels)?i.labels.map(a=>String(a.name??"")):[],closedAt:i.closedAt??null})}return t}async function wC(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","labels"]);if(r.code!==0)return[];try{let n=JSON.parse(r.stdout);return Array.isArray(n.labels)?n.labels.map(o=>String(o.name??"")):[]}catch{return[]}}async function xa(e,t,r,n){let o=["issue","edit",String(t),...qr(e)];for(let s of r)o.push("--remove-label",s);for(let s of n)o.push("--add-label",s);return(await er(e,o)).code===0}async function ni(e,t,r){await er(e,["issue","comment",String(t),...qr(e),"--body",jr(r)])}function x4(e,t){return e.repo?`repos/${e.repo}/${t}`:t}async function xP(e,t,r){let n=await er(e,["api","-X","POST",x4(e,`issues/${t}/comments`),"-f",`body=${jr(r)}`,"--jq",".id"]),o=Number((n.stdout??"").trim());if(n.code!==0||!Number.isFinite(o))throw new Error(`gh: failed to post claim comment on #${t} (code ${n.code})`);return o}async function lR(e,t){let r=await er(e,["api","--paginate",x4(e,`issues/${t}/comments`),"--jq",".[] | {id: .id, body: .body, createdAt: .created_at}"]);if(r.code!==0)return[];let n=[];for(let o of(r.stdout??"").split(`
411
+ `)){let i=o.trim();if(i)try{let s=JSON.parse(i);typeof s.id=="number"&&typeof s.body=="string"&&n.push({id:s.id,body:s.body,createdAt:s.createdAt})}catch{}}return n}async function EP(e,t,r){return(await er(e,["issue","edit",String(t),...qr(e),"--body",jr(r)])).code===0}async function E4(e,t){let r=(t.labels??[]).flatMap(s=>["--label",s]),n=await er(e,["issue","create",...qr(e),"--title",jr(t.title),"--body",jr(t.body),...r]),o=(n.stdout??"").match(/\/issues\/(\d+)\b/),i=o?Number(o[1]):NaN;if(n.code!==0||!Number.isInteger(i)||i<=0)throw new Error(`gh: failed to create issue (code ${n.code}): ${(n.stdout||n.stderr||"").trim()}`);return i}async function Rst(e){let t=await er(e,["issue","list",...qr(e),"--state","open","--limit","50","--search",`"${uR}" in:title`,"--json","number,title,body,labels"]);if(t.code!==0)return null;try{let r=JSON.parse(t.stdout||"[]");if(!Array.isArray(r))return null;let n=r.filter(o=>String(o.title??"")===uR).sort((o,i)=>Number(o.number??0)-Number(i.number??0))[0];return!n||!Number(n.number)?null:{number:Number(n.number),title:String(n.title??""),body:String(n.body??""),labels:Array.isArray(n.labels)?n.labels.map(o=>String(o.name??"")):[]}}catch{return null}}async function _st(e,t){return E4(e,t)}async function Bst(e,t,r){let n=["issue","edit",String(t),...qr(e),"--title",jr(r.title),"--body",jr(r.body)];for(let o of r.labels)n.push("--add-label",o);await er(e,n)}async function Tst(e,t,r){await ni(e,t,r),await Tx(e,t)}async function Dst(e){await er(e,["label","create","runner-error",...qr(e),"--color","B60205","--description","AFK supervisor circuit-tripped; runner was misconfigured"])}async function wl(e,t){await er(e,["label","create",t,...qr(e),"--color","5319E7","--description","AFK terminal-failure reason (observability)"])}async function Tx(e,t){await er(e,["issue","close",String(t),...qr(e),"--reason","completed"])}async function b4(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","number,title,body,labels"]);if(r.code!==0)return null;try{let n=JSON.parse(r.stdout);return{number:Number(n.number??t),title:String(n.title??""),body:String(n.body??""),labels:Array.isArray(n.labels)?n.labels.map(o=>String(o.name??"")):[]}}catch{return null}}async function Ege(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","body"]);if(r.code===0)try{return String(JSON.parse(r.stdout).body??"")}catch{return}}async function Qst(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","url"]);if(r.code!==0)return"";try{return String(JSON.parse(r.stdout).url??"")}catch{return""}}async function gg(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","number,title,url"]);if(r.code===0)try{let n=JSON.parse(r.stdout);return{number:Number(n.number??t),title:String(n.title??""),url:String(n.url??"")}}catch{return}}function rar(e){let t=[];for(let r of e.reactionGroups??[])if(String(r.content??"").toUpperCase()==="THUMBS_UP")for(let n of r.users?.nodes??[]){let o=String(n.login??"").trim();o&&t.push(o)}return t}function nar(e){return e?.executable===!0&&(e.basis==="write-access"||e.basis==="codeowners")}async function oar(e,t){let r=new Map,n=async i=>{if(!i||!t)return;if(r.has(i))return r.get(i);let s;try{s=await t(i)}catch{s=void 0}return r.set(i,s),s},o=[];for(let i of e){let s=i.author?.login?String(i.author.login):void 0,a=i.author?.is_bot===!0,c=i.authorAssociation?String(i.authorAssociation):void 0,u=yP.has((c??"").trim().toUpperCase()),l=a||u?void 0:await n(s),d=(await Promise.all(rar(i).map(f=>n(f)))).some(nar);o.push({body:String(i.body??""),author:s,createdAt:i.createdAt?String(i.createdAt):void 0,sourceTrust:cR({authorAssociation:c,isBot:a,trustVerdict:l,maintainerThumbsUp:d})})}return o}async function S4(e,t,r){let n=await er(e,["issue","view",String(t),...qr(e),"--json","comments"]);if(n.code!==0)return[];let o;try{o=JSON.parse(n.stdout)}catch{return[]}return Array.isArray(o.comments)?oar(o.comments,r):[]}async function Ost(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","state,labels"]);if(r.code!==0)return{ghOk:!1,state:"OPEN",label:null,envelopePosted:!1};try{let n=JSON.parse(r.stdout),o=Array.isArray(n.labels)?n.labels.map(s=>String(s.name??"")):[],i=o.includes(rt)?rt:o.includes(ze)?ze:null;return{ghOk:!0,state:String(n.state??"OPEN"),label:i,envelopePosted:!1}}catch{return{ghOk:!1,state:"OPEN",label:null,envelopePosted:!1}}}async function Nst(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","state,labels,comments"]);if(r.code!==0)return{ghOk:!1,stillRunning:!1,envelopePosted:!1};try{let n=JSON.parse(r.stdout),o=Array.isArray(n.labels)?n.labels.map(a=>String(a.name??"")):[],i=String(n.state??"OPEN")!=="CLOSED"&&o.includes(ze),s=Array.isArray(n.comments)?n.comments.some(a=>String(a.body??"").includes("data-attempt-status")):!1;return{ghOk:!0,stillRunning:i,envelopePosted:s}}catch{return{ghOk:!1,stillRunning:!1,envelopePosted:!1}}}async function bge(e,t){let r=await er(e,["issue","view",String(t),...qr(e),"--json","state"]);if(r.code===0)try{return String(JSON.parse(r.stdout).state??"")||void 0}catch{return}}async function C4(e,t){let r=await er(e,["issue","list",...qr(e),"--state","open","--limit","500","--json","number",...t]);if(r.code!==0)return 0;try{let n=JSON.parse(r.stdout);return Array.isArray(n)?n.length:0}catch{return 0}}function wst(e,t){return`repo:${e} is:issue is:open label:"${t}"`}async function Sge(e){if(!e.repo)return{queue:0,human:0};let r=await er(e,["api","graphql","-f",`query=
410
412
  query($ready: String!, $human: String!) {
411
413
  ready: search(type: ISSUE, query: $ready) { issueCount }
412
414
  human: search(type: ISSUE, query: $human) { issueCount }
@@ -494,19 +496,19 @@ ${n}`,"</details>"].join(`
494
496
 
495
497
  Inner agent emitted a completion sentinel with this file still dirty; AFK committed it so the feedback gate and landing see the work.`;(await Tt(o,["commit","--no-verify","-m",l,"--",c])).code===0&&(a+=1)}return a>0&&await Tt(o,["push","--force-with-lease",r,`HEAD:refs/heads/${t}`]),a}async function _ge(e,t,r="origin"){if(!t)return{ok:!1,error:"empty branch"};let n=await Tt(e,["push",r,`refs/heads/${t}:refs/heads/${t}`]);return n.code===0?{ok:!0}:{ok:!1,error:(n.stderr||n.stdout||`git push exited ${n.code}`).trim()}}async function Kp(e,t){let r=await Tt(e,["ls-remote","--heads","origin",`refs/heads/${t}*`]);if(r.code!==0)return[];let n=[];for(let o of r.stdout.split(`
496
498
  `)){let i=/^([0-9a-fA-F]+)\trefs\/heads\/(.+)$/.exec(o);if(!i||!i[1]||!i[2])continue;let s={branch:i[2]},a=await har(e,i[1],i[2]);a!==void 0&&(s.commitS=a),n.push(s)}return n}async function har(e,t,r){let n=async()=>{let i=await Tt(e,["show","-s","--format=%ct",t]),s=Number((i.stdout??"").trim());return i.code===0&&Number.isFinite(s)?s:void 0},o=await n();return o!==void 0?o:(await Tt(e,["fetch","--quiet","--no-tags","origin",`refs/heads/${r}:refs/remotes/origin/${r}`]),n())}tf();import{createReadStream as Uar}from"node:fs";import{mkdir as $ar,readFile as Har,rename as War,stat as jar,writeFile as qar}from"node:fs/promises";import{dirname as Gar}from"node:path";function zar(e){if(e===null||typeof e!="object")return null;let t=e,r=Number(t.size),n=Number(t.lines);return!Number.isFinite(r)||r<0||!Number.isFinite(n)||n<0?null:{size:r,lines:n}}async function Var(e){try{let t=JSON.parse(await Har(e,"utf8"));if(t===null||typeof t!="object"||Array.isArray(t))return{};let r={};for(let[n,o]of Object.entries(t)){let i=zar(o);i!==null&&(r[n]=i)}return r}catch{return{}}}async function Yar(e,t){await $ar(Gar(e),{recursive:!0});let r=`${e}.tmp.${process.pid}.${Date.now()}`;await qar(r,`${JSON.stringify(t)}
497
- `,"utf8"),await War(r,e)}function Jar(e){let t=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(t+=1);return t}async function Kar(e,t){return await new Promise((r,n)=>{let o=[],i=Uar(e,{start:t,encoding:"utf8"});i.on("data",s=>o.push(Buffer.from(s))),i.on("error",n),i.on("end",()=>r(Buffer.concat(o).toString("utf8")))})}async function Zar(e,t){let r;try{r=(await jar(e)).size}catch{return null}let n=t===void 0||r<t.size,o=n?0:t.size,i=r>o?await Kar(e,o):"",s=Jar(i),a=n?s:t.lines+s;return{count:{lines:a,newLines:s},cursor:{size:r,lines:a}}}async function Sat(e,t){let r=await Var(e),n={},o=new Map;for(let i of t){let s=await Zar(i,r[i]);s!==null&&(o.set(i,s.count),n[i]=s.cursor)}return await Yar(e,n).catch(()=>{}),o}var Xar=e=>new Promise(t=>setTimeout(t,e));function ni(e){try{return process.kill(e,0),!0}catch{return!1}}function ecr(e,t){try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}var tcr={isAlive:ni,signal:ecr,sleep:Xar};async function Cg(e,t={}){let r=t.io??tcr,n=t.pollMs??100,o=t.graceTries??20,i=t.killTries??10;r.signal(e,"SIGTERM");for(let s=0;s<o;s+=1){if(!r.isAlive(e))return!0;await r.sleep(n)}r.signal(e,"SIGKILL");for(let s=0;s<i;s+=1){if(!r.isAlive(e))return!0;await r.sleep(n)}return!r.isAlive(e)}pR();tf();nu();Kd();import{readdirSync as rcr,readFileSync as Hge,statSync as Iat}from"node:fs";import{join as Wge,dirname as rf,basename as jge}from"node:path";function ncr(e){return jge(rf(e))}function Cat(e){let t=/^[1-9][0-9]*-a([1-9][0-9]*)$/.exec(ncr(e));return t?Number(t[1]):0}function ocr(e){try{return Iat(rf(e)).mtimeMs}catch{return 0}}function wat(e){let t=e.state.current.started_at||e.state.started_at;if(t){let r=Date.parse(t);if(!Number.isNaN(r))return r}return ocr(e.path)}function icr(e){return e.state.worker_id||jge(rf(rf(e.path)))}function scr(e,t){let r=wat(e)-wat(t);if(r!==0)return r;let n=Cat(e.path)-Cat(t.path);return n!==0?n:e.path.localeCompare(t.path)}function F4(e){let t=new Map;for(let r of e){if(!r.renderableLive)continue;let n=icr(r),o=t.get(n);(o===void 0||scr(r,o)>0)&&t.set(n,r)}return[...t.values()]}function acr(e){let t=rf(e),r=rf(t),n;try{n=rcr(r)}catch{return!0}let o=null,i=-1;for(let s of n){let a=Wge(r,s);try{let c=Iat(a);if(!c.isDirectory())continue;let u=c.mtimeMs;(u>i||u===i&&a>(o??""))&&(i=u,o=a)}catch{}}return o===null||o===t}var ccr=18e4;function ucr(e){try{let t=Hge(e,"utf-8"),r=fg(t);return r.length===0?void 0:r.reduce((n,o)=>o.at>n?o.at:n,r[0].at)}catch{return}}function lcr(e){return e.status==="stalled"?"dead":e.status==="alive"&&e.laneFresh?"active":"quiet-but-live"}function Dx(e,t={}){let r;try{r=Hge(e,"utf8")}catch{return null}let n;try{n=IC(JSON.parse(r))}catch{return null}let o=t.nowMs??Date.now(),i=t.laneRecencyMs!==void 0?t.laneRecencyMs:ucr(Wge(rf(e),Vp)),{crossCheckArmed:s}=vx({sandboxTag:t.sandboxTag??"none"}),a=s&&n.pid>0?_x({agentPid:n.pid,snapshot:t.psSnapshot}):void 0,c=Rx({laneRecencyMs:i,now:o,laneIdleMs:ccr,crossCheckArmed:s,hasLiveDescendants:a}),u=c,l=!1;if(c.status==="stalled"&&n.pid===0&&acr(e)){let A=Wge(rf(rf(e)),"worker.pid"),E;if(t.workerPidContent!==void 0)E=t.workerPidContent;else try{E=Hge(A,"utf8")}catch{E=null}let y=E?parseInt(E.trim(),10):NaN;if(Number.isFinite(y)&&y>0){let b=t.kill??(I=>(process.kill(I,0),!0)),w=!1;try{w=b(y,0)}catch{w=!1}if(w){l=!0,u={status:"alive",laneFresh:!1,crossCheckArmed:!1,reason:`state.pid=0 but worker.pid=${y} is alive (isolation worker)`};let I=t.identityContent!==void 0?Bge(t.identityContent):mat(rf(e));if(I&&(!n.worker_id&&I.worker_id&&(n.worker_id=I.worker_id),!n.runner&&I.runner&&(n.runner=I.runner),!n.origin&&I.origin&&(n.origin=I.origin),!n.started_at&&I.started_at&&(n.started_at=I.started_at),!n.current.started_at&&I.started_at&&(n.current.started_at=I.started_at),(n.current.number===""||n.current.number===void 0||n.current.number===null)&&I.number!==""&&I.number!==void 0&&I.number!==null&&(n.current.number=I.number)),n.current.number===""||n.current.number===void 0||n.current.number===null){let v=jge(rf(e)),k=/^([1-9][0-9]*)-a[1-9][0-9]*$/.exec(v);k&&(n.current.number=Number(k[1]))}}}}let d=lcr(u),f=u.status!=="stalled",p=d==="active",m=gat(n,t.kill,t.pidStartTime),g=u.status!=="stalled"&&(m||l);return{path:e,state:n,live:f,active:p,liveness:d,livenessVerdict:u,pidIdentityLive:m,hostPidLive:l,renderableLive:g}}async function qge(e,t={}){let r=t.glob??Mge,n=t.nowMs??Date.now(),o=await r(e),i=[];for(let s of o){let a=Dx(s,{nowMs:n,kill:t.kill,pidStartTime:t.pidStartTime,sandboxTag:t.sandboxTag,psSnapshot:t.psSnapshot,workerPidContent:t.workerPidContent,identityContent:t.identityContent});a!==null&&i.push(a)}return i}async function AR(e,t={}){let r=t.nowMs??Date.now(),n=[];for(let o of mR(e))n.push(...await qge(o,{...t,nowMs:r}));return n}nu();un();var kat=7*86400,Gge=1*86400,dcr=14*86400,fcr=5,pcr=/^[0-9]+$/;function vat(e){return e.hasStateFile?e.ghOk?e.issueState==="CLOSED"?{kind:"remove"}:e.label===rt?{kind:"keep-until",ttlS:e.envelopePosted?Gge:kat}:e.label===ze?{kind:"restore-and-remove"}:{kind:"remove"}:{kind:"keep-until",ttlS:e.hasStateFile?kat:Gge}:{kind:"keep-until",ttlS:Gge}}function Rat(e,t){let r=t.ttlS,n=t.keep,o=t.nowS,i=[];for(let c of e){if(c.live)continue;let u=Xd(c.path);u&&i.push({dir:c,attempt:u.attempt})}let s=[],a=[];for(let c of i)o-c.dir.mtimeS>r?s.push(c.dir):a.push(c);if(a.length>n){let c=[...a].sort((l,d)=>l.attempt-d.attempt),u=a.length-n;for(let l=0;l<u;l++)s.push(c[l].dir)}return s}function _at(e){let t=[];for(let r of e)r.workerPidAlive||t.push({attemptDir:r.attemptDir,worktreePath:r.worktreePath,removeWorktree:!0,reclaimDir:!r.preserved});return t}function Bat(e,t){if(e!==void 0&&pcr.test(e)){let r=Number(e);if(r>0)return r}return t}function Tat(e=process.env){return Bat(e.RED_AFK_ATTEMPT_TTL_S,dcr)}function Dat(e=process.env){return Bat(e.RED_AFK_ATTEMPT_KEEP,fcr)}_C();ru();un();nu();var bcr="<!-- afk:claim",Lat=/<!--\s*afk:claim\s+([^>]*?)\s*-->/g;function Kge(e){return e.replace(/[\s>]/g,"_")}function Scr(e,t,r){let n=t.map(s=>`\`${s}\``).join(", "),o=`\u{1F916} AFK cross-host recovery: worker \`${e.worker}\` released ${t.length===1?"a stale claim":"stale claims"} held by ${n} (owner stopped refreshing past the staleness window) and re-claimed this issue.`;if(!r)return o;let i=t.map(s=>{let a=r(s);return a?`\`${s}\`: ${a}`:null}).filter(s=>s!==null);return i.length===0?o:`${o}
499
+ `,"utf8"),await War(r,e)}function Jar(e){let t=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(t+=1);return t}async function Kar(e,t){return await new Promise((r,n)=>{let o=[],i=Uar(e,{start:t,encoding:"utf8"});i.on("data",s=>o.push(Buffer.from(s))),i.on("error",n),i.on("end",()=>r(Buffer.concat(o).toString("utf8")))})}async function Zar(e,t){let r;try{r=(await jar(e)).size}catch{return null}let n=t===void 0||r<t.size,o=n?0:t.size,i=r>o?await Kar(e,o):"",s=Jar(i),a=n?s:t.lines+s;return{count:{lines:a,newLines:s},cursor:{size:r,lines:a}}}async function Sat(e,t){let r=await Var(e),n={},o=new Map;for(let i of t){let s=await Zar(i,r[i]);s!==null&&(o.set(i,s.count),n[i]=s.cursor)}return await Yar(e,n).catch(()=>{}),o}var Xar=e=>new Promise(t=>setTimeout(t,e));function oi(e){try{return process.kill(e,0),!0}catch{return!1}}function ecr(e,t){try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}var tcr={isAlive:oi,signal:ecr,sleep:Xar};async function Cg(e,t={}){let r=t.io??tcr,n=t.pollMs??100,o=t.graceTries??20,i=t.killTries??10;r.signal(e,"SIGTERM");for(let s=0;s<o;s+=1){if(!r.isAlive(e))return!0;await r.sleep(n)}r.signal(e,"SIGKILL");for(let s=0;s<i;s+=1){if(!r.isAlive(e))return!0;await r.sleep(n)}return!r.isAlive(e)}pR();tf();nu();Kd();import{readdirSync as rcr,readFileSync as Hge,statSync as Iat}from"node:fs";import{join as Wge,dirname as rf,basename as jge}from"node:path";function ncr(e){return jge(rf(e))}function Cat(e){let t=/^[1-9][0-9]*-a([1-9][0-9]*)$/.exec(ncr(e));return t?Number(t[1]):0}function ocr(e){try{return Iat(rf(e)).mtimeMs}catch{return 0}}function wat(e){let t=e.state.current.started_at||e.state.started_at;if(t){let r=Date.parse(t);if(!Number.isNaN(r))return r}return ocr(e.path)}function icr(e){return e.state.worker_id||jge(rf(rf(e.path)))}function scr(e,t){let r=wat(e)-wat(t);if(r!==0)return r;let n=Cat(e.path)-Cat(t.path);return n!==0?n:e.path.localeCompare(t.path)}function F4(e){let t=new Map;for(let r of e){if(!r.renderableLive)continue;let n=icr(r),o=t.get(n);(o===void 0||scr(r,o)>0)&&t.set(n,r)}return[...t.values()]}function acr(e){let t=rf(e),r=rf(t),n;try{n=rcr(r)}catch{return!0}let o=null,i=-1;for(let s of n){let a=Wge(r,s);try{let c=Iat(a);if(!c.isDirectory())continue;let u=c.mtimeMs;(u>i||u===i&&a>(o??""))&&(i=u,o=a)}catch{}}return o===null||o===t}var ccr=18e4;function ucr(e){try{let t=Hge(e,"utf-8"),r=fg(t);return r.length===0?void 0:r.reduce((n,o)=>o.at>n?o.at:n,r[0].at)}catch{return}}function lcr(e){return e.status==="stalled"?"dead":e.status==="alive"&&e.laneFresh?"active":"quiet-but-live"}function Dx(e,t={}){let r;try{r=Hge(e,"utf8")}catch{return null}let n;try{n=IC(JSON.parse(r))}catch{return null}let o=t.nowMs??Date.now(),i=t.laneRecencyMs!==void 0?t.laneRecencyMs:ucr(Wge(rf(e),Vp)),{crossCheckArmed:s}=vx({sandboxTag:t.sandboxTag??"none"}),a=s&&n.pid>0?_x({agentPid:n.pid,snapshot:t.psSnapshot}):void 0,c=Rx({laneRecencyMs:i,now:o,laneIdleMs:ccr,crossCheckArmed:s,hasLiveDescendants:a}),u=c,l=!1;if(c.status==="stalled"&&n.pid===0&&acr(e)){let A=Wge(rf(rf(e)),"worker.pid"),E;if(t.workerPidContent!==void 0)E=t.workerPidContent;else try{E=Hge(A,"utf8")}catch{E=null}let y=E?parseInt(E.trim(),10):NaN;if(Number.isFinite(y)&&y>0){let b=t.kill??(I=>(process.kill(I,0),!0)),w=!1;try{w=b(y,0)}catch{w=!1}if(w){l=!0,u={status:"alive",laneFresh:!1,crossCheckArmed:!1,reason:`state.pid=0 but worker.pid=${y} is alive (isolation worker)`};let I=t.identityContent!==void 0?Bge(t.identityContent):mat(rf(e));if(I&&(!n.worker_id&&I.worker_id&&(n.worker_id=I.worker_id),!n.runner&&I.runner&&(n.runner=I.runner),!n.origin&&I.origin&&(n.origin=I.origin),!n.started_at&&I.started_at&&(n.started_at=I.started_at),!n.current.started_at&&I.started_at&&(n.current.started_at=I.started_at),(n.current.number===""||n.current.number===void 0||n.current.number===null)&&I.number!==""&&I.number!==void 0&&I.number!==null&&(n.current.number=I.number)),n.current.number===""||n.current.number===void 0||n.current.number===null){let v=jge(rf(e)),k=/^([1-9][0-9]*)-a[1-9][0-9]*$/.exec(v);k&&(n.current.number=Number(k[1]))}}}}let d=lcr(u),f=u.status!=="stalled",p=d==="active",m=gat(n,t.kill,t.pidStartTime),g=u.status!=="stalled"&&(m||l);return{path:e,state:n,live:f,active:p,liveness:d,livenessVerdict:u,pidIdentityLive:m,hostPidLive:l,renderableLive:g}}async function qge(e,t={}){let r=t.glob??Mge,n=t.nowMs??Date.now(),o=await r(e),i=[];for(let s of o){let a=Dx(s,{nowMs:n,kill:t.kill,pidStartTime:t.pidStartTime,sandboxTag:t.sandboxTag,psSnapshot:t.psSnapshot,workerPidContent:t.workerPidContent,identityContent:t.identityContent});a!==null&&i.push(a)}return i}async function AR(e,t={}){let r=t.nowMs??Date.now(),n=[];for(let o of mR(e))n.push(...await qge(o,{...t,nowMs:r}));return n}nu();un();var kat=7*86400,Gge=1*86400,dcr=14*86400,fcr=5,pcr=/^[0-9]+$/;function vat(e){return e.hasStateFile?e.ghOk?e.issueState==="CLOSED"?{kind:"remove"}:e.label===rt?{kind:"keep-until",ttlS:e.envelopePosted?Gge:kat}:e.label===ze?{kind:"restore-and-remove"}:{kind:"remove"}:{kind:"keep-until",ttlS:e.hasStateFile?kat:Gge}:{kind:"keep-until",ttlS:Gge}}function Rat(e,t){let r=t.ttlS,n=t.keep,o=t.nowS,i=[];for(let c of e){if(c.live)continue;let u=Xd(c.path);u&&i.push({dir:c,attempt:u.attempt})}let s=[],a=[];for(let c of i)o-c.dir.mtimeS>r?s.push(c.dir):a.push(c);if(a.length>n){let c=[...a].sort((l,d)=>l.attempt-d.attempt),u=a.length-n;for(let l=0;l<u;l++)s.push(c[l].dir)}return s}function _at(e){let t=[];for(let r of e)r.workerPidAlive||t.push({attemptDir:r.attemptDir,worktreePath:r.worktreePath,removeWorktree:!0,reclaimDir:!r.preserved});return t}function Bat(e,t){if(e!==void 0&&pcr.test(e)){let r=Number(e);if(r>0)return r}return t}function Tat(e=process.env){return Bat(e.RED_AFK_ATTEMPT_TTL_S,dcr)}function Dat(e=process.env){return Bat(e.RED_AFK_ATTEMPT_KEEP,fcr)}_C();ru();un();nu();var bcr="<!-- afk:claim",Lat=/<!--\s*afk:claim\s+([^>]*?)\s*-->/g;function Kge(e){return e.replace(/[\s>]/g,"_")}function Scr(e,t,r){let n=t.map(s=>`\`${s}\``).join(", "),o=`\u{1F916} AFK cross-host recovery: worker \`${e.worker}\` released ${t.length===1?"a stale claim":"stale claims"} held by ${n} (owner stopped refreshing past the staleness window) and re-claimed this issue.`;if(!r)return o;let i=t.map(s=>{let a=r(s);return a?`\`${s}\`: ${a}`:null}).filter(s=>s!==null);return i.length===0?o:`${o}
498
500
 
499
501
  Predecessor cause${i.length===1?"":"s"} (process-safety diagnostic): ${i.join("; ")}.`}function yR(e,t="claim"){let r=["v1",`worker=${Kge(e.worker)}`,`kind=${t}`];e.runner&&r.push(`runner=${Kge(e.runner)}`),e.createdAt&&r.push(`ts=${Kge(e.createdAt)}`);let n=`${bcr} ${r.join(" ")} -->`,o=t==="claim"?`\u{1F916} AFK claim by worker \`${e.worker}\`${e.runner?` (runner \`${e.runner}\`)`:""}.`:`\u{1F916} AFK worker \`${e.worker}\` conceded this issue (lost the claim race or released).`;return`${n}
500
502
  ${o}`}function Ccr(e){let t=new Map;for(let r of e.split(/\s+/)){let n=r.indexOf("=");n<=0||t.set(r.slice(0,n),r.slice(n+1))}return t}function FP(e){let t=[];for(let r of e){if(typeof r.id!="number"||!Number.isFinite(r.id)||typeof r.body!="string")continue;Lat.lastIndex=0;let n;for(;(n=Lat.exec(r.body))!==null;){let o=Ccr(n[1]),i=o.get("worker");if(!i)continue;let a=o.get("kind")==="concede"?"concede":"claim";t.push({commentId:r.id,worker:i,kind:a,runner:o.get("runner"),createdAt:o.get("ts")??r.createdAt})}}return t}function wcr(e,t,r={}){let n=r.isStale??(()=>!1),o=new Map,i=l=>{if(!Number.isFinite(l.commentId)||l.worker==="")return;let d=o.get(l.worker);if(d===void 0){o.set(l.worker,{earliestClaimId:l.kind==="claim"?l.commentId:null,latestId:l.commentId,latestKind:l.kind,latestRecord:l});return}l.kind==="claim"&&(d.earliestClaimId===null||l.commentId<d.earliestClaimId)&&(d.earliestClaimId=l.commentId),l.commentId>=d.latestId&&(d.latestId=l.commentId,d.latestKind=l.kind,d.latestRecord=l)};for(let l of e)i(l);i({commentId:t.commentId,worker:t.worker,kind:"claim",runner:t.runner,createdAt:t.createdAt});let s=[],a=[];for(let[l,d]of o)if(d.latestKind!=="concede"&&d.earliestClaimId!==null){if(n(d.latestRecord)){a.push({worker:l,claimId:d.earliestClaimId});continue}s.push({worker:l,claimId:d.earliestClaimId})}if(s.length===0)return{verdict:"lost",winner:null,reason:"no live claim contends",recovered:[]};s.sort((l,d)=>l.claimId-d.claimId||(l.worker<d.worker?-1:1));let c=s[0],u=c.worker===t.worker?a.filter(l=>l.claimId<c.claimId).map(l=>l.worker).sort():[];return c.worker===t.worker?{verdict:"won",winner:c.worker,winnerClaimId:c.claimId,winnerCreatedAt:o.get(c.worker)?.latestRecord.createdAt,reason:s.length===1?"solo claim":`earliest of ${s.length} live claims (id ${c.claimId})`,recovered:u}:{verdict:"lost",winner:c.worker,winnerClaimId:c.claimId,winnerCreatedAt:o.get(c.worker)?.latestRecord.createdAt,reason:`worker ${c.worker} holds earlier claim (id ${c.claimId} < our ${t.commentId})`,recovered:[]}}async function Uat(e,t,r,n={}){let o=await e.postClaim(r,yR({worker:t.worker,runner:t.runner,createdAt:t.createdAt},"claim")),i=await e.listClaims(r),s=FP(i),a=wcr(s,{...t,commentId:o},n);if(a.verdict==="lost"&&!n.suppressConcede&&await e.concede(r,yR({worker:t.worker,runner:t.runner},"concede")),a.verdict==="won"&&a.recovered.length>0&&e.audit)try{await e.audit(r,Scr({worker:t.worker},a.recovered,n.deathFor))}catch{}return a}async function TC(e){let{gh:t}=await Promise.resolve().then(()=>(bn(),hg)),r=await t(["repo","view","--json","nameWithOwner","-q",".nameWithOwner"],{cwd:e});return r.code===0?r.stdout.trim():""}async function Ns(e=process.cwd()){let t=await TC(e);return{root:e,repo:t,remote:"origin"}}function Mr(e){let t=Sn(e,".red","tmp"),r=Sn(e,".red","state");return{tmpDir:t,stateDir:r,workersRoot:Sn(t,"workers"),historyPath:Sn(r,"afk-history.jsonl"),fleetStatePath:Sn(t,"afk-supervisor.state.json"),fleetFirehosePath:Sn(t,"afk-supervisor.log.jsonl"),monitorLogCursorPath:Sn(t,"monitor-log-cursors.json"),gitignorePath:Sn(e,".gitignore"),configPath:Sn(e,".red","config.yaml")}}var Hat=["none","docker","podman"];function Xp(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}function Rcr(e,t){let r={maxTotalTokens:Xp(e.RED_AFK_ATTEMPT_MAX_TOKENS)??Xp(t("afk.attempt.max_tokens")),maxCostUsd:Xp(e.RED_AFK_ATTEMPT_MAX_COST_USD)??Xp(t("afk.attempt.max_cost_usd")),maxToolCalls:Xp(e.RED_AFK_ATTEMPT_MAX_TOOL_CALLS)??Xp(t("afk.attempt.max_tool_calls")),maxWaitingWindows:Xp(e.RED_AFK_ATTEMPT_MAX_WAITING_WINDOWS)??Xp(t("afk.attempt.max_waiting_windows"))};return r.maxTotalTokens!==void 0||r.maxCostUsd!==void 0||r.maxToolCalls!==void 0||r.maxWaitingWindows!==void 0?r:void 0}function eAe(e,t=process.env,r){let n=Mr(e),o=Sr(n.configPath,{warn:()=>{}}),i=(t.RED_AFK_SANDBOX??"").trim(),s=Hat.includes(i)?i:Pe(o,"afk.sandbox"),a=Hat.includes(s)?s:"none",c=Pe(o,"afk.default_runner")||"claude",u=r??(Tg(c)?c:"claude"),l=Ia(o,u,"think",t),d=mP(t.RED_AFK_MAX_ITERATIONS)??mP(Pe(o,"afk.max_iterations")),f=pP(t.RED_AFK_ATTEMPT_TIMEOUT_S)??pP(Pe(o,"afk.attempt_timeout")),p=cge(t),g=(t.RED_AFK_FEEDBACK_REBASE??"").trim()==="1"||Pe(o,"afk.feedback.rebase_on_base")==="true"?Pe(o,"dev.lock.branch")||Pe(o,"dev.trunk")||"main":void 0,A=Rcr(t,E=>Pe(o,E));return{sandbox:a,defaultRunner:c,model:l.model,effort:l.effort,maxIterations:d,attemptTimeoutSeconds:f,laneIdle:p,feedbackRebaseBase:g,attemptBudget:A}}function _cr(e,t){let r=Sn(e,Vp),n;try{let s=BC(r,"utf-8"),a=fg(s);a.length>0&&(n=a.reduce((c,u)=>u.at>c?u.at:c,a[0].at))}catch{}let{crossCheckArmed:o}=vx({sandboxTag:"none"}),i=o?_x({agentPid:process.pid}):void 0;try{return Rx({laneRecencyMs:n,now:Date.now(),laneIdleMs:t,crossCheckArmed:o,hasLiveDescendants:i})}catch{return null}}function Bcr(e){let t=!!e.branch,r=e.sandbox==="none"&&t&&!!e.attemptDir;return{guardArmed:t,laneArmed:r}}async function Tcr(e,t){let r=await vP(e,t);if(r){let n=await Kst({...e,cwd:r});if(n)return n}return Yp(e,t)}function zat(e,t=process.env,r,n,o,i,s){let a=null;return async c=>{let{runAgent:u,defaultSandcastleDeps:l,parseIdleTimeout:d,DEFAULT_ATTEMPT_TIMEOUT_S:f,DEFAULT_ATTEMPT_HARD_CAP_S:p,parseAttemptHardCap:m}=await Promise.resolve().then(()=>(CC(),mst));a||(a=l());let g=await a,A=d(t.RED_AFK_IDLE_TIMEOUT_S),E=c.sandboxMode??e,y=c.attemptTimeoutSeconds??n??pP(t.RED_AFK_ATTEMPT_TIMEOUT_S)??f,b=Math.max(c.attemptHardCapSeconds??m(t.RED_AFK_ATTEMPT_HARD_CAP_S)??p,y),w=o??cge(t),I=c.cwd,{guardArmed:v,laneArmed:k}=Bcr({sandbox:E,branch:c.branch,attemptDir:I});return u(g,{...c,sandboxMode:E,maxIterations:c.maxIterations??r??mP(t.RED_AFK_MAX_ITERATIONS),idleTimeoutSeconds:c.idleTimeoutSeconds??A,...v?{attemptTimeoutSeconds:y,attemptHardCapSeconds:b,headProbe:()=>Tcr({cwd:c.cwd??process.cwd()},c.branch),progressProbe:async()=>{let R={cwd:c.cwd??process.cwd()},B=await vP(R,c.branch);if(!B)return;let L=c.base?`origin/${c.base}`:"origin/main",{added:D,removed:ee}=await Ige({cwd:B},L);return D+ee}}:{},...v&&s?{budgetUsage:s}:{},...v&&i&&s?{budget:i}:{},...k&&I?{laneIdleThresholdSeconds:w.stallThresholdS,laneIdleKillThresholdSeconds:w.stallKillThresholdS,laneIdlePollSeconds:w.stallPollS,livenessVerdictProbe:()=>_cr(I,w.stallThresholdS*1e3),inspectTree:()=>p4(process.pid)}:{}})}}var Dcr=new Set(["open","half-open","idle-parked"]);function Qcr(e){if(e===null||typeof e!="object")return null;let t=e,r=Number(t.epoch??0);if(!Number.isFinite(r)||r<=0)return null;let n=Number(t.last_progress_epoch??0),o;if(Array.isArray(t.slot_details)){o=[];for(let i of t.slot_details){if(i===null||typeof i!="object")continue;let s=i,a=Number(s.index??-1);if(!Number.isFinite(a)||a<0)continue;let c=s.status;if(typeof c!="string"||!Dcr.has(c))continue;let u=s.retry_at!==void 0?Number(s.retry_at):void 0,l=u!==void 0&&Number.isFinite(u)?u:void 0;o.push({index:a,status:c,...l!==void 0?{retryAt:l}:{}})}}return{ts:typeof t.ts=="string"?t.ts:"",epoch:r,lastProgressEpoch:Number.isFinite(n)&&n>0?n:void 0,runner:typeof t.runner=="string"?t.runner:"",readyForAgent:Number(t.ready_for_agent??0)||0,slotsBusy:Number(t.slots?.busy??0)||0,slotsFree:Number(t.slots?.free??0)||0,slotsTotal:Number(t.slots?.total??0)||0,slotsParked:Number(t.slots?.parked??0)||0,spawnsThisTick:Number(t.spawns_this_tick??0)||0,...o!==void 0?{slotDetails:o}:{}}}async function UP(e){let t=await kl(e);if(t===null)return null;try{return Qcr(JSON.parse(t))}catch{return null}}async function Ocr(e,t,r="",n={}){let o=n.exists??(m=>qat(m)),i=n.readWorkerPid??(m=>{try{return BC(Sn(m,"worker.pid"),"utf8")}catch{return null}}),s=n.killAlive??(m=>{try{return process.kill(m,0),!0}catch{return!1}}),a=n.isPreserved??(async m=>{try{let g=await wC({cwd:e,repo:r},m);return g.length===0?!0:g.some(A=>A===rt||A.startsWith("blocked:"))}catch{return!0}}),c=n.removeWorktree??(async m=>{await No({cwd:e},m)}),u=n.removeDir??(m=>ds(m)),l=new Map,d=m=>{let g=l.get(m);if(g!==void 0)return g;let A=i(m),E=A?parseInt(A.trim(),10):NaN,y=Number.isFinite(E)&&E>0?s(E):!0;return l.set(m,y),y},f=[];for(let m of t){let g=ER(m.path),A=ER(g),E=m.renderableLive||d(A),y=m.state.current.number,b=typeof y=="number"?y:Number.parseInt(String(y),10),w=Number.isFinite(b)&&b>0?await a(b):!0;f.push({attemptDir:g,worktreePath:Sn(g,"worktree"),workerPidAlive:E,preserved:w})}let p=[];for(let m of _at(f))m.removeWorktree&&o(m.worktreePath)&&await c(m.worktreePath).catch(()=>{}),m.reclaimDir&&(await u(m.attemptDir).catch(()=>{}),p.push(m.attemptDir));return p}async function Ig(e=process.cwd(),t=""){let r=Mr(e),n=await AR(r.tmpDir);await Ocr(e,n,t).catch(()=>{}),await P4(r.tmpDir).catch(()=>{});let o=F4(n),i=o.map(({path:g,state:A})=>A.log||Sn(ER(g),"afk.log")),s=await Sat(r.monitorLogCursorPath,i),a=[];for(let{path:g,state:A,active:E,live:y,liveness:b,livenessVerdict:w}of o){let I=A.current.loc_added,v=A.current.loc_removed,k=A.log||Sn(ER(g),"afk.log"),R=s.get(k);a.push({state:{worker_id:A.worker_id,pid:A.pid,runner:A.runner,started_at:A.started_at,origin:A.origin||void 0,total:A.total,done:A.done,blocked:A.blocked,failed:A.failed,current:{number:A.current.number,title:A.current.title,activity:A.current.activity,phase:A.current.phase,started_at:A.current.started_at,input_tokens:A.current.input_tokens,output_tokens:A.current.output_tokens,cost_usd:A.current.cost_usd,tools_called_count:A.current.tools_called_count,text_chunk_count:A.current.text_chunk_count,reasoning_events:A.current.reasoning_events,waiting_count:A.current.waiting_count}},liveness:b,livenessVerdict:w,live:E,pidLive:y,diffAdded:I,diffRemoved:v,...R!==void 0?{logLines:R.lines,logNewLines:R.newLines}:{}})}let c=await kl(r.historyPath),u=c===null?[]:MP(c).map(g=>({event:g.event,epoch:g.epoch})),l=await UP(r.fleetStatePath),d=Sn(r.tmpDir,"statusline-cache.json"),f=H4(d),p=Math.floor(Date.now()/1e3),m=f!==null?{remoteQueue:f.queue,remoteHuman:f.human,remoteCacheAgeS:p-f.ts}:{};return{workers:a,events:u,fleet:l,...m}}var tAe=900,Ncr=60;function $4(e,t){return Xp(e.RED_AFK_STATUSLINE_CACHE_TTL_S)??Xp(t("afk.statusline_cache_ttl"))??tAe}var Zge=5e3;async function Xge(e,t,r){let n,o=new Promise(i=>{n=setTimeout(()=>i(r),t)});try{return await Promise.race([e,o])}finally{clearTimeout(n)}}function DC(e){return Sn(Mr(e).tmpDir,"statusline-cache.json")}function H4(e){try{let t=JSON.parse(BC(e,"utf8"));return{queue:Number(t.queue??0),human:Number(t.human??0),ts:Number(t.ts??0)}}catch{return null}}function rAe(e,t){try{Gat(ER(e),{recursive:!0});let r=`${e}.tmp`;U4(r,JSON.stringify(t),"utf8"),jat(r,e)}catch{}}function Pcr(e){let t=e.trim(),r=/^git@github\.com:([^/]+\/[^/]+?)(?:\.git)?$/.exec(t);if(r)return r[1]??"";let n=/^https:\/\/github\.com\/([^/]+\/[^/]+?)(?:\.git)?\/?$/.exec(t);return n?n[1]??"":""}function Wat(e){try{return BC(e,"utf8")}catch{return""}}function bR(e){let t=Sn(e,".git"),r=Wat(t),n=[Sn(t,"config")],o=/^gitdir:\s*(.+)$/m.exec(r)?.[1]?.trim();if(o){let i=o.startsWith("/")?o:Sn(e,o);n.push(Sn(i,"config")),n.push(Sn(i,"..","..","config"))}for(let i of n){let s=Wat(i),a=/\[remote "origin"\][\s\S]*?\n\s*url\s*=\s*(.+)\n/.exec(`${s}
501
- `)?.[1],c=a?Pcr(a):"";if(c)return c}return""}function Mcr(e){return`${e}.refresh.lock`}function nAe(e){try{vcr(e)}catch{}}function Fcr(e,t){Gat(ER(e),{recursive:!0});let r=JSON.stringify({pid:process.pid,ts:t});try{return U4(e,r,{encoding:"utf8",flag:"wx"}),!0}catch{let n=H4(e);if(n&&t-n.ts<Ncr)return!1;nAe(e);try{return U4(e,r,{encoding:"utf8",flag:"wx"}),!0}catch{return!1}}}function Lcr(e,t,r,n=Math.floor(Date.now()/1e3)){let o=H4(e);if(!o)return!1;let i=new Set(t),s=new Set(r),a=l=>(s.has(l)?1:0)-(i.has(l)?1:0),c=a(Je),u=a(rt);return c===0&&u===0?!1:(rAe(e,{queue:Math.max(0,o.queue+c),human:Math.max(0,o.human+u),ts:n}),!0)}async function W4(e,t,r,n){let o=await t();return o&&Lcr(e,r,n),o}async function Vat(e,t=bR(e),r){try{let n=DC(e),o=await Sge({cwd:e,repo:t});rAe(n,{...o,ts:Math.floor(Date.now()/1e3)})}finally{r&&nAe(r)}}function Ucr(e,t={}){let r=DC(e.root),n=t.nowS??Math.floor(Date.now()/1e3),o=Mcr(r),i=e.repo||bR(e.root),s=t.argv1??process.argv[1];if(!i||!s||!Fcr(o,n))return!1;try{return(t.spawn??kcr)(process.execPath,[s,"statusline-refresh-counts",e.root,"--repo",i,"--lock",o],{detached:!0,stdio:"ignore",env:{...process.env,RED_AFK_STATUSLINE_REFRESH_CHILD:"1"}}).unref(),!0}catch{return nAe(o),!1}}async function Yat(e,t=tAe,r={}){let n=Mr(e.root),o=Date.now(),i=F4(await AR(n.tmpDir,{nowMs:o})),s={cwd:e.root},a=0,c=0,u=0,l=0,d=!1,f=0,p=0,m=0,g="",A="",E="",y=0,b=[],w=[],I=[],v=new Map;for(let{state:N}of i){a+=1,c+=N.blocked,g===""&&N.runner&&(g=N.runner),A===""&&N.current.model&&(A=N.current.model),E===""&&N.current.effort&&(E=N.current.effort),N.done>y&&(y=N.done),N.origin&&v.set(N.origin,(v.get(N.origin)??0)+1);let q=N.started_at||N.current.started_at,re=q?Math.max(0,o-Date.parse(q)):0,ie=N.current;f+=ie.waiting_count,p+=ie.input_tokens+ie.output_tokens,m+=ie.cost_usd;let ue=ie.loc_added,Oe=ie.loc_removed;if(ue===0&&Oe===0){let T=N.current.loc_peak_added??0,J=N.current.loc_peak_removed??0;(T>0||J>0)&&(ue=T,Oe=J,d=!0)}u+=ue,l+=Oe;let Ye=N.current.number;Ye!==""&&Ye!==void 0&&Ye!==null&&(b.push(Ye),w.push(N.current.phase||void 0),I.push(re))}let k=DC(e.root),R=Math.floor(Date.now()/1e3),B=H4(k),L=B?.queue??0,D=B?.human??0,ee={cwd:e.root,repo:e.repo||bR(e.root)},F=!1,_=async()=>{let N=await Sge(ee);L=N.queue,D=N.human,F=!0,rAe(k,{queue:L,human:D,ts:R})},P;if(B?R-B.ts>=t&&(P=R-B.ts,Ucr({...e,repo:ee.repo},{...r,nowS:R})):await Xge(_(),Zge,void 0).catch(()=>{}),a<=0)return null;let $=v.size>0?[...v.entries()].sort(([N],[q])=>N<q?-1:N>q?1:0).map(([N,q])=>({origin:N,count:q})):void 0;return{workers:a,queue:L,human:D,blocked:c,added:u,removed:l,locIsPeak:d||void 0,waiting:f,tokens:p,costUsd:m,runner:g,resolved:y,issues:b,phases:w,aliveMs:I.length>0?I:void 0,model:A||void 0,effort:E||void 0,sourceCounts:$,cacheAgeS:P}}var $cr=120;function Hcr(e){try{let t=Number.parseInt(BC(e,"utf8").trim(),10);return Number.isInteger(t)&&t>0?t:null}catch{return null}}async function Jat(e,t=$cr,r=Math.floor(Date.now()/1e3)){let n=Mr(e.root),o=Hcr(Sn(n.tmpDir,"afk-supervisor.pid"));if(o===null||!ni(o))return;let i=await UP(n.fleetStatePath);if(i&&!(r-i.epoch>t))return{runner:i.runner,busy:i.slotsBusy,total:i.slotsTotal,queue:i.readyForAgent,parked:i.slotsParked}}async function Kat(e){let t=Mr(e.root),r=Date.now(),n=F4(await AR(t.tmpDir,{nowMs:r})),o=[];for(let{state:i,active:s,live:a,liveness:c,livenessVerdict:u}of n){let l=i.current.loc_added,d=i.current.loc_removed;o.push({state:{worker_id:i.worker_id,pid:i.pid,runner:i.runner,started_at:i.started_at,origin:i.origin||void 0,total:i.total,done:i.done,blocked:i.blocked,failed:i.failed,current:{number:i.current.number,title:i.current.title,activity:i.current.activity,phase:i.current.phase,started_at:i.current.started_at,model:i.current.model,effort:i.current.effort,input_tokens:i.current.input_tokens,output_tokens:i.current.output_tokens,cost_usd:i.current.cost_usd,tools_called_count:i.current.tools_called_count,text_chunk_count:i.current.text_chunk_count,reasoning_events:i.current.reasoning_events,waiting_count:i.current.waiting_count}},liveness:c,livenessVerdict:u,live:s,pidLive:a,diffAdded:l,diffRemoved:d})}return o.sort((i,s)=>{let a=i.state.started_at||i.state.current.started_at||"",c=s.state.started_at||s.state.current.started_at||"";return a<c?-1:a>c?1:0}),o}function Wcr(e){try{let t=JSON.parse(BC(e,"utf8"));return{baseRef:typeof t.baseRef=="string"&&t.baseRef.trim()?t.baseRef.trim():"origin/main",openPrs:Number(t.openPrs??0),todayPrs:Number(t.todayPrs??0),openIssues:Number(t.openIssues??0),localAdded:Number(t.localAdded??0),localRemoved:Number(t.localRemoved??0),ts:Number(t.ts??0)}}catch{return null}}function jcr(e,t){try{let r=`${e}.tmp`;U4(r,JSON.stringify(t),"utf8"),jat(r,e)}catch{}}async function Zat(e,t=tAe,r="origin/main"){let n=Mr(e.root),o=Sn(n.tmpDir,"statusline-repo-cache.json"),i=Math.floor(Date.now()/1e3),s=Wcr(o),a=s?.baseRef===r,c=s?.openPrs??0,u=s?.todayPrs??0,l=s?.openIssues??0,d=a?s?.localAdded??0:0,f=a?s?.localRemoved??0:0,p={cwd:e.root,repo:e.repo},m=!1,g=async()=>{let[E,y,b,w]=await Promise.all([Lst(p),Ust(p),Fst(p),Ige({cwd:e.root},r)]);c=E,u=y,l=b,d=w.added,f=w.removed,m=!0,jcr(o,{baseRef:r,openPrs:E,todayPrs:y,openIssues:b,localAdded:w.added,localRemoved:w.removed,ts:i})},A;if(!s||!a)await Xge(g(),Zge,void 0).catch(()=>{});else if(i-s.ts>=t){let E=i-s.ts;await Xge(g(),Zge,void 0).catch(()=>{}),m||(A=E)}return{openPrs:c,todayPrs:u,openIssues:l,localAdded:d,localRemoved:f,cacheAgeS:A}}async function Xat(e){let t={cwd:e.root},r={cwd:e.root,repo:e.repo},n=await Kp(t,"afk-attempts/"),o=await Kp(t,"afk/"),i=await vge(t,"afk/*"),s=await Rge(t),a=i.filter(p=>!s.has(p)).map(p=>({branch:p})),{liveIssueFromBranch:c,attemptIssueFromBranch:u}=await Promise.resolve().then(()=>(sR(),gge)),l=new Set;for(let p of n){let m=u(p.branch);m!==null&&l.add(m)}for(let p of[...o,...a]){let m=c(p.branch);m!==null&&l.add(m)}let d=await y4(r),f=new Map;for(let p of l){let m=d.get(p);m?f.set(p,{state:m.state,closedAt:m.closedAt}):f.set(p,await Cge(r,p))}return{snapshotRefs:n,remoteLiveRefs:o,localLiveRefs:a,lookup:p=>f.get(p),deleteRemote:p=>wge(t,p),deleteLocal:p=>xg(t,p)}}async function j4(e,t,r,n){let o=Mr(e.root),i={cwd:e.root},s={cwd:e.root,repo:e.repo},a=(await Promise.all(mR(o.tmpDir).map(y=>Uge(y,n)))).flat(),c=new Map;for(let y of a){let b=Xd(y.path);if(!b)continue;let w=Dx(Sn(y.path,"afk.state.json"))?.live??!1,I=n-y.ageS,v=c.get(b.issue)??[];v.push({path:y.path,mtimeS:I,live:w}),c.set(b.issue,v)}let[u,l,d,f,p,m,g,A]=await Promise.all([Kp(i,"afk-attempts/"),Kp(i,"afk/"),vge(i,"afk/*"),Rge(i),I4(s),RC(o.tmpDir),$ge(o.tmpDir),k4(s)]),E=d.filter(y=>!f.has(y)).map(y=>({branch:y}));return{precheck:t,bootstrap:r,orphans:a,attemptCap:{byIssue:c},branches:{snapshotRefs:u,remoteLiveRefs:l,localLiveRefs:E},unblockCandidates:p,staleClaimDirs:m,legacyWorkDirs:g,reconcileSweepCandidates:A}}async function q4(e){let t={cwd:e.root},r={cwd:e.root,repo:e.repo},{branchLockPath:n,readLockedBranch:o}=await Promise.resolve().then(()=>(LP(),$at)),i=n(e.root),s=Sr(Mr(e.root).configPath,{warn:()=>{}}),a=Pe(s,"dev.lock.branch")||void 0,c=Pe(s,"dev.trunk")||void 0,[u,l,d,f,p,m,g,A]=await Promise.all([Ist(r),kst(r),Vst(t),Yst(t),Jst(t),CP(t),Promise.resolve().then(()=>(bn(),hg)).then(b=>b.pnpm(["--version"],{cwd:e.root})),o(i)]),E=await pf({issueBody:""},{readLockedBranch:async()=>A,configLockedBranch:a,configTrunk:c,fetchIssueBody:async()=>{}}),y=g.code!==127;return{ghInstalled:u,ghAuthenticated:l,isGitRepo:d,remoteUrls:f,hasMainBranch:p,currentBranch:m,lockedBranch:A,configuredTrunk:E,pnpmInstalled:y,allowHttpsRemote:process.env.RED_AFK_LANE==="actions"||process.env.GITHUB_ACTIONS==="true"}}async function qcr(e,t,r){let{liveIssueFromBranch:n,attemptIssueFromBranch:o}=await Promise.resolve().then(()=>(sR(),gge)),i=new Set;for(let a of t.branches.snapshotRefs){let c=o(a.branch);c!==null&&i.add(c)}for(let a of[...t.branches.remoteLiveRefs,...t.branches.localLiveRefs]){let c=n(a.branch);c!==null&&i.add(c)}let s=new Map;for(let a of i){let c=r.get(a);c?s.set(a,{state:c.state,closedAt:c.closedAt}):s.set(a,await Cge(e,a))}return s}async function G4(e,t,r){let n={cwd:e.root,repo:e.repo},o={cwd:e.root},i=Mr(e.root),s=Sr(i.configPath,{warn:()=>{}}),a=DC(e.root),c=await y4(n),u=await qcr(n,t,c),l=new Map;for(let d of t.branches.remoteLiveRefs){let f=m4(d.branch);if(f===null||!Number.isFinite(d.commitS))continue;let p=l.get(f);(p===void 0||d.commitS>p)&&l.set(f,d.commitS)}return{fs:{ensureDir:Zp,ensureGitignoreLine:D4,writeWorkerPid:Q4,removeDir:ds,reapDeadEmptyWorkerShells:P4},gh:{editLabels:async(d,f,p)=>{await W4(a,()=>xa(n,d,f,p),f,p)},comment:(d,f)=>ri(n,d,f),viewLabels:d=>wC(n,d),issueReference:d=>gg(n,d)},git:{deleteRemoteBranch:d=>wge(o,d),deleteLocalBranch:d=>xg(o,d)},lookups:{claimHolderAlive:d=>N4(Sn(Mr(e.root).tmpDir,"claims",String(d))),orphanState:async d=>{let f=c.get(d);if(!f)return Ost(n,d);let p=f.labels.includes(rt)?rt:f.labels.includes(ze)?ze:null;return{ghOk:!0,state:f.state,label:p,envelopePosted:!1}},branchIssue:d=>u.get(d),blockerState:async d=>c.get(d)?.state,straggler:{unlabeled:()=>Pst(n),needsTriage:()=>Mst(n),needsInfo:()=>$st(n)},claimedIssues:async()=>{let d=[],f=e_();for(let[p,m]of c)if(m.state==="OPEN"&&m.labels.includes(ze))try{let g=await lR(n,p),A=FP(g),E=A.map(y=>y.worker).filter((y,b,w)=>w.indexOf(y)===b).filter(y=>{if(!y.startsWith(f))return!1;let b=y.slice(f.length);if(!b)return!1;let w=Sn(i.workersRoot,b,"worker.pid");if(!qat(w))return!0;let I=Number(BC(w,"utf8").trim());return!Number.isInteger(I)||!ni(I)});d.push({issue:p,records:A,deadOwners:E,attemptBranchCommitS:l.get(p)})}catch{}return d}},nowS:r,config:s}}function ect(e,t){let r=()=>{throw new Error("buildMinimalBootDeps: sweep IO invoked on a skip-sweeps boot (#623)")};return{fs:{ensureDir:Zp,ensureGitignoreLine:D4,writeWorkerPid:Q4,removeDir:ds},gh:{editLabels:async()=>r(),comment:async()=>r(),viewLabels:async()=>r()},git:{deleteRemoteBranch:async()=>r(),deleteLocalBranch:async()=>r()},lookups:{orphanState:async()=>r(),branchIssue:()=>r(),blockerState:async()=>r(),straggler:{unlabeled:async()=>r(),needsTriage:async()=>r(),needsInfo:async()=>r()}},nowS:t}}tf();ru();import{spawn as Gcr}from"node:child_process";import{openSync as zcr,renameSync as Vcr,writeFileSync as Ycr}from"node:fs";import{readFile as Jcr}from"node:fs/promises";import{join as oAe}from"node:path";var Kcr=e=>new Promise(t=>setTimeout(t,e));function Zcr(e){try{return process.kill(e,0),!0}catch{return!1}}async function Xcr(e){try{let t=(await Jcr(e,"utf8")).trim();return/^\d+$/.test(t)?Number(t):null}catch{return null}}async function eur(e,t){let r=Date.now()+t;for(;Date.now()<r;){let n=await Xcr(e);if(n&&Zcr(n))return n;await Kcr(100)}return null}async function z4(e){let t=oAe(e.root,".red","tmp"),r=oAe(t,"afk-supervisor.pid"),n=oAe(t,"afk-supervisor.log"),o=[...e.passthrough??[]];e.request&&o.unshift("--request",e.request);let i={...process.env,RED_AFK_TARGET:String(e.target),RED_AFK_RUNNER:e.runner};e.request&&(i.RED_AFK_REQUEST=e.request),e.drainBudgetUsd!==void 0&&(i.RED_AFK_DRAIN_MAX_COST_USD=String(e.drainBudgetUsd));let s=zcr(n,"a");return Gcr(process.execPath,[process.argv[1],"__supervise",...o],{cwd:e.root,env:i,detached:!0,stdio:["ignore",s,s]}).unref(),eur(r,3e3)}function tct(e,t,r,n){let o=JSON.stringify({ts:new Date(t*1e3).toISOString(),epoch:t,last_progress_epoch:t,runner:r,ready_for_agent:0,slots:{busy:0,free:n,total:n,parked:0},spawns_this_tick:0},null,2),i=`${e}.tmp`;Ycr(i,o,"utf8"),Vcr(i,e)}async function aur(e){try{let t=(await V4(e,"utf8")).trim();return/^\d+$/.test(t)?Number(t):null}catch{return null}}async function cur(e){try{return await rur(e,tur.F_OK),!0}catch{return!1}}function Y4(e,t=process.stdout){let r=Mr(e),n=SR(r.tmpDir,"afk-supervisor.pid"),o=SR(r.tmpDir,"afk-supervisor.stop"),i=SR(r.tmpDir,"afk-supervisor.log"),s=SR(r.tmpDir,"afk-supervisor.restarts.json"),a=2,c="",u=async()=>{let l;try{l=await rct(r.workersRoot)}catch{return 0}let d=0;for(let f of l){let p=SR(r.workersRoot,f,"worker.pid");try{let m=(await V4(p,"utf8")).trim();if(!/^[1-9][0-9]*$/.test(m))continue;ni(Number(m))&&(d+=1)}catch{}}return d};return{now:()=>Math.floor(Date.now()/1e3),liveness:async()=>{let l=await aur(n),d=await UP(r.fleetStatePath);return d&&(d.slotsTotal>0&&(a=d.slotsTotal),d.runner&&(c=d.runner)),{pid:l,pidAlive:l!==null&&ni(l),lastHeartbeatEpoch:d?d.epoch:null,lastProgressEpoch:d?.lastProgressEpoch??null,slotsBusy:d?.slotsBusy??0}},killTree:async l=>{await Cg(l)},killWorkers:async()=>{let l;try{l=await rct(r.workersRoot)}catch{return}for(let d of l){let f=SR(r.workersRoot,d,"worker.pid");try{let p=(await V4(f,"utf8")).trim();if(!/^[1-9][0-9]*$/.test(p))continue;let m=Number(p);ni(m)&&await Cg(m)}catch{}}},clearControlFiles:async()=>{await nct(n,{force:!0}),await nct(o,{force:!0})},reconcile:async()=>{let l=await RC(r.tmpDir).catch(()=>[]);for(let d of l)await ds(d.path).catch(()=>{})},relaunch:async()=>{let l=c||GC({processTree:zC(),scriptPath:process.argv[1]}).runner;await z4({root:e,target:a,runner:l});try{tct(r.fleetStatePath,Math.floor(Date.now()/1e3),l,a)}catch{}},deadSupervisorSignals:async()=>{let l=await UP(r.fleetStatePath),d=l&&l.slotsTotal>0?l.slotsTotal:a,f=l?.readyForAgent??0;try{let g=await TC(e).catch(()=>"");f=await w4({repo:g,cwd:e})}catch{}let p=await u(),m=await cur(o);return{readyForAgent:f,target:d,liveWorkers:p,stopRequested:m}},readRestartLedger:async()=>{try{let l=await V4(s,"utf8"),d=JSON.parse(l);return Array.isArray(d)?d.filter(f=>typeof f=="number"&&Number.isFinite(f)):[]}catch{return[]}},writeRestartLedger:async l=>{try{await nur(s,JSON.stringify(l),"utf8")}catch{}},log:l=>{try{t.write(`${l}
503
+ `)?.[1],c=a?Pcr(a):"";if(c)return c}return""}function Mcr(e){return`${e}.refresh.lock`}function nAe(e){try{vcr(e)}catch{}}function Fcr(e,t){Gat(ER(e),{recursive:!0});let r=JSON.stringify({pid:process.pid,ts:t});try{return U4(e,r,{encoding:"utf8",flag:"wx"}),!0}catch{let n=H4(e);if(n&&t-n.ts<Ncr)return!1;nAe(e);try{return U4(e,r,{encoding:"utf8",flag:"wx"}),!0}catch{return!1}}}function Lcr(e,t,r,n=Math.floor(Date.now()/1e3)){let o=H4(e);if(!o)return!1;let i=new Set(t),s=new Set(r),a=l=>(s.has(l)?1:0)-(i.has(l)?1:0),c=a(Je),u=a(rt);return c===0&&u===0?!1:(rAe(e,{queue:Math.max(0,o.queue+c),human:Math.max(0,o.human+u),ts:n}),!0)}async function W4(e,t,r,n){let o=await t();return o&&Lcr(e,r,n),o}async function Vat(e,t=bR(e),r){try{let n=DC(e),o=await Sge({cwd:e,repo:t});rAe(n,{...o,ts:Math.floor(Date.now()/1e3)})}finally{r&&nAe(r)}}function Ucr(e,t={}){let r=DC(e.root),n=t.nowS??Math.floor(Date.now()/1e3),o=Mcr(r),i=e.repo||bR(e.root),s=t.argv1??process.argv[1];if(!i||!s||!Fcr(o,n))return!1;try{return(t.spawn??kcr)(process.execPath,[s,"statusline-refresh-counts",e.root,"--repo",i,"--lock",o],{detached:!0,stdio:"ignore",env:{...process.env,RED_AFK_STATUSLINE_REFRESH_CHILD:"1"}}).unref(),!0}catch{return nAe(o),!1}}async function Yat(e,t=tAe,r={}){let n=Mr(e.root),o=Date.now(),i=F4(await AR(n.tmpDir,{nowMs:o})),s={cwd:e.root},a=0,c=0,u=0,l=0,d=!1,f=0,p=0,m=0,g="",A="",E="",y=0,b=[],w=[],I=[],v=new Map;for(let{state:N}of i){a+=1,c+=N.blocked,g===""&&N.runner&&(g=N.runner),A===""&&N.current.model&&(A=N.current.model),E===""&&N.current.effort&&(E=N.current.effort),N.done>y&&(y=N.done),N.origin&&v.set(N.origin,(v.get(N.origin)??0)+1);let q=N.started_at||N.current.started_at,re=q?Math.max(0,o-Date.parse(q)):0,ie=N.current;f+=ie.waiting_count,p+=ie.input_tokens+ie.output_tokens,m+=ie.cost_usd;let ue=ie.loc_added,Oe=ie.loc_removed;if(ue===0&&Oe===0){let T=N.current.loc_peak_added??0,J=N.current.loc_peak_removed??0;(T>0||J>0)&&(ue=T,Oe=J,d=!0)}u+=ue,l+=Oe;let Ye=N.current.number;Ye!==""&&Ye!==void 0&&Ye!==null&&(b.push(Ye),w.push(N.current.phase||void 0),I.push(re))}let k=DC(e.root),R=Math.floor(Date.now()/1e3),B=H4(k),L=B?.queue??0,D=B?.human??0,ee={cwd:e.root,repo:e.repo||bR(e.root)},F=!1,_=async()=>{let N=await Sge(ee);L=N.queue,D=N.human,F=!0,rAe(k,{queue:L,human:D,ts:R})},P;if(B?R-B.ts>=t&&(P=R-B.ts,Ucr({...e,repo:ee.repo},{...r,nowS:R})):await Xge(_(),Zge,void 0).catch(()=>{}),a<=0)return null;let $=v.size>0?[...v.entries()].sort(([N],[q])=>N<q?-1:N>q?1:0).map(([N,q])=>({origin:N,count:q})):void 0;return{workers:a,queue:L,human:D,blocked:c,added:u,removed:l,locIsPeak:d||void 0,waiting:f,tokens:p,costUsd:m,runner:g,resolved:y,issues:b,phases:w,aliveMs:I.length>0?I:void 0,model:A||void 0,effort:E||void 0,sourceCounts:$,cacheAgeS:P}}var $cr=120;function Hcr(e){try{let t=Number.parseInt(BC(e,"utf8").trim(),10);return Number.isInteger(t)&&t>0?t:null}catch{return null}}async function Jat(e,t=$cr,r=Math.floor(Date.now()/1e3)){let n=Mr(e.root),o=Hcr(Sn(n.tmpDir,"afk-supervisor.pid"));if(o===null||!oi(o))return;let i=await UP(n.fleetStatePath);if(i&&!(r-i.epoch>t))return{runner:i.runner,busy:i.slotsBusy,total:i.slotsTotal,queue:i.readyForAgent,parked:i.slotsParked}}async function Kat(e){let t=Mr(e.root),r=Date.now(),n=F4(await AR(t.tmpDir,{nowMs:r})),o=[];for(let{state:i,active:s,live:a,liveness:c,livenessVerdict:u}of n){let l=i.current.loc_added,d=i.current.loc_removed;o.push({state:{worker_id:i.worker_id,pid:i.pid,runner:i.runner,started_at:i.started_at,origin:i.origin||void 0,total:i.total,done:i.done,blocked:i.blocked,failed:i.failed,current:{number:i.current.number,title:i.current.title,activity:i.current.activity,phase:i.current.phase,started_at:i.current.started_at,model:i.current.model,effort:i.current.effort,input_tokens:i.current.input_tokens,output_tokens:i.current.output_tokens,cost_usd:i.current.cost_usd,tools_called_count:i.current.tools_called_count,text_chunk_count:i.current.text_chunk_count,reasoning_events:i.current.reasoning_events,waiting_count:i.current.waiting_count}},liveness:c,livenessVerdict:u,live:s,pidLive:a,diffAdded:l,diffRemoved:d})}return o.sort((i,s)=>{let a=i.state.started_at||i.state.current.started_at||"",c=s.state.started_at||s.state.current.started_at||"";return a<c?-1:a>c?1:0}),o}function Wcr(e){try{let t=JSON.parse(BC(e,"utf8"));return{baseRef:typeof t.baseRef=="string"&&t.baseRef.trim()?t.baseRef.trim():"origin/main",openPrs:Number(t.openPrs??0),todayPrs:Number(t.todayPrs??0),openIssues:Number(t.openIssues??0),localAdded:Number(t.localAdded??0),localRemoved:Number(t.localRemoved??0),ts:Number(t.ts??0)}}catch{return null}}function jcr(e,t){try{let r=`${e}.tmp`;U4(r,JSON.stringify(t),"utf8"),jat(r,e)}catch{}}async function Zat(e,t=tAe,r="origin/main"){let n=Mr(e.root),o=Sn(n.tmpDir,"statusline-repo-cache.json"),i=Math.floor(Date.now()/1e3),s=Wcr(o),a=s?.baseRef===r,c=s?.openPrs??0,u=s?.todayPrs??0,l=s?.openIssues??0,d=a?s?.localAdded??0:0,f=a?s?.localRemoved??0:0,p={cwd:e.root,repo:e.repo},m=!1,g=async()=>{let[E,y,b,w]=await Promise.all([Lst(p),Ust(p),Fst(p),Ige({cwd:e.root},r)]);c=E,u=y,l=b,d=w.added,f=w.removed,m=!0,jcr(o,{baseRef:r,openPrs:E,todayPrs:y,openIssues:b,localAdded:w.added,localRemoved:w.removed,ts:i})},A;if(!s||!a)await Xge(g(),Zge,void 0).catch(()=>{});else if(i-s.ts>=t){let E=i-s.ts;await Xge(g(),Zge,void 0).catch(()=>{}),m||(A=E)}return{openPrs:c,todayPrs:u,openIssues:l,localAdded:d,localRemoved:f,cacheAgeS:A}}async function Xat(e){let t={cwd:e.root},r={cwd:e.root,repo:e.repo},n=await Kp(t,"afk-attempts/"),o=await Kp(t,"afk/"),i=await vge(t,"afk/*"),s=await Rge(t),a=i.filter(p=>!s.has(p)).map(p=>({branch:p})),{liveIssueFromBranch:c,attemptIssueFromBranch:u}=await Promise.resolve().then(()=>(sR(),gge)),l=new Set;for(let p of n){let m=u(p.branch);m!==null&&l.add(m)}for(let p of[...o,...a]){let m=c(p.branch);m!==null&&l.add(m)}let d=await y4(r),f=new Map;for(let p of l){let m=d.get(p);m?f.set(p,{state:m.state,closedAt:m.closedAt}):f.set(p,await Cge(r,p))}return{snapshotRefs:n,remoteLiveRefs:o,localLiveRefs:a,lookup:p=>f.get(p),deleteRemote:p=>wge(t,p),deleteLocal:p=>xg(t,p)}}async function j4(e,t,r,n){let o=Mr(e.root),i={cwd:e.root},s={cwd:e.root,repo:e.repo},a=(await Promise.all(mR(o.tmpDir).map(y=>Uge(y,n)))).flat(),c=new Map;for(let y of a){let b=Xd(y.path);if(!b)continue;let w=Dx(Sn(y.path,"afk.state.json"))?.live??!1,I=n-y.ageS,v=c.get(b.issue)??[];v.push({path:y.path,mtimeS:I,live:w}),c.set(b.issue,v)}let[u,l,d,f,p,m,g,A]=await Promise.all([Kp(i,"afk-attempts/"),Kp(i,"afk/"),vge(i,"afk/*"),Rge(i),I4(s),RC(o.tmpDir),$ge(o.tmpDir),k4(s)]),E=d.filter(y=>!f.has(y)).map(y=>({branch:y}));return{precheck:t,bootstrap:r,orphans:a,attemptCap:{byIssue:c},branches:{snapshotRefs:u,remoteLiveRefs:l,localLiveRefs:E},unblockCandidates:p,staleClaimDirs:m,legacyWorkDirs:g,reconcileSweepCandidates:A}}async function q4(e){let t={cwd:e.root},r={cwd:e.root,repo:e.repo},{branchLockPath:n,readLockedBranch:o}=await Promise.resolve().then(()=>(LP(),$at)),i=n(e.root),s=Sr(Mr(e.root).configPath,{warn:()=>{}}),a=Pe(s,"dev.lock.branch")||void 0,c=Pe(s,"dev.trunk")||void 0,[u,l,d,f,p,m,g,A]=await Promise.all([Ist(r),kst(r),Vst(t),Yst(t),Jst(t),CP(t),Promise.resolve().then(()=>(bn(),hg)).then(b=>b.pnpm(["--version"],{cwd:e.root})),o(i)]),E=await pf({issueBody:""},{readLockedBranch:async()=>A,configLockedBranch:a,configTrunk:c,fetchIssueBody:async()=>{}}),y=g.code!==127;return{ghInstalled:u,ghAuthenticated:l,isGitRepo:d,remoteUrls:f,hasMainBranch:p,currentBranch:m,lockedBranch:A,configuredTrunk:E,pnpmInstalled:y,allowHttpsRemote:process.env.RED_AFK_LANE==="actions"||process.env.GITHUB_ACTIONS==="true"}}async function qcr(e,t,r){let{liveIssueFromBranch:n,attemptIssueFromBranch:o}=await Promise.resolve().then(()=>(sR(),gge)),i=new Set;for(let a of t.branches.snapshotRefs){let c=o(a.branch);c!==null&&i.add(c)}for(let a of[...t.branches.remoteLiveRefs,...t.branches.localLiveRefs]){let c=n(a.branch);c!==null&&i.add(c)}let s=new Map;for(let a of i){let c=r.get(a);c?s.set(a,{state:c.state,closedAt:c.closedAt}):s.set(a,await Cge(e,a))}return s}async function G4(e,t,r){let n={cwd:e.root,repo:e.repo},o={cwd:e.root},i=Mr(e.root),s=Sr(i.configPath,{warn:()=>{}}),a=DC(e.root),c=await y4(n),u=await qcr(n,t,c),l=new Map;for(let d of t.branches.remoteLiveRefs){let f=m4(d.branch);if(f===null||!Number.isFinite(d.commitS))continue;let p=l.get(f);(p===void 0||d.commitS>p)&&l.set(f,d.commitS)}return{fs:{ensureDir:Zp,ensureGitignoreLine:D4,writeWorkerPid:Q4,removeDir:ds,reapDeadEmptyWorkerShells:P4},gh:{editLabels:async(d,f,p)=>{await W4(a,()=>xa(n,d,f,p),f,p)},comment:(d,f)=>ni(n,d,f),viewLabels:d=>wC(n,d),issueReference:d=>gg(n,d)},git:{deleteRemoteBranch:d=>wge(o,d),deleteLocalBranch:d=>xg(o,d)},lookups:{claimHolderAlive:d=>N4(Sn(Mr(e.root).tmpDir,"claims",String(d))),orphanState:async d=>{let f=c.get(d);if(!f)return Ost(n,d);let p=f.labels.includes(rt)?rt:f.labels.includes(ze)?ze:null;return{ghOk:!0,state:f.state,label:p,envelopePosted:!1}},branchIssue:d=>u.get(d),blockerState:async d=>c.get(d)?.state,straggler:{unlabeled:()=>Pst(n),needsTriage:()=>Mst(n),needsInfo:()=>$st(n)},claimedIssues:async()=>{let d=[],f=e_();for(let[p,m]of c)if(m.state==="OPEN"&&m.labels.includes(ze))try{let g=await lR(n,p),A=FP(g),E=A.map(y=>y.worker).filter((y,b,w)=>w.indexOf(y)===b).filter(y=>{if(!y.startsWith(f))return!1;let b=y.slice(f.length);if(!b)return!1;let w=Sn(i.workersRoot,b,"worker.pid");if(!qat(w))return!0;let I=Number(BC(w,"utf8").trim());return!Number.isInteger(I)||!oi(I)});d.push({issue:p,records:A,deadOwners:E,attemptBranchCommitS:l.get(p)})}catch{}return d}},nowS:r,config:s}}function ect(e,t){let r=()=>{throw new Error("buildMinimalBootDeps: sweep IO invoked on a skip-sweeps boot (#623)")};return{fs:{ensureDir:Zp,ensureGitignoreLine:D4,writeWorkerPid:Q4,removeDir:ds},gh:{editLabels:async()=>r(),comment:async()=>r(),viewLabels:async()=>r()},git:{deleteRemoteBranch:async()=>r(),deleteLocalBranch:async()=>r()},lookups:{orphanState:async()=>r(),branchIssue:()=>r(),blockerState:async()=>r(),straggler:{unlabeled:async()=>r(),needsTriage:async()=>r(),needsInfo:async()=>r()}},nowS:t}}tf();ru();import{spawn as Gcr}from"node:child_process";import{openSync as zcr,renameSync as Vcr,writeFileSync as Ycr}from"node:fs";import{readFile as Jcr}from"node:fs/promises";import{join as oAe}from"node:path";var Kcr=e=>new Promise(t=>setTimeout(t,e));function Zcr(e){try{return process.kill(e,0),!0}catch{return!1}}async function Xcr(e){try{let t=(await Jcr(e,"utf8")).trim();return/^\d+$/.test(t)?Number(t):null}catch{return null}}async function eur(e,t){let r=Date.now()+t;for(;Date.now()<r;){let n=await Xcr(e);if(n&&Zcr(n))return n;await Kcr(100)}return null}async function z4(e){let t=oAe(e.root,".red","tmp"),r=oAe(t,"afk-supervisor.pid"),n=oAe(t,"afk-supervisor.log"),o=[...e.passthrough??[]];e.request&&o.unshift("--request",e.request);let i={...process.env,RED_AFK_TARGET:String(e.target),RED_AFK_RUNNER:e.runner};e.request&&(i.RED_AFK_REQUEST=e.request),e.drainBudgetUsd!==void 0&&(i.RED_AFK_DRAIN_MAX_COST_USD=String(e.drainBudgetUsd));let s=zcr(n,"a");return Gcr(process.execPath,[process.argv[1],"__supervise",...o],{cwd:e.root,env:i,detached:!0,stdio:["ignore",s,s]}).unref(),eur(r,3e3)}function tct(e,t,r,n){let o=JSON.stringify({ts:new Date(t*1e3).toISOString(),epoch:t,last_progress_epoch:t,runner:r,ready_for_agent:0,slots:{busy:0,free:n,total:n,parked:0},spawns_this_tick:0},null,2),i=`${e}.tmp`;Ycr(i,o,"utf8"),Vcr(i,e)}async function aur(e){try{let t=(await V4(e,"utf8")).trim();return/^\d+$/.test(t)?Number(t):null}catch{return null}}async function cur(e){try{return await rur(e,tur.F_OK),!0}catch{return!1}}function Y4(e,t=process.stdout){let r=Mr(e),n=SR(r.tmpDir,"afk-supervisor.pid"),o=SR(r.tmpDir,"afk-supervisor.stop"),i=SR(r.tmpDir,"afk-supervisor.log"),s=SR(r.tmpDir,"afk-supervisor.restarts.json"),a=2,c="",u=async()=>{let l;try{l=await rct(r.workersRoot)}catch{return 0}let d=0;for(let f of l){let p=SR(r.workersRoot,f,"worker.pid");try{let m=(await V4(p,"utf8")).trim();if(!/^[1-9][0-9]*$/.test(m))continue;oi(Number(m))&&(d+=1)}catch{}}return d};return{now:()=>Math.floor(Date.now()/1e3),liveness:async()=>{let l=await aur(n),d=await UP(r.fleetStatePath);return d&&(d.slotsTotal>0&&(a=d.slotsTotal),d.runner&&(c=d.runner)),{pid:l,pidAlive:l!==null&&oi(l),lastHeartbeatEpoch:d?d.epoch:null,lastProgressEpoch:d?.lastProgressEpoch??null,slotsBusy:d?.slotsBusy??0}},killTree:async l=>{await Cg(l)},killWorkers:async()=>{let l;try{l=await rct(r.workersRoot)}catch{return}for(let d of l){let f=SR(r.workersRoot,d,"worker.pid");try{let p=(await V4(f,"utf8")).trim();if(!/^[1-9][0-9]*$/.test(p))continue;let m=Number(p);oi(m)&&await Cg(m)}catch{}}},clearControlFiles:async()=>{await nct(n,{force:!0}),await nct(o,{force:!0})},reconcile:async()=>{let l=await RC(r.tmpDir).catch(()=>[]);for(let d of l)await ds(d.path).catch(()=>{})},relaunch:async()=>{let l=c||GC({processTree:zC(),scriptPath:process.argv[1]}).runner;await z4({root:e,target:a,runner:l});try{tct(r.fleetStatePath,Math.floor(Date.now()/1e3),l,a)}catch{}},deadSupervisorSignals:async()=>{let l=await UP(r.fleetStatePath),d=l&&l.slotsTotal>0?l.slotsTotal:a,f=l?.readyForAgent??0;try{let g=await TC(e).catch(()=>"");f=await w4({repo:g,cwd:e})}catch{}let p=await u(),m=await cur(o);return{readyForAgent:f,target:d,liveWorkers:p,stopRequested:m}},readRestartLedger:async()=>{try{let l=await V4(s,"utf8"),d=JSON.parse(l);return Array.isArray(d)?d.filter(f=>typeof f=="number"&&Number.isFinite(f)):[]}catch{return[]}},writeRestartLedger:async l=>{try{await nur(s,JSON.stringify(l),"utf8")}catch{}},log:l=>{try{t.write(`${l}
502
504
  `)}catch{}try{let d=iur(i,"a");try{sur(d,`[${new Date().toISOString()}] ${l}
503
- `)}finally{our(d)}}catch{}}}}import{constants as uur}from"node:fs";import{access as lur,readdir as dur,readFile as fur,rm as pur}from"node:fs/promises";import{join as CR}from"node:path";async function mur(e){try{let t=(await fur(e,"utf8")).trim();if(!/^\d+$/.test(t))return null;let r=Number(t);return Number.isSafeInteger(r)&&r>0?r:null}catch{return null}}async function hur(e){try{return await lur(e,uur.F_OK),!0}catch{return!1}}async function gur(e){let t=[CR(e,"afk-supervisor.pid"),CR(e,"afk-supervisor.state.json"),CR(e,"afk-supervisor.state.json.tmp"),CR(e,"afk-supervisor.stop")];try{for(let r of await dur(e))r.startsWith("afk-supervisor.log")&&t.push(CR(e,r))}catch{}return[...new Set(t)]}async function $P(e,t=ni){let r=CR(e,"afk-supervisor.pid"),n=await mur(r);if(n!==null&&t(n))return{status:"live",pid:n,removed:[]};let o=await gur(e),i=[];for(let a of o)await hur(a)&&i.push(a);if(i.length===0)return{status:"absent",removed:[]};let s=[];for(let a of i)try{await pur(a,{force:!0}),s.push(a)}catch{}return{status:"stale",...n!==null?{pid:n}:{},removed:s}}var Sur=e=>new Promise(t=>setTimeout(t,e));async function Cur(e){try{return await yur(e,Aur.F_OK),!0}catch{return!1}}function iAe(e,t){if(e===void 0)throw new Error(`${t} requires a value`);let r=Number(e);if(!Number.isFinite(r)||r<=0)throw new Error(`${t} requires a positive number`);return r}function ict(e){let t=[],r=!1,n,o,i,s;for(let a=0;a<e.length;a+=1){let c=e[a];if(c==="stop"){r=!0;continue}if(c==="--request"||c==="-r"){if(o=e[++a],o===void 0)throw new Error(`${c} requires a value`);continue}if(c.startsWith("--request=")){o=c.slice(10);continue}if(c==="--runner"){if(i=e[++a],i===void 0)throw new Error("--runner requires a value");continue}if(c.startsWith("--runner=")){i=c.slice(9);continue}if(c==="--budget-usd"||c==="--drain-budget-usd"){s=iAe(e[++a],c);continue}if(c.startsWith("--budget-usd=")){s=iAe(c.slice(13),"--budget-usd");continue}if(c.startsWith("--drain-budget-usd=")){s=iAe(c.slice(19),"--drain-budget-usd");continue}if(/^[0-9]+$/.test(c)&&n===void 0){n=Number(c);continue}t.push(c)}return{stop:r,target:n??2,request:o,runnerFlag:i,drainBudgetUsd:s,passthrough:t}}async function sAe(e=process.cwd(),t=process.stdout){let r=wR(e,".red","tmp"),n=wR(r,"afk-supervisor.pid"),o=wR(r,"afk-supervisor.stop"),i=await $P(r,ni);if(i.status==="stale")return t.write(`no fleet running (stale supervisor files under .red/tmp \u2014 cleaned).
505
+ `)}finally{our(d)}}catch{}}}}import{constants as uur}from"node:fs";import{access as lur,readdir as dur,readFile as fur,rm as pur}from"node:fs/promises";import{join as CR}from"node:path";async function mur(e){try{let t=(await fur(e,"utf8")).trim();if(!/^\d+$/.test(t))return null;let r=Number(t);return Number.isSafeInteger(r)&&r>0?r:null}catch{return null}}async function hur(e){try{return await lur(e,uur.F_OK),!0}catch{return!1}}async function gur(e){let t=[CR(e,"afk-supervisor.pid"),CR(e,"afk-supervisor.state.json"),CR(e,"afk-supervisor.state.json.tmp"),CR(e,"afk-supervisor.stop")];try{for(let r of await dur(e))r.startsWith("afk-supervisor.log")&&t.push(CR(e,r))}catch{}return[...new Set(t)]}async function $P(e,t=oi){let r=CR(e,"afk-supervisor.pid"),n=await mur(r);if(n!==null&&t(n))return{status:"live",pid:n,removed:[]};let o=await gur(e),i=[];for(let a of o)await hur(a)&&i.push(a);if(i.length===0)return{status:"absent",removed:[]};let s=[];for(let a of i)try{await pur(a,{force:!0}),s.push(a)}catch{}return{status:"stale",...n!==null?{pid:n}:{},removed:s}}var Sur=e=>new Promise(t=>setTimeout(t,e));async function Cur(e){try{return await yur(e,Aur.F_OK),!0}catch{return!1}}function iAe(e,t){if(e===void 0)throw new Error(`${t} requires a value`);let r=Number(e);if(!Number.isFinite(r)||r<=0)throw new Error(`${t} requires a positive number`);return r}function ict(e){let t=[],r=!1,n,o,i,s;for(let a=0;a<e.length;a+=1){let c=e[a];if(c==="stop"){r=!0;continue}if(c==="--request"||c==="-r"){if(o=e[++a],o===void 0)throw new Error(`${c} requires a value`);continue}if(c.startsWith("--request=")){o=c.slice(10);continue}if(c==="--runner"){if(i=e[++a],i===void 0)throw new Error("--runner requires a value");continue}if(c.startsWith("--runner=")){i=c.slice(9);continue}if(c==="--budget-usd"||c==="--drain-budget-usd"){s=iAe(e[++a],c);continue}if(c.startsWith("--budget-usd=")){s=iAe(c.slice(13),"--budget-usd");continue}if(c.startsWith("--drain-budget-usd=")){s=iAe(c.slice(19),"--drain-budget-usd");continue}if(/^[0-9]+$/.test(c)&&n===void 0){n=Number(c);continue}t.push(c)}return{stop:r,target:n??2,request:o,runnerFlag:i,drainBudgetUsd:s,passthrough:t}}async function sAe(e=process.cwd(),t=process.stdout){let r=wR(e,".red","tmp"),n=wR(r,"afk-supervisor.pid"),o=wR(r,"afk-supervisor.stop"),i=await $P(r,oi);if(i.status==="stale")return t.write(`no fleet running (stale supervisor files under .red/tmp \u2014 cleaned).
504
506
  `),{status:"stale",...i.pid!==void 0?{pid:i.pid}:{}};let s=i.pid;if(!s)return t.write(`no fleet running.
505
- `),{status:"none"};await bur(o,"","utf8");let a=Date.now()+3e4;for(;Date.now()<a;){if(!await Cur(n)||!ni(s))return t.write(`\u{1F6D1} fleet stopped (supervisor pid=${s} exited).
507
+ `),{status:"none"};await bur(o,"","utf8");let a=Date.now()+3e4;for(;Date.now()<a;){if(!await Cur(n)||!oi(s))return t.write(`\u{1F6D1} fleet stopped (supervisor pid=${s} exited).
506
508
  `),{status:"stopped",pid:s};await Sur(1e3)}return t.write(`warn: supervisor pid=${s} did not exit within 30s of the stop file; escalating to SIGTERM/SIGKILL.
507
509
  `),await Cg(s)?(await oct(n,{force:!0}),await oct(o,{force:!0}),t.write(`\u{1F6D1} fleet stopped (supervisor pid=${s} killed after graceful-stop timeout).
508
510
  `),{status:"stopped",pid:s}):(t.write(`\u2717 supervisor pid=${s} survived SIGKILL; still live \u2014 see .red/tmp/afk-supervisor.log.
509
- `),{status:"timeout",pid:s})}async function wur(e,t=process.cwd(),r=process.stdout){let n=ict(e);if(!Number.isInteger(n.target)||n.target<0)throw new Error("fleet target must be a non-negative integer");let o=wR(t,".red","tmp");await xur(o,{recursive:!0});let i=wR(o,"afk-supervisor.pid"),s=wR(o,"afk-supervisor.log"),a=await $P(o,ni);a.status==="stale"&&r.write(`cleaned stale supervisor files under .red/tmp before fleet launch.
511
+ `),{status:"timeout",pid:s})}async function wur(e,t=process.cwd(),r=process.stdout){let n=ict(e);if(!Number.isInteger(n.target)||n.target<0)throw new Error("fleet target must be a non-negative integer");let o=wR(t,".red","tmp");await xur(o,{recursive:!0});let i=wR(o,"afk-supervisor.pid"),s=wR(o,"afk-supervisor.log"),a=await $P(o,oi);a.status==="stale"&&r.write(`cleaned stale supervisor files under .red/tmp before fleet launch.
510
512
  `);let c=a.status==="live"?a.pid:null;if(c){let d=ow(),f=Y4(t,r),p=await f.liveness();if(BM(p,f.now(),d.supervisorStaleS,d.progressStaleS)!=="quiescent")throw new Error(`fleet already running (supervisor pid=${c}, log .red/tmp/afk-supervisor.log).
511
513
  to stop it: /dev:afk fleet stop`);let g=p.lastHeartbeatEpoch!==null?f.now()-p.lastHeartbeatEpoch:null;f.log(`\u26A0\uFE0F fleet pre-check: supervisor pid=${c} is QUIESCENT \u2014 heartbeat stale ${g??"?"}s \u2265 ${d.supervisorStaleS}s; recovering before relaunch.`),await EJ(f,p.pid)}let u=GC({flag:n.runnerFlag??yM(e),processTree:zC(),scriptPath:process.argv[1]}),l=await z4({root:t,target:n.target,runner:u.runner,passthrough:n.passthrough,request:n.request,drainBudgetUsd:n.drainBudgetUsd});if(!l){let d="";try{d=(await Eur(s,"utf8")).split(/\r?\n/).slice(-20).join(`
512
514
  `)}catch{}throw new Error(`fleet launch failed: supervisor pid file did not appear. log: .red/tmp/afk-supervisor.log
@@ -550,8 +552,8 @@ ${l}`);let d=await YP(e,t,s.envelopeStatus,n,{validation:r.sidecar.join(`
550
552
  `)}async function Mdr(e,t,r,n,o){return(await _R(e.envelope,{status:"done",issue:t.issue,worker:t.workerId,durationS:n,branch:t.branch,attempt:t.attempt,mergeSha:r,diff:"merged",sections:{validation:o.join(`
551
553
  `)},historyPath:e.historyPath,historyClock:e.historyClock,historyFields:{runner:t.runner,merge_sha:r}})).posted}async function YP(e,t,r,n,o){let i=kR("afk-attempts",t.workerId,t.issue,IR(t.title))??"";return(await _R(e.envelope,{status:r,issue:t.issue,worker:t.workerId,durationS:e.nowEpoch()-n,branch:t.branch,attempt:t.attempt,diff:"not-landed",remoteName:i,repo:t.repo,repoDir:t.repoDir,worktreeRel:t.attemptDir,diffstat:"",sections:o,historyPath:e.historyPath,historyClock:e.historyClock,historyFields:{runner:t.runner}})).posted}async function BR(e,t,r,n){if(e.recordAttempt)try{await e.recordAttempt(hY({repo:t.repo,issue:t.issue,attempt:t.attempt,outcome:r,labels:t.labels,title:t.title,body:t.body,workerId:t.workerId,branch:t.branch,durationS:n.durationS,mergeSha:n.mergeSha,notes:n.notes,validationSummary:n.validationSummary}))}catch(o){e.appendIterLog(`\u{1F916} /afk reconcile memory attempt-record for #${t.issue} failed (best-effort; ignored): ${String(o)}`)}}async function Fdr(e,t,r){if(e.fs.writeValidationSidecar&&r.length!==0)try{await e.fs.writeValidationSidecar(`${t}/validation.jsonl`,r)}catch{}}async function Ldr(e,t){try{let r=await e.gh.listByLabel(`req:${t}`);if(r.length===0)return;let n=new Map([[t,!0]]),o=async s=>{let a=n.get(s);if(a!==void 0)return a;let c=await e.gh.issueClosed(s);return n.set(s,c),c},i=[];for(let s of r){let a=jP(s.labels),c=[];for(let u of a)c.push({n:u,closed:await o(u)});i.push({number:s.number,reqs:c})}for(let s of rY(t,i)){await e.gh.editLabels(s.number,[ac,...s.reqLabels],[Je]);let a=s.refs.map(c=>Number(c.slice(1))).filter(c=>Number.isFinite(c));await e.gh.comment(s.number,await qP(a,e.gh.issueReference))}}catch(r){e.appendIterLog(`\u{1F916} /afk reconcile close-cascade for #${t} failed (best-effort; boot sweep will retry): ${String(r)}`)}}function dut(e,t,r={}){let n={issue:{number:e.issue,title:e.title},workspace:e.repoDir,branch:t};return r.mergeBase&&(n.merge_base=r.mergeBase),r.mergeSha&&(n.merge_commit={sha:r.mergeSha,short:r.mergeSha.slice(0,7)}),JSON.stringify(n)}var Udr="<<<<<<<",$dr="=======",Hdr=">>>>>>>";function Wdr(e){let t=e.split(`
552
554
  `),r=[],n=0;for(;n<t.length;){if(!t[n].startsWith(Udr)){n++;continue}let o=[],i=[];n++;let s=!1,a=!1;for(;n<t.length;n++){if(t[n].startsWith($dr)){s=!0;continue}if(t[n].startsWith(Hdr)){n++,a=!0;break}(s?i:o).push(t[n])}a&&r.push({ours:o,theirs:i})}return r}function jdr(e,t){let r=i=>{let s=i.map(a=>a.replace(/\s+$/,""));for(;s.length>0&&s[s.length-1]==="";)s.pop();return s},n=r(e),o=r(t);return n.length!==o.length?!1:n.every((i,s)=>i===o[s])}function qdr(e){return jdr(e.ours,e.theirs)?"trailing-whitespace":null}function put(e){let t=Wdr(e);if(t.length===0)return"semantic";let r=null;for(let n of t){let o=qdr(n);if(o===null)return"semantic";r=o}return r??"semantic"}function mut(e){let t=[],r=[];for(let n of e)Zct(n)==="mechanical"?t.push(n):r.push(n);return{mechanical:t,nonMechanical:r}}Kd();import{readFileSync as nfr}from"node:fs";import{join as yut,resolve as xut}from"node:path";import{existsSync as Gdr,readFileSync as yxn}from"node:fs";import{dirname as zdr,join as Vdr}from"node:path";function hut(e,t){let r=e;for(let n=0;n<16;n++){let o=Vdr(r,t);if(Gdr(o))return o;let i=zdr(r);if(i===r)break;r=i}return null}function Ydr(e){let t=e.indexOf(" #");return(t>=0?e.slice(0,t):e).trim()}function AY(e,t){let r=[];for(let n of e.split(`
553
- `)){let o=n.replace(/\r$/,""),i=o.trim();if(!i||i.startsWith("#"))continue;let s=o.indexOf(":");if(s<0)continue;let a=o.length-o.trimStart().length,c=o.slice(0,s).trim();if(!c)continue;let u=o.slice(s+1).trim();for(;r.length&&r[r.length-1].indent>=a;)r.pop();if(r.push({indent:a,key:c}),u&&r.map(d=>d.key).join(".")===t)return Ydr(u)}}function gut(e,t){return AY(e,`plugins.${t}.enabled`)==="true"}import{createHash as Jdr,randomUUID as Cxn}from"node:crypto";import{readFileSync as Kdr}from"node:fs";import{tmpdir as Zdr}from"node:os";import{dirname as yY,join as Rl,resolve as TAe}from"node:path";var Xdr=108;function DR(e){let t=tfr(e)??TAe(e),r=efr(t);return{rootDir:t,socketPath:Rl(r,"rsp.sock"),pidPath:Rl(r,"rsp.pid"),lockPath:Rl(r,"rsp.lock"),wakeLockPath:Rl(t,".red","tmp","rsp.wake.lock"),summaryPath:Rl(t,".red","tmp","rsp-status-summary.json"),registryPath:Rl(t,".red","tmp","rsp-resident.pid.json")}}function efr(e){let t=Jdr("sha256").update(e).digest("hex").slice(0,20),r=process.env.XDG_RUNTIME_DIR;if(r){let o=Rl(r,"red-skills",t);if(Rl(o,"rsp.sock").length<Xdr)return o}let n=typeof process.getuid=="function"?process.getuid():"nouid";return Rl(Zdr(),`red-skills-${n}`,t)}function tfr(e){let t=TAe(e);for(let r=0;r<32;r++){try{let o=BAe(Rl(t,".git"));if(o!=null)return rfr(t,o)??t;if(BAe(Rl(t,".git","HEAD"))!=null||BAe(Rl(t,".red","config.yaml"))!=null)return t}catch{}let n=yY(t);if(n===t)return null;t=n}return null}function rfr(e,t){let r=/^gitdir:\s*(.+?)\s*$/m.exec(t);if(!r)return null;let n=TAe(e,r[1]);return/[/\\]worktrees[/\\][^/\\]+$/.test(n)?yY(yY(yY(n))):null}function BAe(e){try{return Kdr(e,"utf8")}catch{return null}}var ofr=8*1024,ifr=".red/tmp/red-skills.rdb",sfr=7,afr=64*1024*1024,cfr=90,ufr=4*1024*1024,lfr=3e4,dfr=2e3,ffr=5*6e4,pfr=5e3;function DAe(e,t,r){let n=hut(xut(e),yut(".red","config.yaml")),o=n?nfr(n,"utf8"):"",i=AY(o,"rsp.enabled")==="true",s=Ox(_g(o,"rsp.ttlDays"),sfr),a=Ox(_g(o,"rsp.byteBudget"),afr),c=Ox(_g(o,"rsp.telemetryTtlDays"),cfr),u=Ox(_g(o,"rsp.telemetryByteBudget")??_g(o,"rsp.byteBudget"),ufr),l=Ox(xY(t.RSP_TELEMETRY_DRAIN_INTERVAL_MS)??_g(o,"rsp.telemetryDrainIntervalMs"),lfr),d=Ox(xY(t.RSP_TELEMETRY_DRAIN_TIMEOUT_MS)??_g(o,"rsp.telemetryDrainTimeoutMs"),dfr),f=mfr(xY(t.RSP_IDLE_MS)??_g(o,"rsp.idleMs"),ffr,pfr),p=Ox(xY(t.RSP_HEAVY_GIT_BYTE_THRESHOLD)??_g(o,"rsp.heavyGitByteThreshold"),ofr),m=DR(e).rootDir,g=r??t.RSP_STORE_URI??`file://${yut(xut(m),ifr)}`;return{enabled:i,storeUri:g,ttlDays:s,byteBudget:a,telemetryTtlDays:c,telemetryByteBudget:u,telemetryDrainIntervalMs:l,telemetryDrainTimeoutMs:d,idleMs:f,heavyGitByteThreshold:p}}function _g(e,t){let r=AY(e,t);if(r==null)return;let n=Number(r);return Number.isFinite(n)?n:void 0}function Ox(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function mfr(e,t,r){let n=Ox(e,t);return Math.max(n,r)}function xY(e){if(e==null||e.trim()==="")return;let t=Number(e);return Number.isFinite(t)?t:void 0}var QAe=[{id:"git:status",command:["git","status"],wrapper:["git","status"]},{id:"git:log",command:["git","log"],wrapper:["git","log"]},{id:"git:diff",command:["git","diff"],wrapper:["git","diff"]},{id:"git:commit",command:["git","commit"],wrapper:["git","commit"]},{id:"git:push",command:["git","push"],wrapper:["git","push"]},{id:"git:blame",command:["git","blame"],wrapper:["git","blame"]},{id:"git:branch:av",command:["git","branch","-av"],wrapper:["git","branch","-av"]},{id:"git:show",command:["git","show"],wrapper:["git","show"]},{id:"gh:pr:list",command:["gh","pr","list"],wrapper:["gh","pr","list"]},{id:"gh:pr:view",command:["gh","pr","view"],wrapper:["gh","pr","view"]},{id:"gh:issue:list",command:["gh","issue","list"],wrapper:["gh","issue","list"]},{id:"gh:issue:view",command:["gh","issue","view"],wrapper:["gh","issue","view"]},{id:"gh:run:list",command:["gh","run","list"],wrapper:["gh","run","list"]},{id:"gh:run:view",command:["gh","run","view"],wrapper:["gh","run","view"]},{id:"vitest",command:["vitest"],wrapper:["vitest"]},{id:"vitest:run",command:["vitest","run"],wrapper:["vitest","run"]},{id:"cargo:test",command:["cargo","test"],wrapper:["cargo","test"]}],Vxn=Afr(QAe);function Afr(e){let t=new Map;for(let r of e)t.set(yfr(r.command),["rsp",...r.wrapper]);return t}function yfr(e){return e.join("\0")}function JP(e=QAe,t={}){let r=e.map(i=>{let s=i.command.join(" "),a=["rsp",...i.wrapper].join(" ");return`| \`${s}\` | \`${a}\` |`}),n=e.map(i=>{let s=["rsp",...i.wrapper].join(" ");return`- For \`${i.command.join(" ")}\`, prefer \`${s}\` when the summarized output is enough.`}),o=xfr(t.runner);return["# rsp \u2014 token-efficient command wrappers","","<!-- GENERATED FILE \u2014 do not edit by hand."," Source: apps/rsp/src/intercept.ts (RSP_WRAPPER_CAPABILITIES),"," rendered by apps/rsp/src/ambient-skill.ts."," Regenerate: pnpm --filter @reddb-io/rsp gen:ambient-skill -->","","`rsp` wraps noisy development commands and stores their full output in a","reversible elision store, so the agent reads a compact summary and can","recover the original bytes on demand with `rsp show el:<id>`.","",...o,...o.length>0?[""]:[],"## Wrapped commands","","When you would run one of these commands, run it through `rsp` instead:","","| Command | rsp wrapper |","| --- | --- |","| `cat <file>` | `rsp cat <file>` |","| `head <file>` / `head -n N <file>` | `rsp cat --head N <file>` |","| `tail <file>` / `tail -n N <file>` | `rsp cat --tail N <file>` |",...r,"","## When to prefer rsp","","- For deterministic file reads, prefer `rsp cat <file>`; code files render an outline plus bounded content, text/config files are threshold-gated, and binary files pass through untouched.","- For simple file dumps, Claude pre-exec may rewrite bare `cat <file>`, `head <file>`, `head -n N <file>`, `tail <file>`, and `tail -n N <file>` when the path is an unquoted single file token.",...n,"","For arbitrary shell pipelines or compound commands where only final stdout",'should enter the agent context, call `rsp exec -- "<command line>"` directly.',"Bytes inside pipes remain untouched; stderr and exit status follow the raw","shell command.","","Use raw commands when exact stdout/stderr is the behavior under test, when","a wrapper does not support the command shape, or when resolving low-level","git conflicts where every byte matters.","","## Standardized Waiting","","Never hand-write sleep polling loops; run `rsp wait` in a background shell - process exit IS the signal.","","Examples:","",'- `rsp wait pr 123 --reason "before merge"` waits for a GitHub PR\'s checks and reports pass/fail plus mergeable state.',"- `rsp wait run 987654321` waits for a GitHub Actions run conclusion.","- `rsp wait run --branch feature/wait --latest` waits for the latest run on a branch.",'- `rsp wait release --tag "v2.*"` waits for the next matching release to publish.','- `rsp wait cmd -- "pnpm -C apps/rsp build"` runs a local async command and waits for its exit.',"- `rsp wait ls` lists active waits from `.red/tmp/waits/`.","","Exit codes: `0` = success verdict, `1` = failure verdict, `2` = timeout/indeterminate.","Every wait writes a live registry entry under `.red/tmp/waits/` with its target, reason, pid, started time, poll tier, and status, then removes that entry on every exit path.","","## Loss levels","","Use `--brief` for compact summaries that keep enough inline context for","normal debugging. Use `--terse` for large or repetitive output; lossy output","mints an `el:<id>` handle, and `rsp show el:<id>` writes the original bytes","back to stdout. Use `--full` when exact inline output is required.","","`rsp cat <file>`, large `rsp git diff`, and large `rsp git log` output may","truncate by default; pass `--full` when exact inline output is required.","","## Recovering elided output","","`rsp show el:<id>` writes the original bytes verbatim to stdout. Expired or","evicted handles print `expired <ISO date> \u2014 re-run: <original command>` and","exit 1, so the exact command to reproduce the output is always in reach.","","## Failure behavior","","If an rsp wrapper is disabled, lacks its store, or fails, it passes through to the raw command","with the raw command's stdout, stderr, and exit status intact.",""].join(`
554
- `)}function xfr(e){return e==="codex"?["## Codex lane","","This ambient instruction is the primary Codex lane: call `rsp` directly","when one of the wrapped command forms applies."]:e==="claude"?["## Claude lane","","Claude Code pre-execution interception is available for simple wrapped","commands, and direct calls still help when composing commands deliberately."]:[]}var Efr='<details data-attempt-status="',bfr='<details data-kind="directive">';function Sfr(e){return e.replace(/\s/g,"").length===0}function Cfr(e){return e.startsWith(Efr)&&e.includes("</details>")}function wfr(e){return e.startsWith("\u{1F916} /afk started ")}function Ifr(e){return e.startsWith("\u{1F916} /afk promoted to ready-for-agent")}function kfr(e){let t=e.replace(/\s/g,"");return/^:(one|two|three|four|five|six):$/.test(t)}function OAe(e){let t=[],r=0,n=!1,o="";for(let i of e.split(`
555
+ `)){let o=n.replace(/\r$/,""),i=o.trim();if(!i||i.startsWith("#"))continue;let s=o.indexOf(":");if(s<0)continue;let a=o.length-o.trimStart().length,c=o.slice(0,s).trim();if(!c)continue;let u=o.slice(s+1).trim();for(;r.length&&r[r.length-1].indent>=a;)r.pop();if(r.push({indent:a,key:c}),u&&r.map(d=>d.key).join(".")===t)return Ydr(u)}}function gut(e,t){return AY(e,`plugins.${t}.enabled`)==="true"}import{createHash as Jdr,randomUUID as Cxn}from"node:crypto";import{readFileSync as Kdr}from"node:fs";import{tmpdir as Zdr}from"node:os";import{dirname as yY,join as Rl,resolve as TAe}from"node:path";var Xdr=108;function DR(e){let t=tfr(e)??TAe(e),r=efr(t);return{rootDir:t,socketPath:Rl(r,"rsp.sock"),pidPath:Rl(r,"rsp.pid"),lockPath:Rl(r,"rsp.lock"),wakeLockPath:Rl(t,".red","tmp","rsp.wake.lock"),summaryPath:Rl(t,".red","tmp","rsp-status-summary.json"),registryPath:Rl(t,".red","tmp","rsp-resident.pid.json")}}function efr(e){let t=Jdr("sha256").update(e).digest("hex").slice(0,20),r=process.env.XDG_RUNTIME_DIR;if(r){let o=Rl(r,"red-skills",t);if(Rl(o,"rsp.sock").length<Xdr)return o}let n=typeof process.getuid=="function"?process.getuid():"nouid";return Rl(Zdr(),`red-skills-${n}`,t)}function tfr(e){let t=TAe(e);for(let r=0;r<32;r++){try{let o=BAe(Rl(t,".git"));if(o!=null)return rfr(t,o)??t;if(BAe(Rl(t,".git","HEAD"))!=null||BAe(Rl(t,".red","config.yaml"))!=null)return t}catch{}let n=yY(t);if(n===t)return null;t=n}return null}function rfr(e,t){let r=/^gitdir:\s*(.+?)\s*$/m.exec(t);if(!r)return null;let n=TAe(e,r[1]);return/[/\\]worktrees[/\\][^/\\]+$/.test(n)?yY(yY(yY(n))):null}function BAe(e){try{return Kdr(e,"utf8")}catch{return null}}var ofr=8*1024,ifr=".red/tmp/red-skills.rdb",sfr=7,afr=64*1024*1024,cfr=90,ufr=4*1024*1024,lfr=3e4,dfr=2e3,ffr=5*6e4,pfr=5e3;function DAe(e,t,r){let n=hut(xut(e),yut(".red","config.yaml")),o=n?nfr(n,"utf8"):"",i=AY(o,"rsp.enabled")==="true",s=Ox(_g(o,"rsp.ttlDays"),sfr),a=Ox(_g(o,"rsp.byteBudget"),afr),c=Ox(_g(o,"rsp.telemetryTtlDays"),cfr),u=Ox(_g(o,"rsp.telemetryByteBudget")??_g(o,"rsp.byteBudget"),ufr),l=Ox(xY(t.RSP_TELEMETRY_DRAIN_INTERVAL_MS)??_g(o,"rsp.telemetryDrainIntervalMs"),lfr),d=Ox(xY(t.RSP_TELEMETRY_DRAIN_TIMEOUT_MS)??_g(o,"rsp.telemetryDrainTimeoutMs"),dfr),f=mfr(xY(t.RSP_IDLE_MS)??_g(o,"rsp.idleMs"),ffr,pfr),p=Ox(xY(t.RSP_HEAVY_GIT_BYTE_THRESHOLD)??_g(o,"rsp.heavyGitByteThreshold"),ofr),m=DR(e).rootDir,g=r??t.RSP_STORE_URI??`file://${yut(xut(m),ifr)}`;return{enabled:i,storeUri:g,ttlDays:s,byteBudget:a,telemetryTtlDays:c,telemetryByteBudget:u,telemetryDrainIntervalMs:l,telemetryDrainTimeoutMs:d,idleMs:f,heavyGitByteThreshold:p}}function _g(e,t){let r=AY(e,t);if(r==null)return;let n=Number(r);return Number.isFinite(n)?n:void 0}function Ox(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:t}function mfr(e,t,r){let n=Ox(e,t);return Math.max(n,r)}function xY(e){if(e==null||e.trim()==="")return;let t=Number(e);return Number.isFinite(t)?t:void 0}var QAe=[{id:"git:status",command:["git","status"],wrapper:["git","status"]},{id:"git:log",command:["git","log"],wrapper:["git","log"]},{id:"git:diff",command:["git","diff"],wrapper:["git","diff"]},{id:"git:commit",command:["git","commit"],wrapper:["git","commit"]},{id:"git:push",command:["git","push"],wrapper:["git","push"]},{id:"git:blame",command:["git","blame"],wrapper:["git","blame"]},{id:"git:branch:av",command:["git","branch","-av"],wrapper:["git","branch","-av"]},{id:"git:show",command:["git","show"],wrapper:["git","show"]},{id:"gh:pr:list",command:["gh","pr","list"],wrapper:["gh","pr","list"]},{id:"gh:pr:view",command:["gh","pr","view"],wrapper:["gh","pr","view"]},{id:"gh:issue:list",command:["gh","issue","list"],wrapper:["gh","issue","list"]},{id:"gh:issue:view",command:["gh","issue","view"],wrapper:["gh","issue","view"]},{id:"gh:run:list",command:["gh","run","list"],wrapper:["gh","run","list"]},{id:"gh:run:view",command:["gh","run","view"],wrapper:["gh","run","view"]},{id:"vitest",command:["vitest"],wrapper:["vitest"]},{id:"vitest:run",command:["vitest","run"],wrapper:["vitest","run"]},{id:"cargo:test",command:["cargo","test"],wrapper:["cargo","test"]}],Vxn=Afr(QAe);function Afr(e){let t=new Map;for(let r of e)t.set(yfr(r.command),["rsp",...r.wrapper]);return t}function yfr(e){return e.join("\0")}function JP(e=QAe,t={}){let r=e.map(i=>{let s=i.command.join(" "),a=["rsp",...i.wrapper].join(" ");return`| \`${s}\` | \`${a}\` |`}),n=e.map(i=>{let s=["rsp",...i.wrapper].join(" ");return`- For \`${i.command.join(" ")}\`, prefer \`${s}\` when the summarized output is enough.`}),o=xfr(t.runner);return["# rsp \u2014 token-efficient command wrappers","","<!-- GENERATED FILE \u2014 do not edit by hand."," Source: apps/rsp/src/intercept.ts (RSP_WRAPPER_CAPABILITIES),"," rendered by apps/rsp/src/ambient-skill.ts."," Regenerate: pnpm --filter @reddb-io/rsp gen:ambient-skill -->","","`rsp` wraps noisy development commands and stores their full output in a","reversible elision store, so the agent reads a compact summary and can","recover the original bytes on demand with `rsp show el:<id>`.","",...o,...o.length>0?[""]:[],"## Wrapped commands","","When you would run one of these commands, run it through `rsp` instead:","","| Command | rsp wrapper |","| --- | --- |","| `cat <file>` | `rsp cat <file>` |","| `head <file>` / `head -n N <file>` | `rsp cat --head N <file>` |","| `tail <file>` / `tail -n N <file>` | `rsp cat --tail N <file>` |",...r,"","## When to prefer rsp","","- For deterministic file reads, prefer `rsp cat <file>`; code files render an outline plus bounded content, text/config files are threshold-gated, and binary files pass through untouched.","- For simple file dumps, the host pre-exec hook may rewrite bare `cat <file>`, `head <file>`, `head -n N <file>`, `tail <file>`, and `tail -n N <file>` when the path is an unquoted single file token.",...n,"","For arbitrary shell pipelines or compound commands where only final stdout",'should enter the agent context, call `rsp exec -- "<command line>"` directly.',"Bytes inside pipes remain untouched; stderr and exit status follow the raw","shell command.","","Use raw commands when exact stdout/stderr is the behavior under test, when","a wrapper does not support the command shape, or when resolving low-level","git conflicts where every byte matters.","","## Standardized Waiting","","Never hand-write sleep polling loops; run `rsp wait` in a background shell - process exit IS the signal.","","Examples:","",'- `rsp wait pr 123 --reason "before merge"` waits for a GitHub PR\'s checks and reports pass/fail plus mergeable state.',"- `rsp wait run 987654321` waits for a GitHub Actions run conclusion.","- `rsp wait run --branch feature/wait --latest` waits for the latest run on a branch.",'- `rsp wait release --tag "v2.*"` waits for the next matching release to publish.','- `rsp wait cmd -- "pnpm -C apps/rsp build"` runs a local async command and waits for its exit.',"- `rsp wait ls` lists active waits from `.red/tmp/waits/`.","","Exit codes: `0` = success verdict, `1` = failure verdict, `2` = timeout/indeterminate.","Every wait writes a live registry entry under `.red/tmp/waits/` with its target, reason, pid, started time, poll tier, and status, then removes that entry on every exit path.","","## Loss levels","","Use `--brief` for compact summaries that keep enough inline context for","normal debugging. Use `--terse` for large or repetitive output; lossy output","mints an `el:<id>` handle, and `rsp show el:<id>` writes the original bytes","back to stdout. Use `--full` when exact inline output is required.","","`rsp cat <file>`, large `rsp git diff`, and large `rsp git log` output may","truncate by default; pass `--full` when exact inline output is required.","","## Recovering elided output","","`rsp show el:<id>` writes the original bytes verbatim to stdout. Expired or","evicted handles print `expired <ISO date> \u2014 re-run: <original command>` and","exit 1, so the exact command to reproduce the output is always in reach.","","## Failure behavior","","If an rsp wrapper is disabled, lacks its store, or fails, it passes through to the raw command","with the raw command's stdout, stderr, and exit status intact.",""].join(`
556
+ `)}function xfr(e){return e==="codex"?["## Codex lane","","Codex pre-execution rewrite hook is available for simple wrapped","commands when the repo opts into `rsp.enabled`; direct `rsp` calls still","help when composing commands deliberately. Codex PostToolUse cannot","replace completed Bash output, so post-exec output normalization remains","a Claude-only hook gap; invocation accounting comes from the rewritten","`rsp` command's telemetry event."]:e==="claude"?["## Claude lane","","Claude Code pre-execution interception is available for simple wrapped","commands, and direct calls still help when composing commands deliberately."]:e==="opencode"?["## OpenCode lane","","OpenCode receives this guidance through the generated opencode plugin surface.","The plugin can rewrite simple shell-tool commands before execution, and direct","`rsp` calls still help when composing commands deliberately."]:[]}var Efr='<details data-attempt-status="',bfr='<details data-kind="directive">';function Sfr(e){return e.replace(/\s/g,"").length===0}function Cfr(e){return e.startsWith(Efr)&&e.includes("</details>")}function wfr(e){return e.startsWith("\u{1F916} /afk started ")}function Ifr(e){return e.startsWith("\u{1F916} /afk promoted to ready-for-agent")}function kfr(e){let t=e.replace(/\s/g,"");return/^:(one|two|three|four|five|six):$/.test(t)}function OAe(e){let t=[],r=0,n=!1,o="";for(let i of e.split(`
555
557
  `)){i.endsWith("\r")&&(i=i.slice(0,-1));let s=i.trim();if(s.startsWith("```")){r>0&&(o+=`
556
558
  `+i),n=!n;continue}if(n){r>0&&(o+=`
557
559
  `+i);continue}if(r===0){s===bfr&&(r=1,o="");continue}if(s.startsWith("<details")){r+=1,o+=`
@@ -609,15 +611,15 @@ ${e.labels.join(`
609
611
  `)}function Lpr(e){if(!e)return!1;let t="prev-failure-reason:",r=e.indexOf(t),n=r===-1?e:e.slice(r+t.length);return/\bmerge-conflict\b/.test(n)}function rlt(e,t,r){return e.resolveTier?.(t,r)??{model:e.model,effort:e.effort}}var nlt=0,jAe=1,Upr=124;function $pr(e){let t={"current.phase":"terminal","current.outcome":e};return e==="done"?{...t,"current.last_exit_code":nlt}:e==="blocked"?{...t,"current.last_exit_code":nlt}:e==="stalled"?{...t,"current.last_exit_code":Upr,"current.failure_kind":"timeout"}:e==="no-sentinel"?{...t,"current.last_exit_code":jAe,"current.failure_kind":"crash"}:e==="signal-killed"?{...t,"current.last_exit_code":jAe,"current.failure_kind":"signal-killed"}:{...t,"current.last_exit_code":jAe}}function ult(e){return e??"stalled"}function Hpr(e){let t=ult(e);return t==="edit-loop-stall"?"_(attempt aborted by attempt guard: edit-loop-stall \u2014 worktree diff volume changed without reaching a new high-water mark)_":t==="hard-cap"?"_(attempt aborted by attempt guard: hard-cap \u2014 worktree edits continued without a fresh commit)_":"_(attempt aborted by attempt guard: stalled \u2014 no new commit or diff growth within the wall-clock guard)_"}function llt(e,t){e.markState?.($pr(t))}function dlt(e){return e.filter(t=>t.startsWith("blocked:"))}var Wpr=new Set(["stalled","crashed","merge-conflict"]);async function flt(e,t,r,n,o){let i=CM(o);return i===null?e.gh.editLabels(t,r,n):(await e.gh.ensureLabel(i),e.gh.editLabels(t,r,[...n,i]))}async function NR(e,t,r,n,o,i){try{return sm({edge:i,fromLabels:r,removeLabels:n,addLabels:o}),await e.gh.editLabels(t,n,o)}catch(s){if(!(s instanceof XC))throw s;let a=dlt([...r]).filter(u=>!o.includes(u)),c=[...new Set([...n,...a])];try{sm({edge:i,fromLabels:r,removeLabels:c,addLabels:o})}catch(u){let l=u instanceof Error?u.message:String(u);e.appendIterLog(`warn: lifecycle transition "${i}" for #${t} still malformed after reconcile (${l}); applying best-effort park.`)}return await e.gh.editLabels(t,c,o)}}async function rm(e,t,r,n,o={}){let i=af(r,n,e.recoveryEnv??{},{stalledRecoverable:!1}),s=o.forceDecision??i.decision;if(!o.forceDecision){let a=await olt(e,"on_recovery_decision",JSON.stringify({issue:{number:t,title:""},decision:s,reason:r,attempt_n:n})),c=jpr(a.context);c!==null&&(s=c)}if(s==="escalate"){i.typedLabel!==null&&await e.gh.ensureLabel(i.typedLabel);let a=i.typedLabel!==null?[rt,i.typedLabel]:[rt];if(await NR(e,t,[ze],[ze],a,"human-blocked"),s===i.decision&&i.escalationComment!==null&&await e.gh.comment(t,i.escalationComment),await olt(e,"on_blocked",JSON.stringify({issue:{number:t,title:""},blocked_label:i.typedLabel??"",reason:r,attempt_n:n})),e.gh.renderDecisionCard)try{await e.gh.renderDecisionCard(t)}catch{}}else await NR(e,t,[ze],[ze],[Je],"retry");return s}async function olt(e,t,r){try{let n=QC(e.hooks.config,e.hooks.resolveOptions);return await HP(t,n[t],r,e.hooks.exec,{env:e.hooks.env??{},log:o=>e.appendIterLog(o)})}catch{return{context:r,aborted:!1}}}function jpr(e){try{let t=JSON.parse(e);if(typeof t!="object"||t===null)return null;let r=t.decision;return r==="retry"||r==="escalate"?r:null}catch{return null}}function qpr(e){try{let t=JSON.parse(e);if(typeof t!="object"||t===null)return null;let r=t.class;return r==="infra"||r==="semantic"?r:null}catch{return null}}function Gpr(e){let t=e.recoveryEnv?.RED_GO_VERIFY_RETRIES,r=t===void 0?NaN:Number(t);return Number.isInteger(r)&&r>=0?r:e.goVerifyRetries!==void 0&&Number.isInteger(e.goVerifyRetries)&&e.goVerifyRetries>=0?e.goVerifyRetries:cct}function zpr(e,t){let r=e.split(`
610
612
  `);return r.slice(Math.max(0,r.length-t)).join(`
611
613
  `)}function Vpr(e,t){return[e.replace(/\n+$/,""),"","<go-machine-gate-retry>",`The ${t.gate} machine gate failed after DONE. This is bounded correction retry ${t.retry}/${t.cap}.`,"Fix the failure on the existing branch, run the relevant gate, commit only the needed changes, then emit the required terminal sentinel.","","<validation-tail>",zpr(t.validation,80),"</validation-tail>","</go-machine-gate-retry>",""].join(`
612
- `)}var Ypr=new Set([".adoc",".avif",".gif",".ico",".jpeg",".jpg",".md",".mdx",".pdf",".png",".rst",".svg",".txt",".webp"]);function Jpr(e){let t=e.split("/").pop()??e,r=t.lastIndexOf(".");return r>0?t.slice(r).toLowerCase():""}function Kpr(e){return e.some(t=>!Ypr.has(Jpr(t)))}function Zpr(e){let t=e.slice(0,8).map(n=>`\`${n}\``).join(", "),r=e.length>8?`, and ${e.length-8} more`:"";return`DONE diff warning: attempt changed no source files; changed files: ${t}${r}.`}async function Xpr(e,t,r){let n=e.sandboxMode??"none";if(!r?.authorSourceTrust)return{sandboxMode:n,authorTrusted:!0,refused:!1};let o=r.authorSourceTrust==="trusted";if(!o&&e.gh.actorTrustSignals){let s=await Bl(t,r.author,a=>e.gh.actorTrustSignals(a));o=s.executable&&s.basis!=="permissive-default"}if(o)return{sandboxMode:n,authorTrusted:!0,refused:!1};let i=n==="docker"?["docker","podman"]:n==="podman"?["podman","docker"]:["docker","podman"];for(let s of i)if(!e.sandboxAvailable||await e.sandboxAvailable(s))return{sandboxMode:s,authorTrusted:!1,refused:!1};return{sandboxMode:n,authorTrusted:!1,refused:!0,reason:`untrusted issue author ${r.author?`'${r.author}'`:"(unknown)"} requires container isolation, but no docker/podman sandbox backend is available`}}async function emr(e,t,r,n){if(await NR(e,t.issue,[Je],[Je],[rt],"preflight-blocked"),await e.gh.comment(t.issue,`\u{1F916} /afk preflight stopped: ${n}. Autonomous execution refused; maintainer intervention required.`),e.gh.renderDecisionCard)try{await e.gh.renderDecisionCard(t.issue)}catch{}return await ba(e,t),{outcome:"blocked",issue:t.issue,hooksFired:r,preserved:!1,swept:!1}}async function tmr(e,t){if(!t.baselineProbeRan)return null;let{findMainRedRepairIssue:r,createMainRedRepairIssue:n,updateMainRedRepairIssue:o,closeMainRedRepairIssue:i}=e.gh;if(!r||!n||!o||!i)return null;try{let s=await r(),a=Sst(t.baselineFailures??[],s);switch(a.action){case"noop":return null;case"create":{let c=await n({title:a.title,body:a.body,labels:a.labels});return e.appendIterLog(`\u{1F916} /afk baseline probe: opened main-red repair issue #${c}.`),null}case"update":return await o(a.issue,{title:a.title,body:a.body,labels:a.labels}),e.appendIterLog(`\u{1F916} /afk baseline probe: updated main-red repair issue #${a.issue}.`),null;case"close":return await i(a.issue,a.comment),e.appendIterLog(`\u{1F916} /afk baseline probe: closed main-red repair issue #${a.issue}.`),null}}catch(s){let a=s instanceof Error?s.message:String(s);return e.appendIterLog(`warn: main-red repair issue sync failed: ${a}`),a}}async function plt(e,t){let{issue:r}=t,n=[],o=e.nowEpoch(),i=QC(e.hooks.config,e.hooks.resolveOptions),s=!1,a=async()=>{if(s){s=!1;try{await ba(e,t)}finally{LAe(null)}return}await e.claimLock.release(r)},c,u=async(_t,ps)=>{n.push(_t);let Fs=await HP(_t,i[_t],ps,e.hooks.exec,{env:e.hooks.env??{},log:jx=>e.appendIterLog(jx)});if(_t==="pre_worktree"&&!Fs.aborted){let jx=gmr(Fs.context);jx&&(c=jx)}return Fs},l=async(_t,ps)=>!(await u(_t,ps)).aborted;if(!await e.claimLock.acquire(r))return MC(r,n);let d=t.laneLabel??Je,f=await e.gh.viewLabels(r);if(!f.includes(d))return await e.claimLock.release(r),MC(r,n);if(e.claimGh){let _t=await Uat(e.claimGh,{worker:t.claimant??t.workerId,runner:t.runner},r,{isStale:e.claimStale,deathFor:e.recoveredWorkerDeathCause});if(_t.verdict==="lost")return await e.claimLock.release(r),MC(r,n,e,_t);s=!0,LAe(async()=>{s&&(s=!1,await ba(e,t))})}else if(f.includes(ze))return await e.claimLock.release(r),MC(r,n,e,void 0,"running label already present");let p=Ea(t.body);if(p&&!Wpr.has(p.kind))return await e.gh.ensureLabel(Qg),await NR(e,r,f,[Je],[rt,Qg],"preflight-blocked"),await e.gh.comment(r,`\u{1F916} /afk preflight stopped: active Current blocker (${p.kind}) still requires human input: ${p.next}`),await a(),{outcome:"blocked",issue:r,hooksFired:n,preserved:!1,swept:!1};let m=e.gh.repoVisibility?await e.gh.repoVisibility():void 0,g=Tl(e.hooks.config,m),A;e.gh.issueTrust&&(A=await e.gh.issueTrust(r));let E=!!(g.failClosed&&e.gh.actorTrustSignals);if((g.enabled||E)&&A){let _t=e.gh.actorTrustSignals,Fs=await zut(g,A,_t?jx=>_t(jx):async()=>({}));if(!Fs.executable)return e.appendIterLog(`\u{1F916} /afk trust gate refused #${r} [${Gut(g)}]: ${Fs.reason} \u2014 not claimed; no worktree/handoff materialised.`),await a(),MC(r,n,e,void 0,Fs.reason)}let y=await Xpr(e,g,A);if(y.refused){let _t=y.reason??"untrusted issue author requires container isolation";return e.appendIterLog(`\u{1F916} /afk sandbox policy refused #${r}: ${_t}.`),emr(e,t,n,_t)}!y.authorTrusted&&y.sandboxMode!==(e.sandboxMode??"none")&&e.appendIterLog(`\u{1F916} /afk sandbox policy: untrusted issue author forced ${y.sandboxMode} isolation for #${r}.`);let b=[Je,...dlt(f)];if(!await NR(e,r,f,b,[ze],"claim")&&!e.claimGh)return await a(),MC(r,n);let I=IR(t.title),v=kR("afk",t.workerId,r,I);if(v===null)return await NR(e,r,[ze],[ze],[Je],"retry"),await a(),MC(r,n);let k=await pf(t.baseInput,e.lookups.base),R=(e.lookups.base.configTrunk??"").trim()||"main",B=e.nowIso();if(await e.fs.ensureAttemptDir(t.attemptDir),await e.gh.comment(r,`\u{1F916} /afk started at \`${B}\` on runner \`${t.runner}\` (worker \`${t.workerId}\`). branch: \`${v}\``),!await l("pre_worktree",sc({issue:r,title:t.title,target:v,branch:v})))return await OR(e,t,v,k,n,"pre_worktree");let L=await e.lookups.comments(r),D=await e.lookups.issueUrl(r),ee=await e.lookups.priorAttemptContext(r),F=Cut(r,e.outputShaping??{terseSteering:!1}),_=vut({issue:r,title:t.title,body:t.body,runner:t.runner,started:B,attempt:t.attempt,url:D,comments:L,priorAttemptContext:ee,specRef:t.specRef,mergeGateCommands:e.backpressureCommands??[],outputShaping:F});e.markState?.({"current.output_shaping_enabled":F.enabled,"current.output_shaping_variant":F.variant});let P=`${t.attemptDir}/handoff.md`;await e.fs.writeHandoff(P,_),e.appendIterLog(jut(r,B));let $=await e.classifyIssue?.(Kut({issue:r,title:t.title,body:t.body,labels:f})).catch(()=>{})??"think";if(!await l("pre_attempt",sc({issue:r,title:t.title,workspace:v,runner:t.runner,attempt_n:t.attempt})))return await OR(e,t,v,k,n,"pre_attempt");let N;if(e.git.resolveFreshBase?N=await e.git.resolveFreshBase({base:k,remote:t.remote}):(e.git.fetchBase&&await e.git.fetchBase(k),N={ok:!0,base:k,baseRef:Mpr(t.remote,k),sha:"",source:"remote",remoteReachable:!0}),e.markState?.(Fpr(N)),!N.ok){let _t={deps:e,input:t,branch:v,base:k,slug:I,hooksFired:n,startedEpoch:o,issueType:mY(f),modelTier:$,model:e.model,effort:e.effort,resolvedBase:N},ps=N.message??"Base is stale; remote is unreachable and local ref is behind.";return await tm(_t,"base-stale","base-stale",{notes:ps,log:ps})}let q=N.baseRef;await e.git.prepareFreshWorkerBranch?.({branch:v,baseRef:q,force:Lpr(ee)});let re=mw(t.runner),ie=t.attempt,ue=$,Oe=mY(f),Ye=!1,T=v,J={...t,runner:re,attempt:ie},Ne={deps:e,input:J,branch:T,base:k,slug:I,hooksFired:n,startedEpoch:o,issueType:Oe,modelTier:ue,model:e.model,effort:e.effort,resolvedBase:N},Cr=[],Li,oi,at=!1,Fr=null,jn=_,Mo=0,Ui=0,$i,Ms=0,iu,Pye=[],Mye=t.runMode==="scout"?_t=>{_t.type==="text"&&Pye.push(_t.message),e.recordAgentEvent?.(_t)}:e.recordAgentEvent,Fye=_t=>`${Ms===0?`Inner agent emitted ${$i} with zero commits`:`Inner agent emitted ${$i} after ${Ms} commit(s) and left dirty worktree paths`}; AFK salvaged ${Ui} uncommitted file(s), but ${_t==="feedback"?"feedback validation failed":"backpressure validation failed after the feedback gate passed"}. The worker branch was not merged.`,ZY=Gpr(e),XY=async(_t,ps)=>t.laneLabel!==Dg||Mo>=ZY?!1:(Mo+=1,ie+=1,jn=Vpr(_,{gate:_t,validation:ps,retry:Mo,cap:ZY}),e.appendIterLog(`\u{1F916} /go: ${_t} machine gate failed after DONE; correction retry ${Mo}/${ZY}.`),await l("pre_attempt",sc({issue:r,title:t.title,workspace:v,runner:re,attempt_n:ie})));for(;;){let _t=rlt(e,re,ue),ps={runner:re,model:_t.model,effort:_t.effort,handoffPath:P,handoffContent:jn,systemPrompt:NAe({runMode:t.runMode,structuredOutput:i_(mw(re)),runner:re}),branch:v,base:q,cwd:t.attemptDir,logPath:`${t.attemptDir}/afk.log`,onAgentEvent:Mye,onHeartbeat:He=>{let Wi=e.heartbeatVitals?.();l("on_heartbeat",sc({issue:r,title:t.title,workspace:v,runner:re,attempt_n:ie,...Wi?{vitals:Wi}:{}})),e.emitHeartbeat?.({...He,base:k})},remote:t.remote,continuousPush:t.runMode!=="scout",goalProbe:()=>e.gh.issueClosed(r),env:c,sandboxMode:y.sandboxMode},Fs=e.notesLoop??{enabled:!1,maxIterations:1,innerMaxIterations:0,tokenBudget:0,wallClockS:0},yr=(await Jut({config:Fs,baseHandoff:jn,runOnce:({handoff:He})=>e.runAgent({...ps,handoffContent:He,...Fs.enabled&&Fs.innerMaxIterations>0?{maxIterations:Fs.innerMaxIterations}:{}}),persistNotes:He=>e.writeNotes?.(Yut(t.attemptDir),He),now:()=>e.nowEpoch()*1e3,tokensSpent:()=>{let He=e.heartbeatVitals?.();return He?(He.input_tokens??0)+(He.output_tokens??0):0},log:He=>e.appendIterLog(He)})).run;if(slt(yr.outcome)){if(!e.fallbackRunner)return await alt(e,t,v,k,n,re,yr.outcome,!1);await l("post_attempt",eM({...t,attempt:ie},v,"fail",yr.outcome));let He=re==="claude"?"codex":"claude";if(re=He,ie+=1,!await l("pre_attempt",sc({issue:r,title:t.title,workspace:v,runner:re,attempt_n:ie})))return await OR(e,t,v,k,n,"pre_attempt");let Wi=rlt(e,He,ue);if(yr=await e.runAgent({runner:He,model:Wi.model,effort:Wi.effort,handoffPath:P,handoffContent:jn,systemPrompt:NAe({runMode:t.runMode,structuredOutput:i_(mw(He)),runner:He}),branch:v,base:k,cwd:t.attemptDir,logPath:`${t.attemptDir}/afk.log`,onAgentEvent:Mye,remote:t.remote,continuousPush:t.runMode!=="scout",goalProbe:()=>e.gh.issueClosed(r),env:c,sandboxMode:y.sandboxMode}),slt(yr.outcome))return await l("post_attempt",eM({...t,attempt:ie},v,"fail",yr.outcome)),await alt(e,t,v,k,n,re,yr.outcome,!0)}if(T=yr.branch||v,J={...t,runner:re,attempt:ie},Ne={deps:e,input:J,branch:T,base:k,slug:I,hooksFired:n,startedEpoch:o,issueType:Oe,modelTier:ue,model:_t.model,effort:_t.effort},e.exitBarrier&&yr.outcome==="done"){try{of("exit-barrier:start"),iu=await e.exitBarrier(T),of("exit-barrier:pushed")}catch(He){if(of("exit-barrier:failed"),He instanceof KP)return await l("on_attempt_error",CY(J,T,"merge-conflict",J.attempt)),await tm(Ne,"merge-conflict","merge-conflict",{notes:`_(exit barrier: could not push the attempt branch \`${T}\` to origin after retry \u2014 work is NOT confirmed saved, so the attempt is not reported as cleanly done)_`,log:String(He)});throw He}if(iu.salvagedFiles>0){Ui=iu.salvagedFiles,$i=yr.outcome,Ms=yr.commits.length;let He=yr.commits.length===0?"committed nothing":`left dirty worktree paths after ${yr.commits.length} commit(s)`;e.appendIterLog(`\u{1F916} /afk: inner agent emitted done but ${He} \u2014 exit barrier salvaged ${iu.salvagedFiles} uncommitted file(s) onto \`${T}\` and pushed to origin (receipt head ${iu.head||"?"}).`)}else e.appendIterLog(`\u{1F916} /afk: exit barrier pushed \`${T}\` to origin (clean worktree; receipt head ${iu.head||"?"}).`)}else if(e.salvageUncommitted&&(yr.outcome==="done"||yr.outcome==="no-sentinel"||yr.outcome==="budget-exceeded")){let He=await e.salvageUncommitted(T).catch(()=>0);if(He>0){Ui=He,$i=yr.outcome,Ms=yr.commits.length;let Wi=yr.commits.length===0?"committed nothing":`left dirty worktree paths after ${yr.commits.length} commit(s)`;e.appendIterLog(`\u{1F916} /afk: inner agent emitted ${yr.outcome} but ${Wi} \u2014 salvaged ${He} uncommitted file(s) onto \`${T}\` so the feedback gate + landing see the work.`)}}if(yr.outcome==="budget-exceeded")return await l("on_attempt_error",CY(J,T,"budget-exceeded",J.attempt)),await tm(Ne,"budget-exceeded","budget",{notes:Ui>0?`_(budget guard aborted the attempt; salvaged ${Ui} uncommitted file(s) onto \`${T}\` \u2014 partial work preserved for review)_`:"_(budget guard aborted the attempt; no uncommitted work to salvage)_",log:yr.stdout||"afk: attempt aborted \u2014 per-attempt resource budget exceeded (#908)"});let Hye=!1;if(yr.outcome==="no-sentinel"){if(!(t.runMode!=="scout"&&(await e.lookups.changedFiles(T,q)).length>0&&(!e.lookups.branchPresent||await e.lookups.branchPresent(T))))return await l("on_attempt_error",CY(J,T,"no-sentinel",J.attempt)),await tm(Ne,"no-sentinel","no-sentinel",{notes:"_(no Notes appended; inner agent exited without a sentinel and the branch carries no work)_",log:yr.stdout&&yr.stdout.split(`
614
+ `)}var Ypr=new Set([".adoc",".avif",".gif",".ico",".jpeg",".jpg",".md",".mdx",".pdf",".png",".rst",".svg",".txt",".webp"]);function Jpr(e){let t=e.split("/").pop()??e,r=t.lastIndexOf(".");return r>0?t.slice(r).toLowerCase():""}function Kpr(e){return e.some(t=>!Ypr.has(Jpr(t)))}function Zpr(e){let t=e.slice(0,8).map(n=>`\`${n}\``).join(", "),r=e.length>8?`, and ${e.length-8} more`:"";return`DONE diff warning: attempt changed no source files; changed files: ${t}${r}.`}async function Xpr(e,t,r){let n=e.sandboxMode??"none";if(!r?.authorSourceTrust)return{sandboxMode:n,authorTrusted:!0,refused:!1};let o=r.authorSourceTrust==="trusted";if(!o&&e.gh.actorTrustSignals){let s=await Bl(t,r.author,a=>e.gh.actorTrustSignals(a));o=s.executable&&s.basis!=="permissive-default"}if(o)return{sandboxMode:n,authorTrusted:!0,refused:!1};let i=n==="docker"?["docker","podman"]:n==="podman"?["podman","docker"]:["docker","podman"];for(let s of i)if(!e.sandboxAvailable||await e.sandboxAvailable(s))return{sandboxMode:s,authorTrusted:!1,refused:!1};return{sandboxMode:n,authorTrusted:!1,refused:!0,reason:`untrusted issue author ${r.author?`'${r.author}'`:"(unknown)"} requires container isolation, but no docker/podman sandbox backend is available`}}async function emr(e,t,r,n){if(await NR(e,t.issue,[Je],[Je],[rt],"preflight-blocked"),await e.gh.comment(t.issue,`\u{1F916} /afk preflight stopped: ${n}. Autonomous execution refused; maintainer intervention required.`),e.gh.renderDecisionCard)try{await e.gh.renderDecisionCard(t.issue)}catch{}return await ba(e,t),{outcome:"blocked",issue:t.issue,hooksFired:r,preserved:!1,swept:!1}}async function tmr(e,t){if(!t.baselineProbeRan)return null;let{findMainRedRepairIssue:r,createMainRedRepairIssue:n,updateMainRedRepairIssue:o,closeMainRedRepairIssue:i}=e.gh;if(!r||!n||!o||!i)return null;try{let s=await r(),a=Sst(t.baselineFailures??[],s);switch(a.action){case"noop":return null;case"create":{let c=await n({title:a.title,body:a.body,labels:a.labels});return e.appendIterLog(`\u{1F916} /afk baseline probe: opened main-red repair issue #${c}.`),null}case"update":return await o(a.issue,{title:a.title,body:a.body,labels:a.labels}),e.appendIterLog(`\u{1F916} /afk baseline probe: updated main-red repair issue #${a.issue}.`),null;case"close":return await i(a.issue,a.comment),e.appendIterLog(`\u{1F916} /afk baseline probe: closed main-red repair issue #${a.issue}.`),null}}catch(s){let a=s instanceof Error?s.message:String(s);return e.appendIterLog(`warn: main-red repair issue sync failed: ${a}`),a}}async function plt(e,t){let{issue:r}=t,n=[],o=e.nowEpoch(),i=QC(e.hooks.config,e.hooks.resolveOptions),s=!1,a=async()=>{if(s){s=!1;try{await ba(e,t)}finally{LAe(null)}return}await e.claimLock.release(r)},c,u=async(_t,ps)=>{n.push(_t);let Fs=await HP(_t,i[_t],ps,e.hooks.exec,{env:e.hooks.env??{},log:jx=>e.appendIterLog(jx)});if(_t==="pre_worktree"&&!Fs.aborted){let jx=gmr(Fs.context);jx&&(c=jx)}return Fs},l=async(_t,ps)=>!(await u(_t,ps)).aborted;if(!await e.claimLock.acquire(r))return MC(r,n);let d=t.laneLabel??Je,f=await e.gh.viewLabels(r);if(!f.includes(d))return await e.claimLock.release(r),MC(r,n);if(e.claimGh){let _t=await Uat(e.claimGh,{worker:t.claimant??t.workerId,runner:t.runner},r,{isStale:e.claimStale,deathFor:e.recoveredWorkerDeathCause});if(_t.verdict==="lost")return await e.claimLock.release(r),MC(r,n,e,_t);s=!0,LAe(async()=>{s&&(s=!1,await ba(e,t))})}else if(f.includes(ze))return await e.claimLock.release(r),MC(r,n,e,void 0,"running label already present");let p=Ea(t.body);if(p&&!Wpr.has(p.kind))return await e.gh.ensureLabel(Qg),await NR(e,r,f,[Je],[rt,Qg],"preflight-blocked"),await e.gh.comment(r,`\u{1F916} /afk preflight stopped: active Current blocker (${p.kind}) still requires human input: ${p.next}`),await a(),{outcome:"blocked",issue:r,hooksFired:n,preserved:!1,swept:!1};let m=e.gh.repoVisibility?await e.gh.repoVisibility():void 0,g=Tl(e.hooks.config,m),A;e.gh.issueTrust&&(A=await e.gh.issueTrust(r));let E=!!(g.failClosed&&e.gh.actorTrustSignals);if((g.enabled||E)&&A){let _t=e.gh.actorTrustSignals,Fs=await zut(g,A,_t?jx=>_t(jx):async()=>({}));if(!Fs.executable)return e.appendIterLog(`\u{1F916} /afk trust gate refused #${r} [${Gut(g)}]: ${Fs.reason} \u2014 not claimed; no worktree/handoff materialised.`),await a(),MC(r,n,e,void 0,Fs.reason)}let y=await Xpr(e,g,A);if(y.refused){let _t=y.reason??"untrusted issue author requires container isolation";return e.appendIterLog(`\u{1F916} /afk sandbox policy refused #${r}: ${_t}.`),emr(e,t,n,_t)}!y.authorTrusted&&y.sandboxMode!==(e.sandboxMode??"none")&&e.appendIterLog(`\u{1F916} /afk sandbox policy: untrusted issue author forced ${y.sandboxMode} isolation for #${r}.`);let b=[Je,...dlt(f)];if(!await NR(e,r,f,b,[ze],"claim")&&!e.claimGh)return await a(),MC(r,n);let I=IR(t.title),v=kR("afk",t.workerId,r,I);if(v===null)return await NR(e,r,[ze],[ze],[Je],"retry"),await a(),MC(r,n);let k=await pf(t.baseInput,e.lookups.base),R=(e.lookups.base.configTrunk??"").trim()||"main",B=e.nowIso();if(await e.fs.ensureAttemptDir(t.attemptDir),await e.gh.comment(r,`\u{1F916} /afk started at \`${B}\` on runner \`${t.runner}\` (worker \`${t.workerId}\`). branch: \`${v}\``),!await l("pre_worktree",sc({issue:r,title:t.title,target:v,branch:v})))return await OR(e,t,v,k,n,"pre_worktree");let L=await e.lookups.comments(r),D=await e.lookups.issueUrl(r),ee=await e.lookups.priorAttemptContext(r),F=Cut(r,e.outputShaping??{terseSteering:!1}),_=vut({issue:r,title:t.title,body:t.body,runner:t.runner,started:B,attempt:t.attempt,url:D,comments:L,priorAttemptContext:ee,specRef:t.specRef,mergeGateCommands:e.backpressureCommands??[],outputShaping:F});e.markState?.({"current.output_shaping_enabled":F.enabled,"current.output_shaping_variant":F.variant});let P=`${t.attemptDir}/handoff.md`;await e.fs.writeHandoff(P,_),e.appendIterLog(jut(r,B));let $=await e.classifyIssue?.(Kut({issue:r,title:t.title,body:t.body,labels:f})).catch(()=>{})??"think";if(!await l("pre_attempt",sc({issue:r,title:t.title,workspace:v,runner:t.runner,attempt_n:t.attempt})))return await OR(e,t,v,k,n,"pre_attempt");let N;if(e.git.resolveFreshBase?N=await e.git.resolveFreshBase({base:k,remote:t.remote}):(e.git.fetchBase&&await e.git.fetchBase(k),N={ok:!0,base:k,baseRef:Mpr(t.remote,k),sha:"",source:"remote",remoteReachable:!0}),e.markState?.(Fpr(N)),!N.ok){let _t={deps:e,input:t,branch:v,base:k,slug:I,hooksFired:n,startedEpoch:o,issueType:mY(f),modelTier:$,model:e.model,effort:e.effort,resolvedBase:N},ps=N.message??"Base is stale; remote is unreachable and local ref is behind.";return await tm(_t,"base-stale","base-stale",{notes:ps,log:ps})}let q=N.baseRef;await e.git.prepareFreshWorkerBranch?.({branch:v,baseRef:q,force:Lpr(ee)});let re=mw(t.runner),ie=t.attempt,ue=$,Oe=mY(f),Ye=!1,T=v,J={...t,runner:re,attempt:ie},Ne={deps:e,input:J,branch:T,base:k,slug:I,hooksFired:n,startedEpoch:o,issueType:Oe,modelTier:ue,model:e.model,effort:e.effort,resolvedBase:N},Cr=[],Li,ii,at=!1,Fr=null,jn=_,Mo=0,Ui=0,$i,Ms=0,iu,Pye=[],Mye=t.runMode==="scout"?_t=>{_t.type==="text"&&Pye.push(_t.message),e.recordAgentEvent?.(_t)}:e.recordAgentEvent,Fye=_t=>`${Ms===0?`Inner agent emitted ${$i} with zero commits`:`Inner agent emitted ${$i} after ${Ms} commit(s) and left dirty worktree paths`}; AFK salvaged ${Ui} uncommitted file(s), but ${_t==="feedback"?"feedback validation failed":"backpressure validation failed after the feedback gate passed"}. The worker branch was not merged.`,ZY=Gpr(e),XY=async(_t,ps)=>t.laneLabel!==Dg||Mo>=ZY?!1:(Mo+=1,ie+=1,jn=Vpr(_,{gate:_t,validation:ps,retry:Mo,cap:ZY}),e.appendIterLog(`\u{1F916} /go: ${_t} machine gate failed after DONE; correction retry ${Mo}/${ZY}.`),await l("pre_attempt",sc({issue:r,title:t.title,workspace:v,runner:re,attempt_n:ie})));for(;;){let _t=rlt(e,re,ue),ps={runner:re,model:_t.model,effort:_t.effort,handoffPath:P,handoffContent:jn,systemPrompt:NAe({runMode:t.runMode,structuredOutput:i_(mw(re)),runner:re}),branch:v,base:q,cwd:t.attemptDir,logPath:`${t.attemptDir}/afk.log`,onAgentEvent:Mye,onHeartbeat:He=>{let Wi=e.heartbeatVitals?.();l("on_heartbeat",sc({issue:r,title:t.title,workspace:v,runner:re,attempt_n:ie,...Wi?{vitals:Wi}:{}})),e.emitHeartbeat?.({...He,base:k})},remote:t.remote,continuousPush:t.runMode!=="scout",goalProbe:()=>e.gh.issueClosed(r),env:c,sandboxMode:y.sandboxMode},Fs=e.notesLoop??{enabled:!1,maxIterations:1,innerMaxIterations:0,tokenBudget:0,wallClockS:0},yr=(await Jut({config:Fs,baseHandoff:jn,runOnce:({handoff:He})=>e.runAgent({...ps,handoffContent:He,...Fs.enabled&&Fs.innerMaxIterations>0?{maxIterations:Fs.innerMaxIterations}:{}}),persistNotes:He=>e.writeNotes?.(Yut(t.attemptDir),He),now:()=>e.nowEpoch()*1e3,tokensSpent:()=>{let He=e.heartbeatVitals?.();return He?(He.input_tokens??0)+(He.output_tokens??0):0},log:He=>e.appendIterLog(He)})).run;if(slt(yr.outcome)){if(!e.fallbackRunner)return await alt(e,t,v,k,n,re,yr.outcome,!1);await l("post_attempt",eM({...t,attempt:ie},v,"fail",yr.outcome));let He=re==="claude"?"codex":"claude";if(re=He,ie+=1,!await l("pre_attempt",sc({issue:r,title:t.title,workspace:v,runner:re,attempt_n:ie})))return await OR(e,t,v,k,n,"pre_attempt");let Wi=rlt(e,He,ue);if(yr=await e.runAgent({runner:He,model:Wi.model,effort:Wi.effort,handoffPath:P,handoffContent:jn,systemPrompt:NAe({runMode:t.runMode,structuredOutput:i_(mw(He)),runner:He}),branch:v,base:k,cwd:t.attemptDir,logPath:`${t.attemptDir}/afk.log`,onAgentEvent:Mye,remote:t.remote,continuousPush:t.runMode!=="scout",goalProbe:()=>e.gh.issueClosed(r),env:c,sandboxMode:y.sandboxMode}),slt(yr.outcome))return await l("post_attempt",eM({...t,attempt:ie},v,"fail",yr.outcome)),await alt(e,t,v,k,n,re,yr.outcome,!0)}if(T=yr.branch||v,J={...t,runner:re,attempt:ie},Ne={deps:e,input:J,branch:T,base:k,slug:I,hooksFired:n,startedEpoch:o,issueType:Oe,modelTier:ue,model:_t.model,effort:_t.effort},e.exitBarrier&&yr.outcome==="done"){try{of("exit-barrier:start"),iu=await e.exitBarrier(T),of("exit-barrier:pushed")}catch(He){if(of("exit-barrier:failed"),He instanceof KP)return await l("on_attempt_error",CY(J,T,"merge-conflict",J.attempt)),await tm(Ne,"merge-conflict","merge-conflict",{notes:`_(exit barrier: could not push the attempt branch \`${T}\` to origin after retry \u2014 work is NOT confirmed saved, so the attempt is not reported as cleanly done)_`,log:String(He)});throw He}if(iu.salvagedFiles>0){Ui=iu.salvagedFiles,$i=yr.outcome,Ms=yr.commits.length;let He=yr.commits.length===0?"committed nothing":`left dirty worktree paths after ${yr.commits.length} commit(s)`;e.appendIterLog(`\u{1F916} /afk: inner agent emitted done but ${He} \u2014 exit barrier salvaged ${iu.salvagedFiles} uncommitted file(s) onto \`${T}\` and pushed to origin (receipt head ${iu.head||"?"}).`)}else e.appendIterLog(`\u{1F916} /afk: exit barrier pushed \`${T}\` to origin (clean worktree; receipt head ${iu.head||"?"}).`)}else if(e.salvageUncommitted&&(yr.outcome==="done"||yr.outcome==="no-sentinel"||yr.outcome==="budget-exceeded")){let He=await e.salvageUncommitted(T).catch(()=>0);if(He>0){Ui=He,$i=yr.outcome,Ms=yr.commits.length;let Wi=yr.commits.length===0?"committed nothing":`left dirty worktree paths after ${yr.commits.length} commit(s)`;e.appendIterLog(`\u{1F916} /afk: inner agent emitted ${yr.outcome} but ${Wi} \u2014 salvaged ${He} uncommitted file(s) onto \`${T}\` so the feedback gate + landing see the work.`)}}if(yr.outcome==="budget-exceeded")return await l("on_attempt_error",CY(J,T,"budget-exceeded",J.attempt)),await tm(Ne,"budget-exceeded","budget",{notes:Ui>0?`_(budget guard aborted the attempt; salvaged ${Ui} uncommitted file(s) onto \`${T}\` \u2014 partial work preserved for review)_`:"_(budget guard aborted the attempt; no uncommitted work to salvage)_",log:yr.stdout||"afk: attempt aborted \u2014 per-attempt resource budget exceeded (#908)"});let Hye=!1;if(yr.outcome==="no-sentinel"){if(!(t.runMode!=="scout"&&(await e.lookups.changedFiles(T,q)).length>0&&(!e.lookups.branchPresent||await e.lookups.branchPresent(T))))return await l("on_attempt_error",CY(J,T,"no-sentinel",J.attempt)),await tm(Ne,"no-sentinel","no-sentinel",{notes:"_(no Notes appended; inner agent exited without a sentinel and the branch carries no work)_",log:yr.stdout&&yr.stdout.split(`
613
615
  `).slice(-1)[0]||"(no captured stdout)"});Hye=!0,e.appendIterLog(`\u{1F916} /afk: no-sentinel exit but worker branch \`${T}\` carries work \u2014 salvaging through the feedback gate (issue #332).`),await l("post_attempt",eM(J,T,"success","no-sentinel"))}else if(yr.outcome==="goal-moot"){let He=e.lookups.branchMerged?await e.lookups.branchMerged(T,k).catch(()=>!1):!1,Wi=Rut({closed:!0,ownMerge:He}),Bg=Wi==="done"?"done":"claim-lost";await l("post_attempt",eM(J,T,Wi==="done"?"success":"fail","goal-moot")),e.appendIterLog(Wi==="done"?`\u{1F916} /afk #${r}: goal predicate \u2014 issue already CLOSED by this attempt's own merge; nothing to land (done).`:`\u{1F916} /afk #${r}: goal predicate \u2014 issue already CLOSED by another lander; attempt mooted (claim-lost).`);try{await e.gh.editLabels(r,[ze],[])}catch{}return await a(),{outcome:Bg,issue:r,branch:T,base:k,hooksFired:n,preserved:!1,swept:!1}}else if(yr.outcome==="timeout"){await l("on_attempt_timeout",sc({issue:r,title:t.title,workspace:v,runner:re,attempt_n:ie,reason:ult(yr.timeoutReason)}));let He=await TR({...e,fireHook:l},Amr(t,J,T,k,R,f,re));return await l("on_reconcile",sc({issue:r,title:t.title,workspace:v,attempt_n:ie,outcome:He.outcome})),He.outcome==="landed"?(await a(),{outcome:"done",issue:r,branch:T,base:k,locked:He.locked,mergeSha:He.mergeSha,hooksFired:n,envelopePosted:He.posted,preserved:!0,swept:!0}):He.outcome==="parked"?(await a(),{outcome:"feedback-failed",issue:r,branch:T,base:k,hooksFired:n,envelopePosted:He.posted,preserved:!0,swept:!1}):(await l("on_attempt_error",CY(J,T,"stalled",J.attempt)),await tm(Ne,"stalled","stalled",{notes:Hpr(yr.timeoutReason),log:yr.stdout||"(attempt progress guard fired)"}))}else{let He=yr.outcome==="done"?"success":"fail";if(await l("post_attempt",eM(J,T,He,yr.outcome)),yr.outcome==="blocked")return await tm(Ne,"blocked","blocked",{notes:`_(inner agent emitted BLOCKED \u2014 see iteration log at \`${t.attemptDir}\`)_`})}if(t.runMode==="scout"){let He=Pye.join("").trim()||"_Scout completed without output. Check the attempt log for details._";return await e.gh.comment(r,`## \u{1F50D} Scout Report
614
616
 
615
- ${He}`),await e.gh.close(r),await a(),{outcome:"done",issue:r,hooksFired:n,preserved:!1,swept:!1}}if(e.lookups.branchPresent&&!await e.lookups.branchPresent(T))return of("post-barrier:branch-present-failed"),e.appendIterLog(`\u{1F916} /afk: worker branch \`${T}\` absent on host \u2014 sandcastle commits did not reach the host; escalating.`),await wY(Ne,"worker branch absent \u2014 sandcastle commits did not reach the host");let Wye=e.postAttemptFormatCommands??[];if(e.postAttemptFormat&&Wye.length>0){of("post-barrier:post-attempt-format");let He=await Qut(e.postAttemptFormat,{worktree:T,commands:Wye,now:e.nowEpoch});for(let Wi of He.log)e.appendIterLog(`\u{1F916} /afk: ${Wi}`);if(!He.ok)return await OR(e,t,v,k,n,"post_attempt_format")}e.markPhase?.("validating"),of("post-barrier:feedback-start");let gM=await e.lookups.changedFiles(T,q);if(gM.length===0){let He="DONE rejected: attempt branch has no diff against the merge-base; no work changed, so the completion claim was not accepted.";if(e.appendIterLog(`\u{1F916} /afk: ${He}`),await XY("feedback",He))continue;return await tm(Ne,"feedback-failed","feedback",{notes:"Inner agent emitted DONE, but the attempt branch has no diff against the merge-base. The worker branch was not merged.",validation:He},{validationSummary:He})}oi=Kpr(gM)?void 0:Zpr(gM),oi&&e.appendIterLog(`\u{1F916} /afk: ${oi}`);let jye=_ut(gM,e.layout,e.graph??{packages:[]}),qye=But(jye);if(!await l("pre_feedback",sc({issue:r,title:t.title,workspace:v,scopes:qye})))return await OR(e,t,v,k,n,"pre_feedback");let Hi=await lY(e.pnpm,{worktree:T,scopes:qye,layout:e.layout,now:e.nowEpoch,baselineWorktree:k,validationScope:jye});if(of("post-barrier:feedback-done"),Hi.ok||await l("on_baseline_probe",sc({issue:r,title:t.title,workspace:v,ok:Hi.ok,downgraded:Hi.baselineDowngraded})),at=Hi.baselineProbeRan===!0&&(Hi.baselineFailures?.length??0)>0,Fr=await tmr(e,Hi),await l("post_feedback",sc({issue:r,title:t.title,workspace:v,result:{status:Hi.ok?"pass":"fail"}})),!Hi.ok){await qAe(e,t.attemptDir,Hi.sidecar);let He=uY(Hi),Wi=await u("on_feedback_classify",sc({issue:r,title:t.title,workspace:v,class:He?"infra":"semantic"})),Bg=qpr(Wi.context);if(Bg!==null&&(He=Bg==="infra"),!He&&ue==="simple"&&!Ye){if(Ye=!0,ue="complex",ie+=1,e.appendIterLog(`\u{1F916} /afk: simple-tier feedback failed for #${r}; retrying once on the complex tier before terminal validation routing.`),!await l("pre_attempt",sc({issue:r,title:t.title,workspace:v,runner:re,attempt_n:ie})))return await OR(e,t,v,k,n,"pre_attempt");continue}let nmt=He?"feedback-failed-infra":"feedback-failed",jR;He?jR=`Feedback validation failed for an INFRA reason (worktree/submodule/pnpm install/OOM) on branch \`${T}\` \u2014 the recovery policy will retry up to its cap.`:Ui>0?jR=Fye("feedback"):Hye?jR="Salvaged a no-sentinel branch (it carried work), but feedback validation failed \u2014 the branch was not merged.":jR="Feedback validation failed after the inner agent emitted DONE. The worker branch was not merged.";let Vye=`${Hi.validationScope?`${MAe(Hi.validationScope)}
617
+ ${He}`),await e.gh.close(r),await a(),{outcome:"done",issue:r,hooksFired:n,preserved:!1,swept:!1}}if(e.lookups.branchPresent&&!await e.lookups.branchPresent(T))return of("post-barrier:branch-present-failed"),e.appendIterLog(`\u{1F916} /afk: worker branch \`${T}\` absent on host \u2014 sandcastle commits did not reach the host; escalating.`),await wY(Ne,"worker branch absent \u2014 sandcastle commits did not reach the host");let Wye=e.postAttemptFormatCommands??[];if(e.postAttemptFormat&&Wye.length>0){of("post-barrier:post-attempt-format");let He=await Qut(e.postAttemptFormat,{worktree:T,commands:Wye,now:e.nowEpoch});for(let Wi of He.log)e.appendIterLog(`\u{1F916} /afk: ${Wi}`);if(!He.ok)return await OR(e,t,v,k,n,"post_attempt_format")}e.markPhase?.("validating"),of("post-barrier:feedback-start");let gM=await e.lookups.changedFiles(T,q);if(gM.length===0){let He="DONE rejected: attempt branch has no diff against the merge-base; no work changed, so the completion claim was not accepted.";if(e.appendIterLog(`\u{1F916} /afk: ${He}`),await XY("feedback",He))continue;return await tm(Ne,"feedback-failed","feedback",{notes:"Inner agent emitted DONE, but the attempt branch has no diff against the merge-base. The worker branch was not merged.",validation:He},{validationSummary:He})}ii=Kpr(gM)?void 0:Zpr(gM),ii&&e.appendIterLog(`\u{1F916} /afk: ${ii}`);let jye=_ut(gM,e.layout,e.graph??{packages:[]}),qye=But(jye);if(!await l("pre_feedback",sc({issue:r,title:t.title,workspace:v,scopes:qye})))return await OR(e,t,v,k,n,"pre_feedback");let Hi=await lY(e.pnpm,{worktree:T,scopes:qye,layout:e.layout,now:e.nowEpoch,baselineWorktree:k,validationScope:jye});if(of("post-barrier:feedback-done"),Hi.ok||await l("on_baseline_probe",sc({issue:r,title:t.title,workspace:v,ok:Hi.ok,downgraded:Hi.baselineDowngraded})),at=Hi.baselineProbeRan===!0&&(Hi.baselineFailures?.length??0)>0,Fr=await tmr(e,Hi),await l("post_feedback",sc({issue:r,title:t.title,workspace:v,result:{status:Hi.ok?"pass":"fail"}})),!Hi.ok){await qAe(e,t.attemptDir,Hi.sidecar);let He=uY(Hi),Wi=await u("on_feedback_classify",sc({issue:r,title:t.title,workspace:v,class:He?"infra":"semantic"})),Bg=qpr(Wi.context);if(Bg!==null&&(He=Bg==="infra"),!He&&ue==="simple"&&!Ye){if(Ye=!0,ue="complex",ie+=1,e.appendIterLog(`\u{1F916} /afk: simple-tier feedback failed for #${r}; retrying once on the complex tier before terminal validation routing.`),!await l("pre_attempt",sc({issue:r,title:t.title,workspace:v,runner:re,attempt_n:ie})))return await OR(e,t,v,k,n,"pre_attempt");continue}let nmt=He?"feedback-failed-infra":"feedback-failed",jR;He?jR=`Feedback validation failed for an INFRA reason (worktree/submodule/pnpm install/OOM) on branch \`${T}\` \u2014 the recovery policy will retry up to its cap.`:Ui>0?jR=Fye("feedback"):Hye?jR="Salvaged a no-sentinel branch (it carried work), but feedback validation failed \u2014 the branch was not merged.":jR="Feedback validation failed after the inner agent emitted DONE. The worker branch was not merged.";let Vye=`${Hi.validationScope?`${MAe(Hi.validationScope)}
616
618
  `:""}${Hi.sidecar.join(`
617
619
  `)}`;if(!He&&await XY("feedback",Vye))continue;return await tm(Ne,nmt,"feedback",{notes:jR,validation:Vye},{validationSummary:Hi.sidecar.join(`
618
620
  `)})}let Gye=e.backpressureCommands??[],zye=[];if(e.backpressure&&Gye.length>0){of("post-barrier:backpressure-start");let He=await Tut(e.backpressure,{worktree:T,commands:Gye,now:e.nowEpoch});if(zye=He.sidecar,of("post-barrier:backpressure-done"),Ne.backpressureChecks=He.checks,!He.ok){await qAe(e,t.attemptDir,[...Hi.sidecar,...He.sidecar]);let Wi=Ui>0?Fye("backpressure"):"Backpressure validation failed after the feedback gate passed. The worker branch was not merged.",Bg=He.sidecar.join(`
619
621
  `);if(await XY("backpressure",Bg))continue;return await tm(Ne,"feedback-failed","feedback",{notes:Wi,validation:Bg},{validationSummary:Bg})}}Cr=[...Hi.sidecar,...zye],Li=Hi.validationScope;break}of("post-barrier:landing-start");let Lye=await e.lookups.isLocked(),Uye=e.worktreeLaunchesPr!==!1;if(f.includes(qx))return await lmr(Ne,k,Cr);if(Uye&&e.reviewGate&&Xut(ue,e.reviewGate))return await umr(Ne,ue,Cr);let eJ=_t=>{let ps=e.nowIso();e.markState?.({"current.activity":"landing","current.phase":_t,"current.started_at":ps}),e.markPhase?.(_t)};eJ("gate");let Qn=await fY({mergeExec:e.mergeExec,remoteGit:e.remoteGit,fireHook:l,conflictResolver:e.conflictResolver,waitForReview:e.waitForReview,ciAwait:e.ciAwait,findMainRedRepairIssue:e.gh.findMainRedRepairIssue,makeLandingWorktree:e.makeLandingWorktree,removeLandingWorktree:e.removeLandingWorktree,makeRebaseWorktree:e.makeRebaseWorktree,removeRebaseWorktree:e.removeRebaseWorktree,landLock:e.landLock,onPrResolved:_t=>GAe(Ne,_t),getDiffPaths:async()=>{let ps=(await e.mergeExec(["git","-C",t.repoDir,"diff","--name-only",`${t.remote}/${k}...${T}`])).stdout.trim().split(`
620
- `).filter(Boolean),Fs=await e.mergeExec(["git","-C",t.repoDir,"diff",`${t.remote}/${k}...${T}`,"--","package.json","**/package.json"]);return{changedFiles:ps,packageJsonDiff:Fs.stdout}},landingPhase:eJ},{openPr:Uye,locked:Lye,repo:t.repo,repoDir:t.repoDir,remote:t.remote,branch:T,base:k,trunk:R,issue:r,title:t.title,labels:f,mainRed:at,nativeMergeQueue:e.nativeMergeQueue},{preMerge:()=>sc({issue:r,title:t.title,workspace:t.repoDir,branch:T,merge_base:k}),postMerge:_t=>sc({issue:r,title:t.title,workspace:t.repoDir,branch:T,merge_commit:_t?{sha:_t,short:_t.slice(0,7)}:void 0})});if(!Qn.ok){if(Qn.reason==="trunk-diverged")return await smr(Ne,R,Qn.localTrunkSha??"",Qn.originTrunkSha??"",Qn.locked);if(Qn.reason==="sensitive-paths")return await amr(Ne,Qn.sensitivePaths??[],Qn.locked);if(Qn.reason==="main-red-untracked")return await cmr(Ne,Qn.message??"Admin-merge refused: main is red without an open main-red repair issue.",Qn.locked,Fr);if(Qn.reason==="ci-failed"||Qn.reason==="ci-pending")return await imr(Ne,Qn.reason,Qn.prNumber);if(Qn.reason==="infra"){let _t=Qn.infraReason??"landing infrastructure precondition failed";return await tm(Ne,"infra","infra",{log:_t},{notes:_t})}return Qn.reason==="pr-conflict"?await ilt(Ne,"merge-conflict",Qn.prNumber,"the open PR has merge conflicts and could not be landed"):Qn.reason==="pr-merge-failed"?await ilt(Ne,"ci-failed",Qn.prNumber,"the open PR merge was rejected by GitHub, usually because branch protection or CI is not satisfied"):await wY(Ne,Qn.reason,Qn.locked)}let tJ=Qn.mergeSha??await e.git.headShortSha(),$ye=e.nowEpoch()-o;eJ("cascade"),await qAe(e,t.attemptDir,Cr);let rmt=await omr(Ne,tJ,$ye,Cr,Li,oi);return await nm(Ne,"done",{durationS:$ye,mergeSha:tJ,validationSummary:[oi,Cr.join(`
622
+ `).filter(Boolean),Fs=await e.mergeExec(["git","-C",t.repoDir,"diff",`${t.remote}/${k}...${T}`,"--","package.json","**/package.json"]);return{changedFiles:ps,packageJsonDiff:Fs.stdout}},landingPhase:eJ},{openPr:Uye,locked:Lye,repo:t.repo,repoDir:t.repoDir,remote:t.remote,branch:T,base:k,trunk:R,issue:r,title:t.title,labels:f,mainRed:at,nativeMergeQueue:e.nativeMergeQueue},{preMerge:()=>sc({issue:r,title:t.title,workspace:t.repoDir,branch:T,merge_base:k}),postMerge:_t=>sc({issue:r,title:t.title,workspace:t.repoDir,branch:T,merge_commit:_t?{sha:_t,short:_t.slice(0,7)}:void 0})});if(!Qn.ok){if(Qn.reason==="trunk-diverged")return await smr(Ne,R,Qn.localTrunkSha??"",Qn.originTrunkSha??"",Qn.locked);if(Qn.reason==="sensitive-paths")return await amr(Ne,Qn.sensitivePaths??[],Qn.locked);if(Qn.reason==="main-red-untracked")return await cmr(Ne,Qn.message??"Admin-merge refused: main is red without an open main-red repair issue.",Qn.locked,Fr);if(Qn.reason==="ci-failed"||Qn.reason==="ci-pending")return await imr(Ne,Qn.reason,Qn.prNumber);if(Qn.reason==="infra"){let _t=Qn.infraReason??"landing infrastructure precondition failed";return await tm(Ne,"infra","infra",{log:_t},{notes:_t})}return Qn.reason==="pr-conflict"?await ilt(Ne,"merge-conflict",Qn.prNumber,"the open PR has merge conflicts and could not be landed"):Qn.reason==="pr-merge-failed"?await ilt(Ne,"ci-failed",Qn.prNumber,"the open PR merge was rejected by GitHub, usually because branch protection or CI is not satisfied"):await wY(Ne,Qn.reason,Qn.locked)}let tJ=Qn.mergeSha??await e.git.headShortSha(),$ye=e.nowEpoch()-o;eJ("cascade"),await qAe(e,t.attemptDir,Cr);let rmt=await omr(Ne,tJ,$ye,Cr,Li,ii);return await nm(Ne,"done",{durationS:$ye,mergeSha:tJ,validationSummary:[ii,Cr.join(`
621
623
  `)].filter(Boolean).join(`
622
624
  `),notes:iu?`exit-barrier receipt: branch \`${iu.branch}\` pushed to origin at ${iu.pushedAt} (head ${iu.head||"?"}, salvaged ${iu.salvagedFiles} file(s)).`:void 0}),await e.gh.close(r),await e.gh.editLabels(r,[ze],[]),await Z4(e.remoteGit,t.repoDir,T),await e.git.deleteLocalBranch(T),await e.fs.completionSweep(r),await e.claimLock.release(r),llt(e,"done"),await dmr(e,r),await mmr(e,t,r,k,f),{outcome:"done",issue:r,branch:T,base:k,locked:Lye,mergeSha:tJ,hooksFired:n,envelopePosted:rmt,exitReceipt:iu,preserved:!0,swept:!0}}async function qAe(e,t,r){if(e.fs.writeValidationSidecar&&r.length!==0)try{await e.fs.writeValidationSidecar(`${t}/validation.jsonl`,r)}catch{}}async function nm(e,t,r={}){let{deps:n,input:o}=e,i=hY({repo:o.repo,issue:o.issue,attempt:o.attempt,outcome:t,issueType:e.issueType,modelTier:e.modelTier,title:o.title,body:o.body,workerId:o.workerId,branch:e.branch,durationS:r.durationS,diffstat:void 0,mergeSha:r.mergeSha,notes:r.notes,validationSummary:r.validationSummary});if(n.recordAttempt)try{await n.recordAttempt(i)}catch(s){n.appendIterLog(`\u{1F916} /afk memory attempt-record for #${o.issue} failed (best-effort; ignored): ${String(s)}`)}if(n.recordOutcomeEvent)try{let s={schemaVersion:1,id:`afk:${o.repo}:${o.issue}:${o.attempt}`,emitter:"afk",occurredAt:n.nowIso(),taskClass:e.modelTier,chosenOption:{kind:"runner",runner:o.runner,model:e.model,effort:e.effort},outcome:i.outcome,cost:{signal:"unknown"},context:{repository:o.repo,issueNumber:o.issue,attemptNumber:o.attempt,issueType:i.issueType,workerId:o.workerId,branch:e.branch,durationMs:i.durationMs,status:i.status}};n.recordOutcomeEvent(s).catch(a=>{n.appendIterLog(`\u{1F916} /afk brain outcome-event for #${o.issue} failed (best-effort; ignored): ${String(a)}`)})}catch(s){n.appendIterLog(`\u{1F916} /afk brain outcome-event for #${o.issue} failed (best-effort; ignored): ${String(s)}`)}}async function GAe(e,t){let{deps:r}=e;if(t===void 0||!r.postBackpressureReview)return;let n=Dut(e.backpressureChecks??[]);if(n!==null)try{await r.postBackpressureReview(t,n)}catch{}}async function Px(e,t,r,n){let{deps:o,input:i}=e,s=kR("afk-attempts",i.workerId,i.issue,e.slug)??"",a=o.nowEpoch()-e.startedEpoch;return(await _R(o.envelope,{status:t,issue:i.issue,worker:i.workerId,durationS:a,branch:e.branch,attempt:i.attempt,diff:r,remoteName:s,repo:i.repo,repoDir:i.repoDir,worktreeRel:i.attemptDir,diffstat:"",sections:{...n,...e.resolvedBase?{base:clt(e.resolvedBase)}:{}},historyPath:o.historyPath,historyClock:o.historyClock,historyFields:{runner:i.runner}})).posted}function ic(e,t){return(e??"").split(`
623
625
  `).map(n=>n.replace(/^[-*]\s*(?:\[[^\]]+\]\s*)?/,"").replace(/\s+/g," ").trim()).find(n=>n.length>0)??t}function Mx(e,t){switch(e){case"blocked":return{status:"blocked",kind:"spec",summary:ic(t.notes,"Inner agent emitted BLOCKED."),next:"Review the blocker envelope and add human guidance."};case"feedback-failed":return{status:"blocked",kind:"validation",summary:ic(t.validation??t.log,"Validation failed after implementation."),next:"Decide whether to fix forward, change scope, or adjust the acceptance criteria."};case"no-sentinel":return{status:"blocked",kind:"runner",summary:ic(t.log,"Inner agent exited without an AFK completion sentinel."),next:"Review the attempt log and decide whether to retry or revise the issue brief."};case"stalled":return{status:"blocked",kind:"stalled",summary:ic(t.log,"Inner agent made no progress (no new commit) within the attempt wall-clock."),next:"Review the work already pushed (branch/PR) and decide whether to continue, re-scope, or stop."};case"budget-exceeded":return{status:"blocked",kind:"budget",summary:ic(t.log,"Attempt aborted \u2014 per-attempt resource budget exceeded (#908)."),next:"Review the salvaged partial work (branch/PR) and decide whether to continue with a larger budget, re-scope, or stop."};case"merge-conflict":return{status:"blocked",kind:"merge-conflict",summary:ic(t.log,"Worker branch could not be merged cleanly."),next:"Resolve the merge conflict or add guidance for the next agent attempt."};case"ci-failed":return{status:"blocked",kind:"ci",summary:ic(t.log,"A required status check failed on the completed, mergeable PR."),next:"Fix the failing required check on the open PR, then merge it (no full agent re-run needed)."};case"ci-pending":return{status:"blocked",kind:"ci",summary:ic(t.log,"Required status checks were still pending on the completed, mergeable PR."),next:"Wait for the required checks to go green, then merge the open PR (no full agent re-run needed)."};case"trunk-diverged":return{status:"blocked",kind:"trunk-diverged",summary:ic(t.log,"Local trunk diverged from origin; landing aborted (ADR 0083)."),next:"Reconcile the primary checkout's local trunk with origin (no reset/stash/force-push), then requeue."};case"sensitive-path":return{status:"blocked",kind:"sensitive-path",summary:ic(t.log,"Diff touches a sensitive path (CI workflow, lifecycle script, git hook, or .red/ config)."),next:"Review the sensitive change, then requeue if it is safe to land."};case"main-red-untracked":return{status:"blocked",kind:"main-red-untracked",summary:ic(t.log,"Admin-merge refused because main is red without an open main-red repair issue."),next:"Restore or create the auto-filed main-red repair issue, then requeue."};case"base-stale":return{status:"blocked",kind:"base-stale",summary:ic(t.log,"Remote base was unreachable and the local base is stale."),next:"Refresh the local base from origin, or restore remote access, then requeue."};case"infra":return{status:"blocked",kind:"infra",summary:ic(t.log,"Landing infrastructure precondition failed."),next:"Fix the landing infrastructure failure, then requeue."};case"manual-landing":return{status:"blocked",kind:"manual-landing",summary:ic(t.log,"Manual-landing hold: the full pipeline ran and the PR is open, awaiting a human merge."),next:"Merge the open PR to land the work (it auto-closes this issue); no full agent re-run is needed."};default:return null}}var rmr=new Set(["spec","validation","merge-conflict","ci","stalled","decision","trunk-diverged","sensitive-path","main-red-untracked","infra"]);function nmr(e,t){return!e||t.kind!=="runner"?!1:rmr.has(e.kind)}async function Fx(e,t,r){if(!(!r||!e.gh.editBody))try{let n=Ea(t.body),o=nmr(n,r)?n:r,{body:i,changed:s}=aut(t.body,o);if(!s)return;await e.gh.editBody(t.issue,i)}catch{}}async function zAe(e,t){if(e.terminalExitBarrier)try{return await e.terminalExitBarrier(t)}catch{}return{branch:t,head:"",pushedAt:new Date().toISOString(),salvaged:!1,salvagedFiles:0,pushed:!1}}function VAe(e,t){return{...t,exitReceipt:e,preserved:!0,swept:!1}}async function tm(e,t,r,n,o={}){let{deps:i,input:s}=e;llt(i,t),await rm(i,s.issue,t,s.attempt)==="escalate"&&await Fx(i,s,Mx(t,n));let c=await Px(e,Ol(t),r,n);await nm(e,t,{durationS:i.nowEpoch()-e.startedEpoch,notes:o.notes,validationSummary:o.validationSummary});let u=await zAe(i,e.branch);return u.salvagedFiles>0&&i.appendIterLog(`\u{1F916} /afk: exit barrier salvaged ${u.salvagedFiles} uncommitted file(s) onto \`${e.branch}\` and pushed to origin (${t} terminal; receipt head ${u.head||"?"}).`),await ba(i,s),VAe(u,{outcome:t,issue:s.issue,branch:e.branch,base:e.base,hooksFired:e.hooksFired,envelopePosted:c})}async function omr(e,t,r,n,o,i){let{deps:s,input:a}=e,c=o?`${MAe(o)}
@@ -635,20 +637,20 @@ ${y.stderr.trim()}
635
637
  `),a.set(m,null),null;let b=await r.pnpm(["install","--frozen-lockfile"],{cwd:A});if(b.code!==0)return await r.worktreeRemove(s,A),process.stderr.write(`error: feedback worktree install failed for ${m} (exit ${b.code}); blocking validation
636
638
  ${b.stderr.trim()}
637
639
  `),a.set(m,null),null;if(i){let w=await r.rebase(s,A,i);w.ok||process.stderr.write(`warn: feedback worktree rebase of ${m} onto ${i} failed (${w.stderr||"no detail"}); running the gate on the un-rebased branch
638
- `)}return c.add(A),a.set(m,A),A}let l={hasPackage:m=>{let g=m==="."?e:MR(e,m);try{return Xmr(MR(g,"package.json"),ehr.F_OK),!0}catch{return!1}},hasScript:(m,g)=>{let A=m==="."?e:MR(e,m);try{let E=JSON.parse(thr(MR(A,"package.json"),"utf8"));return!!(E.scripts&&g in E.scripts)}catch{return!1}}};return{pnpm:async(m,g)=>{let A=g?.env??CAe(),E=m.indexOf("-C");if(E>=0&&m[E+1]!==void 0){let{branch:w,scope:I}=nhr(m[E+1],l.hasPackage),v=await u(w);if(v===null)return{code:1,stdout:"",stderr:`feedback worktree setup failed for ${w}; validation blocked`};let k=I==="."?v:MR(v,I),R=m.filter((L,D)=>D!==0&&D!==E&&D!==E+1),B=await r.pnpm(["-C",k,...R],{cwd:e,env:A});return{code:B.code,stdout:B.stdout,stderr:B.stderr}}let y=m[0]==="pnpm"?m.slice(1):m,b=await r.pnpm(y,{cwd:e,env:A});return{code:b.code,stdout:b.stdout,stderr:b.stderr}},layout:l,backpressure:async({command:m,cwd:g,timeoutMs:A})=>{let E=await u(g);if(E===null)return{code:1,stdout:"",stderr:`feedback worktree setup failed for ${g}; validation blocked`};let y=await r.exec("sh",["-c",m],{cwd:E,timeoutMs:A});return{code:y.code,stdout:y.stdout,stderr:y.stderr}},postAttemptFormat:async({command:m,cwd:g,timeoutMs:A})=>{let E=await u(g);if(E===null)return{code:1,stdout:"",stderr:`feedback worktree setup failed for ${g}; format aborted`,committed:!1};let y=await r.exec("sh",["-c",m],{cwd:E,timeoutMs:A});if(y.code!==0)return{code:y.code,stdout:y.stdout,stderr:y.stderr,committed:!1};if((await r.exec("git",["status","--porcelain"],{cwd:E})).stdout.trim()==="")return{code:0,stdout:y.stdout,stderr:y.stderr,committed:!1};let w=await r.exec("git",["add","-A"],{cwd:E});if(w.code!==0)return{code:w.code,stdout:w.stdout,stderr:w.stderr,committed:!1};let I=await r.exec("git",["commit","-m",`style: ${m}`],{cwd:E});if(I.code!==0)return{code:I.code,stdout:I.stdout,stderr:I.stderr,committed:!1};let v=await r.exec("git",["push","origin",`HEAD:${g}`],{cwd:E});return v.code!==0?{code:v.code,stdout:v.stdout,stderr:v.stderr,committed:!1}:{code:0,stdout:y.stdout,stderr:y.stderr,committed:!0}},async cleanup(){for(let m of c)await r.worktreeRemove(s,m);c.clear(),a.clear()}}}TM();import{join as Ft}from"node:path";pR();async function klt(e){let{headSha:t,compute:r,readMemo:n,writeMemo:o,computeUncommitted:i}=e,s=null;if(t){let c=n();c&&c.sha===t&&(s={added:c.added,removed:c.removed})}if(s===null&&(s=await r(),t&&o({sha:t,added:s.added,removed:s.removed})),!i)return s;let a=await i();return{added:s.added+a.added,removed:s.removed+a.removed}}function vlt(e,t="/"){return`${e}${t}.loc-memo.json`}function KAe(){let e=0,t=0,r=0,n=0,o=0,i=0,s=0,a=0,c=0,u=()=>e+t+r;return{record(l){l.type==="toolCall"?e+=1:l.type==="text"?t+=1:l.type==="usage"?(typeof l.inputTokens=="number"&&(i+=l.inputTokens),typeof l.outputTokens=="number"&&(s+=l.outputTokens),typeof l.costUsd=="number"&&(a+=l.costUsd)):l.type==="reasoning"&&(r+=1,typeof l.tokens=="number"&&l.tokens>0&&(n+=l.tokens))},snapshotWindow(){let l=u()-c;return l<=0&&(o+=1),c=u(),{toolsCalled:e,textChunks:t,reasoningCount:r,reasoningTokens:n,waiting:o,eventsThisWindow:Math.max(0,l),inputTokens:i,outputTokens:s,costUsd:a}},peek(){return{toolsCalled:e,textChunks:t,reasoningCount:r,reasoningTokens:n,waiting:o,eventsThisWindow:u()-c,inputTokens:i,outputTokens:s,costUsd:a}}}}CC();var _Y=class extends Error{constructor(t){super(t),this.name="RunFlagError"}};async function Dhr(e,t=ni){try{let r=(await sye(e,"utf8")).trim();if(!/^\d+$/.test(r))return{live:!1};let n=Number(r);return t(n)?{live:!0,pid:n}:{live:!1}}catch{return{live:!1}}}function Qhr(e,t=process.env){if(e.origin===aAe||e.origin===lAe||e.lane===Dg||e.lane===KC)return!0;let r=t.RED_AFK_WORKERS_NAMESPACE;return r===J4||r===K4}async function Ohr(e,t,r,n=ni,o=!1){if(o)return"clear";let i=await Dhr(e,n);return i.live?t?(r.write(`warn: --force: fleet supervisor pid=${i.pid} is still running; collision risk accepted.
640
+ `)}return c.add(A),a.set(m,A),A}let l={hasPackage:m=>{let g=m==="."?e:MR(e,m);try{return Xmr(MR(g,"package.json"),ehr.F_OK),!0}catch{return!1}},hasScript:(m,g)=>{let A=m==="."?e:MR(e,m);try{let E=JSON.parse(thr(MR(A,"package.json"),"utf8"));return!!(E.scripts&&g in E.scripts)}catch{return!1}}};return{pnpm:async(m,g)=>{let A=g?.env??CAe(),E=m.indexOf("-C");if(E>=0&&m[E+1]!==void 0){let{branch:w,scope:I}=nhr(m[E+1],l.hasPackage),v=await u(w);if(v===null)return{code:1,stdout:"",stderr:`feedback worktree setup failed for ${w}; validation blocked`};let k=I==="."?v:MR(v,I),R=m.filter((L,D)=>D!==0&&D!==E&&D!==E+1),B=await r.pnpm(["-C",k,...R],{cwd:e,env:A});return{code:B.code,stdout:B.stdout,stderr:B.stderr}}let y=m[0]==="pnpm"?m.slice(1):m,b=await r.pnpm(y,{cwd:e,env:A});return{code:b.code,stdout:b.stdout,stderr:b.stderr}},layout:l,backpressure:async({command:m,cwd:g,timeoutMs:A})=>{let E=await u(g);if(E===null)return{code:1,stdout:"",stderr:`feedback worktree setup failed for ${g}; validation blocked`};let y=await r.exec("sh",["-c",m],{cwd:E,timeoutMs:A});return{code:y.code,stdout:y.stdout,stderr:y.stderr}},postAttemptFormat:async({command:m,cwd:g,timeoutMs:A})=>{let E=await u(g);if(E===null)return{code:1,stdout:"",stderr:`feedback worktree setup failed for ${g}; format aborted`,committed:!1};let y=await r.exec("sh",["-c",m],{cwd:E,timeoutMs:A});if(y.code!==0)return{code:y.code,stdout:y.stdout,stderr:y.stderr,committed:!1};if((await r.exec("git",["status","--porcelain"],{cwd:E})).stdout.trim()==="")return{code:0,stdout:y.stdout,stderr:y.stderr,committed:!1};let w=await r.exec("git",["add","-A"],{cwd:E});if(w.code!==0)return{code:w.code,stdout:w.stdout,stderr:w.stderr,committed:!1};let I=await r.exec("git",["commit","-m",`style: ${m}`],{cwd:E});if(I.code!==0)return{code:I.code,stdout:I.stdout,stderr:I.stderr,committed:!1};let v=await r.exec("git",["push","origin",`HEAD:${g}`],{cwd:E});return v.code!==0?{code:v.code,stdout:v.stdout,stderr:v.stderr,committed:!1}:{code:0,stdout:y.stdout,stderr:y.stderr,committed:!0}},async cleanup(){for(let m of c)await r.worktreeRemove(s,m);c.clear(),a.clear()}}}TM();import{join as Ft}from"node:path";pR();async function klt(e){let{headSha:t,compute:r,readMemo:n,writeMemo:o,computeUncommitted:i}=e,s=null;if(t){let c=n();c&&c.sha===t&&(s={added:c.added,removed:c.removed})}if(s===null&&(s=await r(),t&&o({sha:t,added:s.added,removed:s.removed})),!i)return s;let a=await i();return{added:s.added+a.added,removed:s.removed+a.removed}}function vlt(e,t="/"){return`${e}${t}.loc-memo.json`}function KAe(){let e=0,t=0,r=0,n=0,o=0,i=0,s=0,a=0,c=0,u=()=>e+t+r;return{record(l){l.type==="toolCall"?e+=1:l.type==="text"?t+=1:l.type==="usage"?(typeof l.inputTokens=="number"&&(i+=l.inputTokens),typeof l.outputTokens=="number"&&(s+=l.outputTokens),typeof l.costUsd=="number"&&(a+=l.costUsd)):l.type==="reasoning"&&(r+=1,typeof l.tokens=="number"&&l.tokens>0&&(n+=l.tokens))},snapshotWindow(){let l=u()-c;return l<=0&&(o+=1),c=u(),{toolsCalled:e,textChunks:t,reasoningCount:r,reasoningTokens:n,waiting:o,eventsThisWindow:Math.max(0,l),inputTokens:i,outputTokens:s,costUsd:a}},peek(){return{toolsCalled:e,textChunks:t,reasoningCount:r,reasoningTokens:n,waiting:o,eventsThisWindow:u()-c,inputTokens:i,outputTokens:s,costUsd:a}}}}CC();var _Y=class extends Error{constructor(t){super(t),this.name="RunFlagError"}};async function Dhr(e,t=oi){try{let r=(await sye(e,"utf8")).trim();if(!/^\d+$/.test(r))return{live:!1};let n=Number(r);return t(n)?{live:!0,pid:n}:{live:!1}}catch{return{live:!1}}}function Qhr(e,t=process.env){if(e.origin===aAe||e.origin===lAe||e.lane===Dg||e.lane===KC)return!0;let r=t.RED_AFK_WORKERS_NAMESPACE;return r===J4||r===K4}async function Ohr(e,t,r,n=oi,o=!1){if(o)return"clear";let i=await Dhr(e,n);return i.live?t?(r.write(`warn: --force: fleet supervisor pid=${i.pid} is still running; collision risk accepted.
639
641
  `),"forced"):(r.write(`afk: a fleet supervisor is already running (pid=${i.pid}).
640
642
  monitor the running fleet: /dev:afk fleet
641
643
  stop it first: afk stop
642
644
  override (risk): afk run --force
643
645
  `),"refused"):"clear"}function Nhr(e){return e.split(",").map(t=>Number(t.trim())).filter(t=>Number.isFinite(t))}function Phr(e){let t=Nhr(e);if(t.length===0)throw new _Y(`--issues requires at least one valid issue number (got: ${JSON.stringify(e)})`);return{kind:"issues",numbers:t}}var Mhr={spec:{kind:"value",coerce:e=>({kind:"spec",spec:Number(e)})},issues:{kind:"value",coerce:Phr},n:{kind:"value",coerce:e=>Number(e)},once:{kind:"boolean"},runner:{kind:"value",coerce:e=>e},model:{kind:"value",coerce:e=>e},effort:{kind:"value",coerce:e=>e},request:{kind:"value",aliases:["r"],coerce:e=>e},alternate:{kind:"boolean"},"fallback-runner":{kind:"boolean"},"boot-only":{kind:"boolean"},"reconcile-issue":{kind:"value",coerce:e=>Number(e)},origin:{kind:"value",coerce:e=>e},lane:{kind:"value",coerce:e=>e},"pre-pr":{kind:"boolean"},"local-merge":{kind:"boolean"},yolo:{kind:"boolean"},verify:{kind:"value",coerce:e=>e},"go-verify-retries":{kind:"value",coerce:e=>Number(e)},"run-mode":{kind:"value",coerce:e=>e},force:{kind:"boolean"}};function Fhr(e){let{values:t}=Dl(e,Mhr),r={kind:"all"},n=-1;for(let c=0;c<e.length;c+=1){let u=e[c];(u==="--spec"||u.startsWith("--spec="))&&t.spec!==void 0&&c>n?(r=t.spec,n=c):(u==="--issues"||u.startsWith("--issues="))&&t.issues!==void 0&&c>n&&(r=t.issues,n=c)}let o=t.runner,i=t.alternate===!0;if(i&&o!==void 0)throw new _Y("--alternate is mutually exclusive with --runner");let s=t["reconcile-issue"],a=typeof s=="number"&&Number.isFinite(s)&&s>0?s:void 0;return{filter:r,iterCap:t.n,once:t.once===!0,runnerFlag:o,model:t.model,effort:t.effort,request:t.request,alternate:i,fallbackRunner:t["fallback-runner"]===!0,bootOnly:t["boot-only"]===!0,reconcileIssue:a,origin:t.origin,lane:t.lane,prePr:t["pre-pr"]===!0,localMerge:t["local-merge"]===!0,yolo:t.yolo===!0,verifyCommand:t.verify,goVerifyRetries:typeof t["go-verify-retries"]=="number"&&Number.isFinite(t["go-verify-retries"])?t["go-verify-retries"]:void 0,runMode:t["run-mode"],force:t.force===!0}}function Lhr(e){let t=Jp(e);return async r=>{let n=await t(["-C",r,"diff","--name-only","--diff-filter=U"]);if(n.code!==0)return!1;let o=n.stdout.split(`
644
- `).map(a=>a.trim()).filter(Boolean);if(o.length===0)return!1;let i=[];for(let a of o){let c;try{c=await sye(Ft(r,a),"utf8")}catch{return!1}let u=put(c);i.push({path:a,kind:u,description:`${u} conflict in ${a}`})}if(mut(i).nonMechanical.length>0)return!1;for(let a of o)if((await t(["-C",r,"checkout","--theirs","--",a])).code!==0||(await t(["-C",r,"add","--",a])).code!==0)return!1;return(await t(["-C",r,"-c","core.editor=true","rebase","--continue"])).code===0}}function Xlt(e,t,r,n,o){let i={cwd:e.root,repo:e.repo},s={cwd:e.root},a=Qx(e.root),c=Sr(t.configPath,{warn:()=>{}}),u=Pe(c,"dev.lock.branch")||void 0,l=Pe(c,"dev.trunk")||void 0;return async d=>{let f=`${t.tmpDir}/claims/${d.number}`;if(!await O4(f,process.pid))return{outcome:"skipped"};let p={gh:{editLabels:async(m,g,A)=>(await xa(i,m,g,A),!0),ensureLabel:m=>wl(i,m),comment:(m,g)=>ri(i,m,g),close:m=>Tx(i,m),listByLabel:m=>bP(i,m),issueClosed:m=>SP(i,m),issueReference:m=>gg(i,m)},git:{headShortSha:()=>yg(s),deleteLocalBranch:m=>xg(s,m)},fs:{completionSweep:m=>M4(t.workersRoot,m)},lookups:{changedFiles:(m,g)=>IP(s,m,g),branchPresent:async m=>await Eg(s,m)?!0:(await wP(s,m),Eg(s,m)),isLocked:()=>xR(a)},mergeExec:kP(s),remoteGit:Jp(s),pnpm:o.pnpm,layout:o.layout,makeLandingWorktree:async m=>{let g=LC(process.env.RED_AFK_SLOT)??0,A=m.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"base",E=Ft(t.tmpDir,"landing",`${A}-boot-${g}`);return await No(s,E),await Zd(s,E,m)?E:null},removeLandingWorktree:m=>No(s,m),makeRebaseWorktree:async m=>{let g=LC(process.env.RED_AFK_SLOT)??0,A=m.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"branch",E=Ft(t.tmpDir,"rebase",`${A}-boot-${g}`);return await No(s,E),await Zd(s,E,m)?E:null},removeRebaseWorktree:m=>No(s,m),resolveMechanicalConflict:d.labels.includes(cu)?Lhr(s):void 0,envelope:{git:Jp(s),poster:async(m,g)=>(await ri(i,m,g),!0),writeMarkers:async()=>{},writePosted:async()=>{},issueReference:m=>gg(i,m)},nowEpoch:()=>Math.floor(Date.now()/1e3),appendIterLog:()=>{},recoveryEnv:process.env};try{let m=await pf({issueBody:d.body},{readLockedBranch:()=>wg(a),configLockedBranch:u,configTrunk:l,fetchIssueBody:y=>Ege(i,y)}),g={issue:d.number,title:d.title,body:d.body,labels:d.labels,branch:d.branch,base:m,trunk:l||"main",repo:e.repo,repoDir:e.root,remote:e.remote,workerId:r,attempt:0,attemptDir:Ft(t.tmpDir,"boot-reconcile",String(d.number)),runner:n,trustPriorValidation:d.labels.includes(cu)},A=await TR(p,g);return{outcome:A.outcome==="landed"?"landed":A.outcome==="parked"?"parked":"skipped"}}finally{await ds(f)}}}async function Uhr(e,t,r,n,o){let i={cwd:r.root,repo:r.repo},s={cwd:r.root},a=await b4(i,e);if(!a)return process.stderr.write(`[afk reconcile-worker] #${e} not found or fetch failed \u2014 nothing to reconcile
646
+ `).map(a=>a.trim()).filter(Boolean);if(o.length===0)return!1;let i=[];for(let a of o){let c;try{c=await sye(Ft(r,a),"utf8")}catch{return!1}let u=put(c);i.push({path:a,kind:u,description:`${u} conflict in ${a}`})}if(mut(i).nonMechanical.length>0)return!1;for(let a of o)if((await t(["-C",r,"checkout","--theirs","--",a])).code!==0||(await t(["-C",r,"add","--",a])).code!==0)return!1;return(await t(["-C",r,"-c","core.editor=true","rebase","--continue"])).code===0}}function Xlt(e,t,r,n,o){let i={cwd:e.root,repo:e.repo},s={cwd:e.root},a=Qx(e.root),c=Sr(t.configPath,{warn:()=>{}}),u=Pe(c,"dev.lock.branch")||void 0,l=Pe(c,"dev.trunk")||void 0;return async d=>{let f=`${t.tmpDir}/claims/${d.number}`;if(!await O4(f,process.pid))return{outcome:"skipped"};let p={gh:{editLabels:async(m,g,A)=>(await xa(i,m,g,A),!0),ensureLabel:m=>wl(i,m),comment:(m,g)=>ni(i,m,g),close:m=>Tx(i,m),listByLabel:m=>bP(i,m),issueClosed:m=>SP(i,m),issueReference:m=>gg(i,m)},git:{headShortSha:()=>yg(s),deleteLocalBranch:m=>xg(s,m)},fs:{completionSweep:m=>M4(t.workersRoot,m)},lookups:{changedFiles:(m,g)=>IP(s,m,g),branchPresent:async m=>await Eg(s,m)?!0:(await wP(s,m),Eg(s,m)),isLocked:()=>xR(a)},mergeExec:kP(s),remoteGit:Jp(s),pnpm:o.pnpm,layout:o.layout,makeLandingWorktree:async m=>{let g=LC(process.env.RED_AFK_SLOT)??0,A=m.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"base",E=Ft(t.tmpDir,"landing",`${A}-boot-${g}`);return await No(s,E),await Zd(s,E,m)?E:null},removeLandingWorktree:m=>No(s,m),makeRebaseWorktree:async m=>{let g=LC(process.env.RED_AFK_SLOT)??0,A=m.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"branch",E=Ft(t.tmpDir,"rebase",`${A}-boot-${g}`);return await No(s,E),await Zd(s,E,m)?E:null},removeRebaseWorktree:m=>No(s,m),resolveMechanicalConflict:d.labels.includes(cu)?Lhr(s):void 0,envelope:{git:Jp(s),poster:async(m,g)=>(await ni(i,m,g),!0),writeMarkers:async()=>{},writePosted:async()=>{},issueReference:m=>gg(i,m)},nowEpoch:()=>Math.floor(Date.now()/1e3),appendIterLog:()=>{},recoveryEnv:process.env};try{let m=await pf({issueBody:d.body},{readLockedBranch:()=>wg(a),configLockedBranch:u,configTrunk:l,fetchIssueBody:y=>Ege(i,y)}),g={issue:d.number,title:d.title,body:d.body,labels:d.labels,branch:d.branch,base:m,trunk:l||"main",repo:e.repo,repoDir:e.root,remote:e.remote,workerId:r,attempt:0,attemptDir:Ft(t.tmpDir,"boot-reconcile",String(d.number)),runner:n,trustPriorValidation:d.labels.includes(cu)},A=await TR(p,g);return{outcome:A.outcome==="landed"?"landed":A.outcome==="parked"?"parked":"skipped"}}finally{await ds(f)}}}async function Uhr(e,t,r,n,o){let i={cwd:r.root,repo:r.repo},s={cwd:r.root},a=await b4(i,e);if(!a)return process.stderr.write(`[afk reconcile-worker] #${e} not found or fetch failed \u2014 nothing to reconcile
645
647
  `),0;let c=await Kp(s,"afk/"),u=yAe(c.map(p=>p.branch),e);if(!u)return process.stderr.write(`[afk reconcile-worker] no afk branch for #${e} \u2014 nothing to reconcile
646
- `),0;let l={number:a.number,title:a.title,body:a.body,labels:a.labels,branch:u},d=eAe(r.root,process.env,t),f=iM(r.root,Ft(n.tmpDir,"feedback"),void 0,{rebaseOnto:d.feedbackRebaseBase});try{await Xlt(r,n,o,t,f)(l)}finally{await f.cleanup()}return 0}var $hr=[{activity:"impl",pattern:/^(edit|write|multiedit|notebookedit)$/},{activity:"explore",pattern:/^(read|grep|glob)$/}],Hhr=[{activity:"commit",pattern:/\bgit\s+commit(?:\s|$)/},{activity:"push",pattern:/\bgit\s+push(?:\s|$)/},{activity:"review",pattern:/\bgit\s+(?:diff|log|show)(?:\s|$)/},{activity:"build",pattern:/\btsc\s+--build\b/},{activity:"build",pattern:/\b(?:npm|pnpm|yarn|bun)(?:(?![;&|]).)*\bbuild\b/},{activity:"build",pattern:/\bvite\s+build\b/},{activity:"build",pattern:/\bcargo\s+build\b/},{activity:"build",pattern:/\bgo\s+build\b/},{activity:"build",pattern:/\bmake\b/},{activity:"build",pattern:/\bgradle(?:(?![;&|]).)*\bbuild\b/},{activity:"build",pattern:/\bmvn(?:(?![;&|]).)*\bpackage\b/},{activity:"build",pattern:/\bdotnet\s+build\b/},{activity:"build",pattern:/\bcmake\b/},{activity:"build",pattern:/\bbazel\s+build\b/},{activity:"build",pattern:/\bzig\s+build\b/},{activity:"build",pattern:/\bdart\s+compile\b/},{activity:"typecheck",pattern:/\b(?:npm|pnpm|yarn|bun)(?:(?![;&|]).)*\btypecheck\b/},{activity:"typecheck",pattern:/\btsc\b(?!\s+--build\b)/},{activity:"typecheck",pattern:/\b(?:mypy|pyright)\b/},{activity:"typecheck",pattern:/\bcargo\s+check\b/},{activity:"typecheck",pattern:/\bdart\s+analyze\b/},{activity:"lint",pattern:/\b(?:eslint|biome)\b/},{activity:"lint",pattern:/\bprettier\b(?:(?![;&|]).)*\b--check\b/},{activity:"lint",pattern:/\bcargo\s+clippy\b/},{activity:"lint",pattern:/\b(?:ruff|flake8|pylint)\b/},{activity:"lint",pattern:/\bblack\b(?:(?![;&|]).)*\b--check\b/},{activity:"lint",pattern:/\brubocop\b/},{activity:"lint",pattern:/\bgolangci-lint\b/},{activity:"lint",pattern:/\bgo\s+vet\b/},{activity:"lint",pattern:/\bgofmt\b/},{activity:"lint",pattern:/\b(?:ktlint|checkstyle)\b/},{activity:"lint",pattern:/\bclang-tidy\b/},{activity:"lint",pattern:/\bdotnet\s+format\b/},{activity:"lint",pattern:/\bdart\s+analyze\b/},{activity:"tests",pattern:/\b(?:vitest|jest|mocha)\b/},{activity:"tests",pattern:/\b(?:npm|pnpm|yarn|bun)(?:(?![;&|]).)*\btest\b/},{activity:"tests",pattern:/\bcargo\s+test\b/},{activity:"tests",pattern:/\bgo\s+test\b/},{activity:"tests",pattern:/\bpytest\b/},{activity:"tests",pattern:/\bpython(?:\d+(?:\.\d+)?)?\s+-m\s+(?:pytest|unittest)\b/},{activity:"tests",pattern:/\bunittest\b/},{activity:"tests",pattern:/\bphpunit\b/},{activity:"tests",pattern:/\bgradle(?:(?![;&|]).)*\btest\b/},{activity:"tests",pattern:/\bmvn(?:(?![;&|]).)*\btest\b/},{activity:"tests",pattern:/\bdotnet\s+test\b/},{activity:"tests",pattern:/\bctest\b/},{activity:"tests",pattern:/\bdart\s+test\b/},{activity:"tests",pattern:/\bzig\s+test\b/},{activity:"explore",pattern:/\bgit\s+ls-files(?:\s|$)/},{activity:"explore",pattern:/\bfind\b/}];function Whr(e){if(e.type!=="toolCall")return;let t=e.name.toLowerCase(),r=e.formattedArgs.toLowerCase();for(let n of $hr)if(n.pattern.test(t))return n.activity;for(let n of Hhr)if(n.pattern.test(r))return n.activity}function LC(e){if(e===void 0)return;let t=parseInt(e,10);return Number.isFinite(t)&&t>=0?t:void 0}function jhr(e,t,r,n,o,i,s,a,c,u,l,d,f,p){let m={cwd:e.root,repo:e.repo,exec:a},g={cwd:e.root,exec:a},A=Mr(e.root),E=Qx(e.root),y=c??f4,b=0,w="",I=KAe(),v="",k={added:0,removed:0},R=0,B=0,L="",D=Sr(A.configPath,{warn:()=>{}}),ee=Tl(D),F=oM(e.root);QC(D,F);let _=Pe(D,"afk.merge.wait_for_review")==="true"?{check:Pe(D,"afk.merge.review_check")||"CodeRabbit",sleep:T=>new Promise(J=>setTimeout(J,T))}:void 0,P=Pe(D,"afk.merge.ci_aware")==="true"?{sleep:T=>new Promise(J=>setTimeout(J,T)),intervalMs:1e4,maxPolls:Math.max(1,Math.ceil(sEe(process.env)/10))}:void 0,$=elt(D),N=Pe(D,"afk.worktree_launches_pull_request")!=="false",q=Pe(D,"afk.merge.native_queue")==="true",re=q||Pe(D,"afk.merge.land_lock")==="false"?void 0:Clt(A.tmpDir,`pid-${process.pid}`),ie=Vut(D),ue=Sut(D),Oe=jM(D),Ye=f&&f.trim()!==""?[...Oe,f.trim()]:Oe;return{gh:{viewLabels:T=>wC(m,T),editLabels:(T,J,Ne)=>xa(m,T,J,Ne),ensureLabel:async T=>{try{await wl(m,T)}catch{}},comment:(T,J)=>ri(m,T,J),editBody:(T,J)=>EP(m,T,J),close:T=>Tx(m,T),listByLabel:T=>bP(m,T),issueClosed:T=>SP(m,T),issueReference:T=>gg(m,T),issueTrust:T=>Hst(m,T),repoVisibility:()=>jst(m),actorTrustSignals:T=>Ag(m,T),renderDecisionCard:async T=>{let{hitlCardCommand:J}=await Promise.resolve().then(()=>(iye(),Ylt));await J(["render",`--issue=${T}`,`--root=${e.root}`])},findMainRedRepairIssue:()=>Rst(m),createMainRedRepairIssue:T=>_st(m,T),updateMainRedRepairIssue:(T,J)=>Bst(m,T,J),closeMainRedRepairIssue:(T,J)=>Tst(m,T,J)},claimGh:{postClaim:(T,J)=>xP(m,T,J),listClaims:T=>lR(m,T),concede:async(T,J)=>{try{await xP(m,T,J)}catch{}},audit:async(T,J)=>{try{await ri(m,T,J)}catch{}}},claimStale:bAe(Math.floor(Date.now()/1e3),Nct(process.env)),recoveredWorkerDeathCause:T=>Lut(A.tmpDir,T,e_()),claimLock:{acquire:T=>O4(`${A.tmpDir}/claims/${T}`,process.pid),release:async T=>{await ds(`${A.tmpDir}/claims/${T}`)}},fs:{ensureAttemptDir:T=>Zp(T),writeHandoff:(T,J)=>Nge(T,J),writeValidationSidecar:(T,J)=>Pge(T,J),completionSweep:T=>M4(A.workersRoot,T)},git:{headShortSha:()=>yg(g),deleteLocalBranch:T=>xg(g,T),resolveFreshBase:T=>Zst(g,T),fetchBase:async T=>{await Jp(g)(["fetch",e.remote,T])},prepareFreshWorkerBranch:T=>Xst(g,{...T,remote:e.remote})},mergeExec:kP(g),remoteGit:Jp(g),salvageUncommitted:T=>v4(g,T,e.remote),exitBarrier:T=>Out({salvage:J=>v4(g,J,e.remote),push:J=>_ge(g,J,e.remote),headSha:async J=>await Yp(g,J)??"",nowIso:()=>new Date().toISOString()},T),terminalExitBarrier:T=>Nut({salvage:J=>v4(g,J,e.remote),push:J=>_ge(g,J,e.remote),headSha:async J=>await Yp(g,J)??"",nowIso:()=>new Date().toISOString()},T),pnpm:n.pnpm,layout:n.layout,backpressure:n.backpressure,backpressureCommands:Ye,outputShaping:ue,postBackpressureReview:(T,J)=>IY(m).postReview(T,{summary:J,comments:[]}),goVerifyRetries:p,postAttemptFormat:n.postAttemptFormat,postAttemptFormatCommands:iEe(D),runAgent:zat(r,process.env,c,u,l,d,()=>I.peek()),sandboxMode:r,sandboxAvailable:async T=>(await(a??jt)("sh",["-c",`command -v ${T}`],{cwd:e.root})).code===0,model:t,classifyIssue:qhr(D,s,e.root,a),resolveTier:(T,J="think")=>Ia(D,T,J,process.env),fallbackRunner:i,waitForReview:_,ciAwait:P,worktreeLaunchesPr:N,landLock:re,nativeMergeQueue:q,reviewGate:$,reviewGateLabel:JC,conflictResolver:async(T,J)=>{let Ne=Ia(D,s,"think",process.env),Cr=s==="codex"?Fit({prompt:T,worktree:J,lastMessagePath:Ft(A.tmpDir,"merge-resolve.last"),model:Ne.model,effort:Ne.effort}):Mit({prompt:T,worktree:J}),{execTool:Li}=await Promise.resolve().then(()=>(bn(),hg));await Li(Cr.command,Cr.args,{cwd:J})},makeLandingWorktree:async T=>{let J=LC(process.env.RED_AFK_SLOT)??0,Ne=T.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"base",Cr=Ft(A.tmpDir,"landing",`${Ne}-${J}`);return await No(g,Cr),await Zd(g,Cr,T)?Cr:null},removeLandingWorktree:T=>No(g,T),makeRebaseWorktree:async T=>{let J=LC(process.env.RED_AFK_SLOT)??0,Ne=T.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"branch",Cr=Ft(A.tmpDir,"rebase",`${Ne}-${J}`);return await No(g,Cr),await Zd(g,Cr,T)?Cr:null},removeRebaseWorktree:T=>No(g,T),hooks:{config:D,resolveOptions:F,exec:nM(e.root),env:JAe(e.repo,e.root,LC(process.env.RED_AFK_SLOT),s)},lookups:{base:{readLockedBranch:()=>wg(E),configLockedBranch:Pe(D,"dev.lock.branch")||void 0,configTrunk:Pe(D,"dev.trunk")||void 0,fetchIssueBody:T=>Ege(m,T)},isLocked:()=>xR(E),comments:T=>S4(m,T,J=>Bl(ee,J,Ne=>Ag(m,Ne))),issueUrl:T=>Qst(m,T),priorAttemptContext:async T=>{try{let J=await blt(A.tmpDir,T);return J?Slt(J):void 0}catch{return}},changedFiles:(T,J)=>IP(g,T,J),diffstat:(T,J)=>tat(g,T,J),branchPresent:async T=>await Eg(g,T)?!0:(await wP(g,T),Eg(g,T)),branchMerged:(T,J)=>eat(g,T,J)},envelope:{git:Jp(g),poster:async(T,J)=>(await ri(m,T,J),!0),writeMarkers:T=>Fge(o.attemptDir,T),writePosted:T=>Lge(o.attemptDir,T),issueReference:T=>gg(m,T)},nowEpoch:()=>Math.floor(Date.now()/1e3),nowIso:()=>new Date().toISOString(),appendIterLog:T=>{OP(Ft(o.attemptDir,"afk.log"),T)},recordAgentEvent:T=>{let J=new Date().toISOString();if(T.type==="raw"){Nx(Ft(o.attemptDir,"log.jsonl"),"raw",T.line,{ts:J,fields:{extra:{kind:"raw",iteration:String(T.iteration)}}}).catch(()=>{});return}if(T.type==="sessionId"){Nx(Ft(o.attemptDir,"log.jsonl"),"session",`session ${T.sessionId}`,{ts:J,fields:{extra:{kind:"sessionId",iteration:String(T.iteration),session_id:T.sessionId}}}).catch(()=>{});return}let Ne=o.attemptDir;if(Ne!==w&&(w=Ne,b=0),Ne!==v&&(v=Ne,I=KAe()),Ne!==L&&(L=Ne,R=0,B=0),(T.type==="text"||T.type==="toolCall"||T.type==="reasoning"||T.type==="usage")&&I.record(T),T.iteration!==b){let Fr=(jn,Mo,Ui)=>{OP(Ft(Ne,"afk.log"),jn),Nx(Ft(Ne,"log.jsonl"),"iteration",jn,{ts:J,fields:{extra:{iteration:String(Ui),phase:Mo}}}).catch(()=>{})};b>0&&Fr(HAe(b,"ended",y),"ended",b),b=T.iteration,Fr(HAe(b,"started",y),"started",b),Il(Ft(Ne,"afk.state.json"),{"current.iteration":String(b)}).catch(()=>{})}let Cr=T.type==="text"?T.message:T.type==="reasoning"?`\u{1F9E0} reasoning${T.tokens?` (${T.tokens} tok)`:T.message?`: ${T.message.slice(0,80)}`:""}`:T.type==="usage"?`\u{1F4B0} usage (in:${T.inputTokens} out:${T.outputTokens}${T.reasoningTokens?` reason:${T.reasoningTokens}`:""})`:T.type==="result"?`result: ${T.result}`:`\u2192 ${T.name} ${T.formattedArgs}`;Wut(Ft(o.attemptDir,"agent.log.jsonl"),Cr,{ts:J,fields:{extra:{iteration:String(T.iteration),kind:T.type}}}).catch(()=>{}),Nx(Ft(o.attemptDir,"log.jsonl"),"agent",Cr,{ts:J,fields:{extra:{iteration:String(T.iteration),kind:T.type}}}).catch(()=>{});let Li=Whr(T),oi=T.type==="toolCall"||T.type==="reasoning"||T.type==="usage"||T.type==="result",at=T.type==="usage"?{"current.input_tokens":I.peek().inputTokens,"current.output_tokens":I.peek().outputTokens,"current.cost_usd":I.peek().costUsd}:{};(Li||oi)&&Il(Ft(o.attemptDir,"afk.state.json"),{...Li?{"current.activity":Li,"current.last_stream_line":Cr.slice(0,200)}:{},"current.phase":"coding","current.last_event_at":J,...at}).catch(()=>{})},emitHeartbeat:T=>{let J=new Date().toISOString(),Ne=Math.max(0,Math.floor((T.nowMs-T.lastProgressMs)/1e3)),Cr=new Date(T.lastProgressMs).toISOString(),Li=T.head??"";(async()=>{let oi=await oat(g,o.attemptDir).catch(()=>{})??Ft(o.attemptDir,"worktree"),at=T.base?`origin/${T.base}`:`origin/${Pe(D,"dev.trunk")||"main"}`,Fr=vlt(o.attemptDir,"/"),{added:jn,removed:Mo}=await klt({headSha:Li,compute:()=>rat({cwd:oi},at).catch(()=>({added:0,removed:0})),computeUncommitted:()=>nat({cwd:oi}).catch(()=>({added:0,removed:0})),readMemo:()=>{try{let Ms=JSON.parse(cM(Fr,"utf8"));return{sha:String(Ms.sha??""),added:Number(Ms.added??0),removed:Number(Ms.removed??0)}}catch{return null}},writeMemo:Ms=>{try{Klt(Fr,JSON.stringify(Ms),"utf8")}catch{}}});k={added:jn,removed:Mo},jn>R&&(R=jn),Mo>B&&(B=Mo);let Ui=I.snapshotWindow(),$i=qut({secsSinceProgress:Ne,lastProgressAt:Cr,head:Li,added:jn,removed:Mo,activity:Ui});await Nx(Ft(o.attemptDir,"log.jsonl"),"heartbeat",$i.msg,{ts:J,fields:{extra:$i.extra}}).catch(()=>{}),await OP(Ft(o.attemptDir,"afk.log"),`[heartbeat] ${$i.msg}`),await Il(Ft(o.attemptDir,"afk.state.json"),{...$i.statePatch,"current.loc_peak_added":R,"current.loc_peak_removed":B,"current.worktree":oi,...T.base?{"current.base":T.base}:{}}).catch(()=>{})})()},heartbeatVitals:()=>{let T=I.peek();return{tools_called_count:T.toolsCalled,text_chunk_count:T.textChunks,reasoning_events:T.reasoningCount,reasoning_tokens:T.reasoningTokens,waiting_count:T.waiting,input_tokens:T.inputTokens,output_tokens:T.outputTokens,cost_usd:T.costUsd,loc_added:k.added,loc_removed:k.removed}},notesLoop:ie,writeNotes:(T,J)=>{try{Klt(T,J,"utf8")}catch{}},markPhase:T=>{Il(Ft(o.attemptDir,"afk.state.json"),{"current.phase":T}).catch(()=>{})},markState:T=>{Il(Ft(o.attemptDir,"afk.state.json"),T).catch(()=>{})},historyPath:A.historyPath,historyClock:{ts:new Date().toISOString(),epoch:Math.floor(Date.now()/1e3)},recoveryEnv:process.env,recordAttempt:zhr(e.root,o,a),recordOutcomeEvent:Vhr(e.root,o,a),cascadeRebase:{async listAFKBranches(){return(await Kp(g,"afk/")).map(J=>J.branch)},isWorkerLive(T){try{let J=DP(A.tmpDir,T),Ne=cM(J,"utf8").trim();return/^[1-9][0-9]*$/.test(Ne)?(process.kill(Number(Ne),0),!0):!1}catch(J){return J.code==="EPERM"}},async rebaseAndPush(T,J,Ne){let Cr=J.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40),Li=LC(process.env.RED_AFK_SLOT)??0,oi=Ft(A.tmpDir,"cascade-rebase",`${Cr}-${Li}`);try{if(await No(g,oi),!await Zd(g,oi,J))return{ok:!1,warn:`failed to create worktree for ${J}`};let Fr=a??(await Promise.resolve().then(()=>(bn(),hg))).execTool,jn=await Fr("git",["rebase",`origin/${Ne}`],{cwd:oi});if(jn.code!==0)return await Fr("git",["rebase","--abort"],{cwd:oi}).catch(()=>{}),{ok:!1,warn:`rebase of ${J} onto ${Ne} conflicted: ${jn.stderr.slice(0,200)}`};let Mo=await Fr("git",["push","origin",`HEAD:refs/heads/${J}`,"--force-with-lease"],{cwd:oi});return Mo.code!==0?{ok:!1,warn:`--force-with-lease push rejected for ${J}: ${Mo.stderr.slice(0,200)}`}:{ok:!0}}finally{await No(g,oi).catch(()=>{})}}}}}function qhr(e,t,r,n){return async o=>{let i=Ia(e,t,"validate",process.env);return Zut(o,async({prompt:s})=>{let a=n??(await Promise.resolve().then(()=>(bn(),hg))).execTool,c={cwd:r,timeoutMs:45e3,maxBuffer:1024*1024},u=t==="codex"?await a("codex",["exec","--model",i.model,"-c",`model_reasoning_effort=${i.effort}`,"-C",r,"--sandbox","read-only","--skip-git-repo-check",s],c):await a("claude",["--model",i.model,"--effort",i.effort,"--permission-mode","bypassPermissions","--print",s],c);return u.code===0?u.stdout.trim():void 0})}}function Ghr(e){try{let t=JSON.parse(cM(e,"utf8")).version;return typeof t=="string"&&t.length>0?t:void 0}catch{return}}function zhr(e,t,r){return async n=>{try{let o={...process.env,MEMORY_REPO_ROOT:process.env.MEMORY_REPO_ROOT??e},i=lut(e,o,{exists:aM,readJsonVersion:Ghr,readText:f=>{try{return cM(f,"utf8")}catch{return}}});if(!i)return;let s=t.attemptDir||e,a=Ft(s,`memory-attempt-${n.issueNumber}-a${n.attemptNumber}.json`);await Zp(s);let c=uut(n);await BY(a,c,"utf8");let u=r??(await Promise.resolve().then(()=>(bn(),hg))).execTool,[l,...d]=i;await u(l,[...d,"attempt","record","--root",e],{cwd:e,env:o,input:c})}catch(o){process.stderr.write(`[afk] memory attempt-record skipped (best-effort): ${String(o)}
648
+ `),0;let l={number:a.number,title:a.title,body:a.body,labels:a.labels,branch:u},d=eAe(r.root,process.env,t),f=iM(r.root,Ft(n.tmpDir,"feedback"),void 0,{rebaseOnto:d.feedbackRebaseBase});try{await Xlt(r,n,o,t,f)(l)}finally{await f.cleanup()}return 0}var $hr=[{activity:"impl",pattern:/^(edit|write|multiedit|notebookedit)$/},{activity:"explore",pattern:/^(read|grep|glob)$/}],Hhr=[{activity:"commit",pattern:/\bgit\s+commit(?:\s|$)/},{activity:"push",pattern:/\bgit\s+push(?:\s|$)/},{activity:"review",pattern:/\bgit\s+(?:diff|log|show)(?:\s|$)/},{activity:"build",pattern:/\btsc\s+--build\b/},{activity:"build",pattern:/\b(?:npm|pnpm|yarn|bun)(?:(?![;&|]).)*\bbuild\b/},{activity:"build",pattern:/\bvite\s+build\b/},{activity:"build",pattern:/\bcargo\s+build\b/},{activity:"build",pattern:/\bgo\s+build\b/},{activity:"build",pattern:/\bmake\b/},{activity:"build",pattern:/\bgradle(?:(?![;&|]).)*\bbuild\b/},{activity:"build",pattern:/\bmvn(?:(?![;&|]).)*\bpackage\b/},{activity:"build",pattern:/\bdotnet\s+build\b/},{activity:"build",pattern:/\bcmake\b/},{activity:"build",pattern:/\bbazel\s+build\b/},{activity:"build",pattern:/\bzig\s+build\b/},{activity:"build",pattern:/\bdart\s+compile\b/},{activity:"typecheck",pattern:/\b(?:npm|pnpm|yarn|bun)(?:(?![;&|]).)*\btypecheck\b/},{activity:"typecheck",pattern:/\btsc\b(?!\s+--build\b)/},{activity:"typecheck",pattern:/\b(?:mypy|pyright)\b/},{activity:"typecheck",pattern:/\bcargo\s+check\b/},{activity:"typecheck",pattern:/\bdart\s+analyze\b/},{activity:"lint",pattern:/\b(?:eslint|biome)\b/},{activity:"lint",pattern:/\bprettier\b(?:(?![;&|]).)*\b--check\b/},{activity:"lint",pattern:/\bcargo\s+clippy\b/},{activity:"lint",pattern:/\b(?:ruff|flake8|pylint)\b/},{activity:"lint",pattern:/\bblack\b(?:(?![;&|]).)*\b--check\b/},{activity:"lint",pattern:/\brubocop\b/},{activity:"lint",pattern:/\bgolangci-lint\b/},{activity:"lint",pattern:/\bgo\s+vet\b/},{activity:"lint",pattern:/\bgofmt\b/},{activity:"lint",pattern:/\b(?:ktlint|checkstyle)\b/},{activity:"lint",pattern:/\bclang-tidy\b/},{activity:"lint",pattern:/\bdotnet\s+format\b/},{activity:"lint",pattern:/\bdart\s+analyze\b/},{activity:"tests",pattern:/\b(?:vitest|jest|mocha)\b/},{activity:"tests",pattern:/\b(?:npm|pnpm|yarn|bun)(?:(?![;&|]).)*\btest\b/},{activity:"tests",pattern:/\bcargo\s+test\b/},{activity:"tests",pattern:/\bgo\s+test\b/},{activity:"tests",pattern:/\bpytest\b/},{activity:"tests",pattern:/\bpython(?:\d+(?:\.\d+)?)?\s+-m\s+(?:pytest|unittest)\b/},{activity:"tests",pattern:/\bunittest\b/},{activity:"tests",pattern:/\bphpunit\b/},{activity:"tests",pattern:/\bgradle(?:(?![;&|]).)*\btest\b/},{activity:"tests",pattern:/\bmvn(?:(?![;&|]).)*\btest\b/},{activity:"tests",pattern:/\bdotnet\s+test\b/},{activity:"tests",pattern:/\bctest\b/},{activity:"tests",pattern:/\bdart\s+test\b/},{activity:"tests",pattern:/\bzig\s+test\b/},{activity:"explore",pattern:/\bgit\s+ls-files(?:\s|$)/},{activity:"explore",pattern:/\bfind\b/}];function Whr(e){if(e.type!=="toolCall")return;let t=e.name.toLowerCase(),r=e.formattedArgs.toLowerCase();for(let n of $hr)if(n.pattern.test(t))return n.activity;for(let n of Hhr)if(n.pattern.test(r))return n.activity}function LC(e){if(e===void 0)return;let t=parseInt(e,10);return Number.isFinite(t)&&t>=0?t:void 0}function jhr(e,t,r,n,o,i,s,a,c,u,l,d,f,p){let m={cwd:e.root,repo:e.repo,exec:a},g={cwd:e.root,exec:a},A=Mr(e.root),E=Qx(e.root),y=c??f4,b=0,w="",I=KAe(),v="",k={added:0,removed:0},R=0,B=0,L="",D=Sr(A.configPath,{warn:()=>{}}),ee=Tl(D),F=oM(e.root);QC(D,F);let _=Pe(D,"afk.merge.wait_for_review")==="true"?{check:Pe(D,"afk.merge.review_check")||"CodeRabbit",sleep:T=>new Promise(J=>setTimeout(J,T))}:void 0,P=Pe(D,"afk.merge.ci_aware")==="true"?{sleep:T=>new Promise(J=>setTimeout(J,T)),intervalMs:1e4,maxPolls:Math.max(1,Math.ceil(sEe(process.env)/10))}:void 0,$=elt(D),N=Pe(D,"afk.worktree_launches_pull_request")!=="false",q=Pe(D,"afk.merge.native_queue")==="true",re=q||Pe(D,"afk.merge.land_lock")==="false"?void 0:Clt(A.tmpDir,`pid-${process.pid}`),ie=Vut(D),ue=Sut(D),Oe=jM(D),Ye=f&&f.trim()!==""?[...Oe,f.trim()]:Oe;return{gh:{viewLabels:T=>wC(m,T),editLabels:(T,J,Ne)=>xa(m,T,J,Ne),ensureLabel:async T=>{try{await wl(m,T)}catch{}},comment:(T,J)=>ni(m,T,J),editBody:(T,J)=>EP(m,T,J),close:T=>Tx(m,T),listByLabel:T=>bP(m,T),issueClosed:T=>SP(m,T),issueReference:T=>gg(m,T),issueTrust:T=>Hst(m,T),repoVisibility:()=>jst(m),actorTrustSignals:T=>Ag(m,T),renderDecisionCard:async T=>{let{hitlCardCommand:J}=await Promise.resolve().then(()=>(iye(),Ylt));await J(["render",`--issue=${T}`,`--root=${e.root}`])},findMainRedRepairIssue:()=>Rst(m),createMainRedRepairIssue:T=>_st(m,T),updateMainRedRepairIssue:(T,J)=>Bst(m,T,J),closeMainRedRepairIssue:(T,J)=>Tst(m,T,J)},claimGh:{postClaim:(T,J)=>xP(m,T,J),listClaims:T=>lR(m,T),concede:async(T,J)=>{try{await xP(m,T,J)}catch{}},audit:async(T,J)=>{try{await ni(m,T,J)}catch{}}},claimStale:bAe(Math.floor(Date.now()/1e3),Nct(process.env)),recoveredWorkerDeathCause:T=>Lut(A.tmpDir,T,e_()),claimLock:{acquire:T=>O4(`${A.tmpDir}/claims/${T}`,process.pid),release:async T=>{await ds(`${A.tmpDir}/claims/${T}`)}},fs:{ensureAttemptDir:T=>Zp(T),writeHandoff:(T,J)=>Nge(T,J),writeValidationSidecar:(T,J)=>Pge(T,J),completionSweep:T=>M4(A.workersRoot,T)},git:{headShortSha:()=>yg(g),deleteLocalBranch:T=>xg(g,T),resolveFreshBase:T=>Zst(g,T),fetchBase:async T=>{await Jp(g)(["fetch",e.remote,T])},prepareFreshWorkerBranch:T=>Xst(g,{...T,remote:e.remote})},mergeExec:kP(g),remoteGit:Jp(g),salvageUncommitted:T=>v4(g,T,e.remote),exitBarrier:T=>Out({salvage:J=>v4(g,J,e.remote),push:J=>_ge(g,J,e.remote),headSha:async J=>await Yp(g,J)??"",nowIso:()=>new Date().toISOString()},T),terminalExitBarrier:T=>Nut({salvage:J=>v4(g,J,e.remote),push:J=>_ge(g,J,e.remote),headSha:async J=>await Yp(g,J)??"",nowIso:()=>new Date().toISOString()},T),pnpm:n.pnpm,layout:n.layout,backpressure:n.backpressure,backpressureCommands:Ye,outputShaping:ue,postBackpressureReview:(T,J)=>IY(m).postReview(T,{summary:J,comments:[]}),goVerifyRetries:p,postAttemptFormat:n.postAttemptFormat,postAttemptFormatCommands:iEe(D),runAgent:zat(r,process.env,c,u,l,d,()=>I.peek()),sandboxMode:r,sandboxAvailable:async T=>(await(a??jt)("sh",["-c",`command -v ${T}`],{cwd:e.root})).code===0,model:t,classifyIssue:qhr(D,s,e.root,a),resolveTier:(T,J="think")=>Ia(D,T,J,process.env),fallbackRunner:i,waitForReview:_,ciAwait:P,worktreeLaunchesPr:N,landLock:re,nativeMergeQueue:q,reviewGate:$,reviewGateLabel:JC,conflictResolver:async(T,J)=>{let Ne=Ia(D,s,"think",process.env),Cr=s==="codex"?Fit({prompt:T,worktree:J,lastMessagePath:Ft(A.tmpDir,"merge-resolve.last"),model:Ne.model,effort:Ne.effort}):Mit({prompt:T,worktree:J}),{execTool:Li}=await Promise.resolve().then(()=>(bn(),hg));await Li(Cr.command,Cr.args,{cwd:J})},makeLandingWorktree:async T=>{let J=LC(process.env.RED_AFK_SLOT)??0,Ne=T.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"base",Cr=Ft(A.tmpDir,"landing",`${Ne}-${J}`);return await No(g,Cr),await Zd(g,Cr,T)?Cr:null},removeLandingWorktree:T=>No(g,T),makeRebaseWorktree:async T=>{let J=LC(process.env.RED_AFK_SLOT)??0,Ne=T.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"branch",Cr=Ft(A.tmpDir,"rebase",`${Ne}-${J}`);return await No(g,Cr),await Zd(g,Cr,T)?Cr:null},removeRebaseWorktree:T=>No(g,T),hooks:{config:D,resolveOptions:F,exec:nM(e.root),env:JAe(e.repo,e.root,LC(process.env.RED_AFK_SLOT),s)},lookups:{base:{readLockedBranch:()=>wg(E),configLockedBranch:Pe(D,"dev.lock.branch")||void 0,configTrunk:Pe(D,"dev.trunk")||void 0,fetchIssueBody:T=>Ege(m,T)},isLocked:()=>xR(E),comments:T=>S4(m,T,J=>Bl(ee,J,Ne=>Ag(m,Ne))),issueUrl:T=>Qst(m,T),priorAttemptContext:async T=>{try{let J=await blt(A.tmpDir,T);return J?Slt(J):void 0}catch{return}},changedFiles:(T,J)=>IP(g,T,J),diffstat:(T,J)=>tat(g,T,J),branchPresent:async T=>await Eg(g,T)?!0:(await wP(g,T),Eg(g,T)),branchMerged:(T,J)=>eat(g,T,J)},envelope:{git:Jp(g),poster:async(T,J)=>(await ni(m,T,J),!0),writeMarkers:T=>Fge(o.attemptDir,T),writePosted:T=>Lge(o.attemptDir,T),issueReference:T=>gg(m,T)},nowEpoch:()=>Math.floor(Date.now()/1e3),nowIso:()=>new Date().toISOString(),appendIterLog:T=>{OP(Ft(o.attemptDir,"afk.log"),T)},recordAgentEvent:T=>{let J=new Date().toISOString();if(T.type==="raw"){Nx(Ft(o.attemptDir,"log.jsonl"),"raw",T.line,{ts:J,fields:{extra:{kind:"raw",iteration:String(T.iteration)}}}).catch(()=>{});return}if(T.type==="sessionId"){Nx(Ft(o.attemptDir,"log.jsonl"),"session",`session ${T.sessionId}`,{ts:J,fields:{extra:{kind:"sessionId",iteration:String(T.iteration),session_id:T.sessionId}}}).catch(()=>{});return}let Ne=o.attemptDir;if(Ne!==w&&(w=Ne,b=0),Ne!==v&&(v=Ne,I=KAe()),Ne!==L&&(L=Ne,R=0,B=0),(T.type==="text"||T.type==="toolCall"||T.type==="reasoning"||T.type==="usage")&&I.record(T),T.iteration!==b){let Fr=(jn,Mo,Ui)=>{OP(Ft(Ne,"afk.log"),jn),Nx(Ft(Ne,"log.jsonl"),"iteration",jn,{ts:J,fields:{extra:{iteration:String(Ui),phase:Mo}}}).catch(()=>{})};b>0&&Fr(HAe(b,"ended",y),"ended",b),b=T.iteration,Fr(HAe(b,"started",y),"started",b),Il(Ft(Ne,"afk.state.json"),{"current.iteration":String(b)}).catch(()=>{})}let Cr=T.type==="text"?T.message:T.type==="reasoning"?`\u{1F9E0} reasoning${T.tokens?` (${T.tokens} tok)`:T.message?`: ${T.message.slice(0,80)}`:""}`:T.type==="usage"?`\u{1F4B0} usage (in:${T.inputTokens} out:${T.outputTokens}${T.reasoningTokens?` reason:${T.reasoningTokens}`:""})`:T.type==="result"?`result: ${T.result}`:`\u2192 ${T.name} ${T.formattedArgs}`;Wut(Ft(o.attemptDir,"agent.log.jsonl"),Cr,{ts:J,fields:{extra:{iteration:String(T.iteration),kind:T.type}}}).catch(()=>{}),Nx(Ft(o.attemptDir,"log.jsonl"),"agent",Cr,{ts:J,fields:{extra:{iteration:String(T.iteration),kind:T.type}}}).catch(()=>{});let Li=Whr(T),ii=T.type==="toolCall"||T.type==="reasoning"||T.type==="usage"||T.type==="result",at=T.type==="usage"?{"current.input_tokens":I.peek().inputTokens,"current.output_tokens":I.peek().outputTokens,"current.cost_usd":I.peek().costUsd}:{};(Li||ii)&&Il(Ft(o.attemptDir,"afk.state.json"),{...Li?{"current.activity":Li,"current.last_stream_line":Cr.slice(0,200)}:{},"current.phase":"coding","current.last_event_at":J,...at}).catch(()=>{})},emitHeartbeat:T=>{let J=new Date().toISOString(),Ne=Math.max(0,Math.floor((T.nowMs-T.lastProgressMs)/1e3)),Cr=new Date(T.lastProgressMs).toISOString(),Li=T.head??"";(async()=>{let ii=await oat(g,o.attemptDir).catch(()=>{})??Ft(o.attemptDir,"worktree"),at=T.base?`origin/${T.base}`:`origin/${Pe(D,"dev.trunk")||"main"}`,Fr=vlt(o.attemptDir,"/"),{added:jn,removed:Mo}=await klt({headSha:Li,compute:()=>rat({cwd:ii},at).catch(()=>({added:0,removed:0})),computeUncommitted:()=>nat({cwd:ii}).catch(()=>({added:0,removed:0})),readMemo:()=>{try{let Ms=JSON.parse(cM(Fr,"utf8"));return{sha:String(Ms.sha??""),added:Number(Ms.added??0),removed:Number(Ms.removed??0)}}catch{return null}},writeMemo:Ms=>{try{Klt(Fr,JSON.stringify(Ms),"utf8")}catch{}}});k={added:jn,removed:Mo},jn>R&&(R=jn),Mo>B&&(B=Mo);let Ui=I.snapshotWindow(),$i=qut({secsSinceProgress:Ne,lastProgressAt:Cr,head:Li,added:jn,removed:Mo,activity:Ui});await Nx(Ft(o.attemptDir,"log.jsonl"),"heartbeat",$i.msg,{ts:J,fields:{extra:$i.extra}}).catch(()=>{}),await OP(Ft(o.attemptDir,"afk.log"),`[heartbeat] ${$i.msg}`),await Il(Ft(o.attemptDir,"afk.state.json"),{...$i.statePatch,"current.loc_peak_added":R,"current.loc_peak_removed":B,"current.worktree":ii,...T.base?{"current.base":T.base}:{}}).catch(()=>{})})()},heartbeatVitals:()=>{let T=I.peek();return{tools_called_count:T.toolsCalled,text_chunk_count:T.textChunks,reasoning_events:T.reasoningCount,reasoning_tokens:T.reasoningTokens,waiting_count:T.waiting,input_tokens:T.inputTokens,output_tokens:T.outputTokens,cost_usd:T.costUsd,loc_added:k.added,loc_removed:k.removed}},notesLoop:ie,writeNotes:(T,J)=>{try{Klt(T,J,"utf8")}catch{}},markPhase:T=>{Il(Ft(o.attemptDir,"afk.state.json"),{"current.phase":T}).catch(()=>{})},markState:T=>{Il(Ft(o.attemptDir,"afk.state.json"),T).catch(()=>{})},historyPath:A.historyPath,historyClock:{ts:new Date().toISOString(),epoch:Math.floor(Date.now()/1e3)},recoveryEnv:process.env,recordAttempt:zhr(e.root,o,a),recordOutcomeEvent:Vhr(e.root,o,a),cascadeRebase:{async listAFKBranches(){return(await Kp(g,"afk/")).map(J=>J.branch)},isWorkerLive(T){try{let J=DP(A.tmpDir,T),Ne=cM(J,"utf8").trim();return/^[1-9][0-9]*$/.test(Ne)?(process.kill(Number(Ne),0),!0):!1}catch(J){return J.code==="EPERM"}},async rebaseAndPush(T,J,Ne){let Cr=J.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40),Li=LC(process.env.RED_AFK_SLOT)??0,ii=Ft(A.tmpDir,"cascade-rebase",`${Cr}-${Li}`);try{if(await No(g,ii),!await Zd(g,ii,J))return{ok:!1,warn:`failed to create worktree for ${J}`};let Fr=a??(await Promise.resolve().then(()=>(bn(),hg))).execTool,jn=await Fr("git",["rebase",`origin/${Ne}`],{cwd:ii});if(jn.code!==0)return await Fr("git",["rebase","--abort"],{cwd:ii}).catch(()=>{}),{ok:!1,warn:`rebase of ${J} onto ${Ne} conflicted: ${jn.stderr.slice(0,200)}`};let Mo=await Fr("git",["push","origin",`HEAD:refs/heads/${J}`,"--force-with-lease"],{cwd:ii});return Mo.code!==0?{ok:!1,warn:`--force-with-lease push rejected for ${J}: ${Mo.stderr.slice(0,200)}`}:{ok:!0}}finally{await No(g,ii).catch(()=>{})}}}}}function qhr(e,t,r,n){return async o=>{let i=Ia(e,t,"validate",process.env);return Zut(o,async({prompt:s})=>{let a=n??(await Promise.resolve().then(()=>(bn(),hg))).execTool,c={cwd:r,timeoutMs:45e3,maxBuffer:1024*1024},u=t==="codex"?await a("codex",["exec","--model",i.model,"-c",`model_reasoning_effort=${i.effort}`,"-C",r,"--sandbox","read-only","--skip-git-repo-check",s],c):await a("claude",["--model",i.model,"--effort",i.effort,"--permission-mode","bypassPermissions","--print",s],c);return u.code===0?u.stdout.trim():void 0})}}function Ghr(e){try{let t=JSON.parse(cM(e,"utf8")).version;return typeof t=="string"&&t.length>0?t:void 0}catch{return}}function zhr(e,t,r){return async n=>{try{let o={...process.env,MEMORY_REPO_ROOT:process.env.MEMORY_REPO_ROOT??e},i=lut(e,o,{exists:aM,readJsonVersion:Ghr,readText:f=>{try{return cM(f,"utf8")}catch{return}}});if(!i)return;let s=t.attemptDir||e,a=Ft(s,`memory-attempt-${n.issueNumber}-a${n.attemptNumber}.json`);await Zp(s);let c=uut(n);await BY(a,c,"utf8");let u=r??(await Promise.resolve().then(()=>(bn(),hg))).execTool,[l,...d]=i;await u(l,[...d,"attempt","record","--root",e],{cwd:e,env:o,input:c})}catch(o){process.stderr.write(`[afk] memory attempt-record skipped (best-effort): ${String(o)}
647
649
  `)}}}function Vhr(e,t,r){return async n=>{try{let o=Ft(e,".red","config.yaml"),i=cM(o,"utf8");if(!gut(i,"brain"))return;let s={...process.env,BRAIN_REPO_ROOT:process.env.BRAIN_REPO_ROOT??e},a=Yhr(e,s);if(!a)return;let c=t.attemptDir||e;await Zp(c);let u=JSON.stringify(n);await BY(Ft(c,`brain-outcome-event-${n.context?.issueNumber??"unknown"}-a${n.context?.attemptNumber??"unknown"}.json`),u,"utf8");let l=r??(await Promise.resolve().then(()=>(bn(),hg))).execTool,[d,...f]=a;await l(d,[...f,"outcome-event","record","--root",e],{cwd:e,env:s,input:u})}catch(o){process.stderr.write(`[afk] brain outcome-event skipped (best-effort): ${String(o)}
648
650
  `)}}}function Yhr(e,t){let r=t.RED_BRAIN_CLI;if(r)return aM(r)?["node",r]:void 0;if(Jhr("brain",t.PATH))return["brain"];let o=t.CLAUDE_PLUGIN_ROOT??t.CODEX_PLUGIN_ROOT;if(o){let s=Ft(o,"..","brain","dist","cli.js");if(aM(s))return["node",s]}let i=Ft(e,"plugins","brain","dist","cli.js");if(aM(i))return["node",i]}function Jhr(e,t){for(let r of(t??"").split(":").filter(Boolean)){let n=Ft(r,e);if(aM(n))return n}}var Khr=300;async function Zlt(e,t,r){let n=r instanceof Error?r.message:String(r),o=r instanceof Error?r.stack:void 0,i={type:t,at:new Date().toISOString(),message:n,stack:o};await Zp(e),await BY(Ft(e,`${t}.log`),`${JSON.stringify(i)}
649
651
  `,"utf8"),process.stderr.write(`[afk] ${t}: ${n}
650
652
  `)}function edt(e){return Ft(e,"runner-circuit")}function tdt(e,t){return Ft(edt(e),`${t}.json`)}function Zhr(e){let t=e.RED_AFK_RUNNER_TRANSIENT_COOLDOWN_S;if(t!==void 0){let r=Number(t);if(Number.isInteger(r)&&r>0)return r}return Khr}async function Xhr(e,t,r,n){let o=Zhr(n);await Zp(edt(e)),await BY(tdt(e,t),`${JSON.stringify({runner:t,opened_at:r,expires_at:r+o,reason:"runner-transient"})}
651
- `,"utf8")}async function egr(e,t,r){try{let n=await sye(tdt(e,t),"utf8"),o=JSON.parse(n);return typeof o.expires_at=="number"&&o.expires_at>r}catch{return!1}}function tgr(e,t){let r=[];for(let o of Oge){let i;try{i=Jlt(Ft(e,o))}catch{continue}for(let s of i)if(bg(s))try{r.push({worker:s,basenames:Jlt(Ft(e,o,s))})}catch{}}let n=YAe(e,t,r);return n?n.attempt+1:1}async function uM(e){let t=e.cwd??process.cwd(),r=Fhr(e.args);r.model&&(process.env.RED_AFK_MODEL=r.model),r.effort&&(process.env.RED_AFK_EFFORT=r.effort);let n=GC({flag:r.runnerFlag??yM(e.args),processTree:zC(),scriptPath:process.argv[1]}),o=Tg(n.runner)?n.runner:"claude",i=await Ns(t),s=eAe(t,process.env,o),a=Mr(t);if(r.reconcileIssue===void 0&&process.env.RED_AFK_SWEEPS_DONE!=="1"){let R=Ft(a.tmpDir,"afk-supervisor.pid"),B=Qhr({origin:r.origin,lane:r.lane});if(await Ohr(R,r.force,process.stdout,ni,B)==="refused")return 1}let c=new Set((await Ig(t)).workers.map(R=>R.state.worker_id)),u=xct(Math.random,R=>c.has(R)),l=BP(process.pid)??"";if(process.stdout.write(`[afk] worker: ${u}
653
+ `,"utf8")}async function egr(e,t,r){try{let n=await sye(tdt(e,t),"utf8"),o=JSON.parse(n);return typeof o.expires_at=="number"&&o.expires_at>r}catch{return!1}}function tgr(e,t){let r=[];for(let o of Oge){let i;try{i=Jlt(Ft(e,o))}catch{continue}for(let s of i)if(bg(s))try{r.push({worker:s,basenames:Jlt(Ft(e,o,s))})}catch{}}let n=YAe(e,t,r);return n?n.attempt+1:1}async function uM(e){let t=e.cwd??process.cwd(),r=Fhr(e.args);r.model&&(process.env.RED_AFK_MODEL=r.model),r.effort&&(process.env.RED_AFK_EFFORT=r.effort);let n=GC({flag:r.runnerFlag??yM(e.args),processTree:zC(),scriptPath:process.argv[1]}),o=Tg(n.runner)?n.runner:"claude",i=await Ns(t),s=eAe(t,process.env,o),a=Mr(t);if(r.reconcileIssue===void 0&&process.env.RED_AFK_SWEEPS_DONE!=="1"){let R=Ft(a.tmpDir,"afk-supervisor.pid"),B=Qhr({origin:r.origin,lane:r.lane});if(await Ohr(R,r.force,process.stdout,oi,B)==="refused")return 1}let c=new Set((await Ig(t)).workers.map(R=>R.state.worker_id)),u=xct(Math.random,R=>c.has(R)),l=BP(process.pid)??"";if(process.stdout.write(`[afk] worker: ${u}
652
654
  `),process.env.RED_AFK_NO_PROCESS_SAFETY!=="1"&&Fut(Mut(UAe(a.tmpDir,u)),{workerId:u,pid:process.pid}),r.reconcileIssue!==void 0)return Uhr(r.reconcileIssue,o,i,a,u);let d=await q4(i),f=Math.floor(Date.now()/1e3),p=process.env.RED_AFK_SWEEPS_DONE==="1",m={runner:o,workerId:u,iterCap:r.iterCap,once:r.once,filter:r.filter,alternate:r.alternate,bootOnly:r.bootOnly,sweepsSkipped:p,issueTemplate:{tmpDir:a.tmpDir,repo:i.repo,repoDir:i.root,remote:i.remote,model:s.model}},g={cwd:i.root,repo:i.repo},A={tmpDir:a.tmpDir,stateDir:a.stateDir,gitignorePath:a.gitignorePath,workerDir:TP(a.tmpDir,u),workerPidFile:DP(a.tmpDir,u),workerPid:process.pid},E,y;try{p?(E={precheck:d,bootstrap:A,orphans:[],attemptCap:{byIssue:new Map},branches:{snapshotRefs:[],remoteLiveRefs:[],localLiveRefs:[]},unblockCandidates:[],skipSweeps:!0},y=ect(i,f)):(E=await j4(i,d,A,f),y=await G4(i,E,f))}catch(R){return await Zlt(A.workerDir,"boot-error",R).catch(()=>{process.stderr.write(`[afk] boot-error: ${R instanceof Error?R.message:String(R)}
653
655
  `)}),1}let b=iM(i.root,Ft(a.tmpDir,"feedback"),void 0,{rebaseOnto:s.feedbackRebaseBase});p||(y={...y,reconcileRunner:Xlt(i,a,u,o,b)});let w={attemptDir:""},I=Pit(r.request),v={gh:{listCandidates:()=>vst(g,r.lane)},runBoot:iY,bootDeps:y,bootOptions:E,processIssue:async(R,B)=>{let L=await plt(R,B);if(L.outcome==="runner-transient"&&await Xhr(a.tmpDir,B.runner,Math.floor(Date.now()/1e3),process.env).catch(()=>{}),L.outcome==="claim-lost")return await ds(B.attemptDir).catch(()=>{}),L;let D=Ft(B.attemptDir,"afk.state.json");return await vC(D)&&await Il(D,{pid:0},{allowPidReset:!0}).catch(()=>{}),L},processDeps:jhr(i,s.model,s.sandbox,b,w,r.fallbackRunner,o,void 0,s.maxIterations,s.attemptTimeoutSeconds,s.laneIdle,s.attemptBudget,r.verifyCommand,r.goVerifyRetries),hooks:{config:Sr(Mr(i.root).configPath,{warn:()=>{}}),resolveOptions:oM(i.root),exec:nM(i.root),env:JAe(i.repo,i.root,LC(process.env.RED_AFK_SLOT),o)},runnerCircuit:{isOpen:R=>egr(a.tmpDir,R,Math.floor(Date.now()/1e3))},buildProcessInput:(R,B)=>{let L=tgr(B.issueTemplate.tmpDir,R.number),D=T4(B.issueTemplate.tmpDir,B.workerId,R.number,L);w.attemptDir=D;let ee=Ft(D,"afk.state.json"),F=new Date().toISOString();try{B4(ee,{worker_id:B.workerId,pid:process.pid,pid_start_time:l,runner:B.runner,origin:r.origin??"",log:Ft(D,"afk.log"),started_at:F,"current.number":R.number,"current.title":R.title,"current.worktree":Ft(D,"worktree"),"current.handoff":Ft(D,"handoff.md"),"current.started_at":F,"current.runner":B.runner,"current.model":B.issueTemplate.model??"","current.effort":s.effort??"","current.activity":"setup","current.phase":"setup"}),_4(D,{worker_id:B.workerId,runner:B.runner,origin:r.origin??"",number:R.number,started_at:F})}catch{}let _=I?`${R.body}
654
656
 
@@ -756,7 +758,7 @@ ${e.slice(i.end).replace(/^\n+/,"")}`.trimEnd()+`
756
758
  Correction:
757
759
  ${e.note}`:`Drift detected (\`${e.signal}\`) on attempt ${r}. ${e.reason}`;return['<details data-kind="companion">',`<summary>Companion ${e.kind==="correct"?"correction":"escalation"} \u2014 ${e.signal}</summary>`,"",`<!-- ${e.fingerprint} -->`,n,"</details>"].join(`
758
760
  `)}function oyr(e,t,r){let n=["<!-- companion-correction -->","",`Companion drift correction (\`${r}\`):`,"",t].join(`
759
- `);return yft(e,n)}function iyr(e,t,r){return _Ae(e,{status:"blocked",kind:"drift",summary:`Companion drift correction budget spent (${t}).`,next:`${r} A human should re-read the issue, decide whether to re-scope or close it, then requeue.`})}async function wft(e){let r=await(e.readStates??qge)(e.workersRoot,e.readOpts),n=[];for(let o of r){if(!o.live)continue;let i=Xd(XAr(o.path));if(!i)continue;let s=tyr(o.state);if(!Cye(s,e.thresholds).drifting){n.push({issue:i.issue,attempt:i.attempt,disposition:"clean"});continue}let a=await b4(e.ctx,i.issue);if(a===null)continue;let c=await S4(e.ctx,i.issue),u=nyr(c.map(f=>f.body)),l=xft({issue:i.issue,attempt:i.attempt,vitals:s,thresholds:e.thresholds,seenFingerprints:u,cap:e.cap});if(l===null){n.push({issue:i.issue,attempt:i.attempt,disposition:"skipped-idempotent"});continue}if(e.dryRun){n.push({issue:i.issue,attempt:i.attempt,disposition:l.kind==="correct"?"corrected":"escalated",signal:l.signal});continue}let d=f=>a.labels.includes(f);l.kind==="correct"?(await EP(e.ctx,i.issue,oyr(a.body,l.note,l.signal)),await ri(e.ctx,i.issue,bft(l,i.issue,i.attempt)),await xa(e.ctx,i.issue,[],d(FY)?[]:[FY]),n.push({issue:i.issue,attempt:i.attempt,disposition:"corrected",signal:l.signal})):(await EP(e.ctx,i.issue,iyr(a.body,l.signal,l.reason)),await ri(e.ctx,i.issue,bft(l,i.issue,i.attempt)),await xa(e.ctx,i.issue,d(FY)?[FY]:[],d(Eft)?[]:[Eft]),n.push({issue:i.issue,attempt:i.attempt,disposition:"escalated",signal:l.signal}))}return n}function Ift(e,t=!1){let r=e.filter(i=>i.disposition==="corrected"||i.disposition==="escalated");if(r.length===0)return"";let n=t?"would ":"";return`companion: ${r.map(i=>`#${i.issue} a${i.attempt} ${n}${i.disposition==="corrected"?"correct":"escalate"} (${i.signal})`).join(", ")}`}var syr=["setup","coding","validating","merging","done"];function wye(e,t,r,n){let o=syr.indexOf(r),i=o>=0?`[${o+1}/5 ${r}]`:r?`[${r}]`:"";return`${i?`${e} ${i}`:e} #${t} ${n}`.trimEnd()}function kft(e,t){return`${e}:${t}`}function ayr(e,t){let r=new Map;for(let i of t)r.set(i.key,i);let n=new Set(e.map(i=>kft(i.worker_id,i.issue))),o=[];for(let i of e){let s=kft(i.worker_id,i.issue),a=r.get(s);i.status==="running"?a===void 0?o.push({op:"create",key:s,worker_id:i.worker_id,issue:i.issue,title:i.title,slug:i.slug,activity:i.activity,phase:i.phase,status:"running"}):(a.activity!==i.activity||(a.phase??"")!==i.phase)&&o.push({op:"update",key:s,worker_id:i.worker_id,issue:i.issue,title:i.title,slug:i.slug,activity:i.activity,phase:i.phase,status:"running"}):a!==void 0&&o.push({op:"complete",key:s,worker_id:i.worker_id,issue:i.issue,slug:i.slug,phase:i.status==="blocked"?"blocked":"done",result:i.status==="blocked"?"failed":"completed"})}for(let i of t)n.has(i.key)||o.push({op:"complete",key:i.key,result:"completed"});return o}function Iye(e,t){let r=[];for(let n of ayr(e,t))n.op==="create"?r.push({call:"TaskCreate",key:n.key,title:wye(n.worker_id,n.issue,n.phase??"",n.slug??""),description:`activity: ${n.activity}`,state:"in_progress"}):n.op==="update"?r.push({call:"TaskUpdate",key:n.key,title:wye(n.worker_id,n.issue,n.phase??"",n.slug??""),description:`activity: ${n.activity}`,state:"in_progress"}):n.result==="failed"&&n.worker_id!==void 0?r.push({call:"TaskUpdate",key:n.key,title:wye(n.worker_id,n.issue,n.phase??"blocked",n.slug??""),state:"failed"}):r.push({call:"TaskUpdate",key:n.key,state:n.result});return r}var cyr="afk: Codex has no native task surface \u2014 mirroring via the monitor.sh dashboard instead.";function vft(e,t,r={}){return r.nativeTaskAvailable?{plan:Iye(e,t)}:{plan:[],notice:cyr}}function Rft(e){switch(e.trim().toLowerCase()){case"claude":return{host:"claude",surface:"native-task",agentDriven:!0,nativeTaskApi:!0,note:"Claude Code Agent runner: native Task mirror via TaskCreate/TaskUpdate."};case"codex":return{host:"codex",surface:"monitor-agent",agentDriven:!0,nativeTaskApi:!1,note:"Codex Agent runner: no task API \u2014 dashboard fallback plus one read-only Codex monitor agent."};case"opencode":return{host:"opencode",surface:"headless",agentDriven:!1,nativeTaskApi:!1,note:"OpenCode runner: headless API-auth Worker, no host session and no Task mirror surface."};default:throw new Error(`taskMirrorCapability: unknown host '${e}'`)}}function uyr(e){let t=[];for(let r of e){let n=r.state.current.number;if(n===""||n===null||n===void 0)continue;let o=typeof n=="number"?n:Number(n);if(!Number.isFinite(o))continue;let i=r.state.current.phase??"",s=r.livenessVerdict?r.livenessVerdict.status!=="stalled":r.liveness?r.liveness!=="dead":r.pidLive??r.live;t.push({worker_id:r.state.worker_id,issue:o,title:r.state.current.title,slug:r.state.current.slug||r.state.current.title,activity:r.state.current.activity,phase:i,started_at:r.state.current.started_at||r.state.started_at,status:s?"running":i==="blocked"?"blocked":"gone"})}return t}function lyr(e){let t=[];for(let r of e.split(`
761
+ `);return yft(e,n)}function iyr(e,t,r){return _Ae(e,{status:"blocked",kind:"drift",summary:`Companion drift correction budget spent (${t}).`,next:`${r} A human should re-read the issue, decide whether to re-scope or close it, then requeue.`})}async function wft(e){let r=await(e.readStates??qge)(e.workersRoot,e.readOpts),n=[];for(let o of r){if(!o.live)continue;let i=Xd(XAr(o.path));if(!i)continue;let s=tyr(o.state);if(!Cye(s,e.thresholds).drifting){n.push({issue:i.issue,attempt:i.attempt,disposition:"clean"});continue}let a=await b4(e.ctx,i.issue);if(a===null)continue;let c=await S4(e.ctx,i.issue),u=nyr(c.map(f=>f.body)),l=xft({issue:i.issue,attempt:i.attempt,vitals:s,thresholds:e.thresholds,seenFingerprints:u,cap:e.cap});if(l===null){n.push({issue:i.issue,attempt:i.attempt,disposition:"skipped-idempotent"});continue}if(e.dryRun){n.push({issue:i.issue,attempt:i.attempt,disposition:l.kind==="correct"?"corrected":"escalated",signal:l.signal});continue}let d=f=>a.labels.includes(f);l.kind==="correct"?(await EP(e.ctx,i.issue,oyr(a.body,l.note,l.signal)),await ni(e.ctx,i.issue,bft(l,i.issue,i.attempt)),await xa(e.ctx,i.issue,[],d(FY)?[]:[FY]),n.push({issue:i.issue,attempt:i.attempt,disposition:"corrected",signal:l.signal})):(await EP(e.ctx,i.issue,iyr(a.body,l.signal,l.reason)),await ni(e.ctx,i.issue,bft(l,i.issue,i.attempt)),await xa(e.ctx,i.issue,d(FY)?[FY]:[],d(Eft)?[]:[Eft]),n.push({issue:i.issue,attempt:i.attempt,disposition:"escalated",signal:l.signal}))}return n}function Ift(e,t=!1){let r=e.filter(i=>i.disposition==="corrected"||i.disposition==="escalated");if(r.length===0)return"";let n=t?"would ":"";return`companion: ${r.map(i=>`#${i.issue} a${i.attempt} ${n}${i.disposition==="corrected"?"correct":"escalate"} (${i.signal})`).join(", ")}`}var syr=["setup","coding","validating","merging","done"];function wye(e,t,r,n){let o=syr.indexOf(r),i=o>=0?`[${o+1}/5 ${r}]`:r?`[${r}]`:"";return`${i?`${e} ${i}`:e} #${t} ${n}`.trimEnd()}function kft(e,t){return`${e}:${t}`}function ayr(e,t){let r=new Map;for(let i of t)r.set(i.key,i);let n=new Set(e.map(i=>kft(i.worker_id,i.issue))),o=[];for(let i of e){let s=kft(i.worker_id,i.issue),a=r.get(s);i.status==="running"?a===void 0?o.push({op:"create",key:s,worker_id:i.worker_id,issue:i.issue,title:i.title,slug:i.slug,activity:i.activity,phase:i.phase,status:"running"}):(a.activity!==i.activity||(a.phase??"")!==i.phase)&&o.push({op:"update",key:s,worker_id:i.worker_id,issue:i.issue,title:i.title,slug:i.slug,activity:i.activity,phase:i.phase,status:"running"}):a!==void 0&&o.push({op:"complete",key:s,worker_id:i.worker_id,issue:i.issue,slug:i.slug,phase:i.status==="blocked"?"blocked":"done",result:i.status==="blocked"?"failed":"completed"})}for(let i of t)n.has(i.key)||o.push({op:"complete",key:i.key,result:"completed"});return o}function Iye(e,t){let r=[];for(let n of ayr(e,t))n.op==="create"?r.push({call:"TaskCreate",key:n.key,title:wye(n.worker_id,n.issue,n.phase??"",n.slug??""),description:`activity: ${n.activity}`,state:"in_progress"}):n.op==="update"?r.push({call:"TaskUpdate",key:n.key,title:wye(n.worker_id,n.issue,n.phase??"",n.slug??""),description:`activity: ${n.activity}`,state:"in_progress"}):n.result==="failed"&&n.worker_id!==void 0?r.push({call:"TaskUpdate",key:n.key,title:wye(n.worker_id,n.issue,n.phase??"blocked",n.slug??""),state:"failed"}):r.push({call:"TaskUpdate",key:n.key,state:n.result});return r}var cyr="afk: Codex has no native task surface \u2014 mirroring via the monitor.sh dashboard instead.";function vft(e,t,r={}){return r.nativeTaskAvailable?{plan:Iye(e,t)}:{plan:[],notice:cyr}}function Rft(e){switch(e.trim().toLowerCase()){case"claude":return{host:"claude",surface:"native-task",agentDriven:!0,nativeTaskApi:!0,note:"Claude Code Agent runner: native Task mirror via TaskCreate/TaskUpdate."};case"codex":return{host:"codex",surface:"monitor-agent",agentDriven:!0,nativeTaskApi:!1,note:"Codex Agent runner: no task API \u2014 dashboard fallback plus one read-only Codex monitor agent."};case"opencode":return{host:"opencode",surface:"headless",agentDriven:!1,nativeTaskApi:!1,note:"OpenCode runner: headless API-auth Worker, no host session and no Task mirror surface."};default:throw new Error(`taskMirrorCapability: unknown host '${e}'`)}}function uyr(e){let t=[];for(let r of e){let n=r.state.current.number;if(n===""||n===null||n===void 0)continue;let o=typeof n=="number"?n:Number(n);if(!Number.isFinite(o))continue;let i=r.state.current.phase??"",s=r.livenessVerdict?r.livenessVerdict.status!=="stalled":r.liveness?r.liveness!=="dead":r.pidLive??r.live;t.push({worker_id:r.state.worker_id,issue:o,title:r.state.current.title,slug:r.state.current.slug||r.state.current.title,activity:r.state.current.activity,phase:i,started_at:r.state.current.started_at||r.state.started_at,status:s?"running":i==="blocked"?"blocked":"gone"})}return t}function lyr(e){let t=[];for(let r of e.split(`
760
762
  `)){let n=r.trim();if(n==="")continue;let o;try{o=JSON.parse(n)}catch{continue}if(o===null||typeof o!="object")continue;let i=o;typeof i.key=="string"&&t.push({key:i.key,activity:typeof i.activity=="string"?i.activity:typeof i.stage=="string"?i.stage:"",phase:typeof i.phase=="string"?i.phase:""})}return t}function dyr(e,t,r={}){let n=uyr(e),o=lyr(t),i=r.host??(r.codex?"codex":"claude"),s,a;switch(Rft(i).surface){case"native-task":s=Iye(n,o);break;case"monitor-agent":{let l=vft(n,o);s=l.plan,a=l.notice;break}case"headless":s=[];break}let c=s.length===0?"":`${s.map(l=>JSON.stringify(l)).join(`
761
763
  `)}
762
764
  `;return a===void 0?c:`${c}${JSON.stringify({signal:"fallback-notice",message:a})}
@@ -789,7 +791,7 @@ ${e.note}`:`Drift detected (\`${e.signal}\`) on attempt ${r}. ${e.reason}`;retur
789
791
  requeued to ready-for-agent${e.activeBlocker?` (cleared active blocker: ${e.activeBlocker.kind})`:""}`,"</details>"].join(`
790
792
  `)}async function Gyr(e,t,r){let n="a maintainer";try{let i=await jt("gh",["api","user","-q",".login"],{cwd:e});i.code===0&&i.stdout.trim()&&(n=`@${i.stdout.trim()}`)}catch{}let o=new Date().toISOString();return['<details data-kind="sensitive-path-adopt">',"<summary>Sensitive-path adopt approved</summary>","",`${n} approved the sensitive-path diff and landed \`${t}\` via \`/requeue --adopt-branch\` at ${o}.`,"The landing sensitive-path guard (#1102) was bypassed for this human-reviewed land only; every autonomous attempt keeps the guard armed (#1171).","","Human guidance:",r?.trim()||"(none recorded)","</details>"].join(`
791
793
  `)}async function zyr(e,t){if(t?.trim())return t.trim();let r=await jt("gh",["repo","view","--json","nameWithOwner","-q",".nameWithOwner"],{cwd:e});return r.code===0?r.stdout.trim():""}function Hft(e){try{Fyr(e,{recursive:!0}),Myr(UR(e,Vp),`${JSON.stringify({at:Date.now(),kind:"iteration-start"})}
792
- `)}catch{}}function Vyr(e){return{seed(t){try{let r=new Date().toISOString();B4(t.statePath,{worker_id:t.worker,pid:process.pid,pid_start_time:BP(process.pid)??"",runner:e,origin:vye,log:UR(t.attemptDir,"afk.log"),started_at:r,"current.number":t.issue,"current.title":t.title,"current.started_at":r,"current.runner":e,"current.activity":t.stage,"current.phase":"validating"}),_4(t.attemptDir,{worker_id:t.worker,runner:e,origin:vye,number:t.issue,started_at:r}),Hft(t.attemptDir)}catch{}},async setStage(t,r){try{await Il(t,{"current.activity":r,"current.phase":r==="landing"?"merging":"validating"}),Hft(Lyr(t))}catch{}},async teardown(t,r){try{await vC(t)&&await Il(t,{pid:0},{allowPidReset:!0})}catch{}await ds(r).catch(()=>{})}}}async function Yyr(e,t,r,n,o,i){let s=Mr(n),a=DC(n),c={cwd:n,repo:o},u={cwd:n},l=Qx(n),d=UR(s.tmpDir,"adopt-landing",String(e)),f=iM(n,d,void 0,{}),p;try{let m=await pf({issueBody:r.body},{readLockedBranch:()=>wg(l),configLockedBranch:void 0,configTrunk:Pe(Sr(s.configPath,{warn:()=>{}}),"dev.trunk")||void 0,fetchIssueBody:async()=>{}}),g=`Issue #${e}`;try{let y=await jt("gh",["issue","view",String(e),"--repo",o,"--json","title","-q",".title"],{cwd:n});y.code===0&&y.stdout.trim()&&(g=y.stdout.trim())}catch{}let A={gh:{editLabels:async(y,b,w)=>W4(a,()=>xa(c,y,b,w),b,w),ensureLabel:y=>wl(c,y),comment:(y,b)=>ri(c,y,b),close:y=>Tx(c,y),listByLabel:y=>bP(c,y),issueClosed:y=>SP(c,y)},git:{headShortSha:()=>yg(u),deleteLocalBranch:y=>xg(u,y)},fs:{completionSweep:async()=>[]},lookups:{changedFiles:(y,b)=>IP(u,y,b),branchPresent:async y=>await Eg(u,y)?!0:(await wP(u,y),Eg(u,y)),isLocked:()=>xR(l)},mergeExec:kP(u),remoteGit:Jp(u),pnpm:f.pnpm,layout:f.layout,makeLandingWorktree:async y=>{let b=y.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"base",w=UR(s.tmpDir,"landing",`${b}-adopt-${e}`);return await No(u,w),await Zd(u,w,y)?w:null},removeLandingWorktree:y=>No(u,y),makeRebaseWorktree:async y=>{let b=y.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"branch",w=UR(s.tmpDir,"rebase",`${b}-adopt-${e}`);return await No(u,w),await Zd(u,w,y)?w:null},removeRebaseWorktree:y=>No(u,y),envelope:{git:Jp(u),poster:async(y,b)=>(await ri(c,y,b),!0),writeMarkers:async()=>{},writePosted:async()=>{}},nowEpoch:()=>Math.floor(Date.now()/1e3),appendIterLog:y=>{i.write(`${y}
794
+ `)}catch{}}function Vyr(e){return{seed(t){try{let r=new Date().toISOString();B4(t.statePath,{worker_id:t.worker,pid:process.pid,pid_start_time:BP(process.pid)??"",runner:e,origin:vye,log:UR(t.attemptDir,"afk.log"),started_at:r,"current.number":t.issue,"current.title":t.title,"current.started_at":r,"current.runner":e,"current.activity":t.stage,"current.phase":"validating"}),_4(t.attemptDir,{worker_id:t.worker,runner:e,origin:vye,number:t.issue,started_at:r}),Hft(t.attemptDir)}catch{}},async setStage(t,r){try{await Il(t,{"current.activity":r,"current.phase":r==="landing"?"merging":"validating"}),Hft(Lyr(t))}catch{}},async teardown(t,r){try{await vC(t)&&await Il(t,{pid:0},{allowPidReset:!0})}catch{}await ds(r).catch(()=>{})}}}async function Yyr(e,t,r,n,o,i){let s=Mr(n),a=DC(n),c={cwd:n,repo:o},u={cwd:n},l=Qx(n),d=UR(s.tmpDir,"adopt-landing",String(e)),f=iM(n,d,void 0,{}),p;try{let m=await pf({issueBody:r.body},{readLockedBranch:()=>wg(l),configLockedBranch:void 0,configTrunk:Pe(Sr(s.configPath,{warn:()=>{}}),"dev.trunk")||void 0,fetchIssueBody:async()=>{}}),g=`Issue #${e}`;try{let y=await jt("gh",["issue","view",String(e),"--repo",o,"--json","title","-q",".title"],{cwd:n});y.code===0&&y.stdout.trim()&&(g=y.stdout.trim())}catch{}let A={gh:{editLabels:async(y,b,w)=>W4(a,()=>xa(c,y,b,w),b,w),ensureLabel:y=>wl(c,y),comment:(y,b)=>ni(c,y,b),close:y=>Tx(c,y),listByLabel:y=>bP(c,y),issueClosed:y=>SP(c,y)},git:{headShortSha:()=>yg(u),deleteLocalBranch:y=>xg(u,y)},fs:{completionSweep:async()=>[]},lookups:{changedFiles:(y,b)=>IP(u,y,b),branchPresent:async y=>await Eg(u,y)?!0:(await wP(u,y),Eg(u,y)),isLocked:()=>xR(l)},mergeExec:kP(u),remoteGit:Jp(u),pnpm:f.pnpm,layout:f.layout,makeLandingWorktree:async y=>{let b=y.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"base",w=UR(s.tmpDir,"landing",`${b}-adopt-${e}`);return await No(u,w),await Zd(u,w,y)?w:null},removeLandingWorktree:y=>No(u,y),makeRebaseWorktree:async y=>{let b=y.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"branch",w=UR(s.tmpDir,"rebase",`${b}-adopt-${e}`);return await No(u,w),await Zd(u,w,y)?w:null},removeRebaseWorktree:y=>No(u,y),envelope:{git:Jp(u),poster:async(y,b)=>(await ni(c,y,b),!0),writeMarkers:async()=>{},writePosted:async()=>{}},nowEpoch:()=>Math.floor(Date.now()/1e3),appendIterLog:y=>{i.write(`${y}
793
795
  `)},markStage:y=>p?p(y):Promise.resolve(),recoveryEnv:process.env},E={issue:e,title:g,body:r.body,labels:[...r.labels],branch:t,base:m,trunk:Pe(Sr(s.configPath,{warn:()=>{}}),"dev.trunk")||"main",repo:o,repoDir:n,remote:"origin",workerId:"requeue-adopt",attempt:0,attemptDir:UR(s.tmpDir,"adopt-landing",String(e)),runner:"claude",sensitivePathApproved:r.sensitivePathApproved===!0};return await $ft(Vyr(E.runner),{tmpDir:s.tmpDir,issue:e,title:g,runner:E.runner},async y=>(p=y.markStage,(await TR(A,E)).outcome))}finally{await f.cleanup()}}async function Wft(e,t=process.cwd(),r=process.stdout,n,o){let{values:i,positionals:s}=Dl(e,Uyr),a=$yr(s[0]);if(a===void 0)return process.stderr.write(`[afk] requeue requires an issue number like #123
794
796
  `),2;let c=i.guidance?.trim(),u=i.json===!0,l=i["dry-run"]===!0,d=i["adopt-branch"]?.trim()||void 0;if(!c)return process.stderr.write(`[afk] requeue requires --guidance with the retry decision so it can be recorded as Human guidance
795
797
  `),2;let f=n?"":await zyr(t,i.repo),p=n??Hyr(t,f),m=await p.view(a);if(m.state.toUpperCase()!=="OPEN")return process.stderr.write(`[afk] requeue #${a}: issue is ${m.state||"unknown"}, not OPEN
@@ -816,7 +818,7 @@ requeued to ready-for-agent${e.activeBlocker?` (cleared active blocker: ${e.acti
816
818
  `),2;let i=n.root?.trim()||t,s=Sr(sf(i),{warn:()=>{}}),a=n.runner,c=Pe(s,"afk.default_runner")||"claude",u=a??c,l=mxr(u)?u:"claude",d=await hxr(i,n.repo),f={cwd:i,repo:d},p=Tl(s),m=Ia(s,l,"complex",process.env),g=await SC(),A=npt({run:g.run,agentFor:g.agentFor,sandboxFor:y=>g.sandboxFor(y),output:({tag:y,maxRetries:b})=>Wp.object({tag:y,schema:fye,maxRetries:b}),cwd:i},{model:m.model,effort:m.effort}),E;try{E=await Tdt({gh:IY(f,y=>Bl(p,y,b=>Ag(f,b))),extractReview:A,log:y=>process.stderr.write(`${y}
817
819
  `)},{pr:o,runner:l})}catch(y){return process.stderr.write(`[afk] review failed: ${y instanceof Error?y.message:String(y)}
818
820
  `),1}return r.write(`Review #${o}: ${E.verdict} (${E.postedComments} inline comment(s)${E.posted?", posted":""}).
819
- `),0}Ng();nu();import{Writable as gxr}from"node:stream";import{readFile as Axr}from"node:fs/promises";tf();async function yxr(e){try{let t=(await Axr(e,"utf8")).trim();return/^[1-9][0-9]*$/.test(t)?Number(t):null}catch{return null}}var xxr={stopFleet:sAe,listStaleClaimDirs:RC,removeDir:ds,readWorkerPid:yxr,isLivePid:ni,killTreeAndWait:Cg};function Exr(e){let t=null;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="--worker"||n==="-w"){t=e[++r]??null;continue}if(n.startsWith("--worker=")){t=n.slice(9);continue}}return{worker:t}}var bxr=new gxr({write(e,t,r){r()}});async function opt(e,t=process.cwd(),r=process.stdout,n=xxr){let o=Exr(e),i=Mr(t);try{return o.worker!==null?await Cxr(o.worker,i.tmpDir,r,n):await Sxr(t,i.tmpDir,r,n)}catch(s){let a=s instanceof Error?s.message:String(s);return process.stderr.write(`[afk stop] \u2717 ${a}
821
+ `),0}Ng();nu();import{Writable as gxr}from"node:stream";import{readFile as Axr}from"node:fs/promises";tf();async function yxr(e){try{let t=(await Axr(e,"utf8")).trim();return/^[1-9][0-9]*$/.test(t)?Number(t):null}catch{return null}}var xxr={stopFleet:sAe,listStaleClaimDirs:RC,removeDir:ds,readWorkerPid:yxr,isLivePid:oi,killTreeAndWait:Cg};function Exr(e){let t=null;for(let r=0;r<e.length;r+=1){let n=e[r];if(n==="--worker"||n==="-w"){t=e[++r]??null;continue}if(n.startsWith("--worker=")){t=n.slice(9);continue}}return{worker:t}}var bxr=new gxr({write(e,t,r){r()}});async function opt(e,t=process.cwd(),r=process.stdout,n=xxr){let o=Exr(e),i=Mr(t);try{return o.worker!==null?await Cxr(o.worker,i.tmpDir,r,n):await Sxr(t,i.tmpDir,r,n)}catch(s){let a=s instanceof Error?s.message:String(s);return process.stderr.write(`[afk stop] \u2717 ${a}
820
822
  `),1}}async function Sxr(e,t,r,n){let o=await n.stopFleet(e,bxr),i=await n.listStaleClaimDirs(t).catch(()=>[]),s=0;for(let a of i)await n.removeDir(a.path).catch(()=>{}),s+=1;return r.write(ji({op:"stop",supervisor_pid:o.pid??null,supervisor_status:o.status,claims_released:s})+`
821
823
  `),o.status==="timeout"?1:0}async function Cxr(e,t,r,n){if(!bg(e))return process.stderr.write(`[afk stop] invalid worker id: ${JSON.stringify(e)}
822
824
  `),1;let o=DP(t,e),i=await n.readWorkerPid(o);if(i===null)return r.write(ji({op:"stop-worker",worker:e,worker_pid:null,worker_status:"none"})+`
@@ -827,8 +829,8 @@ requeued to ready-for-agent${e.activeBlocker?` (cleared active blocker: ${e.acti
827
829
  `),2;let i=n.body??"",s=n.author?.trim()||void 0,a=n["is-pr"]===!0,c=n.root?.trim()||t,u=Sr(sf(c),{warn:()=>{}}),l=n.runner,d=Pe(u,"afk.default_runner")||"claude",f=l??d,p=Dxr(f)?f:"claude",m=await Qxr(c,n.repo),g={cwd:c,repo:m},A=Tl(u),E=Ia(u,p,"complex",process.env),y=await SC(),b=cpt({run:y.run,agentFor:y.agentFor,sandboxFor:k=>y.sandboxFor(k),output:({tag:k,maxRetries:R})=>Wp.object({tag:k,schema:apt,maxRetries:R}),cwd:c},{model:E.model,effort:E.effort}),w={async reply(k,R){let B=a?"pr":"issue",L=m?["--repo",m]:[];await jt("gh",[B,"comment",String(k),...L,"--body",jr(R)],{cwd:c})}},I={body:i,author:s,number:o,isPr:a,runner:p},v;try{v=await spt({gh:w,resolveTrust:k=>Bl(A,k,R=>Ag(g,R)),explain:b,review:async()=>{let k=["--pr",String(o),"--runner",p];m&&k.push("--repo",m),c&&k.push("--root",c),await HY(k,c,r)},log:k=>process.stderr.write(`${k}
828
830
  `)},I)}catch(k){return process.stderr.write(`[afk] respond failed: ${k instanceof Error?k.message:String(k)}
829
831
  `),1}return r.write(`Respond #${o}: ${v.action}${v.verb?` (/dev ${v.verb})`:""}.
830
- `),0}FC();function Oxr(e){let t=e.indexOf("--runner");return(t>=0?e[t+1]:void 0)==="claude"?"claude":"codex"}function Nxr(e){let t=JP(void 0,{runner:e});return JSON.stringify(e==="codex"?{systemMessage:t}:{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:t}})}async function lpt(e){let t=Oxr(e),r=JP(void 0,{runner:t});return process.stdout.write(e.includes("--hook")?Nxr(t):r),e.includes("--hook")&&process.stdout.write(`
831
- `),0}import{existsSync as EEr,readFileSync as bEr,statSync as Bye}from"node:fs";import{join as vpt,basename as SEr}from"node:path";function jY(e){let t={app:e,version:Pxr(HR("__RED_BUILD_VERSION__",()=>"2.53.1")??"0.0.0-dev"),gitSha:HR("__RED_BUILD_GIT_SHA__",()=>"edb9247168a7138eda26e59f5fe75c1d7e3cadbd")??"unknown",buildTime:HR("__RED_BUILD_TIME__",()=>"2026-07-13T14:55:49-03:00")??"unknown",bundleAsset:HR("__RED_BUNDLE_ASSET__",()=>"dev.bundle.min.mjs")??"unknown"},r=HR("__REDDB_SDK_VERSION__",()=>""),n=HR("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function Pxr(e){return e.startsWith("v")?e.slice(1):e}function dpt(e){return`${e.app} ${e.version} ${e.gitSha}`}function HR(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}function zY(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.floor(e/1e3)}k`:String(e)}function mpt(e){let t=(r,n)=>{let o=(Math.round(r*10)/10).toFixed(1);return`${o.endsWith(".0")?o.slice(0,-2):o}${n}`};return e>=1e9?t(e/1e9,"B"):e>=1e6?t(e/1e6,"M"):e>=1e3?t(e/1e3,"k"):String(e>0?e:0)}function qY(e){if(e>=100)return e.toFixed(0);if(e>=10)return e.toFixed(1);if(e>=1)return e.toFixed(2);let t=Math.max(2,Math.ceil(-Math.log10(e))+2);return e.toFixed(t)}function Mxr(e){let t=Number.isFinite(e)&&e>0?e:0;return t===0?"0":t>=1e9?`${qY(t/1e9)}B`:t>=1e6?`${qY(t/1e6)}M`:t>=1e3?`${qY(t/1e3)}k`:qY(t)}function Fxr(e){let t=Math.max(0,Math.floor(e));return t<1e3?String(t):t<1e6?`${(Math.floor(t/100)/10).toFixed(1)}k`:Mxr(t)}function hpt(e){let t=e.toLowerCase();for(let r of["opus","sonnet","haiku","fable"])if(t.includes(r))return r;return e}function Lxr(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let r=Math.floor(t/60);if(r<60)return`${r}m${t%60}s`;let n=Math.floor(r/60);return n<24?`${n}h${r%60}m`:`${Math.floor(n/24)}d${n%24}h`}function WR(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let r=Math.floor(t/60),n=t%60;return n>0?`${r}h${n}m`:`${r}h`}function fpt(e){let t=e.basename;if(e.branch){let r=e.branch;return r.length>28&&(r=`${r.slice(0,27)}\u2026`),`${t} (${r})`}return e.detachedSha?`${t} (detached ${e.detachedSha})`:t}function Uxr(e){return!e||!e.model?null:e.effort?`${e.model}\xB7${e.effort}`:e.model}function ppt(e){if(!e)return null;let t=e.contextTokens;if(t===void 0||t===0)return null;let r=zY(t);return e.contextPercent===void 0?r:`${r} ${Math.round(e.contextPercent)}%`}function $xr(e){if(!e||e.workers<=0)return[];let t=[],r=(i,s)=>{t.push({label:i,value:s,suffix:""})};if(e.workers>0&&r("wrk=",String(e.workers)),e.sourceCounts&&e.sourceCounts.length>0)for(let{origin:i,count:s}of e.sourceCounts)r(`${i}=`,String(s));let n=e.cacheAgeS!==void 0?` (${WR(e.cacheAgeS)})`:"";if(e.queue>0&&t.push({label:"rdy=",value:String(e.queue),suffix:n}),e.human>0){let i=n&&e.queue===0?n:"";t.push({label:"hmn=",value:String(e.human),suffix:i})}e.blocked>0&&r("blk=",String(e.blocked));let o=[];return e.added>0&&o.push(`+${e.added}`),e.removed>0&&o.push(`-${e.removed}`),o.length&&r("loc=",e.locIsPeak?`~${o.join(" ")}`:o.join(" ")),e.waiting!==void 0&&e.waiting>0&&r("wai=",String(e.waiting)),e.tokens!==void 0&&e.tokens>0&&r("tok=",zY(e.tokens)),e.costUsd!==void 0&&e.costUsd>0&&r("usd=",e.costUsd.toFixed(2)),e.issues.forEach((i,s)=>{let a=e.phases?.[s],c=e.aliveMs?.[s],u=a?`\xB7${a}`:"";c!==void 0&&c>0&&(u+=`\xB7${Lxr(c)}`),t.push({label:"#",value:String(i),suffix:u})}),t}function Hxr(e){if(!e)return null;let t=[];return e.usage5h!==void 0&&t.push(`5h=${Math.round(e.usage5h)}%`),e.usage7d!==void 0&&t.push(`7d=${Math.round(e.usage7d)}%`),t.length?t.join(" "):null}function Wxr(e){if(!e)return null;let t=[],r=e.cacheAgeS!==void 0?` (${WR(e.cacheAgeS)})`:"";if(e.openPrs&&e.openPrs>0&&t.push(`prs=${e.openPrs}${r}`),e.todayPrs&&e.todayPrs>0){let o=r&&(!e.openPrs||e.openPrs===0)?r:"";t.push(`cpr=${e.todayPrs}${o}`)}if(e.openIssues&&e.openIssues>0){let o=r&&(!e.openPrs||e.openPrs===0)&&(!e.todayPrs||e.todayPrs===0)?r:"";t.push(`iss=${e.openIssues}${o}`)}let n=[];return e.localAdded&&e.localAdded>0&&n.push(`+${e.localAdded}`),e.localRemoved&&e.localRemoved>0&&n.push(`-${e.localRemoved}`),n.length&&t.push(`loc=${n.join(" ")}`),t.length?t.join(" "):null}function jxr(e){if(!e||!e.openIssues||e.openIssues<=0)return null;let t=e.cacheAgeS!==void 0?` (${WR(e.cacheAgeS)})`:"";return`iss=${e.openIssues}${t}`}function _ye(e){if(!e)return null;let t=e.runner||"?",r=Math.max(0,Math.floor(e.busy)),n=Math.max(0,Math.floor(e.total)),o=Math.max(0,Math.floor(e.queue)),i=[`flt=${t} ${r}/${n} busy`,`q=${o}`];return e.parked!==void 0&&e.parked>0&&i.push(`park=${Math.floor(e.parked)}`),i.join(" \xB7 ")}function GY(e){return e?e.state==="ready"?`rsp=\u2193${Fxr(e.tokensSavedToday)}`:e.state==="warming"?"rsp=\u2026":"rsp=!":null}function qxr(e){let t=$xr(e);return t.length===0?null:t.map(r=>`${r.label}${r.value}${r.suffix}`).join(" ")}function gpt(e,t="full"){if(t==="short"){let l=[fpt(e.project)],d=ppt(e.claude);d!==null&&l.push(`ctx=${d}`);let f=jxr(e.repo);f!==null&&l.push(f);let p=GY(e.rsp);return p!==null&&l.push(p),l.join(" \xB7 ")}let r=[fpt(e.project)],n=Uxr(e.claude);n!==null&&r.push(n);let o=ppt(e.claude);o!==null&&r.push(o);let i=Hxr(e.claude);i!==null&&r.push(i);let s=Wxr(e.repo);s!==null&&r.push(s);let a=_ye(e.fleet);a!==null&&r.push(a);let c=GY(e.rsp);c!==null&&r.push(c);let u=qxr(e.afk);return u!==null&&r.push(u),r.join(" \xB7 ")}var Gxr="\x1B[48;2;114;47;55m",zxr="\x1B[48;2;88;36;42m",xpt="\x1B[49m",WC="\x1B[38;2;255;255;255m",Ept="\x1B[38;2;255;214;214m",bpt="\x1B[39m",jC="\x1B[38;2;224;138;148m",mM="\x1B[38;2;201;150;158m",Vxr="\x1B[38;2;96;214;128m",Yxr="\x1B[38;2;255;95;95m",Jxr="\x1B[38;2;240;200;120m",Spt="\x1B[1m",Cpt="\x1B[22m",wpt="\x1B[0m",Kxr=28,Zxr=" ",VY=["workerId","run","org","iss","phase","elapsed","loc","tks","tls","rsn","txt"],Xxr=["workerId","iss","phase","elapsed"],eEr=new Set(["requeue"]),tEr=new Set(["gate","push-pr","merge","cascade"]),rEr=e=>e.replace(/\x1b\[[0-9;]*m/g,"");function Ipt(e){return rEr(e).length}function nEr(e,t){return e+" ".repeat(Math.max(0,t-Ipt(e)))}var Wx=(e,t)=>`${Ept}${e}=${bpt}${t}${jC}`;function oEr(e,t){let r=[];return e&&e>0&&r.push(`+${e}`),t&&t>0&&r.push(`-${t}`),r.length?r.join(" "):null}function iEr(e){return e.runner==="claude"&&e.tokens===0?"\u2014":mpt(e.tokens)}function sEr(e,t=!0){let r="";if(e.branch){let o=e.branch.length>Kxr?`${e.branch.slice(0,27)}\u2026`:e.branch;r=` ${mM}(${o})${WC}`}else e.detachedSha&&(r=` ${mM}(detached ${e.detachedSha})${WC}`);let n=t&&e.version?` ${mM}v${e.version}${WC}`:"";return`${Jxr}\xBB${WC} ${Spt}${e.basename}${Cpt}${r}${n}`}function aEr(e){return!e||!e.model?null:e.effort?`${e.model}${mM}\xB7${WC}${e.effort}`:e.model}function Apt(e){if(!e||!e.contextTokens)return null;let t=zY(e.contextTokens),r=e.contextPercent===void 0?t:`${t} ${Math.round(e.contextPercent)}%`;return Wx("ctx",r)}function cEr(e){if(!e)return[];let t=[];return e.usage5h!==void 0&&t.push(Wx("5h",`${Math.round(e.usage5h)}%`)),e.usage7d!==void 0&&t.push(Wx("7d",`${Math.round(e.usage7d)}%`)),t}function uEr(e){if(!e)return[];let t=[],r=e.cacheAgeS!==void 0?` (${WR(e.cacheAgeS)})`:"";if(e.openPrs&&e.openPrs>0&&t.push(Wx("prs",String(e.openPrs))+r),e.todayPrs&&e.todayPrs>0){let n=r&&(!e.openPrs||e.openPrs===0)?r:"";t.push(Wx("cpr",String(e.todayPrs))+n)}if(e.openIssues&&e.openIssues>0){let n=r&&(!e.openPrs||e.openPrs===0)&&(!e.todayPrs||e.todayPrs===0)?r:"";t.push(Wx("iss",String(e.openIssues))+n)}return t}function lEr(e){if(!e)return[];let t=oEr(e.localAdded,e.localRemoved);return t?[Wx("loc",t)]:[]}function dEr(e){let t=_ye(e);return t?[t]:[]}function ypt(e){let t=GY(e);return!e||!t?[]:e.state==="ready"?[`${Vxr}${t}${jC}`]:e.state==="error"?[`${Yxr}${t}${jC}`]:[`${mM}${t}${jC}`]}function fEr(e,t,r,n,o="full",i){let s=`${zxr}${WC} ${sEr(e,o==="full")} `,a=aEr(t);o==="full"&&a!==null&&(s+=`${Gxr}${WC} ${a} `),s+=`${xpt}${jC}`;let c=o==="short"?[Apt(t),r&&r.openIssues&&r.openIssues>0?Wx("iss",String(r.openIssues))+(r.cacheAgeS!==void 0?` (${WR(r.cacheAgeS)})`:""):null,...ypt(i)].filter(u=>u!==null):[Apt(t),...cEr(t),...uEr(r),...lEr(r),...dEr(n),...ypt(i)].filter(u=>u!==null);return c.length&&(s+=` ${c.join(" ")}`),`${s}${wpt}`}function pEr(e,t){return[e,t].filter(Boolean).join("\xB7")}function mEr(e,t){let r=fft(e,t),n=[r.runner,r.model?hpt(r.model):void 0,r.effort].filter(s=>!!s).join(" "),o=tEr.has(r.phase),i=o||r.origin!==void 0&&eEr.has(r.origin);return{workerId:r.workerId,run:`run=${n}`,org:`org=${o?"landing":r.origin||"afk"}`,iss:r.issue===null?"":`iss=${String(r.issue)}`,phase:r.issue===null?"":pEr(r.phase,r.activity),elapsed:r.elapsed,loc:i?"":`loc=${dM(r.added,r.removed)}`,tks:i?"":`tks=${iEr(r)}`,tls:i?"":`tls=${String(r.tools)}`,rsn:i?"":`rsn=${String(r.reasoning)}`,txt:i?"":`txt=${String(r.text)}`}}function hEr(e,t=VY){let r=Object.fromEntries(VY.map(n=>[n,0]));for(let n of e)for(let o of t)r[o]=Math.max(r[o],Ipt(n[o]));return r}function gEr(e,t){if(e==="workerId")return`${Spt}${t}${Cpt}`;let r=t.indexOf("=");return r>0?`${Ept}${t.slice(0,r+1)}${bpt}${t.slice(r+1)}${jC}`:t}function AEr(e,t,r=VY){let n=r.map(o=>gEr(o,nEr(e[o],t[o])));return`${xpt}${jC}${n.join(Zxr)}${wpt}`}function yEr(e,t,r="full"){let n=e.map(s=>mEr(s,t)),o=r==="short"?Xxr:VY,i=hEr(n,o);return n.map(s=>AEr(s,i,o))}function xEr(e,t={}){let r=t.preset??"full",n=[fEr(e.project,e.claude,e.repo,e.fleet,r,e.rsp)],o=t.now??0;return n.push(...yEr(t.workers??[],o,r)),n.join(`
832
+ `),0}FC();function Oxr(e){let t=e.indexOf("--runner"),r=t>=0?e[t+1]:void 0;return r==="opencode"?"opencode":r==="claude"?"claude":"codex"}function Nxr(e){let t=JP(void 0,{runner:e});return JSON.stringify(e==="codex"||e==="opencode"?{systemMessage:t}:{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:t}})}async function lpt(e){let t=Oxr(e),r=JP(void 0,{runner:t});return process.stdout.write(e.includes("--hook")?Nxr(t):r),e.includes("--hook")&&process.stdout.write(`
833
+ `),0}import{existsSync as EEr,readFileSync as bEr,statSync as Bye}from"node:fs";import{join as vpt,basename as SEr}from"node:path";function jY(e){let t={app:e,version:Pxr(HR("__RED_BUILD_VERSION__",()=>"2.55.0")??"0.0.0-dev"),gitSha:HR("__RED_BUILD_GIT_SHA__",()=>"9dc21e6b45f4e6f32cc93f082906207fae603dcd")??"unknown",buildTime:HR("__RED_BUILD_TIME__",()=>"2026-07-13T19:53:04-03:00")??"unknown",bundleAsset:HR("__RED_BUNDLE_ASSET__",()=>"dev.bundle.min.mjs")??"unknown"},r=HR("__REDDB_SDK_VERSION__",()=>""),n=HR("__REDDB_BINARY_TAG__",()=>"");return r&&(t.reddbSdkVersion=r),n&&(t.reddbBinaryTag=n),t}function Pxr(e){return e.startsWith("v")?e.slice(1):e}function dpt(e){return`${e.app} ${e.version} ${e.gitSha}`}function HR(e,t){try{let r=t();return typeof r=="string"&&r.length>0?r:void 0}catch{return process.env[e.replace(/^__|__$/g,"")]}}function zY(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.floor(e/1e3)}k`:String(e)}function mpt(e){let t=(r,n)=>{let o=(Math.round(r*10)/10).toFixed(1);return`${o.endsWith(".0")?o.slice(0,-2):o}${n}`};return e>=1e9?t(e/1e9,"B"):e>=1e6?t(e/1e6,"M"):e>=1e3?t(e/1e3,"k"):String(e>0?e:0)}function qY(e){if(e>=100)return e.toFixed(0);if(e>=10)return e.toFixed(1);if(e>=1)return e.toFixed(2);let t=Math.max(2,Math.ceil(-Math.log10(e))+2);return e.toFixed(t)}function Mxr(e){let t=Number.isFinite(e)&&e>0?e:0;return t===0?"0":t>=1e9?`${qY(t/1e9)}B`:t>=1e6?`${qY(t/1e6)}M`:t>=1e3?`${qY(t/1e3)}k`:qY(t)}function Fxr(e){let t=Math.max(0,Math.floor(e));return t<1e3?String(t):t<1e6?`${(Math.floor(t/100)/10).toFixed(1)}k`:Mxr(t)}function hpt(e){let t=e.toLowerCase();for(let r of["opus","sonnet","haiku","fable"])if(t.includes(r))return r;return e}function Lxr(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let r=Math.floor(t/60);if(r<60)return`${r}m${t%60}s`;let n=Math.floor(r/60);return n<24?`${n}h${r%60}m`:`${Math.floor(n/24)}d${n%24}h`}function WR(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let r=Math.floor(t/60),n=t%60;return n>0?`${r}h${n}m`:`${r}h`}function fpt(e){let t=e.basename;if(e.branch){let r=e.branch;return r.length>28&&(r=`${r.slice(0,27)}\u2026`),`${t} (${r})`}return e.detachedSha?`${t} (detached ${e.detachedSha})`:t}function Uxr(e){return!e||!e.model?null:e.effort?`${e.model}\xB7${e.effort}`:e.model}function ppt(e){if(!e)return null;let t=e.contextTokens;if(t===void 0||t===0)return null;let r=zY(t);return e.contextPercent===void 0?r:`${r} ${Math.round(e.contextPercent)}%`}function $xr(e){if(!e||e.workers<=0)return[];let t=[],r=(i,s)=>{t.push({label:i,value:s,suffix:""})};if(e.workers>0&&r("wrk=",String(e.workers)),e.sourceCounts&&e.sourceCounts.length>0)for(let{origin:i,count:s}of e.sourceCounts)r(`${i}=`,String(s));let n=e.cacheAgeS!==void 0?` (${WR(e.cacheAgeS)})`:"";if(e.queue>0&&t.push({label:"rdy=",value:String(e.queue),suffix:n}),e.human>0){let i=n&&e.queue===0?n:"";t.push({label:"hmn=",value:String(e.human),suffix:i})}e.blocked>0&&r("blk=",String(e.blocked));let o=[];return e.added>0&&o.push(`+${e.added}`),e.removed>0&&o.push(`-${e.removed}`),o.length&&r("loc=",e.locIsPeak?`~${o.join(" ")}`:o.join(" ")),e.waiting!==void 0&&e.waiting>0&&r("wai=",String(e.waiting)),e.tokens!==void 0&&e.tokens>0&&r("tok=",zY(e.tokens)),e.costUsd!==void 0&&e.costUsd>0&&r("usd=",e.costUsd.toFixed(2)),e.issues.forEach((i,s)=>{let a=e.phases?.[s],c=e.aliveMs?.[s],u=a?`\xB7${a}`:"";c!==void 0&&c>0&&(u+=`\xB7${Lxr(c)}`),t.push({label:"#",value:String(i),suffix:u})}),t}function Hxr(e){if(!e)return null;let t=[];return e.usage5h!==void 0&&t.push(`5h=${Math.round(e.usage5h)}%`),e.usage7d!==void 0&&t.push(`7d=${Math.round(e.usage7d)}%`),t.length?t.join(" "):null}function Wxr(e){if(!e)return null;let t=[],r=e.cacheAgeS!==void 0?` (${WR(e.cacheAgeS)})`:"";if(e.openPrs&&e.openPrs>0&&t.push(`prs=${e.openPrs}${r}`),e.todayPrs&&e.todayPrs>0){let o=r&&(!e.openPrs||e.openPrs===0)?r:"";t.push(`cpr=${e.todayPrs}${o}`)}if(e.openIssues&&e.openIssues>0){let o=r&&(!e.openPrs||e.openPrs===0)&&(!e.todayPrs||e.todayPrs===0)?r:"";t.push(`iss=${e.openIssues}${o}`)}let n=[];return e.localAdded&&e.localAdded>0&&n.push(`+${e.localAdded}`),e.localRemoved&&e.localRemoved>0&&n.push(`-${e.localRemoved}`),n.length&&t.push(`loc=${n.join(" ")}`),t.length?t.join(" "):null}function jxr(e){if(!e||!e.openIssues||e.openIssues<=0)return null;let t=e.cacheAgeS!==void 0?` (${WR(e.cacheAgeS)})`:"";return`iss=${e.openIssues}${t}`}function _ye(e){if(!e)return null;let t=e.runner||"?",r=Math.max(0,Math.floor(e.busy)),n=Math.max(0,Math.floor(e.total)),o=Math.max(0,Math.floor(e.queue)),i=[`flt=${t} ${r}/${n} busy`,`q=${o}`];return e.parked!==void 0&&e.parked>0&&i.push(`park=${Math.floor(e.parked)}`),i.join(" \xB7 ")}function GY(e){return e?e.state==="ready"?`rsp=\u2193${Fxr(e.tokensSavedToday)}`:e.state==="warming"?"rsp=\u2026":"rsp=!":null}function qxr(e){let t=$xr(e);return t.length===0?null:t.map(r=>`${r.label}${r.value}${r.suffix}`).join(" ")}function gpt(e,t="full"){if(t==="short"){let l=[fpt(e.project)],d=ppt(e.claude);d!==null&&l.push(`ctx=${d}`);let f=jxr(e.repo);f!==null&&l.push(f);let p=GY(e.rsp);return p!==null&&l.push(p),l.join(" \xB7 ")}let r=[fpt(e.project)],n=Uxr(e.claude);n!==null&&r.push(n);let o=ppt(e.claude);o!==null&&r.push(o);let i=Hxr(e.claude);i!==null&&r.push(i);let s=Wxr(e.repo);s!==null&&r.push(s);let a=_ye(e.fleet);a!==null&&r.push(a);let c=GY(e.rsp);c!==null&&r.push(c);let u=qxr(e.afk);return u!==null&&r.push(u),r.join(" \xB7 ")}var Gxr="\x1B[48;2;114;47;55m",zxr="\x1B[48;2;88;36;42m",xpt="\x1B[49m",WC="\x1B[38;2;255;255;255m",Ept="\x1B[38;2;255;214;214m",bpt="\x1B[39m",jC="\x1B[38;2;224;138;148m",mM="\x1B[38;2;201;150;158m",Vxr="\x1B[38;2;96;214;128m",Yxr="\x1B[38;2;255;95;95m",Jxr="\x1B[38;2;240;200;120m",Spt="\x1B[1m",Cpt="\x1B[22m",wpt="\x1B[0m",Kxr=28,Zxr=" ",VY=["workerId","run","org","iss","phase","elapsed","loc","tks","tls","rsn","txt"],Xxr=["workerId","iss","phase","elapsed"],eEr=new Set(["requeue"]),tEr=new Set(["gate","push-pr","merge","cascade"]),rEr=e=>e.replace(/\x1b\[[0-9;]*m/g,"");function Ipt(e){return rEr(e).length}function nEr(e,t){return e+" ".repeat(Math.max(0,t-Ipt(e)))}var Wx=(e,t)=>`${Ept}${e}=${bpt}${t}${jC}`;function oEr(e,t){let r=[];return e&&e>0&&r.push(`+${e}`),t&&t>0&&r.push(`-${t}`),r.length?r.join(" "):null}function iEr(e){return e.runner==="claude"&&e.tokens===0?"\u2014":mpt(e.tokens)}function sEr(e,t=!0){let r="";if(e.branch){let o=e.branch.length>Kxr?`${e.branch.slice(0,27)}\u2026`:e.branch;r=` ${mM}(${o})${WC}`}else e.detachedSha&&(r=` ${mM}(detached ${e.detachedSha})${WC}`);let n=t&&e.version?` ${mM}v${e.version}${WC}`:"";return`${Jxr}\xBB${WC} ${Spt}${e.basename}${Cpt}${r}${n}`}function aEr(e){return!e||!e.model?null:e.effort?`${e.model}${mM}\xB7${WC}${e.effort}`:e.model}function Apt(e){if(!e||!e.contextTokens)return null;let t=zY(e.contextTokens),r=e.contextPercent===void 0?t:`${t} ${Math.round(e.contextPercent)}%`;return Wx("ctx",r)}function cEr(e){if(!e)return[];let t=[];return e.usage5h!==void 0&&t.push(Wx("5h",`${Math.round(e.usage5h)}%`)),e.usage7d!==void 0&&t.push(Wx("7d",`${Math.round(e.usage7d)}%`)),t}function uEr(e){if(!e)return[];let t=[],r=e.cacheAgeS!==void 0?` (${WR(e.cacheAgeS)})`:"";if(e.openPrs&&e.openPrs>0&&t.push(Wx("prs",String(e.openPrs))+r),e.todayPrs&&e.todayPrs>0){let n=r&&(!e.openPrs||e.openPrs===0)?r:"";t.push(Wx("cpr",String(e.todayPrs))+n)}if(e.openIssues&&e.openIssues>0){let n=r&&(!e.openPrs||e.openPrs===0)&&(!e.todayPrs||e.todayPrs===0)?r:"";t.push(Wx("iss",String(e.openIssues))+n)}return t}function lEr(e){if(!e)return[];let t=oEr(e.localAdded,e.localRemoved);return t?[Wx("loc",t)]:[]}function dEr(e){let t=_ye(e);return t?[t]:[]}function ypt(e){let t=GY(e);return!e||!t?[]:e.state==="ready"?[`${Vxr}${t}${jC}`]:e.state==="error"?[`${Yxr}${t}${jC}`]:[`${mM}${t}${jC}`]}function fEr(e,t,r,n,o="full",i){let s=`${zxr}${WC} ${sEr(e,o==="full")} `,a=aEr(t);o==="full"&&a!==null&&(s+=`${Gxr}${WC} ${a} `),s+=`${xpt}${jC}`;let c=o==="short"?[Apt(t),r&&r.openIssues&&r.openIssues>0?Wx("iss",String(r.openIssues))+(r.cacheAgeS!==void 0?` (${WR(r.cacheAgeS)})`:""):null,...ypt(i)].filter(u=>u!==null):[Apt(t),...cEr(t),...uEr(r),...lEr(r),...dEr(n),...ypt(i)].filter(u=>u!==null);return c.length&&(s+=` ${c.join(" ")}`),`${s}${wpt}`}function pEr(e,t){return[e,t].filter(Boolean).join("\xB7")}function mEr(e,t){let r=fft(e,t),n=[r.runner,r.model?hpt(r.model):void 0,r.effort].filter(s=>!!s).join(" "),o=tEr.has(r.phase),i=o||r.origin!==void 0&&eEr.has(r.origin);return{workerId:r.workerId,run:`run=${n}`,org:`org=${o?"landing":r.origin||"afk"}`,iss:r.issue===null?"":`iss=${String(r.issue)}`,phase:r.issue===null?"":pEr(r.phase,r.activity),elapsed:r.elapsed,loc:i?"":`loc=${dM(r.added,r.removed)}`,tks:i?"":`tks=${iEr(r)}`,tls:i?"":`tls=${String(r.tools)}`,rsn:i?"":`rsn=${String(r.reasoning)}`,txt:i?"":`txt=${String(r.text)}`}}function hEr(e,t=VY){let r=Object.fromEntries(VY.map(n=>[n,0]));for(let n of e)for(let o of t)r[o]=Math.max(r[o],Ipt(n[o]));return r}function gEr(e,t){if(e==="workerId")return`${Spt}${t}${Cpt}`;let r=t.indexOf("=");return r>0?`${Ept}${t.slice(0,r+1)}${bpt}${t.slice(r+1)}${jC}`:t}function AEr(e,t,r=VY){let n=r.map(o=>gEr(o,nEr(e[o],t[o])));return`${xpt}${jC}${n.join(Zxr)}${wpt}`}function yEr(e,t,r="full"){let n=e.map(s=>mEr(s,t)),o=r==="short"?Xxr:VY,i=hEr(n,o);return n.map(s=>AEr(s,i,o))}function xEr(e,t={}){let r=t.preset??"full",n=[fEr(e.project,e.claude,e.repo,e.fleet,r,e.rsp)],o=t.now??0;return n.push(...yEr(t.workers??[],o,r)),n.join(`
832
834
  `)}function kpt(e,t,r={}){let n=r.preset??"full";return t?xEr(e,r):gpt(e,n)}bo();LP();function CEr(e){return new Promise(t=>{if(e.isTTY){t("");return}let r="",n=!1,o=()=>{n||(n=!0,t(r))};e.setEncoding("utf8"),e.on("data",i=>{r+=i}),e.on("end",o),e.on("error",o),e.on("close",o)})}function wEr(e){if(!e.trim())return{};try{let t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{}}catch{return{}}}function IEr(e){try{return Bye(e).isDirectory()}catch{return!1}}function kEr(e,t,r){if(e&&IEr(e))return e;let n=t.workspace?.project_dir||t.workspace?.current_dir||t.cwd;return n||r}function vEr(e){let t=vpt(e,".red","config.yaml");if(!EEr(t))return!0;let r=Sr(t,{warn:()=>{}});return!(Pe(r,"statusline")==="false"||Pe(r,"afk.statusline")==="false")}function YY(e){return e==="full"||e==="short"?e:void 0}function REr(e){return YY(Pe(e,"plugins.dev.statusline.preset"))??YY(Pe(e,"dev.statusline.preset"))??YY(Pe(e,"afk.statusline.preset"))??YY(Pe(e,"statusline.preset"))??"full"}var _Er=15e3;function BEr(e){try{let t=JSON.parse(bEr(e,"utf8"));if(typeof t=="object"&&t!==null&&t.version===1&&typeof t.tokens_saved_today=="number"&&typeof t.updated_at=="string")return t}catch{}}function TEr(e,t,r){try{return t-Bye(e).mtimeMs<=r}catch{return!1}}function DEr(e){try{return Bye(e),!0}catch{return!1}}function Rpt(e){let t=Date.parse(e);if(Number.isFinite(t))return new Date(t).toISOString().slice(0,10)}function QEr(e,t){return Rpt(e.updated_at)!==new Date(t).toISOString().slice(0,10)?0:Math.max(0,Math.floor(e.tokens_saved_today))}function OEr(e,t){if(Rpt(e.updated_at)===new Date(t).toISOString().slice(0,10)&&typeof e.dollars_saved_today_usd=="number")return Math.max(0,e.dollars_saved_today_usd)}async function NEr(e,t=process.env){if(!DAe(e,t).enabled)return;let n=DR(e),o=Date.now(),i=BEr(n.summaryPath);if(i)return{state:"ready",tokensSavedToday:QEr(i,o),dollarsSavedTodayUsd:OEr(i,o)};if(TEr(n.wakeLockPath,o,_Er))return{state:"warming"};if(DEr(n.wakeLockPath))return{state:"error"}}async function PEr(e){let t={cwd:e},r=jY("dev").version,n={basename:SEr(e),version:r},o=await CP(t);if(o)return{...n,branch:o};let i=await yg(t);return i?{...n,detachedSha:i}:n}function MEr(e){let t=e.model?.display_name,r=e.effort?.level,n=e.context_window?.total_input_tokens,o=e.context_window?.used_percentage,i=e.rate_limits?.five_hour?.used_percentage,s=e.rate_limits?.seven_day?.used_percentage;if(!(t===void 0&&n===void 0&&i===void 0&&s===void 0))return{model:t||void 0,effort:r||void 0,contextTokens:n,contextPercent:o,usage5h:i,usage7d:s}}async function _pt(e,t=process.cwd(),r=process.stdout,n=process.stdin){if(e.includes("--legend"))return r.write(`${MY()}
833
835
  `),0;let o=e[0],i=await CEr(n),s=wEr(i),a=kEr(o,s,t);if(!vEr(a))return 0;let c=await PEr(a),u=MEr(s),l={root:a,repo:bR(a),remote:"origin"},d=Sr(vpt(a,".red","config.yaml"),{warn:()=>{}}),f=REr(d),p=$4(process.env,B=>Pe(d,B)),g=`origin/${await pf({issueBody:""},{readLockedBranch:()=>wg(Qx(a)),configLockedBranch:Pe(d,"dev.lock.branch"),configTrunk:Pe(d,"dev.trunk"),fetchIssueBody:async()=>{}})}`,[A,E,y,b,w]=await Promise.all([Zat(l,p,g),Yat(l,p).then(B=>B??void 0),Jat(l),Kat(l),NEr(a)]),I=!process.env.NO_COLOR,v=Number.parseInt(process.env.COLUMNS??"",10),k=Math.floor(Date.now()/1e3),R=kpt({project:c,claude:u,repo:A,fleet:y,afk:E,rsp:w},I,{columns:Number.isFinite(v)&&v>0?v:void 0,workers:b,now:k,preset:f});return r.write(`${R}
834
836
  `),0}async function Bpt(e,t=process.cwd()){let r=e[0]??t,n="",o="";for(let i=1;i<e.length;i+=1){let s=e[i];s==="--repo"?n=e[++i]??"":s==="--lock"&&(o=e[++i]??"")}return await Vat(r,n||bR(r),o||void 0),0}iw();import{spawn as qpt}from"node:child_process";import{existsSync as Dye,openSync as zpt,closeSync as GEr,writeFileSync as Vpt,writeSync as zEr,rmSync as Qye,renameSync as VEr}from"node:fs";import{join as qC}from"node:path";import{existsSync as FEr,readdirSync as hM,readFileSync as JY,statSync as Opt}from"node:fs";import{join as fs}from"node:path";nu();Kd();function LEr(e,t){return fs(e,`afk-supervisor-slot-${t}.log`)}function UEr(e){let t;try{t=JY(e,"utf8")}catch{return[]}let r=[],n=new Set;for(let o of t.split(`
@@ -837,8 +839,8 @@ requeued to ready-for-agent${e.activeBlocker?` (cleared active blocker: ${e.acti
837
839
  `)}function Mpt(e,t,r){let n=Tye(e,t);if(n===null)return null;let o=null,i="",s="",a,c=Dx(fs(n,"afk.state.json"));if(c!==null){let p=c.state.current.number;typeof p=="number"&&Number.isInteger(p)&&(o=p),i=c.state.worker_id,s=c.state.started_at,o!==null&&i.length>0&&(a=dct("afk",i,o,c.state.current.title)??void 0)}let u=0;if(s.length>0){let p=Math.floor(Date.parse(s)/1e3);Number.isFinite(p)&&p>0&&r>p&&(u=r-p)}let l=Qpt(fs(n,"handoff.md"),200),d=Qpt(fs(n,"afk.log"),50),f=Xd(n)?.attempt??1;return{path:n,issue:o,workerId:i,branch:a,logTail:d,notes:l,durationS:u,attempt:f}}function Fpt(e,t,r=null){let n=fs(e,"afk-supervisor.log"),o=UEr(LEr(e,t));if(o.length>0)return{workers:o.map(u=>({workerId:u,pairs:Tpt(e,u).map(l=>({dir:l,issue:Dpt(l)}))})),supervisorLogPath:n};let i=Tye(e,r);if(i===null)return{workers:[],supervisorLogPath:n};let s=Xd(i);if(s===null)return{workers:[],supervisorLogPath:n};let a=Tpt(e,s.worker).map(c=>({dir:c,issue:Dpt(c)}));return{workers:[{workerId:s.worker,pairs:a}],supervisorLogPath:n}}async function Lpt(e,t){let r=await import("node:fs/promises"),n=fs(e.path,"worktree");if(FEr(n))try{let{git:o}=await Promise.resolve().then(()=>(bn(),hg)),i=await o(["-C",n,"rev-parse","--abbrev-ref","HEAD"]),s=i.code===0?i.stdout.trim():"";if(s&&s!=="HEAD"&&s.startsWith("afk/")){let a=await o(["-C",n,"rev-list","--count",`origin/${s}..${s}`]),c=a.code===0?parseInt(a.stdout.trim(),10):NaN;if(!Number.isNaN(c)&&c>0){let u=await o(["-C",n,"push","--force","origin",`HEAD:refs/heads/${s}`]);u.code!==0&&process.stderr.write(`[afk teardown] WARN: ${c} commit(s) on ${s} could not be pushed \u2014 they survive in the local branch ref until a manual push or git gc.
838
840
  push stderr: ${u.stderr.trim()}
839
841
  `)}}await o(["-C",t,"worktree","remove","--force",n])}catch{}try{await r.rm(e.path,{recursive:!0,force:!0})}catch{}}ru();tf();import{watch as $Er}from"node:fs";var HEr="afk.state.json";function Upt(e){return{waitForEvent(t){return new Promise(r=>{if(t.aborted){r();return}let n,o=!1,i=()=>{if(!o){o=!0,t.removeEventListener("abort",i);try{n?.close()}catch{}r()}};t.addEventListener("abort",i,{once:!0});try{n=$Er(e,{recursive:!0,persistent:!1},(s,a)=>{a&&a.toString().endsWith(HEr)&&i()}),n.on("error",()=>i())}catch{}})}}}import{existsSync as WEr,readdirSync as jEr}from"node:fs";var $pt=["pre_fleet","post_fleet","on_slot_spawn","on_slot_death","on_circuit_trip","on_stall_detected","on_stall_reap","on_respawn"],akn=new Set($pt);var Hpt={pre_fleet:"abort",post_fleet:"continue",on_slot_spawn:"continue",on_slot_death:"continue",on_circuit_trip:"continue",on_stall_detected:"continue",on_stall_reap:"continue",on_respawn:"continue"};function Wpt(e){let{libraryHooksDir:t,projectHooksDir:r}=e,n=e.listFiles??(s=>jEr(s)),o=e.dirExists??WEr,i={};for(let s of $pt)i[s]=fAe(s,t,r,n,o);return i}function qEr(e,t){let r={...e};return r.RED_AFK_FLEET_EVENT=t.event,r.RED_AFK_RUNNER=t.runner,t.slot!==void 0&&(r.RED_AFK_FLEET_SLOT=String(t.slot)),t.pid!==void 0&&t.pid>0&&(r.RED_AFK_FLEET_PID=String(t.pid)),t.worker_ids!==void 0&&t.worker_ids.length>0&&(r.RED_AFK_FLEET_WORKER_IDS=t.worker_ids),t.death_count!==void 0&&(r.RED_AFK_FLEET_DEATH_COUNT=String(t.death_count)),t.idle_seconds!==void 0&&(r.RED_AFK_FLEET_IDLE_SECONDS=String(t.idle_seconds)),t.stall_since!==void 0&&t.stall_since>0&&(r.RED_AFK_FLEET_STALL_SINCE=String(t.stall_since)),t.supervisor_log!==void 0&&t.supervisor_log.length>0&&(r.RED_AFK_FLEET_SUPERVISOR_LOG=t.supervisor_log),r}async function jpt(e,t,r,n,o={}){let i=qEr(o.env??{},r),s=o.log??(()=>{}),a=Hpt[e],c=JSON.stringify(r),u=[];for(let l of t){if(l.length===0)continue;s(`[afk:fleet-hooks] ${e}: enter: ${l}`);let{code:d}=await n(l,i,c);if(u.push({name:e,command:l,rc:d}),s(`[afk:fleet-hooks] ${e}: exit rc=${d}: ${l}`),d!==0){if(e==="on_stall_reap")return s(`[afk:fleet-hooks] ${e}: hook vetoed the reap (rc=${d}): ${l}`),{aborted:!1,vetoed:!0,executions:u};if(a==="abort")return s(`[afk:fleet-hooks] ${e}: command failed (rc=${d}): ${l}`),{aborted:!0,vetoed:!1,executions:u};s(`[afk:fleet-hooks] ${e}: command failed (rc=${d}), continuing: ${l}`)}}return{aborted:!1,vetoed:!1,executions:u}}bo();function Oye(e){try{return process.kill(e,0),!0}catch{return!1}}function YEr(e){return`fleet tick ready=${e.readyForAgent} busy=${e.slotsBusy} free=${e.slotsFree} spawns=${e.spawnsThisTick}`}function JEr(e){return JSON.stringify({ts:e.ts,epoch:e.epoch,last_progress_epoch:e.lastProgressEpoch>0?e.lastProgressEpoch:void 0,runner:e.runner,ready_for_agent:e.readyForAgent,slots:{busy:e.slotsBusy,free:e.slotsFree,total:e.slotsTotal,parked:e.slotsParked},spawns_this_tick:e.spawnsThisTick,...e.drainBudget?{drain_budget:{tier:e.drainBudget.tier,spent_usd:Number(e.drainBudget.spentUsd.toFixed(4)),limit_usd:Number(e.drainBudget.limitUsd.toFixed(4)),percent:Number((e.drainBudget.percent*100).toFixed(2))}}:{}},null,2)}function KEr(e,t){let r=`${e}.tmp`;Vpt(r,JEr(t),"utf8"),VEr(r,e)}var ZEr=["RED_AFK_TARGET","RED_AFK_REQUEST","RED_AFK_RUNNER","RED_AFK_SWEEPS_DONE","RED_AFK_POLL_S","RED_AFK_STALL_POLL_S","RED_AFK_STALL_THRESHOLD_S","RED_AFK_STALL_KILL_THRESHOLD_S","RED_AFK_CIRCUIT_K","RED_AFK_CIRCUIT_WINDOW_S","RED_AFK_PLUGIN_DIR","RED_AFK_SLOT","RED_AFK_WORKER_ID","RED_AFK_EXIT_CODE","RED_AFK_DURATION_S","RED_AFK_TASK_TIER_DOWNGRADE"];function XEr(e,t){let r=new Set(ZEr),n={};for(let[o,i]of Object.entries(e))i!==void 0&&(o.startsWith("RED_AFK_")&&(r.has(o)||o.endsWith("_BASE"))||(n[o]=i));return n.RED_AFK_RUNNER=t,n.RED_AFK_SWEEPS_DONE="1",n}function Gpt(e,t,r={}){let n={...e,RED_AFK_SLOT:String(t)};return r.taskTierDowngrade?n.RED_AFK_TASK_TIER_DOWNGRADE="1":delete n.RED_AFK_TASK_TIER_DOWNGRADE,n}function ebr(e){let t=[],r=new Map([["--spec","--spec"],["--issues","--issues"],["--request","--request"],["-r","--request"]]),n=new Set(["--alternate","--fallback-runner"]);for(let o=0;o<e.length;o+=1){let i=e[o],s=i.indexOf("=");if(s>0){let c=i.slice(0,s),u=r.get(c);if(u){t.push(u,i.slice(s+1));continue}}let a=r.get(i);if(a){let c=e[o+1];c!==void 0&&(t.push(a,c),o+=1);continue}if(n.has(i)){t.push(i);continue}}return t}function tbr(e){if(!e.precheck.ok)return`boot sweeps: precheck FAILED (${e.precheck.failed}) \u2014 workers will run their own precheck`;let t=e.orphanCleanup,r=e.attemptCap,n=e.branchCleanup,o=e.unblockSweep,i=e.straggler;return`boot sweeps complete: orphans removed=${t?.removed.length??0} restored=${t?.restored.length??0} kept=${t?.kept.length??0} | attempt-cap reclaimed=${r?.reclaimed.length??0} | branches snapshot=${n?.snapshotReaped.length??0} remote=${n?.remoteLiveReaped.length??0} local=${n?.localLiveReaped.length??0} | unblocked=${o?.promoted.length??0} | stragglers unlabeled=${i?.counts.unlabeled??0} triage=${i?.counts.needsTriage??0} info=${i?.counts.needsInfo??0}`}function rbr(e,t,r){let n={root:e,repo:t,remote:"origin"},o=Mr(e);return async()=>{let i=Math.floor(Date.now()/1e3),s=await q4(n),a={tmpDir:o.tmpDir,stateDir:o.stateDir,gitignorePath:o.gitignorePath,workerDir:o.tmpDir,workerPidFile:qC(o.tmpDir,"afk-supervisor-boot.pid"),workerPid:process.pid},c=await j4(n,s,a,i),u=await G4(n,c,i),l=await iY(u,c);r(tbr(l))}}function nbr(e,t,r,n,o,i,s,a,c){let u=process.argv[1],l=()=>Math.floor(Date.now()/1e3),d=y=>{try{zEr(r,`[${new Date().toISOString()}] ${y}
840
- `)}catch{}},f=oM(e),p=Wpt({libraryHooksDir:f.libraryHooksDir,projectHooksDir:f.projectHooksDir}),m=nM(e,f.libraryHooksDir),g=new Map,A=new Map,E=XEr(process.env,i);return{proc:{spawnSlot:async(y,b)=>{let w=["run","--once","--runner",i,...a],I=qC(t,`afk-supervisor-slot-${y}.log`),v=zpt(I,"a"),k=qpt(process.execPath,[u,...w],{cwd:e,env:Gpt(E,y,b),detached:!0,stdio:["ignore",v,v]});GEr(v),k.on("exit",B=>{A.set(y,B??1)}),k.unref();let R=k.pid??0;return g.set(y,R),{pid:R,spawnEpoch:l()}},spawnReconcileWorker:async(y,b)=>{let w=["run","--once","--runner",i,"--reconcile-issue",String(b.issue),...a],I=qpt(process.execPath,[u,...w],{cwd:e,env:Gpt(E,y),detached:!0,stdio:["ignore",r,r]});I.on("exit",k=>{A.set(y,k??1)}),I.unref();let v=I.pid??0;return g.set(y,v),{pid:v,spawnEpoch:l()}},lastExitCode:y=>A.get(y)??null,isAlive:Oye,killTree:y=>Cg(y),inspectTree:y=>p4(y),sleep:y=>new Promise(b=>setTimeout(b,y))},fs:{workerLivenessVerdict:(y,b)=>Ppt(t,g.get(y)??null,b),resolveIterDir:y=>Mpt(t,g.get(y)??null,l()),teardownIterDir:async y=>{await Lpt(y,e)},parkedSlotWork:(y,b)=>Fpt(t,y,b),removeDir:async y=>{try{await ds(y)}catch{}},fleetCostUsd:()=>Npt(t)},gh:{comment:async(y,b)=>{try{await ri(s,y,b)}catch{}},editLabels:async(y,b,w)=>{try{await xa(s,y,w,b)}catch{}},ensureRunnerErrorLabel:async()=>{try{await Dst(s)}catch{}},ensureLabel:async y=>{try{await wl(s,y)}catch{}},readyQueueDepth:async()=>{try{return await w4(s)}catch{return 0}},findReconcileCandidate:async()=>{try{let[y,b]=await Promise.all([k4(s),Kp({cwd:e},"afk/")]),w=b.map(k=>k.branch),I=oY(y,w);if(I.length===0)return null;let v=I[0];return{issue:v.number,branch:v.branch}}catch{return null}},crashedClaimState:async y=>{try{return await Nst(s,y)}catch{return{ghOk:!1,stillRunning:!1,envelopePosted:!1}}}},now:l,wake:Upt(qC(t,"workers")),recoveryEnv:process.env,log:d,bootSweeps:rbr(e,s.repo,d),unblockSweep:async()=>{try{let y=await I4(s);return y.length===0?[]:await nY(y,b=>bge(s,b),{editLabels:async(b,w,I)=>{await xa(s,b,w,I)},comment:async(b,w)=>{await ri(s,b,w)},issueReference:b=>gg(s,b)})}catch{return[]}},attemptBranchHead:y=>Yp({cwd:e},y),dispatchFleetHook:async(y,b)=>{let w=p[y];return jpt(y,w,b,m,{env:c,log:d})},emitFleetHeartbeat:async y=>{try{KEr(o,y)}catch{}try{await Nx(n,"heartbeat",YEr(y),{ts:y.ts,fields:{worker:"fleet",extra:{scope:"fleet",runner:y.runner,ready_for_agent:String(y.readyForAgent),slots_busy:String(y.slotsBusy),slots_free:String(y.slotsFree),slots_total:String(y.slotsTotal),slots_parked:String(y.slotsParked),spawns_this_tick:String(y.spawnsThisTick),...y.drainBudget?{drain_budget_tier:y.drainBudget.tier,drain_budget_spent_usd:y.drainBudget.spentUsd.toFixed(4),drain_budget_limit_usd:y.drainBudget.limitUsd.toFixed(4),drain_budget_percent:(y.drainBudget.percent*100).toFixed(2)}:{}}}})}catch{}}}}async function Ypt(e,t=process.cwd()){let r=t,n=Mr(r),o=n.tmpDir,i=qC(o,"afk-supervisor.pid"),s=qC(o,"afk-supervisor.stop"),a=qC(o,"afk-supervisor.log"),c=n.fleetFirehosePath,u=n.fleetStatePath;if(await Promise.resolve().then(()=>(tf(),PP)).then(w=>w.ensureDir(o)),await Promise.resolve().then(()=>(tf(),PP)).then(w=>w.ensureDir(qC(o,"workers"))),await $P(o,Oye),Dye(i))try{let w=Number(Y("node:fs").readFileSync(i,"utf8").trim());if(w&&Oye(w))return process.stderr.write(`supervisor already running (pid=${w})
841
- `),1}catch{}Vpt(i,String(process.pid),"utf8"),Dye(s)&&Qye(s,{force:!0});let l=zpt(a,"a"),d=Sr(n.configPath,{warn:()=>{}}),f=ow(process.env,w=>Pe(d,w)),p=vxe(f.target),m=await TC(r).catch(()=>""),g={cwd:r,repo:m},A=ebr(e),E={RED_AFK_ROOT:r,RED_AFK_WORKSPACE:r,RED_AFK_RUNNER:f.runner,...m.length>0?{RED_AFK_REPO:m}:{}},y=nbr(r,o,l,c,u,f.runner,g,A,E),b=()=>Dye(s);try{await Dxe(p,y,f,b)}finally{Qye(i,{force:!0}),Qye(s,{force:!0})}return 0}un();var KY=["ready-for-agent","needs-info","ready-for-human","wontfix"];function Jpt(e){return KY.includes(e)}function Kpt(e){switch(e){case"ready-for-agent":return{remove:[qR],add:[Je],close:!1};case"needs-info":return{remove:[qR],add:[nxe],close:!1};case"ready-for-human":return{remove:[qR],add:[rt],close:!1};case"wontfix":return{remove:[qR],add:[oxe],close:!0}}}function Zpt(e,t){if(!e.enabled)return!0;let r=(t??"").trim();return r.length>0&&e.allowlist.includes(r)}function Xpt(e,t){return!e.enabled||t.authorTrusted||t.summoned?"auto-triage":"hold-for-summon"}un();PC();bo();ru();FC();var obr="> *This was generated by AI during triage.*";async function ibr(e,t,r){let n=await Wst(e,r.issue),o=await wC(e,r.issue),i=r.summon||o.includes(GR),s=Zpt(t,n),a=Xpt(t,{authorTrusted:s,summoned:i});if(a==="hold-for-summon")return{issue:r.issue,action:a,author:n,reason:`untrusted author ${n?`'${n}'`:"(unknown)"} \u2014 held for a maintainer summon (\`dev triage --summon\` or the \`${GR}\` label)`};let c=Kpt(r.decision),u=o.includes(GR)?[...c.remove,GR]:c.remove;for(let l of c.add)await wl(e,l);return await xa(e,r.issue,u,c.add),await ri(e,r.issue,`${obr}
842
+ `)}catch{}},f=oM(e),p=Wpt({libraryHooksDir:f.libraryHooksDir,projectHooksDir:f.projectHooksDir}),m=nM(e,f.libraryHooksDir),g=new Map,A=new Map,E=XEr(process.env,i);return{proc:{spawnSlot:async(y,b)=>{let w=["run","--once","--runner",i,...a],I=qC(t,`afk-supervisor-slot-${y}.log`),v=zpt(I,"a"),k=qpt(process.execPath,[u,...w],{cwd:e,env:Gpt(E,y,b),detached:!0,stdio:["ignore",v,v]});GEr(v),k.on("exit",B=>{A.set(y,B??1)}),k.unref();let R=k.pid??0;return g.set(y,R),{pid:R,spawnEpoch:l()}},spawnReconcileWorker:async(y,b)=>{let w=["run","--once","--runner",i,"--reconcile-issue",String(b.issue),...a],I=qpt(process.execPath,[u,...w],{cwd:e,env:Gpt(E,y),detached:!0,stdio:["ignore",r,r]});I.on("exit",k=>{A.set(y,k??1)}),I.unref();let v=I.pid??0;return g.set(y,v),{pid:v,spawnEpoch:l()}},lastExitCode:y=>A.get(y)??null,isAlive:Oye,killTree:y=>Cg(y),inspectTree:y=>p4(y),sleep:y=>new Promise(b=>setTimeout(b,y))},fs:{workerLivenessVerdict:(y,b)=>Ppt(t,g.get(y)??null,b),resolveIterDir:y=>Mpt(t,g.get(y)??null,l()),teardownIterDir:async y=>{await Lpt(y,e)},parkedSlotWork:(y,b)=>Fpt(t,y,b),removeDir:async y=>{try{await ds(y)}catch{}},fleetCostUsd:()=>Npt(t)},gh:{comment:async(y,b)=>{try{await ni(s,y,b)}catch{}},editLabels:async(y,b,w)=>{try{await xa(s,y,w,b)}catch{}},ensureRunnerErrorLabel:async()=>{try{await Dst(s)}catch{}},ensureLabel:async y=>{try{await wl(s,y)}catch{}},readyQueueDepth:async()=>{try{return await w4(s)}catch{return 0}},findReconcileCandidate:async()=>{try{let[y,b]=await Promise.all([k4(s),Kp({cwd:e},"afk/")]),w=b.map(k=>k.branch),I=oY(y,w);if(I.length===0)return null;let v=I[0];return{issue:v.number,branch:v.branch}}catch{return null}},crashedClaimState:async y=>{try{return await Nst(s,y)}catch{return{ghOk:!1,stillRunning:!1,envelopePosted:!1}}}},now:l,wake:Upt(qC(t,"workers")),recoveryEnv:process.env,log:d,bootSweeps:rbr(e,s.repo,d),unblockSweep:async()=>{try{let y=await I4(s);return y.length===0?[]:await nY(y,b=>bge(s,b),{editLabels:async(b,w,I)=>{await xa(s,b,w,I)},comment:async(b,w)=>{await ni(s,b,w)},issueReference:b=>gg(s,b)})}catch{return[]}},attemptBranchHead:y=>Yp({cwd:e},y),dispatchFleetHook:async(y,b)=>{let w=p[y];return jpt(y,w,b,m,{env:c,log:d})},emitFleetHeartbeat:async y=>{try{KEr(o,y)}catch{}try{await Nx(n,"heartbeat",YEr(y),{ts:y.ts,fields:{worker:"fleet",extra:{scope:"fleet",runner:y.runner,ready_for_agent:String(y.readyForAgent),slots_busy:String(y.slotsBusy),slots_free:String(y.slotsFree),slots_total:String(y.slotsTotal),slots_parked:String(y.slotsParked),spawns_this_tick:String(y.spawnsThisTick),...y.drainBudget?{drain_budget_tier:y.drainBudget.tier,drain_budget_spent_usd:y.drainBudget.spentUsd.toFixed(4),drain_budget_limit_usd:y.drainBudget.limitUsd.toFixed(4),drain_budget_percent:(y.drainBudget.percent*100).toFixed(2)}:{}}}})}catch{}}}}async function Ypt(e,t=process.cwd()){let r=t,n=Mr(r),o=n.tmpDir,i=qC(o,"afk-supervisor.pid"),s=qC(o,"afk-supervisor.stop"),a=qC(o,"afk-supervisor.log"),c=n.fleetFirehosePath,u=n.fleetStatePath;if(await Promise.resolve().then(()=>(tf(),PP)).then(w=>w.ensureDir(o)),await Promise.resolve().then(()=>(tf(),PP)).then(w=>w.ensureDir(qC(o,"workers"))),await $P(o,Oye),Dye(i))try{let w=Number(Y("node:fs").readFileSync(i,"utf8").trim());if(w&&Oye(w))return process.stderr.write(`supervisor already running (pid=${w})
843
+ `),1}catch{}Vpt(i,String(process.pid),"utf8"),Dye(s)&&Qye(s,{force:!0});let l=zpt(a,"a"),d=Sr(n.configPath,{warn:()=>{}}),f=ow(process.env,w=>Pe(d,w)),p=vxe(f.target),m=await TC(r).catch(()=>""),g={cwd:r,repo:m},A=ebr(e),E={RED_AFK_ROOT:r,RED_AFK_WORKSPACE:r,RED_AFK_RUNNER:f.runner,...m.length>0?{RED_AFK_REPO:m}:{}},y=nbr(r,o,l,c,u,f.runner,g,A,E),b=()=>Dye(s);try{await Dxe(p,y,f,b)}finally{Qye(i,{force:!0}),Qye(s,{force:!0})}return 0}un();var KY=["ready-for-agent","needs-info","ready-for-human","wontfix"];function Jpt(e){return KY.includes(e)}function Kpt(e){switch(e){case"ready-for-agent":return{remove:[qR],add:[Je],close:!1};case"needs-info":return{remove:[qR],add:[nxe],close:!1};case"ready-for-human":return{remove:[qR],add:[rt],close:!1};case"wontfix":return{remove:[qR],add:[oxe],close:!0}}}function Zpt(e,t){if(!e.enabled)return!0;let r=(t??"").trim();return r.length>0&&e.allowlist.includes(r)}function Xpt(e,t){return!e.enabled||t.authorTrusted||t.summoned?"auto-triage":"hold-for-summon"}un();PC();bo();ru();FC();var obr="> *This was generated by AI during triage.*";async function ibr(e,t,r){let n=await Wst(e,r.issue),o=await wC(e,r.issue),i=r.summon||o.includes(GR),s=Zpt(t,n),a=Xpt(t,{authorTrusted:s,summoned:i});if(a==="hold-for-summon")return{issue:r.issue,action:a,author:n,reason:`untrusted author ${n?`'${n}'`:"(unknown)"} \u2014 held for a maintainer summon (\`dev triage --summon\` or the \`${GR}\` label)`};let c=Kpt(r.decision),u=o.includes(GR)?[...c.remove,GR]:c.remove;for(let l of c.add)await wl(e,l);return await xa(e,r.issue,u,c.add),await ni(e,r.issue,`${obr}
842
844
 
843
845
  \u{1F916} \`dev triage\`: ${r.decision}`+(i&&!s?" (released by maintainer summon)":"")+"."),c.close&&await Tx(e,r.issue),{issue:r.issue,action:a,author:n,applied:{decision:r.decision,transition:c}}}function sbr(e){let t,r,n=!1,o,i=!1,s=(a,c)=>{if(a===void 0)throw new Error(`${c} requires a value`);if(!Jpt(a))throw new Error(`${c}: '${a}' is not a triage decision (${KY.join(" | ")})`);return a};for(let a=0;a<e.length;a+=1){let c=e[a];if(c==="--summon"){n=!0;continue}if(c==="--json"){i=!0;continue}if(c==="--decision"){r=s(e[++a],"--decision");continue}if(c.startsWith("--decision=")){r=s(c.slice(11),"--decision");continue}if(c==="--repo"||c==="-R"){let l=e[++a];if(l===void 0)throw new Error(`${c} requires a value`);o=l;continue}if(c.startsWith("--repo=")){o=c.slice(7);continue}if(c.startsWith("-"))throw new Error(`unknown flag: ${c}`);let u=Number(c.replace(/^#/,""));if(!Number.isInteger(u)||u<=0)throw new Error(`invalid issue number: ${c}`);t=u}if(t===void 0)throw new Error("usage: dev triage <issue> --decision <state> [--summon]");if(r===void 0)throw new Error(`--decision is required (${KY.join(" | ")})`);return{issue:t,decision:r,summon:n,repo:o,json:i}}async function emt(e,t=process.cwd(),r=process.stdout){let n;try{n=sbr(e)}catch(u){return r.write(`[triage] ${u instanceof Error?u.message:String(u)}
844
846
  `),2}let o=Sr(sf(t),{warn:()=>{}}),i=Tl(o),s=n.repo??(await Ns(t)).repo,c=await ibr({cwd:t,repo:s},i,{issue:n.issue,decision:n.decision,summon:n.summon});return n.json?(r.write(`${JSON.stringify(c)}