@anmol-srv/sigil 0.18.2 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +37 -25
  2. package/dist/cli.js +1191 -790
  3. package/dist/daemon.js +664 -302
  4. package/dist/hooks/post-tool-use.js +1 -69
  5. package/dist/hooks/session-end.js +13 -236
  6. package/dist/hooks/stop.js +36 -246
  7. package/dist/hooks/user-prompt-submit.js +25 -288
  8. package/dist/mcp/worker-server.js +6 -0
  9. package/dist/npm-entry.js +10 -0
  10. package/dist/server.js +64 -56
  11. package/install.sh +207 -0
  12. package/integrations/hermes/README.md +30 -24
  13. package/integrations/hermes/plugin/README.md +1 -1
  14. package/integrations/hermes/plugin/__init__.py +68 -24
  15. package/knexfile.js +19 -22
  16. package/package.json +9 -28
  17. package/prompts/audm-decision.md +26 -1
  18. package/prompts/entity-extraction.md +32 -30
  19. package/prompts/graph-extraction.md +20 -2
  20. package/src/db/drivers/index.js +38 -15
  21. package/src/db/migrations/20260629120000_add-trace-event-attribution.cjs +29 -0
  22. package/src/db/migrations/20260629120001_add-llm-log-session-correlation.cjs +29 -0
  23. package/src/db/migrations/20260806120000_add-document-content.cjs +27 -0
  24. package/src/db/migrations/20260806120001_llm-log-model-nullable.cjs +36 -0
  25. package/src/db/migrations/20260811120000_add-relation-provenance.cjs +42 -0
  26. package/src/db/migrations/20260811130000_add-fact-visibility.cjs +67 -0
  27. package/src/db/migrations/20260813090000_rescore-defaulted-vital.cjs +57 -0
  28. package/src/db/migrations/20260814120000_create-ingestion-job.cjs +52 -0
  29. package/src/db/migrations/20260814120100_add-llm-log-queued-ms.cjs +8 -0
  30. package/src/db/migrations/20260814120200_add-active-fact-content-hash-index.cjs +16 -0
  31. package/src/db/migrations/20260814120300_create-relation-candidate-judgment.cjs +25 -0
  32. package/src/gui/web/app.css +851 -84
  33. package/src/gui/web/app.js +796 -383
  34. package/src/gui/web/cmdk.js +238 -0
  35. package/src/gui/web/components.js +64 -0
  36. package/src/gui/web/design/colors_and_type.css +6 -1
  37. package/src/gui/web/graph/GraphIsland.jsx +450 -0
  38. package/src/gui/web/graph/cluster.js +305 -0
  39. package/src/gui/web/graph/cluster.test.js +219 -0
  40. package/src/gui/web/health.js +117 -0
  41. package/src/gui/web/health.test.js +159 -0
  42. package/src/gui/web/icons.js +65 -0
  43. package/src/gui/web/index.html +310 -115
  44. package/src/gui/web/settings.js +386 -0
  45. package/src/gui/web/setup.js +2 -2
  46. package/src/gui/web/toast.js +6 -3
  47. package/src/gui/web/vendor/graph-island.js +52 -0
