@reason-machines/cli-linux-x64 0.2.541 → 0.2.544

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/bin/reason +1 -1
  2. package/bin/vm-hands/{api-credentials-x83hr1kq.js → api-credentials-xcnq8kkg.js} +1 -1
  3. package/bin/vm-hands/{api-75h5hd18.js → api-xhc0tntd.js} +1 -1
  4. package/bin/vm-hands/connect-cli-98zcpbp7.js +2 -0
  5. package/bin/vm-hands/{custom-endpoint-device-7tgcmhbz.js → custom-endpoint-device-rrzyx1tx.js} +1 -1
  6. package/bin/vm-hands/local-automation-ss891qsd.js +2 -0
  7. package/bin/vm-hands/{local-capabilities-c10vhc0p.js → local-capabilities-wztc4g5f.js} +1 -1
  8. package/bin/vm-hands/{local-display-session-fr5dn62y.js → local-display-session-pdcjqrbs.js} +1 -1
  9. package/bin/vm-hands/local-display-video-7gcdsqmz.js +2 -0
  10. package/bin/vm-hands/{local-managed-process-w4ys9j24.js → local-managed-process-n8t2zfhm.js} +1 -1
  11. package/bin/vm-hands/{local-pty-session-tnz6jwtt.js → local-pty-session-92d5hy1c.js} +1 -1
  12. package/bin/vm-hands/{managed-runtime-cmw13n0g.js → managed-runtime-vxj5cv3w.js} +1 -1
  13. package/bin/vm-hands/{network-contract-e98v6mwd.js → network-contract-dp38yj78.js} +1 -1
  14. package/bin/vm-hands/{permissions-bc4hvcrw.js → permissions-afcgrd5x.js} +1 -1
  15. package/bin/vm-hands/{serve-service-kw8y72ks.js → serve-service-v0tpfr5x.js} +1 -1
  16. package/bin/vm-hands/{status-bhhr39ts.js → status-y0mkm1dt.js} +2 -2
  17. package/bin/vm-hands/version-d3b19nf7.js +2 -0
  18. package/bin/vm-hands/{vm-hands-entry-lite-xtt68ger.js → vm-hands-entry-lite-4wz1jsvh.js} +3 -3
  19. package/bin/vm-hands/{vm-hands-entry-lite-xy25e60x.js → vm-hands-entry-lite-b4brjgqm.js} +1 -1
  20. package/bin/vm-hands/{vm-hands-entry-lite-9y350dzx.js → vm-hands-entry-lite-besphapx.js} +1 -1
  21. package/bin/vm-hands/{vm-hands-entry-lite-5710nt7x.js → vm-hands-entry-lite-bn14pnz1.js} +1 -1
  22. package/bin/vm-hands/{vm-hands-entry-lite-ztsp4gs8.js → vm-hands-entry-lite-dszmx6yf.js} +1 -1
  23. package/bin/vm-hands/vm-hands-entry-lite-fmghv8b1.js +2 -0
  24. package/bin/vm-hands/{vm-hands-entry-lite-mc8j8dj2.js → vm-hands-entry-lite-h43y7nth.js} +1 -1
  25. package/bin/vm-hands/{vm-hands-entry-lite-hksjmf2k.js → vm-hands-entry-lite-h8vsnvme.js} +1 -1
  26. package/bin/vm-hands/{vm-hands-entry-lite-j5t2pj4v.js → vm-hands-entry-lite-hhk4h552.js} +1 -1
  27. package/bin/vm-hands/{vm-hands-entry-lite-ph90e13p.js → vm-hands-entry-lite-j0k3d751.js} +4 -4
  28. package/bin/vm-hands/{vm-hands-entry-lite-8bwgar3k.js → vm-hands-entry-lite-nfa3h3kf.js} +1 -1
  29. package/bin/vm-hands/{vm-hands-entry-lite-qc6gxqgs.js → vm-hands-entry-lite-nxd394w3.js} +5 -5
  30. package/bin/vm-hands/vm-hands-entry-lite-rw4v5k74.js +3 -0
  31. package/bin/vm-hands/{vm-hands-entry-lite-6f759623.js → vm-hands-entry-lite-s3bhann1.js} +1 -1
  32. package/bin/vm-hands/{vm-hands-entry-lite-z790r7k4.js → vm-hands-entry-lite-s4t51trq.js} +1 -1
  33. package/bin/vm-hands/{vm-hands-entry-lite-aefx54pr.js → vm-hands-entry-lite-tkj4q5pq.js} +1 -1
  34. package/bin/vm-hands/{vm-hands-entry-lite-qew9bjge.js → vm-hands-entry-lite-var43tsz.js} +5 -5
  35. package/bin/vm-hands/{vm-hands-entry-lite-411a6dt4.js → vm-hands-entry-lite-ve1pndrs.js} +1 -1
  36. package/bin/vm-hands/{vm-hands-entry-lite-cgddp0y3.js → vm-hands-entry-lite-vj0gm694.js} +1 -1
  37. package/bin/vm-hands/{vm-hands-entry-lite-37b5045h.js → vm-hands-entry-lite-xv7tgef8.js} +1 -1
  38. package/bin/vm-hands/{vm-hands-entry-lite-79f3h259.js → vm-hands-entry-lite-zhf20g7y.js} +1 -1
  39. package/bin/vm-hands/vm-hands-entry-lite.js +2 -2
  40. package/bin/vm-hands/{vm-hands-executor-vztves7f.js → vm-hands-executor-p8qbck9b.js} +1 -1
  41. package/bin/vm-hands/{vm-hands-op-runner-8a3q5gks.js → vm-hands-op-runner-hteap8kk.js} +1 -1
  42. package/bin/vm-hands/{vm-hands-runtime-k614z3e4.js → vm-hands-runtime-4aftkbtv.js} +3 -3
  43. package/package.json +1 -1
  44. package/bin/vm-hands/connect-cli-nxm79ypx.js +0 -2
  45. package/bin/vm-hands/local-automation-fkg30r92.js +0 -2
  46. package/bin/vm-hands/local-display-video-1yeyrkvb.js +0 -2
  47. package/bin/vm-hands/version-f185g65g.js +0 -2
  48. package/bin/vm-hands/vm-hands-entry-lite-rjsr6mmk.js +0 -2
  49. package/bin/vm-hands/vm-hands-entry-lite-tqx566rz.js +0 -3
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ge,pt}from"./vm-hands-entry-lite-k9vk84wa.js";import{Qe}from"./vm-hands-entry-lite-rjsr6mmk.js";import{$o,le,Kr,gt,Mo}from"./vm-hands-entry-lite-mc8j8dj2.js";import{E}from"./vm-hands-entry-lite-72nj66ab.js";import{a,nr}from"./vm-hands-entry-lite-jvszqt0z.js";import{spawnSync as H}from"child_process";import{dirname as w}from"path";import{spawn as A}from"child_process";import{accessSync as _,constants as v}from"fs";import{basename as C,join as O}from"path";var l=null;function S(e){if(l===e)l=null;if(e.exitCode===null&&e.signalCode===null)e.kill("SIGTERM")}var Ir=(e,t)=>{if(l)S(l);let s=O(e,$o);try{_(s,v.X_OK)}catch{return()=>{}}let n;try{n=A(s,["--app",e,"--name",C(e,".app"),"--permission",t==="screen"?"screen_recording":"accessibility"],{detached:!0,stdio:"ignore"})}catch{return()=>{}}return n.on("error",()=>{if(l===n)l=null}),n.once("exit",()=>{if(l===n)l=null}),n.unref(),l=n,()=>S(n)};import{chmodSync as ne,existsSync as se,mkdirSync as re,readFileSync as D,realpathSync as ie,renameSync as oe,statSync as j,writeFileSync as ae}from"fs";import{dirname as de,isAbsolute as G,join as N,resolve as T,sep as b}from"path";function F(e=a()){return N(nr(e),"reason","protected-path-grants.json")}var f=null;function L(e){let t=JSON.parse(e);if(!Array.isArray(t?.grants))return[];return t.grants.flatMap((s)=>{let n=s;return n&&typeof n.path==="string"&&G(n.path)&&(n.kind==="file"||n.kind==="folder")&&typeof n.grantedAt==="number"?[{path:n.path,kind:n.kind,grantedAt:n.grantedAt}]:[]})}function y(e=F()){try{let{mtimeMs:t}=j(e);if(f&&f.file===e&&f.mtimeMs===t)return f.grants;let s=L(D(e,"utf8"));return f={file:e,mtimeMs:t,grants:s},s}catch{return[]}}function W(e,t){return e.kind==="file"?t===e.path:t===e.path||t.startsWith(`${e.path}${b}`)}function U(e,t){let s=T(e);return y(t).some((n)=>W(n,s))}function wo(e,t){return E(e)&&!U(e,t)}function bo(e,t,s){let n=t?"file-read* file-write*":"file-read*";return y(s).filter((r)=>r.path===e||r.path.startsWith(`${e}${b}`)).map((r)=>`(allow ${n} (${r.kind==="file"?"literal":"subpath"} ${JSON.stringify(r.path)}))`)}var P="x-apple.systempreferences:com.apple.preference.security",J="curl -fsSL https://reasonmachines.com/install.sh | bash",q=180000,B=2000;var k={screen:{label:"Screen & System Audio Recording",purpose:"desktop video, computer-use screenshots",level:"required",pane:`${P}?Privacy_ScreenCapture`},accessibility:{label:"Accessibility",purpose:"computer-use clicks and typing, desktop input",level:"required",pane:`${P}?Privacy_Accessibility`},disk:{label:"Full Disk Access",purpose:"Sessions in Desktop, Documents, Downloads, iCloud Drive and Mail",level:"recommended",pane:`${P}?Privacy_AllFiles`}};function R(e){return e.executable}function K(e,t){if(e==="computer_use_identity_missing")return`Reason's background identity is not installed (${e}); reinstall Reason: ${J}`;if(e==="computer_use_identity_outdated")return`Reason's background identity is outdated (${Kr(t)??"unknown"}; this CLI is ${Qe}) (${e}); \`reason update\` installs this release's`;return`Reason's background identity cannot run computer use for this CLI (${e}); run the installed \`reason\``}function ls(e=a()){let t=gt(e);if(t.length>0)return{state:"ready",path:w(w(w(t[0]))),prefix:t};let s=Mo(t,e)??"computer_use_identity_unavailable";return{state:s,path:le(e),detail:K(s,e)}}function V(){return{identity:()=>ls(),grants:(e)=>Ge(e),request:(e,t)=>pt(e,t),worker:async()=>(await import("./status-bhhr39ts.js")).connectionMacState(),open:(e)=>{H("/usr/bin/open",e,{stdio:"ignore",timeout:1e4})},tile:Ir,restartConnection:async()=>(await import("./connect-cli-nxm79ypx.js")).restartConnection(),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()}}function M(e,t,s){if(e.state!=="ready"||!t)return"unknown";return t[s]?"granted":"missing"}async function us(e){let t=e.identity(),s=t.state==="ready"?await e.grants(t.prefix):null,n=await e.worker(),r=n?R(n):null,i=!r||n?.full_disk_access==="unknown"?"unknown":n?.full_disk_access==="granted"?"granted":"missing",c=(u,d,o)=>{let{label:p,purpose:h,level:m}=k[u];return{id:u,label:p,purpose:h,level:m,state:d,holder:o}};return{identity:{state:t.state,path:t.path,detail:t.state==="ready"?null:t.detail},worker_detail:r?null:"Full Disk Access is read from this computer's running worker; `reason connect` starts it.",permissions:[c("screen",M(t,s,"screen"),t.path),c("accessibility",M(t,s,"accessibility"),t.path),c("disk",i,r)]}}function Ks(e){let t=e.identity.state==="ready"?null:e.identity.state,s=e.permissions.filter((i)=>i.state==="granted").length,n=[...t?[t]:[],...e.permissions.filter((i)=>i.state!=="granted"&&!(t&&i.id!=="disk")).map((i)=>`${i.label} ${i.state}`)],r=!t&&e.permissions.some((i)=>i.state==="missing");return`Permissions: ${s} of ${e.permissions.length}${n.length>0?` (${n.join(", ")})`:""}`+(r?" \u2014 reason permissions allow":n.length>0?" \u2014 reason permissions":"")}async function x(e,t){let s=t.now()+q;for(;;){if(await e())return!0;if(t.now()>=s)return!1;await t.sleep(B)}}async function Js(e,t){let s=t.host??V(),{io:n}=t,r=await us(s),i=r.permissions.filter((o)=>e.includes(o.id)&&o.state!=="granted");if(i.length===0)return n.stdout.write(`Reason permissions: ${e.map((o)=>k[o].label).join(", ")} already allowed.
2
+ import{Ge,pt}from"./vm-hands-entry-lite-k9vk84wa.js";import{Qe}from"./vm-hands-entry-lite-fmghv8b1.js";import{$o,le,Kr,gt,Mo}from"./vm-hands-entry-lite-h43y7nth.js";import{E}from"./vm-hands-entry-lite-72nj66ab.js";import{a,nr}from"./vm-hands-entry-lite-jvszqt0z.js";import{spawnSync as H}from"child_process";import{dirname as w}from"path";import{spawn as A}from"child_process";import{accessSync as _,constants as v}from"fs";import{basename as C,join as O}from"path";var l=null;function S(e){if(l===e)l=null;if(e.exitCode===null&&e.signalCode===null)e.kill("SIGTERM")}var Ir=(e,t)=>{if(l)S(l);let s=O(e,$o);try{_(s,v.X_OK)}catch{return()=>{}}let n;try{n=A(s,["--app",e,"--name",C(e,".app"),"--permission",t==="screen"?"screen_recording":"accessibility"],{detached:!0,stdio:"ignore"})}catch{return()=>{}}return n.on("error",()=>{if(l===n)l=null}),n.once("exit",()=>{if(l===n)l=null}),n.unref(),l=n,()=>S(n)};import{chmodSync as ne,existsSync as se,mkdirSync as re,readFileSync as D,realpathSync as ie,renameSync as oe,statSync as j,writeFileSync as ae}from"fs";import{dirname as de,isAbsolute as G,join as N,resolve as T,sep as b}from"path";function F(e=a()){return N(nr(e),"reason","protected-path-grants.json")}var f=null;function L(e){let t=JSON.parse(e);if(!Array.isArray(t?.grants))return[];return t.grants.flatMap((s)=>{let n=s;return n&&typeof n.path==="string"&&G(n.path)&&(n.kind==="file"||n.kind==="folder")&&typeof n.grantedAt==="number"?[{path:n.path,kind:n.kind,grantedAt:n.grantedAt}]:[]})}function y(e=F()){try{let{mtimeMs:t}=j(e);if(f&&f.file===e&&f.mtimeMs===t)return f.grants;let s=L(D(e,"utf8"));return f={file:e,mtimeMs:t,grants:s},s}catch{return[]}}function W(e,t){return e.kind==="file"?t===e.path:t===e.path||t.startsWith(`${e.path}${b}`)}function U(e,t){let s=T(e);return y(t).some((n)=>W(n,s))}function wo(e,t){return E(e)&&!U(e,t)}function bo(e,t,s){let n=t?"file-read* file-write*":"file-read*";return y(s).filter((r)=>r.path===e||r.path.startsWith(`${e}${b}`)).map((r)=>`(allow ${n} (${r.kind==="file"?"literal":"subpath"} ${JSON.stringify(r.path)}))`)}var P="x-apple.systempreferences:com.apple.preference.security",J="curl -fsSL https://reasonmachines.com/install.sh | bash",q=180000,B=2000;var k={screen:{label:"Screen & System Audio Recording",purpose:"desktop video, computer-use screenshots",level:"required",pane:`${P}?Privacy_ScreenCapture`},accessibility:{label:"Accessibility",purpose:"computer-use clicks and typing, desktop input",level:"required",pane:`${P}?Privacy_Accessibility`},disk:{label:"Full Disk Access",purpose:"Sessions in Desktop, Documents, Downloads, iCloud Drive and Mail",level:"recommended",pane:`${P}?Privacy_AllFiles`}};function R(e){return e.executable}function K(e,t){if(e==="computer_use_identity_missing")return`Reason's background identity is not installed (${e}); reinstall Reason: ${J}`;if(e==="computer_use_identity_outdated")return`Reason's background identity is outdated (${Kr(t)??"unknown"}; this CLI is ${Qe}) (${e}); \`reason update\` installs this release's`;return`Reason's background identity cannot run computer use for this CLI (${e}); run the installed \`reason\``}function ls(e=a()){let t=gt(e);if(t.length>0)return{state:"ready",path:w(w(w(t[0]))),prefix:t};let s=Mo(t,e)??"computer_use_identity_unavailable";return{state:s,path:le(e),detail:K(s,e)}}function V(){return{identity:()=>ls(),grants:(e)=>Ge(e),request:(e,t)=>pt(e,t),worker:async()=>(await import("./status-y0mkm1dt.js")).connectionMacState(),open:(e)=>{H("/usr/bin/open",e,{stdio:"ignore",timeout:1e4})},tile:Ir,restartConnection:async()=>(await import("./connect-cli-98zcpbp7.js")).restartConnection(),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()}}function M(e,t,s){if(e.state!=="ready"||!t)return"unknown";return t[s]?"granted":"missing"}async function us(e){let t=e.identity(),s=t.state==="ready"?await e.grants(t.prefix):null,n=await e.worker(),r=n?R(n):null,i=!r||n?.full_disk_access==="unknown"?"unknown":n?.full_disk_access==="granted"?"granted":"missing",c=(u,d,o)=>{let{label:p,purpose:h,level:m}=k[u];return{id:u,label:p,purpose:h,level:m,state:d,holder:o}};return{identity:{state:t.state,path:t.path,detail:t.state==="ready"?null:t.detail},worker_detail:r?null:"Full Disk Access is read from this computer's running worker; `reason connect` starts it.",permissions:[c("screen",M(t,s,"screen"),t.path),c("accessibility",M(t,s,"accessibility"),t.path),c("disk",i,r)]}}function Ks(e){let t=e.identity.state==="ready"?null:e.identity.state,s=e.permissions.filter((i)=>i.state==="granted").length,n=[...t?[t]:[],...e.permissions.filter((i)=>i.state!=="granted"&&!(t&&i.id!=="disk")).map((i)=>`${i.label} ${i.state}`)],r=!t&&e.permissions.some((i)=>i.state==="missing");return`Permissions: ${s} of ${e.permissions.length}${n.length>0?` (${n.join(", ")})`:""}`+(r?" \u2014 reason permissions allow":n.length>0?" \u2014 reason permissions":"")}async function x(e,t){let s=t.now()+q;for(;;){if(await e())return!0;if(t.now()>=s)return!1;await t.sleep(B)}}async function Js(e,t){let s=t.host??V(),{io:n}=t,r=await us(s),i=r.permissions.filter((o)=>e.includes(o.id)&&o.state!=="granted");if(i.length===0)return n.stdout.write(`Reason permissions: ${e.map((o)=>k[o].label).join(", ")} already allowed.
3
3
  `),0;let c=!1,u=!1,d=s.identity();for(let o of i){let{label:p,pane:h}=k[o.id];if(o.id!=="disk"){if(d.state!=="ready"){if(!c)n.stderr.write(`Reason permissions: ${d.detail}
4
4
  `);c=!0;continue}let g=o.id;await s.request(d.prefix,g),s.open([h]);let I=s.tile(d.path,g);if(n.stdout.write(`Allow Reason in System Settings > Privacy & Security > ${p}.
5
5
  `),!t.wait)continue;if(n.stdout.write(`Waiting for it (Ctrl-C to stop)\u2026
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{R}from"./vm-hands-entry-lite-a3p6xz53.js";import{Gr}from"./vm-hands-entry-lite-mc8j8dj2.js";import{mt}from"./vm-hands-entry-lite-73f4cgkf.js";import{a}from"./vm-hands-entry-lite-jvszqt0z.js";import{A}from"./vm-hands-entry-lite-b6gsggvp.js";import{randomUUID as f}from"crypto";import{chmodSync as U,closeSync as h,constants as g,existsSync as me,fstatSync as F,lstatSync as p,mkdirSync as B,openSync as G,readFileSync as Y,readdirSync as z,readlinkSync as J,realpathSync as P,renameSync as _,rmSync as L,statSync as K,symlinkSync as _t,unlinkSync as M,writeFileSync as N}from"fs";import{basename as vt,dirname as k,isAbsolute as fe,join as c,relative as ge,resolve as b,sep as _e}from"path";import{createRequire as H}from"module";var q=1,j=1,ye=128,ve=65536;var he=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;var D=/^[a-z0-9_.-]{1,80}$/,be=64,Ee="so.ara.device-broker",Me=[Ee,"com.reasonmachines.device-broker"],Pt=Gr(Me);var we=["service.install_started","service.install_completed","service.install_failed","service.launcher_adopted","service.launcher_conflict","service.started","service.reconnecting","service.reconnected","service.idle_sleep_held","service.idle_sleep_released","service.idle_sleep_failed","service.start_failed","service.stopped","service.exit_failed","service.singleton_rejected","credential.migration_started","credential.migration_completed","credential.migration_failed","credential.store_started","credential.store_completed","credential.store_failed","credential.delete_started","credential.delete_completed","credential.delete_failed","update.check_started","update.not_available","update.download_started","update.downloaded","update.verified","update.activated","update.rollback","update.failed","executor.update.check_started","executor.update.not_available","executor.update.download_started","executor.update.downloaded","executor.update.verified","executor.update.activated","executor.update.rollback","executor.update.failed","identity.refresh_completed","identity.refresh_failed","update.device_moved","update.components_installed","update.deferred","update.deferral_expired","worker.previous_exit","worker.capabilities_withheld","identity.computer_use_unavailable"];function W(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function X(e,t,n=[]){let r=new Set([...t,...n]);return t.every((i)=>(i in e))&&Object.keys(e).every((i)=>r.has(i))}function E(e){return typeof e==="string"&&he.test(e)}function Z(e){return typeof e==="string"&&!Number.isNaN(Date.parse(e))&&new Date(e).toISOString()===e}function I(e){B(e,{recursive:!0,mode:448}),U(e,448)}function Re(e,t){I(k(e));let n=`${e}.${process.pid}.${f()}.tmp`;try{N(n,t,{mode:384,flag:"wx"}),U(n,384),_(n,e)}finally{if(me(n))M(n)}}function Rs(e={}){if((e.platform??process.platform)!=="darwin")throw new mt("unsupported_platform","The managed Reason runtime is currently available only on macOS.");let n=e.environment??process.env,r=R(n,"REASON_CLI_CHANNEL")==="staging",i=r?R(n,"REASON_MANAGED_RUNTIME_ROOT")?.trim():void 0,o=e.root!==void 0||Boolean(i&&fe(i))?null:c(e.home??a(),"Library","Application Support"),d=e.root??(o?c(o,r?"Reason Staging":"Reason","CLI"):i);return{executableName:"reason",root:d,...o?{legacyRoot:c(o,"Ara",...r?["staging","runtime"]:["runtime"])}:{},versions:c(d,"versions"),current:c(d,"current"),previous:c(d,"previous"),brokerLock:c(d,"broker.lock"),transitionLock:c(d,"transition.lock"),lifecycleEvents:c(d,"lifecycle-events")}}function Ts(e){let t=e.legacyRoot;if(!t)return null;return{root:t,versions:c(t,"versions"),current:c(t,"current"),previous:c(t,"previous"),brokerLock:c(t,"broker.lock"),transitionLock:c(t,"transition.lock"),lifecycleEvents:c(t,"lifecycle-events")}}function pe(e,t){let n;try{if(!p(e).isSymbolicLink())return null;n=J(e)}catch{return null}let r=n.match(/^versions\/(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)\/(ara|Reason|reason)$/);return r&&(r[2]==="ara"||r[2]===t)?r[1]:null}function Is(e){return pe(e.current,e.executableName)}function O(e,t,n){let i=ge(t,e).split(_e);return i.length===2&&E(i[0])&&(i[1]==="ara"||n!==void 0&&i[1]===n)?i[0]:null}function Le(e,t){try{return p(t).isSymbolicLink()&&b(k(t),J(t))===b(e.current)}catch{return!1}}function Ds(e,t=process.execPath){try{return O(P(t),P(e.versions),e.executableName)!==null}catch{let n=b(t);return n===b(e.current)||Le(e,n)||O(n,b(e.versions),e.executableName)!==null}}function Ae(e){return W(e)&&X(e,["schema_version","pid","nonce","started_at","runtime_version"])&&e.schema_version===q&&typeof e.pid==="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.nonce==="string"&&/^[0-9a-f-]{36}$/.test(e.nonce)&&Z(e.started_at)&&E(e.runtime_version)}function Q(e,t){try{let n=p(e);if(!n.isDirectory()||!A(n))return null;let r=G(c(e,t),g.O_RDONLY|g.O_NOFOLLOW|g.O_NONBLOCK);try{let i=F(r);if(!i.isFile()||i.nlink!==1||!A(i)||i.size>4096)return null;return Y(r,"utf8")}finally{h(r)}}catch{return null}}function S(e){try{let t=JSON.parse(Q(e,"owner.json")??"null");return Ae(t)?t:null}catch{return null}}function ee(e){try{return process.kill(e,0),!0}catch(t){return!(t instanceof Error&&("code"in t)&&t.code==="ESRCH")}}var C="lease",Ne=2,Se=4,y;function ke(){if(y!==void 0)return y;if(y=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let e;try{e=H(import.meta.url)("bun:ffi")}catch{return null}let t=process.platform==="darwin"?"__error":"__errno_location",n=process.platform==="darwin"?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`];for(let r of n)try{let i=e.dlopen(r,{flock:{args:[e.FFIType.i32,e.FFIType.i32],returns:e.FFIType.i32},[t]:{args:[],returns:e.FFIType.ptr}}),s=i.symbols[t]();if(s===null)continue;return y={flock:(o,d)=>i.symbols.flock(o,d),errno:()=>e.read.i32(s),wouldBlock:process.platform==="darwin"?35:11},y}catch{}return null}var v,Ie=3221225472,Te=4,xe=128,Pe=32;function De(e){if(v===void 0){v=null;try{let s=H(import.meta.url)("bun:ffi"),{FFIType:o}=s;v={kernel:s.dlopen("kernel32.dll",{CreateFileW:{args:[o.ptr,o.u32,o.u32,o.ptr,o.u32,o.u32,o.ptr],returns:o.i64_fast},CloseHandle:{args:[o.i64_fast],returns:o.i32},GetLastError:{args:[],returns:o.u32}}).symbols,ptr:(l)=>s.ptr(l)}}catch{return null}}if(!v)return null;let{kernel:t,ptr:n}=v,r=Buffer.from(`${e}\x00`,"utf16le"),i=t.CreateFileW(n(r),Ie,0,null,Te,xe,null);if(Number(i)===-1)return t.GetLastError()===Pe?"busy":null;return{release:()=>{t.CloseHandle(i)}}}function Oe(e){if(process.platform==="win32")return De(`${e}.lease`);let t=ke();if(!t)return null;let n=G(`${e}.lease`,g.O_RDWR|g.O_CREAT|g.O_NOFOLLOW,384);try{let r=F(n);if(!r.isFile()||r.nlink!==1||!A(r))return h(n),"busy";if(t.flock(n,Ne|Se)===0)return{release:()=>h(n)};let i=t.errno();return h(n),i===t.wouldBlock?"busy":null}catch(r){throw h(n),r}}function Os(e){I(k(e.path));let t=Oe(e.path);if(t==="busy")return{acquired:!1,owner:S(e.path),recoveredStaleOwner:!1};let n=t!==null;try{let r=Ce(e,t);if(r.acquired)n=!1;return r}finally{if(n)t.release()}}function Ce(e,t){let n=e.alive??ee,r=!1;for(let i=0;i<4;i+=1){let s={schema_version:q,pid:e.pid??process.pid,nonce:e.nonce?.()??f(),started_at:(e.now?.()??new Date).toISOString(),runtime_version:e.runtimeVersion},o=`${e.path}.init-${process.pid}-${f()}`,d=!1;try{if(B(o,{mode:448}),N(c(o,"owner.json"),`${JSON.stringify(s)}
2
+ import{R}from"./vm-hands-entry-lite-a3p6xz53.js";import{Gr}from"./vm-hands-entry-lite-h43y7nth.js";import{mt}from"./vm-hands-entry-lite-73f4cgkf.js";import{a}from"./vm-hands-entry-lite-jvszqt0z.js";import{A}from"./vm-hands-entry-lite-b6gsggvp.js";import{randomUUID as f}from"crypto";import{chmodSync as U,closeSync as h,constants as g,existsSync as me,fstatSync as F,lstatSync as p,mkdirSync as B,openSync as G,readFileSync as Y,readdirSync as z,readlinkSync as J,realpathSync as P,renameSync as _,rmSync as L,statSync as K,symlinkSync as _t,unlinkSync as M,writeFileSync as N}from"fs";import{basename as vt,dirname as k,isAbsolute as fe,join as c,relative as ge,resolve as b,sep as _e}from"path";import{createRequire as H}from"module";var q=1,j=1,ye=128,ve=65536;var he=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;var D=/^[a-z0-9_.-]{1,80}$/,be=64,Ee="so.ara.device-broker",Me=[Ee,"com.reasonmachines.device-broker"],Pt=Gr(Me);var we=["service.install_started","service.install_completed","service.install_failed","service.launcher_adopted","service.launcher_conflict","service.started","service.reconnecting","service.reconnected","service.idle_sleep_held","service.idle_sleep_released","service.idle_sleep_failed","service.start_failed","service.stopped","service.exit_failed","service.singleton_rejected","credential.migration_started","credential.migration_completed","credential.migration_failed","credential.store_started","credential.store_completed","credential.store_failed","credential.delete_started","credential.delete_completed","credential.delete_failed","update.check_started","update.not_available","update.download_started","update.downloaded","update.verified","update.activated","update.rollback","update.failed","executor.update.check_started","executor.update.not_available","executor.update.download_started","executor.update.downloaded","executor.update.verified","executor.update.activated","executor.update.rollback","executor.update.failed","identity.refresh_completed","identity.refresh_failed","update.device_moved","update.components_installed","update.deferred","update.deferral_expired","worker.previous_exit","worker.capabilities_withheld","identity.computer_use_unavailable"];function W(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function X(e,t,n=[]){let r=new Set([...t,...n]);return t.every((i)=>(i in e))&&Object.keys(e).every((i)=>r.has(i))}function E(e){return typeof e==="string"&&he.test(e)}function Z(e){return typeof e==="string"&&!Number.isNaN(Date.parse(e))&&new Date(e).toISOString()===e}function I(e){B(e,{recursive:!0,mode:448}),U(e,448)}function Re(e,t){I(k(e));let n=`${e}.${process.pid}.${f()}.tmp`;try{N(n,t,{mode:384,flag:"wx"}),U(n,384),_(n,e)}finally{if(me(n))M(n)}}function Rs(e={}){if((e.platform??process.platform)!=="darwin")throw new mt("unsupported_platform","The managed Reason runtime is currently available only on macOS.");let n=e.environment??process.env,r=R(n,"REASON_CLI_CHANNEL")==="staging",i=r?R(n,"REASON_MANAGED_RUNTIME_ROOT")?.trim():void 0,o=e.root!==void 0||Boolean(i&&fe(i))?null:c(e.home??a(),"Library","Application Support"),d=e.root??(o?c(o,r?"Reason Staging":"Reason","CLI"):i);return{executableName:"reason",root:d,...o?{legacyRoot:c(o,"Ara",...r?["staging","runtime"]:["runtime"])}:{},versions:c(d,"versions"),current:c(d,"current"),previous:c(d,"previous"),brokerLock:c(d,"broker.lock"),transitionLock:c(d,"transition.lock"),lifecycleEvents:c(d,"lifecycle-events")}}function Ts(e){let t=e.legacyRoot;if(!t)return null;return{root:t,versions:c(t,"versions"),current:c(t,"current"),previous:c(t,"previous"),brokerLock:c(t,"broker.lock"),transitionLock:c(t,"transition.lock"),lifecycleEvents:c(t,"lifecycle-events")}}function pe(e,t){let n;try{if(!p(e).isSymbolicLink())return null;n=J(e)}catch{return null}let r=n.match(/^versions\/(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)\/(ara|Reason|reason)$/);return r&&(r[2]==="ara"||r[2]===t)?r[1]:null}function Is(e){return pe(e.current,e.executableName)}function O(e,t,n){let i=ge(t,e).split(_e);return i.length===2&&E(i[0])&&(i[1]==="ara"||n!==void 0&&i[1]===n)?i[0]:null}function Le(e,t){try{return p(t).isSymbolicLink()&&b(k(t),J(t))===b(e.current)}catch{return!1}}function Ds(e,t=process.execPath){try{return O(P(t),P(e.versions),e.executableName)!==null}catch{let n=b(t);return n===b(e.current)||Le(e,n)||O(n,b(e.versions),e.executableName)!==null}}function Ae(e){return W(e)&&X(e,["schema_version","pid","nonce","started_at","runtime_version"])&&e.schema_version===q&&typeof e.pid==="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.nonce==="string"&&/^[0-9a-f-]{36}$/.test(e.nonce)&&Z(e.started_at)&&E(e.runtime_version)}function Q(e,t){try{let n=p(e);if(!n.isDirectory()||!A(n))return null;let r=G(c(e,t),g.O_RDONLY|g.O_NOFOLLOW|g.O_NONBLOCK);try{let i=F(r);if(!i.isFile()||i.nlink!==1||!A(i)||i.size>4096)return null;return Y(r,"utf8")}finally{h(r)}}catch{return null}}function S(e){try{let t=JSON.parse(Q(e,"owner.json")??"null");return Ae(t)?t:null}catch{return null}}function ee(e){try{return process.kill(e,0),!0}catch(t){return!(t instanceof Error&&("code"in t)&&t.code==="ESRCH")}}var C="lease",Ne=2,Se=4,y;function ke(){if(y!==void 0)return y;if(y=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let e;try{e=H(import.meta.url)("bun:ffi")}catch{return null}let t=process.platform==="darwin"?"__error":"__errno_location",n=process.platform==="darwin"?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`];for(let r of n)try{let i=e.dlopen(r,{flock:{args:[e.FFIType.i32,e.FFIType.i32],returns:e.FFIType.i32},[t]:{args:[],returns:e.FFIType.ptr}}),s=i.symbols[t]();if(s===null)continue;return y={flock:(o,d)=>i.symbols.flock(o,d),errno:()=>e.read.i32(s),wouldBlock:process.platform==="darwin"?35:11},y}catch{}return null}var v,Ie=3221225472,Te=4,xe=128,Pe=32;function De(e){if(v===void 0){v=null;try{let s=H(import.meta.url)("bun:ffi"),{FFIType:o}=s;v={kernel:s.dlopen("kernel32.dll",{CreateFileW:{args:[o.ptr,o.u32,o.u32,o.ptr,o.u32,o.u32,o.ptr],returns:o.i64_fast},CloseHandle:{args:[o.i64_fast],returns:o.i32},GetLastError:{args:[],returns:o.u32}}).symbols,ptr:(l)=>s.ptr(l)}}catch{return null}}if(!v)return null;let{kernel:t,ptr:n}=v,r=Buffer.from(`${e}\x00`,"utf16le"),i=t.CreateFileW(n(r),Ie,0,null,Te,xe,null);if(Number(i)===-1)return t.GetLastError()===Pe?"busy":null;return{release:()=>{t.CloseHandle(i)}}}function Oe(e){if(process.platform==="win32")return De(`${e}.lease`);let t=ke();if(!t)return null;let n=G(`${e}.lease`,g.O_RDWR|g.O_CREAT|g.O_NOFOLLOW,384);try{let r=F(n);if(!r.isFile()||r.nlink!==1||!A(r))return h(n),"busy";if(t.flock(n,Ne|Se)===0)return{release:()=>h(n)};let i=t.errno();return h(n),i===t.wouldBlock?"busy":null}catch(r){throw h(n),r}}function Os(e){I(k(e.path));let t=Oe(e.path);if(t==="busy")return{acquired:!1,owner:S(e.path),recoveredStaleOwner:!1};let n=t!==null;try{let r=Ce(e,t);if(r.acquired)n=!1;return r}finally{if(n)t.release()}}function Ce(e,t){let n=e.alive??ee,r=!1;for(let i=0;i<4;i+=1){let s={schema_version:q,pid:e.pid??process.pid,nonce:e.nonce?.()??f(),started_at:(e.now?.()??new Date).toISOString(),runtime_version:e.runtimeVersion},o=`${e.path}.init-${process.pid}-${f()}`,d=!1;try{if(B(o,{mode:448}),N(c(o,"owner.json"),`${JSON.stringify(s)}
3
3
  `,{mode:384,flag:"wx"}),t!==null)N(c(o,C),`flock
4
4
  `,{mode:384,flag:"wx"});e.beforePublish?.();try{throw p(e.path),Object.assign(Error("Managed runtime lock exists."),{code:"EEXIST"})}catch(m){if(m.code!=="ENOENT")throw m}_(o,e.path),d=!0;let l=!1;return{acquired:!0,owner:s,recoveredStaleOwner:r,release(){if(l)return;if(l=!0,S(e.path)?.nonce===s.nonce)L(e.path,{recursive:!0,force:!0});t?.release()}}}catch(l){let m=l.code;if(!["EEXIST","ENOTEMPTY"].includes(m??""))throw l;let u=S(e.path),re=(e.now?.()??new Date).getTime(),ie=u&&e.staleAfterMs!==void 0?re-Date.parse(u.started_at)<e.staleAfterMs:!1,ae=u!==null&&!(t!==null&&Q(e.path,C)!==null)&&n(u.pid);if(!u||ae||ie)return{acquired:!1,owner:u,recoveredStaleOwner:!1};let T=`${e.path}.stale-${process.pid}-${f()}`;try{_(e.path,T),L(T,{recursive:!0,force:!0}),r=!0}catch(x){let oe=x.code;if(!["ENOENT","EEXIST"].includes(oe??""))throw x}}finally{if(!d)L(o,{recursive:!0,force:!0})}}throw new mt("lock_unavailable","Could not acquire the managed Reason runtime lock.")}function te(e){return W(e)&&X(e,["schema_version","event_id","occurred_at","event","runtime_version"],["from_version","to_version","reason_code","duration_ms","attempt_count","retry_in_ms","capabilities"])&&e.schema_version===j&&typeof e.event_id==="string"&&/^[0-9a-f-]{36}$/.test(e.event_id)&&Z(e.occurred_at)&&typeof e.event==="string"&&we.includes(e.event)&&E(e.runtime_version)&&(e.from_version===void 0||E(e.from_version))&&(e.to_version===void 0||E(e.to_version))&&(e.reason_code===void 0||typeof e.reason_code==="string"&&D.test(e.reason_code))&&(e.duration_ms===void 0||typeof e.duration_ms==="number"&&Number.isSafeInteger(e.duration_ms)&&e.duration_ms>=0&&e.duration_ms<=86400000)&&(e.attempt_count===void 0||typeof e.attempt_count==="number"&&Number.isSafeInteger(e.attempt_count)&&e.attempt_count>=1&&e.attempt_count<=1e5)&&(e.retry_in_ms===void 0||typeof e.retry_in_ms==="number"&&Number.isSafeInteger(e.retry_in_ms)&&e.retry_in_ms>=0&&e.retry_in_ms<=30000)&&(e.capabilities===void 0||Array.isArray(e.capabilities)&&e.capabilities.length<=be&&e.capabilities.every((t)=>typeof t==="string"&&D.test(t)))}var Ve=/^(\d{22}-[0-9a-f-]{36}\.json)$/,Ue=/^(\d{22}-[0-9a-f-]{36}\.json)\.sending-(\d+)-[0-9a-f-]{36}$/,Fe=300000,w=0n;function Be(e){let t=BigInt(new Date(e.occurred_at).getTime())*1000000n;return w=t>w?t:w+1n,`${String(w).padStart(22,"0")}-${e.event_id}.json`}function ne(e){try{return z(e.lifecycleEvents).filter((t)=>Ve.test(t)).sort()}catch{return[]}}function V(e){try{let t=JSON.parse(Y(e,"utf8"));return te(t)?t:null}catch{return null}}function $e(e,t=ee,n=Date.now()){let r;try{r=z(e.lifecycleEvents)}catch{return}for(let i of r){let s=i.match(Ue);if(!s)continue;let o=c(e.lifecycleEvents,i),d=c(e.lifecycleEvents,s[1]),l=!t(Number(s[2]));if(!l)try{l=n-K(o).mtimeMs>=Fe}catch{continue}if(!l)continue;try{_(o,d)}catch(m){let u=m.code;if(u==="EEXIST")M(o);else if(u!=="ENOENT")throw m}}}function Ge(e){let n=ne(e).flatMap((i)=>{try{return[{name:i,size:K(c(e.lifecycleEvents,i)).size}]}catch{return[]}}),r=n.reduce((i,s)=>i+s.size,0);while(n.length>ye||r>ve){let i=n.shift();if(!i)break;try{M(c(e.lifecycleEvents,i.name)),r-=i.size}catch(s){if(s.code!=="ENOENT")throw s}}}function Ns(e,t,n={}){let r={schema_version:j,event_id:n.eventId?.()??f(),occurred_at:(n.now?.()??new Date).toISOString(),...t};if(!te(r))throw new mt("invalid_lifecycle_event","Managed runtime lifecycle event is invalid.");return I(e.lifecycleEvents),Re(c(e.lifecycleEvents,Be(r)),`${JSON.stringify(r)}
5
5
  `),Ge(e),r}async function Ls(e,t,n){$e(e);let r=0;for(let i of ne(e)){let s=c(e.lifecycleEvents,i);if(n){let l=V(s);if(!l||!n(l))continue}let o=`${s}.sending-${process.pid}-${f()}`;try{_(s,o)}catch(l){if(l.code==="ENOENT")continue;throw l}let d=V(o);if(!d){M(o);continue}try{await t(d),M(o),r+=1}catch{try{_(o,s)}catch(l){if(l.code!=="ENOENT")throw l}break}}return r}export{Rs,Ts,Is,Ds,Os,Ns,Ls};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var tr={name:"github-native-engineer-device-worker-production",version:"0.2.541",private:!0,type:"module",engines:{node:">=22",bun:">=1.3.0"},workspaces:["../../packages/runtime-distribution"],dependencies:{"@agentclientprotocol/sdk":"1.9.0","@anthropic-ai/sandbox-runtime":"^0.0.80","@earendil-works/pi-tui":"1.0.0","@reason/runtime-distribution":"workspace:*",diff:"8.0.4","open-browser-use-sdk":"0.1.42","playwright-core":"1.60.0",toml:"4.2.0",zod:"^4.4.3"},overrides:{"@hono/node-server":"^1.19.15","@earendil-works/pi-agent-core":"1.0.0","@earendil-works/pi-ai":"1.0.0","@earendil-works/pi-coding-agent":"1.0.0","@earendil-works/chord":"1.0.0","@earendil-works/pi-codemode":"1.0.0","@earendil-works/pi-mcp":"1.0.0","@earendil-works/pi-telemetry":"1.0.0","@earendil-works/pi-tui":"1.0.0","brace-expansion":"2.1.7",axios:"^1.20.0","basic-ftp":"^6.2.1","@grpc/grpc-js":"^1.14.5",browserslist:"^4.28.8","engine.io":"^6.6.7","fast-uri":"^3.1.8",hono:"^4.13.7","ip-address":"^10.7.1",nanoid:"^3.3.18",dompurify:"^3.4.17",postcss:"^8.5.23",qs:"^6.16.0","shell-quote":"^1.11.0","socket.io-parser":"^4.2.7",tmp:"^0.2.7",toml:"^4.2.0",undici:"^8.10.2",ws:"^8.21.0","js-yaml":"^4.3.2","@modelcontextprotocol/sdk":"^1.31.0","proxy-addr":"^2.0.8","source-map-js":"^1.2.2"}};
2
+ var tr={name:"github-native-engineer-device-worker-production",version:"0.2.544",private:!0,type:"module",engines:{node:">=22",bun:">=1.3.0"},workspaces:["../../packages/runtime-distribution"],dependencies:{"@agentclientprotocol/sdk":"1.9.0","@anthropic-ai/sandbox-runtime":"^0.0.80","@earendil-works/pi-tui":"1.0.0","@reason/runtime-distribution":"workspace:*",diff:"8.0.4","open-browser-use-sdk":"0.1.42","playwright-core":"1.60.0",toml:"4.2.0",zod:"^4.4.3"},overrides:{"@hono/node-server":"^1.19.15","@earendil-works/pi-agent-core":"1.0.0","@earendil-works/pi-ai":"1.0.0","@earendil-works/pi-coding-agent":"1.0.0","@earendil-works/chord":"1.0.0","@earendil-works/pi-codemode":"1.0.0","@earendil-works/pi-mcp":"1.0.0","@earendil-works/pi-telemetry":"1.0.0","@earendil-works/pi-tui":"1.0.0","brace-expansion":"2.1.7",axios:"^1.20.0","basic-ftp":"^6.2.1","@grpc/grpc-js":"^1.14.5",browserslist:"^4.28.8","engine.io":"^6.6.7","fast-uri":"^3.1.8",hono:"^4.13.7","ip-address":"^10.7.1",nanoid:"^3.3.18",dompurify:"^3.4.17",postcss:"^8.5.23",qs:"^6.16.0","shell-quote":"^1.11.0","socket.io-parser":"^4.2.7",tmp:"^0.2.7",toml:"^4.2.0",undici:"^8.10.2",ws:"^8.21.0","js-yaml":"^4.3.2","@modelcontextprotocol/sdk":"^1.31.0","proxy-addr":"^2.0.8","source-map-js":"^1.2.2"}};
3
3
  export{tr};
@@ -62,4 +62,4 @@ import{ys}from"./vm-hands-entry-lite-pzj5s203.js";var Xr,Xo=Object.freeze({statu
62
62
 
63
63
  `)}Z.write("payload.value = newResult;"),Z.write("return payload;");let Xs=Z.compile();return(B,j)=>Xs(P,B,j)},f,m=se,h=!ne.jitless,x=h&&rt.value,v=r.catchall,w;e._zod.parse=(P,Z)=>{w??(w=p.value);let O=P.value;if(!m(O))return P.issues.push({expected:"object",code:"invalid_type",input:O,inst:e}),P;if(h&&x&&Z?.async===!1&&Z.jitless!==!0){if(!f)f=l(r.shape);if(P=f(P,Z),!v)return P;return Qo([],O,P,Z,w,e)}return a(P,Z)}});function lo(e,r,a,p){for(let f of e)if(f.issues.length===0)return r.value=f.value,r;let l=e.filter((f)=>!re(f));if(l.length===1)return r.value=l[0].value,l[0];return r.issues.push({code:"invalid_union",input:r.value,inst:a,errors:e.map((f)=>f.issues.map((m)=>J(m,p,L())))}),r}var or=z("$ZodUnion",(e,r)=>{I.init(e,r),S(e._zod,"optin",()=>r.options.some((p)=>p._zod.optin==="optional")?"optional":void 0),S(e._zod,"optout",()=>r.options.some((p)=>p._zod.optout==="optional")?"optional":void 0),S(e._zod,"values",()=>{if(r.options.every((p)=>p._zod.values))return new Set(r.options.flatMap((p)=>Array.from(p._zod.values)));return}),S(e._zod,"pattern",()=>{if(r.options.every((p)=>p._zod.pattern)){let p=r.options.map((l)=>l._zod.pattern);return new RegExp(`^(${p.map((l)=>ke(l.source)).join("|")})$`)}return});let a=r.options.length===1?r.options[0]._zod.run:null;e._zod.parse=(p,l)=>{if(a)return a(p,l);let f=!1,m=[];for(let h of r.options){let _=h._zod.run({value:p.value,issues:[]},l);if(_ instanceof Promise)m.push(_),f=!0;else{if(_.issues.length===0)return _;m.push(_)}}if(!f)return lo(m,p,e,l);return Promise.all(m).then((h)=>lo(h,p,e,l))}});var rn=z("$ZodDiscriminatedUnion",(e,r)=>{r.inclusive=!1,or.init(e,r);let a=e._zod.parse;S(e._zod,"propValues",()=>{let l={};for(let f of r.options){let m=f._zod.propValues;if(!m||Object.keys(m).length===0)throw Error(`Invalid discriminated union option at index "${r.options.indexOf(f)}"`);for(let[h,_]of Object.entries(m)){if(!l[h])l[h]=new Set;for(let x of _)l[h].add(x)}}return l});let p=pe(()=>{let l=r.options,f=new Map;for(let m of l){let h=m._zod.propValues?.[r.discriminator];if(!h||h.size===0)throw Error(`Invalid discriminated union option at index "${r.options.indexOf(m)}"`);for(let _ of h){if(f.has(_))throw Error(`Duplicate discriminator value "${String(_)}"`);f.set(_,m)}}return f});e._zod.parse=(l,f)=>{let m=l.value;if(!se(m))return l.issues.push({code:"invalid_type",expected:"object",input:m,inst:e}),l;let h=p.value.get(m?.[r.discriminator]);if(h)return h._zod.run(l,f);if(r.unionFallback||f.direction==="backward")return a(l,f);return l.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:r.discriminator,options:Array.from(p.value.keys()),input:m,path:[r.discriminator],inst:e}),l}}),tn=z("$ZodIntersection",(e,r)=>{I.init(e,r),e._zod.parse=(a,p)=>{let l=a.value,f=r.left._zod.run({value:l,issues:[]},p),m=r.right._zod.run({value:l,issues:[]},p);if(f instanceof Promise||m instanceof Promise)return Promise.all([f,m]).then(([_,x])=>fo(a,_,x));return fo(a,f,m)}});function rr(e,r){if(e===r)return{valid:!0,data:e};if(e instanceof Date&&r instanceof Date&&+e===+r)return{valid:!0,data:e};if(Q(e)&&Q(r)){let a=Object.keys(r),p=Object.keys(e).filter((f)=>a.indexOf(f)!==-1),l={...e,...r};for(let f of p){let m=rr(e[f],r[f]);if(!m.valid)return{valid:!1,mergeErrorPath:[f,...m.mergeErrorPath]};l[f]=m.data}return{valid:!0,data:l}}if(Array.isArray(e)&&Array.isArray(r)){if(e.length!==r.length)return{valid:!1,mergeErrorPath:[]};let a=[];for(let p=0;p<e.length;p++){let l=e[p],f=r[p],m=rr(l,f);if(!m.valid)return{valid:!1,mergeErrorPath:[p,...m.mergeErrorPath]};a.push(m.data)}return{valid:!0,data:a}}return{valid:!1,mergeErrorPath:[]}}function fo(e,r,a){let p=new Map,l;for(let h of r.issues)if(h.code==="unrecognized_keys"){l??(l=h);for(let _ of h.keys){if(!p.has(_))p.set(_,{});p.get(_).l=!0}}else e.issues.push(h);for(let h of a.issues)if(h.code==="unrecognized_keys")for(let _ of h.keys){if(!p.has(_))p.set(_,{});p.get(_).r=!0}else e.issues.push(h);let f=[...p].filter(([,h])=>h.l&&h.r).map(([h])=>h);if(f.length&&l)e.issues.push({...l,keys:f});if(re(e))return e;let m=rr(r.value,a.value);if(!m.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(m.mergeErrorPath)}`);return e.value=m.data,e}var on=z("$ZodRecord",(e,r)=>{I.init(e,r),e._zod.parse=(a,p)=>{let l=a.value;if(!Q(l))return a.issues.push({expected:"record",code:"invalid_type",input:l,inst:e}),a;let f=[],m=r.keyType._zod.values;if(m){a.value={};let h=new Set;for(let x of m)if(typeof x==="string"||typeof x==="number"||typeof x==="symbol"){h.add(typeof x==="number"?x.toString():x);let v=r.keyType._zod.run({value:x,issues:[]},p);if(v instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(v.issues.length){a.issues.push({code:"invalid_key",origin:"record",issues:v.issues.map((Z)=>J(Z,p,L())),input:x,path:[x],inst:e});continue}let w=v.value,P=r.valueType._zod.run({value:l[x],issues:[]},p);if(P instanceof Promise)f.push(P.then((Z)=>{if(Z.issues.length)a.issues.push(...q(x,Z.issues));a.value[w]=Z.value}));else{if(P.issues.length)a.issues.push(...q(x,P.issues));a.value[w]=P.value}}let _;for(let x in l)if(!h.has(x))_=_??[],_.push(x);if(_&&_.length>0)a.issues.push({code:"unrecognized_keys",input:l,inst:e,keys:_})}else{a.value={};for(let h of Reflect.ownKeys(l)){if(h==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(l,h))continue;let _=r.keyType._zod.run({value:h,issues:[]},p);if(_ instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof h==="string"&&Xe.test(h)&&_.issues.length){let w=r.keyType._zod.run({value:Number(h),issues:[]},p);if(w instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(w.issues.length===0)_=w}if(_.issues.length){if(r.mode==="loose")a.value[h]=l[h];else a.issues.push({code:"invalid_key",origin:"record",issues:_.issues.map((w)=>J(w,p,L())),input:h,path:[h],inst:e});continue}let v=r.valueType._zod.run({value:l[h],issues:[]},p);if(v instanceof Promise)f.push(v.then((w)=>{if(w.issues.length)a.issues.push(...q(h,w.issues));a.value[_.value]=w.value}));else{if(v.issues.length)a.issues.push(...q(h,v.issues));a.value[_.value]=v.value}}}if(f.length)return Promise.all(f).then(()=>a);return a}});var nn=z("$ZodEnum",(e,r)=>{I.init(e,r);let a=be(r.entries),p=new Set(a);e._zod.values=p,e._zod.pattern=new RegExp(`^(${a.filter((l)=>tt.has(typeof l)).map((l)=>typeof l==="string"?G(l):l.toString()).join("|")})$`),e._zod.parse=(l,f)=>{let m=l.value;if(p.has(m))return l;return l.issues.push({code:"invalid_value",values:a,input:m,inst:e}),l}}),sn=z("$ZodLiteral",(e,r)=>{if(I.init(e,r),r.values.length===0)throw Error("Cannot create literal schema with no valid values");let a=new Set(r.values);e._zod.values=a,e._zod.pattern=new RegExp(`^(${r.values.map((p)=>typeof p==="string"?G(p):p?G(p.toString()):String(p)).join("|")})$`),e._zod.parse=(p,l)=>{let f=p.value;if(a.has(f))return p;return p.issues.push({code:"invalid_value",values:r.values,input:f,inst:e}),p}});var un=z("$ZodTransform",(e,r)=>{I.init(e,r),e._zod.optin="optional",e._zod.parse=(a,p)=>{if(p.direction==="backward")throw new ue(e.constructor.name);let l=r.transform(a.value,a);if(p.async)return(l instanceof Promise?l:Promise.resolve(l)).then((m)=>(a.value=m,a.fallback=!0,a));if(l instanceof Promise)throw new V;return a.value=l,a.fallback=!0,a}});function mo(e,r){if(r===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var nr=z("$ZodOptional",(e,r)=>{I.init(e,r),e._zod.optin="optional",e._zod.optout="optional",S(e._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,void 0]):void 0),S(e._zod,"pattern",()=>{let a=r.innerType._zod.pattern;return a?new RegExp(`^(${ke(a.source)})?$`):void 0}),e._zod.parse=(a,p)=>{if(r.innerType._zod.optin==="optional"){let l=a.value,f=r.innerType._zod.run(a,p);if(f instanceof Promise)return f.then((m)=>mo(m,l));return mo(f,l)}if(a.value===void 0)return a;return r.innerType._zod.run(a,p)}}),pn=z("$ZodExactOptional",(e,r)=>{nr.init(e,r),S(e._zod,"values",()=>r.innerType._zod.values),S(e._zod,"pattern",()=>r.innerType._zod.pattern),e._zod.parse=(a,p)=>r.innerType._zod.run(a,p)}),ln=z("$ZodNullable",(e,r)=>{I.init(e,r),S(e._zod,"optin",()=>r.innerType._zod.optin),S(e._zod,"optout",()=>r.innerType._zod.optout),S(e._zod,"pattern",()=>{let a=r.innerType._zod.pattern;return a?new RegExp(`^(${ke(a.source)}|null)$`):void 0}),S(e._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,null]):void 0),e._zod.parse=(a,p)=>{if(a.value===null)return a;return r.innerType._zod.run(a,p)}}),fn=z("$ZodDefault",(e,r)=>{I.init(e,r),e._zod.optin="optional",S(e._zod,"values",()=>r.innerType._zod.values),e._zod.parse=(a,p)=>{if(p.direction==="backward")return r.innerType._zod.run(a,p);if(a.value===void 0)return a.value=r.defaultValue,a;let l=r.innerType._zod.run(a,p);if(l instanceof Promise)return l.then((f)=>ho(f,r));return ho(l,r)}});function ho(e,r){if(e.value===void 0)e.value=r.defaultValue;return e}var dn=z("$ZodPrefault",(e,r)=>{I.init(e,r),e._zod.optin="optional",S(e._zod,"values",()=>r.innerType._zod.values),e._zod.parse=(a,p)=>{if(p.direction==="backward")return r.innerType._zod.run(a,p);if(a.value===void 0)a.value=r.defaultValue;return r.innerType._zod.run(a,p)}}),mn=z("$ZodNonOptional",(e,r)=>{I.init(e,r),S(e._zod,"values",()=>{let a=r.innerType._zod.values;return a?new Set([...a].filter((p)=>p!==void 0)):void 0}),e._zod.parse=(a,p)=>{let l=r.innerType._zod.run(a,p);if(l instanceof Promise)return l.then((f)=>_o(f,e));return _o(l,e)}});function _o(e,r){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:r});return e}var hn=z("$ZodCatch",(e,r)=>{I.init(e,r),e._zod.optin="optional",S(e._zod,"optout",()=>r.innerType._zod.optout),S(e._zod,"values",()=>r.innerType._zod.values),e._zod.parse=(a,p)=>{if(p.direction==="backward")return r.innerType._zod.run(a,p);let l=r.innerType._zod.run(a,p);if(l instanceof Promise)return l.then((f)=>{if(a.value=f.value,f.issues.length)a.value=r.catchValue({...a,error:{issues:f.issues.map((m)=>J(m,p,L()))},input:a.value}),a.issues=[],a.fallback=!0;return a});if(a.value=l.value,l.issues.length)a.value=r.catchValue({...a,error:{issues:l.issues.map((f)=>J(f,p,L()))},input:a.value}),a.issues=[],a.fallback=!0;return a}});var _n=z("$ZodPipe",(e,r)=>{I.init(e,r),S(e._zod,"values",()=>r.in._zod.values),S(e._zod,"optin",()=>r.in._zod.optin),S(e._zod,"optout",()=>r.out._zod.optout),S(e._zod,"propValues",()=>r.in._zod.propValues),e._zod.parse=(a,p)=>{if(p.direction==="backward"){let f=r.out._zod.run(a,p);if(f instanceof Promise)return f.then((m)=>Te(m,r.in,p));return Te(f,r.in,p)}let l=r.in._zod.run(a,p);if(l instanceof Promise)return l.then((f)=>Te(f,r.out,p));return Te(l,r.out,p)}});function Te(e,r,a){if(e.issues.length)return e.aborted=!0,e;return r._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},a)}var gn=z("$ZodReadonly",(e,r)=>{I.init(e,r),S(e._zod,"propValues",()=>r.innerType._zod.propValues),S(e._zod,"values",()=>r.innerType._zod.values),S(e._zod,"optin",()=>r.innerType?._zod?.optin),S(e._zod,"optout",()=>r.innerType?._zod?.optout),e._zod.parse=(a,p)=>{if(p.direction==="backward")return r.innerType._zod.run(a,p);let l=r.innerType._zod.run(a,p);if(l instanceof Promise)return l.then(go);return go(l)}});function go(e){return e.value=Object.freeze(e.value),e}var xn=z("$ZodLazy",(e,r)=>{I.init(e,r),S(e._zod,"innerType",()=>{let a=r;if(!a._cachedInner)a._cachedInner=r.getter();return a._cachedInner}),S(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),S(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),S(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),S(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(a,p)=>e._zod.innerType._zod.run(a,p)}),zn=z("$ZodCustom",(e,r)=>{D.init(e,r),I.init(e,r),e._zod.parse=(a,p)=>a,e._zod.check=(a)=>{let p=a.value,l=r.fn(p);if(l instanceof Promise)return l.then((f)=>xo(f,a,p,e));xo(l,a,p,e);return}});function xo(e,r,a,p){if(!e){let l={code:"custom",input:a,inst:p,path:[...p._zod.def.path??[]],continue:!p._zod.def.abort};if(p._zod.def.params)l.params=p._zod.def.params;r.issues.push(te(l))}}var vn,Rc=Symbol("ZodOutput"),Dc=Symbol("ZodInput");class yn{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let a=r[0];if(this._map.set(e,a),a&&typeof a==="object"&&"id"in a)this._idmap.set(a.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);if(r&&typeof r==="object"&&"id"in r)this._idmap.delete(r.id);return this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let a={...this.get(r)??{}};delete a.id;let p={...a,...this._map.get(e)};return Object.keys(p).length?p:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function li(){return new yn}(vn=globalThis).__zod_globalRegistry??(vn.__zod_globalRegistry=li());var oe=globalThis.__zod_globalRegistry;function $n(e,r){return new e({type:"string",...b(r)})}function bn(e,r){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(r)})}function je(e,r){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(r)})}function sr(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(r)})}function wn(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(r)})}function kn(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(r)})}function Zn(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(r)})}function ir(e,r){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(r)})}function Pn(e,r){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(r)})}function Sn(e,r){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(r)})}function On(e,r){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(r)})}function En(e,r){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(r)})}function In(e,r){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(r)})}function Tn(e,r){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(r)})}function Nn(e,r){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(r)})}function An(e,r){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(r)})}function jn(e,r){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(r)})}function Cn(e,r){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(r)})}function Rn(e,r){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(r)})}function Dn(e,r){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(r)})}function Ln(e,r){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(r)})}function Fn(e,r){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(r)})}function Un(e,r){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(r)})}function Mn(e,r){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(r)})}function Jn(e,r){return new e({type:"string",format:"date",check:"string_format",...b(r)})}function Bn(e,r){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(r)})}function Vn(e,r){return new e({type:"string",format:"duration",check:"string_format",...b(r)})}function Wn(e,r){return new e({type:"number",checks:[],...b(r)})}function Kn(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(r)})}function Gn(e,r){return new e({type:"boolean",...b(r)})}function qn(e,r){return new e({type:"null",...b(r)})}function Yn(e){return new e({type:"unknown"})}function Xn(e,r){return new e({type:"never",...b(r)})}function Ce(e,r){return new He({check:"less_than",...b(r),value:e,inclusive:!1})}function me(e,r){return new He({check:"less_than",...b(r),value:e,inclusive:!0})}function Re(e,r){return new Qe({check:"greater_than",...b(r),value:e,inclusive:!1})}function he(e,r){return new Qe({check:"greater_than",...b(r),value:e,inclusive:!0})}function De(e,r){return new Yt({check:"multiple_of",...b(r),value:e})}function Le(e,r){return new Ht({check:"max_length",...b(r),maximum:e})}function ie(e,r){return new Qt({check:"min_length",...b(r),minimum:e})}function Fe(e,r){return new eo({check:"length_equals",...b(r),length:e})}function cr(e,r){return new ro({check:"string_format",format:"regex",...b(r),pattern:e})}function ur(e){return new to({check:"string_format",format:"lowercase",...b(e)})}function ar(e){return new oo({check:"string_format",format:"uppercase",...b(e)})}function pr(e,r){return new no({check:"string_format",format:"includes",...b(r),includes:e})}function lr(e,r){return new so({check:"string_format",format:"starts_with",...b(r),prefix:e})}function fr(e,r){return new io({check:"string_format",format:"ends_with",...b(r),suffix:e})}function X(e){return new co({check:"overwrite",tx:e})}function dr(e){return X((r)=>r.normalize(e))}function mr(){return X((e)=>e.trim())}function hr(){return X((e)=>e.toLowerCase())}function _r(){return X((e)=>e.toUpperCase())}function gr(){return X((e)=>et(e))}function Hn(e,r,a){return new e({type:"array",element:r,...b(a)})}function Qn(e,r,a){let p=b(a);return p.abort??(p.abort=!0),new e({type:"custom",check:"custom",fn:r,...p})}function es(e,r,a){return new e({type:"custom",check:"custom",fn:r,...b(a)})}function rs(e,r){let a=fi((p)=>(p.addIssue=(l)=>{if(typeof l==="string")p.issues.push(te(l,p.value,a._zod.def));else{let f=l;if(f.fatal)f.continue=!1;f.code??(f.code="custom"),f.input??(f.input=p.value),f.inst??(f.inst=a),f.continue??(f.continue=!a._zod.def.abort),p.issues.push(te(f))}},e(p.value,p)),r);return a}function fi(e,r){let a=new D({check:"custom",...b(r)});return a._zod.check=e,a}function ge(e){let r=e?.target??"draft-2020-12";if(r==="draft-4")r="draft-04";if(r==="draft-7")r="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??oe,target:r,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function E(e,r,a={path:[],schemaPath:[]}){var p;let l=e._zod.def,f=r.seen.get(e);if(f){if(f.count++,a.schemaPath.includes(e))f.cycle=a.path;return f.schema}let m={schema:{},count:1,cycle:void 0,path:a.path};r.seen.set(e,m);let h=e._zod.toJSONSchema?.();if(h)m.schema=h;else{let v={...a,schemaPath:[...a.schemaPath,e],path:a.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(r,m.schema,v);else{let P=m.schema,Z=r.processors[l.type];if(!Z)throw Error(`[toJSONSchema]: Non-representable type encountered: ${l.type}`);Z(e,r,P,v)}let w=e._zod.parent;if(w){if(!m.ref)m.ref=w;E(w,r,v),r.seen.get(w).isParent=!0}}let _=r.metadataRegistry.get(e);if(_)Object.assign(m.schema,_);if(r.io==="input"&&F(e))delete m.schema.examples,delete m.schema.default;if(r.io==="input"&&"_prefault"in m.schema)(p=m.schema).default??(p.default=m.schema._prefault);return delete m.schema._prefault,r.seen.get(e).schema}function xe(e,r){let a=e.seen.get(r);if(!a)throw Error("Unprocessed schema. This is a bug in Zod.");let p=new Map;for(let m of e.seen.entries()){let h=e.metadataRegistry.get(m[0])?.id;if(h){let _=p.get(h);if(_&&_!==m[0])throw Error(`Duplicate schema id "${h}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);p.set(h,m[0])}}let l=(m)=>{let h=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let w=e.external.registry.get(m[0])?.id,P=e.external.uri??((O)=>O);if(w)return{ref:P(w)};let Z=m[1].defId??m[1].schema.id??`schema${e.counter++}`;return m[1].defId=Z,{defId:Z,ref:`${P("__shared")}#/${h}/${Z}`}}if(m[1]===a)return{ref:"#"};let x=`${"#"}/${h}/`,v=m[1].schema.id??`__schema${e.counter++}`;return{defId:v,ref:x+v}},f=(m)=>{if(m[1].schema.$ref)return;let h=m[1],{ref:_,defId:x}=l(m);if(h.def={...h.schema},x)h.defId=x;let v=h.schema;for(let w in v)delete v[w];v.$ref=_};if(e.cycles==="throw")for(let m of e.seen.entries()){let h=m[1];if(h.cycle)throw Error(`Cycle detected: #/${h.cycle?.join("/")}/<root>
64
64
 
65
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let m of e.seen.entries()){let h=m[1];if(r===m[0]){f(m);continue}if(e.external){let x=e.external.registry.get(m[0])?.id;if(r!==m[0]&&x){f(m);continue}}if(e.metadataRegistry.get(m[0])?.id){f(m);continue}if(h.cycle){f(m);continue}if(h.count>1){if(e.reused==="ref"){f(m);continue}}}}function ze(e,r){let a=e.seen.get(r);if(!a)throw Error("Unprocessed schema. This is a bug in Zod.");let p=(h)=>{let _=e.seen.get(h);if(_.ref===null)return;let x=_.def??_.schema,v={...x},w=_.ref;if(_.ref=null,w){p(w);let Z=e.seen.get(w),O=Z.schema;if(O.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))x.allOf=x.allOf??[],x.allOf.push(O);else Object.assign(x,O);if(Object.assign(x,v),h._zod.parent===w)for(let C in x){if(C==="$ref"||C==="allOf")continue;if(!(C in v))delete x[C]}if(O.$ref&&Z.def)for(let C in x){if(C==="$ref"||C==="allOf")continue;if(C in Z.def&&JSON.stringify(x[C])===JSON.stringify(Z.def[C]))delete x[C]}}let P=h._zod.parent;if(P&&P!==w){p(P);let Z=e.seen.get(P);if(Z?.schema.$ref){if(x.$ref=Z.schema.$ref,Z.def)for(let O in x){if(O==="$ref"||O==="allOf")continue;if(O in Z.def&&JSON.stringify(x[O])===JSON.stringify(Z.def[O]))delete x[O]}}}e.override({zodSchema:h,jsonSchema:x,path:_.path??[]})};for(let h of[...e.seen.entries()].reverse())p(h[0]);let l={};if(e.target==="draft-2020-12")l.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")l.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")l.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let h=e.external.registry.get(r)?.id;if(!h)throw Error("Schema is missing an `id` property");l.$id=e.external.uri(h)}Object.assign(l,a.def??a.schema);let f=e.metadataRegistry.get(r)?.id;if(f!==void 0&&l.id===f)delete l.id;let m=e.external?.defs??{};for(let h of e.seen.entries()){let _=h[1];if(_.def&&_.defId){if(_.def.id===_.defId)delete _.def.id;m[_.defId]=_.def}}if(e.external);else if(Object.keys(m).length>0)if(e.target==="draft-2020-12")l.$defs=m;else l.definitions=m;try{let h=JSON.parse(JSON.stringify(l));return Object.defineProperty(h,"~standard",{value:{...r["~standard"],jsonSchema:{input:_e(r,"input",e.processors),output:_e(r,"output",e.processors)}},enumerable:!1,writable:!1}),h}catch(h){throw Error("Error converting schema to JSON.")}}function F(e,r){let a=r??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);let p=e._zod.def;if(p.type==="transform")return!0;if(p.type==="array")return F(p.element,a);if(p.type==="set")return F(p.valueType,a);if(p.type==="lazy")return F(p.getter(),a);if(p.type==="promise"||p.type==="optional"||p.type==="nonoptional"||p.type==="nullable"||p.type==="readonly"||p.type==="default"||p.type==="prefault")return F(p.innerType,a);if(p.type==="intersection")return F(p.left,a)||F(p.right,a);if(p.type==="record"||p.type==="map")return F(p.keyType,a)||F(p.valueType,a);if(p.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return F(p.in,a)||F(p.out,a)}if(p.type==="object"){for(let l in p.shape)if(F(p.shape[l],a))return!0;return!1}if(p.type==="union"){for(let l of p.options)if(F(l,a))return!0;return!1}if(p.type==="tuple"){for(let l of p.items)if(F(l,a))return!0;if(p.rest&&F(p.rest,a))return!0;return!1}return!1}var ts=(e,r={})=>(a)=>{let p=ge({...a,processors:r});return E(e,p),xe(p,e),ze(p,e)},_e=(e,r,a={})=>(p)=>{let{libraryOptions:l,target:f}=p??{},m=ge({...l??{},target:f,io:r,processors:a});return E(e,m),xe(m,e),ze(m,e)};var di={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},xr=(e,r,a,p)=>{let l=a;l.type="string";let{minimum:f,maximum:m,format:h,patterns:_,contentEncoding:x}=e._zod.bag;if(typeof f==="number")l.minLength=f;if(typeof m==="number")l.maxLength=m;if(h){if(l.format=di[h]??h,l.format==="")delete l.format;if(h==="time")delete l.format}if(x)l.contentEncoding=x;if(_&&_.size>0){let v=[..._];if(v.length===1)l.pattern=v[0].source;else if(v.length>1)l.allOf=[...v.map((w)=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:w.source}))]}},zr=(e,r,a,p)=>{let l=a,{minimum:f,maximum:m,format:h,multipleOf:_,exclusiveMaximum:x,exclusiveMinimum:v}=e._zod.bag;if(typeof h==="string"&&h.includes("int"))l.type="integer";else l.type="number";let w=typeof v==="number"&&v>=(f??Number.NEGATIVE_INFINITY),P=typeof x==="number"&&x<=(m??Number.POSITIVE_INFINITY),Z=r.target==="draft-04"||r.target==="openapi-3.0";if(w)if(Z)l.minimum=v,l.exclusiveMinimum=!0;else l.exclusiveMinimum=v;else if(typeof f==="number")l.minimum=f;if(P)if(Z)l.maximum=x,l.exclusiveMaximum=!0;else l.exclusiveMaximum=x;else if(typeof m==="number")l.maximum=m;if(typeof _==="number")l.multipleOf=_},vr=(e,r,a,p)=>{a.type="boolean"},ns=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},ss=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},yr=(e,r,a,p)=>{if(r.target==="openapi-3.0")a.type="string",a.nullable=!0,a.enum=[null];else a.type="null"},is=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},cs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},$r=(e,r,a,p)=>{a.not={}},us=(e,r,a,p)=>{},br=(e,r,a,p)=>{},as=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},wr=(e,r,a,p)=>{let l=e._zod.def,f=be(l.entries);if(f.every((m)=>typeof m==="number"))a.type="number";if(f.every((m)=>typeof m==="string"))a.type="string";a.enum=f},kr=(e,r,a,p)=>{let l=e._zod.def,f=[];for(let m of l.values)if(m===void 0){if(r.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof m==="bigint")if(r.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else f.push(Number(m));else f.push(m);if(f.length===0);else if(f.length===1){let m=f[0];if(a.type=m===null?"null":typeof m,r.target==="draft-04"||r.target==="openapi-3.0")a.enum=[m];else a.const=m}else{if(f.every((m)=>typeof m==="number"))a.type="number";if(f.every((m)=>typeof m==="string"))a.type="string";if(f.every((m)=>typeof m==="boolean"))a.type="boolean";if(f.every((m)=>m===null))a.type="null";a.enum=f}},ps=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},ls=(e,r,a,p)=>{let l=a,f=e._zod.pattern;if(!f)throw Error("Pattern not found in template literal");l.type="string",l.pattern=f.source},fs=(e,r,a,p)=>{let l=a,f={type:"string",format:"binary",contentEncoding:"binary"},{minimum:m,maximum:h,mime:_}=e._zod.bag;if(m!==void 0)f.minLength=m;if(h!==void 0)f.maxLength=h;if(_)if(_.length===1)f.contentMediaType=_[0],Object.assign(l,f);else Object.assign(l,f),l.anyOf=_.map((x)=>({contentMediaType:x}));else Object.assign(l,f)},ds=(e,r,a,p)=>{a.type="boolean"},Zr=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},hs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},Pr=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},xs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},zs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},Sr=(e,r,a,p)=>{let l=a,f=e._zod.def,{minimum:m,maximum:h}=e._zod.bag;if(typeof m==="number")l.minItems=m;if(typeof h==="number")l.maxItems=h;l.type="array",l.items=E(f.element,r,{...p,path:[...p.path,"items"]})},Or=(e,r,a,p)=>{let l=a,f=e._zod.def;l.type="object",l.properties={};let m=f.shape;for(let x in m)l.properties[x]=E(m[x],r,{...p,path:[...p.path,"properties",x]});let h=new Set(Object.keys(m)),_=new Set([...h].filter((x)=>{let v=f.shape[x]._zod;if(r.io==="input")return v.optin===void 0;else return v.optout===void 0}));if(_.size>0)l.required=Array.from(_);if(f.catchall?._zod.def.type==="never")l.additionalProperties=!1;else if(!f.catchall){if(r.io==="output")l.additionalProperties=!1}else if(f.catchall)l.additionalProperties=E(f.catchall,r,{...p,path:[...p.path,"additionalProperties"]})},Er=(e,r,a,p)=>{let l=e._zod.def,f=l.inclusive===!1,m=l.options.map((h,_)=>E(h,r,{...p,path:[...p.path,f?"oneOf":"anyOf",_]}));if(f)a.oneOf=m;else a.anyOf=m},Ir=(e,r,a,p)=>{let l=e._zod.def,f=E(l.left,r,{...p,path:[...p.path,"allOf",0]}),m=E(l.right,r,{...p,path:[...p.path,"allOf",1]}),h=(x)=>("allOf"in x)&&Object.keys(x).length===1,_=[...h(f)?f.allOf:[f],...h(m)?m.allOf:[m]];a.allOf=_},vs=(e,r,a,p)=>{let l=a,f=e._zod.def;l.type="array";let m=r.target==="draft-2020-12"?"prefixItems":"items",h=r.target==="draft-2020-12"?"items":r.target==="openapi-3.0"?"items":"additionalItems",_=f.items.map((P,Z)=>E(P,r,{...p,path:[...p.path,m,Z]})),x=f.rest?E(f.rest,r,{...p,path:[...p.path,h,...r.target==="openapi-3.0"?[f.items.length]:[]]}):null;if(r.target==="draft-2020-12"){if(l.prefixItems=_,x)l.items=x}else if(r.target==="openapi-3.0"){if(l.items={anyOf:_},x)l.items.anyOf.push(x);if(l.minItems=_.length,!x)l.maxItems=_.length}else if(l.items=_,x)l.additionalItems=x;let{minimum:v,maximum:w}=e._zod.bag;if(typeof v==="number")l.minItems=v;if(typeof w==="number")l.maxItems=w},Tr=(e,r,a,p)=>{let l=a,f=e._zod.def;l.type="object";let m=f.keyType,_=m._zod.bag?.patterns;if(f.mode==="loose"&&_&&_.size>0){let v=E(f.valueType,r,{...p,path:[...p.path,"patternProperties","*"]});l.patternProperties={};for(let w of _)l.patternProperties[w.source]=v}else{if(r.target==="draft-07"||r.target==="draft-2020-12")l.propertyNames=E(f.keyType,r,{...p,path:[...p.path,"propertyNames"]});l.additionalProperties=E(f.valueType,r,{...p,path:[...p.path,"additionalProperties"]})}let x=m._zod.values;if(x){let v=[...x].filter((w)=>typeof w==="string"||typeof w==="number");if(v.length>0)l.required=v}},Nr=(e,r,a,p)=>{let l=e._zod.def,f=E(l.innerType,r,p),m=r.seen.get(e);if(r.target==="openapi-3.0")m.ref=l.innerType,a.nullable=!0;else a.anyOf=[f,{type:"null"}]},Ar=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType},jr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType,a.default=JSON.parse(JSON.stringify(l.defaultValue))},Cr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);if(f.ref=l.innerType,r.io==="input")a._prefault=JSON.parse(JSON.stringify(l.defaultValue))},Rr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType;let m;try{m=l.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}a.default=m},Dr=(e,r,a,p)=>{let l=e._zod.def,f=l.in._zod.traits.has("$ZodTransform"),m=r.io==="input"?f?l.out:l.in:l.out;E(m,r,p);let h=r.seen.get(e);h.ref=m},Lr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType,a.readOnly=!0},$s=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType},Ue=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType},Fr=(e,r,a,p)=>{let l=e._zod.innerType;E(l,r,p);let f=r.seen.get(e);f.ref=l},os={string:xr,number:zr,boolean:vr,bigint:ns,symbol:ss,null:yr,undefined:is,void:cs,never:$r,any:us,unknown:br,date:as,enum:wr,literal:kr,nan:ps,template_literal:ls,file:fs,success:ds,custom:Zr,function:hs,transform:Pr,map:xs,set:zs,array:Sr,object:Or,union:Er,intersection:Ir,tuple:vs,record:Tr,nullable:Nr,nonoptional:Ar,default:jr,prefault:Cr,catch:Rr,pipe:Dr,readonly:Lr,promise:$s,optional:Ue,lazy:Fr};function an(e,r){if("_idmap"in e){let p=e,l=ge({...r,processors:os}),f={};for(let _ of p._idmap.entries()){let[x,v]=_;E(v,l)}let m={},h={registry:p,uri:r?.uri,defs:f};l.external=h;for(let _ of p._idmap.entries()){let[x,v]=_;xe(l,v),m[x]=ze(l,v)}if(Object.keys(f).length>0){let _=l.target==="draft-2020-12"?"$defs":"definitions";m.__shared={[_]:f}}return{schemas:m}}let a=ge({...r,processors:os});return E(e,a),xe(a,e),ze(a,e)}var y={};ys(y,{ZodISODate:()=>ws,ZodISODateTime:()=>bs,ZodISODuration:()=>Zs,ZodISOTime:()=>ks,date:()=>Mr,datetime:()=>Ur,duration:()=>Br,time:()=>Jr});var bs=z("ZodISODateTime",(e,r)=>{Io.init(e,r),A.init(e,r)});function Ur(e){return Mn(bs,e)}var ws=z("ZodISODate",(e,r)=>{To.init(e,r),A.init(e,r)});function Mr(e){return Jn(ws,e)}var ks=z("ZodISOTime",(e,r)=>{No.init(e,r),A.init(e,r)});function Jr(e){return Bn(ks,e)}var Zs=z("ZodISODuration",(e,r)=>{Ao.init(e,r),A.init(e,r)});function Br(e){return Vn(Zs,e)}var yi=(e,r)=>{Pe.init(e,r),e.name="ZodError",Object.defineProperties(e,{format:{value:(a)=>ut(e,a)},flatten:{value:(a)=>ct(e,a)},addIssue:{value:(a)=>{e.issues.push(a),e.message=JSON.stringify(e.issues,ae,2)}},addIssues:{value:(a)=>{e.issues.push(...a),e.message=JSON.stringify(e.issues,ae,2)}},isEmpty:{get(){return e.issues.length===0}}})};var U=z("ZodError",yi,{Parent:Error});var Ps=Se(U),Ss=Oe(U),Os=le(U),Es=fe(U),Is=lt(U),Ts=ft(U),Ns=dt(U),As=mt(U),js=ht(U),Cs=_t(U),Rs=gt(U),Ds=xt(U);var Ls=new WeakMap;function ye(e,r,a){let p=Object.getPrototypeOf(e),l=Ls.get(p);if(!l)l=new Set,Ls.set(p,l);if(l.has(r))return;l.add(r);for(let f in a){let m=a[f];Object.defineProperty(p,f,{configurable:!0,enumerable:!1,get(){let h=m.bind(this);return Object.defineProperty(this,f,{configurable:!0,writable:!0,enumerable:!0,value:h}),h},set(h){Object.defineProperty(this,f,{configurable:!0,writable:!0,enumerable:!0,value:h})}})}}var N=z("ZodType",(e,r)=>(I.init(e,r),Object.assign(e["~standard"],{jsonSchema:{input:_e(e,"input"),output:_e(e,"output")}}),e.toJSONSchema=ts(e,{}),e.def=r,e.type=r.type,Object.defineProperty(e,"_def",{value:r}),e.parse=(a,p)=>Ps(e,a,p,{callee:e.parse}),e.safeParse=(a,p)=>Os(e,a,p),e.parseAsync=async(a,p)=>Ss(e,a,p,{callee:e.parseAsync}),e.safeParseAsync=async(a,p)=>Es(e,a,p),e.spa=e.safeParseAsync,e.encode=(a,p)=>Is(e,a,p),e.decode=(a,p)=>Ts(e,a,p),e.encodeAsync=async(a,p)=>Ns(e,a,p),e.decodeAsync=async(a,p)=>As(e,a,p),e.safeEncode=(a,p)=>js(e,a,p),e.safeDecode=(a,p)=>Cs(e,a,p),e.safeEncodeAsync=async(a,p)=>Rs(e,a,p),e.safeDecodeAsync=async(a,p)=>Ds(e,a,p),ye(e,"ZodType",{check(...a){let p=this.def;return this.clone(K(p,{checks:[...p.checks??[],...a.map((l)=>typeof l==="function"?{_zod:{check:l,def:{check:"custom"},onattach:[]}}:l)]}),{parent:!0})},with(...a){return this.check(...a)},clone(a,p){return M(this,a,p)},brand(){return this},register(a,p){return a.add(this,p),this},refine(a,p){return this.check(hc(a,p))},superRefine(a,p){return this.check(_c(a,p))},overwrite(a){return this.check(X(a))},optional(){return Us(this)},exactOptional(){return tc(this)},nullable(){return Ms(this)},nullish(){return Us(Ms(this))},nonoptional(a){return uc(this,a)},array(){return u(this)},or(a){return W([this,a])},and(a){return Xi(this,a)},transform(a){return Js(this,ec(a))},default(a){return sc(this,a)},prefault(a){return cc(this,a)},catch(a){return pc(this,a)},pipe(a){return Js(this,a)},readonly(){return dc(this)},describe(a){let p=this.clone();return oe.add(p,{description:a}),p},meta(...a){if(a.length===0)return oe.get(this);let p=this.clone();return oe.add(p,a[0]),p},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(a){return a(this)}}),Object.defineProperty(e,"description",{get(){return oe.get(e)?.description},configurable:!0}),e)),Bs=z("_ZodString",(e,r)=>{Ae.init(e,r),N.init(e,r),e._zod.processJSONSchema=(p,l,f)=>xr(e,p,l,f);let a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null,ye(e,"_ZodString",{regex(...p){return this.check(cr(...p))},includes(...p){return this.check(pr(...p))},startsWith(...p){return this.check(lr(...p))},endsWith(...p){return this.check(fr(...p))},min(...p){return this.check(ie(...p))},max(...p){return this.check(Le(...p))},length(...p){return this.check(Fe(...p))},nonempty(...p){return this.check(ie(1,...p))},lowercase(p){return this.check(ur(p))},uppercase(p){return this.check(ar(p))},trim(){return this.check(mr())},normalize(...p){return this.check(dr(...p))},toLowerCase(){return this.check(hr())},toUpperCase(){return this.check(_r())},slugify(){return this.check(gr())}})}),wi=z("ZodString",(e,r)=>{Ae.init(e,r),Bs.init(e,r),e.email=(a)=>e.check(bn(ki,a)),e.url=(a)=>e.check(ir(Vs,a)),e.jwt=(a)=>e.check(Un(Fi,a)),e.emoji=(a)=>e.check(Pn(Zi,a)),e.guid=(a)=>e.check(je(Vr,a)),e.uuid=(a)=>e.check(sr(ve,a)),e.uuidv4=(a)=>e.check(wn(ve,a)),e.uuidv6=(a)=>e.check(kn(ve,a)),e.uuidv7=(a)=>e.check(Zn(ve,a)),e.nanoid=(a)=>e.check(Sn(Pi,a)),e.guid=(a)=>e.check(je(Vr,a)),e.cuid=(a)=>e.check(On(Si,a)),e.cuid2=(a)=>e.check(En(Oi,a)),e.ulid=(a)=>e.check(In(Ei,a)),e.base64=(a)=>e.check(Dn(Ri,a)),e.base64url=(a)=>e.check(Ln(Di,a)),e.xid=(a)=>e.check(Tn(Ii,a)),e.ksuid=(a)=>e.check(Nn(Ti,a)),e.ipv4=(a)=>e.check(An(Ni,a)),e.ipv6=(a)=>e.check(jn(Ai,a)),e.cidrv4=(a)=>e.check(Cn(ji,a)),e.cidrv6=(a)=>e.check(Rn(Ci,a)),e.e164=(a)=>e.check(Fn(Li,a)),e.datetime=(a)=>e.check(Ur(a)),e.date=(a)=>e.check(Mr(a)),e.time=(a)=>e.check(Jr(a)),e.duration=(a)=>e.check(Br(a))});function t(e){return $n(wi,e)}var A=z("ZodStringFormat",(e,r)=>{T.init(e,r),Bs.init(e,r)}),ki=z("ZodEmail",(e,r)=>{yo.init(e,r),A.init(e,r)});var Vr=z("ZodGUID",(e,r)=>{zo.init(e,r),A.init(e,r)});function Ct(e){return je(Vr,e)}var ve=z("ZodUUID",(e,r)=>{vo.init(e,r),A.init(e,r)});function k(e){return sr(ve,e)}var Vs=z("ZodURL",(e,r)=>{$o.init(e,r),A.init(e,r)});function At(e){return ir(Vs,e)}var Zi=z("ZodEmoji",(e,r)=>{bo.init(e,r),A.init(e,r)});var Pi=z("ZodNanoID",(e,r)=>{wo.init(e,r),A.init(e,r)});var Si=z("ZodCUID",(e,r)=>{ko.init(e,r),A.init(e,r)});var Oi=z("ZodCUID2",(e,r)=>{Po.init(e,r),A.init(e,r)});var Ei=z("ZodULID",(e,r)=>{So.init(e,r),A.init(e,r)});var Ii=z("ZodXID",(e,r)=>{Oo.init(e,r),A.init(e,r)});var Ti=z("ZodKSUID",(e,r)=>{Eo.init(e,r),A.init(e,r)});var Ni=z("ZodIPv4",(e,r)=>{jo.init(e,r),A.init(e,r)});var Ai=z("ZodIPv6",(e,r)=>{Co.init(e,r),A.init(e,r)});var ji=z("ZodCIDRv4",(e,r)=>{Ro.init(e,r),A.init(e,r)});var Ci=z("ZodCIDRv6",(e,r)=>{Do.init(e,r),A.init(e,r)});var Ri=z("ZodBase64",(e,r)=>{Fo.init(e,r),A.init(e,r)});var Di=z("ZodBase64URL",(e,r)=>{Uo.init(e,r),A.init(e,r)});var Li=z("ZodE164",(e,r)=>{Mo.init(e,r),A.init(e,r)});var Fi=z("ZodJWT",(e,r)=>{Jo.init(e,r),A.init(e,r)});var Ws=z("ZodNumber",(e,r)=>{tr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(p,l,f)=>zr(e,p,l,f),ye(e,"ZodNumber",{gt(p,l){return this.check(Re(p,l))},gte(p,l){return this.check(he(p,l))},min(p,l){return this.check(he(p,l))},lt(p,l){return this.check(Ce(p,l))},lte(p,l){return this.check(me(p,l))},max(p,l){return this.check(me(p,l))},int(p){return this.check(Fs(p))},safe(p){return this.check(Fs(p))},positive(p){return this.check(Re(0,p))},nonnegative(p){return this.check(he(0,p))},negative(p){return this.check(Ce(0,p))},nonpositive(p){return this.check(me(0,p))},multipleOf(p,l){return this.check(De(p,l))},step(p,l){return this.check(De(p,l))},finite(){return this}});let a=e._zod.bag;e.minValue=Math.max(a.minimum??Number.NEGATIVE_INFINITY,a.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(a.maximum??Number.POSITIVE_INFINITY,a.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(a.format??"").includes("int")||Number.isSafeInteger(a.multipleOf??0.5),e.isFinite=!0,e.format=a.format??null});function o(e){return Wn(Ws,e)}var Ui=z("ZodNumberFormat",(e,r)=>{Bo.init(e,r),Ws.init(e,r)});function Fs(e){return Kn(Ui,e)}var Ji=z("ZodBoolean",(e,r)=>{Vo.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>vr(e,a,p,l)});function d(e){return Gn(Ji,e)}var Vi=z("ZodNull",(e,r)=>{Wo.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>yr(e,a,p,l)});function ms(e){return qn(Vi,e)}var Wi=z("ZodUnknown",(e,r)=>{Ko.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>br(e,a,p,l)});function Ie(){return Yn(Wi)}var Ki=z("ZodNever",(e,r)=>{Go.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>$r(e,a,p,l)});function Bi(e){return Xn(Ki,e)}var Gi=z("ZodArray",(e,r)=>{qo.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Sr(e,a,p,l),e.element=r.element,ye(e,"ZodArray",{min(a,p){return this.check(ie(a,p))},nonempty(a){return this.check(ie(1,a))},max(a,p){return this.check(Le(a,p))},length(a,p){return this.check(Fe(a,p))},unwrap(){return this.element}})});function u(e,r){return Hn(Gi,e,r)}var Gr=z("ZodObject",(e,r)=>{en.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Or(e,a,p,l),S(e,"shape",()=>r.shape),ye(e,"ZodObject",{keyof(){return s(Object.keys(this._zod.def.shape))},catchall(a){return this.clone({...this._zod.def,catchall:a})},passthrough(){return this.clone({...this._zod.def,catchall:Ie()})},loose(){return this.clone({...this._zod.def,catchall:Ie()})},strict(){return this.clone({...this._zod.def,catchall:Bi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(a){return ri(this,a)},safeExtend(a){return ti(this,a)},merge(a){return oi(this,a)},pick(a){return Qs(this,a)},omit(a){return ei(this,a)},partial(...a){return ni(Gs,this,a[0])},required(...a){return si(qs,this,a[0])}})});function i(e,r){let a={type:"object",shape:e??{},...b(r)};return new Gr(a)}function c(e,r){return new Gr({type:"object",shape:e,catchall:Bi(),...b(r)})}function gs(e,r){return new Gr({type:"object",shape:e,catchall:Ie(),...b(r)})}var Ks=z("ZodUnion",(e,r)=>{or.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Er(e,a,p,l),e.options=r.options});function W(e,r){return new Ks({type:"union",options:e,...b(r)})}var qi=z("ZodDiscriminatedUnion",(e,r)=>{Ks.init(e,r),rn.init(e,r)});function g(e,r,a){return new qi({type:"union",options:r,discriminator:e,...b(a)})}var Yi=z("ZodIntersection",(e,r)=>{tn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ir(e,a,p,l)});function Xi(e,r){return new Yi({type:"intersection",left:e,right:r})}var Wr=z("ZodRecord",(e,r)=>{on.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Tr(e,a,p,l),e.keyType=r.keyType,e.valueType=r.valueType});function ee(e,r,a){if(!r||!r._zod)return new Wr({type:"record",keyType:t(),valueType:e,...b(r)});return new Wr({type:"record",keyType:e,valueType:r,...b(a)})}function _s(e,r,a){let p=M(e);return p._zod.values=void 0,new Wr({type:"record",keyType:p,valueType:r,...b(a)})}var Kr=z("ZodEnum",(e,r)=>{nn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(p,l,f)=>wr(e,p,l,f),e.enum=r.entries,e.options=Object.values(r.entries);let a=new Set(Object.keys(r.entries));e.extract=(p,l)=>{let f={};for(let m of p)if(a.has(m))f[m]=r.entries[m];else throw Error(`Key ${m} not found in enum`);return new Kr({...r,checks:[],...b(l),entries:f})},e.exclude=(p,l)=>{let f={...r.entries};for(let m of p)if(a.has(m))delete f[m];else throw Error(`Key ${m} not found in enum`);return new Kr({...r,checks:[],...b(l),entries:f})}});function s(e,r){let a=Array.isArray(e)?Object.fromEntries(e.map((p)=>[p,p])):e;return new Kr({type:"enum",entries:a,...b(r)})}var Hi=z("ZodLiteral",(e,r)=>{sn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>kr(e,a,p,l),e.values=new Set(r.values),Object.defineProperty(e,"value",{get(){if(r.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function n(e,r){return new Hi({type:"literal",values:Array.isArray(e)?e:[e],...b(r)})}var Qi=z("ZodTransform",(e,r)=>{un.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Pr(e,a,p,l),e._zod.parse=(a,p)=>{if(p.direction==="backward")throw new ue(e.constructor.name);a.addIssue=(f)=>{if(typeof f==="string")a.issues.push(te(f,a.value,r));else{let m=f;if(m.fatal)m.continue=!1;m.code??(m.code="custom"),m.input??(m.input=a.value),m.inst??(m.inst=e),a.issues.push(te(m))}};let l=r.transform(a.value,a);if(l instanceof Promise)return l.then((f)=>(a.value=f,a.fallback=!0,a));return a.value=l,a.fallback=!0,a}});function ec(e){return new Qi({type:"transform",transform:e})}var Gs=z("ZodOptional",(e,r)=>{nr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ue(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function Us(e){return new Gs({type:"optional",innerType:e})}var rc=z("ZodExactOptional",(e,r)=>{pn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ue(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function tc(e){return new rc({type:"optional",innerType:e})}var oc=z("ZodNullable",(e,r)=>{ln.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Nr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function Ms(e){return new oc({type:"nullable",innerType:e})}var nc=z("ZodDefault",(e,r)=>{fn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>jr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sc(e,r){return new nc({type:"default",innerType:e,get defaultValue(){return typeof r==="function"?r():Ke(r)}})}var ic=z("ZodPrefault",(e,r)=>{dn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Cr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function cc(e,r){return new ic({type:"prefault",innerType:e,get defaultValue(){return typeof r==="function"?r():Ke(r)}})}var qs=z("ZodNonOptional",(e,r)=>{mn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ar(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function uc(e,r){return new qs({type:"nonoptional",innerType:e,...b(r)})}var ac=z("ZodCatch",(e,r)=>{hn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Rr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pc(e,r){return new ac({type:"catch",innerType:e,catchValue:typeof r==="function"?r:()=>r})}var lc=z("ZodPipe",(e,r)=>{_n.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Dr(e,a,p,l),e.in=r.in,e.out=r.out});function Js(e,r){return new lc({type:"pipe",in:e,out:r})}var fc=z("ZodReadonly",(e,r)=>{gn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Lr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new fc({type:"readonly",innerType:e})}var mc=z("ZodLazy",(e,r)=>{xn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Fr(e,a,p,l),e.unwrap=()=>e._zod.def.getter()});function Zo(e){return new mc({type:"lazy",getter:e})}var Ys=z("ZodCustom",(e,r)=>{zn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Zr(e,a,p,l)});function cn(e,r){return Qn(Ys,e??(()=>!0),r)}function hc(e,r={}){return es(Ys,e,r)}function _c(e,r){return rs(e,r)}export{Xo,L,$i,Mi,Yo,an,y,t,Ct,k,At,o,d,ms,Ie,Bi,u,i,c,gs,W,g,ee,_s,s,n,Zo,cn};
65
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let m of e.seen.entries()){let h=m[1];if(r===m[0]){f(m);continue}if(e.external){let x=e.external.registry.get(m[0])?.id;if(r!==m[0]&&x){f(m);continue}}if(e.metadataRegistry.get(m[0])?.id){f(m);continue}if(h.cycle){f(m);continue}if(h.count>1){if(e.reused==="ref"){f(m);continue}}}}function ze(e,r){let a=e.seen.get(r);if(!a)throw Error("Unprocessed schema. This is a bug in Zod.");let p=(h)=>{let _=e.seen.get(h);if(_.ref===null)return;let x=_.def??_.schema,v={...x},w=_.ref;if(_.ref=null,w){p(w);let Z=e.seen.get(w),O=Z.schema;if(O.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))x.allOf=x.allOf??[],x.allOf.push(O);else Object.assign(x,O);if(Object.assign(x,v),h._zod.parent===w)for(let C in x){if(C==="$ref"||C==="allOf")continue;if(!(C in v))delete x[C]}if(O.$ref&&Z.def)for(let C in x){if(C==="$ref"||C==="allOf")continue;if(C in Z.def&&JSON.stringify(x[C])===JSON.stringify(Z.def[C]))delete x[C]}}let P=h._zod.parent;if(P&&P!==w){p(P);let Z=e.seen.get(P);if(Z?.schema.$ref){if(x.$ref=Z.schema.$ref,Z.def)for(let O in x){if(O==="$ref"||O==="allOf")continue;if(O in Z.def&&JSON.stringify(x[O])===JSON.stringify(Z.def[O]))delete x[O]}}}e.override({zodSchema:h,jsonSchema:x,path:_.path??[]})};for(let h of[...e.seen.entries()].reverse())p(h[0]);let l={};if(e.target==="draft-2020-12")l.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")l.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")l.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let h=e.external.registry.get(r)?.id;if(!h)throw Error("Schema is missing an `id` property");l.$id=e.external.uri(h)}Object.assign(l,a.def??a.schema);let f=e.metadataRegistry.get(r)?.id;if(f!==void 0&&l.id===f)delete l.id;let m=e.external?.defs??{};for(let h of e.seen.entries()){let _=h[1];if(_.def&&_.defId){if(_.def.id===_.defId)delete _.def.id;m[_.defId]=_.def}}if(e.external);else if(Object.keys(m).length>0)if(e.target==="draft-2020-12")l.$defs=m;else l.definitions=m;try{let h=JSON.parse(JSON.stringify(l));return Object.defineProperty(h,"~standard",{value:{...r["~standard"],jsonSchema:{input:_e(r,"input",e.processors),output:_e(r,"output",e.processors)}},enumerable:!1,writable:!1}),h}catch(h){throw Error("Error converting schema to JSON.")}}function F(e,r){let a=r??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);let p=e._zod.def;if(p.type==="transform")return!0;if(p.type==="array")return F(p.element,a);if(p.type==="set")return F(p.valueType,a);if(p.type==="lazy")return F(p.getter(),a);if(p.type==="promise"||p.type==="optional"||p.type==="nonoptional"||p.type==="nullable"||p.type==="readonly"||p.type==="default"||p.type==="prefault")return F(p.innerType,a);if(p.type==="intersection")return F(p.left,a)||F(p.right,a);if(p.type==="record"||p.type==="map")return F(p.keyType,a)||F(p.valueType,a);if(p.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return F(p.in,a)||F(p.out,a)}if(p.type==="object"){for(let l in p.shape)if(F(p.shape[l],a))return!0;return!1}if(p.type==="union"){for(let l of p.options)if(F(l,a))return!0;return!1}if(p.type==="tuple"){for(let l of p.items)if(F(l,a))return!0;if(p.rest&&F(p.rest,a))return!0;return!1}return!1}var ts=(e,r={})=>(a)=>{let p=ge({...a,processors:r});return E(e,p),xe(p,e),ze(p,e)},_e=(e,r,a={})=>(p)=>{let{libraryOptions:l,target:f}=p??{},m=ge({...l??{},target:f,io:r,processors:a});return E(e,m),xe(m,e),ze(m,e)};var di={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},xr=(e,r,a,p)=>{let l=a;l.type="string";let{minimum:f,maximum:m,format:h,patterns:_,contentEncoding:x}=e._zod.bag;if(typeof f==="number")l.minLength=f;if(typeof m==="number")l.maxLength=m;if(h){if(l.format=di[h]??h,l.format==="")delete l.format;if(h==="time")delete l.format}if(x)l.contentEncoding=x;if(_&&_.size>0){let v=[..._];if(v.length===1)l.pattern=v[0].source;else if(v.length>1)l.allOf=[...v.map((w)=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:w.source}))]}},zr=(e,r,a,p)=>{let l=a,{minimum:f,maximum:m,format:h,multipleOf:_,exclusiveMaximum:x,exclusiveMinimum:v}=e._zod.bag;if(typeof h==="string"&&h.includes("int"))l.type="integer";else l.type="number";let w=typeof v==="number"&&v>=(f??Number.NEGATIVE_INFINITY),P=typeof x==="number"&&x<=(m??Number.POSITIVE_INFINITY),Z=r.target==="draft-04"||r.target==="openapi-3.0";if(w)if(Z)l.minimum=v,l.exclusiveMinimum=!0;else l.exclusiveMinimum=v;else if(typeof f==="number")l.minimum=f;if(P)if(Z)l.maximum=x,l.exclusiveMaximum=!0;else l.exclusiveMaximum=x;else if(typeof m==="number")l.maximum=m;if(typeof _==="number")l.multipleOf=_},vr=(e,r,a,p)=>{a.type="boolean"},ns=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},ss=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},yr=(e,r,a,p)=>{if(r.target==="openapi-3.0")a.type="string",a.nullable=!0,a.enum=[null];else a.type="null"},is=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},cs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},$r=(e,r,a,p)=>{a.not={}},us=(e,r,a,p)=>{},br=(e,r,a,p)=>{},as=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},wr=(e,r,a,p)=>{let l=e._zod.def,f=be(l.entries);if(f.every((m)=>typeof m==="number"))a.type="number";if(f.every((m)=>typeof m==="string"))a.type="string";a.enum=f},kr=(e,r,a,p)=>{let l=e._zod.def,f=[];for(let m of l.values)if(m===void 0){if(r.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof m==="bigint")if(r.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else f.push(Number(m));else f.push(m);if(f.length===0);else if(f.length===1){let m=f[0];if(a.type=m===null?"null":typeof m,r.target==="draft-04"||r.target==="openapi-3.0")a.enum=[m];else a.const=m}else{if(f.every((m)=>typeof m==="number"))a.type="number";if(f.every((m)=>typeof m==="string"))a.type="string";if(f.every((m)=>typeof m==="boolean"))a.type="boolean";if(f.every((m)=>m===null))a.type="null";a.enum=f}},ps=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},ls=(e,r,a,p)=>{let l=a,f=e._zod.pattern;if(!f)throw Error("Pattern not found in template literal");l.type="string",l.pattern=f.source},fs=(e,r,a,p)=>{let l=a,f={type:"string",format:"binary",contentEncoding:"binary"},{minimum:m,maximum:h,mime:_}=e._zod.bag;if(m!==void 0)f.minLength=m;if(h!==void 0)f.maxLength=h;if(_)if(_.length===1)f.contentMediaType=_[0],Object.assign(l,f);else Object.assign(l,f),l.anyOf=_.map((x)=>({contentMediaType:x}));else Object.assign(l,f)},ds=(e,r,a,p)=>{a.type="boolean"},Zr=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},hs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},Pr=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},xs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},zs=(e,r,a,p)=>{if(r.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},Sr=(e,r,a,p)=>{let l=a,f=e._zod.def,{minimum:m,maximum:h}=e._zod.bag;if(typeof m==="number")l.minItems=m;if(typeof h==="number")l.maxItems=h;l.type="array",l.items=E(f.element,r,{...p,path:[...p.path,"items"]})},Or=(e,r,a,p)=>{let l=a,f=e._zod.def;l.type="object",l.properties={};let m=f.shape;for(let x in m)l.properties[x]=E(m[x],r,{...p,path:[...p.path,"properties",x]});let h=new Set(Object.keys(m)),_=new Set([...h].filter((x)=>{let v=f.shape[x]._zod;if(r.io==="input")return v.optin===void 0;else return v.optout===void 0}));if(_.size>0)l.required=Array.from(_);if(f.catchall?._zod.def.type==="never")l.additionalProperties=!1;else if(!f.catchall){if(r.io==="output")l.additionalProperties=!1}else if(f.catchall)l.additionalProperties=E(f.catchall,r,{...p,path:[...p.path,"additionalProperties"]})},Er=(e,r,a,p)=>{let l=e._zod.def,f=l.inclusive===!1,m=l.options.map((h,_)=>E(h,r,{...p,path:[...p.path,f?"oneOf":"anyOf",_]}));if(f)a.oneOf=m;else a.anyOf=m},Ir=(e,r,a,p)=>{let l=e._zod.def,f=E(l.left,r,{...p,path:[...p.path,"allOf",0]}),m=E(l.right,r,{...p,path:[...p.path,"allOf",1]}),h=(x)=>("allOf"in x)&&Object.keys(x).length===1,_=[...h(f)?f.allOf:[f],...h(m)?m.allOf:[m]];a.allOf=_},vs=(e,r,a,p)=>{let l=a,f=e._zod.def;l.type="array";let m=r.target==="draft-2020-12"?"prefixItems":"items",h=r.target==="draft-2020-12"?"items":r.target==="openapi-3.0"?"items":"additionalItems",_=f.items.map((P,Z)=>E(P,r,{...p,path:[...p.path,m,Z]})),x=f.rest?E(f.rest,r,{...p,path:[...p.path,h,...r.target==="openapi-3.0"?[f.items.length]:[]]}):null;if(r.target==="draft-2020-12"){if(l.prefixItems=_,x)l.items=x}else if(r.target==="openapi-3.0"){if(l.items={anyOf:_},x)l.items.anyOf.push(x);if(l.minItems=_.length,!x)l.maxItems=_.length}else if(l.items=_,x)l.additionalItems=x;let{minimum:v,maximum:w}=e._zod.bag;if(typeof v==="number")l.minItems=v;if(typeof w==="number")l.maxItems=w},Tr=(e,r,a,p)=>{let l=a,f=e._zod.def;l.type="object";let m=f.keyType,_=m._zod.bag?.patterns;if(f.mode==="loose"&&_&&_.size>0){let v=E(f.valueType,r,{...p,path:[...p.path,"patternProperties","*"]});l.patternProperties={};for(let w of _)l.patternProperties[w.source]=v}else{if(r.target==="draft-07"||r.target==="draft-2020-12")l.propertyNames=E(f.keyType,r,{...p,path:[...p.path,"propertyNames"]});l.additionalProperties=E(f.valueType,r,{...p,path:[...p.path,"additionalProperties"]})}let x=m._zod.values;if(x){let v=[...x].filter((w)=>typeof w==="string"||typeof w==="number");if(v.length>0)l.required=v}},Nr=(e,r,a,p)=>{let l=e._zod.def,f=E(l.innerType,r,p),m=r.seen.get(e);if(r.target==="openapi-3.0")m.ref=l.innerType,a.nullable=!0;else a.anyOf=[f,{type:"null"}]},Ar=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType},jr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType,a.default=JSON.parse(JSON.stringify(l.defaultValue))},Cr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);if(f.ref=l.innerType,r.io==="input")a._prefault=JSON.parse(JSON.stringify(l.defaultValue))},Rr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType;let m;try{m=l.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}a.default=m},Dr=(e,r,a,p)=>{let l=e._zod.def,f=l.in._zod.traits.has("$ZodTransform"),m=r.io==="input"?f?l.out:l.in:l.out;E(m,r,p);let h=r.seen.get(e);h.ref=m},Lr=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType,a.readOnly=!0},$s=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType},Ue=(e,r,a,p)=>{let l=e._zod.def;E(l.innerType,r,p);let f=r.seen.get(e);f.ref=l.innerType},Fr=(e,r,a,p)=>{let l=e._zod.innerType;E(l,r,p);let f=r.seen.get(e);f.ref=l},os={string:xr,number:zr,boolean:vr,bigint:ns,symbol:ss,null:yr,undefined:is,void:cs,never:$r,any:us,unknown:br,date:as,enum:wr,literal:kr,nan:ps,template_literal:ls,file:fs,success:ds,custom:Zr,function:hs,transform:Pr,map:xs,set:zs,array:Sr,object:Or,union:Er,intersection:Ir,tuple:vs,record:Tr,nullable:Nr,nonoptional:Ar,default:jr,prefault:Cr,catch:Rr,pipe:Dr,readonly:Lr,promise:$s,optional:Ue,lazy:Fr};function an(e,r){if("_idmap"in e){let p=e,l=ge({...r,processors:os}),f={};for(let _ of p._idmap.entries()){let[x,v]=_;E(v,l)}let m={},h={registry:p,uri:r?.uri,defs:f};l.external=h;for(let _ of p._idmap.entries()){let[x,v]=_;xe(l,v),m[x]=ze(l,v)}if(Object.keys(f).length>0){let _=l.target==="draft-2020-12"?"$defs":"definitions";m.__shared={[_]:f}}return{schemas:m}}let a=ge({...r,processors:os});return E(e,a),xe(a,e),ze(a,e)}var y={};ys(y,{ZodISODate:()=>ws,ZodISODateTime:()=>bs,ZodISODuration:()=>Zs,ZodISOTime:()=>ks,date:()=>Mr,datetime:()=>Ur,duration:()=>Br,time:()=>Jr});var bs=z("ZodISODateTime",(e,r)=>{Io.init(e,r),A.init(e,r)});function Ur(e){return Mn(bs,e)}var ws=z("ZodISODate",(e,r)=>{To.init(e,r),A.init(e,r)});function Mr(e){return Jn(ws,e)}var ks=z("ZodISOTime",(e,r)=>{No.init(e,r),A.init(e,r)});function Jr(e){return Bn(ks,e)}var Zs=z("ZodISODuration",(e,r)=>{Ao.init(e,r),A.init(e,r)});function Br(e){return Vn(Zs,e)}var yi=(e,r)=>{Pe.init(e,r),e.name="ZodError",Object.defineProperties(e,{format:{value:(a)=>ut(e,a)},flatten:{value:(a)=>ct(e,a)},addIssue:{value:(a)=>{e.issues.push(a),e.message=JSON.stringify(e.issues,ae,2)}},addIssues:{value:(a)=>{e.issues.push(...a),e.message=JSON.stringify(e.issues,ae,2)}},isEmpty:{get(){return e.issues.length===0}}})};var U=z("ZodError",yi,{Parent:Error});var Ps=Se(U),Ss=Oe(U),Os=le(U),Es=fe(U),Is=lt(U),Ts=ft(U),Ns=dt(U),As=mt(U),js=ht(U),Cs=_t(U),Rs=gt(U),Ds=xt(U);var Ls=new WeakMap;function ye(e,r,a){let p=Object.getPrototypeOf(e),l=Ls.get(p);if(!l)l=new Set,Ls.set(p,l);if(l.has(r))return;l.add(r);for(let f in a){let m=a[f];Object.defineProperty(p,f,{configurable:!0,enumerable:!1,get(){let h=m.bind(this);return Object.defineProperty(this,f,{configurable:!0,writable:!0,enumerable:!0,value:h}),h},set(h){Object.defineProperty(this,f,{configurable:!0,writable:!0,enumerable:!0,value:h})}})}}var N=z("ZodType",(e,r)=>(I.init(e,r),Object.assign(e["~standard"],{jsonSchema:{input:_e(e,"input"),output:_e(e,"output")}}),e.toJSONSchema=ts(e,{}),e.def=r,e.type=r.type,Object.defineProperty(e,"_def",{value:r}),e.parse=(a,p)=>Ps(e,a,p,{callee:e.parse}),e.safeParse=(a,p)=>Os(e,a,p),e.parseAsync=async(a,p)=>Ss(e,a,p,{callee:e.parseAsync}),e.safeParseAsync=async(a,p)=>Es(e,a,p),e.spa=e.safeParseAsync,e.encode=(a,p)=>Is(e,a,p),e.decode=(a,p)=>Ts(e,a,p),e.encodeAsync=async(a,p)=>Ns(e,a,p),e.decodeAsync=async(a,p)=>As(e,a,p),e.safeEncode=(a,p)=>js(e,a,p),e.safeDecode=(a,p)=>Cs(e,a,p),e.safeEncodeAsync=async(a,p)=>Rs(e,a,p),e.safeDecodeAsync=async(a,p)=>Ds(e,a,p),ye(e,"ZodType",{check(...a){let p=this.def;return this.clone(K(p,{checks:[...p.checks??[],...a.map((l)=>typeof l==="function"?{_zod:{check:l,def:{check:"custom"},onattach:[]}}:l)]}),{parent:!0})},with(...a){return this.check(...a)},clone(a,p){return M(this,a,p)},brand(){return this},register(a,p){return a.add(this,p),this},refine(a,p){return this.check(hc(a,p))},superRefine(a,p){return this.check(_c(a,p))},overwrite(a){return this.check(X(a))},optional(){return Us(this)},exactOptional(){return tc(this)},nullable(){return Ms(this)},nullish(){return Us(Ms(this))},nonoptional(a){return uc(this,a)},array(){return u(this)},or(a){return W([this,a])},and(a){return Xi(this,a)},transform(a){return Js(this,ec(a))},default(a){return sc(this,a)},prefault(a){return cc(this,a)},catch(a){return pc(this,a)},pipe(a){return Js(this,a)},readonly(){return dc(this)},describe(a){let p=this.clone();return oe.add(p,{description:a}),p},meta(...a){if(a.length===0)return oe.get(this);let p=this.clone();return oe.add(p,a[0]),p},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(a){return a(this)}}),Object.defineProperty(e,"description",{get(){return oe.get(e)?.description},configurable:!0}),e)),Bs=z("_ZodString",(e,r)=>{Ae.init(e,r),N.init(e,r),e._zod.processJSONSchema=(p,l,f)=>xr(e,p,l,f);let a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null,ye(e,"_ZodString",{regex(...p){return this.check(cr(...p))},includes(...p){return this.check(pr(...p))},startsWith(...p){return this.check(lr(...p))},endsWith(...p){return this.check(fr(...p))},min(...p){return this.check(ie(...p))},max(...p){return this.check(Le(...p))},length(...p){return this.check(Fe(...p))},nonempty(...p){return this.check(ie(1,...p))},lowercase(p){return this.check(ur(p))},uppercase(p){return this.check(ar(p))},trim(){return this.check(mr())},normalize(...p){return this.check(dr(...p))},toLowerCase(){return this.check(hr())},toUpperCase(){return this.check(_r())},slugify(){return this.check(gr())}})}),wi=z("ZodString",(e,r)=>{Ae.init(e,r),Bs.init(e,r),e.email=(a)=>e.check(bn(ki,a)),e.url=(a)=>e.check(ir(Vs,a)),e.jwt=(a)=>e.check(Un(Fi,a)),e.emoji=(a)=>e.check(Pn(Zi,a)),e.guid=(a)=>e.check(je(Vr,a)),e.uuid=(a)=>e.check(sr(ve,a)),e.uuidv4=(a)=>e.check(wn(ve,a)),e.uuidv6=(a)=>e.check(kn(ve,a)),e.uuidv7=(a)=>e.check(Zn(ve,a)),e.nanoid=(a)=>e.check(Sn(Pi,a)),e.guid=(a)=>e.check(je(Vr,a)),e.cuid=(a)=>e.check(On(Si,a)),e.cuid2=(a)=>e.check(En(Oi,a)),e.ulid=(a)=>e.check(In(Ei,a)),e.base64=(a)=>e.check(Dn(Ri,a)),e.base64url=(a)=>e.check(Ln(Di,a)),e.xid=(a)=>e.check(Tn(Ii,a)),e.ksuid=(a)=>e.check(Nn(Ti,a)),e.ipv4=(a)=>e.check(An(Ni,a)),e.ipv6=(a)=>e.check(jn(Ai,a)),e.cidrv4=(a)=>e.check(Cn(ji,a)),e.cidrv6=(a)=>e.check(Rn(Ci,a)),e.e164=(a)=>e.check(Fn(Li,a)),e.datetime=(a)=>e.check(Ur(a)),e.date=(a)=>e.check(Mr(a)),e.time=(a)=>e.check(Jr(a)),e.duration=(a)=>e.check(Br(a))});function t(e){return $n(wi,e)}var A=z("ZodStringFormat",(e,r)=>{T.init(e,r),Bs.init(e,r)}),ki=z("ZodEmail",(e,r)=>{yo.init(e,r),A.init(e,r)});var Vr=z("ZodGUID",(e,r)=>{zo.init(e,r),A.init(e,r)});function Ct(e){return je(Vr,e)}var ve=z("ZodUUID",(e,r)=>{vo.init(e,r),A.init(e,r)});function k(e){return sr(ve,e)}var Vs=z("ZodURL",(e,r)=>{$o.init(e,r),A.init(e,r)});function At(e){return ir(Vs,e)}var Zi=z("ZodEmoji",(e,r)=>{bo.init(e,r),A.init(e,r)});var Pi=z("ZodNanoID",(e,r)=>{wo.init(e,r),A.init(e,r)});var Si=z("ZodCUID",(e,r)=>{ko.init(e,r),A.init(e,r)});var Oi=z("ZodCUID2",(e,r)=>{Po.init(e,r),A.init(e,r)});var Ei=z("ZodULID",(e,r)=>{So.init(e,r),A.init(e,r)});var Ii=z("ZodXID",(e,r)=>{Oo.init(e,r),A.init(e,r)});var Ti=z("ZodKSUID",(e,r)=>{Eo.init(e,r),A.init(e,r)});var Ni=z("ZodIPv4",(e,r)=>{jo.init(e,r),A.init(e,r)});var Ai=z("ZodIPv6",(e,r)=>{Co.init(e,r),A.init(e,r)});var ji=z("ZodCIDRv4",(e,r)=>{Ro.init(e,r),A.init(e,r)});var Ci=z("ZodCIDRv6",(e,r)=>{Do.init(e,r),A.init(e,r)});var Ri=z("ZodBase64",(e,r)=>{Fo.init(e,r),A.init(e,r)});var Di=z("ZodBase64URL",(e,r)=>{Uo.init(e,r),A.init(e,r)});var Li=z("ZodE164",(e,r)=>{Mo.init(e,r),A.init(e,r)});var Fi=z("ZodJWT",(e,r)=>{Jo.init(e,r),A.init(e,r)});var Ws=z("ZodNumber",(e,r)=>{tr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(p,l,f)=>zr(e,p,l,f),ye(e,"ZodNumber",{gt(p,l){return this.check(Re(p,l))},gte(p,l){return this.check(he(p,l))},min(p,l){return this.check(he(p,l))},lt(p,l){return this.check(Ce(p,l))},lte(p,l){return this.check(me(p,l))},max(p,l){return this.check(me(p,l))},int(p){return this.check(Fs(p))},safe(p){return this.check(Fs(p))},positive(p){return this.check(Re(0,p))},nonnegative(p){return this.check(he(0,p))},negative(p){return this.check(Ce(0,p))},nonpositive(p){return this.check(me(0,p))},multipleOf(p,l){return this.check(De(p,l))},step(p,l){return this.check(De(p,l))},finite(){return this}});let a=e._zod.bag;e.minValue=Math.max(a.minimum??Number.NEGATIVE_INFINITY,a.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(a.maximum??Number.POSITIVE_INFINITY,a.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(a.format??"").includes("int")||Number.isSafeInteger(a.multipleOf??0.5),e.isFinite=!0,e.format=a.format??null});function o(e){return Wn(Ws,e)}var Ui=z("ZodNumberFormat",(e,r)=>{Bo.init(e,r),Ws.init(e,r)});function Fs(e){return Kn(Ui,e)}var Ji=z("ZodBoolean",(e,r)=>{Vo.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>vr(e,a,p,l)});function d(e){return Gn(Ji,e)}var Vi=z("ZodNull",(e,r)=>{Wo.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>yr(e,a,p,l)});function ms(e){return qn(Vi,e)}var Wi=z("ZodUnknown",(e,r)=>{Ko.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>br(e,a,p,l)});function Ie(){return Yn(Wi)}var Ki=z("ZodNever",(e,r)=>{Go.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>$r(e,a,p,l)});function Bi(e){return Xn(Ki,e)}var Gi=z("ZodArray",(e,r)=>{qo.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Sr(e,a,p,l),e.element=r.element,ye(e,"ZodArray",{min(a,p){return this.check(ie(a,p))},nonempty(a){return this.check(ie(1,a))},max(a,p){return this.check(Le(a,p))},length(a,p){return this.check(Fe(a,p))},unwrap(){return this.element}})});function u(e,r){return Hn(Gi,e,r)}var Gr=z("ZodObject",(e,r)=>{en.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Or(e,a,p,l),S(e,"shape",()=>r.shape),ye(e,"ZodObject",{keyof(){return s(Object.keys(this._zod.def.shape))},catchall(a){return this.clone({...this._zod.def,catchall:a})},passthrough(){return this.clone({...this._zod.def,catchall:Ie()})},loose(){return this.clone({...this._zod.def,catchall:Ie()})},strict(){return this.clone({...this._zod.def,catchall:Bi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(a){return ri(this,a)},safeExtend(a){return ti(this,a)},merge(a){return oi(this,a)},pick(a){return Qs(this,a)},omit(a){return ei(this,a)},partial(...a){return ni(Gs,this,a[0])},required(...a){return si(qs,this,a[0])}})});function n(e,r){let a={type:"object",shape:e??{},...b(r)};return new Gr(a)}function c(e,r){return new Gr({type:"object",shape:e,catchall:Bi(),...b(r)})}function gs(e,r){return new Gr({type:"object",shape:e,catchall:Ie(),...b(r)})}var Ks=z("ZodUnion",(e,r)=>{or.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Er(e,a,p,l),e.options=r.options});function W(e,r){return new Ks({type:"union",options:e,...b(r)})}var qi=z("ZodDiscriminatedUnion",(e,r)=>{Ks.init(e,r),rn.init(e,r)});function g(e,r,a){return new qi({type:"union",options:r,discriminator:e,...b(a)})}var Yi=z("ZodIntersection",(e,r)=>{tn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ir(e,a,p,l)});function Xi(e,r){return new Yi({type:"intersection",left:e,right:r})}var Wr=z("ZodRecord",(e,r)=>{on.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Tr(e,a,p,l),e.keyType=r.keyType,e.valueType=r.valueType});function ee(e,r,a){if(!r||!r._zod)return new Wr({type:"record",keyType:t(),valueType:e,...b(r)});return new Wr({type:"record",keyType:e,valueType:r,...b(a)})}function _s(e,r,a){let p=M(e);return p._zod.values=void 0,new Wr({type:"record",keyType:p,valueType:r,...b(a)})}var Kr=z("ZodEnum",(e,r)=>{nn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(p,l,f)=>wr(e,p,l,f),e.enum=r.entries,e.options=Object.values(r.entries);let a=new Set(Object.keys(r.entries));e.extract=(p,l)=>{let f={};for(let m of p)if(a.has(m))f[m]=r.entries[m];else throw Error(`Key ${m} not found in enum`);return new Kr({...r,checks:[],...b(l),entries:f})},e.exclude=(p,l)=>{let f={...r.entries};for(let m of p)if(a.has(m))delete f[m];else throw Error(`Key ${m} not found in enum`);return new Kr({...r,checks:[],...b(l),entries:f})}});function s(e,r){let a=Array.isArray(e)?Object.fromEntries(e.map((p)=>[p,p])):e;return new Kr({type:"enum",entries:a,...b(r)})}var Hi=z("ZodLiteral",(e,r)=>{sn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>kr(e,a,p,l),e.values=new Set(r.values),Object.defineProperty(e,"value",{get(){if(r.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function i(e,r){return new Hi({type:"literal",values:Array.isArray(e)?e:[e],...b(r)})}var Qi=z("ZodTransform",(e,r)=>{un.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Pr(e,a,p,l),e._zod.parse=(a,p)=>{if(p.direction==="backward")throw new ue(e.constructor.name);a.addIssue=(f)=>{if(typeof f==="string")a.issues.push(te(f,a.value,r));else{let m=f;if(m.fatal)m.continue=!1;m.code??(m.code="custom"),m.input??(m.input=a.value),m.inst??(m.inst=e),a.issues.push(te(m))}};let l=r.transform(a.value,a);if(l instanceof Promise)return l.then((f)=>(a.value=f,a.fallback=!0,a));return a.value=l,a.fallback=!0,a}});function ec(e){return new Qi({type:"transform",transform:e})}var Gs=z("ZodOptional",(e,r)=>{nr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ue(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function Us(e){return new Gs({type:"optional",innerType:e})}var rc=z("ZodExactOptional",(e,r)=>{pn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ue(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function tc(e){return new rc({type:"optional",innerType:e})}var oc=z("ZodNullable",(e,r)=>{ln.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Nr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function Ms(e){return new oc({type:"nullable",innerType:e})}var nc=z("ZodDefault",(e,r)=>{fn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>jr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sc(e,r){return new nc({type:"default",innerType:e,get defaultValue(){return typeof r==="function"?r():Ke(r)}})}var ic=z("ZodPrefault",(e,r)=>{dn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Cr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function cc(e,r){return new ic({type:"prefault",innerType:e,get defaultValue(){return typeof r==="function"?r():Ke(r)}})}var qs=z("ZodNonOptional",(e,r)=>{mn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Ar(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function uc(e,r){return new qs({type:"nonoptional",innerType:e,...b(r)})}var ac=z("ZodCatch",(e,r)=>{hn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Rr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function pc(e,r){return new ac({type:"catch",innerType:e,catchValue:typeof r==="function"?r:()=>r})}var lc=z("ZodPipe",(e,r)=>{_n.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Dr(e,a,p,l),e.in=r.in,e.out=r.out});function Js(e,r){return new lc({type:"pipe",in:e,out:r})}var fc=z("ZodReadonly",(e,r)=>{gn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Lr(e,a,p,l),e.unwrap=()=>e._zod.def.innerType});function dc(e){return new fc({type:"readonly",innerType:e})}var mc=z("ZodLazy",(e,r)=>{xn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Fr(e,a,p,l),e.unwrap=()=>e._zod.def.getter()});function Zo(e){return new mc({type:"lazy",getter:e})}var Ys=z("ZodCustom",(e,r)=>{zn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(a,p,l)=>Zr(e,a,p,l)});function cn(e,r){return Qn(Ys,e??(()=>!0),r)}function hc(e,r={}){return es(Ys,e,r)}function _c(e,r){return rs(e,r)}export{Xo,L,$i,Mi,Yo,an,y,t,Ct,k,At,o,d,ms,Ie,Bi,u,n,c,gs,W,g,ee,_s,s,i,Zo,cn};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{tr}from"./vm-hands-entry-lite-bn14pnz1.js";var Qe=tr.version,Qn=`reason-cli/${Qe}`;export{Qe,Qn};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Qe}from"./vm-hands-entry-lite-rjsr6mmk.js";import{a}from"./vm-hands-entry-lite-jvszqt0z.js";import{randomUUID as L}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as ee,cpSync as te,existsSync as x,lstatSync as A,mkdirSync as Y,readdirSync as ne,readFileSync as w,readlinkSync as re,realpathSync as T,renameSync as E,rmdirSync as ie,rmSync as g,symlinkSync as M,writeFileSync as oe}from"fs";import{dirname as I,join as u,relative as se,resolve as ce}from"path";var Yn="so.ara.cli",k=[Yn,"com.reasonmachines.cli"],F="5LJFSBRY2F";function Gr(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${F}"`}var G="ReasonBackgroundIdentity",$o="Contents/Helpers/ReasonPermissionTile",ae="so.ara.cli.permission-tile",Ne=Gr([ae,"com.reasonmachines.cli.permission-tile"]),v="AraBackgroundIdentity",ue="Reason",Ce=Gr(k),de=`anchor apple generic and (${k.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${F}"`;class h extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var R="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function le(e=a()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=a()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function fe(e){try{return A(e).isFile()}catch{return!1}}function D(e){return[G,v].map((t)=>u(e,"Contents","MacOS",t)).find(fe)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=w(u(e,"Contents","Info.plist"),"utf8");return k.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ue}</string>`)||t.includes("<string>Ara</string>"))&&D(e)!==null}catch{return!1}}function Kr(e=a()){let t=le(e);if(!d(t))return null;try{let n=w(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function pe(e,t=a()){let n=Kr(t);return n===null||j(N(n.split(".")),N(e.split(/[.-]/).slice(0,3)))}var ge=1e4;function K(e,t){return b(e,[...t],{stdio:"ignore",timeout:ge}).status??1}var W=new Set;function H(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return ce(n)}};if(e!==void 0&&t(e)!==t(a()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var V=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,J=new Set(["ara","ara.exe","reason","reason.exe"]);function N(e){return e.map((t)=>Number(t))}function j(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var ye=[0,2,161];function me(e){if(e===null)return!0;let t=ye,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=V.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return j(N(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return J.has(o)&&r!==n&&r!==process.execPath})}function Ee(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
2
+ import{Qe}from"./vm-hands-entry-lite-fmghv8b1.js";import{a}from"./vm-hands-entry-lite-jvszqt0z.js";import{randomUUID as L}from"crypto";import{spawnSync as b}from"child_process";import{chmodSync as ee,cpSync as te,existsSync as x,lstatSync as A,mkdirSync as Y,readdirSync as ne,readFileSync as w,readlinkSync as re,realpathSync as T,renameSync as E,rmdirSync as ie,rmSync as g,symlinkSync as M,writeFileSync as oe}from"fs";import{dirname as I,join as u,relative as se,resolve as ce}from"path";var Yn="so.ara.cli",k=[Yn,"com.reasonmachines.cli"],F="5LJFSBRY2F";function Gr(e){return`(${e.map((t)=>`identifier "${t}"`).join(" or ")}) and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = "${F}"`}var G="ReasonBackgroundIdentity",$o="Contents/Helpers/ReasonPermissionTile",ae="so.ara.cli.permission-tile",Ne=Gr([ae,"com.reasonmachines.cli.permission-tile"]),v="AraBackgroundIdentity",ue="Reason",Ce=Gr(k),de=`anchor apple generic and (${k.map((e)=>`identifier "${e}"`).join(" or ")}) and certificate leaf[subject.OU] = "${F}"`;class h extends Error{code;constructor(e,t){super(t);this.code=e;this.name="MacOSBackgroundIdentityError"}}var R="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function le(e=a()){return u(e,"Library","Application Support","Reason","Background","Reason.app")}function O(e=a()){return u(e,"Library","Application Support","Ara","Background","Ara.app")}function fe(e){try{return A(e).isFile()}catch{return!1}}function D(e){return[G,v].map((t)=>u(e,"Contents","MacOS",t)).find(fe)??null}function d(e){try{if(!A(e).isDirectory())return!1;let t=w(u(e,"Contents","Info.plist"),"utf8");return k.some((n)=>t.includes(`<string>${n}</string>`))&&(t.includes(`<string>${ue}</string>`)||t.includes("<string>Ara</string>"))&&D(e)!==null}catch{return!1}}function Kr(e=a()){let t=le(e);if(!d(t))return null;try{let n=w(u(t,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(n)?.[1]??null}catch{return null}}function pe(e,t=a()){let n=Kr(t);return n===null||j(N(n.split(".")),N(e.split(/[.-]/).slice(0,3)))}var ge=1e4;function K(e,t){return b(e,[...t],{stdio:"ignore",timeout:ge}).status??1}var W=new Set;function H(e){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let t=(n)=>{try{return T(n)}catch{return ce(n)}};if(e!==void 0&&t(e)!==t(a()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var V=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.(?:ara|reason)(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,J=new Set(["ara","ara.exe","reason","reason.exe"]);function N(e){return e.map((t)=>Number(t))}function j(e,t){for(let n=0;n<3;n+=1)if(e[n]!==t[n])return e[n]<t[n];return!1}var ye=[0,2,161];function me(e){if(e===null)return!0;let t=ye,n=null;try{n=T(process.execPath)}catch{}return e.some((r)=>{let i=V.exec(r);if(i){let f=i[1]===void 0?i.slice(4,7):i.slice(1,4);return j(N(f),t)}let o=r.slice(r.lastIndexOf("/")+1);return J.has(o)&&r!==n&&r!==process.execPath})}function Ee(){let e=b("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(e.status!==0)return null;let t=[];for(let n of e.stdout.split(`
3
3
  `)){let r=/^\s*(\d+)\s+(\S.*)$/.exec(n);if(!r||Number(r[1])===process.pid)continue;let i=r[2].trimEnd(),o=i.slice(i.lastIndexOf("/")+1);if(!V.test(i)&&J.has(o)){let c=b("/usr/sbin/lsof",["-a","-p",r[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
4
4
  `).find((l)=>l.startsWith("n/"));if(c)i=c.slice(1)}t.push(i)}return t}function _e(e){if(H(e.home),!d(e.sourceApp))throw new h("identity_invalid","The packaged Reason background identity is missing or invalid.");let t=e.command??K,n=le(e.home),r=I(n);Y(r,{recursive:!0,mode:448}),ee(r,448);let i=T(e.sourceApp),o=null;try{o=T(n)}catch{}if(i!==o){let f=`${process.pid}.${L()}`,c=u(r,`.Reason.app.${f}.tmp`),l=u(r,`.Reason.app.${f}.old`),y=!1;try{if(te(i,c,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!d(c))throw new h("identity_invalid","The copied Reason background identity is invalid.");let _=e.releaseSigned?["--test-requirement",`=${de}`]:[];if(t("/usr/bin/codesign",["--verify","--strict",..._,c])!==0)throw new h("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let S=!1;for(let p=0;p<4;p+=1){let m=!1;try{E(n,l),m=!0,y=!0}catch(s){if(s.code!=="ENOENT")throw s}if(p===0)e.beforePublish?.();try{E(c,n),S=!0}catch(s){let Z=s.code;if(!["EEXIST","ENOTEMPTY"].includes(Z??""))throw s;if(m)g(l,{recursive:!0,force:!0}),y=!1;if(p===3)throw s;continue}if(m)g(l,{recursive:!0,force:!0}),y=!1;break}if(!S)throw Error("Could not publish Reason's background identity.")}catch(_){if(y&&!x(n)&&x(l))E(l,n);throw _}finally{g(c,{recursive:!0,force:!0}),g(l,{recursive:!0,force:!0})}}return z(n,e,{verified:i!==o}),n}function X(e){return u(I(e),".Reason.app.registered")}function q(e){try{let t=A(e);return t.isDirectory()?`${t.ino}:${t.birthtimeMs}`:null}catch{return null}}function C(e){let t=q(e);try{return t!==null&&w(X(e),"utf8")===t}catch{return!1}}function Q(e){if(d(e))return"bundle";try{if(A(u(e,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return A(u(e,"Contents","MacOS",v)).isSymbolicLink()?"retired":null}catch{return null}}function z(e,t,n={}){let r=t.command??K;if(!n.verified&&r("/usr/bin/codesign",["--verify","--strict",e])!==0)throw new h("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(r(R,["-f",e])!==0)throw new h("identity_register_failed","Could not register Reason's macOS background identity.");let i=q(e);try{if(i)oe(X(e),i,{mode:384})}catch{}try{Se(e,t.home,r,t.runningExecutables??Ee)}catch(o){let f=o.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${f})
5
5
  `)}}function Se(e,t,n,r){let i=D(e);if(!i)return;let o=O(t),f=I(o),c=(s)=>u(s,"Contents","MacOS",v),l=se(I(c(o)),i),y=`${process.pid}.${L()}`,_=Q(o);if(_===null)return;let S=_==="bundle";if(S)n(R,["-u",o]);let p=u(f,`.Ara.app.${y}.old`);if(!W.has(o)&&!me(r())){if(!S)n(R,["-u",o]);try{E(o,p)}catch(s){if(s.code==="ENOENT")return;throw s}g(p,{recursive:!0,force:!0}),Ie(f);return}if(!S){if(re(c(o))===l)return;let s=`${c(o)}.${y}`;M(l,s);try{E(s,c(o))}finally{g(s,{force:!0})}return}let m=u(f,`.Ara.app.${y}.shim`);Y(I(c(m)),{recursive:!0}),M(l,c(m));try{try{E(o,p)}catch(s){if(s.code==="ENOENT")return;throw s}try{E(m,o)}catch(s){if(x(o))return;throw E(p,o),s}}finally{g(m,{recursive:!0,force:!0}),g(p,{recursive:!0,force:!0})}}function Ie(e){try{if(ne(e).some((n)=>n!==".DS_Store"))return;g(u(e,".DS_Store"),{force:!0}),ie(e)}catch{}}var B=new Map;function Zn(e=a()){let t=B.get(e);if(t)return t;if(process.platform!=="darwin")return[];let n=U(e);if(n===null&&x(I(le(e))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),n=U(e);if(n===null)return[];return B.set(e,n),n}function U(e){let t=le(e),n=O(e);if(!d(t)||!C(t))try{he({home:e,skipWhenSettled:!0})}catch{}let r=d(t)&&(C(t)||!d(n))?t:d(n)?n:null,i=r?D(r):null;if(!i)return null;if(r===n)W.add(n);let o=b(i,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return o.status===0&&o.stdout===`spawn
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$n,Mn,To,Wt}from"./vm-hands-entry-lite-k9vk84wa.js";import{Tn,Ve,_o,In,Dn,On,Rr,x}from"./vm-hands-entry-lite-79f3h259.js";import{Pt}from"./vm-hands-entry-lite-xe0benev.js";import{Nr}from"./vm-hands-entry-lite-j5t2pj4v.js";import{j}from"./vm-hands-entry-lite-cgddp0y3.js";import{a}from"./vm-hands-entry-lite-jvszqt0z.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ce,spawn as ne}from"child_process";import{randomBytes as Oe}from"crypto";import{chmodSync as he,existsSync as ae,lstatSync as Je,mkdirSync as Qe,readFileSync as oe,rmSync as ie,writeFileSync as u}from"fs";import{connect as Se}from"net";import{join as I}from"path";var B=32,Y=76;var m="./desktop-wallpaper-fd8f2wb2.jpg";var v="./dock-browser-y53t41cx.png";var Z="./dock-files-cp52htdw.png";var V="./dock-terminal-1es514yq.png";var z="./grok-wallpaper-71zwn2pj.jpg";var W="./grok-dock-browser-pzw59wnd.png";var U="./grok-dock-files-eckq444x.png";var ee="./grok-dock-terminal-hcpz3e43.png";var re=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
2
+ import{$n,Mn,To,Wt}from"./vm-hands-entry-lite-k9vk84wa.js";import{Tn,Ve,_o,In,Dn,On,Rr,x}from"./vm-hands-entry-lite-zhf20g7y.js";import{Pt}from"./vm-hands-entry-lite-xe0benev.js";import{Nr}from"./vm-hands-entry-lite-hhk4h552.js";import{j}from"./vm-hands-entry-lite-vj0gm694.js";import{a}from"./vm-hands-entry-lite-jvszqt0z.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{execFile as ce,spawn as ne}from"child_process";import{randomBytes as Oe}from"crypto";import{chmodSync as he,existsSync as ae,lstatSync as Je,mkdirSync as Qe,readFileSync as oe,rmSync as ie,writeFileSync as u}from"fs";import{connect as Se}from"net";import{join as I}from"path";var B=32,Y=76;var m="./desktop-wallpaper-fd8f2wb2.jpg";var v="./dock-browser-y53t41cx.png";var Z="./dock-files-cp52htdw.png";var V="./dock-terminal-1es514yq.png";var z="./grok-wallpaper-71zwn2pj.jpg";var W="./grok-dock-browser-pzw59wnd.png";var U="./grok-dock-files-eckq444x.png";var ee="./grok-dock-terminal-hcpz3e43.png";var re=`# Sets the X root window background and _XROOTPMAP_ID, as feh --bg-fill does.
3
3
  # The native Blaxel image ships no feh, hsetroot or compositor, but it does ship
4
4
  # python3-gi and libX11. tint2 reads _XROOTPMAP_ID to draw its transparent panel.
5
5
  # Usage: DISPLAY=:99 python3 set-root-wallpaper.py IMAGE
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{U}from"./vm-hands-entry-lite-a0g6c3wr.js";import{ft}from"./vm-hands-entry-lite-hv3dxd5k.js";import{Xt}from"./vm-hands-entry-lite-y9jarm7q.js";import{j}from"./vm-hands-entry-lite-cgddp0y3.js";import{ie}from"./vm-hands-entry-lite-jvszqt0z.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{Me}from"./vm-hands-entry-lite-3gbf905c.js";import{existsSync as D,realpathSync as z,statSync as K}from"fs";import{platform as h}from"os";import{isAbsolute as I,sep as G}from"path";import{existsSync as X}from"fs";import{createRequire as Y}from"module";var k=Me(Xt)(()=>Y(import.meta.url)("bun:ffi"),X);function C(){return process.platform==="win32"&&typeof globalThis.Bun<"u"&&k.available()}function M(e=process.env){return k.defaultShell(e)}function N(e){return k.shellArgs(e)}function W(e){let n=k.spawn({...e,env:e.environment});return n.exited.then(()=>n.close()),{write:(o)=>n.write(o),resize:(o,t)=>n.resize(o,t),kill:()=>n.close(),exited:n.exited}}var Dr=43200000,Vt=ft,Or=4,Q=/^[A-Za-z0-9._:-]{1,160}$/,V=1000;function F(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function P(e,n){if(typeof e!=="number"||!Number.isFinite(e)||e<=0)return n;return Math.min(V,Math.max(1,Math.floor(e)))}function Z(e,n=Date.now()){let o=["relay_url","session_id","expires_at"],t=new Set([...o,"cols","rows","cwd","workspace"]);if(!F(e)||o.some((b)=>!(b in e))||Object.keys(e).some((b)=>!t.has(b)))throw new r("invalid_pty_request","Reason terminal request is malformed.");let{relay_url:c,session_id:m,expires_at:g}=e;if(typeof c!=="string")throw new r("invalid_pty_request","Reason terminal relay URL is missing.");let d;try{d=new URL(c)}catch{throw new r("invalid_pty_request","Reason terminal relay URL is invalid.")}if(d.protocol!=="wss:"&&d.protocol!=="ws:"||d.username||d.password)throw new r("invalid_pty_request","Reason terminal relay URL is invalid.");if(typeof m!=="string"||!Q.test(m))throw new r("invalid_pty_request","Reason terminal session identity is invalid.");let p=typeof g==="string"?Date.parse(g):Number.NaN;if(!Number.isFinite(p)||p<=n)throw new r("invalid_pty_request","Reason terminal session has already expired.");if(e.cwd!==void 0&&typeof e.cwd!=="string")throw new r("invalid_pty_request","Reason terminal working directory is invalid.");let a=e.workspace===void 0?void 0:U(e.workspace);if(a===null||a&&e.cwd!==void 0)throw new r("invalid_pty_request","Reason terminal workspace is invalid.");return{relay_url:c,session_id:m,expires_at:new Date(Math.min(p,n+Dr)).toISOString(),cols:P(e.cols,80),rows:P(e.rows,24),...e.cwd===void 0?{}:{cwd:e.cwd},...a?{workspace:a}:{}}}function ee(e,n){if(h()==="win32")[e,n]=[e.toLowerCase(),n.toLowerCase()];return n===e||n.startsWith(e+G)}function q(e,n){if(n===void 0)return e;if(!I(n))throw new r("pty_cwd_invalid","Reason terminal working directory must be absolute.");let o;try{o=z(n)}catch{throw new r("pty_cwd_invalid","Reason terminal working directory does not exist.")}if(!ee(e,o))throw new r("pty_cwd_outside_root","Reason terminal working directory escapes the granted root.");if(!K(o).isDirectory())throw new r("pty_cwd_invalid","Reason terminal working directory is not a directory.");return o}function ds(e=process.env){if(h()==="win32")return M(e);let n=e.SHELL;if(n&&I(n)&&D(n))return n;for(let o of h()==="darwin"?["/bin/zsh","/bin/bash","/bin/sh"]:["/bin/bash","/bin/sh"])if(D(o))return o;return"/bin/sh"}function ne(){let e=globalThis.Bun;if(!e)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");return e.spawn}function Hn(){if(h()==="win32")return C();return typeof globalThis.Bun<"u"}var re=(e)=>{if(h()==="win32")try{return W({...e,file:e.shell,args:N(e.shell),environment:{...e.environment,TERM:"xterm-256color"}})}catch{throw new r("pty_unavailable","Reason could not allocate a pseudo-terminal.")}let n=ne()({cmd:[e.shell,"-i","-l"],cwd:e.cwd,env:{...e.environment,TERM:"xterm-256color"},terminal:{cols:e.cols,rows:e.rows,data:(t,c)=>{e.onData(c)}}}),o=n.terminal;if(!o){try{n.kill()}catch{}throw new r("pty_unavailable","Reason could not allocate a pseudo-terminal.")}return{write:(t)=>o.write(t),resize:(t,c)=>o.resize(t,c),kill:()=>{try{n.kill()}catch{}},exited:n.exited.then((t)=>typeof t==="number"?t:null,()=>null)}},Nr=(e,n)=>n===void 0?new WebSocket(e):new WebSocket(e,{proxy:n}),v=new Set;function te(e){if(v.size>=Or||v.has(e))return null;v.add(e);let n=!1;return()=>{if(n)return;n=!0,v.delete(e)}}async function Un(e,n={}){let o=n.now??Date.now,t=Z(e.payload,o()),c=te(e.operationId);if(!c)throw new r("pty_slot_busy","This Reason Device already runs the maximum number of terminals.");let m=o(),g,d,p;try{let a=t.workspace?ie(e.root,t.workspace):void 0;g=a?q(D(a.boundary)?z(a.boundary):a.boundary,a.path):q(e.root,t.cwd),d=n.environment??process.env,p=n.shellPath??ds(d)}catch(a){throw c(),a}return await new Promise((a,b)=>{let w=null,i=null,S=!1,x=!1,y=!1,T=null,B=0,O=0,E=[],R=0,A=null,l=(s)=>{if(y)return;if(y=!0,A)clearTimeout(A);e.signal.removeEventListener("abort",L);try{w?.kill()}catch{}try{i?.close(1000,"pty_session_over")}catch{}if(c(),s.kind==="rejected"){b(s.error);return}let u={reason:s.reason,exit_code:T,output_bytes:B,input_bytes:O,duration_ms:Math.max(0,o()-m)};e.emitEvent("pty.stopped",{...u}).catch(()=>{return}),a({...u})},L=()=>{let s=e.signal.reason;l({kind:"rejected",error:s instanceof r?s:new r("cancelled","Reason closed the terminal session.")})};if(e.signal.aborted){L();return}e.signal.addEventListener("abort",L,{once:!0}),A=setTimeout(()=>l({kind:"resolved",reason:"session_expired"}),Math.max(1,Date.parse(t.expires_at)-o()));let H=(s)=>{if(B+=s.byteLength,!S||!i){if(E.push(s),R+=s.byteLength,R>Vt)l({kind:"resolved",reason:"output_backpressure"});return}try{i.send(s)}catch{l({kind:"resolved",reason:"relay_closed"});return}if(i.bufferedAmount>Vt)l({kind:"resolved",reason:"output_backpressure"})};try{w=(n.spawnPty??re)({shell:p,args:["-i","-l"],cwd:g,cols:t.cols,rows:t.rows,environment:d,onData:(s)=>{if(!y)H(s)}})}catch(s){l({kind:"rejected",error:s instanceof r?s:new r("pty_spawn_failed","Reason could not start the terminal shell.")});return}w.exited.then((s)=>{if(y)return;if(T=s,S&&i)try{i.send(JSON.stringify({t:"exit",code:s}))}catch{}l({kind:"resolved",reason:"shell_exited"})});let J=(n.loadProxy??j)()?.url;try{i=(n.connect??Nr)(t.relay_url,J)}catch{l({kind:"rejected",error:new r("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}i.binaryType="arraybuffer",i.onopen=()=>{if(y||!i)return;S=!0;try{i.send(JSON.stringify({t:"open",cols:t.cols,rows:t.rows}));for(let s of E.splice(0))i.send(s);R=0}catch{l({kind:"resolved",reason:"relay_closed"});return}x=!0,e.emitEvent("pty.ready",{session_id:t.session_id,cols:t.cols,rows:t.rows}).catch(()=>{return})},i.onmessage=(s)=>{if(y||!w)return;let u=s.data;if(typeof u==="string"){let f;try{f=JSON.parse(u)}catch{return}if(!F(f))return;if(f.t==="resize"){try{w.resize(P(f.cols,t.cols),P(f.rows,t.rows))}catch{}return}if(f.t==="close")l({kind:"resolved",reason:"client_closed"});return}let _=u instanceof ArrayBuffer?new Uint8Array(u):ArrayBuffer.isView(u)?new Uint8Array(u.buffer,u.byteOffset,u.byteLength):null;if(!_||_.byteLength===0)return;O+=_.byteLength;try{w.write(_)}catch{}},i.onclose=()=>{if(y)return;if(!x){l({kind:"rejected",error:new r("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}l({kind:"resolved",reason:"relay_closed"})},i.onerror=()=>{if(y||x)return;l({kind:"rejected",error:new r("pty_relay_unavailable","Reason could not reach the terminal relay.")})}})}
2
+ import{U}from"./vm-hands-entry-lite-a0g6c3wr.js";import{ft}from"./vm-hands-entry-lite-hv3dxd5k.js";import{Xt}from"./vm-hands-entry-lite-y9jarm7q.js";import{j}from"./vm-hands-entry-lite-vj0gm694.js";import{ie}from"./vm-hands-entry-lite-jvszqt0z.js";import{r}from"./vm-hands-entry-lite-qy9xg6em.js";import{Me}from"./vm-hands-entry-lite-3gbf905c.js";import{existsSync as D,realpathSync as z,statSync as K}from"fs";import{platform as h}from"os";import{isAbsolute as I,sep as G}from"path";import{existsSync as X}from"fs";import{createRequire as Y}from"module";var k=Me(Xt)(()=>Y(import.meta.url)("bun:ffi"),X);function C(){return process.platform==="win32"&&typeof globalThis.Bun<"u"&&k.available()}function M(e=process.env){return k.defaultShell(e)}function N(e){return k.shellArgs(e)}function W(e){let n=k.spawn({...e,env:e.environment});return n.exited.then(()=>n.close()),{write:(o)=>n.write(o),resize:(o,t)=>n.resize(o,t),kill:()=>n.close(),exited:n.exited}}var Dr=43200000,Vt=ft,Or=4,Q=/^[A-Za-z0-9._:-]{1,160}$/,V=1000;function F(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function P(e,n){if(typeof e!=="number"||!Number.isFinite(e)||e<=0)return n;return Math.min(V,Math.max(1,Math.floor(e)))}function Z(e,n=Date.now()){let o=["relay_url","session_id","expires_at"],t=new Set([...o,"cols","rows","cwd","workspace"]);if(!F(e)||o.some((b)=>!(b in e))||Object.keys(e).some((b)=>!t.has(b)))throw new r("invalid_pty_request","Reason terminal request is malformed.");let{relay_url:c,session_id:m,expires_at:g}=e;if(typeof c!=="string")throw new r("invalid_pty_request","Reason terminal relay URL is missing.");let d;try{d=new URL(c)}catch{throw new r("invalid_pty_request","Reason terminal relay URL is invalid.")}if(d.protocol!=="wss:"&&d.protocol!=="ws:"||d.username||d.password)throw new r("invalid_pty_request","Reason terminal relay URL is invalid.");if(typeof m!=="string"||!Q.test(m))throw new r("invalid_pty_request","Reason terminal session identity is invalid.");let p=typeof g==="string"?Date.parse(g):Number.NaN;if(!Number.isFinite(p)||p<=n)throw new r("invalid_pty_request","Reason terminal session has already expired.");if(e.cwd!==void 0&&typeof e.cwd!=="string")throw new r("invalid_pty_request","Reason terminal working directory is invalid.");let a=e.workspace===void 0?void 0:U(e.workspace);if(a===null||a&&e.cwd!==void 0)throw new r("invalid_pty_request","Reason terminal workspace is invalid.");return{relay_url:c,session_id:m,expires_at:new Date(Math.min(p,n+Dr)).toISOString(),cols:P(e.cols,80),rows:P(e.rows,24),...e.cwd===void 0?{}:{cwd:e.cwd},...a?{workspace:a}:{}}}function ee(e,n){if(h()==="win32")[e,n]=[e.toLowerCase(),n.toLowerCase()];return n===e||n.startsWith(e+G)}function q(e,n){if(n===void 0)return e;if(!I(n))throw new r("pty_cwd_invalid","Reason terminal working directory must be absolute.");let o;try{o=z(n)}catch{throw new r("pty_cwd_invalid","Reason terminal working directory does not exist.")}if(!ee(e,o))throw new r("pty_cwd_outside_root","Reason terminal working directory escapes the granted root.");if(!K(o).isDirectory())throw new r("pty_cwd_invalid","Reason terminal working directory is not a directory.");return o}function ds(e=process.env){if(h()==="win32")return M(e);let n=e.SHELL;if(n&&I(n)&&D(n))return n;for(let o of h()==="darwin"?["/bin/zsh","/bin/bash","/bin/sh"]:["/bin/bash","/bin/sh"])if(D(o))return o;return"/bin/sh"}function ne(){let e=globalThis.Bun;if(!e)throw new r("pty_unavailable","Reason terminals require the Bun runtime.");return e.spawn}function Hn(){if(h()==="win32")return C();return typeof globalThis.Bun<"u"}var re=(e)=>{if(h()==="win32")try{return W({...e,file:e.shell,args:N(e.shell),environment:{...e.environment,TERM:"xterm-256color"}})}catch{throw new r("pty_unavailable","Reason could not allocate a pseudo-terminal.")}let n=ne()({cmd:[e.shell,"-i","-l"],cwd:e.cwd,env:{...e.environment,TERM:"xterm-256color"},terminal:{cols:e.cols,rows:e.rows,data:(t,c)=>{e.onData(c)}}}),o=n.terminal;if(!o){try{n.kill()}catch{}throw new r("pty_unavailable","Reason could not allocate a pseudo-terminal.")}return{write:(t)=>o.write(t),resize:(t,c)=>o.resize(t,c),kill:()=>{try{n.kill()}catch{}},exited:n.exited.then((t)=>typeof t==="number"?t:null,()=>null)}},Nr=(e,n)=>n===void 0?new WebSocket(e):new WebSocket(e,{proxy:n}),v=new Set;function te(e){if(v.size>=Or||v.has(e))return null;v.add(e);let n=!1;return()=>{if(n)return;n=!0,v.delete(e)}}async function Un(e,n={}){let o=n.now??Date.now,t=Z(e.payload,o()),c=te(e.operationId);if(!c)throw new r("pty_slot_busy","This Reason Device already runs the maximum number of terminals.");let m=o(),g,d,p;try{let a=t.workspace?ie(e.root,t.workspace):void 0;g=a?q(D(a.boundary)?z(a.boundary):a.boundary,a.path):q(e.root,t.cwd),d=n.environment??process.env,p=n.shellPath??ds(d)}catch(a){throw c(),a}return await new Promise((a,b)=>{let w=null,i=null,S=!1,x=!1,y=!1,T=null,B=0,O=0,E=[],R=0,A=null,l=(s)=>{if(y)return;if(y=!0,A)clearTimeout(A);e.signal.removeEventListener("abort",L);try{w?.kill()}catch{}try{i?.close(1000,"pty_session_over")}catch{}if(c(),s.kind==="rejected"){b(s.error);return}let u={reason:s.reason,exit_code:T,output_bytes:B,input_bytes:O,duration_ms:Math.max(0,o()-m)};e.emitEvent("pty.stopped",{...u}).catch(()=>{return}),a({...u})},L=()=>{let s=e.signal.reason;l({kind:"rejected",error:s instanceof r?s:new r("cancelled","Reason closed the terminal session.")})};if(e.signal.aborted){L();return}e.signal.addEventListener("abort",L,{once:!0}),A=setTimeout(()=>l({kind:"resolved",reason:"session_expired"}),Math.max(1,Date.parse(t.expires_at)-o()));let H=(s)=>{if(B+=s.byteLength,!S||!i){if(E.push(s),R+=s.byteLength,R>Vt)l({kind:"resolved",reason:"output_backpressure"});return}try{i.send(s)}catch{l({kind:"resolved",reason:"relay_closed"});return}if(i.bufferedAmount>Vt)l({kind:"resolved",reason:"output_backpressure"})};try{w=(n.spawnPty??re)({shell:p,args:["-i","-l"],cwd:g,cols:t.cols,rows:t.rows,environment:d,onData:(s)=>{if(!y)H(s)}})}catch(s){l({kind:"rejected",error:s instanceof r?s:new r("pty_spawn_failed","Reason could not start the terminal shell.")});return}w.exited.then((s)=>{if(y)return;if(T=s,S&&i)try{i.send(JSON.stringify({t:"exit",code:s}))}catch{}l({kind:"resolved",reason:"shell_exited"})});let J=(n.loadProxy??j)()?.url;try{i=(n.connect??Nr)(t.relay_url,J)}catch{l({kind:"rejected",error:new r("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}i.binaryType="arraybuffer",i.onopen=()=>{if(y||!i)return;S=!0;try{i.send(JSON.stringify({t:"open",cols:t.cols,rows:t.rows}));for(let s of E.splice(0))i.send(s);R=0}catch{l({kind:"resolved",reason:"relay_closed"});return}x=!0,e.emitEvent("pty.ready",{session_id:t.session_id,cols:t.cols,rows:t.rows}).catch(()=>{return})},i.onmessage=(s)=>{if(y||!w)return;let u=s.data;if(typeof u==="string"){let f;try{f=JSON.parse(u)}catch{return}if(!F(f))return;if(f.t==="resize"){try{w.resize(P(f.cols,t.cols),P(f.rows,t.rows))}catch{}return}if(f.t==="close")l({kind:"resolved",reason:"client_closed"});return}let _=u instanceof ArrayBuffer?new Uint8Array(u):ArrayBuffer.isView(u)?new Uint8Array(u.buffer,u.byteOffset,u.byteLength):null;if(!_||_.byteLength===0)return;O+=_.byteLength;try{w.write(_)}catch{}},i.onclose=()=>{if(y)return;if(!x){l({kind:"rejected",error:new r("pty_relay_unavailable","Reason could not reach the terminal relay.")});return}l({kind:"resolved",reason:"relay_closed"})},i.onerror=()=>{if(y||x)return;l({kind:"rejected",error:new r("pty_relay_unavailable","Reason could not reach the terminal relay.")})}})}
3
3
  export{Dr,Vt,Or,ds,Hn,Nr,Un};