package/dist/server.js CHANGED
@@ -1,83 +1,91 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __sigilCreateRequire } from 'node:module'; const require = __sigilCreateRequire(import.meta.url);
3
- var Ya=Object.defineProperty;var K=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ze=(t,e)=>{for(var r in e)Ya(t,r,{get:e[r],enumerable:!0})};import{fileURLToPath as Ml}from"node:url";import{dirname as ea,join as A}from"node:path";import{existsSync as ta}from"node:fs";import{homedir as Dl}from"node:os";function jl(){let t=ea(Ml(import.meta.url));for(let e=0;e<10;e++){if(ta(A(t,"package.json"))&&ta(A(t,"prompts")))return t;let r=ea(t);if(r===t)break;t=r}return process.cwd()}var Ue,Iv,Sv,ra,N,ar,ee,wv,Ov,Av,kv,Rv,Lv,Cv,Nv,Pv,Fe,sr,ht,na,$v,Mv,Dv,jv,Gv,oa,Bv,Uv,gt=K(()=>{Ue=jl(),Iv=A(Ue,"prompts"),Sv=A(Ue,"src","db","migrations"),ra=Dl(),N=A(ra,".sigil"),ar=A(N,".env"),ee=A(N,"config.json"),wv=A(N,"db"),Ov=A(N,"CLAUDE.md"),Av=A(N,"schemas"),kv=A(N,".hook-errors.log"),Rv=A(N,".last-clean-doctor"),Lv=A(N,".active-session.json"),Cv=A(N,".stop-cursor.json"),Nv=A(N,".stop-spool.jsonl"),Pv=A(N,".hook-dedup.json"),Fe=A(N,"sock"),sr=A(N,"sigild.pid"),ht=A(N,"sigild.log"),na=A(N,"heartbeat.json"),$v=A(N,"gui.token"),Mv=A(Ue,"dist","gui"),Dv=A(Ue,"src","gui","web"),jv=A(N,"iroh"),Gv=A(N,"identity.key"),oa=A(ra,".claude"),Bv=A(oa,"settings.json"),Uv=A(oa,"CLAUDE.md")});var He,ir=K(()=>{He=1024});var fa={};Ze(fa,{CONFIG_SCHEMA_VERSION:()=>Lt,EMBEDDING_DIM:()=>He,ensureDeviceId:()=>Ql,getConfig:()=>xt,isSetupComplete:()=>rd,loadConfig:()=>ua,markSetupComplete:()=>td,patchConfig:()=>Ct,resetConfig:()=>nd,setStepStatus:()=>ed});import{existsSync as cr,readFileSync as ia,writeFileSync as Gl,renameSync as ca,mkdirSync as Bl,chmodSync as Ul,unlinkSync as Fl}from"node:fs";import{dirname as Hl}from"node:path";import{randomUUID as zl}from"node:crypto";function Rt(){return{schemaVersion:Lt,device:{id:null},database:{mode:null,url:null,host:"localhost",port:5432,name:"sigil",user:"sigil_app",password:null},llm:{provider:null,model:null,apiKey:null,host:null},embedding:{provider:null,model:null,apiKey:null,host:null},identity:{name:null},setup:{complete:!1,steps:{}}}}function yt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ur(t,e){if(!yt(e))return e;let r=Array.isArray(t)?[...t]:{...t};for(let[n,o]of Object.entries(e))r[n]=yt(o)&&yt(r[n])?ur(r[n],o):o;return r}function _t(){if(!cr(ee))return{};try{return JSON.parse(ia(ee,"utf8"))||{}}catch{return{}}}function Kl(t){let e=t,r=Number(e.schemaVersion)||1;for(;r<Lt;){let n=r+1,o=Zl[n];e=o?o(e):{...e,schemaVersion:n},r=n}return e}function ze(t){let e=Rt(),r={};for(let n of Object.keys(e)){if(!(n in t))continue;if(!yt(e[n])){r[n]=t[n];continue}let o={};for(let a of Object.keys(e[n]))t[n]&&a in t[n]&&(o[a]=t[n][a]);n==="setup"&&yt(t.setup?.steps)&&(o.steps=t.setup.steps),r[n]=o}return r}function Or(t){Bl(Hl(ee),{recursive:!0});let e=`${ee}.tmp`;Gl(e,`${JSON.stringify(t,null,2)}
4
- `,{mode:384}),ca(e,ee);try{Ul(ee,384)}catch{}}function Wl(t,e){let r={};if(!yt(e))throw new Error(`config patch for "${t}" must be an object`);if(t==="database"&&("mode"in e&&e.mode!==null&&!aa.includes(e.mode)&&(r.mode=`must be one of ${aa.join(", ")}`),"port"in e&&e.port!=null&&!Number.isInteger(Number(e.port))&&(r.port="must be an integer"),"url"in e&&e.url!=null&&typeof e.url!="string"&&(r.url="must be a string")),Object.keys(r).length){let n=new Error(`invalid config for "${t}": ${JSON.stringify(r)}`);throw n.code="invalid_config",n.errors=r,n}}function Yl(t){if(!cr(t))return null;let e={};for(let r of ia(t,"utf8").split(`
5
- `)){let n=r.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/i);if(!n)continue;let o=n[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),e[n[1]]=o}return e}function ql(t){let e={},r={};if(t.SIGIL_DATABASE_URL||t.DATABASE_URL?(r.mode="url",r.url=t.SIGIL_DATABASE_URL||t.DATABASE_URL):(t.SIGIL_DB_HOST||t.SIGIL_DB_NAME||t.SIGIL_DB_PASSWORD)&&(r.mode="local",t.SIGIL_DB_HOST&&(r.host=t.SIGIL_DB_HOST),t.SIGIL_DB_PORT&&(r.port=Number(t.SIGIL_DB_PORT)||5432),t.SIGIL_DB_NAME&&(r.name=t.SIGIL_DB_NAME),t.SIGIL_DB_USER&&(r.user=t.SIGIL_DB_USER),t.SIGIL_DB_PASSWORD&&(r.password=t.SIGIL_DB_PASSWORD)),Object.keys(r).length&&(e.database=r),t.LLM_PROVIDER){let n={provider:t.LLM_PROVIDER},o={anthropic:t.ANTHROPIC_API_KEY,openai:t.OPENAI_API_KEY,openrouter:t.OPENROUTER_API_KEY}[t.LLM_PROVIDER];o&&(n.apiKey=o);let a={openai:t.LLM_OPENAI_MODEL,openrouter:t.LLM_OPENROUTER_MODEL,ollama:t.LLM_OLLAMA_MODEL,"claude-cli":t.LLM_CLI_MODEL}[t.LLM_PROVIDER];a&&(n.model=a),t.LLM_PROVIDER==="ollama"&&(t.LLM_OLLAMA_HOST||t.OLLAMA_HOST)&&(n.host=t.LLM_OLLAMA_HOST||t.OLLAMA_HOST),e.llm=n}if(t.EMBEDDING_PROVIDER){let n={provider:t.EMBEDDING_PROVIDER};t.EMBEDDING_MODEL&&(n.model=t.EMBEDDING_MODEL);let o={openai:t.OPENAI_API_KEY,voyage:t.VOYAGE_API_KEY,openrouter:t.OPENROUTER_API_KEY}[t.EMBEDDING_PROVIDER];o&&(n.apiKey=o),t.EMBEDDING_PROVIDER==="ollama"&&t.OLLAMA_HOST&&(n.host=t.OLLAMA_HOST),e.embedding=n}return t.SIGIL_SETUP_COMPLETE==="true"&&(e.setup={complete:!0}),e}function Jl(){if(!sa){sa=!0;try{let t=Yl(ar);if(!t)return;let e=ql(t),r=ze(_t()),n={database:!!r.database?.mode,llm:!!r.llm?.provider,embedding:!!r.embedding?.provider,setup:!!r.setup?.complete};for(let[o,a]of Object.entries(e))if(!n[o])try{Ct(o,a)}catch{}try{ca(ar,`${ar}.migrated`)}catch{}}catch{}}}function ua(){Jl();let t=_t(),e=Kl(t);return cr(ee)&&e.schemaVersion!==t.schemaVersion&&Or(ze(e)),Te=ur(Rt(),ze(e)),Xl(),Te}function Xl(){let t=Te?.setup?.steps;if(!t)return;let e=Object.entries(t).filter(([,o])=>o==="active").map(([o])=>o);if(!e.length)return;let r=ze(_t()),n={...r.setup?.steps||{}};for(let o of e)n[o]="pending";Or({...r,schemaVersion:Lt,setup:{...r.setup||{},steps:n}}),Te=ur(Rt(),ze(_t()))}function xt(){return Te||ua()}function Ct(t,e){if(!(t in Rt()))throw new Error(`unknown config section: ${t}`);Wl(t,e);let r=ze(_t());return r.schemaVersion=Lt,r[t]={...r[t]||{},...e},Or(r),Te=ur(Rt(),r),Te}function Ql(){let t=xt();if(t.device?.id)return t.device.id;let e=zl();return Ct("device",{id:e}),e}function ed(t,e){if(!Vl.includes(e))throw new Error(`invalid step status: ${e}`);let r=ze(_t()),n={...r.setup?.steps||{},[t]:e};return Ct("setup",{...r.setup||{},steps:n})}function td(t=!0){return Ct("setup",{complete:!!t})}function rd(){return!!xt().setup?.complete}function nd(){try{cr(ee)&&Fl(ee)}catch{}return Te=null,xt()}var Lt,aa,Vl,Zl,Te,sa,Ar=K(()=>{gt();ir();Lt=1,aa=["embedded","local","docker","url"],Vl=["pending","active","done","error"];Zl={},Te=null;sa=!1});var da={};Ze(da,{default:()=>ad});var C,P,kr,fr,Rr,la,od,ad,pa=K(()=>{Ar();ir();C=(t,e)=>process.env[t]??e,P=()=>xt(),kr=t=>P().llm.provider===t&&P().llm.apiKey||"",fr=t=>P().llm.provider===t&&P().llm.model||"",Rr=t=>P().embedding.provider===t&&P().embedding.apiKey||"",la=C("SIGIL_DB_TYPE","postgres");if(la!=="postgres")throw new Error(`SIGIL_DB_TYPE=${la} is no longer supported. Sigil 0.10.0+ is Postgres-only.
6
- PGlite was deprecated; existing PGlite data at ~/.sigil/db is preserved but unreachable from this version.
7
- Set SIGIL_DB_TYPE=postgres in ~/.sigil/.env and configure SIGIL_DB_HOST / PORT / NAME / USER / PASSWORD.
8
- Run \`sigil init\` for an interactive setup.`);od={db:{type:"postgres",get mode(){return process.env.SIGIL_DB_MODE||P().database.mode||null},get url(){return process.env.SIGIL_DATABASE_URL||process.env.DATABASE_URL||P().database.url||null},get host(){return process.env.SIGIL_DB_HOST||P().database.host||"localhost"},get port(){return Number(process.env.SIGIL_DB_PORT||P().database.port||5432)},get database(){return process.env.SIGIL_DB_NAME||P().database.name||"sigil"},get user(){return process.env.SIGIL_DB_USER||P().database.user||"sigil_app"},get password(){return process.env.SIGIL_DB_PASSWORD||P().database.password||""}},embedding:{get provider(){return process.env.EMBEDDING_PROVIDER||P().embedding.provider||""},get model(){return process.env.EMBEDDING_MODEL||P().embedding.model||"mxbai-embed-large"},get dimensions(){return 1024},get ollamaHost(){return process.env.OLLAMA_HOST||(P().embedding.provider==="ollama"?P().embedding.host:"")||"http://localhost:11434"},get openaiApiKey(){return process.env.OPENAI_API_KEY||Rr("openai")},get voyageApiKey(){return process.env.VOYAGE_API_KEY||Rr("voyage")},get openrouterApiKey(){return process.env.OPENROUTER_API_KEY||Rr("openrouter")},openrouterBaseUrl:process.env.EMBEDDING_OPENROUTER_BASE_URL||process.env.LLM_OPENROUTER_BASE_URL||"",openrouterReferer:process.env.EMBEDDING_OPENROUTER_REFERER||process.env.LLM_OPENROUTER_REFERER||"https://github.com/Anmol-Srv/sigil",openrouterTitle:process.env.EMBEDDING_OPENROUTER_TITLE||process.env.LLM_OPENROUTER_TITLE||"Sigil"},llm:{get provider(){return process.env.LLM_PROVIDER||P().llm.provider||""},get openaiApiKey(){return process.env.OPENAI_API_KEY||kr("openai")},get openaiModel(){return process.env.LLM_OPENAI_MODEL||fr("openai")||"gpt-4o-mini"},get ollamaHost(){return process.env.LLM_OLLAMA_HOST||process.env.OLLAMA_HOST||(P().llm.provider==="ollama"?P().llm.host:"")||"http://localhost:11434"},get ollamaModel(){return process.env.LLM_OLLAMA_MODEL||fr("ollama")||"qwen2.5:7b"},get cliModel(){return process.env.LLM_CLI_MODEL||fr("claude-cli")||"haiku"},get cliPath(){return process.env.LLM_CLI_PATH||""},get apiKey(){return process.env.ANTHROPIC_API_KEY||kr("anthropic")},get openrouterApiKey(){return process.env.OPENROUTER_API_KEY||kr("openrouter")},get openrouterModel(){return process.env.LLM_OPENROUTER_MODEL||fr("openrouter")||"google/gemini-flash-latest"},get openrouterBaseUrl(){return process.env.LLM_OPENROUTER_BASE_URL||""},get openrouterReferer(){return process.env.LLM_OPENROUTER_REFERER||"https://github.com/Anmol-Srv/sigil"},get openrouterTitle(){return process.env.LLM_OPENROUTER_TITLE||"Sigil"},get extractionModel(){return process.env.LLM_EXTRACTION_MODEL||""},get decisionModel(){return process.env.LLM_DECISION_MODEL||""},get entityModel(){return process.env.LLM_ENTITY_MODEL||""},get maxRetries(){return Number(process.env.LLM_MAX_RETRIES)||3},get cliTimeout(){return Number(process.env.LLM_CLI_TIMEOUT)||12e4},get requestTimeout(){return Number(process.env.LLM_REQUEST_TIMEOUT)||6e4}},output:{storage:process.env.OUTPUT_STORAGE||"local",dir:process.env.OUTPUT_DIR||"./output",s3:{endpoint:process.env.S3_ENDPOINT||"",bucket:process.env.S3_BUCKET||"",region:process.env.S3_REGION||"us-east-1",accessKey:process.env.S3_ACCESS_KEY||"",secretKey:process.env.S3_SECRET_KEY||"",publicUrl:process.env.S3_PUBLIC_URL||""}},server:{port:Number(process.env.PORT)||4e3,host:process.env.HOST||"0.0.0.0",logLevel:process.env.LOG_LEVEL||"info"},http:{enabled:C("SIGIL_HTTP_ENABLED","true")!=="false",host:C("SIGIL_HTTP_HOST","127.0.0.1"),port:Number(C("SIGIL_HTTP_PORT",7777))},network:{mode:C("SIGIL_MODE","solo"),enabled:C("SIGIL_NETWORK_ENABLED",null)===null?C("SIGIL_MODE","solo")!=="solo":C("SIGIL_NETWORK_ENABLED","false")!=="false",masterNodeId:C("SIGIL_MASTER_NODE_ID","")||null},defaults:{namespace:process.env.DEFAULT_NAMESPACE||"default"},memory:{skipThreshold:Number(process.env.MEMORY_SKIP_THRESHOLD)||.88,ambiguousThreshold:Number(process.env.MEMORY_AMBIGUOUS_THRESHOLD)||.78,minFactSimilarity:Number(process.env.MEMORY_MIN_FACT_SIMILARITY)||.45,injectionFloor:Number(process.env.MEMORY_INJECTION_FLOOR)||.6},search:{synthesize:C("SIGIL_SYNTHESIZE","true")!=="false",synthesizeModel:C("SIGIL_SYNTH_MODEL","")},ingest:{eagerExtract:C("SIGIL_EAGER_EXTRACT","true")!=="false",extractRelations:C("SIGIL_EXTRACT_RELATIONS","true")!=="false",graphGleanRounds:Number(C("SIGIL_GRAPH_GLEAN_ROUNDS",0))},hebbian:{entity:{enabled:C("SIGIL_HEBBIAN_ENTITY_ENABLED",null,"true")!=="false",eta:Number(C("SIGIL_HEBBIAN_ENTITY_ETA",null,1)),cap:Number(C("SIGIL_HEBBIAN_ENTITY_CAP",null,50)),halfLifeDays:Number(C("SIGIL_HEBBIAN_ENTITY_HALF_LIFE_DAYS",null,30)),minEffective:Number(C("SIGIL_HEBBIAN_ENTITY_MIN_EFFECTIVE",null,.5)),rrfWeight:Number(C("SIGIL_HEBBIAN_ENTITY_RRF_WEIGHT",null,.3)),maxWriteEntities:Number(C("SIGIL_HEBBIAN_ENTITY_MAX_WRITE",null,12)),expandPerSeed:Number(C("SIGIL_HEBBIAN_ENTITY_EXPAND_PER_SEED",null,3))}}},ad=od});import{readFile as ma,writeFile as Xv,unlink as ha,mkdir as Qv}from"node:fs/promises";import{existsSync as ga}from"node:fs";function sd(t){if(!t||!Number.isFinite(t))return!1;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function id(){if(!ga(sr))return null;try{let t=(await ma(sr,"utf8")).trim(),e=Number(t);return Number.isFinite(e)?e:null}catch{return null}}async function cd(){try{await ha(sr)}catch{}}async function ud(){try{await ha(Fe)}catch{}}async function ya(){try{return JSON.parse(await ma(na,"utf8"))}catch{return null}}async function ld(){let t=await ya();return Number.isFinite(t?.pid)?t.pid:null}async function dd(){try{let{default:t}=await Promise.resolve().then(()=>(pa(),da));if(!t.http.enabled)return!1;let{host:e,port:r}=t.http,n=new AbortController,o=setTimeout(()=>n.abort(),500);try{return(await fetch(`http://${e}:${r}/healthz`,{signal:n.signal})).ok}finally{clearTimeout(o)}}catch{return!1}}async function _a(){let t=await id();if(t&&sd(t)){let e=await ya();if(e&&Number.isFinite(e.ts)&&Date.now()-e.ts<fd&&e.pid===t)return t}return await dd()?await ld()??"unknown":(t&&await cd(),ga(Fe)&&await ud(),null)}var fd,xa=K(()=>{gt();fd=45e3});import{existsSync as pd}from"node:fs";import{dirname as md,join as Lr}from"node:path";import{fileURLToPath as hd}from"node:url";function va(){let t=[Lr(Ue,"dist","daemon.js"),Lr(Ue,"src","daemon","index.js"),Lr(md(hd(import.meta.url)),"..","daemon","index.js")];for(let e of t)if(pd(e))return e;throw new Error("cannot locate daemon entry point (looked in dist/ and src/daemon/)")}var ba=K(()=>{gt()});import{connect as gd}from"node:net";import{randomUUID as yd}from"node:crypto";function lr({path:t=Fe,timeoutMs:e=3e4}={}){return new Promise((r,n)=>{let o=gd(t),a=new Map,i="",s=!1;o.setEncoding("utf8"),o.once("connect",()=>{o.off("error",c),r(u())});function c(l){n(l)}o.once("error",c),o.on("data",l=>{i+=l;let p;for(;(p=i.indexOf(`
9
- `))!==-1;){let y=i.slice(0,p);if(i=i.slice(p+1),!y.trim())continue;let x;try{x=JSON.parse(y)}catch{continue}let O=a.get(x.id);O&&(a.delete(x.id),clearTimeout(O.timer),x.ok?O.resolve(x):O.reject(new Cr(x.error||{})))}}),o.on("close",()=>{s=!0;for(let[,l]of a){clearTimeout(l.timer);let p=new Error("daemon connection closed");p.code="ECLOSED",l.reject(p)}a.clear()}),o.on("error",()=>{});function u(){return{call(l,p){if(s){let I=new Error("client is closed");return I.code="ECLOSED",Promise.reject(I)}let y=yd(),x=process.env.SIGIL_AGENT||null,O=JSON.stringify({id:y,method:l,params:p,agent:x})+`
10
- `;return new Promise((I,w)=>{let $=setTimeout(()=>{a.delete(y)&&w(new Error(`rpc timeout after ${e}ms: ${l}`))},e);a.set(y,{resolve:I,reject:w,timer:$}),o.write(O)})},close(){return new Promise(l=>{if(s)return l();o.end(()=>l())})}}}})}var Cr,Ta=K(()=>{gt();Cr=class extends Error{constructor({code:e,message:r,stack:n}){super(r||e||"rpc error"),this.name="SigilRpcError",this.code=e||"handler_error",n&&(this.remoteStack=n)}}});import{spawn as _d}from"node:child_process";import{existsSync as xd,openSync as Ea,closeSync as Ia,mkdirSync as vd,readFileSync as bd}from"node:fs";import{setTimeout as Td}from"node:timers/promises";async function dr({quiet:t=!1,timeoutMs:e}={}){let r=e?{timeoutMs:e}:void 0;return await wa()?lr(r):(t||process.stderr.write(`[sigil] daemon not running, starting it...
11
- `),await Sd(),await wd(),lr(r))}async function wa(){if(!xd(Fe))return!1;try{let t=await lr({timeoutMs:1e3});return await t.call("ping",{}),await t.close(),!0}catch{return!1}}async function Sd(){vd(N,{recursive:!0}),await _a();let t=va(),e=Ea(ht,"a"),r=Ea(ht,"a");_d(process.execPath,[t],{detached:!0,stdio:["ignore",e,r],env:{...process.env,SIGIL_DAEMON_AUTOSPAWN:"1"}}).unref();try{Ia(e)}catch{}try{Ia(r)}catch{}}async function wd(){let t=Date.now()+Sa,e=Ed;for(;Date.now()<t;){if(await wa())return;await Td(e),e=Math.min(e*2,Id)}let r=Od(ht,12),n=r?`
3
+ var ss=Object.defineProperty;var z=(t,e)=>()=>(t&&(e=t(t=0)),e);var we=(t,e)=>{for(var r in e)ss(t,r,{get:e[r],enumerable:!0})};import{fileURLToPath as Wf}from"node:url";import{dirname as sa,join as E,sep as Gv}from"node:path";import{existsSync as ia}from"node:fs";import{homedir as Kf,tmpdir as Uv}from"node:os";function qf(){let t=sa(Wf(import.meta.url));for(let e=0;e<10;e++){if(ia(E(t,"package.json"))&&ia(E(t,"prompts")))return t;let r=sa(t);if(r===t)break;t=r}return process.cwd()}var Fe,zv,Hv,ua,C,ir,te,Zv,Vv,Wv,Kv,qv,Jv,Yv,Xv,Qv,eb,tb,Ue,ur,mt,ca,Er,rb,nb,ob,ab,sb,ib,la,ub,cb,ht=z(()=>{Fe=qf(),zv=E(Fe,"prompts"),Hv=E(Fe,"src","db","migrations"),ua=Kf(),C=E(ua,".sigil"),ir=E(C,".env"),te=E(C,"config.json"),Zv=E(C,"db"),Vv=E(C,"snapshots"),Wv=E(C,"CLAUDE.md"),Kv=E(C,"schemas"),qv=E(C,".hook-errors.log"),Jv=E(C,".update-available"),Yv=E(C,".last-clean-doctor"),Xv=E(C,".active-session.json"),Qv=E(C,".stop-cursor.json"),eb=E(C,".stop-spool.jsonl"),tb=E(C,".hook-dedup.json"),Ue=E(C,"sock"),ur=E(C,"sigild.pid"),mt=E(C,"sigild.log"),ca=E(C,"heartbeat.json"),Er=E(C,".spawn.lock"),rb=E(C,".daemon-breaker.json"),nb=E(C,"gui.token"),ob=E(Fe,"dist","gui"),ab=E(Fe,"src","gui","web"),sb=E(C,"iroh"),ib=E(C,"identity.key"),la=E(ua,".claude"),ub=E(la,"settings.json"),cb=E(la,"CLAUDE.md")});var ze,cr=z(()=>{ze=1024});var ha={};we(ha,{CONFIG_SCHEMA_VERSION:()=>Ct,EMBEDDING_DIM:()=>ze,__resetTestConfig:()=>fd,__setTestConfig:()=>ld,ensureDeviceId:()=>dd,getConfig:()=>_t,isSetupComplete:()=>hd,loadConfig:()=>ma,markSetupComplete:()=>md,patchConfig:()=>Rt,resetConfig:()=>gd,setStepStatus:()=>pd});import{existsSync as lr,readFileSync as da,writeFileSync as Jf,renameSync as pa,mkdirSync as Yf,chmodSync as Xf,unlinkSync as Qf}from"node:fs";import{dirname as ed}from"node:path";import{randomUUID as td}from"node:crypto";function yt(){return{schemaVersion:Ct,device:{id:null},database:{mode:null,url:null,host:"localhost",port:5432,name:"sigil",user:"sigil_app",password:null},llm:{provider:null,model:null,apiKey:null,host:null,cliPath:"",extractionModel:"",decisionModel:"",entityModel:"",maxRetries:3,cliTimeout:12e4,requestTimeout:6e4,maxClaudeProcs:4,openrouterBaseUrl:"",openrouterReferer:"https://github.com/Anmol-Srv/sigil",openrouterTitle:"Sigil",managedSession:{enabled:!1,poolSize:2,tokenBudget:6e4,taskTimeoutMs:12e4,queueTimeoutMs:45e3,firstTaskTimeoutMs:45e3,healthProbeMs:15e3,clearBetweenTasks:!0}},embedding:{provider:null,model:null,apiKey:null,host:null,openrouterBaseUrl:"",openrouterReferer:"https://github.com/Anmol-Srv/sigil",openrouterTitle:"Sigil"},identity:{name:null},http:{enabled:!0,host:"127.0.0.1",port:7777},network:{mode:"solo",enabled:!1,masterNodeId:null},defaults:{namespace:"default",searchNamespaces:[]},memory:{skipThreshold:.88,ambiguousThreshold:.78,supersedeThreshold:.72,supersedeScanLimit:8,minFactSimilarity:.45,injectionFloor:.6,graphHubMentionCutoff:25},search:{synthesize:!0,synthesizeModel:""},jev:{enabled:!1,apiKey:null,model:"jev-1.13.0",timeoutMs:4e3,maxRetries:2,maxCandidates:12,minScore:.55,injectionMax:.7,autoInject:!1},ingest:{eagerExtract:!0,extractRelations:!1,graphGleanRounds:0,workerConcurrency:2,maxJobAttempts:3},output:{storage:"local",dir:"./output",s3:{endpoint:"",bucket:"",region:"us-east-1",accessKey:"",secretKey:"",publicUrl:""}},hebbian:{entity:{enabled:!0,eta:1,cap:50,halfLifeDays:30,minEffective:.5,rrfWeight:.3,maxWriteEntities:12,expandPerSeed:3}},preferences:{noUpdateCheck:!1},setup:{complete:!1,steps:{}}}}function gt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function $t(t,e){if(!gt(e))return e;let r=Array.isArray(t)?[...t]:{...t};for(let[n,o]of Object.entries(e))r[n]=gt(o)&&gt(r[n])?$t(r[n],o):o;return r}function xt(){if(!lr(te))return{};try{return JSON.parse(da(te,"utf8"))||{}}catch{return{}}}function od(t){let e=t,r=Number(e.schemaVersion)||1;for(;r<Ct;){let n=r+1,o=nd[n];e=o?o(e):{...e,schemaVersion:n},r=n}return e}function He(t){let e=yt(),r={};for(let n of Object.keys(e)){if(!(n in t))continue;if(!gt(e[n])){r[n]=t[n];continue}let o={};for(let a of Object.keys(e[n]))t[n]&&a in t[n]&&(o[a]=t[n][a]);n==="setup"&&gt(t.setup?.steps)&&(o.steps=t.setup.steps),r[n]=o}return r}function $r(t){Yf(ed(te),{recursive:!0});let e=`${te}.tmp`;Jf(e,`${JSON.stringify(t,null,2)}
4
+ `,{mode:384}),pa(e,te);try{Xf(te,384)}catch{}}function ad(t,e){let r={};if(!gt(e))throw new Error(`config patch for "${t}" must be an object`);if(t==="database"&&("mode"in e&&e.mode!==null&&!Cr.includes(e.mode)&&(r.mode=`must be one of ${Cr.join(", ")}`),"port"in e&&e.port!=null&&!Number.isInteger(Number(e.port))&&(r.port="must be an integer"),"url"in e&&e.url!=null&&typeof e.url!="string"&&(r.url="must be a string")),Object.keys(r).length){let n=new Error(`invalid config for "${t}": ${JSON.stringify(r)}`);throw n.code="invalid_config",n.errors=r,n}}function sd(t){if(!lr(t))return null;let e={};for(let r of da(t,"utf8").split(`
5
+ `)){let n=r.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/i);if(!n)continue;let o=n[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),e[n[1]]=o}return e}function id(t){let e={},r={};if(t.SIGIL_DATABASE_URL||t.DATABASE_URL?(r.mode="url",r.url=t.SIGIL_DATABASE_URL||t.DATABASE_URL):t.SIGIL_DB_HOST||t.SIGIL_DB_NAME||t.SIGIL_DB_PASSWORD?(r.mode="local",t.SIGIL_DB_HOST&&(r.host=t.SIGIL_DB_HOST),t.SIGIL_DB_PORT&&(r.port=Number(t.SIGIL_DB_PORT)||5432),t.SIGIL_DB_NAME&&(r.name=t.SIGIL_DB_NAME),t.SIGIL_DB_USER&&(r.user=t.SIGIL_DB_USER),t.SIGIL_DB_PASSWORD&&(r.password=t.SIGIL_DB_PASSWORD)):t.SIGIL_DB_MODE&&Cr.includes(t.SIGIL_DB_MODE)&&(r.mode=t.SIGIL_DB_MODE),Object.keys(r).length&&(e.database=r),t.LLM_PROVIDER){let a={provider:t.LLM_PROVIDER},i={anthropic:t.ANTHROPIC_API_KEY,openai:t.OPENAI_API_KEY,openrouter:t.OPENROUTER_API_KEY}[t.LLM_PROVIDER];i&&(a.apiKey=i);let s={openai:t.LLM_OPENAI_MODEL,openrouter:t.LLM_OPENROUTER_MODEL,ollama:t.LLM_OLLAMA_MODEL,"claude-cli":t.LLM_CLI_MODEL}[t.LLM_PROVIDER];s&&(a.model=s),t.LLM_PROVIDER==="ollama"&&(t.LLM_OLLAMA_HOST||t.OLLAMA_HOST)&&(a.host=t.LLM_OLLAMA_HOST||t.OLLAMA_HOST),e.llm=a}if(t.EMBEDDING_PROVIDER){let a={provider:t.EMBEDDING_PROVIDER};t.EMBEDDING_MODEL&&(a.model=t.EMBEDDING_MODEL);let i={openai:t.OPENAI_API_KEY,voyage:t.VOYAGE_API_KEY,openrouter:t.OPENROUTER_API_KEY}[t.EMBEDDING_PROVIDER];i&&(a.apiKey=i),t.EMBEDDING_PROVIDER==="ollama"&&t.OLLAMA_HOST&&(a.host=t.OLLAMA_HOST),e.embedding=a}t.SIGIL_MANAGED_SESSION!==void 0&&(e.llm=e.llm||{},e.llm.managedSession={enabled:t.SIGIL_MANAGED_SESSION==="true"});let n={};t.SIGIL_MODE&&(n.mode=t.SIGIL_MODE),t.SIGIL_NETWORK_ENABLED!==void 0?n.enabled=t.SIGIL_NETWORK_ENABLED!=="false":t.SIGIL_MODE&&t.SIGIL_MODE!=="solo"&&(n.enabled=!0),t.SIGIL_MASTER_NODE_ID&&(n.masterNodeId=t.SIGIL_MASTER_NODE_ID),Object.keys(n).length&&(e.network=n);let o={};return t.SIGIL_HTTP_PORT&&(o.port=Number(t.SIGIL_HTTP_PORT)||7777),t.SIGIL_HTTP_HOST&&(o.host=t.SIGIL_HTTP_HOST),t.SIGIL_HTTP_ENABLED!==void 0&&(o.enabled=t.SIGIL_HTTP_ENABLED!=="false"),Object.keys(o).length&&(e.http=o),t.SIGIL_SETUP_COMPLETE==="true"&&(e.setup={complete:!0}),e}function ud(){if(!fa){fa=!0;try{let t=sd(ir);if(!t)return;let e=id(t),r=He(xt()),n={database:!!r.database?.mode,llm:!!r.llm?.provider,embedding:!!r.embedding?.provider,setup:!!r.setup?.complete};for(let[o,a]of Object.entries(e))if(!n[o])try{Rt(o,a)}catch{}try{pa(ir,`${ir}.migrated`)}catch{}}catch{}}}function ma({migrateEnv:t=!0}={}){t&&ud();let e=xt(),r=od(e);return lr(te)&&r.schemaVersion!==e.schemaVersion&&$r(He(r)),W=$t(yt(),He(r)),cd(),W}function cd(){let t=W?.setup?.steps;if(!t)return;let e=Object.entries(t).filter(([,o])=>o==="active").map(([o])=>o);if(!e.length)return;let r=He(xt()),n={...r.setup?.steps||{}};for(let o of e)n[o]="pending";$r({...r,schemaVersion:Ct,setup:{...r.setup||{},steps:n}}),W=$t(yt(),He(xt()))}function _t(){return W||ma()}function ld(t={}){return W=$t(W??yt(),t),W}function fd(){W=null}function Rt(t,e){if(!(t in yt()))throw new Error(`unknown config section: ${t}`);ad(t,e);let r=He(xt());return r.schemaVersion=Ct,r[t]={...r[t]||{},...e},$r(r),W=$t(yt(),r),W}function dd(){let t=_t();if(t.device?.id)return t.device.id;let e=td();return Rt("device",{id:e}),e}function pd(t,e){if(!rd.includes(e))throw new Error(`invalid step status: ${e}`);let r=He(xt()),n={...r.setup?.steps||{},[t]:e};return Rt("setup",{...r.setup||{},steps:n})}function md(t=!0){return Rt("setup",{complete:!!t})}function hd(){return!!_t().setup?.complete}function gd(){try{lr(te)&&Qf(te)}catch{}return W=null,_t()}var Ct,Cr,rd,nd,W,fa,Rr=z(()=>{ht();cr();Ct=2,Cr=["embedded","local","docker","url"],rd=["pending","active","done","error"];nd={},W=null;fa=!1});var ga={};we(ga,{default:()=>xd});var x,Pr,Pt,Mr,yd,xd,ya=z(()=>{Rr();cr();x=()=>_t(),Pr=t=>x().llm.provider===t&&x().llm.apiKey||"",Pt=t=>x().llm.provider===t&&x().llm.model||"",Mr=t=>x().embedding.provider===t&&x().embedding.apiKey||"",yd={db:{type:"postgres",get mode(){return x().database.mode??null},get url(){return x().database.url??null},get host(){return x().database.host??"localhost"},get port(){return Number(x().database.port??5432)},get database(){return x().database.name??"sigil"},get user(){return x().database.user??"sigil_app"},get password(){return x().database.password??""}},embedding:{get provider(){return x().embedding.provider??""},get model(){return x().embedding.model??"mxbai-embed-large"},get dimensions(){return 1024},get ollamaHost(){return(x().embedding.provider==="ollama"?x().embedding.host:"")||"http://localhost:11434"},get openaiApiKey(){return Mr("openai")},get voyageApiKey(){return Mr("voyage")},get openrouterApiKey(){return Mr("openrouter")},get openrouterBaseUrl(){return x().embedding.openrouterBaseUrl??""},get openrouterReferer(){return x().embedding.openrouterReferer??"https://github.com/Anmol-Srv/sigil"},get openrouterTitle(){return x().embedding.openrouterTitle??"Sigil"}},llm:{get provider(){return x().llm.provider??""},get openaiApiKey(){return Pr("openai")},get openaiModel(){return Pt("openai")||"gpt-4o-mini"},get ollamaHost(){return(x().llm.provider==="ollama"?x().llm.host:"")||"http://localhost:11434"},get ollamaModel(){return Pt("ollama")||"qwen2.5:7b"},get cliModel(){return Pt("claude-cli")||"haiku"},get cliPath(){return x().llm.cliPath??""},get codexModel(){return Pt("codex")||null},get codexPath(){return x().llm.codexPath??""},get codexExtraArgs(){return x().llm.codexExtraArgs??[]},get apiKey(){return Pr("anthropic")},get openrouterApiKey(){return Pr("openrouter")},get openrouterModel(){return Pt("openrouter")||"google/gemini-flash-latest"},get openrouterBaseUrl(){return x().llm.openrouterBaseUrl??""},get openrouterReferer(){return x().llm.openrouterReferer??"https://github.com/Anmol-Srv/sigil"},get openrouterTitle(){return x().llm.openrouterTitle??"Sigil"},get extractionModel(){return x().llm.extractionModel??""},get decisionModel(){return x().llm.decisionModel??""},get entityModel(){return x().llm.entityModel??""},get maxRetries(){return Number(x().llm.maxRetries??3)||3},get cliTimeout(){return Number(x().llm.cliTimeout??12e4)||12e4},get maxClaudeProcs(){return Math.max(1,Number(x().llm.maxClaudeProcs??4)||4)},managedSession:{get enabled(){return x().llm.managedSession?.enabled===!0},get poolSize(){return Math.max(1,Number(x().llm.managedSession?.poolSize??2)||2)},get tokenBudget(){return Number(x().llm.managedSession?.tokenBudget??6e4)||6e4},get taskTimeoutMs(){return Number(x().llm.managedSession?.taskTimeoutMs??12e4)||12e4},get queueTimeoutMs(){return Number(x().llm.managedSession?.queueTimeoutMs??45e3)||45e3},get firstTaskTimeoutMs(){return Number(x().llm.managedSession?.firstTaskTimeoutMs??45e3)||45e3},get healthProbeMs(){return Number(x().llm.managedSession?.healthProbeMs??15e3)||15e3},get clearBetweenTasks(){return x().llm.managedSession?.clearBetweenTasks!==!1}},get requestTimeout(){return Number(x().llm.requestTimeout??6e4)||6e4}},get output(){return x().output},get http(){return x().http},get network(){return x().network},get defaults(){return x().defaults},get memory(){return x().memory},get search(){return x().search},get jev(){return x().jev},get ingest(){return x().ingest},get hebbian(){return x().hebbian},get preferences(){return x().preferences}},xd=yd});import{readFile as xa,writeFile as vb,unlink as _a,mkdir as bb}from"node:fs/promises";import{existsSync as va}from"node:fs";function Lr(t){if(!t||!Number.isFinite(t))return!1;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function _d(){if(!va(ur))return null;try{let t=(await xa(ur,"utf8")).trim(),e=Number(t);return Number.isFinite(e)?e:null}catch{return null}}async function vd(){try{await _a(ur)}catch{}}async function bd(){try{await _a(Ue)}catch{}}async function ba(){try{return JSON.parse(await xa(ca,"utf8"))}catch{return null}}async function Td(){let t=await ba();return Number.isFinite(t?.pid)?t.pid:null}async function Sd(){try{let{default:t}=await Promise.resolve().then(()=>(ya(),ga));if(!t.http.enabled)return!1;let{host:e,port:r}=t.http,n=new AbortController,o=setTimeout(()=>n.abort(),500);try{return(await fetch(`http://${e}:${r}/healthz`,{signal:n.signal})).ok}finally{clearTimeout(o)}}catch{return!1}}async function Nr(){let t=await _d();if(t&&Lr(t)){let e=await ba();if(e&&Number.isFinite(e.ts)&&Date.now()-e.ts<wd&&e.pid===t)return t}return await Sd()?await Td()??"unknown":(t&&await vd(),va(Ue)&&await bd(),null)}var wd,wa=z(()=>{ht();wd=45e3});import{existsSync as kd}from"node:fs";import{dirname as Id,join as Dr}from"node:path";import{fileURLToPath as Od}from"node:url";function Ta(){let t=[Dr(Fe,"dist","daemon.js"),Dr(Fe,"src","daemon","index.js"),Dr(Id(Od(import.meta.url)),"..","daemon","index.js")];for(let e of t)if(kd(e))return e;throw new Error("cannot locate daemon entry point (looked in dist/ and src/daemon/)")}var Sa=z(()=>{ht()});import{connect as Ad}from"node:net";import{randomUUID as Ed}from"node:crypto";function Mt({path:t=Ue,timeoutMs:e=3e4}={}){return new Promise((r,n)=>{let o=Ad(t),a=new Map,i="",s=!1;o.setEncoding("utf8"),o.once("connect",()=>{o.off("error",u),r(c())});function u(f){n(f)}o.once("error",u),o.on("data",f=>{i+=f;let p;for(;(p=i.indexOf(`
6
+ `))!==-1;){let d=i.slice(0,p);if(i=i.slice(p+1),!d.trim())continue;let _;try{_=JSON.parse(d)}catch{continue}let A=a.get(_.id);A&&(a.delete(_.id),clearTimeout(A.timer),_.ok?A.resolve(_):A.reject(new jr(_.error||{})))}}),o.on("close",()=>{s=!0;for(let[,f]of a){clearTimeout(f.timer);let p=new Error("daemon connection closed");p.code="ECLOSED",f.reject(p)}a.clear()}),o.on("error",()=>{});function c(){return{call(f,p,{timeoutMs:d=e}={}){if(s){let S=new Error("client is closed");return S.code="ECLOSED",Promise.reject(S)}let _=Ed(),A=process.env.SIGIL_AGENT||null,O=JSON.stringify({id:_,method:f,params:p,agent:A})+`
7
+ `;return new Promise((S,M)=>{let K=setTimeout(()=>{a.delete(_)&&M(new Error(`rpc timeout after ${d}ms: ${f}`))},d);a.set(_,{resolve:S,reject:M,timer:K}),o.write(O)})},close(){return new Promise(f=>{if(s)return f();o.end(()=>f())})}}}})}var jr,ka=z(()=>{ht();jr=class extends Error{constructor({code:e,message:r,stack:n}){super(r||e||"rpc error"),this.name="SigilRpcError",this.code=e||"handler_error",n&&(this.remoteStack=n)}}});import{spawn as Cd}from"node:child_process";import{existsSync as $d,openSync as fr,closeSync as dr,mkdirSync as Aa,readFileSync as Ea,writeFileSync as Ia,unlinkSync as Ca}from"node:fs";import{setTimeout as $a}from"node:timers/promises";async function pr({quiet:t=!1,timeoutMs:e}={}){let r=e?{timeoutMs:e}:void 0;if(await mr())return Mt(r);let n=await Nr();if(n){if(await Md(Rd))return Mt(r);throw new Gr(n)}return await Ld({quiet:t}),await Gd(),Mt(r)}async function mr(){if(!$d(Ue))return!1;try{let t=await Mt({timeoutMs:1e3});return await t.call("ping",{}),await t.close(),!0}catch{return!1}}async function Md(t){let e=Date.now()+t,r=Ra;for(;Date.now()<e;){if(await mr())return!0;await $a(r),r=Math.min(r*2,Pa)}return!1}async function Ld({quiet:t}){if(Aa(C,{recursive:!0}),!!Nd())try{if(await mr())return;t||process.stderr.write(`[sigil] daemon not running, starting it...
8
+ `),await jd()}finally{Dd()}}function Nd(t=Er){try{let n=fr(t,"wx");return Ia(n,JSON.stringify({pid:process.pid,ts:Date.now()})),dr(n),!0}catch(n){if(n.code!=="EEXIST")throw n}let e=null;try{e=JSON.parse(Ea(t,"utf8"))}catch{}if(!(!e||!Number.isFinite(e.ts)||Date.now()-e.ts>Pd||Number.isFinite(e.pid)&&!Lr(e.pid)))return!1;try{Ca(t)}catch{}try{let n=fr(t,"wx");return Ia(n,JSON.stringify({pid:process.pid,ts:Date.now()})),dr(n),!0}catch{return!1}}function Dd(t=Er){try{Ca(t)}catch{}}async function jd(){Aa(C,{recursive:!0}),await Nr();let t=Ta(),e=fr(mt,"a"),r=fr(mt,"a");Cd(process.execPath,[t],{detached:!0,stdio:["ignore",e,r],env:{...process.env,SIGIL_DAEMON_AUTOSPAWN:"1"}}).unref();try{dr(e)}catch{}try{dr(r)}catch{}}async function Gd(){let t=Date.now()+Oa,e=Ra;for(;Date.now()<t;){if(await mr())return;await $a(e),e=Math.min(e*2,Pa)}let r=Bd(mt,12),n=r?`
12
9
 
13
- --- ${ht} (last lines) ---
14
- ${r}`:` \u2014 check ${ht}`;throw new Error(`daemon did not become ready within ${Sa}ms${n}`)}function Od(t,e){try{return bd(t,"utf8").split(`
10
+ --- ${mt} (last lines) ---
11
+ ${r}`:` \u2014 check ${mt}`;throw new Error(`daemon did not become ready within ${Oa}ms${n}`)}function Bd(t,e){try{return Ea(t,"utf8").split(`
15
12
  `).filter(n=>n.trim()).slice(-e).join(`
16
- `)}catch{return""}}var Sa,Ed,Id,Nr=K(()=>{gt();xa();ba();Ta();Sa=5e3,Ed=25,Id=400});var Aa={};Ze(Aa,{closeDaemonConnection:()=>Ld,daemonCall:()=>L,setInProcessDispatch:()=>Ad});function Ad(t){Pr=t}async function Oa(){return bt||(vt||(vt=dr({quiet:!0}).then(t=>(bt=t,t)).catch(t=>{throw vt=null,t})),vt)}function Rd(t){return t?t.code&&kd.has(t.code)?!0:/^(daemon connection closed|client is closed)/i.test(t.message||""):!1}async function L(t,e){if(Pr)return Pr(t,e??{});let r=await Oa();try{let{data:n}=await r.call(t,e??{});return n}catch(n){if(Rd(n)){bt=null,vt=null;let o=await Oa(),{data:a}=await o.call(t,e??{});return a}throw n}}async function Ld(){let t=bt;bt=null,vt=null,t&&await t.close()}var vt,bt,Pr,kd,H=K(()=>{Nr();vt=null,bt=null,Pr=null;kd=new Set(["ECONNREFUSED","ENOENT","EPIPE","ECONNRESET","ECLOSED"])});var Ba={};Ze(Ba,{buildPreamble:()=>Nd});async function Nd({cwd:t=process.cwd(),limit:e=12,call:r}={}){let n={state:"ready",checks:{},config:{},totals:{facts:0,documents:0},facts:[],issues:[]};n.config=await Pd(),n.checks.llm=n.config.llmProvider?{ok:!0,detail:`${n.config.llmProvider}${n.config.llmModel?`/${n.config.llmModel}`:""}`}:{ok:!1,detail:"not configured"},n.checks.embedding=n.config.embProvider?{ok:!0,detail:`${n.config.embProvider}/${n.config.embModel} (dim=${n.config.dim})`}:{ok:!1,detail:"not configured"},n.config.llmProvider||n.issues.push("No LLM provider configured \u2014 fact extraction is off. Run `sigil init`."),n.config.embProvider||n.issues.push("No embedding provider configured \u2014 semantic search is off. Run `sigil init`.");let o=null,a=r;if(!a)try{o=await dr({quiet:!0}),a=async(i,s)=>(await o.call(i,s??{})).data}catch(i){return n.checks.daemon={ok:!1,detail:i.message},n.issues.push("Sigil daemon not reachable \u2014 run `npx sigil` (or `sigil daemon start`)."),Ga(n)}n.checks.daemon={ok:!0};try{let i=null;try{i=await a("status",{}),n.totals={facts:i.facts??0,documents:i.documents??0},n.checks.db=i.db?.healthy?{ok:!0,detail:`${i.facts??0} facts`}:{ok:!1,detail:i.db?.error||"unreachable"},i.db?.healthy||n.issues.push(`Database unreachable: ${i.db?.error||"unknown"} \u2014 check Postgres, then \`sigil doctor\`.`);let s=i.providers;s?.embedding&&(n.checks.embedding=s.embedding.ok?{ok:!0,detail:`${s.embedding.provider}/${s.embedding.model} (dim=${s.embedding.dim})`}:{ok:!1,detail:s.embedding.error||"unreachable"},s.embedding.ok||n.issues.push(`Embedding provider unreachable: ${s.embedding.error} \u2014 semantic search/ingest will fail.`)),s?.llm&&(n.checks.llm=s.llm.ok?{ok:!0,detail:`${s.llm.provider}${s.llm.model?`/${s.llm.model}`:""}`}:{ok:!1,detail:s.llm.error||"unreachable"},s.llm.ok||n.issues.push(`LLM provider unreachable: ${s.llm.error} \u2014 fact extraction will fail.`))}catch(s){n.checks.db={ok:!1,detail:s.message},n.issues.push(`Could not query Sigil status: ${s.message}`)}try{let s=await a("setup.state",{});n.checks.setup=s.complete?{ok:!0}:{ok:!1,detail:`next: ${s.currentStep}`},s.complete||n.issues.push(`Setup incomplete \u2014 next step "${s.currentStep}". Run \`sigil init\` or open the GUI.`)}catch{}if(n.checks.db?.ok)try{let s=await a("refreshContext.explain",{cwd:t}),c=new Set;for(let u of s.sections||[]){for(let l of u.facts||[]){let p=(typeof l=="string"?l:l.content||"").trim();if(p&&!c.has(p)&&(c.add(p),n.facts.push({content:p,section:u.name}),n.facts.length>=e))break}if(n.facts.length>=e)break}}catch(s){n.checks.collection={ok:!1,detail:s.message}}}finally{if(o)try{await o.close()}catch{}}return Ga(n)}function Ga(t){let e=t.checks.daemon&&!t.checks.daemon.ok,r=t.checks.db&&!t.checks.db.ok,n=!!(t.config.llmProvider&&t.config.embProvider),o=t.checks.llm?.ok&&t.checks.embedding?.ok,a=t.checks.setup&&!t.checks.setup.ok||!n;return e||r||n&&!o?t.state="degraded":a?t.state="setup":t.state="ready",t}async function Pd(){try{let{getConfig:t}=await Promise.resolve().then(()=>(Ar(),fa)),e=t();return{llmProvider:e.llm?.provider||"",llmModel:e.llm?.model||"",embProvider:e.embedding?.provider||"",embModel:e.embedding?.model||"",dim:1024,name:e.identity?.name||""}}catch{return{llmProvider:"",llmModel:"",embProvider:"",embModel:"",dim:1024,name:""}}}var Ua=K(()=>{Nr();ir()});var Ha={};Ze(Ha,{renderPreamble:()=>$d,statusLines:()=>$r});function $d(t,{format:e="md",transport:r="cli"}={}){if(e==="json")return JSON.stringify(t,null,2);if(e==="lines")return $r(t).join(`
17
- `);let n=[...$r(t),""];if(t.facts.length){n.push(`## Sigil memory (${t.facts.length} facts loaded at session start)`);for(let o of t.facts)n.push(`- ${o.content}`)}else t.state==="degraded"?(n.push("## Sigil memory"),n.push("- (unavailable \u2014 see the health warnings below)")):(n.push("## Sigil memory"),n.push("- (nothing stored yet \u2014 facts accrue as you and the user work)"));if(n.push("",Md(r)),t.issues.length){n.push("","## Sigil health");for(let o of t.issues)n.push(`- \u26A0 ${o}`)}return n.join(`
18
- `)}function Fa(t){return t?t.ok?t.detail||"ok":!t.detail||t.detail==="not configured"?"not configured":`down (${String(t.detail).split(`
19
- `)[0].slice(0,80)})`:"unknown"}function $r(t){let e=[`SIGIL: ${t.state}`];return t.checks.daemon&&e.push(`DAEMON: ${t.checks.daemon.ok?"up":`down (${t.checks.daemon.detail||"unreachable"})`}`),t.checks.db&&e.push(`DB: ${t.checks.db.ok?`ok${t.checks.db.detail?` (${t.checks.db.detail})`:""}`:`down (${t.checks.db.detail||"unreachable"})`}`),e.push(`LLM: ${Fa(t.checks.llm)}`),e.push(`EMBED: ${Fa(t.checks.embedding)}`),e.push(`FACTS: ${t.facts.length} loaded / ${t.totals?.facts??0} total`),e}function Md(t){return t==="mcp"?["## Using Sigil (no automatic memory in this client)","- Nothing is injected or saved automatically here. Call the `search` tool BEFORE answering anything that depends on the user, their preferences, or this project; call `ingest` to save durable facts the user will want next session.","- When you use a stored fact, name it in one short clause so the user sees their context being applied."].join(`
13
+ `)}catch{return""}}var Oa,Ra,Pa,Rd,Pd,Gr,Br=z(()=>{ht();wa();Sa();ka();Oa=5e3,Ra=25,Pa=400,Rd=1200,Pd=15e3,Gr=class extends Error{constructor(e){super(`sigil daemon (pid ${e}) is alive but not responding \u2014 run \`sigil daemon restart\` if this persists`),this.name="SigilDaemonBusyError",this.code="daemon_busy",this.pid=e}}});var La={};we(La,{closeDaemonConnection:()=>Hd,daemonCall:()=>$,setInProcessDispatch:()=>Fd});function Fd(t){Fr=t}async function Ma(){return bt||(vt||(vt=pr({quiet:!0}).then(t=>(bt=t,t)).catch(t=>{throw vt=null,t})),vt)}function zd(t){return t?t.code&&Ud.has(t.code)?!0:/^(daemon connection closed|client is closed)/i.test(t.message||""):!1}async function $(t,e,r){if(Fr)return Fr(t,e??{});let n=await Ma();try{let{data:o}=await n.call(t,e??{},r);return o}catch(o){if(zd(o)){bt=null,vt=null;let a=await Ma(),{data:i}=await a.call(t,e??{},r);return i}throw o}}async function Hd(){let t=bt;bt=null,vt=null,t&&await t.close()}var vt,bt,Fr,Ud,U=z(()=>{Br();vt=null,bt=null,Fr=null;Ud=new Set(["ECONNREFUSED","ENOENT","EPIPE","ECONNRESET","ECLOSED"])});var Ha={};we(Ha,{readSource:()=>za,readSources:()=>Yd});import{readFile as Vd,stat as Wd}from"node:fs/promises";import{basename as Kd,extname as qd,resolve as Jd}from"node:path";import*as Ua from"node:fs/promises";async function za(t){let e=Jd(t),r=await Vd(e,"utf8"),n=Kd(e),o=qd(e).toLowerCase();return{content:r,title:n,sourcePath:e,sourceType:"file",contentType:Xd(o),metadata:{filePath:e,fileName:n,extension:o}}}async function Yd(t){let e=[];for await(let r of Ua.glob(t))(await Wd(r)).isFile()&&e.push(await za(r));return e}function Xd(t){return{".md":"text/markdown",".mdx":"text/markdown",".txt":"text/plain",".html":"text/html",".htm":"text/html",".json":"application/json",".js":"text/javascript",".ts":"text/javascript",".py":"text/x-python"}[t]||"text/plain"}var Za=z(()=>{});var Xa={};we(Xa,{buildPreamble:()=>tp});async function tp({cwd:t=process.cwd(),limit:e=12,call:r}={}){let n={state:"ready",checks:{},config:{},totals:{facts:0,documents:0},facts:[],issues:[]};n.config=await rp(),n.checks.llm=n.config.llmProvider?{ok:!0,detail:`${n.config.llmProvider}${n.config.llmModel?`/${n.config.llmModel}`:""}`}:{ok:!1,detail:"not configured"},n.checks.embedding=n.config.embProvider?{ok:!0,detail:`${n.config.embProvider}/${n.config.embModel} (dim=${n.config.dim})`}:{ok:!1,detail:"not configured"},n.config.llmProvider||n.issues.push("No LLM provider configured \u2014 fact extraction is off. Run `sigil init`."),n.config.embProvider||n.issues.push("No embedding provider configured \u2014 semantic search is off. Run `sigil init`.");let o=null,a=r;if(!a)try{o=await pr({quiet:!0}),a=async(i,s)=>(await o.call(i,s??{})).data}catch(i){return n.checks.daemon={ok:!1,detail:i.message},n.issues.push("Sigil daemon not reachable \u2014 run `sigil` (or `sigil daemon start`)."),Ya(n)}n.checks.daemon={ok:!0};try{let i=null;try{i=await a("status",{}),n.totals={facts:i.facts??null,documents:i.documents??null},n.checks.db=i.db?.healthy?{ok:!0,detail:`${i.facts??0} facts`}:{ok:!1,detail:i.db?.error||"unreachable"},i.db?.healthy||n.issues.push(`Database unreachable: ${i.db?.error||"unknown"} \u2014 check Postgres, then \`sigil doctor\`.`);let s=i.providers;s?.embedding&&(n.checks.embedding=s.embedding.ok?{ok:!0,detail:`${s.embedding.provider}/${s.embedding.model} (dim=${s.embedding.dim})`}:{ok:!1,detail:s.embedding.error||"unreachable"},s.embedding.ok||n.issues.push(`Embedding provider unreachable: ${s.embedding.error} \u2014 semantic search/ingest will fail.`)),s?.llm&&(n.checks.llm=s.llm.ok?{ok:!0,detail:`${s.llm.provider}${s.llm.model?`/${s.llm.model}`:""}`}:{ok:!1,detail:s.llm.error||"unreachable"},s.llm.ok||n.issues.push(`LLM provider unreachable: ${s.llm.error} \u2014 fact extraction will fail.`))}catch(s){n.checks.db={ok:!1,detail:s.message},n.issues.push(`Could not query Sigil status: ${s.message}`)}try{let s=await a("setup.state",{});n.checks.setup=s.complete?{ok:!0}:{ok:!1,detail:`next: ${s.currentStep}`},s.complete||n.issues.push(`Setup incomplete \u2014 next step "${s.currentStep}". Run \`sigil init\` or open the GUI.`)}catch{}if(n.checks.db?.ok)try{let s=await a("refreshContext.explain",{cwd:t}),u=new Set;for(let c of s.sections||[]){for(let f of c.facts||[]){let p=(typeof f=="string"?f:f.content||"").trim();if(p&&!u.has(p)&&(u.add(p),n.facts.push({content:p,section:c.name}),n.facts.length>=e))break}if(n.facts.length>=e)break}}catch(s){n.checks.collection={ok:!1,detail:s.message}}}finally{if(o)try{await o.close()}catch{}}return Ya(n)}function Ya(t){let e=t.checks.daemon&&!t.checks.daemon.ok,r=t.checks.db&&!t.checks.db.ok,n=!!(t.config.llmProvider&&t.config.embProvider),o=t.checks.llm?.ok&&t.checks.embedding?.ok,a=t.checks.setup&&!t.checks.setup.ok||!n;return e||r||n&&!o?t.state="degraded":a?t.state="setup":t.state="ready",t}async function rp(){try{let{getConfig:t}=await Promise.resolve().then(()=>(Rr(),ha)),e=t();return{llmProvider:e.llm?.provider||"",llmModel:e.llm?.model||"",embProvider:e.embedding?.provider||"",embModel:e.embedding?.model||"",dim:1024,name:e.identity?.name||""}}catch{return{llmProvider:"",llmModel:"",embProvider:"",embModel:"",dim:1024,name:""}}}var Qa=z(()=>{Br();cr()});var ts={};we(ts,{renderPreamble:()=>np,statusLines:()=>Ur});function np(t,{format:e="md",transport:r="cli"}={}){if(e==="json")return JSON.stringify(t,null,2);if(e==="lines")return Ur(t).join(`
14
+ `);let n=[...Ur(t),""];if(t.facts.length){n.push(`## Sigil memory (${t.facts.length} facts loaded at session start)`);for(let o of t.facts)n.push(`- ${o.content}`)}else t.state==="degraded"?(n.push("## Sigil memory"),n.push("- (unavailable \u2014 see the health warnings below)")):(n.push("## Sigil memory"),n.push("- (nothing stored yet \u2014 facts accrue as you and the user work)"));if(n.push("",op(r)),t.issues.length){n.push("","## Sigil health");for(let o of t.issues)n.push(`- \u26A0 ${o}`)}return n.join(`
15
+ `)}function es(t){return t?t.ok?t.detail||"ok":!t.detail||t.detail==="not configured"?"not configured":`down (${String(t.detail).split(`
16
+ `)[0].slice(0,80)})`:"unknown"}function Ur(t){let e=[`SIGIL: ${t.state}`];return t.checks.daemon&&e.push(`DAEMON: ${t.checks.daemon.ok?"up":`down (${t.checks.daemon.detail||"unreachable"})`}`),t.checks.db&&e.push(`DB: ${t.checks.db.ok?`ok${t.checks.db.detail?` (${t.checks.db.detail})`:""}`:`down (${t.checks.db.detail||"unreachable"})`}`),e.push(`LLM: ${es(t.checks.llm)}`),e.push(`EMBED: ${es(t.checks.embedding)}`),e.push(`FACTS: ${t.facts.length} loaded / ${t.totals?.facts??0} total`),e}function op(t){return t==="mcp"?["## Using Sigil (no automatic memory in this client)","- Nothing is injected or saved automatically here. Call the `search` tool BEFORE answering anything that depends on the user, their preferences, or this project; call `ingest` to save durable facts the user will want next session.","- When you use a stored fact, name it in one short clause so the user sees their context being applied."].join(`
20
17
  `):["## Using Sigil","- Memory is auto-injected per prompt and saved by hooks. Read the injected facts first; use `search` only to drill down when the injection missed something."].join(`
21
- `)}var za=K(()=>{});import{config as Gd}from"dotenv";import{resolve as Mr,dirname as Wa}from"node:path";import{fileURLToPath as Bd}from"node:url";import{existsSync as Ud}from"node:fs";import"dotenv/config";import{StdioServerTransport as jd}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as Dd}from"@modelcontextprotocol/sdk/server/mcp.js";var g={};Ze(g,{BRAND:()=>bs,DIRTY:()=>Ee,EMPTY_PATH:()=>Qa,INVALID:()=>_,NEVER:()=>ai,OK:()=>j,ParseStatus:()=>D,Schema:()=>T,ZodAny:()=>de,ZodArray:()=>se,ZodBigInt:()=>Se,ZodBoolean:()=>we,ZodBranded:()=>It,ZodCatch:()=>De,ZodDate:()=>Oe,ZodDefault:()=>Me,ZodDiscriminatedUnion:()=>Dt,ZodEffects:()=>Z,ZodEnum:()=>Pe,ZodError:()=>B,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>Gt,ZodIntersection:()=>Le,ZodIssueCode:()=>f,ZodLazy:()=>Ce,ZodLiteral:()=>Ne,ZodMap:()=>Xe,ZodNaN:()=>et,ZodNativeEnum:()=>$e,ZodNever:()=>W,ZodNull:()=>ke,ZodNullable:()=>Q,ZodNumber:()=>Ie,ZodObject:()=>U,ZodOptional:()=>z,ZodParsedType:()=>m,ZodPipeline:()=>St,ZodPromise:()=>pe,ZodReadonly:()=>je,ZodRecord:()=>jt,ZodSchema:()=>T,ZodSet:()=>Qe,ZodString:()=>le,ZodSymbol:()=>qe,ZodTransformer:()=>Z,ZodTuple:()=>X,ZodType:()=>T,ZodUndefined:()=>Ae,ZodUnion:()=>Re,ZodUnknown:()=>ae,ZodVoid:()=>Je,addIssueToContext:()=>d,any:()=>Rs,array:()=>Ps,bigint:()=>Ss,boolean:()=>Kr,coerce:()=>oi,custom:()=>zr,date:()=>ws,datetimeRegex:()=>Fr,defaultErrorMap:()=>ne,discriminatedUnion:()=>js,effect:()=>qs,enum:()=>Ks,function:()=>zs,getErrorMap:()=>Ke,getParsedType:()=>J,instanceof:()=>Es,intersection:()=>Gs,isAborted:()=>$t,isAsync:()=>We,isDirty:()=>Mt,isValid:()=>fe,late:()=>Ts,lazy:()=>Vs,literal:()=>Zs,makeIssue:()=>Et,map:()=>Fs,nan:()=>Is,nativeEnum:()=>Ws,never:()=>Cs,null:()=>ks,nullable:()=>Xs,number:()=>Zr,object:()=>$s,objectUtil:()=>pr,oboolean:()=>ni,onumber:()=>ri,optional:()=>Js,ostring:()=>ti,pipeline:()=>ei,preprocess:()=>Qs,promise:()=>Ys,quotelessJson:()=>qa,record:()=>Us,set:()=>Hs,setErrorMap:()=>Xa,strictObject:()=>Ms,string:()=>Vr,symbol:()=>Os,transformer:()=>qs,tuple:()=>Bs,undefined:()=>As,union:()=>Ds,unknown:()=>Ls,util:()=>S,void:()=>Ns});var S;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let a={};for(let i of o)a[i]=i;return a},t.getValidEnumValues=o=>{let a=t.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),i={};for(let s of a)i[s]=o[s];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(a){return o[a]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let a=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&a.push(i);return a},t.find=(o,a)=>{for(let i of o)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,a=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(o,a)=>typeof a=="bigint"?a.toString():a})(S||(S={}));var pr;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(pr||(pr={}));var m=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),J=t=>{switch(typeof t){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN(t)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(t)?m.array:t===null?m.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?m.promise:typeof Map<"u"&&t instanceof Map?m.map:typeof Set<"u"&&t instanceof Set?m.set:typeof Date<"u"&&t instanceof Date?m.date:m.object;default:return m.unknown}};var f=S.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),qa=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),B=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(a){return a.message},n={_errors:[]},o=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let s=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(i))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let a=o.path[0];r[a]=r[a]||[],r[a].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};B.create=t=>new B(t);var Ja=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===m.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:S.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case f.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case f.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,S.assertNever(t)}return{message:r}},ne=Ja;var Dr=ne;function Xa(t){Dr=t}function Ke(){return Dr}var Et=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,a=[...r,...o.path||[]],i={...o,path:a};if(o.message!==void 0)return{...o,path:a,message:o.message};let s="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)s=u(i,{data:e,defaultError:s}).message;return{...o,path:a,message:s}},Qa=[];function d(t,e){let r=Ke(),n=Et({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ne?void 0:ne].filter(o=>!!o)});t.common.issues.push(n)}var D=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return _;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let a=await o.key,i=await o.value;n.push({key:a,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:a,value:i}=o;if(a.status==="aborted"||i.status==="aborted")return _;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},_=Object.freeze({status:"aborted"}),Ee=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),$t=t=>t.status==="aborted",Mt=t=>t.status==="dirty",fe=t=>t.status==="valid",We=t=>typeof Promise<"u"&&t instanceof Promise;var h;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));var V=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},jr=(t,e)=>{if(fe(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new B(t.common.issues);return this._error=r,this._error}}};function b(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,s)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:o}}var T=class{get description(){return this._def.description}_getType(e){return J(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new D,ctx:{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(We(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},o=this._parseSync({data:e,path:n.path,parent:n});return jr(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return fe(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>fe(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},o=this._parse({data:e,path:n.path,parent:n}),a=await(We(o)?o:Promise.resolve(o));return jr(n,a)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,a)=>{let i=e(o),s=()=>a.addIssue({code:f.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new Z({schema:this,typeName:v.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return z.create(this,this._def)}nullable(){return Q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return pe.create(this,this._def)}or(e){return Re.create([this,e],this._def)}and(e){return Le.create(this,e,this._def)}transform(e){return new Z({...b(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Me({...b(this._def),innerType:this,defaultValue:r,typeName:v.ZodDefault})}brand(){return new It({typeName:v.ZodBranded,type:this,...b(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new De({...b(this._def),innerType:this,catchValue:r,typeName:v.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return St.create(this,e)}readonly(){return je.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},es=/^c[^\s-]{8,}$/i,ts=/^[0-9a-z]+$/,rs=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ns=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,os=/^[a-z0-9_-]{21}$/i,as=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ss=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,is=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",mr,us=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,fs=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ls=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ds=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ps=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ms=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Br="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",hs=new RegExp(`^${Br}$`);function Ur(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function gs(t){return new RegExp(`^${Ur(t)}$`)}function Fr(t){let e=`${Br}T${Ur(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function ys(t,e){return!!((e==="v4"||!e)&&us.test(t)||(e==="v6"||!e)&&ls.test(t))}function _s(t,e){if(!as.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function xs(t,e){return!!((e==="v4"||!e)&&fs.test(t)||(e==="v6"||!e)&&ds.test(t))}var le=class t extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){let a=this._getOrReturnCtx(e);return d(a,{code:f.invalid_type,expected:m.string,received:a.parsedType}),_}let n=new D,o;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(o=this._getOrReturnCtx(e,o),d(o,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(o=this._getOrReturnCtx(e,o),d(o,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,s=e.data.length<a.value;(i||s)&&(o=this._getOrReturnCtx(e,o),i?d(o,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&d(o,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")is.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"email",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")mr||(mr=new RegExp(cs,"u")),mr.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"emoji",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")ns.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"uuid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")os.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"nanoid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")es.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"cuid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")ts.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"cuid2",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")rs.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"ulid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),d(o,{validation:"url",code:f.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"regex",code:f.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Fr(a).test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?hs.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?gs(a).test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?ss.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"duration",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?ys(e.data,a.version)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"ip",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?_s(e.data,a.alg)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"jwt",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?xs(e.data,a.version)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"cidr",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?ps.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"base64",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?ms.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"base64url",code:f.invalid_string,message:a.message}),n.dirty()):S.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:f.invalid_string,...h.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...h.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...h.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...h.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...h.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...h.errToObj(r)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};le.create=t=>new le({checks:[],typeName:v.ZodString,coerce:t?.coerce??!1,...b(t)});function vs(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,a=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return a%i/10**o}var Ie=class t extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==m.number){let a=this._getOrReturnCtx(e);return d(a,{code:f.invalid_type,expected:m.number,received:a.parsedType}),_}let n,o=new D;for(let a of this._def.checks)a.kind==="int"?S.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:f.invalid_type,expected:"integer",received:"float",message:a.message}),o.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="multipleOf"?vs(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:f.not_finite,message:a.message}),o.dirty()):S.assertNever(a);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,h.toString(r))}gt(e,r){return this.setLimit("min",e,!1,h.toString(r))}lte(e,r){return this.setLimit("max",e,!0,h.toString(r))}lt(e,r){return this.setLimit("max",e,!1,h.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:h.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Ie.create=t=>new Ie({checks:[],typeName:v.ZodNumber,coerce:t?.coerce||!1,...b(t)});var Se=class t extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==m.bigint)return this._getInvalidInput(e);let n,o=new D;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):S.assertNever(a);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return d(r,{code:f.invalid_type,expected:m.bigint,received:r.parsedType}),_}gte(e,r){return this.setLimit("min",e,!0,h.toString(r))}gt(e,r){return this.setLimit("min",e,!1,h.toString(r))}lte(e,r){return this.setLimit("max",e,!0,h.toString(r))}lt(e,r){return this.setLimit("max",e,!1,h.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:h.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Se.create=t=>new Se({checks:[],typeName:v.ZodBigInt,coerce:t?.coerce??!1,...b(t)});var we=class extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.boolean,received:n.parsedType}),_}return j(e.data)}};we.create=t=>new we({typeName:v.ZodBoolean,coerce:t?.coerce||!1,...b(t)});var Oe=class t extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){let a=this._getOrReturnCtx(e);return d(a,{code:f.invalid_type,expected:m.date,received:a.parsedType}),_}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return d(a,{code:f.invalid_date}),_}let n=new D,o;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(o=this._getOrReturnCtx(e,o),d(o,{code:f.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(o=this._getOrReturnCtx(e,o),d(o,{code:f.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):S.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Oe.create=t=>new Oe({checks:[],coerce:t?.coerce||!1,typeName:v.ZodDate,...b(t)});var qe=class extends T{_parse(e){if(this._getType(e)!==m.symbol){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.symbol,received:n.parsedType}),_}return j(e.data)}};qe.create=t=>new qe({typeName:v.ZodSymbol,...b(t)});var Ae=class extends T{_parse(e){if(this._getType(e)!==m.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.undefined,received:n.parsedType}),_}return j(e.data)}};Ae.create=t=>new Ae({typeName:v.ZodUndefined,...b(t)});var ke=class extends T{_parse(e){if(this._getType(e)!==m.null){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.null,received:n.parsedType}),_}return j(e.data)}};ke.create=t=>new ke({typeName:v.ZodNull,...b(t)});var de=class extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}};de.create=t=>new de({typeName:v.ZodAny,...b(t)});var ae=class extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}};ae.create=t=>new ae({typeName:v.ZodUnknown,...b(t)});var W=class extends T{_parse(e){let r=this._getOrReturnCtx(e);return d(r,{code:f.invalid_type,expected:m.never,received:r.parsedType}),_}};W.create=t=>new W({typeName:v.ZodNever,...b(t)});var Je=class extends T{_parse(e){if(this._getType(e)!==m.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.void,received:n.parsedType}),_}return j(e.data)}};Je.create=t=>new Je({typeName:v.ZodVoid,...b(t)});var se=class t extends T{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==m.array)return d(r,{code:f.invalid_type,expected:m.array,received:r.parsedType}),_;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,s=r.data.length<o.exactLength.value;(i||s)&&(d(r,{code:i?f.too_big:f.too_small,minimum:s?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(d(r,{code:f.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(d(r,{code:f.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,s)=>o.type._parseAsync(new V(r,i,r.path,s)))).then(i=>D.mergeArray(n,i));let a=[...r.data].map((i,s)=>o.type._parseSync(new V(r,i,r.path,s)));return D.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:h.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:h.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:h.toString(r)}})}nonempty(e){return this.min(1,e)}};se.create=(t,e)=>new se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...b(e)});function Ye(t){if(t instanceof U){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=z.create(Ye(n))}return new U({...t._def,shape:()=>e})}else return t instanceof se?new se({...t._def,type:Ye(t.element)}):t instanceof z?z.create(Ye(t.unwrap())):t instanceof Q?Q.create(Ye(t.unwrap())):t instanceof X?X.create(t.items.map(e=>Ye(e))):t}var U=class t extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=S.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==m.object){let u=this._getOrReturnCtx(e);return d(u,{code:f.invalid_type,expected:m.object,received:u.parsedType}),_}let{status:n,ctx:o}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof W&&this._def.unknownKeys==="strip"))for(let u in o.data)i.includes(u)||s.push(u);let c=[];for(let u of i){let l=a[u],p=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new V(o,p,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof W){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")s.length>0&&(d(o,{code:f.unrecognized_keys,keys:s}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of s){let p=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new V(o,p,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let p=await l.key,y=await l.value;u.push({key:p,value:y,alwaysSet:l.alwaysSet})}return u}).then(u=>D.mergeObjectSync(n,u)):D.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:h.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of S.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of S.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ye(this)}partial(e){let r={};for(let n of S.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of S.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof z;)a=a._def.innerType;r[n]=a}return new t({...this._def,shape:()=>r})}keyof(){return Hr(S.objectKeys(this.shape))}};U.create=(t,e)=>new U({shape:()=>t,unknownKeys:"strip",catchall:W.create(),typeName:v.ZodObject,...b(e)});U.strictCreate=(t,e)=>new U({shape:()=>t,unknownKeys:"strict",catchall:W.create(),typeName:v.ZodObject,...b(e)});U.lazycreate=(t,e)=>new U({shape:t,unknownKeys:"strip",catchall:W.create(),typeName:v.ZodObject,...b(e)});var Re=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let i=a.map(s=>new B(s.ctx.common.issues));return d(r,{code:f.invalid_union,unionErrors:i}),_}if(r.common.async)return Promise.all(n.map(async a=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let a,i=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let s=i.map(c=>new B(c));return d(r,{code:f.invalid_union,unionErrors:s}),_}}get options(){return this._def.options}};Re.create=(t,e)=>new Re({options:t,typeName:v.ZodUnion,...b(e)});var oe=t=>t instanceof Ce?oe(t.schema):t instanceof Z?oe(t.innerType()):t instanceof Ne?[t.value]:t instanceof Pe?t.options:t instanceof $e?S.objectValues(t.enum):t instanceof Me?oe(t._def.innerType):t instanceof Ae?[void 0]:t instanceof ke?[null]:t instanceof z?[void 0,...oe(t.unwrap())]:t instanceof Q?[null,...oe(t.unwrap())]:t instanceof It||t instanceof je?oe(t.unwrap()):t instanceof De?oe(t._def.innerType):[],Dt=class t extends T{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.object)return d(r,{code:f.invalid_type,expected:m.object,received:r.parsedType}),_;let n=this.discriminator,o=r.data[n],a=this.optionsMap.get(o);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(d(r,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let a of r){let i=oe(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of i){if(o.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);o.set(s,a)}}return new t({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...b(n)})}};function hr(t,e){let r=J(t),n=J(e);if(t===e)return{valid:!0,data:t};if(r===m.object&&n===m.object){let o=S.objectKeys(e),a=S.objectKeys(t).filter(s=>o.indexOf(s)!==-1),i={...t,...e};for(let s of a){let c=hr(t[s],e[s]);if(!c.valid)return{valid:!1};i[s]=c.data}return{valid:!0,data:i}}else if(r===m.array&&n===m.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let a=0;a<t.length;a++){let i=t[a],s=e[a],c=hr(i,s);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===m.date&&n===m.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Le=class extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(a,i)=>{if($t(a)||$t(i))return _;let s=hr(a.value,i.value);return s.valid?((Mt(a)||Mt(i))&&r.dirty(),{status:r.value,value:s.data}):(d(n,{code:f.invalid_intersection_types}),_)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>o(a,i)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Le.create=(t,e,r)=>new Le({left:t,right:e,typeName:v.ZodIntersection,...b(r)});var X=class t extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.array)return d(n,{code:f.invalid_type,expected:m.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return d(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((i,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new V(n,i,n.path,s)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>D.mergeArray(r,i)):D.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};X.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:t,typeName:v.ZodTuple,rest:null,...b(e)})};var jt=class t extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.object)return d(n,{code:f.invalid_type,expected:m.object,received:n.parsedType}),_;let o=[],a=this._def.keyType,i=this._def.valueType;for(let s in n.data)o.push({key:a._parse(new V(n,s,n.path,s)),value:i._parse(new V(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?D.mergeObjectAsync(r,o):D.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof T?new t({keyType:e,valueType:r,typeName:v.ZodRecord,...b(n)}):new t({keyType:le.create(),valueType:e,typeName:v.ZodRecord,...b(r)})}},Xe=class extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.map)return d(n,{code:f.invalid_type,expected:m.map,received:n.parsedType}),_;let o=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([s,c],u)=>({key:o._parse(new V(n,s,n.path,[u,"key"])),value:a._parse(new V(n,c,n.path,[u,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return _;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return _;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};Xe.create=(t,e,r)=>new Xe({valueType:e,keyType:t,typeName:v.ZodMap,...b(r)});var Qe=class t extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.set)return d(n,{code:f.invalid_type,expected:m.set,received:n.parsedType}),_;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(d(n,{code:f.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(d(n,{code:f.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let a=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return _;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...n.data.values()].map((c,u)=>a._parse(new V(n,c,n.path,u)));return n.common.async?Promise.all(s).then(c=>i(c)):i(s)}min(e,r){return new t({...this._def,minSize:{value:e,message:h.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:h.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Qe.create=(t,e)=>new Qe({valueType:t,minSize:null,maxSize:null,typeName:v.ZodSet,...b(e)});var Gt=class t extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.function)return d(r,{code:f.invalid_type,expected:m.function,received:r.parsedType}),_;function n(s,c){return Et({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ke(),ne].filter(u=>!!u),issueData:{code:f.invalid_arguments,argumentsError:c}})}function o(s,c){return Et({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ke(),ne].filter(u=>!!u),issueData:{code:f.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof pe){let s=this;return j(async function(...c){let u=new B([]),l=await s._def.args.parseAsync(c,a).catch(x=>{throw u.addIssue(n(c,x)),u}),p=await Reflect.apply(i,this,l);return await s._def.returns._def.type.parseAsync(p,a).catch(x=>{throw u.addIssue(o(p,x)),u})})}else{let s=this;return j(function(...c){let u=s._def.args.safeParse(c,a);if(!u.success)throw new B([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),p=s._def.returns.safeParse(l,a);if(!p.success)throw new B([o(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:X.create(e).rest(ae.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||X.create([]).rest(ae.create()),returns:r||ae.create(),typeName:v.ZodFunction,...b(n)})}},Ce=class extends T{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ce.create=(t,e)=>new Ce({getter:t,typeName:v.ZodLazy,...b(e)});var Ne=class extends T{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return d(r,{received:r.data,code:f.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ne.create=(t,e)=>new Ne({value:t,typeName:v.ZodLiteral,...b(e)});function Hr(t,e){return new Pe({values:t,typeName:v.ZodEnum,...b(e)})}var Pe=class t extends T{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{expected:S.joinValues(n),received:r.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{received:r.data,code:f.invalid_enum_value,options:n}),_}return j(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Pe.create=Hr;var $e=class extends T{_parse(e){let r=S.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==m.string&&n.parsedType!==m.number){let o=S.objectValues(r);return d(n,{expected:S.joinValues(o),received:n.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=S.objectValues(r);return d(n,{received:n.data,code:f.invalid_enum_value,options:o}),_}return j(e.data)}get enum(){return this._def.values}};$e.create=(t,e)=>new $e({values:t,typeName:v.ZodNativeEnum,...b(e)});var pe=class extends T{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.promise&&r.common.async===!1)return d(r,{code:f.invalid_type,expected:m.promise,received:r.parsedType}),_;let n=r.parsedType===m.promise?r.data:Promise.resolve(r.data);return j(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};pe.create=(t,e)=>new pe({type:t,typeName:v.ZodPromise,...b(e)});var Z=class extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,a={addIssue:i=>{d(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),o.type==="preprocess"){let i=o.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async s=>{if(r.value==="aborted")return _;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?_:c.status==="dirty"?Ee(c.value):r.value==="dirty"?Ee(c.value):c});{if(r.value==="aborted")return _;let s=this._def.schema._parseSync({data:i,path:n.path,parent:n});return s.status==="aborted"?_:s.status==="dirty"?Ee(s.value):r.value==="dirty"?Ee(s.value):s}}if(o.type==="refinement"){let i=s=>{let c=o.refinement(s,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?_:(s.status==="dirty"&&r.dirty(),i(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?_:(s.status==="dirty"&&r.dirty(),i(s.value).then(()=>({status:r.value,value:s.value}))))}if(o.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!fe(i))return _;let s=o.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>fe(i)?Promise.resolve(o.transform(i.value,a)).then(s=>({status:r.value,value:s})):_);S.assertNever(o)}};Z.create=(t,e,r)=>new Z({schema:t,typeName:v.ZodEffects,effect:e,...b(r)});Z.createWithPreprocess=(t,e,r)=>new Z({schema:e,effect:{type:"preprocess",transform:t},typeName:v.ZodEffects,...b(r)});var z=class extends T{_parse(e){return this._getType(e)===m.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};z.create=(t,e)=>new z({innerType:t,typeName:v.ZodOptional,...b(e)});var Q=class extends T{_parse(e){return this._getType(e)===m.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Q.create=(t,e)=>new Q({innerType:t,typeName:v.ZodNullable,...b(e)});var Me=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===m.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Me.create=(t,e)=>new Me({innerType:t,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var De=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return We(o)?o.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};De.create=(t,e)=>new De({innerType:t,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var et=class extends T{_parse(e){if(this._getType(e)!==m.nan){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}};et.create=t=>new et({typeName:v.ZodNaN,...b(t)});var bs=Symbol("zod_brand"),It=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},St=class t extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?_:a.status==="dirty"?(r.dirty(),Ee(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?_:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:v.ZodPipeline})}},je=class extends T{_parse(e){let r=this._def.innerType._parse(e),n=o=>(fe(o)&&(o.value=Object.freeze(o.value)),o);return We(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};je.create=(t,e)=>new je({innerType:t,typeName:v.ZodReadonly,...b(e)});function Gr(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function zr(t,e={},r){return t?de.create().superRefine((n,o)=>{let a=t(n);if(a instanceof Promise)return a.then(i=>{if(!i){let s=Gr(e,n),c=s.fatal??r??!0;o.addIssue({code:"custom",...s,fatal:c})}});if(!a){let i=Gr(e,n),s=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:s})}}):de.create()}var Ts={object:U.lazycreate},v;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(v||(v={}));var Es=(t,e={message:`Input not instance of ${t.name}`})=>zr(r=>r instanceof t,e),Vr=le.create,Zr=Ie.create,Is=et.create,Ss=Se.create,Kr=we.create,ws=Oe.create,Os=qe.create,As=Ae.create,ks=ke.create,Rs=de.create,Ls=ae.create,Cs=W.create,Ns=Je.create,Ps=se.create,$s=U.create,Ms=U.strictCreate,Ds=Re.create,js=Dt.create,Gs=Le.create,Bs=X.create,Us=jt.create,Fs=Xe.create,Hs=Qe.create,zs=Gt.create,Vs=Ce.create,Zs=Ne.create,Ks=Pe.create,Ws=$e.create,Ys=pe.create,qs=Z.create,Js=z.create,Xs=Q.create,Qs=Z.createWithPreprocess,ei=St.create,ti=()=>Vr().optional(),ri=()=>Zr().optional(),ni=()=>Kr().optional(),oi={string:(t=>le.create({...t,coerce:!0})),number:(t=>Ie.create({...t,coerce:!0})),boolean:(t=>we.create({...t,coerce:!0})),bigint:(t=>Se.create({...t,coerce:!0})),date:(t=>Oe.create({...t,coerce:!0}))};var ai=_;var si=typeof global=="object"&&global&&global.Object===Object&&global,Bt=si;var ii=typeof self=="object"&&self&&self.Object===Object&&self,ci=Bt||ii||Function("return this")(),M=ci;var ui=M.Symbol,G=ui;var Wr=Object.prototype,fi=Wr.hasOwnProperty,li=Wr.toString,wt=G?G.toStringTag:void 0;function di(t){var e=fi.call(t,wt),r=t[wt];try{t[wt]=void 0;var n=!0}catch{}var o=li.call(t);return n&&(e?t[wt]=r:delete t[wt]),o}var Yr=di;var pi=Object.prototype,mi=pi.toString;function hi(t){return mi.call(t)}var qr=hi;var gi="[object Null]",yi="[object Undefined]",Jr=G?G.toStringTag:void 0;function _i(t){return t==null?t===void 0?yi:gi:Jr&&Jr in Object(t)?Yr(t):qr(t)}var Y=_i;function xi(t){return t!=null&&typeof t=="object"}var q=xi;var vi="[object Symbol]";function bi(t){return typeof t=="symbol"||q(t)&&Y(t)==vi}var ie=bi;function Ti(t,e){for(var r=-1,n=t==null?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var tt=Ti;var Ei=Array.isArray,R=Ei;var Ii=1/0,Xr=G?G.prototype:void 0,Qr=Xr?Xr.toString:void 0;function en(t){if(typeof t=="string")return t;if(R(t))return tt(t,en)+"";if(ie(t))return Qr?Qr.call(t):"";var e=t+"";return e=="0"&&1/t==-Ii?"-0":e}var tn=en;function Si(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var me=Si;function wi(t){return t}var he=wi;var Oi="[object AsyncFunction]",Ai="[object Function]",ki="[object GeneratorFunction]",Ri="[object Proxy]";function Li(t){if(!me(t))return!1;var e=Y(t);return e==Ai||e==ki||e==Oi||e==Ri}var Ut=Li;var Ci=M["__core-js_shared__"],Ft=Ci;var rn=(function(){var t=/[^.]+$/.exec(Ft&&Ft.keys&&Ft.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Ni(t){return!!rn&&rn in t}var nn=Ni;var Pi=Function.prototype,$i=Pi.toString;function Mi(t){if(t!=null){try{return $i.call(t)}catch{}try{return t+""}catch{}}return""}var ce=Mi;var Di=/[\\^$.*+?()[\]{}|]/g,ji=/^\[object .+?Constructor\]$/,Gi=Function.prototype,Bi=Object.prototype,Ui=Gi.toString,Fi=Bi.hasOwnProperty,Hi=RegExp("^"+Ui.call(Fi).replace(Di,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function zi(t){if(!me(t)||nn(t))return!1;var e=Ut(t)?Hi:ji;return e.test(ce(t))}var on=zi;function Vi(t,e){return t?.[e]}var an=Vi;function Zi(t,e){var r=an(t,e);return on(r)?r:void 0}var F=Zi;var Ki=F(M,"WeakMap"),Ht=Ki;function Wi(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var sn=Wi;var Yi=800,qi=16,Ji=Date.now;function Xi(t){var e=0,r=0;return function(){var n=Ji(),o=qi-(n-r);if(r=n,o>0){if(++e>=Yi)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var cn=Xi;function Qi(t){return function(){return t}}var un=Qi;var ec=(function(){try{var t=F(Object,"defineProperty");return t({},"",{}),t}catch{}})(),rt=ec;var tc=rt?function(t,e){return rt(t,"toString",{configurable:!0,enumerable:!1,value:un(e),writable:!0})}:he,fn=tc;var rc=cn(fn),ln=rc;var nc=9007199254740991,oc=/^(?:0|[1-9]\d*)$/;function ac(t,e){var r=typeof t;return e=e??nc,!!e&&(r=="number"||r!="symbol"&&oc.test(t))&&t>-1&&t%1==0&&t<e}var nt=ac;function sc(t,e,r){e=="__proto__"&&rt?rt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var dn=sc;function ic(t,e){return t===e||t!==t&&e!==e}var ot=ic;var pn=Math.max;function cc(t,e,r){return e=pn(e===void 0?t.length-1:e,0),function(){for(var n=arguments,o=-1,a=pn(n.length-e,0),i=Array(a);++o<a;)i[o]=n[e+o];o=-1;for(var s=Array(e+1);++o<e;)s[o]=n[o];return s[e]=r(i),sn(t,this,s)}}var mn=cc;function uc(t,e){return ln(mn(t,e,he),t+"")}var hn=uc;var fc=9007199254740991;function lc(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=fc}var at=lc;function dc(t){return t!=null&&at(t.length)&&!Ut(t)}var ge=dc;function pc(t,e,r){if(!me(r))return!1;var n=typeof e;return(n=="number"?ge(r)&&nt(e,r.length):n=="string"&&e in r)?ot(r[e],t):!1}var gr=pc;var mc=Object.prototype;function hc(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||mc;return t===r}var gn=hc;function gc(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}var yn=gc;var yc="[object Arguments]";function _c(t){return q(t)&&Y(t)==yc}var yr=_c;var _n=Object.prototype,xc=_n.hasOwnProperty,vc=_n.propertyIsEnumerable,bc=yr((function(){return arguments})())?yr:function(t){return q(t)&&xc.call(t,"callee")&&!vc.call(t,"callee")},st=bc;function Tc(){return!1}var xn=Tc;var Tn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,vn=Tn&&typeof module=="object"&&module&&!module.nodeType&&module,Ec=vn&&vn.exports===Tn,bn=Ec?M.Buffer:void 0,Ic=bn?bn.isBuffer:void 0,Sc=Ic||xn,Ot=Sc;var wc="[object Arguments]",Oc="[object Array]",Ac="[object Boolean]",kc="[object Date]",Rc="[object Error]",Lc="[object Function]",Cc="[object Map]",Nc="[object Number]",Pc="[object Object]",$c="[object RegExp]",Mc="[object Set]",Dc="[object String]",jc="[object WeakMap]",Gc="[object ArrayBuffer]",Bc="[object DataView]",Uc="[object Float32Array]",Fc="[object Float64Array]",Hc="[object Int8Array]",zc="[object Int16Array]",Vc="[object Int32Array]",Zc="[object Uint8Array]",Kc="[object Uint8ClampedArray]",Wc="[object Uint16Array]",Yc="[object Uint32Array]",k={};k[Uc]=k[Fc]=k[Hc]=k[zc]=k[Vc]=k[Zc]=k[Kc]=k[Wc]=k[Yc]=!0;k[wc]=k[Oc]=k[Gc]=k[Ac]=k[Bc]=k[kc]=k[Rc]=k[Lc]=k[Cc]=k[Nc]=k[Pc]=k[$c]=k[Mc]=k[Dc]=k[jc]=!1;function qc(t){return q(t)&&at(t.length)&&!!k[Y(t)]}var En=qc;function Jc(t){return function(e){return t(e)}}var zt=Jc;var In=typeof exports=="object"&&exports&&!exports.nodeType&&exports,At=In&&typeof module=="object"&&module&&!module.nodeType&&module,Xc=At&&At.exports===In,_r=Xc&&Bt.process,Qc=(function(){try{var t=At&&At.require&&At.require("util").types;return t||_r&&_r.binding&&_r.binding("util")}catch{}})(),xr=Qc;var Sn=xr&&xr.isTypedArray,eu=Sn?zt(Sn):En,Vt=eu;var tu=Object.prototype,ru=tu.hasOwnProperty;function nu(t,e){var r=R(t),n=!r&&st(t),o=!r&&!n&&Ot(t),a=!r&&!n&&!o&&Vt(t),i=r||n||o||a,s=i?yn(t.length,String):[],c=s.length;for(var u in t)(e||ru.call(t,u))&&!(i&&(u=="length"||o&&(u=="offset"||u=="parent")||a&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||nt(u,c)))&&s.push(u);return s}var wn=nu;function ou(t,e){return function(r){return t(e(r))}}var On=ou;var au=On(Object.keys,Object),An=au;var su=Object.prototype,iu=su.hasOwnProperty;function cu(t){if(!gn(t))return An(t);var e=[];for(var r in Object(t))iu.call(t,r)&&r!="constructor"&&e.push(r);return e}var kn=cu;function uu(t){return ge(t)?wn(t):kn(t)}var it=uu;var fu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,lu=/^\w*$/;function du(t,e){if(R(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||ie(t)?!0:lu.test(t)||!fu.test(t)||e!=null&&t in Object(e)}var ct=du;var pu=F(Object,"create"),ue=pu;function mu(){this.__data__=ue?ue(null):{},this.size=0}var Rn=mu;function hu(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ln=hu;var gu="__lodash_hash_undefined__",yu=Object.prototype,_u=yu.hasOwnProperty;function xu(t){var e=this.__data__;if(ue){var r=e[t];return r===gu?void 0:r}return _u.call(e,t)?e[t]:void 0}var Cn=xu;var vu=Object.prototype,bu=vu.hasOwnProperty;function Tu(t){var e=this.__data__;return ue?e[t]!==void 0:bu.call(e,t)}var Nn=Tu;var Eu="__lodash_hash_undefined__";function Iu(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=ue&&e===void 0?Eu:e,this}var Pn=Iu;function ut(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ut.prototype.clear=Rn;ut.prototype.delete=Ln;ut.prototype.get=Cn;ut.prototype.has=Nn;ut.prototype.set=Pn;var vr=ut;function Su(){this.__data__=[],this.size=0}var $n=Su;function wu(t,e){for(var r=t.length;r--;)if(ot(t[r][0],e))return r;return-1}var ye=wu;var Ou=Array.prototype,Au=Ou.splice;function ku(t){var e=this.__data__,r=ye(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Au.call(e,r,1),--this.size,!0}var Mn=ku;function Ru(t){var e=this.__data__,r=ye(e,t);return r<0?void 0:e[r][1]}var Dn=Ru;function Lu(t){return ye(this.__data__,t)>-1}var jn=Lu;function Cu(t,e){var r=this.__data__,n=ye(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var Gn=Cu;function ft(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ft.prototype.clear=$n;ft.prototype.delete=Mn;ft.prototype.get=Dn;ft.prototype.has=jn;ft.prototype.set=Gn;var _e=ft;var Nu=F(M,"Map"),xe=Nu;function Pu(){this.size=0,this.__data__={hash:new vr,map:new(xe||_e),string:new vr}}var Bn=Pu;function $u(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Un=$u;function Mu(t,e){var r=t.__data__;return Un(e)?r[typeof e=="string"?"string":"hash"]:r.map}var ve=Mu;function Du(t){var e=ve(this,t).delete(t);return this.size-=e?1:0,e}var Fn=Du;function ju(t){return ve(this,t).get(t)}var Hn=ju;function Gu(t){return ve(this,t).has(t)}var zn=Gu;function Bu(t,e){var r=ve(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}var Vn=Bu;function lt(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}lt.prototype.clear=Bn;lt.prototype.delete=Fn;lt.prototype.get=Hn;lt.prototype.has=zn;lt.prototype.set=Vn;var Ge=lt;var Uu="Expected a function";function br(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Uu);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var i=t.apply(this,n);return r.cache=a.set(o,i)||a,i};return r.cache=new(br.Cache||Ge),r}br.Cache=Ge;var Zn=br;var Fu=500;function Hu(t){var e=Zn(t,function(n){return r.size===Fu&&r.clear(),n}),r=e.cache;return e}var Kn=Hu;var zu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Vu=/\\(\\)?/g,Zu=Kn(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(zu,function(r,n,o,a){e.push(o?a.replace(Vu,"$1"):n||r)}),e}),Wn=Zu;function Ku(t){return t==null?"":tn(t)}var Yn=Ku;function Wu(t,e){return R(t)?t:ct(t,e)?[t]:Wn(Yn(t))}var Zt=Wu;var Yu=1/0;function qu(t){if(typeof t=="string"||ie(t))return t;var e=t+"";return e=="0"&&1/t==-Yu?"-0":e}var be=qu;function Ju(t,e){e=Zt(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[be(e[r++])];return r&&r==n?t:void 0}var dt=Ju;function Xu(t,e,r){var n=t==null?void 0:dt(t,e);return n===void 0?r:n}var qn=Xu;function Qu(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var Kt=Qu;var Jn=G?G.isConcatSpreadable:void 0;function ef(t){return R(t)||st(t)||!!(Jn&&t&&t[Jn])}var Xn=ef;function Qn(t,e,r,n,o){var a=-1,i=t.length;for(r||(r=Xn),o||(o=[]);++a<i;){var s=t[a];e>0&&r(s)?e>1?Qn(s,e-1,r,n,o):Kt(o,s):n||(o[o.length]=s)}return o}var eo=Qn;function tf(){this.__data__=new _e,this.size=0}var to=tf;function rf(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ro=rf;function nf(t){return this.__data__.get(t)}var no=nf;function of(t){return this.__data__.has(t)}var oo=of;var af=200;function sf(t,e){var r=this.__data__;if(r instanceof _e){var n=r.__data__;if(!xe||n.length<af-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ge(n)}return r.set(t,e),this.size=r.size,this}var ao=sf;function pt(t){var e=this.__data__=new _e(t);this.size=e.size}pt.prototype.clear=to;pt.prototype.delete=ro;pt.prototype.get=no;pt.prototype.has=oo;pt.prototype.set=ao;var mt=pt;function cf(t,e){for(var r=-1,n=t==null?0:t.length,o=0,a=[];++r<n;){var i=t[r];e(i,r,t)&&(a[o++]=i)}return a}var so=cf;function uf(){return[]}var io=uf;var ff=Object.prototype,lf=ff.propertyIsEnumerable,co=Object.getOwnPropertySymbols,df=co?function(t){return t==null?[]:(t=Object(t),so(co(t),function(e){return lf.call(t,e)}))}:io,uo=df;function pf(t,e,r){var n=e(t);return R(t)?n:Kt(n,r(t))}var fo=pf;function mf(t){return fo(t,it,uo)}var Tr=mf;var hf=F(M,"DataView"),Wt=hf;var gf=F(M,"Promise"),Yt=gf;var yf=F(M,"Set"),qt=yf;var lo="[object Map]",_f="[object Object]",po="[object Promise]",mo="[object Set]",ho="[object WeakMap]",go="[object DataView]",xf=ce(Wt),vf=ce(xe),bf=ce(Yt),Tf=ce(qt),Ef=ce(Ht),Be=Y;(Wt&&Be(new Wt(new ArrayBuffer(1)))!=go||xe&&Be(new xe)!=lo||Yt&&Be(Yt.resolve())!=po||qt&&Be(new qt)!=mo||Ht&&Be(new Ht)!=ho)&&(Be=function(t){var e=Y(t),r=e==_f?t.constructor:void 0,n=r?ce(r):"";if(n)switch(n){case xf:return go;case vf:return lo;case bf:return po;case Tf:return mo;case Ef:return ho}return e});var Er=Be;var If=M.Uint8Array,Ir=If;var Sf="__lodash_hash_undefined__";function wf(t){return this.__data__.set(t,Sf),this}var yo=wf;function Of(t){return this.__data__.has(t)}var _o=Of;function Jt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Ge;++e<r;)this.add(t[e])}Jt.prototype.add=Jt.prototype.push=yo;Jt.prototype.has=_o;var xo=Jt;function Af(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}var vo=Af;function kf(t,e){return t.has(e)}var bo=kf;var Rf=1,Lf=2;function Cf(t,e,r,n,o,a){var i=r&Rf,s=t.length,c=e.length;if(s!=c&&!(i&&c>s))return!1;var u=a.get(t),l=a.get(e);if(u&&l)return u==e&&l==t;var p=-1,y=!0,x=r&Lf?new xo:void 0;for(a.set(t,e),a.set(e,t);++p<s;){var O=t[p],I=e[p];if(n)var w=i?n(I,O,p,e,t,a):n(O,I,p,t,e,a);if(w!==void 0){if(w)continue;y=!1;break}if(x){if(!vo(e,function($,re){if(!bo(x,re)&&(O===$||o(O,$,r,n,a)))return x.push(re)})){y=!1;break}}else if(!(O===I||o(O,I,r,n,a))){y=!1;break}}return a.delete(t),a.delete(e),y}var Xt=Cf;function Nf(t){var e=-1,r=Array(t.size);return t.forEach(function(n,o){r[++e]=[o,n]}),r}var To=Nf;function Pf(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var Eo=Pf;var $f=1,Mf=2,Df="[object Boolean]",jf="[object Date]",Gf="[object Error]",Bf="[object Map]",Uf="[object Number]",Ff="[object RegExp]",Hf="[object Set]",zf="[object String]",Vf="[object Symbol]",Zf="[object ArrayBuffer]",Kf="[object DataView]",Io=G?G.prototype:void 0,Sr=Io?Io.valueOf:void 0;function Wf(t,e,r,n,o,a,i){switch(r){case Kf:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Zf:return!(t.byteLength!=e.byteLength||!a(new Ir(t),new Ir(e)));case Df:case jf:case Uf:return ot(+t,+e);case Gf:return t.name==e.name&&t.message==e.message;case Ff:case zf:return t==e+"";case Bf:var s=To;case Hf:var c=n&$f;if(s||(s=Eo),t.size!=e.size&&!c)return!1;var u=i.get(t);if(u)return u==e;n|=Mf,i.set(t,e);var l=Xt(s(t),s(e),n,o,a,i);return i.delete(t),l;case Vf:if(Sr)return Sr.call(t)==Sr.call(e)}return!1}var So=Wf;var Yf=1,qf=Object.prototype,Jf=qf.hasOwnProperty;function Xf(t,e,r,n,o,a){var i=r&Yf,s=Tr(t),c=s.length,u=Tr(e),l=u.length;if(c!=l&&!i)return!1;for(var p=c;p--;){var y=s[p];if(!(i?y in e:Jf.call(e,y)))return!1}var x=a.get(t),O=a.get(e);if(x&&O)return x==e&&O==t;var I=!0;a.set(t,e),a.set(e,t);for(var w=i;++p<c;){y=s[p];var $=t[y],re=e[y];if(n)var Nt=i?n(re,$,y,e,t,a):n($,re,y,t,e,a);if(!(Nt===void 0?$===re||o($,re,r,n,a):Nt)){I=!1;break}w||(w=y=="constructor")}if(I&&!w){var Ve=t.constructor,Pt=e.constructor;Ve!=Pt&&"constructor"in t&&"constructor"in e&&!(typeof Ve=="function"&&Ve instanceof Ve&&typeof Pt=="function"&&Pt instanceof Pt)&&(I=!1)}return a.delete(t),a.delete(e),I}var wo=Xf;var Qf=1,Oo="[object Arguments]",Ao="[object Array]",Qt="[object Object]",el=Object.prototype,ko=el.hasOwnProperty;function tl(t,e,r,n,o,a){var i=R(t),s=R(e),c=i?Ao:Er(t),u=s?Ao:Er(e);c=c==Oo?Qt:c,u=u==Oo?Qt:u;var l=c==Qt,p=u==Qt,y=c==u;if(y&&Ot(t)){if(!Ot(e))return!1;i=!0,l=!1}if(y&&!l)return a||(a=new mt),i||Vt(t)?Xt(t,e,r,n,o,a):So(t,e,c,r,n,o,a);if(!(r&Qf)){var x=l&&ko.call(t,"__wrapped__"),O=p&&ko.call(e,"__wrapped__");if(x||O){var I=x?t.value():t,w=O?e.value():e;return a||(a=new mt),o(I,w,r,n,a)}}return y?(a||(a=new mt),wo(t,e,r,n,o,a)):!1}var Ro=tl;function Lo(t,e,r,n,o){return t===e?!0:t==null||e==null||!q(t)&&!q(e)?t!==t&&e!==e:Ro(t,e,r,n,Lo,o)}var er=Lo;var rl=1,nl=2;function ol(t,e,r,n){var o=r.length,a=o,i=!n;if(t==null)return!a;for(t=Object(t);o--;){var s=r[o];if(i&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++o<a;){s=r[o];var c=s[0],u=t[c],l=s[1];if(i&&s[2]){if(u===void 0&&!(c in t))return!1}else{var p=new mt;if(n)var y=n(u,l,c,t,e,p);if(!(y===void 0?er(l,u,rl|nl,n,p):y))return!1}}return!0}var Co=ol;function al(t){return t===t&&!me(t)}var tr=al;function sl(t){for(var e=it(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,tr(o)]}return e}var No=sl;function il(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}var rr=il;function cl(t){var e=No(t);return e.length==1&&e[0][2]?rr(e[0][0],e[0][1]):function(r){return r===t||Co(r,t,e)}}var Po=cl;function ul(t,e){return t!=null&&e in Object(t)}var $o=ul;function fl(t,e,r){e=Zt(e,t);for(var n=-1,o=e.length,a=!1;++n<o;){var i=be(e[n]);if(!(a=t!=null&&r(t,i)))break;t=t[i]}return a||++n!=o?a:(o=t==null?0:t.length,!!o&&at(o)&&nt(i,o)&&(R(t)||st(t)))}var Mo=fl;function ll(t,e){return t!=null&&Mo(t,e,$o)}var Do=ll;var dl=1,pl=2;function ml(t,e){return ct(t)&&tr(e)?rr(be(t),e):function(r){var n=qn(r,t);return n===void 0&&n===e?Do(r,t):er(e,n,dl|pl)}}var jo=ml;function hl(t){return function(e){return e?.[t]}}var Go=hl;function gl(t){return function(e){return dt(e,t)}}var Bo=gl;function yl(t){return ct(t)?Go(be(t)):Bo(t)}var Uo=yl;function _l(t){return typeof t=="function"?t:t==null?he:typeof t=="object"?R(t)?jo(t[0],t[1]):Po(t):Uo(t)}var nr=_l;function xl(t,e,r,n){for(var o=-1,a=t==null?0:t.length;++o<a;){var i=t[o];e(n,i,r(i),t)}return n}var Fo=xl;function vl(t){return function(e,r,n){for(var o=-1,a=Object(e),i=n(e),s=i.length;s--;){var c=i[t?s:++o];if(r(a[c],c,a)===!1)break}return e}}var Ho=vl;var bl=Ho(),zo=bl;function Tl(t,e){return t&&zo(t,e,it)}var Vo=Tl;function El(t,e){return function(r,n){if(r==null)return r;if(!ge(r))return t(r,n);for(var o=r.length,a=e?o:-1,i=Object(r);(e?a--:++a<o)&&n(i[a],a,i)!==!1;);return r}}var Zo=El;var Il=Zo(Vo),or=Il;function Sl(t,e,r,n){return or(t,function(o,a,i){e(n,o,r(o),i)}),n}var Ko=Sl;function wl(t,e){return function(r,n){var o=R(r)?Fo:Ko,a=e?e():{};return o(r,t,nr(n,2),a)}}var Wo=wl;function Ol(t,e){var r=-1,n=ge(t)?Array(t.length):[];return or(t,function(o,a,i){n[++r]=e(o,a,i)}),n}var Yo=Ol;var Al=Object.prototype,kl=Al.hasOwnProperty,Rl=Wo(function(t,e,r){kl.call(t,r)?t[r].push(e):dn(t,r,[e])}),kt=Rl;function Ll(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}var qo=Ll;function Cl(t,e){if(t!==e){var r=t!==void 0,n=t===null,o=t===t,a=ie(t),i=e!==void 0,s=e===null,c=e===e,u=ie(e);if(!s&&!u&&!a&&t>e||a&&i&&c&&!s&&!u||n&&i&&c||!r&&c||!o)return 1;if(!n&&!a&&!u&&t<e||u&&r&&o&&!n&&!a||s&&r&&o||!i&&o||!c)return-1}return 0}var Jo=Cl;function Nl(t,e,r){for(var n=-1,o=t.criteria,a=e.criteria,i=o.length,s=r.length;++n<i;){var c=Jo(o[n],a[n]);if(c){if(n>=s)return c;var u=r[n];return c*(u=="desc"?-1:1)}}return t.index-e.index}var Xo=Nl;function Pl(t,e,r){e.length?e=tt(e,function(a){return R(a)?function(i){return dt(i,a.length===1?a[0]:a)}:a}):e=[he];var n=-1;e=tt(e,zt(nr));var o=Yo(t,function(a,i,s){var c=tt(e,function(u){return u(a)});return{criteria:c,index:++n,value:a}});return qo(o,function(a,i){return Xo(a,i,r)})}var Qo=Pl;var $l=hn(function(t,e){if(t==null)return[];var r=e.length;return r>1&&gr(t,e[0],e[1])?e=[]:r>2&&gr(e[0],e[1],e[2])&&(e=[e[0]]),Qo(t,eo(e,1),[])}),wr=$l;H();function E(t){return{content:[{type:"text",text:t}]}}function te(t,e){return!t||t.length<=e?t:t.slice(0,e)+"..."}var Tt=200;function ka(t){t.tool("search",`Search Sigil knowledge base for facts across all ingested documents.
18
+ `)}var rs=z(()=>{});import{StdioServerTransport as sp}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as ap}from"@modelcontextprotocol/sdk/server/mcp.js";var h={};we(h,{BRAND:()=>Rs,DIRTY:()=>Te,EMPTY_PATH:()=>ls,INVALID:()=>v,NEVER:()=>gi,OK:()=>D,ParseStatus:()=>N,Schema:()=>k,ZodAny:()=>de,ZodArray:()=>se,ZodBigInt:()=>ke,ZodBoolean:()=>Ie,ZodBranded:()=>St,ZodCatch:()=>De,ZodDate:()=>Oe,ZodDefault:()=>Ne,ZodDiscriminatedUnion:()=>Gt,ZodEffects:()=>V,ZodEnum:()=>Me,ZodError:()=>G,ZodFirstPartyTypeKind:()=>b,ZodFunction:()=>Ft,ZodIntersection:()=>$e,ZodIssueCode:()=>l,ZodLazy:()=>Re,ZodLiteral:()=>Pe,ZodMap:()=>Ye,ZodNaN:()=>Qe,ZodNativeEnum:()=>Le,ZodNever:()=>q,ZodNull:()=>Ee,ZodNullable:()=>ee,ZodNumber:()=>Se,ZodObject:()=>B,ZodOptional:()=>H,ZodParsedType:()=>g,ZodPipeline:()=>kt,ZodPromise:()=>pe,ZodReadonly:()=>je,ZodRecord:()=>Bt,ZodSchema:()=>k,ZodSet:()=>Xe,ZodString:()=>fe,ZodSymbol:()=>qe,ZodTransformer:()=>V,ZodTuple:()=>Q,ZodType:()=>k,ZodUndefined:()=>Ae,ZodUnion:()=>Ce,ZodUnknown:()=>ae,ZodVoid:()=>Je,addIssueToContext:()=>m,any:()=>Fs,array:()=>Zs,bigint:()=>Ns,boolean:()=>Qr,coerce:()=>hi,custom:()=>Jr,date:()=>Ds,datetimeRegex:()=>Kr,defaultErrorMap:()=>ne,discriminatedUnion:()=>qs,effect:()=>ii,enum:()=>oi,function:()=>ti,getErrorMap:()=>Ve,getParsedType:()=>X,instanceof:()=>Ms,intersection:()=>Js,isAborted:()=>Dt,isAsync:()=>We,isDirty:()=>jt,isValid:()=>le,late:()=>Ps,lazy:()=>ri,literal:()=>ni,makeIssue:()=>Tt,map:()=>Qs,nan:()=>Ls,nativeEnum:()=>ai,never:()=>zs,null:()=>Bs,nullable:()=>ci,number:()=>Xr,object:()=>Vs,objectUtil:()=>hr,oboolean:()=>mi,onumber:()=>pi,optional:()=>ui,ostring:()=>di,pipeline:()=>fi,preprocess:()=>li,promise:()=>si,quotelessJson:()=>is,record:()=>Xs,set:()=>ei,setErrorMap:()=>cs,strictObject:()=>Ws,string:()=>Yr,symbol:()=>js,transformer:()=>ii,tuple:()=>Ys,undefined:()=>Gs,union:()=>Ks,unknown:()=>Us,util:()=>I,void:()=>Hs});var I;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let a={};for(let i of o)a[i]=i;return a},t.getValidEnumValues=o=>{let a=t.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),i={};for(let s of a)i[s]=o[s];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(a){return o[a]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let a=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&a.push(i);return a},t.find=(o,a)=>{for(let i of o)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,a=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(o,a)=>typeof a=="bigint"?a.toString():a})(I||(I={}));var hr;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(hr||(hr={}));var g=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),X=t=>{switch(typeof t){case"undefined":return g.undefined;case"string":return g.string;case"number":return Number.isNaN(t)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}};var l=I.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),is=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),G=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(a){return a.message},n={_errors:[]},o=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let s=n,u=0;for(;u<i.path.length;){let c=i.path[u];u===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(r(i))):s[c]=s[c]||{_errors:[]},s=s[c],u++}}};return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let a=o.path[0];r[a]=r[a]||[],r[a].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};G.create=t=>new G(t);var us=(t,e)=>{let r;switch(t.code){case l.invalid_type:t.received===g.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case l.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,I.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:r=`Unrecognized key(s) in object: ${I.joinValues(t.keys,", ")}`;break;case l.invalid_union:r="Invalid input";break;case l.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${I.joinValues(t.options)}`;break;case l.invalid_enum_value:r=`Invalid enum value. Expected ${I.joinValues(t.options)}, received '${t.received}'`;break;case l.invalid_arguments:r="Invalid function arguments";break;case l.invalid_return_type:r="Invalid function return type";break;case l.invalid_date:r="Invalid date";break;case l.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:I.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case l.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case l.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case l.custom:r="Invalid input";break;case l.invalid_intersection_types:r="Intersection results could not be merged";break;case l.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case l.not_finite:r="Number must be finite";break;default:r=e.defaultError,I.assertNever(t)}return{message:r}},ne=us;var zr=ne;function cs(t){zr=t}function Ve(){return zr}var Tt=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,a=[...r,...o.path||[]],i={...o,path:a};if(o.message!==void 0)return{...o,path:a,message:o.message};let s="",u=n.filter(c=>!!c).slice().reverse();for(let c of u)s=c(i,{data:e,defaultError:s}).message;return{...o,path:a,message:s}},ls=[];function m(t,e){let r=Ve(),n=Tt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ne?void 0:ne].filter(o=>!!o)});t.common.issues.push(n)}var N=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return v;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let a=await o.key,i=await o.value;n.push({key:a,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:a,value:i}=o;if(a.status==="aborted"||i.status==="aborted")return v;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},v=Object.freeze({status:"aborted"}),Te=t=>({status:"dirty",value:t}),D=t=>({status:"valid",value:t}),Dt=t=>t.status==="aborted",jt=t=>t.status==="dirty",le=t=>t.status==="valid",We=t=>typeof Promise<"u"&&t instanceof Promise;var y;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(y||(y={}));var Z=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Hr=(t,e)=>{if(le(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new G(t.common.issues);return this._error=r,this._error}}};function T(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,s)=>{let{message:u}=t;return i.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:u??n??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:u??r??s.defaultError}},description:o}}var k=class{get description(){return this._def.description}_getType(e){return X(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:X(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new N,ctx:{common:e.parent.common,data:e.data,parsedType:X(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(We(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:X(e)},o=this._parseSync({data:e,path:n.path,parent:n});return Hr(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:X(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return le(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>le(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:X(e)},o=this._parse({data:e,path:n.path,parent:n}),a=await(We(o)?o:Promise.resolve(o));return Hr(n,a)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,a)=>{let i=e(o),s=()=>a.addIssue({code:l.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new V({schema:this,typeName:b.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return H.create(this,this._def)}nullable(){return ee.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return pe.create(this,this._def)}or(e){return Ce.create([this,e],this._def)}and(e){return $e.create(this,e,this._def)}transform(e){return new V({...T(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ne({...T(this._def),innerType:this,defaultValue:r,typeName:b.ZodDefault})}brand(){return new St({typeName:b.ZodBranded,type:this,...T(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new De({...T(this._def),innerType:this,catchValue:r,typeName:b.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return kt.create(this,e)}readonly(){return je.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},fs=/^c[^\s-]{8,}$/i,ds=/^[0-9a-z]+$/,ps=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ms=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,hs=/^[a-z0-9_-]{21}$/i,gs=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ys=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xs=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_s="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",gr,vs=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,bs=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ws=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ts=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ss=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ks=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Vr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Is=new RegExp(`^${Vr}$`);function Wr(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Os(t){return new RegExp(`^${Wr(t)}$`)}function Kr(t){let e=`${Vr}T${Wr(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function As(t,e){return!!((e==="v4"||!e)&&vs.test(t)||(e==="v6"||!e)&&ws.test(t))}function Es(t,e){if(!gs.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function Cs(t,e){return!!((e==="v4"||!e)&&bs.test(t)||(e==="v6"||!e)&&Ts.test(t))}var fe=class t extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){let a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_type,expected:g.string,received:a.parsedType}),v}let n=new N,o;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,s=e.data.length<a.value;(i||s)&&(o=this._getOrReturnCtx(e,o),i?m(o,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&m(o,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")xs.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"email",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")gr||(gr=new RegExp(_s,"u")),gr.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"emoji",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")ms.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"uuid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")hs.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"nanoid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")fs.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cuid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")ds.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cuid2",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ps.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"ulid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),m(o,{validation:"url",code:l.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"regex",code:l.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(o=this._getOrReturnCtx(e,o),m(o,{code:l.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(o=this._getOrReturnCtx(e,o),m(o,{code:l.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(o=this._getOrReturnCtx(e,o),m(o,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Kr(a).test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:l.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Is.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:l.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Os(a).test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:l.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?ys.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"duration",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?As(e.data,a.version)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"ip",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Es(e.data,a.alg)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"jwt",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Cs(e.data,a.version)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cidr",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Ss.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"base64",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?ks.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"base64url",code:l.invalid_string,message:a.message}),n.dirty()):I.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:l.invalid_string,...y.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...y.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...y.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...y.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...y.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...y.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...y.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...y.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...y.errToObj(r)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};fe.create=t=>new fe({checks:[],typeName:b.ZodString,coerce:t?.coerce??!1,...T(t)});function $s(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,a=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return a%i/10**o}var Se=class t extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){let a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_type,expected:g.number,received:a.parsedType}),v}let n,o=new N;for(let a of this._def.checks)a.kind==="int"?I.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),o.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="multipleOf"?$s(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:l.not_finite,message:a.message}),o.dirty()):I.assertNever(a);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,y.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:y.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&I.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Se.create=t=>new Se({checks:[],typeName:b.ZodNumber,coerce:t?.coerce||!1,...T(t)});var ke=class t extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==g.bigint)return this._getInvalidInput(e);let n,o=new N;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):I.assertNever(a);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return m(r,{code:l.invalid_type,expected:g.bigint,received:r.parsedType}),v}gte(e,r){return this.setLimit("min",e,!0,y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,y.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:y.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ke.create=t=>new ke({checks:[],typeName:b.ZodBigInt,coerce:t?.coerce??!1,...T(t)});var Ie=class extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.boolean,received:n.parsedType}),v}return D(e.data)}};Ie.create=t=>new Ie({typeName:b.ZodBoolean,coerce:t?.coerce||!1,...T(t)});var Oe=class t extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){let a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_type,expected:g.date,received:a.parsedType}),v}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_date}),v}let n=new N,o;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:l.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):I.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:y.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Oe.create=t=>new Oe({checks:[],coerce:t?.coerce||!1,typeName:b.ZodDate,...T(t)});var qe=class extends k{_parse(e){if(this._getType(e)!==g.symbol){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.symbol,received:n.parsedType}),v}return D(e.data)}};qe.create=t=>new qe({typeName:b.ZodSymbol,...T(t)});var Ae=class extends k{_parse(e){if(this._getType(e)!==g.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.undefined,received:n.parsedType}),v}return D(e.data)}};Ae.create=t=>new Ae({typeName:b.ZodUndefined,...T(t)});var Ee=class extends k{_parse(e){if(this._getType(e)!==g.null){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.null,received:n.parsedType}),v}return D(e.data)}};Ee.create=t=>new Ee({typeName:b.ZodNull,...T(t)});var de=class extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return D(e.data)}};de.create=t=>new de({typeName:b.ZodAny,...T(t)});var ae=class extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return D(e.data)}};ae.create=t=>new ae({typeName:b.ZodUnknown,...T(t)});var q=class extends k{_parse(e){let r=this._getOrReturnCtx(e);return m(r,{code:l.invalid_type,expected:g.never,received:r.parsedType}),v}};q.create=t=>new q({typeName:b.ZodNever,...T(t)});var Je=class extends k{_parse(e){if(this._getType(e)!==g.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.void,received:n.parsedType}),v}return D(e.data)}};Je.create=t=>new Je({typeName:b.ZodVoid,...T(t)});var se=class t extends k{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==g.array)return m(r,{code:l.invalid_type,expected:g.array,received:r.parsedType}),v;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,s=r.data.length<o.exactLength.value;(i||s)&&(m(r,{code:i?l.too_big:l.too_small,minimum:s?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(m(r,{code:l.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(m(r,{code:l.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,s)=>o.type._parseAsync(new Z(r,i,r.path,s)))).then(i=>N.mergeArray(n,i));let a=[...r.data].map((i,s)=>o.type._parseSync(new Z(r,i,r.path,s)));return N.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:y.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:y.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:y.toString(r)}})}nonempty(e){return this.min(1,e)}};se.create=(t,e)=>new se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,...T(e)});function Ke(t){if(t instanceof B){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=H.create(Ke(n))}return new B({...t._def,shape:()=>e})}else return t instanceof se?new se({...t._def,type:Ke(t.element)}):t instanceof H?H.create(Ke(t.unwrap())):t instanceof ee?ee.create(Ke(t.unwrap())):t instanceof Q?Q.create(t.items.map(e=>Ke(e))):t}var B=class t extends k{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=I.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==g.object){let c=this._getOrReturnCtx(e);return m(c,{code:l.invalid_type,expected:g.object,received:c.parsedType}),v}let{status:n,ctx:o}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof q&&this._def.unknownKeys==="strip"))for(let c in o.data)i.includes(c)||s.push(c);let u=[];for(let c of i){let f=a[c],p=o.data[c];u.push({key:{status:"valid",value:c},value:f._parse(new Z(o,p,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof q){let c=this._def.unknownKeys;if(c==="passthrough")for(let f of s)u.push({key:{status:"valid",value:f},value:{status:"valid",value:o.data[f]}});else if(c==="strict")s.length>0&&(m(o,{code:l.unrecognized_keys,keys:s}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let f of s){let p=o.data[f];u.push({key:{status:"valid",value:f},value:c._parse(new Z(o,p,o.path,f)),alwaysSet:f in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let f of u){let p=await f.key,d=await f.value;c.push({key:p,value:d,alwaysSet:f.alwaysSet})}return c}).then(c=>N.mergeObjectSync(n,c)):N.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:y.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:b.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of I.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of I.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ke(this)}partial(e){let r={};for(let n of I.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of I.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof H;)a=a._def.innerType;r[n]=a}return new t({...this._def,shape:()=>r})}keyof(){return qr(I.objectKeys(this.shape))}};B.create=(t,e)=>new B({shape:()=>t,unknownKeys:"strip",catchall:q.create(),typeName:b.ZodObject,...T(e)});B.strictCreate=(t,e)=>new B({shape:()=>t,unknownKeys:"strict",catchall:q.create(),typeName:b.ZodObject,...T(e)});B.lazycreate=(t,e)=>new B({shape:t,unknownKeys:"strip",catchall:q.create(),typeName:b.ZodObject,...T(e)});var Ce=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let i=a.map(s=>new G(s.ctx.common.issues));return m(r,{code:l.invalid_union,unionErrors:i}),v}if(r.common.async)return Promise.all(n.map(async a=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let a,i=[];for(let u of n){let c={...r,common:{...r.common,issues:[]},parent:null},f=u._parseSync({data:r.data,path:r.path,parent:c});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let s=i.map(u=>new G(u));return m(r,{code:l.invalid_union,unionErrors:s}),v}}get options(){return this._def.options}};Ce.create=(t,e)=>new Ce({options:t,typeName:b.ZodUnion,...T(e)});var oe=t=>t instanceof Re?oe(t.schema):t instanceof V?oe(t.innerType()):t instanceof Pe?[t.value]:t instanceof Me?t.options:t instanceof Le?I.objectValues(t.enum):t instanceof Ne?oe(t._def.innerType):t instanceof Ae?[void 0]:t instanceof Ee?[null]:t instanceof H?[void 0,...oe(t.unwrap())]:t instanceof ee?[null,...oe(t.unwrap())]:t instanceof St||t instanceof je?oe(t.unwrap()):t instanceof De?oe(t._def.innerType):[],Gt=class t extends k{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return m(r,{code:l.invalid_type,expected:g.object,received:r.parsedType}),v;let n=this.discriminator,o=r.data[n],a=this.optionsMap.get(o);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(m(r,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let a of r){let i=oe(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of i){if(o.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);o.set(s,a)}}return new t({typeName:b.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...T(n)})}};function yr(t,e){let r=X(t),n=X(e);if(t===e)return{valid:!0,data:t};if(r===g.object&&n===g.object){let o=I.objectKeys(e),a=I.objectKeys(t).filter(s=>o.indexOf(s)!==-1),i={...t,...e};for(let s of a){let u=yr(t[s],e[s]);if(!u.valid)return{valid:!1};i[s]=u.data}return{valid:!0,data:i}}else if(r===g.array&&n===g.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let a=0;a<t.length;a++){let i=t[a],s=e[a],u=yr(i,s);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else return r===g.date&&n===g.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var $e=class extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(a,i)=>{if(Dt(a)||Dt(i))return v;let s=yr(a.value,i.value);return s.valid?((jt(a)||jt(i))&&r.dirty(),{status:r.value,value:s.data}):(m(n,{code:l.invalid_intersection_types}),v)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>o(a,i)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};$e.create=(t,e,r)=>new $e({left:t,right:e,typeName:b.ZodIntersection,...T(r)});var Q=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.array)return m(n,{code:l.invalid_type,expected:g.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return m(n,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((i,s)=>{let u=this._def.items[s]||this._def.rest;return u?u._parse(new Z(n,i,n.path,s)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>N.mergeArray(r,i)):N.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Q.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Q({items:t,typeName:b.ZodTuple,rest:null,...T(e)})};var Bt=class t extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return m(n,{code:l.invalid_type,expected:g.object,received:n.parsedType}),v;let o=[],a=this._def.keyType,i=this._def.valueType;for(let s in n.data)o.push({key:a._parse(new Z(n,s,n.path,s)),value:i._parse(new Z(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?N.mergeObjectAsync(r,o):N.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof k?new t({keyType:e,valueType:r,typeName:b.ZodRecord,...T(n)}):new t({keyType:fe.create(),valueType:e,typeName:b.ZodRecord,...T(r)})}},Ye=class extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.map)return m(n,{code:l.invalid_type,expected:g.map,received:n.parsedType}),v;let o=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([s,u],c)=>({key:o._parse(new Z(n,s,n.path,[c,"key"])),value:a._parse(new Z(n,u,n.path,[c,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let u of i){let c=await u.key,f=await u.value;if(c.status==="aborted"||f.status==="aborted")return v;(c.status==="dirty"||f.status==="dirty")&&r.dirty(),s.set(c.value,f.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let u of i){let c=u.key,f=u.value;if(c.status==="aborted"||f.status==="aborted")return v;(c.status==="dirty"||f.status==="dirty")&&r.dirty(),s.set(c.value,f.value)}return{status:r.value,value:s}}}};Ye.create=(t,e,r)=>new Ye({valueType:e,keyType:t,typeName:b.ZodMap,...T(r)});var Xe=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.set)return m(n,{code:l.invalid_type,expected:g.set,received:n.parsedType}),v;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(m(n,{code:l.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(m(n,{code:l.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let a=this._def.valueType;function i(u){let c=new Set;for(let f of u){if(f.status==="aborted")return v;f.status==="dirty"&&r.dirty(),c.add(f.value)}return{status:r.value,value:c}}let s=[...n.data.values()].map((u,c)=>a._parse(new Z(n,u,n.path,c)));return n.common.async?Promise.all(s).then(u=>i(u)):i(s)}min(e,r){return new t({...this._def,minSize:{value:e,message:y.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:y.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Xe.create=(t,e)=>new Xe({valueType:t,minSize:null,maxSize:null,typeName:b.ZodSet,...T(e)});var Ft=class t extends k{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.function)return m(r,{code:l.invalid_type,expected:g.function,received:r.parsedType}),v;function n(s,u){return Tt({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ve(),ne].filter(c=>!!c),issueData:{code:l.invalid_arguments,argumentsError:u}})}function o(s,u){return Tt({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ve(),ne].filter(c=>!!c),issueData:{code:l.invalid_return_type,returnTypeError:u}})}let a={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof pe){let s=this;return D(async function(...u){let c=new G([]),f=await s._def.args.parseAsync(u,a).catch(_=>{throw c.addIssue(n(u,_)),c}),p=await Reflect.apply(i,this,f);return await s._def.returns._def.type.parseAsync(p,a).catch(_=>{throw c.addIssue(o(p,_)),c})})}else{let s=this;return D(function(...u){let c=s._def.args.safeParse(u,a);if(!c.success)throw new G([n(u,c.error)]);let f=Reflect.apply(i,this,c.data),p=s._def.returns.safeParse(f,a);if(!p.success)throw new G([o(f,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Q.create(e).rest(ae.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||Q.create([]).rest(ae.create()),returns:r||ae.create(),typeName:b.ZodFunction,...T(n)})}},Re=class extends k{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Re.create=(t,e)=>new Re({getter:t,typeName:b.ZodLazy,...T(e)});var Pe=class extends k{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return m(r,{received:r.data,code:l.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};Pe.create=(t,e)=>new Pe({value:t,typeName:b.ZodLiteral,...T(e)});function qr(t,e){return new Me({values:t,typeName:b.ZodEnum,...T(e)})}var Me=class t extends k{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{expected:I.joinValues(n),received:r.parsedType,code:l.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{received:r.data,code:l.invalid_enum_value,options:n}),v}return D(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Me.create=qr;var Le=class extends k{_parse(e){let r=I.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==g.string&&n.parsedType!==g.number){let o=I.objectValues(r);return m(n,{expected:I.joinValues(o),received:n.parsedType,code:l.invalid_type}),v}if(this._cache||(this._cache=new Set(I.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=I.objectValues(r);return m(n,{received:n.data,code:l.invalid_enum_value,options:o}),v}return D(e.data)}get enum(){return this._def.values}};Le.create=(t,e)=>new Le({values:t,typeName:b.ZodNativeEnum,...T(e)});var pe=class extends k{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.promise&&r.common.async===!1)return m(r,{code:l.invalid_type,expected:g.promise,received:r.parsedType}),v;let n=r.parsedType===g.promise?r.data:Promise.resolve(r.data);return D(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};pe.create=(t,e)=>new pe({type:t,typeName:b.ZodPromise,...T(e)});var V=class extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,a={addIssue:i=>{m(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),o.type==="preprocess"){let i=o.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async s=>{if(r.value==="aborted")return v;let u=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return u.status==="aborted"?v:u.status==="dirty"?Te(u.value):r.value==="dirty"?Te(u.value):u});{if(r.value==="aborted")return v;let s=this._def.schema._parseSync({data:i,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?Te(s.value):r.value==="dirty"?Te(s.value):s}}if(o.type==="refinement"){let i=s=>{let u=o.refinement(s,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:(s.status==="dirty"&&r.dirty(),i(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?v:(s.status==="dirty"&&r.dirty(),i(s.value).then(()=>({status:r.value,value:s.value}))))}if(o.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!le(i))return v;let s=o.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>le(i)?Promise.resolve(o.transform(i.value,a)).then(s=>({status:r.value,value:s})):v);I.assertNever(o)}};V.create=(t,e,r)=>new V({schema:t,typeName:b.ZodEffects,effect:e,...T(r)});V.createWithPreprocess=(t,e,r)=>new V({schema:e,effect:{type:"preprocess",transform:t},typeName:b.ZodEffects,...T(r)});var H=class extends k{_parse(e){return this._getType(e)===g.undefined?D(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};H.create=(t,e)=>new H({innerType:t,typeName:b.ZodOptional,...T(e)});var ee=class extends k{_parse(e){return this._getType(e)===g.null?D(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ee.create=(t,e)=>new ee({innerType:t,typeName:b.ZodNullable,...T(e)});var Ne=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===g.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ne.create=(t,e)=>new Ne({innerType:t,typeName:b.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...T(e)});var De=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return We(o)?o.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new G(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new G(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};De.create=(t,e)=>new De({innerType:t,typeName:b.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...T(e)});var Qe=class extends k{_parse(e){if(this._getType(e)!==g.nan){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:g.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}};Qe.create=t=>new Qe({typeName:b.ZodNaN,...T(t)});var Rs=Symbol("zod_brand"),St=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},kt=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?v:a.status==="dirty"?(r.dirty(),Te(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?v:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:b.ZodPipeline})}},je=class extends k{_parse(e){let r=this._def.innerType._parse(e),n=o=>(le(o)&&(o.value=Object.freeze(o.value)),o);return We(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};je.create=(t,e)=>new je({innerType:t,typeName:b.ZodReadonly,...T(e)});function Zr(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Jr(t,e={},r){return t?de.create().superRefine((n,o)=>{let a=t(n);if(a instanceof Promise)return a.then(i=>{if(!i){let s=Zr(e,n),u=s.fatal??r??!0;o.addIssue({code:"custom",...s,fatal:u})}});if(!a){let i=Zr(e,n),s=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:s})}}):de.create()}var Ps={object:B.lazycreate},b;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(b||(b={}));var Ms=(t,e={message:`Input not instance of ${t.name}`})=>Jr(r=>r instanceof t,e),Yr=fe.create,Xr=Se.create,Ls=Qe.create,Ns=ke.create,Qr=Ie.create,Ds=Oe.create,js=qe.create,Gs=Ae.create,Bs=Ee.create,Fs=de.create,Us=ae.create,zs=q.create,Hs=Je.create,Zs=se.create,Vs=B.create,Ws=B.strictCreate,Ks=Ce.create,qs=Gt.create,Js=$e.create,Ys=Q.create,Xs=Bt.create,Qs=Ye.create,ei=Xe.create,ti=Ft.create,ri=Re.create,ni=Pe.create,oi=Me.create,ai=Le.create,si=pe.create,ii=V.create,ui=H.create,ci=ee.create,li=V.createWithPreprocess,fi=kt.create,di=()=>Yr().optional(),pi=()=>Xr().optional(),mi=()=>Qr().optional(),hi={string:(t=>fe.create({...t,coerce:!0})),number:(t=>Se.create({...t,coerce:!0})),boolean:(t=>Ie.create({...t,coerce:!0})),bigint:(t=>ke.create({...t,coerce:!0})),date:(t=>Oe.create({...t,coerce:!0}))};var gi=v;var yi=typeof global=="object"&&global&&global.Object===Object&&global,Ut=yi;var xi=typeof self=="object"&&self&&self.Object===Object&&self,_i=Ut||xi||Function("return this")(),L=_i;var vi=L.Symbol,j=vi;var en=Object.prototype,bi=en.hasOwnProperty,wi=en.toString,It=j?j.toStringTag:void 0;function Ti(t){var e=bi.call(t,It),r=t[It];try{t[It]=void 0;var n=!0}catch{}var o=wi.call(t);return n&&(e?t[It]=r:delete t[It]),o}var tn=Ti;var Si=Object.prototype,ki=Si.toString;function Ii(t){return ki.call(t)}var rn=Ii;var Oi="[object Null]",Ai="[object Undefined]",nn=j?j.toStringTag:void 0;function Ei(t){return t==null?t===void 0?Ai:Oi:nn&&nn in Object(t)?tn(t):rn(t)}var J=Ei;function Ci(t){return t!=null&&typeof t=="object"}var Y=Ci;var $i="[object Symbol]";function Ri(t){return typeof t=="symbol"||Y(t)&&J(t)==$i}var ie=Ri;function Pi(t,e){for(var r=-1,n=t==null?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var et=Pi;var Mi=Array.isArray,P=Mi;var Li=1/0,on=j?j.prototype:void 0,an=on?on.toString:void 0;function sn(t){if(typeof t=="string")return t;if(P(t))return et(t,sn)+"";if(ie(t))return an?an.call(t):"";var e=t+"";return e=="0"&&1/t==-Li?"-0":e}var un=sn;function Ni(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var me=Ni;function Di(t){return t}var he=Di;var ji="[object AsyncFunction]",Gi="[object Function]",Bi="[object GeneratorFunction]",Fi="[object Proxy]";function Ui(t){if(!me(t))return!1;var e=J(t);return e==Gi||e==Bi||e==ji||e==Fi}var zt=Ui;var zi=L["__core-js_shared__"],Ht=zi;var cn=(function(){var t=/[^.]+$/.exec(Ht&&Ht.keys&&Ht.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Hi(t){return!!cn&&cn in t}var ln=Hi;var Zi=Function.prototype,Vi=Zi.toString;function Wi(t){if(t!=null){try{return Vi.call(t)}catch{}try{return t+""}catch{}}return""}var ue=Wi;var Ki=/[\\^$.*+?()[\]{}|]/g,qi=/^\[object .+?Constructor\]$/,Ji=Function.prototype,Yi=Object.prototype,Xi=Ji.toString,Qi=Yi.hasOwnProperty,eu=RegExp("^"+Xi.call(Qi).replace(Ki,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function tu(t){if(!me(t)||ln(t))return!1;var e=zt(t)?eu:qi;return e.test(ue(t))}var fn=tu;function ru(t,e){return t?.[e]}var dn=ru;function nu(t,e){var r=dn(t,e);return fn(r)?r:void 0}var F=nu;var ou=F(L,"WeakMap"),Zt=ou;function au(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var pn=au;var su=800,iu=16,uu=Date.now;function cu(t){var e=0,r=0;return function(){var n=uu(),o=iu-(n-r);if(r=n,o>0){if(++e>=su)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var mn=cu;function lu(t){return function(){return t}}var hn=lu;var fu=(function(){try{var t=F(Object,"defineProperty");return t({},"",{}),t}catch{}})(),tt=fu;var du=tt?function(t,e){return tt(t,"toString",{configurable:!0,enumerable:!1,value:hn(e),writable:!0})}:he,gn=du;var pu=mn(gn),yn=pu;var mu=9007199254740991,hu=/^(?:0|[1-9]\d*)$/;function gu(t,e){var r=typeof t;return e=e??mu,!!e&&(r=="number"||r!="symbol"&&hu.test(t))&&t>-1&&t%1==0&&t<e}var rt=gu;function yu(t,e,r){e=="__proto__"&&tt?tt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var xn=yu;function xu(t,e){return t===e||t!==t&&e!==e}var nt=xu;var _n=Math.max;function _u(t,e,r){return e=_n(e===void 0?t.length-1:e,0),function(){for(var n=arguments,o=-1,a=_n(n.length-e,0),i=Array(a);++o<a;)i[o]=n[e+o];o=-1;for(var s=Array(e+1);++o<e;)s[o]=n[o];return s[e]=r(i),pn(t,this,s)}}var vn=_u;function vu(t,e){return yn(vn(t,e,he),t+"")}var bn=vu;var bu=9007199254740991;function wu(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=bu}var ot=wu;function Tu(t){return t!=null&&ot(t.length)&&!zt(t)}var ge=Tu;function Su(t,e,r){if(!me(r))return!1;var n=typeof e;return(n=="number"?ge(r)&&rt(e,r.length):n=="string"&&e in r)?nt(r[e],t):!1}var xr=Su;var ku=Object.prototype;function Iu(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||ku;return t===r}var wn=Iu;function Ou(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}var Tn=Ou;var Au="[object Arguments]";function Eu(t){return Y(t)&&J(t)==Au}var _r=Eu;var Sn=Object.prototype,Cu=Sn.hasOwnProperty,$u=Sn.propertyIsEnumerable,Ru=_r((function(){return arguments})())?_r:function(t){return Y(t)&&Cu.call(t,"callee")&&!$u.call(t,"callee")},at=Ru;function Pu(){return!1}var kn=Pu;var An=typeof exports=="object"&&exports&&!exports.nodeType&&exports,In=An&&typeof module=="object"&&module&&!module.nodeType&&module,Mu=In&&In.exports===An,On=Mu?L.Buffer:void 0,Lu=On?On.isBuffer:void 0,Nu=Lu||kn,Ot=Nu;var Du="[object Arguments]",ju="[object Array]",Gu="[object Boolean]",Bu="[object Date]",Fu="[object Error]",Uu="[object Function]",zu="[object Map]",Hu="[object Number]",Zu="[object Object]",Vu="[object RegExp]",Wu="[object Set]",Ku="[object String]",qu="[object WeakMap]",Ju="[object ArrayBuffer]",Yu="[object DataView]",Xu="[object Float32Array]",Qu="[object Float64Array]",ec="[object Int8Array]",tc="[object Int16Array]",rc="[object Int32Array]",nc="[object Uint8Array]",oc="[object Uint8ClampedArray]",ac="[object Uint16Array]",sc="[object Uint32Array]",R={};R[Xu]=R[Qu]=R[ec]=R[tc]=R[rc]=R[nc]=R[oc]=R[ac]=R[sc]=!0;R[Du]=R[ju]=R[Ju]=R[Gu]=R[Yu]=R[Bu]=R[Fu]=R[Uu]=R[zu]=R[Hu]=R[Zu]=R[Vu]=R[Wu]=R[Ku]=R[qu]=!1;function ic(t){return Y(t)&&ot(t.length)&&!!R[J(t)]}var En=ic;function uc(t){return function(e){return t(e)}}var Vt=uc;var Cn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,At=Cn&&typeof module=="object"&&module&&!module.nodeType&&module,cc=At&&At.exports===Cn,vr=cc&&Ut.process,lc=(function(){try{var t=At&&At.require&&At.require("util").types;return t||vr&&vr.binding&&vr.binding("util")}catch{}})(),br=lc;var $n=br&&br.isTypedArray,fc=$n?Vt($n):En,Wt=fc;var dc=Object.prototype,pc=dc.hasOwnProperty;function mc(t,e){var r=P(t),n=!r&&at(t),o=!r&&!n&&Ot(t),a=!r&&!n&&!o&&Wt(t),i=r||n||o||a,s=i?Tn(t.length,String):[],u=s.length;for(var c in t)(e||pc.call(t,c))&&!(i&&(c=="length"||o&&(c=="offset"||c=="parent")||a&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||rt(c,u)))&&s.push(c);return s}var Rn=mc;function hc(t,e){return function(r){return t(e(r))}}var Pn=hc;var gc=Pn(Object.keys,Object),Mn=gc;var yc=Object.prototype,xc=yc.hasOwnProperty;function _c(t){if(!wn(t))return Mn(t);var e=[];for(var r in Object(t))xc.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ln=_c;function vc(t){return ge(t)?Rn(t):Ln(t)}var st=vc;var bc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,wc=/^\w*$/;function Tc(t,e){if(P(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||ie(t)?!0:wc.test(t)||!bc.test(t)||e!=null&&t in Object(e)}var it=Tc;var Sc=F(Object,"create"),ce=Sc;function kc(){this.__data__=ce?ce(null):{},this.size=0}var Nn=kc;function Ic(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Dn=Ic;var Oc="__lodash_hash_undefined__",Ac=Object.prototype,Ec=Ac.hasOwnProperty;function Cc(t){var e=this.__data__;if(ce){var r=e[t];return r===Oc?void 0:r}return Ec.call(e,t)?e[t]:void 0}var jn=Cc;var $c=Object.prototype,Rc=$c.hasOwnProperty;function Pc(t){var e=this.__data__;return ce?e[t]!==void 0:Rc.call(e,t)}var Gn=Pc;var Mc="__lodash_hash_undefined__";function Lc(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=ce&&e===void 0?Mc:e,this}var Bn=Lc;function ut(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ut.prototype.clear=Nn;ut.prototype.delete=Dn;ut.prototype.get=jn;ut.prototype.has=Gn;ut.prototype.set=Bn;var wr=ut;function Nc(){this.__data__=[],this.size=0}var Fn=Nc;function Dc(t,e){for(var r=t.length;r--;)if(nt(t[r][0],e))return r;return-1}var ye=Dc;var jc=Array.prototype,Gc=jc.splice;function Bc(t){var e=this.__data__,r=ye(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Gc.call(e,r,1),--this.size,!0}var Un=Bc;function Fc(t){var e=this.__data__,r=ye(e,t);return r<0?void 0:e[r][1]}var zn=Fc;function Uc(t){return ye(this.__data__,t)>-1}var Hn=Uc;function zc(t,e){var r=this.__data__,n=ye(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var Zn=zc;function ct(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ct.prototype.clear=Fn;ct.prototype.delete=Un;ct.prototype.get=zn;ct.prototype.has=Hn;ct.prototype.set=Zn;var xe=ct;var Hc=F(L,"Map"),_e=Hc;function Zc(){this.size=0,this.__data__={hash:new wr,map:new(_e||xe),string:new wr}}var Vn=Zc;function Vc(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Wn=Vc;function Wc(t,e){var r=t.__data__;return Wn(e)?r[typeof e=="string"?"string":"hash"]:r.map}var ve=Wc;function Kc(t){var e=ve(this,t).delete(t);return this.size-=e?1:0,e}var Kn=Kc;function qc(t){return ve(this,t).get(t)}var qn=qc;function Jc(t){return ve(this,t).has(t)}var Jn=Jc;function Yc(t,e){var r=ve(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}var Yn=Yc;function lt(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}lt.prototype.clear=Vn;lt.prototype.delete=Kn;lt.prototype.get=qn;lt.prototype.has=Jn;lt.prototype.set=Yn;var Ge=lt;var Xc="Expected a function";function Tr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Xc);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var i=t.apply(this,n);return r.cache=a.set(o,i)||a,i};return r.cache=new(Tr.Cache||Ge),r}Tr.Cache=Ge;var Xn=Tr;var Qc=500;function el(t){var e=Xn(t,function(n){return r.size===Qc&&r.clear(),n}),r=e.cache;return e}var Qn=el;var tl=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rl=/\\(\\)?/g,nl=Qn(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(tl,function(r,n,o,a){e.push(o?a.replace(rl,"$1"):n||r)}),e}),eo=nl;function ol(t){return t==null?"":un(t)}var to=ol;function al(t,e){return P(t)?t:it(t,e)?[t]:eo(to(t))}var Kt=al;var sl=1/0;function il(t){if(typeof t=="string"||ie(t))return t;var e=t+"";return e=="0"&&1/t==-sl?"-0":e}var be=il;function ul(t,e){e=Kt(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[be(e[r++])];return r&&r==n?t:void 0}var ft=ul;function cl(t,e,r){var n=t==null?void 0:ft(t,e);return n===void 0?r:n}var ro=cl;function ll(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var qt=ll;var no=j?j.isConcatSpreadable:void 0;function fl(t){return P(t)||at(t)||!!(no&&t&&t[no])}var oo=fl;function ao(t,e,r,n,o){var a=-1,i=t.length;for(r||(r=oo),o||(o=[]);++a<i;){var s=t[a];e>0&&r(s)?e>1?ao(s,e-1,r,n,o):qt(o,s):n||(o[o.length]=s)}return o}var so=ao;function dl(){this.__data__=new xe,this.size=0}var io=dl;function pl(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var uo=pl;function ml(t){return this.__data__.get(t)}var co=ml;function hl(t){return this.__data__.has(t)}var lo=hl;var gl=200;function yl(t,e){var r=this.__data__;if(r instanceof xe){var n=r.__data__;if(!_e||n.length<gl-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ge(n)}return r.set(t,e),this.size=r.size,this}var fo=yl;function dt(t){var e=this.__data__=new xe(t);this.size=e.size}dt.prototype.clear=io;dt.prototype.delete=uo;dt.prototype.get=co;dt.prototype.has=lo;dt.prototype.set=fo;var pt=dt;function xl(t,e){for(var r=-1,n=t==null?0:t.length,o=0,a=[];++r<n;){var i=t[r];e(i,r,t)&&(a[o++]=i)}return a}var po=xl;function _l(){return[]}var mo=_l;var vl=Object.prototype,bl=vl.propertyIsEnumerable,ho=Object.getOwnPropertySymbols,wl=ho?function(t){return t==null?[]:(t=Object(t),po(ho(t),function(e){return bl.call(t,e)}))}:mo,go=wl;function Tl(t,e,r){var n=e(t);return P(t)?n:qt(n,r(t))}var yo=Tl;function Sl(t){return yo(t,st,go)}var Sr=Sl;var kl=F(L,"DataView"),Jt=kl;var Il=F(L,"Promise"),Yt=Il;var Ol=F(L,"Set"),Xt=Ol;var xo="[object Map]",Al="[object Object]",_o="[object Promise]",vo="[object Set]",bo="[object WeakMap]",wo="[object DataView]",El=ue(Jt),Cl=ue(_e),$l=ue(Yt),Rl=ue(Xt),Pl=ue(Zt),Be=J;(Jt&&Be(new Jt(new ArrayBuffer(1)))!=wo||_e&&Be(new _e)!=xo||Yt&&Be(Yt.resolve())!=_o||Xt&&Be(new Xt)!=vo||Zt&&Be(new Zt)!=bo)&&(Be=function(t){var e=J(t),r=e==Al?t.constructor:void 0,n=r?ue(r):"";if(n)switch(n){case El:return wo;case Cl:return xo;case $l:return _o;case Rl:return vo;case Pl:return bo}return e});var kr=Be;var Ml=L.Uint8Array,Ir=Ml;var Ll="__lodash_hash_undefined__";function Nl(t){return this.__data__.set(t,Ll),this}var To=Nl;function Dl(t){return this.__data__.has(t)}var So=Dl;function Qt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Ge;++e<r;)this.add(t[e])}Qt.prototype.add=Qt.prototype.push=To;Qt.prototype.has=So;var ko=Qt;function jl(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}var Io=jl;function Gl(t,e){return t.has(e)}var Oo=Gl;var Bl=1,Fl=2;function Ul(t,e,r,n,o,a){var i=r&Bl,s=t.length,u=e.length;if(s!=u&&!(i&&u>s))return!1;var c=a.get(t),f=a.get(e);if(c&&f)return c==e&&f==t;var p=-1,d=!0,_=r&Fl?new ko:void 0;for(a.set(t,e),a.set(e,t);++p<s;){var A=t[p],O=e[p];if(n)var S=i?n(O,A,p,e,t,a):n(A,O,p,t,e,a);if(S!==void 0){if(S)continue;d=!1;break}if(_){if(!Io(e,function(M,K){if(!Oo(_,K)&&(A===M||o(A,M,r,n,a)))return _.push(K)})){d=!1;break}}else if(!(A===O||o(A,O,r,n,a))){d=!1;break}}return a.delete(t),a.delete(e),d}var er=Ul;function zl(t){var e=-1,r=Array(t.size);return t.forEach(function(n,o){r[++e]=[o,n]}),r}var Ao=zl;function Hl(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var Eo=Hl;var Zl=1,Vl=2,Wl="[object Boolean]",Kl="[object Date]",ql="[object Error]",Jl="[object Map]",Yl="[object Number]",Xl="[object RegExp]",Ql="[object Set]",ef="[object String]",tf="[object Symbol]",rf="[object ArrayBuffer]",nf="[object DataView]",Co=j?j.prototype:void 0,Or=Co?Co.valueOf:void 0;function of(t,e,r,n,o,a,i){switch(r){case nf:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case rf:return!(t.byteLength!=e.byteLength||!a(new Ir(t),new Ir(e)));case Wl:case Kl:case Yl:return nt(+t,+e);case ql:return t.name==e.name&&t.message==e.message;case Xl:case ef:return t==e+"";case Jl:var s=Ao;case Ql:var u=n&Zl;if(s||(s=Eo),t.size!=e.size&&!u)return!1;var c=i.get(t);if(c)return c==e;n|=Vl,i.set(t,e);var f=er(s(t),s(e),n,o,a,i);return i.delete(t),f;case tf:if(Or)return Or.call(t)==Or.call(e)}return!1}var $o=of;var af=1,sf=Object.prototype,uf=sf.hasOwnProperty;function cf(t,e,r,n,o,a){var i=r&af,s=Sr(t),u=s.length,c=Sr(e),f=c.length;if(u!=f&&!i)return!1;for(var p=u;p--;){var d=s[p];if(!(i?d in e:uf.call(e,d)))return!1}var _=a.get(t),A=a.get(e);if(_&&A)return _==e&&A==t;var O=!0;a.set(t,e),a.set(e,t);for(var S=i;++p<u;){d=s[p];var M=t[d],K=e[d];if(n)var Lt=i?n(K,M,d,e,t,a):n(M,K,d,t,e,a);if(!(Lt===void 0?M===K||o(M,K,r,n,a):Lt)){O=!1;break}S||(S=d=="constructor")}if(O&&!S){var Ze=t.constructor,Nt=e.constructor;Ze!=Nt&&"constructor"in t&&"constructor"in e&&!(typeof Ze=="function"&&Ze instanceof Ze&&typeof Nt=="function"&&Nt instanceof Nt)&&(O=!1)}return a.delete(t),a.delete(e),O}var Ro=cf;var lf=1,Po="[object Arguments]",Mo="[object Array]",tr="[object Object]",ff=Object.prototype,Lo=ff.hasOwnProperty;function df(t,e,r,n,o,a){var i=P(t),s=P(e),u=i?Mo:kr(t),c=s?Mo:kr(e);u=u==Po?tr:u,c=c==Po?tr:c;var f=u==tr,p=c==tr,d=u==c;if(d&&Ot(t)){if(!Ot(e))return!1;i=!0,f=!1}if(d&&!f)return a||(a=new pt),i||Wt(t)?er(t,e,r,n,o,a):$o(t,e,u,r,n,o,a);if(!(r&lf)){var _=f&&Lo.call(t,"__wrapped__"),A=p&&Lo.call(e,"__wrapped__");if(_||A){var O=_?t.value():t,S=A?e.value():e;return a||(a=new pt),o(O,S,r,n,a)}}return d?(a||(a=new pt),Ro(t,e,r,n,o,a)):!1}var No=df;function Do(t,e,r,n,o){return t===e?!0:t==null||e==null||!Y(t)&&!Y(e)?t!==t&&e!==e:No(t,e,r,n,Do,o)}var rr=Do;var pf=1,mf=2;function hf(t,e,r,n){var o=r.length,a=o,i=!n;if(t==null)return!a;for(t=Object(t);o--;){var s=r[o];if(i&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++o<a;){s=r[o];var u=s[0],c=t[u],f=s[1];if(i&&s[2]){if(c===void 0&&!(u in t))return!1}else{var p=new pt;if(n)var d=n(c,f,u,t,e,p);if(!(d===void 0?rr(f,c,pf|mf,n,p):d))return!1}}return!0}var jo=hf;function gf(t){return t===t&&!me(t)}var nr=gf;function yf(t){for(var e=st(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,nr(o)]}return e}var Go=yf;function xf(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}var or=xf;function _f(t){var e=Go(t);return e.length==1&&e[0][2]?or(e[0][0],e[0][1]):function(r){return r===t||jo(r,t,e)}}var Bo=_f;function vf(t,e){return t!=null&&e in Object(t)}var Fo=vf;function bf(t,e,r){e=Kt(e,t);for(var n=-1,o=e.length,a=!1;++n<o;){var i=be(e[n]);if(!(a=t!=null&&r(t,i)))break;t=t[i]}return a||++n!=o?a:(o=t==null?0:t.length,!!o&&ot(o)&&rt(i,o)&&(P(t)||at(t)))}var Uo=bf;function wf(t,e){return t!=null&&Uo(t,e,Fo)}var zo=wf;var Tf=1,Sf=2;function kf(t,e){return it(t)&&nr(e)?or(be(t),e):function(r){var n=ro(r,t);return n===void 0&&n===e?zo(r,t):rr(e,n,Tf|Sf)}}var Ho=kf;function If(t){return function(e){return e?.[t]}}var Zo=If;function Of(t){return function(e){return ft(e,t)}}var Vo=Of;function Af(t){return it(t)?Zo(be(t)):Vo(t)}var Wo=Af;function Ef(t){return typeof t=="function"?t:t==null?he:typeof t=="object"?P(t)?Ho(t[0],t[1]):Bo(t):Wo(t)}var ar=Ef;function Cf(t,e,r,n){for(var o=-1,a=t==null?0:t.length;++o<a;){var i=t[o];e(n,i,r(i),t)}return n}var Ko=Cf;function $f(t){return function(e,r,n){for(var o=-1,a=Object(e),i=n(e),s=i.length;s--;){var u=i[t?s:++o];if(r(a[u],u,a)===!1)break}return e}}var qo=$f;var Rf=qo(),Jo=Rf;function Pf(t,e){return t&&Jo(t,e,st)}var Yo=Pf;function Mf(t,e){return function(r,n){if(r==null)return r;if(!ge(r))return t(r,n);for(var o=r.length,a=e?o:-1,i=Object(r);(e?a--:++a<o)&&n(i[a],a,i)!==!1;);return r}}var Xo=Mf;var Lf=Xo(Yo),sr=Lf;function Nf(t,e,r,n){return sr(t,function(o,a,i){e(n,o,r(o),i)}),n}var Qo=Nf;function Df(t,e){return function(r,n){var o=P(r)?Ko:Qo,a=e?e():{};return o(r,t,ar(n,2),a)}}var ea=Df;function jf(t,e){var r=-1,n=ge(t)?Array(t.length):[];return sr(t,function(o,a,i){n[++r]=e(o,a,i)}),n}var ta=jf;var Gf=Object.prototype,Bf=Gf.hasOwnProperty,Ff=ea(function(t,e,r){Bf.call(t,r)?t[r].push(e):xn(t,r,[e])}),Et=Ff;function Uf(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}var ra=Uf;function zf(t,e){if(t!==e){var r=t!==void 0,n=t===null,o=t===t,a=ie(t),i=e!==void 0,s=e===null,u=e===e,c=ie(e);if(!s&&!c&&!a&&t>e||a&&i&&u&&!s&&!c||n&&i&&u||!r&&u||!o)return 1;if(!n&&!a&&!c&&t<e||c&&r&&o&&!n&&!a||s&&r&&o||!i&&o||!u)return-1}return 0}var na=zf;function Hf(t,e,r){for(var n=-1,o=t.criteria,a=e.criteria,i=o.length,s=r.length;++n<i;){var u=na(o[n],a[n]);if(u){if(n>=s)return u;var c=r[n];return u*(c=="desc"?-1:1)}}return t.index-e.index}var oa=Hf;function Zf(t,e,r){e.length?e=et(e,function(a){return P(a)?function(i){return ft(i,a.length===1?a[0]:a)}:a}):e=[he];var n=-1;e=et(e,Vt(ar));var o=ta(t,function(a,i,s){var u=et(e,function(c){return c(a)});return{criteria:u,index:++n,value:a}});return ra(o,function(a,i){return oa(a,i,r)})}var aa=Zf;var Vf=bn(function(t,e){if(t==null)return[];var r=e.length;return r>1&&xr(t,e[0],e[1])?e=[]:r>2&&xr(e[0],e[1],e[2])&&(e=[e[0]]),aa(t,so(e,1),[])}),Ar=Vf;U();function w(t){return{content:[{type:"text",text:t}]}}function re(t,e){return!t||t.length<=e?t:t.slice(0,e)+"..."}var wt=200;function Na(t){t.tool("search",`Search Sigil knowledge base for facts across all ingested documents.
22
19
  Automatically detects entity names and returns entity-centric results.
23
20
  Use for: "how does X work", "what is Y?", "what are the rules for Z", domain knowledge, decisions.
24
21
  Returns compact facts. Use get_fact_context(factId) for full detail on any fact.
25
22
  Set includeChunks=true only when raw document context is needed.
26
- Set format="compact" for token-efficient output (one line per category, no IDs/metadata).`,{query:g.string().describe("Natural language search query"),limit:g.number().optional().default(5).describe("Max facts to return (default 5)"),namespaces:g.array(g.string()).optional().describe("Filter by namespaces"),minConfidence:g.enum(["low","medium","high"]).optional().default("medium").describe("Minimum fact confidence"),includeChunks:g.boolean().optional().default(!1).describe("Include raw document chunks (verbose \u2014 only when needed)"),useGraph:g.boolean().optional().default(!1).describe("Traverse entity graph for additional related facts"),pointInTime:g.string().optional().describe("ISO timestamp \u2014 return only facts valid at this point in time"),format:g.enum(["full","compact"]).optional().default("full").describe('Output format: "full" (default) or "compact" (token-efficient, one line per category)'),podScope:g.union([g.literal("auto"),g.literal("global"),g.array(g.string())]).optional().describe('Pod scope: "auto" (active project/session pods \u2014 the default), "global" (whole brain, no scope), or list of pod uids/names.')},async({query:e,limit:r,namespaces:n,minConfidence:o,includeChunks:a,useGraph:i,pointInTime:s,format:c,podScope:u})=>{let l=await L("search",{query:e,namespaces:n,limit:r,minConfidence:o,includeChunks:a,useGraph:i,pointInTime:s,podScope:u??"auto",cwd:process.cwd(),route:!1,synthesize:!1}),{facts:p,chunks:y,matchedEntity:x,relatedEntities:O}=l;if(c==="compact")return E(Cd(p,x));let I=[];if(x&&(I.push(`**Matched entity:** ${x.name} (${x.entityType||x.type}, id:${x.id}, ${x.mentions??x.mentionCount??0} mentions)`),x.description&&I.push(x.description),I.push("")),p.length){I.push(`**Facts (${p.length}):**`);for(let w of p){let $=te(w.content,Tt),re=w.importance==="vital"?" **[VITAL]**":"",Nt=w.agent?` \xB7 via ${w.agent}`:"",Ve=Array.isArray(w.sourceDocumentIds)&&w.sourceDocumentIds.length?` \xB7 doc#${w.sourceDocumentIds[0]}`:"";I.push(`- [${w.category}] ${$}${re} _(${w.confidence}, id:${w.id}${Nt}${Ve})_`)}}if(O.length){I.push(""),I.push(`**Related entities (${O.length}):**`);for(let w of O.slice(0,10))I.push(`- ${w.name} (${w.entityType||w.type}) [${w.relation}] id:${w.id}`)}if(a&&y.length){I.push(""),I.push(`**Chunks (${y.length}):**`);for(let w of y.slice(0,3)){let $=w.sectionHeading?`[${w.sectionHeading}] `:"";I.push(`---
27
- ${$}${te(w.content,500)}`)}}return!p.length&&!y.length&&I.push("No results found. Try broader terms or use search_entity to find entity names."),x&&I.push(`
28
- _Drill down: get_entity_context(entityId=${x.id}) for full details about ${x.name}_`),E(I.join(`
29
- `))})}function Cd(t,e){let r=[];if(e&&r.push(`> ${e.name} (${e.entityType||e.type})`),!t.length)return r.push("No results."),r.join(`
30
- `);let n=kt(t,"category");for(let[o,a]of Object.entries(n)){let s=wr(a,c=>c.importance==="vital"?0:1).map(c=>c.content);r.push(`[${o}]: ${s.join(". ")}`)}return r.join(`
31
- `)}H();function Ra(t){t.tool("search_entity",`Find entities in the knowledge graph by name or type.
23
+ Set format="compact" for token-efficient output (one line per category, no IDs/metadata).`,{query:h.string().describe("Natural language search query"),limit:h.number().optional().default(5).describe("Max facts to return (default 5)"),namespaces:h.array(h.string()).optional().describe("Filter by namespaces"),minConfidence:h.enum(["low","medium","high"]).optional().default("medium").describe("Minimum fact confidence"),includeChunks:h.boolean().optional().default(!1).describe("Include raw document chunks (verbose \u2014 only when needed)"),useGraph:h.boolean().optional().default(!1).describe("Traverse entity graph for additional related facts"),pointInTime:h.string().optional().describe("ISO timestamp \u2014 return only facts valid at this point in time"),format:h.enum(["full","compact"]).optional().default("full").describe('Output format: "full" (default) or "compact" (token-efficient, one line per category)'),podScope:h.union([h.literal("auto"),h.literal("global"),h.array(h.string())]).optional().describe('Pod scope: "auto" (active project/session pods \u2014 the default), "global" (whole brain, no scope), or list of pod uids/names.')},async({query:e,limit:r,namespaces:n,minConfidence:o,includeChunks:a,useGraph:i,pointInTime:s,format:u,podScope:c})=>{let f=await $("search",{query:e,namespaces:n,limit:r,minConfidence:o,includeChunks:a,useGraph:i,pointInTime:s,podScope:c??"auto",cwd:process.cwd(),route:!1,synthesize:!1}),{facts:p,chunks:d,matchedEntity:_,relatedEntities:A}=f;if(u==="compact")return w(Zd(p,_));let O=[];if(_&&(O.push(`**Matched entity:** ${_.name} (${_.entityType||_.type}, id:${_.id}, ${_.mentions??_.mentionCount??0} mentions)`),_.description&&O.push(_.description),O.push("")),p.length){O.push(`**Facts (${p.length}):**`);for(let S of p){let M=re(S.content,wt),K=S.importance==="vital"?" **[VITAL]**":"",Lt=S.agent?` \xB7 via ${S.agent}`:"",Ze=Array.isArray(S.sourceDocumentIds)&&S.sourceDocumentIds.length?` \xB7 doc#${S.sourceDocumentIds[0]}`:"";O.push(`- [${S.category}] ${M}${K} _(${S.confidence}, id:${S.id}${Lt}${Ze})_`)}}if(A.length){O.push(""),O.push(`**Related entities (${A.length}):**`);for(let S of A.slice(0,10))O.push(`- ${S.name} (${S.entityType||S.type}) [${S.relation}] id:${S.id}`)}if(a&&d.length){O.push(""),O.push(`**Chunks (${d.length}):**`);for(let S of d.slice(0,3)){let M=S.sectionHeading?`[${S.sectionHeading}] `:"";O.push(`---
24
+ ${M}${re(S.content,500)}`)}}return!p.length&&!d.length&&O.push("No results found. Try broader terms or use search_entity to find entity names."),_&&O.push(`
25
+ _Drill down: get_entity_context(entityId=${_.id}) for full details about ${_.name}_`),w(O.join(`
26
+ `))})}function Zd(t,e){let r=[];if(e&&r.push(`> ${e.name} (${e.entityType||e.type})`),!t.length)return r.push("No results."),r.join(`
27
+ `);let n=Et(t,"category");for(let[o,a]of Object.entries(n)){let s=Ar(a,u=>u.importance==="vital"?0:1).map(u=>u.content);r.push(`[${o}]: ${s.join(". ")}`)}return r.join(`
28
+ `)}U();function Da(t){t.tool("search_entity",`Find entities in the knowledge graph by name or type.
32
29
  Use for: "find Alice", "list all topics", "show all people", "find documents about normalization".
33
30
  Entity types: document, person, topic (extensible per domain).
34
- Returns compact entity list. Use get_entity_context(entityId) for full details.`,{query:g.string().optional().describe('Entity name to search (e.g. "Alice", "Cohort 6")'),entityType:g.string().optional().describe("Filter by type: session, course, person, topic"),limit:g.number().optional().default(10).describe("Max results"),namespace:g.string().optional().describe("Namespace. Omit for default.")},async({query:e,entityType:r,limit:n,namespace:o})=>{if(!e&&!r)return E("Error: Provide either a query (entity name) or entityType.");let{entities:a}=await L("searchEntity",{query:e,entityType:r,limit:n,namespace:o});if(!a.length){let c=e?`matching "${e}"`:`of type "${r}"`;return E(`No entities found ${c}.`)}let i=a.map(c=>{let u=c.description?` \u2014 ${c.description}`:"";return`- **${c.name}** (${c.entityType}, id:${c.id}, ${c.mentionCount} mentions)${u}`}),s=e?`Entities matching "${e}"`:`${r} entities`;return E(`${s} (${a.length}):
31
+ Returns compact entity list. Use get_entity_context(entityId) for full details.`,{query:h.string().optional().describe('Entity name to search (e.g. "Alice", "Cohort 6")'),entityType:h.string().optional().describe("Filter by type: session, course, person, topic"),limit:h.number().optional().default(10).describe("Max results"),namespace:h.string().optional().describe("Namespace. Omit for default.")},async({query:e,entityType:r,limit:n,namespace:o})=>{if(!e&&!r)return w("Error: Provide either a query (entity name) or entityType.");let{entities:a}=await $("searchEntity",{query:e,entityType:r,limit:n,namespace:o});if(!a.length){let u=e?`matching "${e}"`:`of type "${r}"`;return w(`No entities found ${u}.`)}let i=a.map(u=>{let c=u.description?` \u2014 ${u.description}`:"";return`- **${u.name}** (${u.entityType}, id:${u.id}, ${u.mentionCount} mentions)${c}`}),s=e?`Entities matching "${e}"`:`${r} entities`;return w(`${s} (${a.length}):
35
32
  ${i.join(`
36
33
  `)}
37
34
 
38
- _Use get_entity_context(entityId=<id>) for details or traverse_graph(startEntityId=<id>) for connections._`)})}H();function La(t){t.tool("traverse_graph",`Navigate entity relationships in the knowledge graph.
35
+ _Use get_entity_context(entityId=<id>) for details or traverse_graph(startEntityId=<id>) for connections._`)})}U();function ja(t){t.tool("traverse_graph",`Navigate entity relationships in the knowledge graph.
39
36
  Use for: "who did Alice mentor?", "what topics does course X cover?", "how is A related to B?",
40
37
  "what documents cover this topic?", "show mentorship chain".
41
- Relation types: PART_OF, LED_BY, MENTORED, COVERS, FOLLOWS.`,{startEntityId:g.number().describe("Starting entity ID (from search_entity results)"),action:g.enum(["neighbors","path","related"]).optional().default("neighbors").describe("neighbors = direct connections, path = shortest path to target, related = all reachable"),targetEntityId:g.number().optional().describe('Target entity ID (required for "path" action)'),relationType:g.string().optional().describe("Filter: PART_OF, LED_BY, MENTORED, COVERS, FOLLOWS"),maxDepth:g.number().optional().default(2).describe("Traversal depth 1-3"),limit:g.number().optional().default(20).describe("Max results")},async({startEntityId:e,action:r,targetEntityId:n,relationType:o,maxDepth:a,limit:i})=>{let s=await L("traverseGraph",{startEntityId:e,action:r,targetEntityId:n,relationType:o,maxDepth:a,limit:i});if(s.notFound)return E(`Error: Entity ID ${e} not found.`);let c=`${s.start.name} (${s.start.entityType}, id:${s.start.id})`;if(s.action==="path"){if(!s.path)return E(`No path found from ${s.start.name} to entity ${n}.`);let y=s.path.path.map((x,O)=>{let I=O<s.path.relationTypes.length?` --[${s.path.relationTypes[O]}]--> `:"";return`${x.name} (${x.entityType})${I}`});return E(`Path (${s.path.depth} hops):
42
- ${y.join("")}`)}if(s.action==="related"){let y=s.related||[];if(!y.length)return E(`${s.start.name} has no related entities within ${a} hops.`);let x=kt(y,"depth"),O=[`Entities related to ${c} (${y.length}):`];for(let I of Object.keys(x).sort()){let w=I==="1"?"Direct":`${I} hops`;O.push(`
43
- ${w}:`);for(let $ of x[I])O.push(`- [${$.relationType}] ${$.name} (${$.entityType}, id:${$.entityId})`)}return E(O.join(`
44
- `))}if(s.related){let y=s.related.map(x=>`- [${x.relationType}] ${x.name} (${x.entityType}, id:${x.entityId||x.id}) depth:${x.depth}`);return E(`${c}
38
+ Relation types: PART_OF, LED_BY, MENTORED, COVERS, FOLLOWS.`,{startEntityId:h.number().describe("Starting entity ID (from search_entity results)"),action:h.enum(["neighbors","path","related"]).optional().default("neighbors").describe("neighbors = direct connections, path = shortest path to target, related = all reachable"),targetEntityId:h.number().optional().describe('Target entity ID (required for "path" action)'),relationType:h.string().optional().describe("Filter: PART_OF, LED_BY, MENTORED, COVERS, FOLLOWS"),maxDepth:h.number().optional().default(2).describe("Traversal depth 1-3"),limit:h.number().optional().default(20).describe("Max results")},async({startEntityId:e,action:r,targetEntityId:n,relationType:o,maxDepth:a,limit:i})=>{let s=await $("traverseGraph",{startEntityId:e,action:r,targetEntityId:n,relationType:o,maxDepth:a,limit:i});if(s.notFound)return w(`Error: Entity ID ${e} not found.`);let u=`${s.start.name} (${s.start.entityType}, id:${s.start.id})`;if(s.action==="path"){if(!s.path)return w(`No path found from ${s.start.name} to entity ${n}.`);let d=s.path.path.map((_,A)=>{let O=A<s.path.relationTypes.length?` --[${s.path.relationTypes[A]}]--> `:"";return`${_.name} (${_.entityType})${O}`});return w(`Path (${s.path.depth} hops):
39
+ ${d.join("")}`)}if(s.action==="related"){let d=s.related||[];if(!d.length)return w(`${s.start.name} has no related entities within ${a} hops.`);let _=Et(d,"depth"),A=[`Entities related to ${u} (${d.length}):`];for(let O of Object.keys(_).sort()){let S=O==="1"?"Direct":`${O} hops`;A.push(`
40
+ ${S}:`);for(let M of _[O])A.push(`- [${M.relationType}] ${M.name} (${M.entityType}, id:${M.entityId})`)}return w(A.join(`
41
+ `))}if(s.related){let d=s.related.map(_=>`- [${_.relationType}] ${_.name} (${_.entityType}, id:${_.entityId||_.id}) depth:${_.depth}`);return w(`${u}
45
42
  Connections (${s.related.length}):
46
- ${y.join(`
47
- `)}`)}if(!s.relations?.length)return E(`${c}
48
- No connections found.`);let u=s.relations.filter(y=>y.direction==="outgoing"),l=s.relations.filter(y=>y.direction==="incoming"),p=[c];if(u.length){p.push(`
49
- Outgoing (${u.length}):`);for(let y of u)p.push(`- [${y.relationType}] ${y.name} (${y.entityType}, id:${y.entityId})`)}if(l.length){p.push(`
50
- Incoming (${l.length}):`);for(let y of l)p.push(`- ${y.name} (${y.entityType}, id:${y.entityId}) [${y.relationType}]`)}return E(p.join(`
51
- `))})}H();function Ca(t){t.tool("get_fact_context",`Get full context for a specific fact: complete content, entities mentioned, relations created, sources.
43
+ ${d.join(`
44
+ `)}`)}if(!s.relations?.length)return w(`${u}
45
+ No connections found.`);let c=s.relations.filter(d=>d.direction==="outgoing"),f=s.relations.filter(d=>d.direction==="incoming"),p=[u];if(c.length){p.push(`
46
+ Outgoing (${c.length}):`);for(let d of c)p.push(`- [${d.relationType}] ${d.name} (${d.entityType}, id:${d.entityId})`)}if(f.length){p.push(`
47
+ Incoming (${f.length}):`);for(let d of f)p.push(`- ${d.name} (${d.entityType}, id:${d.entityId}) [${d.relationType}]`)}return w(p.join(`
48
+ `))})}U();function Ga(t){t.tool("get_fact_context",`Get full context for a specific fact: complete content, entities mentioned, relations created, sources.
52
49
  Use for: drilling down on a fact from search results, checking provenance, understanding connections.
53
- This is the detail view \u2014 search returns truncated facts, this returns everything.`,{factId:g.number().optional().describe("Fact ID (from search results)"),uid:g.string().optional().describe('Fact UID (e.g. "fact-a1b2c3d4")')},async({uid:e,factId:r})=>{if(!e&&!r)return E("Error: Provide either factId or uid.");let n=await L("getFactContext",{uid:e,factId:r});if(n.notFound)return E("Error: Fact not found.");let{fact:o,entities:a,relations:i,documents:s}=n,c=[`**Fact ${o.uid}** (${o.category}, ${o.confidence}, ${o.status})`,o.content];if(o.sourceSection&&c.push(`Source section: ${o.sourceSection}`),a.length&&c.push(`
54
- Entities mentioned: ${a.map(u=>`${u.name} (${u.entityType}, id:${u.id})`).join(", ")}`),i.length){c.push(`
55
- Relations from this fact:`);for(let u of i)c.push(`- ${u.sourceName} --[${u.relationType}]--> ${u.targetName}`)}return s.length&&c.push(`
56
- Sources: ${s.map(u=>`${u.title} (${u.sourceType})`).join(", ")}`),E(c.join(`
57
- `))})}H();function Na(t){t.tool("get_entity_context",`Get full context for an entity: relations, connected facts, graph position.
50
+ This is the detail view \u2014 search returns truncated facts, this returns everything.`,{factId:h.number().optional().describe("Fact ID (from search results)"),uid:h.string().optional().describe('Fact UID (e.g. "fact-a1b2c3d4")')},async({uid:e,factId:r})=>{if(!e&&!r)return w("Error: Provide either factId or uid.");let n=await $("getFactContext",{uid:e,factId:r});if(n.notFound)return w("Error: Fact not found.");let{fact:o,entities:a,relations:i,documents:s}=n,u=[`**Fact ${o.uid}** (${o.category}, ${o.confidence}, ${o.status})`,o.content];if(o.sourceSection&&u.push(`Source section: ${o.sourceSection}`),a.length&&u.push(`
51
+ Entities mentioned: ${a.map(c=>`${c.name} (${c.entityType}, id:${c.id})`).join(", ")}`),i.length){u.push(`
52
+ Relations from this fact:`);for(let c of i)u.push(`- ${c.sourceName} --[${c.relationType}]--> ${c.targetName}`)}return s.length&&u.push(`
53
+ Sources: ${s.map(c=>`${c.title} (${c.sourceType})`).join(", ")}`),w(u.join(`
54
+ `))})}U();function Ba(t){t.tool("get_entity_context",`Get full context for an entity: relations, connected facts, graph position.
58
55
  Use for: "tell me about Alice", "what documents cover this topic?", "show expertise areas".
59
- Returns entity details + relations + key facts (truncated \u2014 use get_fact_context for full text).`,{entityId:g.number().optional().describe("Entity ID (from search_entity or search results)"),name:g.string().optional().describe("Entity name (alternative to ID)"),namespace:g.string().optional().describe("Namespace. Omit for default.")},async({entityId:e,name:r,namespace:n})=>{if(!e&&!r)return E("Error: Provide either entityId or name.");let o=await L("getEntityContext",{entityId:e,name:r,namespace:n});if(o.notFound)return E("Error: Entity not found.");let{entity:a,relations:i,facts:s}=o,c=[`**${a.name}** (${a.entityType}, id:${a.id}, ${a.mentionCount} mentions)`];a.description&&c.push(a.description);let u=i.filter(p=>p.direction==="outgoing"),l=i.filter(p=>p.direction==="incoming");if(u.length){c.push(`
60
- Outgoing relations (${u.length}):`);for(let p of u.slice(0,15))c.push(`- [${p.relationType}] ${p.name} (${p.entityType}, id:${p.entityId})`);u.length>15&&c.push(` ...and ${u.length-15} more`)}if(l.length){c.push(`
61
- Incoming relations (${l.length}):`);for(let p of l.slice(0,15))c.push(`- ${p.name} (${p.entityType}, id:${p.entityId}) [${p.relationType}]`);l.length>15&&c.push(` ...and ${l.length-15} more`)}if(s.length){c.push(`
62
- Key facts (${s.length}):`);for(let p of s){let y=te(p.content,Tt);c.push(`- [${p.category}] ${y} _(${p.confidence}, id:${p.id})_`)}}return!u.length&&!l.length&&!s.length&&c.push(`
63
- No connections or facts found for this entity.`),c.push(`
64
- _Use traverse_graph(startEntityId=${a.id}) for deeper graph exploration._`),E(c.join(`
65
- `))})}H();function Pa(t){t.tool("status",`Show Sigil knowledge base statistics \u2014 documents, chunks, facts, entities, relations.
66
- Use when: checking system health, verifying ingestion, reviewing knowledge graph size.`,{namespace:g.string().optional().describe("Filter by namespace. Omit for global stats.")},async({namespace:e})=>{let r=await L("status",{namespace:e,hotFactsLimit:5}),o=[`Sigil KB${r.namespace?` (${r.namespace})`:""}: ${r.documents} docs, ${r.chunks} chunks, ${r.facts} facts`,`Entities: ${r.entities.documents} documents, ${r.entities.people} people, ${r.entities.topics} topics`,`Relations: ${r.relations}`,`Hot facts (top ${r.hotFacts.length}): ${r.hotFacts.map(a=>`${te(a.content,60)} (${a.accessCount}x)`).join(", ")||"none yet"}`].join(`
67
- `);return E(o)})}H();function $a(t){t.tool("ingest",`Ingest a document into the Sigil knowledge base. Accepts raw content, a file path, or a URL.
68
- Parses the content, chunks it, embeds it, extracts facts, links entities, and stores everything for search.
69
- Use when: adding documents to the knowledge base, ingesting files, URLs, or raw text.`,{content:g.string().optional().describe("Raw text content to ingest. Provide this OR filePath OR url."),filePath:g.string().optional().describe("Local file path to ingest. Provide this OR content OR url."),url:g.string().optional().describe("URL to fetch and ingest. Provide this OR content OR filePath."),title:g.string().optional().describe("Document title. Auto-detected if not provided."),namespace:g.string().optional().describe("Namespace for the document. Defaults to config default."),sourceType:g.string().optional().describe("Source type label (e.g., docs, code, notes). Auto-detected from format."),skipFacts:g.boolean().optional().default(!1).describe("Skip fact extraction (faster, chunks only)"),skipEntities:g.boolean().optional().default(!1).describe("Skip entity linking")},async({content:e,filePath:r,url:n,title:o,namespace:a,sourceType:i,skipFacts:s,skipEntities:c})=>{let u=await L("ingestDoc",{content:e,filePath:r,url:n,title:o,namespace:a,sourceType:i,skipFacts:s,skipEntities:c}),l=u.skipped?`Document "${u.title}" already up to date \u2014 skipped.`:[`Document "${u.title}" ingested.`,`- Document ID: ${u.documentId}`,`- Chunks: ${u.chunkCount}`,u.facts?`- Facts: ${u.facts.total} extracted (${u.facts.added} new, ${u.facts.skipped} skipped)`:"- Facts: skipped",u.entities?`- Entities: ${u.entities.entityCount}, Relations: ${u.entities.relationCount}`:"- Entities: skipped",u.output?`- Output: ${u.output}`:""].filter(Boolean).join(`
70
- `);return E(l)})}H();function Ma(t){t.tool("remember",`Save one or more standalone facts to the Sigil knowledge base.
56
+ Returns entity details + relations + key facts (truncated \u2014 use get_fact_context for full text).`,{entityId:h.number().optional().describe("Entity ID (from search_entity or search results)"),name:h.string().optional().describe("Entity name (alternative to ID)"),namespace:h.string().optional().describe("Namespace. Omit for default.")},async({entityId:e,name:r,namespace:n})=>{if(!e&&!r)return w("Error: Provide either entityId or name.");let o=await $("getEntityContext",{entityId:e,name:r,namespace:n});if(o.notFound)return w("Error: Entity not found.");let{entity:a,relations:i,facts:s}=o,u=[`**${a.name}** (${a.entityType}, id:${a.id}, ${a.mentionCount} mentions)`];a.description&&u.push(a.description);let c=i.filter(p=>p.direction==="outgoing"),f=i.filter(p=>p.direction==="incoming");if(c.length){u.push(`
57
+ Outgoing relations (${c.length}):`);for(let p of c.slice(0,15))u.push(`- [${p.relationType}] ${p.name} (${p.entityType}, id:${p.entityId})`);c.length>15&&u.push(` ...and ${c.length-15} more`)}if(f.length){u.push(`
58
+ Incoming relations (${f.length}):`);for(let p of f.slice(0,15))u.push(`- ${p.name} (${p.entityType}, id:${p.entityId}) [${p.relationType}]`);f.length>15&&u.push(` ...and ${f.length-15} more`)}if(s.length){u.push(`
59
+ Key facts (${s.length}):`);for(let p of s){let d=re(p.content,wt);u.push(`- [${p.category}] ${d} _(${p.confidence}, id:${p.id})_`)}}return!c.length&&!f.length&&!s.length&&u.push(`
60
+ No connections or facts found for this entity.`),u.push(`
61
+ _Use traverse_graph(startEntityId=${a.id}) for deeper graph exploration._`),w(u.join(`
62
+ `))})}U();function Fa(t){t.tool("status",`Show Sigil knowledge base statistics \u2014 documents, chunks, facts, entities, relations.
63
+ Use when: checking system health, verifying ingestion, reviewing knowledge graph size.`,{namespace:h.string().optional().describe("Filter by namespace. Omit for global stats.")},async({namespace:e})=>{let r=await $("status",{namespace:e,hotFactsLimit:5}),o=[`Sigil KB${r.namespace?` (${r.namespace})`:""}: ${r.documents} docs, ${r.chunks} chunks, ${r.facts} facts`,`Entities: ${r.entities.documents} documents, ${r.entities.people} people, ${r.entities.topics} topics`,`Relations: ${r.relations}`,`Hot facts (top ${r.hotFacts.length}): ${r.hotFacts.map(a=>`${re(a.content,60)} (${a.accessCount}x)`).join(", ")||"none yet"}`].join(`
64
+ `);return w(o)})}U();var Qd=600*1e3;function Va(t){t.tool("ingest",`Ingest a document into the Sigil knowledge base. Accepts raw content, a file path, or a URL.
65
+ Durably queues the content, then chunks, embeds, and extracts facts in the background; entity/relation enrichment follows after the document becomes searchable.
66
+ Use when: adding documents to the knowledge base, ingesting files, URLs, or raw text.`,{content:h.string().optional().describe("Raw text content to ingest. Provide this OR filePath OR url."),filePath:h.string().optional().describe("Local file path to ingest. Provide this OR content OR url."),url:h.string().optional().describe("URL to fetch and ingest. Provide this OR content OR filePath."),title:h.string().optional().describe("Document title. Auto-detected if not provided."),namespace:h.string().optional().describe("Namespace for the document. Defaults to config default."),sourceType:h.string().optional().describe("Source type label (e.g., docs, code, notes). Auto-detected from format."),cwd:h.string().optional().describe("Working directory \u2014 attaches the document to that project's pod so it is findable from that project later. Pass the project you are working in."),skipFacts:h.boolean().optional().default(!1).describe("Skip fact extraction (faster, chunks only)"),skipEntities:h.boolean().optional().default(!1).describe("Skip entity linking"),wait:h.boolean().optional().default(!1).describe("Wait for searchable chunks/facts instead of returning a durable job acknowledgement immediately.")},async({content:e,filePath:r,url:n,title:o,namespace:a,sourceType:i,cwd:s,skipFacts:u,skipEntities:c,wait:f})=>{let p={content:e,filePath:r,url:n};if(r){let{readSource:A}=await Promise.resolve().then(()=>(Za(),Ha)),{resolve:O}=await import("node:path"),S=await A(O(s||process.cwd(),r));p={content:S.content,sourcePath:S.sourcePath},o=o||S.title,i=i||S.sourceType}let d=await $("ingestDoc",{...p,title:o,namespace:a,sourceType:i,cwd:s,skipFacts:u,skipEntities:c,background:!f},{timeoutMs:Qd});if(d.queued)return w([`Document "${d.title||o||"Untitled"}" durably queued.`,`- Job: ${d.jobUid}`,"- Source bytes are staged; processing resumes automatically after daemon restarts.","- Check `sigil status` for queued/running/failed ingestion counts."].join(`
67
+ `));let _=d.skipped?`Document "${d.title}" already up to date \u2014 skipped.`:[`Document "${d.title}" ingested.`,`- Document ID: ${d.documentUid||d.documentId} (read it back with get_document)`,d.pods?.length?`- Pods: ${d.pods.join(", ")}`:null,`- Chunks: ${d.chunkCount}`,d.facts?`- Facts: ${d.facts.total} extracted (${d.facts.added} new, ${d.facts.skipped} skipped)`:"- Facts: skipped",d.entities?.queued?`- Graph enrichment: queued (${d.entities.jobUid})`:d.entities?`- Entities: ${d.entities.entityCount}, Relations: ${d.entities.relationCount}`:"- Entities: skipped",d.output?`- Output: ${d.output}`:""].filter(Boolean).join(`
68
+ `);return w(_)})}U();var ep=600*1e3;function Wa(t){t.tool("remember",`Save one or more standalone facts to the Sigil knowledge base.
71
69
  Each fact is classified, embedded, deduped against existing memory, and stored.
72
70
  Use when: the user states a durable preference, decision, constraint, or factual claim worth recalling later.
73
71
  Pass each distinct fact as its own array element \u2014 don't concatenate unrelated facts into one string.
74
- Facts are written under the agent provenance "mcp" and survive across sessions.`,{facts:g.array(g.string()).min(1).describe("One or more self-contained facts to remember. Each element is a separate fact."),namespace:g.string().optional().describe("Target namespace. Defaults to the config default namespace.")},async({facts:e,namespace:r})=>{let n=await L("remember",{facts:e,namespace:r}),o=[];n.added&&o.push(`${n.added} new`),n.updated&&o.push(`${n.updated} updated`),n.alreadyKnown&&o.push(`${n.alreadyKnown} already known`);let a=o.length?o.join(", "):"nothing stored";return E(`Remembered ${e.length} input${e.length===1?"":"s"} \u2192 ${a} (namespace: ${n.namespace}).`)})}H();function Da(t){t.tool("list_pods",`List memory pods (typed containers segregating facts by source or subject).
72
+ Facts are written under the agent provenance "mcp" and survive across sessions.
73
+ Pass cwd so the fact attaches to that project and resurfaces there; pass pod when the fact is ABOUT a different project than the one you're in.`,{facts:h.array(h.string()).min(1).describe("One or more self-contained facts to remember. Each element is a separate fact."),namespace:h.string().optional().describe("Target namespace. Defaults to the config default namespace."),cwd:h.string().optional().describe("Working directory \u2014 attaches the facts to that project's pod so they resurface there. Pass the project you are working in."),pod:h.string().optional().describe("Attach to this pod (name or uid) INSTEAD of the one derived from cwd. Use when the fact is about a different project than the one you are working in.")},async({facts:e,namespace:r,cwd:n,pod:o})=>{let a=await $("remember",{facts:e,namespace:r,cwd:n,pod:o},{timeoutMs:ep}),i=[];a.added&&i.push(`${a.added} new`),a.updated&&i.push(`${a.updated} updated`),a.alreadyKnown&&i.push(`${a.alreadyKnown} already known`);let s=i.length?i.join(", "):"nothing stored";return w(`Remembered ${e.length} input${e.length===1?"":"s"} \u2192 ${s} (namespace: ${a.namespace}).`)})}U();function Ka(t){t.tool("list_pods",`List memory pods (typed containers segregating facts by source or subject).
75
74
  Use for: "what sessions do I have?", "list everyone I have a pod for", "which workspaces?".
76
75
  Pod types: session (Claude Code), person (people you have a relationship with),
77
- project, connector_workspace, custom.`,{type:g.enum(["session","person","project","connector_workspace","custom"]).optional().describe("Filter by pod type. Omit for all types."),namespace:g.string().optional().describe("Namespace. Omit for default."),status:g.enum(["active","archived"]).optional().default("active"),limit:g.number().int().positive().max(100).optional().default(20)},async({type:e,namespace:r,status:n,limit:o})=>{let{pods:a}=await L("listPods",{type:e,namespace:r,status:n,limit:o});if(!a.length){let s=e?` of type "${e}"`:"";return E(`No${s} pods found.`)}let i=[`Found ${a.length} pod${a.length===1?"":"s"}:`,""];for(let s of a){let c=s.memberFactCount??0,u=s.memberDocCount??0,l=s.updatedAt?new Date(s.updatedAt).toISOString().slice(0,16).replace("T"," "):"\u2014";i.push(`- **${s.name}** (${s.podType}, uid:${s.uid})`),i.push(` facts=${c} docs=${u} updated=${l}`)}return i.push(""),i.push("_Use get_pod(uid=...) for member facts and full metadata._"),E(i.join(`
78
- `))})}H();function ja(t){t.tool("get_pod",`Get a memory pod with its member facts, documents, and (for person pods)
76
+ project, connector_workspace, custom.`,{type:h.enum(["session","person","project","connector_workspace","custom"]).optional().describe("Filter by pod type. Omit for all types."),namespace:h.string().optional().describe("Namespace. Omit for default."),status:h.enum(["active","archived"]).optional().default("active"),limit:h.number().int().positive().max(100).optional().default(20)},async({type:e,namespace:r,status:n,limit:o})=>{let{pods:a}=await $("listPods",{type:e,namespace:r,status:n,limit:o});if(!a.length){let s=e?` of type "${e}"`:"";return w(`No${s} pods found.`)}let i=[`Found ${a.length} pod${a.length===1?"":"s"}:`,""];for(let s of a){let u=s.memberFactCount??0,c=s.memberDocCount??0,f=s.updatedAt?new Date(s.updatedAt).toISOString().slice(0,16).replace("T"," "):"\u2014";i.push(`- **${s.name}** (${s.podType}, uid:${s.uid})`),i.push(` facts=${u} docs=${c} updated=${f}`)}return i.push(""),i.push("_Use get_pod(uid=...) for member facts and full metadata._"),w(i.join(`
77
+ `))})}U();function qa(t){t.tool("get_pod",`Get a memory pod with its member facts, documents, and (for person pods)
79
78
  the canonical entity link.
80
79
  Use for: "what happened in this session?", "show me everything sigil knows
81
80
  about Dhaval", "what's in the Slack workspace pod?".
82
- Returns pod metadata + up to 20 latest facts + up to 10 latest documents.`,{uid:g.string().describe("Pod uid (from list_pods or sigil session current)")},async({uid:e})=>{let r=await L("getPod",{uid:e});if(r.notFound)return E(`Error: pod ${e} not found.`);let{pod:n,facts:o,documents:a}=r,i=[`**${n.name}** (${n.podType}, uid:${n.uid})`,"",`- namespace: ${n.namespace}`,`- status: ${n.status}`];n.startedAt&&i.push(`- started_at: ${n.startedAt}`),n.endedAt&&i.push(`- ended_at: ${n.endedAt}`),n.entityId&&i.push(`- entity_id: ${n.entityId}`),n.connectionId&&i.push(`- connection_id: ${n.connectionId}`),n.externalId&&i.push(`- external_id: ${n.externalId}`);let s=Object.entries(n.attrs||{}).filter(([,c])=>c!=null&&c!=="");if(s.length){i.push("","Attrs:");for(let[c,u]of s){let l=typeof u=="object"?JSON.stringify(u):u;i.push(`- ${c}: ${l}`)}}if(o.length){i.push("",`Member facts (${o.length}, up to 20):`);for(let c of o){let u=te(c.content,Tt),l=c.podRole==="mention"?" _[mention]_":"";i.push(`- ${u} (id:${c.id})${l}`)}}if(a.length){i.push("",`Member documents (${a.length}, up to 10):`);for(let c of a){let u=c.title||c.sourcePath||`doc-${c.id}`;i.push(`- ${te(u,80)} (id:${c.id})`)}}return!o.length&&!a.length&&i.push("","_Pod has no member facts or documents yet._"),E(i.join(`
83
- `))})}H();function Va(t){t.tool("prime","Prime your memory for this session \u2014 CALL THIS FIRST, before answering anything.\nThis client has no automatic memory: nothing is recalled or saved for you.\nReturns: Sigil health (DB/providers) + fresh facts about the user and this project.\nIf you skip it, you start with zero knowledge of who the user is or what they're working on.\nAfter priming, still call `search` for specifics and `ingest` to save durable facts.",{limit:g.number().optional().default(12).describe("Max fresh facts to load (default 12)")},async({limit:e}={})=>{let{buildPreamble:r}=await Promise.resolve().then(()=>(Ua(),Ba)),{renderPreamble:n}=await Promise.resolve().then(()=>(za(),Ha)),o=await r({cwd:process.cwd(),limit:Number.isFinite(e)?e:12,call:L});return E(n(o,{format:"md",transport:"mcp"}))})}function Za(){let t=new Dd({name:"sigil",version:"0.2.0"});return Va(t),ka(t),Ra(t),La(t),Ca(t),Na(t),ja(t),Da(t),Pa(t),$a(t),Ma(t),t}process.env.SIGIL_AGENT||(process.env.SIGIL_AGENT="mcp");async function Ka(){let t=Za(),e=new jd;await t.connect(e);let{closeDaemonConnection:r}=await Promise.resolve().then(()=>(H(),Aa)),n=()=>{r().catch(()=>{})};return process.on("SIGTERM",n),process.on("SIGINT",n),process.on("beforeExit",n),t}var Fd=Wa(Wa(Bd(import.meta.url))),Hd=process.env.DOTENV_CONFIG_PATH||(Ud(Mr(process.cwd(),".env"))?Mr(process.cwd(),".env"):null)||Mr(Fd,".env");Gd({path:Hd,quiet:!0});await Ka();
81
+ Returns pod metadata + up to 20 latest facts + up to 10 latest documents.`,{uid:h.string().describe("Pod uid (from list_pods or sigil session current)")},async({uid:e})=>{let r=await $("getPod",{uid:e});if(r.notFound)return w(`Error: pod ${e} not found.`);let{pod:n,facts:o,documents:a}=r,i=[`**${n.name}** (${n.podType}, uid:${n.uid})`,"",`- namespace: ${n.namespace}`,`- status: ${n.status}`];n.startedAt&&i.push(`- started_at: ${n.startedAt}`),n.endedAt&&i.push(`- ended_at: ${n.endedAt}`),n.entityId&&i.push(`- entity_id: ${n.entityId}`),n.connectionId&&i.push(`- connection_id: ${n.connectionId}`),n.externalId&&i.push(`- external_id: ${n.externalId}`);let s=Object.entries(n.attrs||{}).filter(([,u])=>u!=null&&u!=="");if(s.length){i.push("","Attrs:");for(let[u,c]of s){let f=typeof c=="object"?JSON.stringify(c):c;i.push(`- ${u}: ${f}`)}}if(o.length){i.push("",`Member facts (${o.length}, up to 20):`);for(let u of o){let c=re(u.content,wt),f=u.podRole==="mention"?" _[mention]_":"";i.push(`- ${c} (id:${u.id})${f}`)}}if(a.length){i.push("",`Member documents (${a.length}, up to 10):`);for(let u of a){let c=u.title||u.sourcePath||`doc-${u.id}`;i.push(`- ${re(c,80)} (id:${u.id})`)}}return!o.length&&!a.length&&i.push("","_Pod has no member facts or documents yet._"),w(i.join(`
82
+ `))})}U();function Ja(t){t.tool("list_documents",`List whole documents stored in Sigil, scoped to the current project by default.
83
+ Returns titles and uids only \u2014 call get_document to read one.
84
+ Use when: the user asks what documents/notes/specs are saved, or you need to find the right document before reading it.`,{cwd:h.string().optional().describe("Working directory \u2014 scopes to that project's pod. Pass the project you are working in."),podScope:h.union([h.literal("auto"),h.literal("global"),h.array(h.string())]).optional().describe("'auto' (default) = this project/session. 'global' = every document. Or an explicit list of pod uids/names."),sourceType:h.string().optional().describe("Filter by source type (e.g. docs, notes, code)."),limit:h.number().optional().describe("Max documents to return (default 50).")},async({cwd:e,podScope:r,sourceType:n,limit:o})=>{let a=await $("listDocuments",{cwd:e,podScope:r,sourceType:n,limit:o});if(!a.documents.length)return w(a.scoped?"No documents stored for this project yet. Ingest one with the `ingest` tool.":"No documents stored yet. Ingest one with the `ingest` tool.");let i=a.documents.map(s=>`- ${s.title} [${s.uid}] ${s.sourceType} \xB7 ${s.chunkCount} chunks, ${s.factCount} facts`);return w([`${a.documents.length} document${a.documents.length===1?"":"s"}${a.scoped?" in this project":""}:`,...i,"","Read one with get_document(uid)."].join(`
85
+ `))}),t.tool("get_document",`Read a stored document IN FULL by its uid (from list_documents or a search result's source document).
86
+ Use when: you need the complete text of a spec, note, session history, or file \u2014 not just the facts extracted from it.`,{uid:h.string().describe("Document uid, e.g. doc-a1b2c3... \u2014 from list_documents or a search result."),maxChars:h.number().optional().describe("Truncate the returned text at this many characters (default 40000).")},async({uid:e,maxChars:r})=>{let n=await $("getDocument",{uid:e,maxChars:r});if(n.notFound)return w(`No document with uid "${e}". Run list_documents to see what is stored.`);let o=[`# ${n.title}`,`uid: ${n.uid} \xB7 ${n.sourceType} \xB7 ${n.chunkCount} chunks`,n.pods?.length?`pods: ${n.pods.map(a=>a.name||a.uid).join(", ")}`:null,n.exact?null:"note: reassembled from chunks (ingested before full text was stored) \u2014 re-ingest for exact text",n.truncated?`note: truncated at ${n.content.length} of ${n.totalChars} chars`:null].filter(Boolean).join(`
87
+ `);return w(`${o}
88
+
89
+ ---
90
+
91
+ ${n.content}`)})}U();function ns(t){t.tool("prime","Prime your memory for this session \u2014 CALL THIS FIRST, before answering anything.\nThis client has no automatic memory: nothing is recalled or saved for you.\nReturns: Sigil health (DB/providers) + fresh facts about the user and this project.\nIf you skip it, you start with zero knowledge of who the user is or what they're working on.\nAfter priming, still call `search` for specifics and `ingest` to save durable facts.",{limit:h.number().optional().default(12).describe("Max fresh facts to load (default 12)")},async({limit:e}={})=>{let{buildPreamble:r}=await Promise.resolve().then(()=>(Qa(),Xa)),{renderPreamble:n}=await Promise.resolve().then(()=>(rs(),ts)),o=await r({cwd:process.cwd(),limit:Number.isFinite(e)?e:12,call:$});return w(n(o,{format:"md",transport:"mcp"}))})}function os(){let t=new ap({name:"sigil",version:"0.2.0"});return ns(t),Na(t),Da(t),ja(t),Ga(t),Ba(t),qa(t),Ka(t),Ja(t),Fa(t),Va(t),Wa(t),t}process.env.SIGIL_AGENT||(process.env.SIGIL_AGENT="mcp");async function as(){let t=os(),e=new sp;await t.connect(e);let{closeDaemonConnection:r}=await Promise.resolve().then(()=>(U(),La)),n=()=>{r().catch(()=>{})};return process.on("SIGTERM",n),process.on("SIGINT",n),process.on("beforeExit",n),t}await as();