deepv-code 1.0.267 → 1.0.268
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/dvcode.js +3 -3
- package/package.json +1 -1
package/bundle/dvcode.js
CHANGED
|
@@ -510,7 +510,7 @@ ${h}`)}return e}),Xne=Iwn(xat);$ne=class extends qne{create(t,r){var a;let{api_v
|
|
|
510
510
|
`):[]}};LH.NEWLINE_CHARS=new Set([`
|
|
511
511
|
`,"\r"]);LH.NEWLINE_REGEXP=/\r\n|[\n\r]/g;tre={off:0,error:200,warn:300,info:400,debug:500},Aat=(n,t,r)=>{if(n){if(MEn(tre,n))return n;Om(r).warn(`${t} was set to ${JSON.stringify(n)}, expected one of ${JSON.stringify(Object.keys(tre))}`)}};mwn={error:$D,warn:$D,info:$D,debug:$D},Fat=new WeakMap;xw=n=>(n.options&&(n.options=Object.assign({},n.options),delete n.options.headers),n.headers&&(n.headers=Object.fromEntries((n.headers instanceof Headers?[...n.headers]:Object.entries(n.headers)).map(([t,r])=>[t,t.toLowerCase()==="x-goog-api-key"||t.toLowerCase()==="authorization"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":r]))),"retryOfRequestLogID"in n&&(n.retryOfRequestLogID&&(n.retryOf=n.retryOfRequestLogID),delete n.retryOfRequestLogID),n);q3e=class n{constructor(t,r,a){this.iterator=t,this.controller=r,this.client=a}static fromSSEResponse(t,r,a){let i=!1,s=a?Om(a):console;function e(){return QH(this,arguments,function*(){var u,d,I,h;if(i)throw new l2("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let o=!1;try{try{for(var f=!0,E=Vw(pwn(t,r)),F;F=yield ic(E.next()),u=F.done,!u;f=!0){h=F.value,f=!1;let w=h;if(!o)if(w.data.startsWith("[DONE]")){o=!0;continue}else try{yield yield ic(JSON.parse(w.data))}catch(A){throw s.error("Could not parse message into JSON:",w.data),s.error("From chunk:",w.raw),A}}}catch(w){d={error:w}}finally{try{!f&&!u&&(I=E.return)&&(yield ic(I.call(E)))}finally{if(d)throw d.error}}o=!0}catch(w){if(_3e(w))return yield ic(void 0);throw w}finally{o||r.abort()}})}return new n(e,r,a)}static fromReadableStream(t,r,a){let i=!1;function s(){return QH(this,arguments,function*(){var u,d,I,h;let o=new LH,f=wat(t);try{for(var E=!0,F=Vw(f),w;w=yield ic(F.next()),u=w.done,!u;E=!0){h=w.value,E=!1;let A=h;for(let C of o.decode(A))yield yield ic(C)}}catch(A){d={error:A}}finally{try{!E&&!u&&(I=F.return)&&(yield ic(I.call(F)))}finally{if(d)throw d.error}}for(let A of o.flush())yield yield ic(A)})}function e(){return QH(this,arguments,function*(){var u,d,I,h;if(i)throw new l2("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let o=!1;try{try{for(var f=!0,E=Vw(s()),F;F=yield ic(E.next()),u=F.done,!u;f=!0){h=F.value,f=!1;let w=h;o||w&&(yield yield ic(JSON.parse(w)))}}catch(w){d={error:w}}finally{try{!f&&!u&&(I=E.return)&&(yield ic(I.call(E)))}finally{if(d)throw d.error}}o=!0}catch(w){if(_3e(w))return yield ic(void 0);throw w}finally{o||r.abort()}})}return new n(e,r,a)}[Symbol.asyncIterator](){return this.iterator()}tee(){let t=[],r=[],a=this.iterator(),i=s=>({next:()=>{if(s.length===0){let e=a.next();t.push(e),r.push(e)}return s.shift()}});return[new n(()=>i(t),this.controller,this.client),new n(()=>i(r),this.controller,this.client)]}toReadableStream(){let t=this,r;return Eat({async start(){r=t[Symbol.asyncIterator]()},async pull(a){try{let{value:i,done:s}=await r.next();if(s)return a.close();let e=nNe(JSON.stringify(i)+`
|
|
512
512
|
`);a.enqueue(e)}catch(i){a.error(i)}},async cancel(){var a;await((a=r.return)===null||a===void 0?void 0:a.call(r))}})}};$3e=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;let s={event:this.event,data:this.data.join(`
|
|
513
|
-
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],s}if(this.chunks.push(t),t.startsWith(":"))return null;let[r,a,i]=Gwn(t,":");return i.startsWith(" ")&&(i=i.substring(1)),r==="event"?this.event=i:r==="data"&&this.data.push(i),null}};eNe=class n extends Promise{constructor(t,r,a=fwn){super(i=>{i(null)}),this.responsePromise=r,this.parseResponse=a,this.client=t}_thenUnwrap(t){return new n(this.client,this.responsePromise,async(r,a)=>t(await this.parseResponse(r,a),a))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){let[t,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:r}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(this.client,t))),this.parsedPromise}then(t,r){return this.parse().then(t,r)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};Vat=Symbol("brand.privateNullableHeaders");qD=n=>{let t=new Headers,r=new Set;for(let a of n){let i=new Set;for(let[s,e]of gwn(a)){let c=s.toLowerCase();i.has(c)||(t.delete(s),i.add(c)),e===null?(t.delete(s),r.add(c)):(t.append(s,e),r.delete(c))}}return{[Vat]:!0,values:t,nulls:r}};z3e=n=>{var t,r,a,i,s,e;if(typeof globalThis.process<"u")return(a=(r=(t=globalThis.process.env)===null||t===void 0?void 0:t[n])===null||r===void 0?void 0:r.trim())!==null&&a!==void 0?a:void 0;if(typeof globalThis.Deno<"u")return(e=(s=(i=globalThis.Deno.env)===null||i===void 0?void 0:i.get)===null||s===void 0?void 0:s.call(i,n))===null||e===void 0?void 0:e.trim()};nre=class n{constructor(t){var r,a,i,s,e,c,u,{baseURL:d=z3e("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:I=(r=z3e("GEMINI_API_KEY"))!==null&&r!==void 0?r:null,apiVersion:h="v1beta"}=t,o=Bne(t,["baseURL","apiKey","apiVersion"]);let f=Object.assign(Object.assign({apiKey:I,apiVersion:h},o),{baseURL:d||"https://generativelanguage.googleapis.com"});this.baseURL=f.baseURL,this.timeout=(a=f.timeout)!==null&&a!==void 0?a:n.DEFAULT_TIMEOUT,this.logger=(i=f.logger)!==null&&i!==void 0?i:console;let E="warn";this.logLevel=E,this.logLevel=(e=(s=Aat(f.logLevel,"ClientOptions.logLevel",this))!==null&&s!==void 0?s:Aat(z3e("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&e!==void 0?e:E,this.fetchOptions=f.fetchOptions,this.maxRetries=(c=f.maxRetries)!==null&&c!==void 0?c:2,this.fetch=(u=f.fetch)!==null&&u!==void 0?u:ewn(),this.encoder=rwn,this._options=f,this.apiKey=I,this.apiVersion=h,this.clientAdapter=f.clientAdapter}withOptions(t){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),t))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:r}){if(!(t.has("authorization")||t.has("x-goog-api-key"))&&!(this.apiKey&&t.get("x-goog-api-key"))&&!r.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(t){let r=qD([t.headers]);if(!(r.values.has("authorization")||r.values.has("x-goog-api-key"))){if(this.apiKey)return qD([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return qD([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(t){return Object.entries(t).filter(([r,a])=>typeof a<"u").map(([r,a])=>{if(typeof a=="string"||typeof a=="number"||typeof a=="boolean")return`${encodeURIComponent(r)}=${encodeURIComponent(a)}`;if(a===null)return`${encodeURIComponent(r)}=`;throw new l2(`Cannot stringify type ${typeof a}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${VH}`}defaultIdempotencyKey(){return`stainless-node-retry-${SEn()}`}makeStatusError(t,r,a,i){return s2.generate(t,r,a,i)}buildURL(t,r,a){let i=!this.baseURLOverridden()&&a||this.baseURL,s=DEn(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),e=this.defaultQuery();return UEn(e)||(r=Object.assign(Object.assign({},e),r)),typeof r=="object"&&r&&!Array.isArray(r)&&(s.search=this.stringifyQuery(r)),s.toString()}async prepareOptions(t){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!t.path.startsWith(`/${this.apiVersion}/projects/`)){let r=t.path.slice(this.apiVersion.length+1);t.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${r}`}}async prepareRequest(t,{url:r,options:a}){}get(t,r){return this.methodRequest("get",t,r)}post(t,r){return this.methodRequest("post",t,r)}patch(t,r){return this.methodRequest("patch",t,r)}put(t,r){return this.methodRequest("put",t,r)}delete(t,r){return this.methodRequest("delete",t,r)}methodRequest(t,r,a){return this.request(Promise.resolve(a).then(i=>Object.assign({method:t,path:r},i)))}request(t,r=null){return new eNe(this,this.makeRequest(t,r,void 0))}async makeRequest(t,r,a){var i,s,e;let c=await t,u=(i=c.maxRetries)!==null&&i!==void 0?i:this.maxRetries;r==null&&(r=u),await this.prepareOptions(c);let{req:d,url:I,timeout:h}=await this.buildRequest(c,{retryCount:u-r});await this.prepareRequest(d,{url:I,options:c});let o="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),f=a===void 0?"":`, retryOf: ${a}`,E=Date.now();if(Om(this).debug(`[${o}] sending request`,xw({retryOfRequestLogID:a,method:c.method,url:I,options:c,headers:d.headers})),!((s=c.signal)===null||s===void 0)&&s.aborted)throw new eT;let F=new AbortController,w=await this.fetchWithTimeout(I,d,h,F).catch(P3e),A=Date.now();if(w instanceof globalThis.Error){let W=`retrying, ${r} attempts remaining`;if(!((e=c.signal)===null||e===void 0)&&e.aborted)throw new eT;let y=_3e(w)||/timed? ?out/i.test(String(w)+("cause"in w?String(w.cause):""));if(r)return Om(this).info(`[${o}] connection ${y?"timed out":"failed"} - ${W}`),Om(this).debug(`[${o}] connection ${y?"timed out":"failed"} (${W})`,xw({retryOfRequestLogID:a,url:I,durationMs:A-E,message:w.message})),this.retryRequest(c,r,a??o);throw Om(this).info(`[${o}] connection ${y?"timed out":"failed"} - error; no more retries left`),Om(this).debug(`[${o}] connection ${y?"timed out":"failed"} (error; no more retries left)`,xw({retryOfRequestLogID:a,url:I,durationMs:A-E,message:w.message})),y?new Tne:new kH({cause:w})}let C=`[${o}${f}] ${d.method} ${I} ${w.ok?"succeeded":"failed"} with status ${w.status} in ${A-E}ms`;if(!w.ok){let W=await this.shouldRetry(w);if(r&&W){let m=`retrying, ${r} attempts remaining`;return await nwn(w.body),Om(this).info(`${C} - ${m}`),Om(this).debug(`[${o}] response error (${m})`,xw({retryOfRequestLogID:a,url:w.url,status:w.status,headers:w.headers,durationMs:A-E})),this.retryRequest(c,r,a??o,w.headers)}let y=W?"error; no more retries left":"error; not retryable";Om(this).info(`${C} - ${y}`);let b=await w.text().catch(m=>P3e(m).message),g=_En(b),v=g?void 0:b;throw Om(this).debug(`[${o}] response error (${y})`,xw({retryOfRequestLogID:a,url:w.url,status:w.status,headers:w.headers,message:v,durationMs:Date.now()-E})),this.makeStatusError(w.status,g,v,w.headers)}return Om(this).info(C),Om(this).debug(`[${o}] response start`,xw({retryOfRequestLogID:a,url:w.url,status:w.status,headers:w.headers,durationMs:A-E})),{response:w,options:c,controller:F,requestLogID:o,retryOfRequestLogID:a,startTime:E}}async fetchWithTimeout(t,r,a,i){let s=r||{},{signal:e,method:c}=s,u=Bne(s,["signal","method"]);e&&e.addEventListener("abort",()=>i.abort());let d=setTimeout(()=>i.abort(),a),I=globalThis.ReadableStream&&u.body instanceof globalThis.ReadableStream||typeof u.body=="object"&&u.body!==null&&Symbol.asyncIterator in u.body,h=Object.assign(Object.assign(Object.assign({signal:i.signal},I?{duplex:"half"}:{}),{method:"GET"}),u);c&&(h.method=c.toUpperCase());try{return await this.fetch.call(void 0,t,h)}finally{clearTimeout(d)}}async shouldRetry(t){let r=t.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,r,a,i){var s;let e,c=i?.get("retry-after-ms");if(c){let d=parseFloat(c);Number.isNaN(d)||(e=d)}let u=i?.get("retry-after");if(u&&!e){let d=parseFloat(u);Number.isNaN(d)?e=Date.parse(u)-Date.now():e=d*1e3}if(!(e&&0<=e&&e<60*1e3)){let d=(s=t.maxRetries)!==null&&s!==void 0?s:this.maxRetries;e=this.calculateDefaultRetryTimeoutMillis(r,d)}return await PEn(e),this.makeRequest(t,r-1,a)}calculateDefaultRetryTimeoutMillis(t,r){let s=r-t,e=Math.min(.5*Math.pow(2,s),8),c=1-Math.random()*.25;return e*c*1e3}async buildRequest(t,{retryCount:r=0}={}){var a,i,s;let e=Object.assign({},t),{method:c,path:u,query:d,defaultBaseURL:I}=e,h=this.buildURL(u,d,I);"timeout"in e&&zEn("timeout",e.timeout),e.timeout=(a=e.timeout)!==null&&a!==void 0?a:this.timeout;let{bodyHeaders:o,body:f}=this.buildBody({options:e}),E=await this.buildHeaders({options:t,method:c,bodyHeaders:o,retryCount:r});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:c,headers:E},e.signal&&{signal:e.signal}),globalThis.ReadableStream&&f instanceof globalThis.ReadableStream&&{duplex:"half"}),f&&{body:f}),(i=this.fetchOptions)!==null&&i!==void 0?i:{}),(s=e.fetchOptions)!==null&&s!==void 0?s:{}),url:h,timeout:e.timeout}}async buildHeaders({options:t,method:r,bodyHeaders:a,retryCount:i}){let s={};this.idempotencyHeader&&r!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=t.idempotencyKey);let e=await this.authHeaders(t),c=qD([s,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i)},t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{}),$En()),this._options.defaultHeaders,a,t.headers,e]);return this.validateHeaders(c),c.values}buildBody({options:{body:t,headers:r}}){if(!t)return{bodyHeaders:void 0,body:void 0};let a=qD([r]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&a.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:twn(t)}:this.encoder({body:t,headers:a})}};nre.DEFAULT_TIMEOUT=6e4;rd=class extends nre{constructor(){super(...arguments),this.interactions=new ere(this)}};Qat=rd;rd.GeminiNextGenAPIClient=Qat;rd.GeminiNextGenAPIClientError=l2;rd.APIError=s2;rd.APIConnectionError=kH;rd.APIConnectionTimeoutError=Tne;rd.APIUserAbortError=eT;rd.NotFoundError=zne;rd.ConflictError=_ne;rd.RateLimitError=jne;rd.BadRequestError=One;rd.AuthenticationError=Une;rd.InternalServerError=Kne;rd.PermissionDeniedError=Mne;rd.UnprocessableEntityError=Pne;rd.toFile=own;rd.Interactions=ere;Boa=1024*1024*8;});function vwn(n,t){return{...n,...t}}function Hat(n){let{prompt_id:t,...r}=n;return r}function Qw(n){return Array.isArray(n)?n.map(Hat):n}var rre=ct(()=>{"use strict";hi();});var Xat={};so(Xat,{DEFAULT_PROXY_CONFIG:()=>Wwn,getActiveProxyServerUrl:()=>G3,getAvailableProxyServers:()=>Zwn,getProxyServerInfo:()=>Nwn,getProxyServers:()=>tT,hasAvailableProxyServer:()=>rNe});function tT(){return[{url:"https://api-code.deepvlab.ai",name:"Primary Development Server",region:"default",status:"active"}]}function G3(){let t=tT().find(r=>r.status==="active");if(!t)throw new Error("No active proxy server available. Please contact support.");return t.url}function Zwn(){return tT().filter(t=>t.status==="active")}function rNe(){return tT().some(t=>t.status==="active")}function Nwn(n){return tT().find(r=>r.url===n)}var Wwn,JH=ct(()=>{"use strict";Wwn={serverUrl:G3(),timeout:2e5,retryAttempts:3,retryDelay:1e3}});import*as To from"fs";import*as Pg from"path";import*as Hw from"os";function Awn(n){ms.configure(n)}function Fwn(n){ms.setUserInfo(n)}function ywn(n){ms.setCliVersion(n)}async function Rwn(){return await ms.getUserHeaders()}function Ewn(){return ms.getStatus()}var nT,Xs,ms,gy=ct(()=>{"use strict";JH();nT=259200,Xs=class n{static instance=null;config;userInfo=null;jwtTokenData=null;usageStats={totalCreditsConsumed:0,lastUpdated:new Date().toISOString()};userInfoFilePath;jwtTokenFilePath;usageStatsFilePath;refreshPromise=null;cliVersion="unknown";periodicStatusCheckIntervalId=null;getCliVersion(){return this.cliVersion}getUserAgent(){let t=this.cliVersion,r=process.platform,a=process.arch;return t.startsWith("VSCode-")?`DeepVCode/VSCode/${t.replace("VSCode-","")} (${r}; ${a})`:`DeepVCode/CLI/${t} (${r}; ${a})`}formatTimeRemaining(t){if(t<=0)return"\u5DF2\u8FC7\u671F";let r=Math.floor(t/1e3),a=Math.floor(r/(24*3600)),i=Math.floor(r%(24*3600)/3600),s=Math.floor(r%3600/60),e=r%60;return a>0?`${a}\u5929${i}\u5C0F\u65F6${s}\u5206\u949F`:i>0?`${i}\u5C0F\u65F6${s}\u5206\u949F${e}\u79D2`:s>0?`${s}\u5206\u949F${e}\u79D2`:`${e}\u79D2`}formatAbsoluteTime(t){return new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}constructor(){"https://api-code.deepvlab.ai"?.includes("localhost")?(this.userInfoFilePath=Pg.join(Hw.homedir(),".deepv","user-info-dev.json"),this.jwtTokenFilePath=Pg.join(Hw.homedir(),".deepv","jwt-token-dev.json"),this.usageStatsFilePath=Pg.join(Hw.homedir(),".deepv","usage-stats-dev.json")):(this.userInfoFilePath=Pg.join(Hw.homedir(),".deepv","user-info.json"),this.jwtTokenFilePath=Pg.join(Hw.homedir(),".deepv","jwt-token.json"),this.usageStatsFilePath=Pg.join(Hw.homedir(),".deepv","usage-stats.json")),this.cliVersion="1.0.267",this.config={proxyServerUrl:G3()},this.loadUserInfo(),this.loadJwtToken(),this.loadUsageStats(),this.startPeriodicStatusCheck()}startPeriodicStatusCheck(){this.periodicStatusCheckIntervalId=setInterval(()=>{if(this.jwtTokenData){let t=Date.now(),r=this.jwtTokenData.expiresAt-t,a=this.formatTimeRemaining(r),i=this.formatAbsoluteTime(this.jwtTokenData.expiresAt);if(r>0){let s=this.formatAbsoluteTime(this.jwtTokenData.expiresAt-nT*1e3);console.log(`[Login Check] \u{1F4CA} Periodic status check - Credential remaining: ${a} (until ${i}), next renewal: ${s}`)}else console.log(`[Login Check] \u26A0\uFE0F Periodic status check - Credential expired at: ${i}`)}},600*1e3)}static getInstance(){return n.instance||(n.instance=new n),n.instance}loadUserInfo(){try{if(To.existsSync(this.userInfoFilePath)){let t=To.readFileSync(this.userInfoFilePath,"utf8");this.userInfo=JSON.parse(t);let r=a=>{if(!a||!a.includes("@"))return a;let[i,s]=a.split("@");return i.length<=2?a:`${i[0]+"*".repeat(i.length-2)+i[i.length-1]}@${s}`}}}catch(t){console.warn("[Login Check] Failed to load user info from local file:",t),this.userInfo=null}}saveUserInfo(){try{let t=Pg.dirname(this.userInfoFilePath);To.existsSync(t)||To.mkdirSync(t,{recursive:!0}),To.writeFileSync(this.userInfoFilePath,JSON.stringify(this.userInfo,null,2)),console.log("[Login Check] User info saved to local file")}catch(t){console.error("[Login Check] Failed to save user info:",t)}}loadJwtToken(){try{if(To.existsSync(this.jwtTokenFilePath)){let t=To.readFileSync(this.jwtTokenFilePath,"utf8");this.jwtTokenData=JSON.parse(t);let r=Date.now();this.isTokenExpired()?this.jwtTokenData=null:this.isTokenNearExpiry(300)&&console.log("\u26A0\uFE0F Access credential expiring soon, auto-renewal in progress")}else console.log("[Login Check] No stored access credential found, authentication required")}catch(t){console.warn("[Login Check] Failed to load access credential from local file:",t),this.jwtTokenData=null}}saveJwtToken(){try{if(!this.jwtTokenData)return;let t=Pg.dirname(this.jwtTokenFilePath);To.existsSync(t)||To.mkdirSync(t,{recursive:!0}),To.writeFileSync(this.jwtTokenFilePath,JSON.stringify(this.jwtTokenData,null,2)),console.log("[Login Check] Access credential data saved to local file")}catch(t){console.error("[Login Check] Failed to save access credential:",t)}}loadUsageStats(){try{if(To.existsSync(this.usageStatsFilePath)){let t=To.readFileSync(this.usageStatsFilePath,"utf8");this.usageStats=JSON.parse(t)}}catch(t){console.warn("[Login Check] Failed to load usage stats from local file:",t),this.usageStats={totalCreditsConsumed:0,lastUpdated:new Date().toISOString()}}}saveUsageStats(){try{let t=Pg.dirname(this.usageStatsFilePath);To.existsSync(t)||To.mkdirSync(t,{recursive:!0}),To.writeFileSync(this.usageStatsFilePath,JSON.stringify(this.usageStats,null,2)),console.log("[Login Check] Usage stats saved to local file")}catch(t){console.error("[Login Check] Failed to save usage stats:",t)}}updateUsageStats(t){t<=0||(this.usageStats.totalCreditsConsumed+=t,this.usageStats.lastUpdated=new Date().toISOString(),this.saveUsageStats(),console.log(`[Usage Stats] Updated total credits consumed: ${this.usageStats.totalCreditsConsumed} (+${t})`))}getUsageStats(){return{...this.usageStats}}checkStartupTokenStatus(){return this.jwtTokenData?{hasToken:!0,isExpired:Date.now()>=this.jwtTokenData.expiresAt,expiresAt:this.jwtTokenData.expiresAt,hasRefreshToken:!!this.jwtTokenData.refreshToken}:{hasToken:!1,isExpired:!0,expiresAt:null,hasRefreshToken:!1}}configure(t){this.config={...this.config,...t},t.userInfo&&(this.userInfo=t.userInfo,this.saveUserInfo(),console.log(`[Login Check] User info configured: ${t.userInfo.name}`)),t.proxyServerUrl&&console.log(`[Login Check] Proxy server URL: ${t.proxyServerUrl}`),t.cliVersion&&(this.cliVersion=t.cliVersion,console.log(`[Login Check] CLI version set: ${t.cliVersion}`))}setUserInfo(t){this.userInfo=t,this.saveUserInfo(),console.log(`[Login Check] User info updated: ${t.name} (${t.email||t.openId||"N/A"})`)}setCliVersion(t){this.cliVersion=t,console.log(`[Login Check] CLI version updated: ${t}`)}setJwtToken(t){let r=Date.now();this.jwtTokenData={accessToken:t,expiresIn:900,expiresAt:r+900*1e3,savedAt:new Date().toISOString()},this.saveJwtToken(),console.log("[Login Check] Access credential updated")}setJwtTokenData(t){let a=Date.now()+t.expiresIn*1e3;this.jwtTokenData={accessToken:t.accessToken,refreshToken:t.refreshToken,expiresIn:t.expiresIn,expiresAt:a,savedAt:new Date().toISOString()},this.saveJwtToken();let i=this.formatTimeRemaining(t.expiresIn*1e3),s=this.formatAbsoluteTime(a),e=this.formatAbsoluteTime(a-nT*1e3),u=!!t.refreshToken?", will auto-renew":", manual login required";console.log(`[Login Check] Access credential updated - valid for: ${i} (until ${s}), next renewal: ${e}${u}`)}async getAccessToken(){if(!this.jwtTokenData)return console.log("[Login Check] No access credential available, authentication required"),null;let t=Date.now(),r=this.jwtTokenData.expiresAt-t,a=this.formatTimeRemaining(r),i=this.jwtTokenData.expiresAt-nT*1e3,s=this.formatAbsoluteTime(i);if(this.isTokenNearExpiry()){console.log(`[Login Check] Access credential expiring soon (remaining: ${a}), starting auto-renewal...`);try{return await this.refreshAccessToken()}catch(e){return console.error("[Login Check] Credential renewal failed:",e),null}}return this.jwtTokenData.accessToken}isTokenExpired(){return this.jwtTokenData?Date.now()>=this.jwtTokenData.expiresAt:!0}isTokenNearExpiry(t=nT){if(!this.jwtTokenData)return!0;let r=this.jwtTokenData.expiresAt-Date.now(),a=r<=t*1e3;if(a){let i=this.formatTimeRemaining(r);console.log(`[Login Check] Credential expiry check: ${i} remaining <= ${t}s threshold, renewal needed: ${a}`)}return a}async refreshAccessToken(){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.performTokenRefresh();try{return await this.refreshPromise}finally{this.refreshPromise=null}}async performTokenRefresh(){if(!this.jwtTokenData?.refreshToken)throw new Error("No refresh token available");try{console.log("[Login Check] Refreshing access credential...");let t=await fetch(`${this.config.proxyServerUrl}/auth/jwt/refresh`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":"DeepCode CLI ProxyAuthManager"},body:JSON.stringify({refreshToken:this.jwtTokenData.refreshToken})});if(!t.ok){if(t.status===401)throw this.clearTokens(),new Error("Refresh credential expired or invalid - authentication required");let u=await t.text();throw new Error(`Credential refresh failed (${t.status}): ${u}`)}let r=await t.json();if(!r.success||!r.data?.accessToken)throw new Error("Invalid refresh response from server");let a=Date.now(),i=!!r.data.refreshToken;this.jwtTokenData={accessToken:r.data.accessToken,refreshToken:r.data.refreshToken||this.jwtTokenData.refreshToken,expiresIn:r.data.expiresIn||900,expiresAt:a+(r.data.expiresIn||900)*1e3,savedAt:new Date().toISOString()},this.saveJwtToken();let s=this.formatTimeRemaining((r.data.expiresIn||900)*1e3),e=this.formatAbsoluteTime(this.jwtTokenData.expiresAt),c=this.formatAbsoluteTime(this.jwtTokenData.expiresAt-nT*1e3);return console.log(`[Login Check] \u2705 Credential renewed successfully - valid for: ${s} (until ${e}), next renewal: ${c}${i?" (refresh credential updated)":" (reusing existing refresh credential)"}`),this.jwtTokenData.accessToken}catch(t){throw console.error("[Login Check] Credential refresh error:",t),t}}clearTokens(){this.jwtTokenData=null;try{To.existsSync(this.jwtTokenFilePath)&&To.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}}getProxyServerUrl(){return this.config.proxyServerUrl}async getUserHeaders(){let t=await this.getAccessToken(),r=this.getCliVersion(),a=this.getUserAgent();return t?{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-Client-Version":r,"User-Agent":a}:{"X-Client-Version":r,"User-Agent":a}}getUserHeadersSync(){let t=this.getCliVersion(),r=this.getUserAgent();return this.jwtTokenData?.accessToken?{Authorization:`Bearer ${this.jwtTokenData.accessToken}`,"Content-Type":"application/json","X-Client-Version":t,"User-Agent":r}:{"X-Client-Version":t,"User-Agent":r}}getUserInfo(){return this.userInfo}isConfigured(){return!!this.userInfo}getStatus(){return{configured:this.isConfigured(),proxyServerUrl:this.config.proxyServerUrl,hasUserInfo:!!this.userInfo,userInfo:this.userInfo}}clear(){this.userInfo=null,this.jwtTokenData=null,this.periodicStatusCheckIntervalId!==null&&(clearInterval(this.periodicStatusCheckIntervalId),this.periodicStatusCheckIntervalId=null);try{To.existsSync(this.userInfoFilePath)&&To.unlinkSync(this.userInfoFilePath)}catch(t){console.warn("[Login Check] Failed to delete user info file:",t)}try{To.existsSync(this.jwtTokenFilePath)&&To.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}console.log("[Login Check] Authentication cleared")}},ms=Xs.getInstance()});import{promises as Xw}from"node:fs";import rT from"node:path";import wwn from"os";var zb,are,nr,x1=ct(()=>{"use strict";(function(n){n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR"})(zb||(zb={}));are=class{config;logBuffer=[];constructor(t={}){if(this.config={level:zb.INFO,enableConsole:!0,enableFile:!1,maxFileSize:10,maxFiles:5,...t},this.config.enableFile&&!this.config.filePath){let r=new Date().toISOString().slice(0,19).replace(/[:.]/g,"-");this.config.filePath=rT.join(wwn.homedir(),".deepv","logs",`deepv-${r}.log`)}}formatMessage(t,r,...a){let i=new Date().toISOString(),s=a.map(e=>typeof e=="object"?JSON.stringify(e,null,2):String(e)).join(" ");return`[${i}] [${t}] ${r} ${s}`.trim()}async writeToFile(t){if(!(!this.config.enableFile||!this.config.filePath))try{await Xw.mkdir(rT.dirname(this.config.filePath),{recursive:!0}),await this.rotateLogIfNeeded(),await Xw.appendFile(this.config.filePath,t+`
|
|
513
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],s}if(this.chunks.push(t),t.startsWith(":"))return null;let[r,a,i]=Gwn(t,":");return i.startsWith(" ")&&(i=i.substring(1)),r==="event"?this.event=i:r==="data"&&this.data.push(i),null}};eNe=class n extends Promise{constructor(t,r,a=fwn){super(i=>{i(null)}),this.responsePromise=r,this.parseResponse=a,this.client=t}_thenUnwrap(t){return new n(this.client,this.responsePromise,async(r,a)=>t(await this.parseResponse(r,a),a))}asResponse(){return this.responsePromise.then(t=>t.response)}async withResponse(){let[t,r]=await Promise.all([this.parse(),this.asResponse()]);return{data:t,response:r}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(t=>this.parseResponse(this.client,t))),this.parsedPromise}then(t,r){return this.parse().then(t,r)}catch(t){return this.parse().catch(t)}finally(t){return this.parse().finally(t)}};Vat=Symbol("brand.privateNullableHeaders");qD=n=>{let t=new Headers,r=new Set;for(let a of n){let i=new Set;for(let[s,e]of gwn(a)){let c=s.toLowerCase();i.has(c)||(t.delete(s),i.add(c)),e===null?(t.delete(s),r.add(c)):(t.append(s,e),r.delete(c))}}return{[Vat]:!0,values:t,nulls:r}};z3e=n=>{var t,r,a,i,s,e;if(typeof globalThis.process<"u")return(a=(r=(t=globalThis.process.env)===null||t===void 0?void 0:t[n])===null||r===void 0?void 0:r.trim())!==null&&a!==void 0?a:void 0;if(typeof globalThis.Deno<"u")return(e=(s=(i=globalThis.Deno.env)===null||i===void 0?void 0:i.get)===null||s===void 0?void 0:s.call(i,n))===null||e===void 0?void 0:e.trim()};nre=class n{constructor(t){var r,a,i,s,e,c,u,{baseURL:d=z3e("GEMINI_NEXT_GEN_API_BASE_URL"),apiKey:I=(r=z3e("GEMINI_API_KEY"))!==null&&r!==void 0?r:null,apiVersion:h="v1beta"}=t,o=Bne(t,["baseURL","apiKey","apiVersion"]);let f=Object.assign(Object.assign({apiKey:I,apiVersion:h},o),{baseURL:d||"https://generativelanguage.googleapis.com"});this.baseURL=f.baseURL,this.timeout=(a=f.timeout)!==null&&a!==void 0?a:n.DEFAULT_TIMEOUT,this.logger=(i=f.logger)!==null&&i!==void 0?i:console;let E="warn";this.logLevel=E,this.logLevel=(e=(s=Aat(f.logLevel,"ClientOptions.logLevel",this))!==null&&s!==void 0?s:Aat(z3e("GEMINI_NEXT_GEN_API_LOG"),"process.env['GEMINI_NEXT_GEN_API_LOG']",this))!==null&&e!==void 0?e:E,this.fetchOptions=f.fetchOptions,this.maxRetries=(c=f.maxRetries)!==null&&c!==void 0?c:2,this.fetch=(u=f.fetch)!==null&&u!==void 0?u:ewn(),this.encoder=rwn,this._options=f,this.apiKey=I,this.apiVersion=h,this.clientAdapter=f.clientAdapter}withOptions(t){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),t))}baseURLOverridden(){return this.baseURL!=="https://generativelanguage.googleapis.com"}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:t,nulls:r}){if(!(t.has("authorization")||t.has("x-goog-api-key"))&&!(this.apiKey&&t.get("x-goog-api-key"))&&!r.has("x-goog-api-key"))throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted')}async authHeaders(t){let r=qD([t.headers]);if(!(r.values.has("authorization")||r.values.has("x-goog-api-key"))){if(this.apiKey)return qD([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return qD([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(t){return Object.entries(t).filter(([r,a])=>typeof a<"u").map(([r,a])=>{if(typeof a=="string"||typeof a=="number"||typeof a=="boolean")return`${encodeURIComponent(r)}=${encodeURIComponent(a)}`;if(a===null)return`${encodeURIComponent(r)}=`;throw new l2(`Cannot stringify type ${typeof a}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}getUserAgent(){return`${this.constructor.name}/JS ${VH}`}defaultIdempotencyKey(){return`stainless-node-retry-${SEn()}`}makeStatusError(t,r,a,i){return s2.generate(t,r,a,i)}buildURL(t,r,a){let i=!this.baseURLOverridden()&&a||this.baseURL,s=DEn(t)?new URL(t):new URL(i+(i.endsWith("/")&&t.startsWith("/")?t.slice(1):t)),e=this.defaultQuery();return UEn(e)||(r=Object.assign(Object.assign({},e),r)),typeof r=="object"&&r&&!Array.isArray(r)&&(s.search=this.stringifyQuery(r)),s.toString()}async prepareOptions(t){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!t.path.startsWith(`/${this.apiVersion}/projects/`)){let r=t.path.slice(this.apiVersion.length+1);t.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${r}`}}async prepareRequest(t,{url:r,options:a}){}get(t,r){return this.methodRequest("get",t,r)}post(t,r){return this.methodRequest("post",t,r)}patch(t,r){return this.methodRequest("patch",t,r)}put(t,r){return this.methodRequest("put",t,r)}delete(t,r){return this.methodRequest("delete",t,r)}methodRequest(t,r,a){return this.request(Promise.resolve(a).then(i=>Object.assign({method:t,path:r},i)))}request(t,r=null){return new eNe(this,this.makeRequest(t,r,void 0))}async makeRequest(t,r,a){var i,s,e;let c=await t,u=(i=c.maxRetries)!==null&&i!==void 0?i:this.maxRetries;r==null&&(r=u),await this.prepareOptions(c);let{req:d,url:I,timeout:h}=await this.buildRequest(c,{retryCount:u-r});await this.prepareRequest(d,{url:I,options:c});let o="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),f=a===void 0?"":`, retryOf: ${a}`,E=Date.now();if(Om(this).debug(`[${o}] sending request`,xw({retryOfRequestLogID:a,method:c.method,url:I,options:c,headers:d.headers})),!((s=c.signal)===null||s===void 0)&&s.aborted)throw new eT;let F=new AbortController,w=await this.fetchWithTimeout(I,d,h,F).catch(P3e),A=Date.now();if(w instanceof globalThis.Error){let W=`retrying, ${r} attempts remaining`;if(!((e=c.signal)===null||e===void 0)&&e.aborted)throw new eT;let y=_3e(w)||/timed? ?out/i.test(String(w)+("cause"in w?String(w.cause):""));if(r)return Om(this).info(`[${o}] connection ${y?"timed out":"failed"} - ${W}`),Om(this).debug(`[${o}] connection ${y?"timed out":"failed"} (${W})`,xw({retryOfRequestLogID:a,url:I,durationMs:A-E,message:w.message})),this.retryRequest(c,r,a??o);throw Om(this).info(`[${o}] connection ${y?"timed out":"failed"} - error; no more retries left`),Om(this).debug(`[${o}] connection ${y?"timed out":"failed"} (error; no more retries left)`,xw({retryOfRequestLogID:a,url:I,durationMs:A-E,message:w.message})),y?new Tne:new kH({cause:w})}let C=`[${o}${f}] ${d.method} ${I} ${w.ok?"succeeded":"failed"} with status ${w.status} in ${A-E}ms`;if(!w.ok){let W=await this.shouldRetry(w);if(r&&W){let m=`retrying, ${r} attempts remaining`;return await nwn(w.body),Om(this).info(`${C} - ${m}`),Om(this).debug(`[${o}] response error (${m})`,xw({retryOfRequestLogID:a,url:w.url,status:w.status,headers:w.headers,durationMs:A-E})),this.retryRequest(c,r,a??o,w.headers)}let y=W?"error; no more retries left":"error; not retryable";Om(this).info(`${C} - ${y}`);let b=await w.text().catch(m=>P3e(m).message),g=_En(b),v=g?void 0:b;throw Om(this).debug(`[${o}] response error (${y})`,xw({retryOfRequestLogID:a,url:w.url,status:w.status,headers:w.headers,message:v,durationMs:Date.now()-E})),this.makeStatusError(w.status,g,v,w.headers)}return Om(this).info(C),Om(this).debug(`[${o}] response start`,xw({retryOfRequestLogID:a,url:w.url,status:w.status,headers:w.headers,durationMs:A-E})),{response:w,options:c,controller:F,requestLogID:o,retryOfRequestLogID:a,startTime:E}}async fetchWithTimeout(t,r,a,i){let s=r||{},{signal:e,method:c}=s,u=Bne(s,["signal","method"]);e&&e.addEventListener("abort",()=>i.abort());let d=setTimeout(()=>i.abort(),a),I=globalThis.ReadableStream&&u.body instanceof globalThis.ReadableStream||typeof u.body=="object"&&u.body!==null&&Symbol.asyncIterator in u.body,h=Object.assign(Object.assign(Object.assign({signal:i.signal},I?{duplex:"half"}:{}),{method:"GET"}),u);c&&(h.method=c.toUpperCase());try{return await this.fetch.call(void 0,t,h)}finally{clearTimeout(d)}}async shouldRetry(t){let r=t.headers.get("x-should-retry");return r==="true"?!0:r==="false"?!1:t.status===408||t.status===409||t.status===429||t.status>=500}async retryRequest(t,r,a,i){var s;let e,c=i?.get("retry-after-ms");if(c){let d=parseFloat(c);Number.isNaN(d)||(e=d)}let u=i?.get("retry-after");if(u&&!e){let d=parseFloat(u);Number.isNaN(d)?e=Date.parse(u)-Date.now():e=d*1e3}if(!(e&&0<=e&&e<60*1e3)){let d=(s=t.maxRetries)!==null&&s!==void 0?s:this.maxRetries;e=this.calculateDefaultRetryTimeoutMillis(r,d)}return await PEn(e),this.makeRequest(t,r-1,a)}calculateDefaultRetryTimeoutMillis(t,r){let s=r-t,e=Math.min(.5*Math.pow(2,s),8),c=1-Math.random()*.25;return e*c*1e3}async buildRequest(t,{retryCount:r=0}={}){var a,i,s;let e=Object.assign({},t),{method:c,path:u,query:d,defaultBaseURL:I}=e,h=this.buildURL(u,d,I);"timeout"in e&&zEn("timeout",e.timeout),e.timeout=(a=e.timeout)!==null&&a!==void 0?a:this.timeout;let{bodyHeaders:o,body:f}=this.buildBody({options:e}),E=await this.buildHeaders({options:t,method:c,bodyHeaders:o,retryCount:r});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:c,headers:E},e.signal&&{signal:e.signal}),globalThis.ReadableStream&&f instanceof globalThis.ReadableStream&&{duplex:"half"}),f&&{body:f}),(i=this.fetchOptions)!==null&&i!==void 0?i:{}),(s=e.fetchOptions)!==null&&s!==void 0?s:{}),url:h,timeout:e.timeout}}async buildHeaders({options:t,method:r,bodyHeaders:a,retryCount:i}){let s={};this.idempotencyHeader&&r!=="get"&&(t.idempotencyKey||(t.idempotencyKey=this.defaultIdempotencyKey()),s[this.idempotencyHeader]=t.idempotencyKey);let e=await this.authHeaders(t),c=qD([s,Object.assign(Object.assign({Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i)},t.timeout?{"X-Stainless-Timeout":String(Math.trunc(t.timeout/1e3))}:{}),$En()),this._options.defaultHeaders,a,t.headers,e]);return this.validateHeaders(c),c.values}buildBody({options:{body:t,headers:r}}){if(!t)return{bodyHeaders:void 0,body:void 0};let a=qD([r]);return ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof DataView||typeof t=="string"&&a.values.has("content-type")||globalThis.Blob&&t instanceof globalThis.Blob||t instanceof FormData||t instanceof URLSearchParams||globalThis.ReadableStream&&t instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:t}:typeof t=="object"&&(Symbol.asyncIterator in t||Symbol.iterator in t&&"next"in t&&typeof t.next=="function")?{bodyHeaders:void 0,body:twn(t)}:this.encoder({body:t,headers:a})}};nre.DEFAULT_TIMEOUT=6e4;rd=class extends nre{constructor(){super(...arguments),this.interactions=new ere(this)}};Qat=rd;rd.GeminiNextGenAPIClient=Qat;rd.GeminiNextGenAPIClientError=l2;rd.APIError=s2;rd.APIConnectionError=kH;rd.APIConnectionTimeoutError=Tne;rd.APIUserAbortError=eT;rd.NotFoundError=zne;rd.ConflictError=_ne;rd.RateLimitError=jne;rd.BadRequestError=One;rd.AuthenticationError=Une;rd.InternalServerError=Kne;rd.PermissionDeniedError=Mne;rd.UnprocessableEntityError=Pne;rd.toFile=own;rd.Interactions=ere;Boa=1024*1024*8;});function vwn(n,t){return{...n,...t}}function Hat(n){let{prompt_id:t,...r}=n;return r}function Qw(n){return Array.isArray(n)?n.map(Hat):n}var rre=ct(()=>{"use strict";hi();});var Xat={};so(Xat,{DEFAULT_PROXY_CONFIG:()=>Wwn,getActiveProxyServerUrl:()=>G3,getAvailableProxyServers:()=>Zwn,getProxyServerInfo:()=>Nwn,getProxyServers:()=>tT,hasAvailableProxyServer:()=>rNe});function tT(){return[{url:"https://api-code.deepvlab.ai",name:"Primary Development Server",region:"default",status:"active"}]}function G3(){let t=tT().find(r=>r.status==="active");if(!t)throw new Error("No active proxy server available. Please contact support.");return t.url}function Zwn(){return tT().filter(t=>t.status==="active")}function rNe(){return tT().some(t=>t.status==="active")}function Nwn(n){return tT().find(r=>r.url===n)}var Wwn,JH=ct(()=>{"use strict";Wwn={serverUrl:G3(),timeout:2e5,retryAttempts:3,retryDelay:1e3}});import*as To from"fs";import*as Pg from"path";import*as Hw from"os";function Awn(n){ms.configure(n)}function Fwn(n){ms.setUserInfo(n)}function ywn(n){ms.setCliVersion(n)}async function Rwn(){return await ms.getUserHeaders()}function Ewn(){return ms.getStatus()}var nT,Xs,ms,gy=ct(()=>{"use strict";JH();nT=259200,Xs=class n{static instance=null;config;userInfo=null;jwtTokenData=null;usageStats={totalCreditsConsumed:0,lastUpdated:new Date().toISOString()};userInfoFilePath;jwtTokenFilePath;usageStatsFilePath;refreshPromise=null;cliVersion="unknown";periodicStatusCheckIntervalId=null;getCliVersion(){return this.cliVersion}getUserAgent(){let t=this.cliVersion,r=process.platform,a=process.arch;return t.startsWith("VSCode-")?`DeepVCode/VSCode/${t.replace("VSCode-","")} (${r}; ${a})`:`DeepVCode/CLI/${t} (${r}; ${a})`}formatTimeRemaining(t){if(t<=0)return"\u5DF2\u8FC7\u671F";let r=Math.floor(t/1e3),a=Math.floor(r/(24*3600)),i=Math.floor(r%(24*3600)/3600),s=Math.floor(r%3600/60),e=r%60;return a>0?`${a}\u5929${i}\u5C0F\u65F6${s}\u5206\u949F`:i>0?`${i}\u5C0F\u65F6${s}\u5206\u949F${e}\u79D2`:s>0?`${s}\u5206\u949F${e}\u79D2`:`${e}\u79D2`}formatAbsoluteTime(t){return new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}constructor(){"https://api-code.deepvlab.ai"?.includes("localhost")?(this.userInfoFilePath=Pg.join(Hw.homedir(),".deepv","user-info-dev.json"),this.jwtTokenFilePath=Pg.join(Hw.homedir(),".deepv","jwt-token-dev.json"),this.usageStatsFilePath=Pg.join(Hw.homedir(),".deepv","usage-stats-dev.json")):(this.userInfoFilePath=Pg.join(Hw.homedir(),".deepv","user-info.json"),this.jwtTokenFilePath=Pg.join(Hw.homedir(),".deepv","jwt-token.json"),this.usageStatsFilePath=Pg.join(Hw.homedir(),".deepv","usage-stats.json")),this.cliVersion="1.0.268",this.config={proxyServerUrl:G3()},this.loadUserInfo(),this.loadJwtToken(),this.loadUsageStats(),this.startPeriodicStatusCheck()}startPeriodicStatusCheck(){this.periodicStatusCheckIntervalId=setInterval(()=>{if(this.jwtTokenData){let t=Date.now(),r=this.jwtTokenData.expiresAt-t,a=this.formatTimeRemaining(r),i=this.formatAbsoluteTime(this.jwtTokenData.expiresAt);if(r>0){let s=this.formatAbsoluteTime(this.jwtTokenData.expiresAt-nT*1e3);console.log(`[Login Check] \u{1F4CA} Periodic status check - Credential remaining: ${a} (until ${i}), next renewal: ${s}`)}else console.log(`[Login Check] \u26A0\uFE0F Periodic status check - Credential expired at: ${i}`)}},600*1e3)}static getInstance(){return n.instance||(n.instance=new n),n.instance}loadUserInfo(){try{if(To.existsSync(this.userInfoFilePath)){let t=To.readFileSync(this.userInfoFilePath,"utf8");this.userInfo=JSON.parse(t);let r=a=>{if(!a||!a.includes("@"))return a;let[i,s]=a.split("@");return i.length<=2?a:`${i[0]+"*".repeat(i.length-2)+i[i.length-1]}@${s}`}}}catch(t){console.warn("[Login Check] Failed to load user info from local file:",t),this.userInfo=null}}saveUserInfo(){try{let t=Pg.dirname(this.userInfoFilePath);To.existsSync(t)||To.mkdirSync(t,{recursive:!0}),To.writeFileSync(this.userInfoFilePath,JSON.stringify(this.userInfo,null,2)),console.log("[Login Check] User info saved to local file")}catch(t){console.error("[Login Check] Failed to save user info:",t)}}loadJwtToken(){try{if(To.existsSync(this.jwtTokenFilePath)){let t=To.readFileSync(this.jwtTokenFilePath,"utf8");this.jwtTokenData=JSON.parse(t);let r=Date.now();this.isTokenExpired()?this.jwtTokenData=null:this.isTokenNearExpiry(300)&&console.log("\u26A0\uFE0F Access credential expiring soon, auto-renewal in progress")}else console.log("[Login Check] No stored access credential found, authentication required")}catch(t){console.warn("[Login Check] Failed to load access credential from local file:",t),this.jwtTokenData=null}}saveJwtToken(){try{if(!this.jwtTokenData)return;let t=Pg.dirname(this.jwtTokenFilePath);To.existsSync(t)||To.mkdirSync(t,{recursive:!0}),To.writeFileSync(this.jwtTokenFilePath,JSON.stringify(this.jwtTokenData,null,2)),console.log("[Login Check] Access credential data saved to local file")}catch(t){console.error("[Login Check] Failed to save access credential:",t)}}loadUsageStats(){try{if(To.existsSync(this.usageStatsFilePath)){let t=To.readFileSync(this.usageStatsFilePath,"utf8");this.usageStats=JSON.parse(t)}}catch(t){console.warn("[Login Check] Failed to load usage stats from local file:",t),this.usageStats={totalCreditsConsumed:0,lastUpdated:new Date().toISOString()}}}saveUsageStats(){try{let t=Pg.dirname(this.usageStatsFilePath);To.existsSync(t)||To.mkdirSync(t,{recursive:!0}),To.writeFileSync(this.usageStatsFilePath,JSON.stringify(this.usageStats,null,2)),console.log("[Login Check] Usage stats saved to local file")}catch(t){console.error("[Login Check] Failed to save usage stats:",t)}}updateUsageStats(t){t<=0||(this.usageStats.totalCreditsConsumed+=t,this.usageStats.lastUpdated=new Date().toISOString(),this.saveUsageStats(),console.log(`[Usage Stats] Updated total credits consumed: ${this.usageStats.totalCreditsConsumed} (+${t})`))}getUsageStats(){return{...this.usageStats}}checkStartupTokenStatus(){return this.jwtTokenData?{hasToken:!0,isExpired:Date.now()>=this.jwtTokenData.expiresAt,expiresAt:this.jwtTokenData.expiresAt,hasRefreshToken:!!this.jwtTokenData.refreshToken}:{hasToken:!1,isExpired:!0,expiresAt:null,hasRefreshToken:!1}}configure(t){this.config={...this.config,...t},t.userInfo&&(this.userInfo=t.userInfo,this.saveUserInfo(),console.log(`[Login Check] User info configured: ${t.userInfo.name}`)),t.proxyServerUrl&&console.log(`[Login Check] Proxy server URL: ${t.proxyServerUrl}`),t.cliVersion&&(this.cliVersion=t.cliVersion,console.log(`[Login Check] CLI version set: ${t.cliVersion}`))}setUserInfo(t){this.userInfo=t,this.saveUserInfo(),console.log(`[Login Check] User info updated: ${t.name} (${t.email||t.openId||"N/A"})`)}setCliVersion(t){this.cliVersion=t,console.log(`[Login Check] CLI version updated: ${t}`)}setJwtToken(t){let r=Date.now();this.jwtTokenData={accessToken:t,expiresIn:900,expiresAt:r+900*1e3,savedAt:new Date().toISOString()},this.saveJwtToken(),console.log("[Login Check] Access credential updated")}setJwtTokenData(t){let a=Date.now()+t.expiresIn*1e3;this.jwtTokenData={accessToken:t.accessToken,refreshToken:t.refreshToken,expiresIn:t.expiresIn,expiresAt:a,savedAt:new Date().toISOString()},this.saveJwtToken();let i=this.formatTimeRemaining(t.expiresIn*1e3),s=this.formatAbsoluteTime(a),e=this.formatAbsoluteTime(a-nT*1e3),u=!!t.refreshToken?", will auto-renew":", manual login required";console.log(`[Login Check] Access credential updated - valid for: ${i} (until ${s}), next renewal: ${e}${u}`)}async getAccessToken(){if(!this.jwtTokenData)return console.log("[Login Check] No access credential available, authentication required"),null;let t=Date.now(),r=this.jwtTokenData.expiresAt-t,a=this.formatTimeRemaining(r),i=this.jwtTokenData.expiresAt-nT*1e3,s=this.formatAbsoluteTime(i);if(this.isTokenNearExpiry()){console.log(`[Login Check] Access credential expiring soon (remaining: ${a}), starting auto-renewal...`);try{return await this.refreshAccessToken()}catch(e){return console.error("[Login Check] Credential renewal failed:",e),null}}return this.jwtTokenData.accessToken}isTokenExpired(){return this.jwtTokenData?Date.now()>=this.jwtTokenData.expiresAt:!0}isTokenNearExpiry(t=nT){if(!this.jwtTokenData)return!0;let r=this.jwtTokenData.expiresAt-Date.now(),a=r<=t*1e3;if(a){let i=this.formatTimeRemaining(r);console.log(`[Login Check] Credential expiry check: ${i} remaining <= ${t}s threshold, renewal needed: ${a}`)}return a}async refreshAccessToken(){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.performTokenRefresh();try{return await this.refreshPromise}finally{this.refreshPromise=null}}async performTokenRefresh(){if(!this.jwtTokenData?.refreshToken)throw new Error("No refresh token available");try{console.log("[Login Check] Refreshing access credential...");let t=await fetch(`${this.config.proxyServerUrl}/auth/jwt/refresh`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":"DeepCode CLI ProxyAuthManager"},body:JSON.stringify({refreshToken:this.jwtTokenData.refreshToken})});if(!t.ok){if(t.status===401)throw this.clearTokens(),new Error("Refresh credential expired or invalid - authentication required");let u=await t.text();throw new Error(`Credential refresh failed (${t.status}): ${u}`)}let r=await t.json();if(!r.success||!r.data?.accessToken)throw new Error("Invalid refresh response from server");let a=Date.now(),i=!!r.data.refreshToken;this.jwtTokenData={accessToken:r.data.accessToken,refreshToken:r.data.refreshToken||this.jwtTokenData.refreshToken,expiresIn:r.data.expiresIn||900,expiresAt:a+(r.data.expiresIn||900)*1e3,savedAt:new Date().toISOString()},this.saveJwtToken();let s=this.formatTimeRemaining((r.data.expiresIn||900)*1e3),e=this.formatAbsoluteTime(this.jwtTokenData.expiresAt),c=this.formatAbsoluteTime(this.jwtTokenData.expiresAt-nT*1e3);return console.log(`[Login Check] \u2705 Credential renewed successfully - valid for: ${s} (until ${e}), next renewal: ${c}${i?" (refresh credential updated)":" (reusing existing refresh credential)"}`),this.jwtTokenData.accessToken}catch(t){throw console.error("[Login Check] Credential refresh error:",t),t}}clearTokens(){this.jwtTokenData=null;try{To.existsSync(this.jwtTokenFilePath)&&To.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}}getProxyServerUrl(){return this.config.proxyServerUrl}async getUserHeaders(){let t=await this.getAccessToken(),r=this.getCliVersion(),a=this.getUserAgent();return t?{Authorization:`Bearer ${t}`,"Content-Type":"application/json","X-Client-Version":r,"User-Agent":a}:{"X-Client-Version":r,"User-Agent":a}}getUserHeadersSync(){let t=this.getCliVersion(),r=this.getUserAgent();return this.jwtTokenData?.accessToken?{Authorization:`Bearer ${this.jwtTokenData.accessToken}`,"Content-Type":"application/json","X-Client-Version":t,"User-Agent":r}:{"X-Client-Version":t,"User-Agent":r}}getUserInfo(){return this.userInfo}isConfigured(){return!!this.userInfo}getStatus(){return{configured:this.isConfigured(),proxyServerUrl:this.config.proxyServerUrl,hasUserInfo:!!this.userInfo,userInfo:this.userInfo}}clear(){this.userInfo=null,this.jwtTokenData=null,this.periodicStatusCheckIntervalId!==null&&(clearInterval(this.periodicStatusCheckIntervalId),this.periodicStatusCheckIntervalId=null);try{To.existsSync(this.userInfoFilePath)&&To.unlinkSync(this.userInfoFilePath)}catch(t){console.warn("[Login Check] Failed to delete user info file:",t)}try{To.existsSync(this.jwtTokenFilePath)&&To.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}console.log("[Login Check] Authentication cleared")}},ms=Xs.getInstance()});import{promises as Xw}from"node:fs";import rT from"node:path";import wwn from"os";var zb,are,nr,x1=ct(()=>{"use strict";(function(n){n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR"})(zb||(zb={}));are=class{config;logBuffer=[];constructor(t={}){if(this.config={level:zb.INFO,enableConsole:!0,enableFile:!1,maxFileSize:10,maxFiles:5,...t},this.config.enableFile&&!this.config.filePath){let r=new Date().toISOString().slice(0,19).replace(/[:.]/g,"-");this.config.filePath=rT.join(wwn.homedir(),".deepv","logs",`deepv-${r}.log`)}}formatMessage(t,r,...a){let i=new Date().toISOString(),s=a.map(e=>typeof e=="object"?JSON.stringify(e,null,2):String(e)).join(" ");return`[${i}] [${t}] ${r} ${s}`.trim()}async writeToFile(t){if(!(!this.config.enableFile||!this.config.filePath))try{await Xw.mkdir(rT.dirname(this.config.filePath),{recursive:!0}),await this.rotateLogIfNeeded(),await Xw.appendFile(this.config.filePath,t+`
|
|
514
514
|
`,"utf-8")}catch(r){console.error("\u5199\u5165\u65E5\u5FD7\u6587\u4EF6\u5931\u8D25:",r)}}async rotateLogIfNeeded(){if(this.config.filePath)try{if((await Xw.stat(this.config.filePath)).size/(1024*1024)>(this.config.maxFileSize||10)){let a=new Date().toISOString().slice(0,19).replace(/[:.]/g,"-"),i=this.config.filePath.replace(".log",`-${a}.log`);await Xw.rename(this.config.filePath,i),await this.cleanOldLogs()}}catch(t){t.code!=="ENOENT"&&console.error("\u65E5\u5FD7\u8F6E\u8F6C\u5931\u8D25:",t)}}async cleanOldLogs(){if(this.config.filePath)try{let t=rT.dirname(this.config.filePath),a=(await Xw.readdir(t)).filter(e=>e.startsWith("deepv-")&&e.endsWith(".log")).map(e=>({name:e,path:rT.join(t,e),time:Xw.stat(rT.join(t,e)).then(c=>c.mtime)})),i=await Promise.all(a.map(async e=>({...e,time:await e.time})));i.sort((e,c)=>c.time.getTime()-e.time.getTime());let s=i.slice(this.config.maxFiles||5);for(let e of s)await Xw.unlink(e.path)}catch(t){console.error("\u6E05\u7406\u65E7\u65E5\u5FD7\u5931\u8D25:",t)}}log(t,r,a,...i){if(t<this.config.level)return;let s=this.formatMessage(r,a,...i);this.config.enableConsole&&(t>=zb.ERROR?console.error:t>=zb.WARN?console.warn:t>=zb.INFO?console.log:console.debug)(s),this.config.enableFile&&this.writeToFile(s)}debug(t,...r){this.log(zb.DEBUG,"DEBUG",t,...r)}info(t,...r){this.log(zb.INFO,"INFO",t,...r)}warn(t,...r){this.log(zb.WARN,"WARN",t,...r)}error(t,...r){this.log(zb.ERROR,"ERROR",t,...r)}logApiRequest(t,r){this.debug("API\u8BF7\u6C42",{endpoint:t,timestamp:new Date().toISOString(),requestSize:JSON.stringify(r).length,...process.env.FILE_DEBUG==="1"?{requestData:r}:{}})}logApiResponse(t,r){this.debug("API\u54CD\u5E94",{endpoint:t,timestamp:new Date().toISOString(),responseSize:JSON.stringify(r).length,...process.env.FILE_DEBUG==="1"?{responseData:r}:{}})}},nr=new are({level:process.env.FILE_DEBUG==="1"?zb.DEBUG:zb.INFO,enableConsole:!0,enableFile:process.env.LOG_TO_FILE==="true",filePath:process.env.LOG_FILE_PATH})});function js(n){return n instanceof Error&&"code"in n}function ar(n){if(n instanceof Error)return n.message;try{return String(n)}catch{return"Failed to get error details"}}function aNe(n){if(n&&typeof n=="object"&&"response"in n){let r=Cwn(n);if(r.error&&r.error.message&&r.error.code)switch(r.error.code){case 400:return new lre(r.error.message);case 401:return new HI(r.error.message);case 403:return new ire(r.error.message);default:}}return n}function Cwn(n){return typeof n.response?.data=="string"?JSON.parse(n.response?.data):n.response?.data}var ire,HI,lre,Oo=ct(()=>{"use strict";ire=class extends Error{},HI=class extends Error{},lre=class extends Error{}});var ya,kat,ad,f3=ct(()=>{"use strict";(function(n){n.CHAT_CONVERSATION="chat_conversation",n.WEB_FETCH="web_fetch",n.WEB_SEARCH="web_search",n.CONTENT_SUMMARY="content_summary",n.JSON_GENERATION="json_generation",n.COMPRESSION="compression",n.SUB_AGENT="sub_agent",n.CODE_ASSIST="code_assist",n.EDIT_CORRECTION="edit_correction"})(ya||(ya={}));kat={[ya.CHAT_CONVERSATION]:"auto",[ya.WEB_FETCH]:"gemini-2.5-flash",[ya.WEB_SEARCH]:"gemini-2.5-flash",[ya.CODE_ASSIST]:"auto",[ya.CONTENT_SUMMARY]:"gemini-2.5-flash-lite",[ya.EDIT_CORRECTION]:"gemini-2.5-flash-lite",[ya.JSON_GENERATION]:"gemini-2.5-flash",[ya.COMPRESSION]:"gemini-2.5-flash",[ya.SUB_AGENT]:"auto"},ad=class{static getModelForScene(t){if(t)return kat[t]}static isClaudeModel(t){return t.includes("claude")||t.includes("anthropic")}static isGeminiModel(t){return t.includes("gemini")&&!this.isClaudeModel(t)}static getSceneDisplayName(t){return{[ya.CHAT_CONVERSATION]:"\u804A\u5929\u5BF9\u8BDD",[ya.WEB_FETCH]:"Web\u5185\u5BB9\u83B7\u53D6",[ya.WEB_SEARCH]:"Web\u641C\u7D22",[ya.CODE_ASSIST]:"\u4EE3\u7801\u52A9\u624B",[ya.CONTENT_SUMMARY]:"\u5185\u5BB9\u6458\u8981",[ya.EDIT_CORRECTION]:"\u7F16\u8F91\u6821\u6B63",[ya.JSON_GENERATION]:"JSON\u751F\u6210",[ya.COMPRESSION]:"\u5BF9\u8BDD\u538B\u7F29",[ya.SUB_AGENT]:"SubAgent\u5B50\u4EE3\u7406"}[t]||t}}});function nA(n){return typeof n=="object"&&n!==null&&"error"in n&&typeof n.error=="object"&&"message"in n.error}function _b(n){return typeof n=="object"&&n!==null&&"message"in n&&typeof n.message=="string"}function rA(n){let t=r=>r.includes("Quota exceeded for quota metric 'Gemini")&&r.includes("Pro Requests'");if(typeof n=="string")return t(n);if(_b(n))return t(n.message);if(nA(n))return t(n.error.message);if(n&&typeof n=="object"&&"response"in n){let r=n;if(r.response&&r.response.data){if(typeof r.response.data=="string")return t(r.response.data);if(typeof r.response.data=="object"&&r.response.data!==null&&"error"in r.response.data){let a=r.response.data;return t(a.error?.message||"")}}}return!1}function aA(n){return typeof n=="string"?n.includes("Quota exceeded for quota metric"):_b(n)?n.message.includes("Quota exceeded for quota metric"):nA(n)?n.error.message.includes("Quota exceeded for quota metric"):!1}function V1(n){if(n&&typeof n=="object"&&"response"in n){let t=n;if(t.response?.status===402&&t.response.data){let r=t.response.data;if(r&&typeof r.error=="string"&&(r.error==="Quota limit exceeded"||r.error==="No quota configuration")&&typeof r.message=="string")return!0}}if(n instanceof Error&&n.message&&n.message.includes("API request failed (402):")&&(n.message.includes('"error":"Quota limit exceeded"')||n.message.includes('"error":"No quota configuration"')))return!0;if(typeof n=="object"&&n!==null){let t=n;return t.message&&typeof t.message=="string"&&(t.message.includes("API request failed (402):")&&(t.message.includes('"error":"Quota limit exceeded"')||t.message.includes('"error":"No quota configuration"'))||t.message.includes("API error (402):")&&(t.message.includes('"error":"Quota limit exceeded"')||t.message.includes('"error":"No quota configuration"')))?!0:(t.error==="Quota limit exceeded"||t.error==="No quota configuration")&&typeof t.message=="string"}return typeof n=="string"?n.includes("Quota limit exceeded")||n.includes("No quota configuration")||n.includes("Daily token limit would be exceeded")||n.includes("Daily request limit exceeded")||n.includes("Daily cost limit would be exceeded"):!1}function aT(n){let t=null;if(n&&typeof n=="object"&&"response"in n){let r=n;r.response?.status===402&&r.response.data&&(t=r.response.data)}else if(typeof n=="object"&&n!==null){let r=n;if(r.message&&typeof r.message=="string"&&r.message.includes("API request failed (402):")&&(r.message.includes('"error":"Quota limit exceeded"')||r.message.includes('"error":"No quota configuration"')))try{let a=r.message.match(/\{.*\}$/);a&&(t=JSON.parse(a[0]))}catch{}t||(t=n)}if(!t&&n instanceof Error&&n.message&&n.message.includes("API request failed (402):")&&(n.message.includes('"error":"Quota limit exceeded"')||n.message.includes('"error":"No quota configuration"')))try{let r=n.message.match(/\{.*\}$/);r&&(t=JSON.parse(r[0]))}catch{n.message.includes('"error":"No quota configuration"')?t={error:"No quota configuration",message:"User must be assigned a quota template by administrator"}:n.message.includes('"error":"Quota limit exceeded"')&&(t={error:"Quota limit exceeded",message:"Service quota limit exceeded"})}if(!t&&typeof n=="string"&&n.includes("API request failed (402):")&&(n.includes('"error":"Quota limit exceeded"')||n.includes('"error":"No quota configuration"')))try{let r=n.match(/\{.*\}$/);r&&(t=JSON.parse(r[0]))}catch{n.includes('"error":"No quota configuration"')?t={error:"No quota configuration",message:"User must be assigned a quota template by administrator"}:n.includes('"error":"Quota limit exceeded"')&&(t={error:"Quota limit exceeded",message:"Service quota limit exceeded"})}return t?Ywn(t):null}function Ywn(n){let r=(()=>{try{let a=process.env,i=a.LC_ALL||a.LC_CTYPE||a.LANG||"";return i.toLowerCase().includes("zh")||i.toLowerCase().includes("chinese")}catch{return!1}})();return n.error==="No quota configuration"?r?`\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
515
515
|
\u{1F6AB} \u5F53\u524D\u8D26\u6237\u53EF\u7528\u7684 Credit\uFF08\u79EF\u5206\uFF09\u4E0D\u8DB3\u4EE5\u7EE7\u7EED\u4F7F\u7528\u672C\u670D\u52A1
|
|
516
516
|
\u{1F4A1} \u8BF7\u8003\u8651\u8BA2\u9605\u66F4\u591A\u989D\u5EA6\u7684\u5957\u9910\u3002\u8BE6\u60C5\u8BF7\u8BBF\u95EE\u5B98\u7F51\uFF1Ahttps://dvcode.deepvlab.ai/
|
|
@@ -658,7 +658,7 @@ ${s}`;break;case"retry":y0t(s)&&(r[i]=s);break;case"id":R0t(s)&&(r[i]=s);break;c
|
|
|
658
658
|
|
|
659
659
|
Please check your Feishu authentication token and try again.
|
|
660
660
|
If the problem persists, you may need to re-authenticate.`);throw a.isAuthError=!0,a.statusCode=401,a}throw t}async generateContentStream(t,r){return process.env.DEEPV_CLOUD_MODE==="true"?this._generateContent(t,r):c7n(t.model)?this._generateContentStream(t,r):this._generateContent(t,r)}async _generateContent(t,r){let a=await this.generateContent(t,r);return(async function*(){yield a})()}async _generateContentStream(t,r){try{let a=ad.getModelForScene(r),i=this.config?.getModel(),s=t.model||a||i||"auto";process.env.DEBUG&&console.log(`[\u{1F3AF} Model Resolution (Stream)] Using model: ${s} for scene: ${r}`);let e={model:s,contents:this.cleanContents(Qw(t.contents)),config:{...t.config,stream:!0,httpOptions:{...t.config?.httpOptions,headers:{...t.config?.httpOptions?.headers,"X-Scene-Type":r,"X-Scene-Display":ad.getSceneDisplayName(r)}}}};nr.info(`[DeepV Server] Starting stream with model: ${s}`);let c=await this.callStreamAPI("/v1/chat/stream",e,t.config?.abortSignal);return this.createStreamGenerator(c,t.config?.abortSignal)}catch(a){return nr.error("[DeepV Server] Stream request failed",{error:a}),this.handleStreamError(a)}}async callStreamAPI(t,r,a){return g3(()=>this.executeStreamAPICall(t,r,a),{shouldRetry:i=>V1(i)||i.message.includes("cancelled by user")||i.name==="AbortError"||i.message.includes("401")||i instanceof HI||i.message.includes("451")||i.message.includes("REGION_BLOCKED")?!1:!!(i.message.includes("429")||i.message.match(/5\d{2}/)||i instanceof TypeError&&(i.message.includes("fetch failed")||i.message.includes("ECONNREFUSED")))})}async executeStreamAPICall(t,r,a){let i=await ms.getUserHeaders(),s=`${ms.getProxyServerUrl()}${t}`;if(process.env.DEBUG){console.log("\u{1F50D} [DeepV Debug Stream] Proxy environment variables:"),console.log(" HTTP_PROXY:",process.env.HTTP_PROXY),console.log(" HTTPS_PROXY:",process.env.HTTPS_PROXY),console.log(" http_proxy:",process.env.http_proxy),console.log(" https_proxy:",process.env.https_proxy),console.log(" Target URL:",s);let d=(0,B0t.getGlobalDispatcher)();console.log("\u{1F50D} [DeepV Debug Stream] Global dispatcher:",d?.constructor?.name||"undefined"),d&&"uri"in d&&console.log(" Dispatcher URI:",d.uri)}let e=new AbortController,c=null;if(a)if(a.aborted)e.abort();else{let d=()=>{process.env.DEBUG&&console.log("[DeepV Server] Stream request cancelled by user"),e.abort()};a.addEventListener("abort",d),c=()=>a.removeEventListener("abort",d)}let u=Date.now();try{nr.debug("[DeepV Server] Making stream API call",{endpoint:t,url:s,model:r.model});let d=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...i},body:JSON.stringify(r),signal:e.signal});if(!d.ok){let h=await d.text();if(d.status===401)throw console.error("[DeepV Server] Stream 401 Unauthorized - triggering auth dialog"),this.authHandler&&await this.authHandler(),new HI("Authentication required - please re-authenticate");if(d.status===451)throw console.error("[DeepV Server] Stream 451 Region Blocked - IMMEDIATE ABORT"),e.abort(),new Error(`REGION_BLOCKED_451: ${h}`);let o=new Error(`Stream API error (${d.status}): ${h}`);o.status=d.status;let f=d.headers.get("retry-after");throw f&&(o.response={status:d.status,headers:{"retry-after":f}}),o}let I=Date.now()-u;return nr.debug("[DeepV Server] Stream API call initiated",{endpoint:t,duration:`${I}ms`,status:d.status}),d}catch(d){let I=Date.now()-u;throw c&&c(),d instanceof Error&&(d.message.includes("cancelled by user")||d.name==="AbortError")?(console.log("\u26A0\uFE0F \u6D41\u5F0F\u4EFB\u52A1\u5DF2\u53D6\u6D88"),d):(d instanceof Error&&d.message.includes("abort")?nr.warn("[DeepV Server] Stream API aborted",{endpoint:t,duration:`${I}ms`,reason:d.message}):nr.error("[DeepV Server] Stream API call failed",{endpoint:t,duration:`${I}ms`,error:d instanceof Error?d.message:d}),d)}finally{c&&c()}}async*createStreamGenerator(t,r){let a=t.body?.getReader();if(!a)throw new Error("No stream reader available");let i=new TextDecoder,s="",e=0,c=null,u=()=>{console.log("[DeepV Server] Stream cancelled by user - releasing reader and stopping consumption");try{a.cancel()}catch{}},d;r&&!r.aborted&&(d=u,r.addEventListener("abort",d));try{for(;;){if(r?.aborted){console.log("[DeepV Server] Stream generation cancelled by user - exiting loop"),c&&console.log("[DeepV Server] Partial token consumption recorded:",{inputTokens:c.promptTokenCount||0,outputTokens:c.candidatesTokenCount||0,totalTokens:c.totalTokenCount||0,stoppedReason:"user_cancelled",bytesReceived:e});break}let I;try{I=await this.withTimeout(a.read(),3e5,"[DeepV Server] Stream read timeout after 300s (no data received in this chunk)")}catch(E){if(E instanceof Error&&(E.name==="AbortError"||E.message.includes("cancelled"))){console.log("[DeepV Server] Stream read cancelled - exiting");break}throw E}let{done:h,value:o}=I;if(h)break;e+=o.length,s+=i.decode(o,{stream:!0});let f=s.split(`
|
|
661
|
-
`);s=f.pop()||"";for(let E of f)if(E.startsWith("data: ")){let F=E.slice(6);if(F==="[DONE]")return;try{let w=JSON.parse(F);if(w.type==="connection_established")continue;if(w.error)throw new Error(w.error);w.usageMetadata&&(c=w.usageMetadata);let A=this.convertStreamChunkToGenAI(w);A&&(yield A)}catch(w){nr.warn("[DeepV Server] Stream chunk parse error",{data:F.substring(0,100)+"...",error:w instanceof Error?w.message:w})}}}}finally{d&&r&&r.removeEventListener("abort",d);try{a.releaseLock()}catch{}}}convertStreamChunkToGenAI(t){if(!t.candidates||!Array.isArray(t.candidates)||t.candidates.length===0)return null;let r={candidates:t.candidates,usageMetadata:t.usageMetadata};if(r.candidates?.[0]?.content?.parts){for(let a of r.candidates[0].content.parts)if(a.functionCall&&!a.functionCall.id){let i=`call_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;console.log(`[DeepV Server] \u8865\u5168\u7F3A\u5931\u7684\u5DE5\u5177 ID (Chunk): ${a.functionCall.name} -> ${i}`),a.functionCall.id=i}}return r.functionCalls||Object.defineProperty(r,"functionCalls",{get:function(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");let a=this.candidates?.[0]?.content?.parts?.filter(i=>i.functionCall).map(i=>i.functionCall).filter(i=>i!==void 0);if(a?.length!==0)return a},enumerable:!1,configurable:!0}),r}mergeStreamContent(t,r){if(!t)return r;let a=t.candidates?.[0]?.content?.parts||[],i=r.candidates?.[0]?.content?.parts||[];if(i.length>0&&i[0].text){let s=a[a.length-1];s&&s.text&&!s.functionCall?s.text+=i[0].text:a.push(...i)}else if(i.length>0&&i[0].functionCall){let s=a[a.length-1],e=i[0];if(s&&s.functionCall){let c=s.functionCall,u=e.functionCall;u&&(u.name&&(c.name=u.name),u.id&&(c.id=u.id),u.args&&(typeof u.args=="string"&&typeof c.args=="string"?c.args+=u.args:typeof u.args=="object"&&u.args!==null?c.args={...typeof c.args=="object"?c.args:{},...u.args}:c.args=u.args))}else{let c={...e};if(c.functionCall&&!c.functionCall.id){let u=`call_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;console.log(`[DeepV Server] \u8865\u5168\u7F3A\u5931\u7684\u5DE5\u5177 ID: ${c.functionCall.name} -> ${u}`),c.functionCall.id=u}a.push(c)}}return r.usageMetadata&&(t.usageMetadata=r.usageMetadata),r.candidates?.[0]?.finishReason&&(t.candidates[0].finishReason=r.candidates[0].finishReason),t}buildUnifiedRequest(t,r){let a=ad.getModelForScene(r);return{model:t.model||a||"auto",contents:t.contents,config:{...t.config,httpOptions:{...t.config?.httpOptions,headers:{...t.config?.httpOptions?.headers,"X-Scene-Type":r,"X-Scene-Display":ad.getSceneDisplayName(r)}}}}}async*handleStreamError(t){this.handleError(t)}async countTokens(t){try{let r={model:t.model||"auto",contents:t.contents};(t.config?.systemInstruction||t.config?.tools)&&(r.config={},t.config.systemInstruction&&(r.config.systemInstruction=t.config.systemInstruction),t.config.tools&&(r.config.tools=t.config.tools));let a=await this.callUnifiedTokenCountAPI(r);return o2.emitRealTimeToken({inputTokens:a.totalTokens||0,outputTokens:0,totalTokens:a.totalTokens||0,timestamp:Date.now()}),a}catch(r){return nr.error("[DeepV Server] Token count failed:",r),this.estimateTokensAsFailback(t)}}async callUnifiedTokenCountAPI(t){let r=await ms.getUserHeaders(),a=`${ms.getProxyServerUrl()}/v1/chat/count-tokens`;try{let i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(t)});if(!i.ok){let e=await i.text();throw i.status===401?(console.error("[DeepV Server] Token count 401 Unauthorized"),this.authHandler&&await this.authHandler(),new HI("Authentication required - please re-authenticate")):new Error(`Token count API failed (${i.status}): ${e}`)}let s=await i.json();return nr.debug("[DeepV Server] Token count response",{totalTokens:s.totalTokens}),{totalTokens:s.totalTokens||0}}catch(i){throw nr.error("[DeepV Server] Token count API call failed:",i),i}}estimateTokensAsFailback(t){try{let r=Array.isArray(t.contents)?t.contents:[{role:oa.USER,parts:[{text:t.contents}]}],a=0,i=0,s=0,e=0;for(let o of r)if(typeof o=="object"&&o&&"parts"in o&&Array.isArray(o.parts)){for(let f of o.parts)if(typeof f=="object"&&f&&"text"in f&&typeof f.text=="string")a+=f.text.length,e++;else if(typeof f=="object"&&f&&"functionCall"in f&&f.functionCall){let E=f.functionCall,F=`[Tool: ${E.name}]`+JSON.stringify(E.args||{});a+=F.length,i++}else if(typeof f=="object"&&f&&"functionResponse"in f&&f.functionResponse){let w=`[Tool Result: ${f.functionResponse.response?.output||"result"}]`;a+=w.length+20,s++}}else typeof o=="string"&&(a+=o.length,e++);let c=JSON.stringify(r),u=/[\u4e00-\u9fff]/.test(c),d=/```|function|class|import|export|\{|\}|\[|\]/.test(c),I=4;return u?I=2:d&&(I=3),{totalTokens:Math.ceil(a/I)}}catch(r){return console.error("[DeepV Server] Fallback estimation error:",r),{totalTokens:1e3}}}async embedContent(t){throw new Error("Claude models do not support embedding content")}withTimeout(t,r,a){let i=null,s=new Promise((e,c)=>{i=setTimeout(()=>{c(new Error(a))},r)});return Promise.race([t,s]).finally(()=>{i!==null&&clearTimeout(i)})}}});function gFe(n,t){let r=n.getModel()||"auto",a={authType:t,proxy:n?.getProxy()};return t===Vl.USE_PROXY_AUTH,a}async function vFe(n,t,r){let i={headers:{"User-Agent":`GeminiCLI/1.0.267 (${process.platform}; ${process.arch})`}};if(!0){let e=t.getCustomProxyServerUrl(),c;if(e)c=e,console.log(`[DeepX] Using custom proxy server: ${c}`);else{if(!rNe())throw new Error("DeepV Code server is required for all models but is not available. Please start the DeepV Code server or use proxy authentication.");c=G3(),console.log(`[DeepX] Connecting to DeepV Code server: ${c}`)}let u=process.env.GOOGLE_CLOUD_LOCATION||"us-central1",d=process.env.GOOGLE_CLOUD_PROJECT||"default-project";return new EX(u,d,c,t)}throw new Error(`Error creating contentGenerator: Unsupported authType: ${n.authType}`)}var Vl,lie=ct(()=>{"use strict";fFe();JH();(function(n){n.USE_PROXY_AUTH="proxy-auth"})(Vl||(Vl={}))});var sie,D0t=ct(()=>{"use strict";sie=class{prompts=new Map;registerPrompt(t){if(this.prompts.has(t.name)){let r=`${t.serverName}_${t.name}`;console.warn(`Prompt with name "${t.name}" is already registered. Renaming to "${r}".`),this.prompts.set(r,{...t,name:r})}else this.prompts.set(t.name,t)}getAllPrompts(){return Array.from(this.prompts.values()).sort((t,r)=>t.name.localeCompare(r.name))}getPrompt(t){return this.prompts.get(t)}getPromptsByServer(t){let r=[];for(let a of this.prompts.values())a.serverName===t&&r.push(a);return r.sort((a,i)=>a.name.localeCompare(i.name))}removePromptsByServer(t){for(let[r,a]of this.prompts.entries())a.serverName===t&&this.prompts.delete(r)}}});function av(n){let t={type:"subagent_update",data:n,timestamp:Date.now()};return JSON.stringify(t)}function T0t(n){let t={type:"text",data:n,timestamp:Date.now()};return JSON.stringify(t)}function oie(n){try{let t=JSON.parse(n);if(t&&typeof t=="object"&&t.type&&t.data!==void 0)return t}catch{}return{type:"text",data:n,timestamp:Date.now()}}function cie(n){return n.type==="subagent_update"}function Iie(n){return n.type==="text"}var ZFe=ct(()=>{"use strict";});var Br,Jr,Dr,dl=ct(()=>{"use strict";ZFe();Br=class{name;displayName;description;icon;parameterSchema;isOutputMarkdown;forceMarkdown;canUpdateOutput;allowSubAgentUse;constructor(t,r,a,i,s,e=!0,c=!1,u=!1,d=!0){this.name=t,this.displayName=r,this.description=a,this.icon=i,this.parameterSchema=s,this.isOutputMarkdown=e,this.forceMarkdown=c,this.canUpdateOutput=u,this.allowSubAgentUse=d}get schema(){return{name:this.name,description:this.description,parameters:this.parameterSchema}}validateToolParams(t){return null}getDescription(t){return JSON.stringify(t)}shouldConfirmExecute(t,r){return Promise.resolve(!1)}toolLocations(t){return[]}};(function(n){n.ProceedOnce="proceed_once",n.ProceedAlways="proceed_always",n.ProceedAlwaysServer="proceed_always_server",n.ProceedAlwaysTool="proceed_always_tool",n.ProceedAlwaysProject="proceed_always_project",n.ModifyWithEditor="modify_with_editor",n.Cancel="cancel"})(Jr||(Jr={}));(function(n){n.FileSearch="fileSearch",n.Folder="folder",n.Globe="globe",n.Hammer="hammer",n.LightBulb="lightBulb",n.Pencil="pencil",n.Regex="regex",n.Terminal="terminal",n.Clipboard="clipboard",n.Tasks="tasks",n.Wrench="wrench",n.Trash="trash",n.List="list",n.Info="info"})(Dr||(Dr={}))});var hl,NFe,Tr,k3,mO=ct(()=>{(function(n){n.assertEqual=i=>{};function t(i){}n.assertIs=t;function r(i){throw new Error}n.assertNever=r,n.arrayToEnum=i=>{let s={};for(let e of i)s[e]=e;return s},n.getValidEnumValues=i=>{let s=n.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),e={};for(let c of s)e[c]=i[c];return n.objectValues(e)},n.objectValues=i=>n.objectKeys(i).map(function(s){return i[s]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&s.push(e);return s},n.find=(i,s)=>{for(let e of i)if(s(e))return e},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function a(i,s=" | "){return i.map(e=>typeof e=="string"?`'${e}'`:e).join(s)}n.joinValues=a,n.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(hl||(hl={}));(function(n){n.mergeShapes=(t,r)=>({...t,...r})})(NFe||(NFe={}));Tr=hl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),k3=n=>{switch(typeof n){case"undefined":return Tr.undefined;case"string":return Tr.string;case"number":return Number.isNaN(n)?Tr.nan:Tr.number;case"boolean":return Tr.boolean;case"function":return Tr.function;case"bigint":return Tr.bigint;case"symbol":return Tr.symbol;case"object":return Array.isArray(n)?Tr.array:n===null?Tr.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Tr.promise:typeof Map<"u"&&n instanceof Map?Tr.map:typeof Set<"u"&&n instanceof Set?Tr.set:typeof Date<"u"&&n instanceof Date?Tr.date:Tr.object;default:return Tr.unknown}}});var mr,I7n,G2,uie=ct(()=>{mO();mr=hl.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"]),I7n=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),G2=class n extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(s){return s.message},a={_errors:[]},i=s=>{for(let e of s.issues)if(e.code==="invalid_union")e.unionErrors.map(i);else if(e.code==="invalid_return_type")i(e.returnTypeError);else if(e.code==="invalid_arguments")i(e.argumentsError);else if(e.path.length===0)a._errors.push(r(e));else{let c=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(r(e))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}};return i(this),a}static assert(t){if(!(t instanceof n))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,hl.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},a=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];r[s]=r[s]||[],r[s].push(t(i))}else a.push(t(i));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}};G2.create=n=>new G2(n)});var u7n,pA,WFe=ct(()=>{uie();mO();u7n=(n,t)=>{let r;switch(n.code){case mr.invalid_type:n.received===Tr.undefined?r="Required":r=`Expected ${n.expected}, received ${n.received}`;break;case mr.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(n.expected,hl.jsonStringifyReplacer)}`;break;case mr.unrecognized_keys:r=`Unrecognized key(s) in object: ${hl.joinValues(n.keys,", ")}`;break;case mr.invalid_union:r="Invalid input";break;case mr.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${hl.joinValues(n.options)}`;break;case mr.invalid_enum_value:r=`Invalid enum value. Expected ${hl.joinValues(n.options)}, received '${n.received}'`;break;case mr.invalid_arguments:r="Invalid function arguments";break;case mr.invalid_return_type:r="Invalid function return type";break;case mr.invalid_date:r="Invalid date";break;case mr.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(r=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?r=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?r=`Invalid input: must end with "${n.validation.endsWith}"`:hl.assertNever(n.validation):n.validation!=="regex"?r=`Invalid ${n.validation}`:r="Invalid";break;case mr.too_small:n.type==="array"?r=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?r=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?r=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?r=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?r=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:r="Invalid input";break;case mr.too_big:n.type==="array"?r=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?r=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?r=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?r=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?r=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:r="Invalid input";break;case mr.custom:r="Invalid input";break;case mr.invalid_intersection_types:r="Intersection results could not be merged";break;case mr.not_multiple_of:r=`Number must be a multiple of ${n.multipleOf}`;break;case mr.not_finite:r="Number must be finite";break;default:r=t.defaultError,hl.assertNever(n)}return{message:r}},pA=u7n});function d7n(n){O0t=n}function wX(){return O0t}var O0t,die=ct(()=>{WFe();O0t=pA});function Qr(n,t){let r=wX(),a=pO({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,r,r===pA?void 0:pA].filter(i=>!!i)});n.common.issues.push(a)}var pO,h7n,k0,ka,uC,Qh,hie,mie,Jy,CX,AFe=ct(()=>{die();WFe();pO=n=>{let{data:t,path:r,errorMaps:a,issueData:i}=n,s=[...r,...i.path||[]],e={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="",u=a.filter(d=>!!d).slice().reverse();for(let d of u)c=d(e,{data:t,defaultError:c}).message;return{...i,path:s,message:c}},h7n=[];k0=class n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let a=[];for(let i of r){if(i.status==="aborted")return ka;i.status==="dirty"&&t.dirty(),a.push(i.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,r){let a=[];for(let i of r){let s=await i.key,e=await i.value;a.push({key:s,value:e})}return n.mergeObjectSync(t,a)}static mergeObjectSync(t,r){let a={};for(let i of r){let{key:s,value:e}=i;if(s.status==="aborted"||e.status==="aborted")return ka;s.status==="dirty"&&t.dirty(),e.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof e.value<"u"||i.alwaysSet)&&(a[s.value]=e.value)}return{status:t.value,value:a}}},ka=Object.freeze({status:"aborted"}),uC=n=>({status:"dirty",value:n}),Qh=n=>({status:"valid",value:n}),hie=n=>n.status==="aborted",mie=n=>n.status==="dirty",Jy=n=>n.status==="valid",CX=n=>typeof Promise<"u"&&n instanceof Promise});var U0t=ct(()=>{});var Ia,M0t=ct(()=>{(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t?.message})(Ia||(Ia={}))});function Ei(n){if(!n)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:i}=n;if(t&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(e,c)=>{let{message:u}=n;return e.code==="invalid_enum_value"?{message:u??c.defaultError}:typeof c.data>"u"?{message:u??a??c.defaultError}:e.code!=="invalid_type"?{message:c.defaultError}:{message:u??r??c.defaultError}},description:i}}function j0t(n){let t="[0-5]\\d";n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`);let r=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function C7n(n){return new RegExp(`^${j0t(n)}$`)}function K0t(n){let t=`${P0t}T${j0t(n)}`,r=[];return r.push(n.local?"Z?":"Z"),n.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Y7n(n,t){return!!((t==="v4"||!t)&&W7n.test(n)||(t==="v6"||!t)&&F7n.test(n))}function x7n(n,t){if(!g7n.test(n))return!1;try{let[r]=n.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(a));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function V7n(n,t){return!!((t==="v4"||!t)&&A7n.test(n)||(t==="v6"||!t)&&y7n.test(n))}function Q7n(n,t){let r=(n.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a,s=Number.parseInt(n.toFixed(i).replace(".","")),e=Number.parseInt(t.toFixed(i).replace(".",""));return s%e/10**i}function YX(n){if(n instanceof f2){let t={};for(let r in n.shape){let a=n.shape[r];t[r]=U1.create(YX(a))}return new f2({...n._def,shape:()=>t})}else return n instanceof fA?new fA({...n._def,type:YX(n.element)}):n instanceof U1?U1.create(YX(n.unwrap())):n instanceof J3?J3.create(YX(n.unwrap())):n instanceof L3?L3.create(n.items.map(t=>YX(t))):n}function yFe(n,t){let r=k3(n),a=k3(t);if(n===t)return{valid:!0,data:n};if(r===Tr.object&&a===Tr.object){let i=hl.objectKeys(t),s=hl.objectKeys(n).filter(c=>i.indexOf(c)!==-1),e={...n,...t};for(let c of s){let u=yFe(n[c],t[c]);if(!u.valid)return{valid:!1};e[c]=u.data}return{valid:!0,data:e}}else if(r===Tr.array&&a===Tr.array){if(n.length!==t.length)return{valid:!1};let i=[];for(let s=0;s<n.length;s++){let e=n[s],c=t[s],u=yFe(e,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===Tr.date&&a===Tr.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}function q0t(n,t){return new NC({values:n,typeName:Ta.ZodEnum,...Ei(t)})}function _0t(n,t){let r=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof r=="string"?{message:r}:r}function $0t(n,t={},r){return n?By.create().superRefine((a,i)=>{let s=n(a);if(s instanceof Promise)return s.then(e=>{if(!e){let c=_0t(t,a),u=c.fatal??r??!0;i.addIssue({code:"custom",...c,fatal:u})}});if(!s){let e=_0t(t,a),c=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:c})}}):By.create()}var M1,z0t,Di,m7n,p7n,b7n,G7n,f7n,g7n,v7n,Z7n,N7n,FFe,W7n,A7n,F7n,y7n,R7n,E7n,P0t,w7n,Sy,dC,hC,mC,pC,xX,bC,GC,By,GA,iv,VX,fA,f2,fC,bA,pie,gC,L3,bie,QX,HX,Gie,vC,ZC,NC,WC,Dy,z1,U1,J3,AC,FC,XX,H7n,bO,GO,yC,X7n,Ta,k7n,eht,tht,L7n,J7n,nht,S7n,B7n,D7n,T7n,O7n,U7n,M7n,z7n,_7n,P7n,j7n,K7n,q7n,$7n,eDn,tDn,nDn,rDn,aDn,iDn,lDn,sDn,oDn,cDn,IDn,uDn,dDn,hDn,mDn,pDn,bDn,GDn,fDn,gDn,rht=ct(()=>{uie();die();M0t();AFe();mO();M1=class{constructor(t,r,a,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=a,this._key=i}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}},z0t=(n,t)=>{if(Jy(t))return{success:!0,data:t.value};if(!n.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 G2(n.common.issues);return this._error=r,this._error}}};Di=class{get description(){return this._def.description}_getType(t){return k3(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:k3(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new k0,ctx:{common:t.parent.common,data:t.data,parsedType:k3(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(CX(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let a=this.safeParse(t,r);if(a.success)return a.data;throw a.error}safeParse(t,r){let a={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:k3(t)},i=this._parseSync({data:t,path:a.path,parent:a});return z0t(a,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:k3(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:r});return Jy(a)?{value:a.value}:{issues:r.common.issues}}catch(a){a?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(a=>Jy(a)?{value:a.value}:{issues:r.common.issues})}async parseAsync(t,r){let a=await this.safeParseAsync(t,r);if(a.success)return a.data;throw a.error}async safeParseAsync(t,r){let a={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:k3(t)},i=this._parse({data:t,path:a.path,parent:a}),s=await(CX(i)?i:Promise.resolve(i));return z0t(a,s)}refine(t,r){let a=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,s)=>{let e=t(i),c=()=>s.addIssue({code:mr.custom,...a(i)});return typeof Promise<"u"&&e instanceof Promise?e.then(u=>u?!0:(c(),!1)):e?!0:(c(),!1)})}refinement(t,r){return this._refinement((a,i)=>t(a)?!0:(i.addIssue(typeof r=="function"?r(a,i):r),!1))}_refinement(t){return new z1({schema:this,typeName:Ta.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return U1.create(this,this._def)}nullable(){return J3.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return fA.create(this)}promise(){return Dy.create(this,this._def)}or(t){return fC.create([this,t],this._def)}and(t){return gC.create(this,t,this._def)}transform(t){return new z1({...Ei(this._def),schema:this,typeName:Ta.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new AC({...Ei(this._def),innerType:this,defaultValue:r,typeName:Ta.ZodDefault})}brand(){return new bO({typeName:Ta.ZodBranded,type:this,...Ei(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new FC({...Ei(this._def),innerType:this,catchValue:r,typeName:Ta.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return GO.create(this,t)}readonly(){return yC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},m7n=/^c[^\s-]{8,}$/i,p7n=/^[0-9a-z]+$/,b7n=/^[0-9A-HJKMNP-TV-Z]{26}$/i,G7n=/^[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,f7n=/^[a-z0-9_-]{21}$/i,g7n=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,v7n=/^[-+]?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)?)??$/,Z7n=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,N7n="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",W7n=/^(?:(?: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])$/,A7n=/^(?:(?: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])$/,F7n=/^(([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]))$/,y7n=/^(([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])$/,R7n=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,E7n=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,P0t="((\\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])))",w7n=new RegExp(`^${P0t}$`);Sy=class n extends Di{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Tr.string){let s=this._getOrReturnCtx(t);return Qr(s,{code:mr.invalid_type,expected:Tr.string,received:s.parsedType}),ka}let a=new k0,i;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="length"){let e=t.data.length>s.value,c=t.data.length<s.value;(e||c)&&(i=this._getOrReturnCtx(t,i),e?Qr(i,{code:mr.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&Qr(i,{code:mr.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")Z7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"email",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")FFe||(FFe=new RegExp(N7n,"u")),FFe.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"emoji",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")G7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"uuid",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")f7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"nanoid",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")m7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"cuid",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")p7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"cuid2",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")b7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"ulid",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Qr(i,{validation:"url",code:mr.invalid_string,message:s.message}),a.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"regex",code:mr.invalid_string,message:s.message}),a.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?K0t(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?w7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?C7n(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?v7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"duration",code:mr.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?Y7n(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"ip",code:mr.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?x7n(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"jwt",code:mr.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?V7n(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"cidr",code:mr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?R7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"base64",code:mr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?E7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"base64url",code:mr.invalid_string,message:s.message}),a.dirty()):hl.assertNever(s);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(i=>t.test(i),{validation:r,code:mr.invalid_string,...Ia.errToObj(a)})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ia.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ia.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ia.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ia.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ia.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ia.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ia.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ia.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ia.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ia.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ia.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ia.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ia.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...Ia.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...Ia.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Ia.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Ia.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Ia.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Ia.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Ia.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Ia.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Ia.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Ia.errToObj(r)})}nonempty(t){return this.min(1,Ia.errToObj(t))}trim(){return new n({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Sy.create=n=>new Sy({checks:[],typeName:Ta.ZodString,coerce:n?.coerce??!1,...Ei(n)});dC=class n extends Di{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Tr.number){let s=this._getOrReturnCtx(t);return Qr(s,{code:mr.invalid_type,expected:Tr.number,received:s.parsedType}),ka}let a,i=new k0;for(let s of this._def.checks)s.kind==="int"?hl.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Q7n(t.data,s.value)!==0&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.not_finite,message:s.message}),i.dirty()):hl.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Ia.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Ia.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Ia.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Ia.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:Ia.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ia.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ia.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ia.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ia.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ia.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Ia.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Ia.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ia.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ia.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&hl.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(r)&&Number.isFinite(t)}};dC.create=n=>new dC({checks:[],typeName:Ta.ZodNumber,coerce:n?.coerce||!1,...Ei(n)});hC=class n extends Di{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Tr.bigint)return this._getInvalidInput(t);let a,i=new k0;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):hl.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return Qr(r,{code:mr.invalid_type,expected:Tr.bigint,received:r.parsedType}),ka}gte(t,r){return this.setLimit("min",t,!0,Ia.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Ia.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Ia.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Ia.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:Ia.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ia.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ia.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ia.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ia.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Ia.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};hC.create=n=>new hC({checks:[],typeName:Ta.ZodBigInt,coerce:n?.coerce??!1,...Ei(n)});mC=class extends Di{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Tr.boolean){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.boolean,received:a.parsedType}),ka}return Qh(t.data)}};mC.create=n=>new mC({typeName:Ta.ZodBoolean,coerce:n?.coerce||!1,...Ei(n)});pC=class n extends Di{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Tr.date){let s=this._getOrReturnCtx(t);return Qr(s,{code:mr.invalid_type,expected:Tr.date,received:s.parsedType}),ka}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return Qr(s,{code:mr.invalid_date}),ka}let a=new k0,i;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):hl.assertNever(s);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Ia.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Ia.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};pC.create=n=>new pC({checks:[],coerce:n?.coerce||!1,typeName:Ta.ZodDate,...Ei(n)});xX=class extends Di{_parse(t){if(this._getType(t)!==Tr.symbol){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.symbol,received:a.parsedType}),ka}return Qh(t.data)}};xX.create=n=>new xX({typeName:Ta.ZodSymbol,...Ei(n)});bC=class extends Di{_parse(t){if(this._getType(t)!==Tr.undefined){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.undefined,received:a.parsedType}),ka}return Qh(t.data)}};bC.create=n=>new bC({typeName:Ta.ZodUndefined,...Ei(n)});GC=class extends Di{_parse(t){if(this._getType(t)!==Tr.null){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.null,received:a.parsedType}),ka}return Qh(t.data)}};GC.create=n=>new GC({typeName:Ta.ZodNull,...Ei(n)});By=class extends Di{constructor(){super(...arguments),this._any=!0}_parse(t){return Qh(t.data)}};By.create=n=>new By({typeName:Ta.ZodAny,...Ei(n)});GA=class extends Di{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Qh(t.data)}};GA.create=n=>new GA({typeName:Ta.ZodUnknown,...Ei(n)});iv=class extends Di{_parse(t){let r=this._getOrReturnCtx(t);return Qr(r,{code:mr.invalid_type,expected:Tr.never,received:r.parsedType}),ka}};iv.create=n=>new iv({typeName:Ta.ZodNever,...Ei(n)});VX=class extends Di{_parse(t){if(this._getType(t)!==Tr.undefined){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.void,received:a.parsedType}),ka}return Qh(t.data)}};VX.create=n=>new VX({typeName:Ta.ZodVoid,...Ei(n)});fA=class n extends Di{_parse(t){let{ctx:r,status:a}=this._processInputParams(t),i=this._def;if(r.parsedType!==Tr.array)return Qr(r,{code:mr.invalid_type,expected:Tr.array,received:r.parsedType}),ka;if(i.exactLength!==null){let e=r.data.length>i.exactLength.value,c=r.data.length<i.exactLength.value;(e||c)&&(Qr(r,{code:e?mr.too_big:mr.too_small,minimum:c?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),a.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(Qr(r,{code:mr.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),a.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(Qr(r,{code:mr.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((e,c)=>i.type._parseAsync(new M1(r,e,r.path,c)))).then(e=>k0.mergeArray(a,e));let s=[...r.data].map((e,c)=>i.type._parseSync(new M1(r,e,r.path,c)));return k0.mergeArray(a,s)}get element(){return this._def.type}min(t,r){return new n({...this._def,minLength:{value:t,message:Ia.toString(r)}})}max(t,r){return new n({...this._def,maxLength:{value:t,message:Ia.toString(r)}})}length(t,r){return new n({...this._def,exactLength:{value:t,message:Ia.toString(r)}})}nonempty(t){return this.min(1,t)}};fA.create=(n,t)=>new fA({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Ta.ZodArray,...Ei(t)});f2=class n extends Di{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=hl.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Tr.object){let d=this._getOrReturnCtx(t);return Qr(d,{code:mr.invalid_type,expected:Tr.object,received:d.parsedType}),ka}let{status:a,ctx:i}=this._processInputParams(t),{shape:s,keys:e}=this._getCached(),c=[];if(!(this._def.catchall instanceof iv&&this._def.unknownKeys==="strip"))for(let d in i.data)e.includes(d)||c.push(d);let u=[];for(let d of e){let I=s[d],h=i.data[d];u.push({key:{status:"valid",value:d},value:I._parse(new M1(i,h,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof iv){let d=this._def.unknownKeys;if(d==="passthrough")for(let I of c)u.push({key:{status:"valid",value:I},value:{status:"valid",value:i.data[I]}});else if(d==="strict")c.length>0&&(Qr(i,{code:mr.unrecognized_keys,keys:c}),a.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let I of c){let h=i.data[I];u.push({key:{status:"valid",value:I},value:d._parse(new M1(i,h,i.path,I)),alwaysSet:I in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let d=[];for(let I of u){let h=await I.key,o=await I.value;d.push({key:h,value:o,alwaysSet:I.alwaysSet})}return d}).then(d=>k0.mergeObjectSync(a,d)):k0.mergeObjectSync(a,u)}get shape(){return this._def.shape()}strict(t){return Ia.errToObj,new n({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,a)=>{let i=this._def.errorMap?.(r,a).message??a.defaultError;return r.code==="unrecognized_keys"?{message:Ia.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new n({...this._def,unknownKeys:"strip"})}passthrough(){return new n({...this._def,unknownKeys:"passthrough"})}extend(t){return new n({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new n({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ta.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new n({...this._def,catchall:t})}pick(t){let r={};for(let a of hl.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}omit(t){let r={};for(let a of hl.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}deepPartial(){return YX(this)}partial(t){let r={};for(let a of hl.objectKeys(this.shape)){let i=this.shape[a];t&&!t[a]?r[a]=i:r[a]=i.optional()}return new n({...this._def,shape:()=>r})}required(t){let r={};for(let a of hl.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof U1;)s=s._def.innerType;r[a]=s}return new n({...this._def,shape:()=>r})}keyof(){return q0t(hl.objectKeys(this.shape))}};f2.create=(n,t)=>new f2({shape:()=>n,unknownKeys:"strip",catchall:iv.create(),typeName:Ta.ZodObject,...Ei(t)});f2.strictCreate=(n,t)=>new f2({shape:()=>n,unknownKeys:"strict",catchall:iv.create(),typeName:Ta.ZodObject,...Ei(t)});f2.lazycreate=(n,t)=>new f2({shape:n,unknownKeys:"strip",catchall:iv.create(),typeName:Ta.ZodObject,...Ei(t)});fC=class extends Di{_parse(t){let{ctx:r}=this._processInputParams(t),a=this._def.options;function i(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let e=s.map(c=>new G2(c.ctx.common.issues));return Qr(r,{code:mr.invalid_union,unionErrors:e}),ka}if(r.common.async)return Promise.all(a.map(async s=>{let e={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:e}),ctx:e}})).then(i);{let s,e=[];for(let u of a){let d={...r,common:{...r.common,issues:[]},parent:null},I=u._parseSync({data:r.data,path:r.path,parent:d});if(I.status==="valid")return I;I.status==="dirty"&&!s&&(s={result:I,ctx:d}),d.common.issues.length&&e.push(d.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let c=e.map(u=>new G2(u));return Qr(r,{code:mr.invalid_union,unionErrors:c}),ka}}get options(){return this._def.options}};fC.create=(n,t)=>new fC({options:n,typeName:Ta.ZodUnion,...Ei(t)});bA=n=>n instanceof vC?bA(n.schema):n instanceof z1?bA(n.innerType()):n instanceof ZC?[n.value]:n instanceof NC?n.options:n instanceof WC?hl.objectValues(n.enum):n instanceof AC?bA(n._def.innerType):n instanceof bC?[void 0]:n instanceof GC?[null]:n instanceof U1?[void 0,...bA(n.unwrap())]:n instanceof J3?[null,...bA(n.unwrap())]:n instanceof bO||n instanceof yC?bA(n.unwrap()):n instanceof FC?bA(n._def.innerType):[],pie=class n extends Di{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Tr.object)return Qr(r,{code:mr.invalid_type,expected:Tr.object,received:r.parsedType}),ka;let a=this.discriminator,i=r.data[a],s=this.optionsMap.get(i);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(Qr(r,{code:mr.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),ka)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,a){let i=new Map;for(let s of r){let e=bA(s.shape[t]);if(!e.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let c of e){if(i.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);i.set(c,s)}}return new n({typeName:Ta.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Ei(a)})}};gC=class extends Di{_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=(s,e)=>{if(hie(s)||hie(e))return ka;let c=yFe(s.value,e.value);return c.valid?((mie(s)||mie(e))&&r.dirty(),{status:r.value,value:c.data}):(Qr(a,{code:mr.invalid_intersection_types}),ka)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([s,e])=>i(s,e)):i(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};gC.create=(n,t,r)=>new gC({left:n,right:t,typeName:Ta.ZodIntersection,...Ei(r)});L3=class n extends Di{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Tr.array)return Qr(a,{code:mr.invalid_type,expected:Tr.array,received:a.parsedType}),ka;if(a.data.length<this._def.items.length)return Qr(a,{code:mr.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ka;!this._def.rest&&a.data.length>this._def.items.length&&(Qr(a,{code:mr.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...a.data].map((e,c)=>{let u=this._def.items[c]||this._def.rest;return u?u._parse(new M1(a,e,a.path,c)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>k0.mergeArray(r,e)):k0.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new n({...this._def,rest:t})}};L3.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new L3({items:n,typeName:Ta.ZodTuple,rest:null,...Ei(t)})};bie=class n extends Di{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Tr.object)return Qr(a,{code:mr.invalid_type,expected:Tr.object,received:a.parsedType}),ka;let i=[],s=this._def.keyType,e=this._def.valueType;for(let c in a.data)i.push({key:s._parse(new M1(a,c,a.path,c)),value:e._parse(new M1(a,a.data[c],a.path,c)),alwaysSet:c in a.data});return a.common.async?k0.mergeObjectAsync(r,i):k0.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof Di?new n({keyType:t,valueType:r,typeName:Ta.ZodRecord,...Ei(a)}):new n({keyType:Sy.create(),valueType:t,typeName:Ta.ZodRecord,...Ei(r)})}},QX=class extends Di{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Tr.map)return Qr(a,{code:mr.invalid_type,expected:Tr.map,received:a.parsedType}),ka;let i=this._def.keyType,s=this._def.valueType,e=[...a.data.entries()].map(([c,u],d)=>({key:i._parse(new M1(a,c,a.path,[d,"key"])),value:s._parse(new M1(a,u,a.path,[d,"value"]))}));if(a.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let u of e){let d=await u.key,I=await u.value;if(d.status==="aborted"||I.status==="aborted")return ka;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),c.set(d.value,I.value)}return{status:r.value,value:c}})}else{let c=new Map;for(let u of e){let d=u.key,I=u.value;if(d.status==="aborted"||I.status==="aborted")return ka;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),c.set(d.value,I.value)}return{status:r.value,value:c}}}};QX.create=(n,t,r)=>new QX({valueType:t,keyType:n,typeName:Ta.ZodMap,...Ei(r)});HX=class n extends Di{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Tr.set)return Qr(a,{code:mr.invalid_type,expected:Tr.set,received:a.parsedType}),ka;let i=this._def;i.minSize!==null&&a.data.size<i.minSize.value&&(Qr(a,{code:mr.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&a.data.size>i.maxSize.value&&(Qr(a,{code:mr.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let s=this._def.valueType;function e(u){let d=new Set;for(let I of u){if(I.status==="aborted")return ka;I.status==="dirty"&&r.dirty(),d.add(I.value)}return{status:r.value,value:d}}let c=[...a.data.values()].map((u,d)=>s._parse(new M1(a,u,a.path,d)));return a.common.async?Promise.all(c).then(u=>e(u)):e(c)}min(t,r){return new n({...this._def,minSize:{value:t,message:Ia.toString(r)}})}max(t,r){return new n({...this._def,maxSize:{value:t,message:Ia.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};HX.create=(n,t)=>new HX({valueType:n,minSize:null,maxSize:null,typeName:Ta.ZodSet,...Ei(t)});Gie=class n extends Di{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Tr.function)return Qr(r,{code:mr.invalid_type,expected:Tr.function,received:r.parsedType}),ka;function a(c,u){return pO({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,wX(),pA].filter(d=>!!d),issueData:{code:mr.invalid_arguments,argumentsError:u}})}function i(c,u){return pO({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,wX(),pA].filter(d=>!!d),issueData:{code:mr.invalid_return_type,returnTypeError:u}})}let s={errorMap:r.common.contextualErrorMap},e=r.data;if(this._def.returns instanceof Dy){let c=this;return Qh(async function(...u){let d=new G2([]),I=await c._def.args.parseAsync(u,s).catch(f=>{throw d.addIssue(a(u,f)),d}),h=await Reflect.apply(e,this,I);return await c._def.returns._def.type.parseAsync(h,s).catch(f=>{throw d.addIssue(i(h,f)),d})})}else{let c=this;return Qh(function(...u){let d=c._def.args.safeParse(u,s);if(!d.success)throw new G2([a(u,d.error)]);let I=Reflect.apply(e,this,d.data),h=c._def.returns.safeParse(I,s);if(!h.success)throw new G2([i(I,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new n({...this._def,args:L3.create(t).rest(GA.create())})}returns(t){return new n({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,a){return new n({args:t||L3.create([]).rest(GA.create()),returns:r||GA.create(),typeName:Ta.ZodFunction,...Ei(a)})}},vC=class extends Di{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};vC.create=(n,t)=>new vC({getter:n,typeName:Ta.ZodLazy,...Ei(t)});ZC=class extends Di{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return Qr(r,{received:r.data,code:mr.invalid_literal,expected:this._def.value}),ka}return{status:"valid",value:t.data}}get value(){return this._def.value}};ZC.create=(n,t)=>new ZC({value:n,typeName:Ta.ZodLiteral,...Ei(t)});NC=class n extends Di{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),a=this._def.values;return Qr(r,{expected:hl.joinValues(a),received:r.parsedType,code:mr.invalid_type}),ka}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),a=this._def.values;return Qr(r,{received:r.data,code:mr.invalid_enum_value,options:a}),ka}return Qh(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return n.create(t,{...this._def,...r})}exclude(t,r=this._def){return n.create(this.options.filter(a=>!t.includes(a)),{...this._def,...r})}};NC.create=q0t;WC=class extends Di{_parse(t){let r=hl.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==Tr.string&&a.parsedType!==Tr.number){let i=hl.objectValues(r);return Qr(a,{expected:hl.joinValues(i),received:a.parsedType,code:mr.invalid_type}),ka}if(this._cache||(this._cache=new Set(hl.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=hl.objectValues(r);return Qr(a,{received:a.data,code:mr.invalid_enum_value,options:i}),ka}return Qh(t.data)}get enum(){return this._def.values}};WC.create=(n,t)=>new WC({values:n,typeName:Ta.ZodNativeEnum,...Ei(t)});Dy=class extends Di{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Tr.promise&&r.common.async===!1)return Qr(r,{code:mr.invalid_type,expected:Tr.promise,received:r.parsedType}),ka;let a=r.parsedType===Tr.promise?r.data:Promise.resolve(r.data);return Qh(a.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Dy.create=(n,t)=>new Dy({type:n,typeName:Ta.ZodPromise,...Ei(t)});z1=class extends Di{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ta.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:e=>{Qr(a,e),e.fatal?r.abort():r.dirty()},get path(){return a.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let e=i.transform(a.data,s);if(a.common.async)return Promise.resolve(e).then(async c=>{if(r.value==="aborted")return ka;let u=await this._def.schema._parseAsync({data:c,path:a.path,parent:a});return u.status==="aborted"?ka:u.status==="dirty"?uC(u.value):r.value==="dirty"?uC(u.value):u});{if(r.value==="aborted")return ka;let c=this._def.schema._parseSync({data:e,path:a.path,parent:a});return c.status==="aborted"?ka:c.status==="dirty"?uC(c.value):r.value==="dirty"?uC(c.value):c}}if(i.type==="refinement"){let e=c=>{let u=i.refinement(c,s);if(a.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(a.common.async===!1){let c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return c.status==="aborted"?ka:(c.status==="dirty"&&r.dirty(),e(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>c.status==="aborted"?ka:(c.status==="dirty"&&r.dirty(),e(c.value).then(()=>({status:r.value,value:c.value}))))}if(i.type==="transform")if(a.common.async===!1){let e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Jy(e))return ka;let c=i.transform(e.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(e=>Jy(e)?Promise.resolve(i.transform(e.value,s)).then(c=>({status:r.value,value:c})):ka);hl.assertNever(i)}};z1.create=(n,t,r)=>new z1({schema:n,typeName:Ta.ZodEffects,effect:t,...Ei(r)});z1.createWithPreprocess=(n,t,r)=>new z1({schema:t,effect:{type:"preprocess",transform:n},typeName:Ta.ZodEffects,...Ei(r)});U1=class extends Di{_parse(t){return this._getType(t)===Tr.undefined?Qh(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};U1.create=(n,t)=>new U1({innerType:n,typeName:Ta.ZodOptional,...Ei(t)});J3=class extends Di{_parse(t){return this._getType(t)===Tr.null?Qh(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};J3.create=(n,t)=>new J3({innerType:n,typeName:Ta.ZodNullable,...Ei(t)});AC=class extends Di{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return r.parsedType===Tr.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};AC.create=(n,t)=>new AC({innerType:n,typeName:Ta.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ei(t)});FC=class extends Di{_parse(t){let{ctx:r}=this._processInputParams(t),a={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return CX(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new G2(a.common.issues)},input:a.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new G2(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};FC.create=(n,t)=>new FC({innerType:n,typeName:Ta.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ei(t)});XX=class extends Di{_parse(t){if(this._getType(t)!==Tr.nan){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.nan,received:a.parsedType}),ka}return{status:"valid",value:t.data}}};XX.create=n=>new XX({typeName:Ta.ZodNaN,...Ei(n)});H7n=Symbol("zod_brand"),bO=class extends Di{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}},GO=class n extends Di{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?ka:s.status==="dirty"?(r.dirty(),uC(s.value)):this._def.out._parseAsync({data:s.value,path:a.path,parent:a})})();{let i=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?ka:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:a.path,parent:a})}}static create(t,r){return new n({in:t,out:r,typeName:Ta.ZodPipeline})}},yC=class extends Di{_parse(t){let r=this._def.innerType._parse(t),a=i=>(Jy(i)&&(i.value=Object.freeze(i.value)),i);return CX(r)?r.then(i=>a(i)):a(r)}unwrap(){return this._def.innerType}};yC.create=(n,t)=>new yC({innerType:n,typeName:Ta.ZodReadonly,...Ei(t)});X7n={object:f2.lazycreate};(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Ta||(Ta={}));k7n=(n,t={message:`Input not instance of ${n.name}`})=>$0t(r=>r instanceof n,t),eht=Sy.create,tht=dC.create,L7n=XX.create,J7n=hC.create,nht=mC.create,S7n=pC.create,B7n=xX.create,D7n=bC.create,T7n=GC.create,O7n=By.create,U7n=GA.create,M7n=iv.create,z7n=VX.create,_7n=fA.create,P7n=f2.create,j7n=f2.strictCreate,K7n=fC.create,q7n=pie.create,$7n=gC.create,eDn=L3.create,tDn=bie.create,nDn=QX.create,rDn=HX.create,aDn=Gie.create,iDn=vC.create,lDn=ZC.create,sDn=NC.create,oDn=WC.create,cDn=Dy.create,IDn=z1.create,uDn=U1.create,dDn=J3.create,hDn=z1.createWithPreprocess,mDn=GO.create,pDn=()=>eht().optional(),bDn=()=>tht().optional(),GDn=()=>nht().optional(),fDn={string:(n=>Sy.create({...n,coerce:!0})),number:(n=>dC.create({...n,coerce:!0})),boolean:(n=>mC.create({...n,coerce:!0})),bigint:(n=>hC.create({...n,coerce:!0})),date:(n=>pC.create({...n,coerce:!0}))},gDn=ka});var zc={};so(zc,{BRAND:()=>H7n,DIRTY:()=>uC,EMPTY_PATH:()=>h7n,INVALID:()=>ka,NEVER:()=>gDn,OK:()=>Qh,ParseStatus:()=>k0,Schema:()=>Di,ZodAny:()=>By,ZodArray:()=>fA,ZodBigInt:()=>hC,ZodBoolean:()=>mC,ZodBranded:()=>bO,ZodCatch:()=>FC,ZodDate:()=>pC,ZodDefault:()=>AC,ZodDiscriminatedUnion:()=>pie,ZodEffects:()=>z1,ZodEnum:()=>NC,ZodError:()=>G2,ZodFirstPartyTypeKind:()=>Ta,ZodFunction:()=>Gie,ZodIntersection:()=>gC,ZodIssueCode:()=>mr,ZodLazy:()=>vC,ZodLiteral:()=>ZC,ZodMap:()=>QX,ZodNaN:()=>XX,ZodNativeEnum:()=>WC,ZodNever:()=>iv,ZodNull:()=>GC,ZodNullable:()=>J3,ZodNumber:()=>dC,ZodObject:()=>f2,ZodOptional:()=>U1,ZodParsedType:()=>Tr,ZodPipeline:()=>GO,ZodPromise:()=>Dy,ZodReadonly:()=>yC,ZodRecord:()=>bie,ZodSchema:()=>Di,ZodSet:()=>HX,ZodString:()=>Sy,ZodSymbol:()=>xX,ZodTransformer:()=>z1,ZodTuple:()=>L3,ZodType:()=>Di,ZodUndefined:()=>bC,ZodUnion:()=>fC,ZodUnknown:()=>GA,ZodVoid:()=>VX,addIssueToContext:()=>Qr,any:()=>O7n,array:()=>_7n,bigint:()=>J7n,boolean:()=>nht,coerce:()=>fDn,custom:()=>$0t,date:()=>S7n,datetimeRegex:()=>K0t,defaultErrorMap:()=>pA,discriminatedUnion:()=>q7n,effect:()=>IDn,enum:()=>sDn,function:()=>aDn,getErrorMap:()=>wX,getParsedType:()=>k3,instanceof:()=>k7n,intersection:()=>$7n,isAborted:()=>hie,isAsync:()=>CX,isDirty:()=>mie,isValid:()=>Jy,late:()=>X7n,lazy:()=>iDn,literal:()=>lDn,makeIssue:()=>pO,map:()=>nDn,nan:()=>L7n,nativeEnum:()=>oDn,never:()=>M7n,null:()=>T7n,nullable:()=>dDn,number:()=>tht,object:()=>P7n,objectUtil:()=>NFe,oboolean:()=>GDn,onumber:()=>bDn,optional:()=>uDn,ostring:()=>pDn,pipeline:()=>mDn,preprocess:()=>hDn,promise:()=>cDn,quotelessJson:()=>I7n,record:()=>tDn,set:()=>rDn,setErrorMap:()=>d7n,strictObject:()=>j7n,string:()=>eht,symbol:()=>B7n,transformer:()=>IDn,tuple:()=>eDn,undefined:()=>D7n,union:()=>K7n,unknown:()=>U7n,util:()=>hl,void:()=>z7n});var RFe=ct(()=>{die();AFe();U0t();mO();rht();uie()});function Ln(n,t,r){function a(c,u){var d;Object.defineProperty(c,"_zod",{value:c._zod??{},enumerable:!1}),(d=c._zod).traits??(d.traits=new Set),c._zod.traits.add(n),t(c,u);for(let I in e.prototype)I in c||Object.defineProperty(c,I,{value:e.prototype[I].bind(c)});c._zod.constr=e,c._zod.def=u}let i=r?.Parent??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function e(c){var u;let d=r?.Parent?new s:this;a(d,c),(u=d._zod).deferred??(u.deferred=[]);for(let I of d._zod.deferred)I();return d}return Object.defineProperty(e,"init",{value:a}),Object.defineProperty(e,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(n)}),Object.defineProperty(e,"name",{value:n}),e}function aG(n){return n&&Object.assign(fie,n),fie}var EFe,vDn,gA,fie,kX=ct(()=>{EFe=Object.freeze({status:"aborted"});vDn=Symbol("zod_brand"),gA=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},fie={}});var ps={};so(ps,{BIGINT_FORMAT_RANGES:()=>iht,Class:()=>CFe,NUMBER_FORMAT_RANGES:()=>LFe,aborted:()=>EC,allowsEval:()=>HFe,assert:()=>FDn,assertEqual:()=>ZDn,assertIs:()=>WDn,assertNever:()=>ADn,assertNotEqual:()=>NDn,assignProp:()=>QFe,cached:()=>gO,captureStackTrace:()=>vie,cleanEnum:()=>LDn,cleanRegex:()=>ZO,clone:()=>lv,createTransparentProxy:()=>YDn,defineLazy:()=>Uo,esc:()=>RC,escapeRegex:()=>Ty,extend:()=>QDn,finalizeIssue:()=>sv,floatSafeRemainder:()=>VFe,getElementAtPath:()=>yDn,getEnumValues:()=>YFe,getLengthableOrigin:()=>NO,getParsedType:()=>CDn,getSizableOrigin:()=>lht,isObject:()=>LX,isPlainObject:()=>JX,issue:()=>JFe,joinValues:()=>gie,jsonStringifyReplacer:()=>xFe,merge:()=>HDn,normalizeParams:()=>Wa,nullish:()=>vO,numKeys:()=>wDn,omit:()=>VDn,optionalKeys:()=>kFe,partial:()=>XDn,pick:()=>xDn,prefixIssues:()=>S3,primitiveTypes:()=>aht,promiseAllObject:()=>RDn,propertyKeyTypes:()=>XFe,randomString:()=>EDn,required:()=>kDn,stringifyPrimitive:()=>Zie,unwrapMessage:()=>fO});function ZDn(n){return n}function NDn(n){return n}function WDn(n){}function ADn(n){throw new Error}function FDn(n){}function YFe(n){let t=Object.values(n).filter(a=>typeof a=="number");return Object.entries(n).filter(([a,i])=>t.indexOf(+a)===-1).map(([a,i])=>i)}function gie(n,t="|"){return n.map(r=>Zie(r)).join(t)}function xFe(n,t){return typeof t=="bigint"?t.toString():t}function gO(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function vO(n){return n==null}function ZO(n){let t=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(t,r)}function VFe(n,t){let r=(n.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a,s=Number.parseInt(n.toFixed(i).replace(".","")),e=Number.parseInt(t.toFixed(i).replace(".",""));return s%e/10**i}function Uo(n,t,r){Object.defineProperty(n,t,{get(){{let i=r();return n[t]=i,i}throw new Error("cached value already set")},set(i){Object.defineProperty(n,t,{value:i})},configurable:!0})}function QFe(n,t,r){Object.defineProperty(n,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function yDn(n,t){return t?t.reduce((r,a)=>r?.[a],n):n}function RDn(n){let t=Object.keys(n),r=t.map(a=>n[a]);return Promise.all(r).then(a=>{let i={};for(let s=0;s<t.length;s++)i[t[s]]=a[s];return i})}function EDn(n=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<n;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function RC(n){return JSON.stringify(n)}function LX(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function JX(n){if(LX(n)===!1)return!1;let t=n.constructor;if(t===void 0)return!0;let r=t.prototype;return!(LX(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function wDn(n){let t=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&t++;return t}function Ty(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lv(n,t,r){let a=new n._zod.constr(t??n._zod.def);return(!t||r?.parent)&&(a._zod.parent=n),a}function Wa(n){let t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function YDn(n){let t;return new Proxy({},{get(r,a,i){return t??(t=n()),Reflect.get(t,a,i)},set(r,a,i,s){return t??(t=n()),Reflect.set(t,a,i,s)},has(r,a){return t??(t=n()),Reflect.has(t,a)},deleteProperty(r,a){return t??(t=n()),Reflect.deleteProperty(t,a)},ownKeys(r){return t??(t=n()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,a){return t??(t=n()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(r,a,i){return t??(t=n()),Reflect.defineProperty(t,a,i)}})}function Zie(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function kFe(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}function xDn(n,t){let r={},a=n._zod.def;for(let i in t){if(!(i in a.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=a.shape[i])}return lv(n,{...n._zod.def,shape:r,checks:[]})}function VDn(n,t){let r={...n._zod.def.shape},a=n._zod.def;for(let i in t){if(!(i in a.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return lv(n,{...n._zod.def,shape:r,checks:[]})}function QDn(n,t){if(!JX(t))throw new Error("Invalid input to extend: expected a plain object");let r={...n._zod.def,get shape(){let a={...n._zod.def.shape,...t};return QFe(this,"shape",a),a},checks:[]};return lv(n,r)}function HDn(n,t){return lv(n,{...n._zod.def,get shape(){let r={...n._zod.def.shape,...t._zod.def.shape};return QFe(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function XDn(n,t,r){let a=t._zod.def.shape,i={...a};if(r)for(let s in r){if(!(s in a))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=n?new n({type:"optional",innerType:a[s]}):a[s])}else for(let s in a)i[s]=n?new n({type:"optional",innerType:a[s]}):a[s];return lv(t,{...t._zod.def,shape:i,checks:[]})}function kDn(n,t,r){let a=t._zod.def.shape,i={...a};if(r)for(let s in r){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=new n({type:"nonoptional",innerType:a[s]}))}else for(let s in a)i[s]=new n({type:"nonoptional",innerType:a[s]});return lv(t,{...t._zod.def,shape:i,checks:[]})}function EC(n,t=0){for(let r=t;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function S3(n,t){return t.map(r=>{var a;return(a=r).path??(a.path=[]),r.path.unshift(n),r})}function fO(n){return typeof n=="string"?n:n?.message}function sv(n,t,r){let a={...n,path:n.path??[]};if(!n.message){let i=fO(n.inst?._zod.def?.error?.(n))??fO(t?.error?.(n))??fO(r.customError?.(n))??fO(r.localeError?.(n))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function lht(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function NO(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function JFe(...n){let[t,r,a]=n;return typeof t=="string"?{message:t,code:"custom",input:r,inst:a}:{...t}}function LDn(n){return Object.entries(n).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var vie,HFe,CDn,XFe,aht,LFe,iht,CFe,vA=ct(()=>{vie=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};HFe=gO(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});CDn=n=>{let t=typeof n;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},XFe=new Set(["string","number","symbol"]),aht=new Set(["string","number","bigint","boolean","symbol","undefined"]);LFe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},iht={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};CFe=class{constructor(...t){}}});function BFe(n,t=r=>r.message){let r={},a=[];for(let i of n.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:r}}function DFe(n,t){let r=t||function(s){return s.message},a={_errors:[]},i=s=>{for(let e of s.issues)if(e.code==="invalid_union"&&e.errors.length)e.errors.map(c=>i({issues:c}));else if(e.code==="invalid_key")i({issues:e.issues});else if(e.code==="invalid_element")i({issues:e.issues});else if(e.path.length===0)a._errors.push(r(e));else{let c=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(r(e))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}};return i(n),a}var sht,Nie,SFe,TFe=ct(()=>{kX();vA();sht=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),Object.defineProperty(n,"message",{get(){return JSON.stringify(t,xFe,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Nie=Ln("$ZodError",sht),SFe=Ln("$ZodError",sht,{Parent:Error})});var oht,cht,OFe,WO,UFe,Wie,MFe=ct(()=>{kX();TFe();vA();oht=n=>(t,r,a,i)=>{let s=a?Object.assign(a,{async:!1}):{async:!1},e=t._zod.run({value:r,issues:[]},s);if(e instanceof Promise)throw new gA;if(e.issues.length){let c=new(i?.Err??n)(e.issues.map(u=>sv(u,s,aG())));throw vie(c,i?.callee),c}return e.value},cht=n=>async(t,r,a,i)=>{let s=a?Object.assign(a,{async:!0}):{async:!0},e=t._zod.run({value:r,issues:[]},s);if(e instanceof Promise&&(e=await e),e.issues.length){let c=new(i?.Err??n)(e.issues.map(u=>sv(u,s,aG())));throw vie(c,i?.callee),c}return e.value},OFe=n=>(t,r,a)=>{let i=a?{...a,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new gA;return s.issues.length?{success:!1,error:new(n??Nie)(s.issues.map(e=>sv(e,i,aG())))}:{success:!0,data:s.value}},WO=OFe(SFe),UFe=n=>async(t,r,a)=>{let i=a?Object.assign(a,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(e=>sv(e,i,aG())))}:{success:!0,data:s.value}},Wie=UFe(SFe)});function ght(){return new RegExp(SDn,"u")}function wht(n){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Cht(n){return new RegExp(`^${wht(n)}$`)}function Yht(n){let t=wht({precision:n.precision}),r=["Z"];n.local&&r.push(""),n.offset&&r.push("([+-]\\d{2}:\\d{2})");let a=`${t}(?:${r.join("|")})`;return new RegExp(`^${Rht}T(?:${a})$`)}var Iht,uht,dht,hht,mht,pht,bht,Ght,zFe,fht,SDn,vht,Zht,Nht,Wht,Aht,_Fe,Fht,yht,Rht,Eht,xht,Vht,Qht,Hht,Xht,kht,Lht,Jht,Fie=ct(()=>{Iht=/^[cC][^\s-]{8,}$/,uht=/^[0-9a-z]+$/,dht=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hht=/^[0-9a-vA-V]{20}$/,mht=/^[A-Za-z0-9]{27}$/,pht=/^[a-zA-Z0-9_-]{21}$/,bht=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ght=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zFe=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,fht=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,SDn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";vht=/^(?:(?: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])$/,Zht=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Nht=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Wht=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Aht=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,_Fe=/^[A-Za-z0-9_-]*$/,Fht=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,yht=/^\+(?:[0-9]){6,14}[0-9]$/,Rht="(?:(?:\\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])))",Eht=new RegExp(`^${Rht}$`);xht=n=>{let t=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Vht=/^\d+n?$/,Qht=/^\d+$/,Hht=/^-?\d+(?:\.\d+)?/i,Xht=/true|false/i,kht=/null/i,Lht=/^[^A-Z]*$/,Jht=/^[^a-z]*$/});var Hh,Sht,PFe,jFe,Bht,Dht,Tht,Oht,Uht,AO,Mht,zht,_ht,Pht,jht,Kht,qht,yie=ct(()=>{kX();Fie();vA();Hh=Ln("$ZodCheck",(n,t)=>{var r;n._zod??(n._zod={}),n._zod.def=t,(r=n._zod).onattach??(r.onattach=[])}),Sht={number:"number",bigint:"bigint",object:"date"},PFe=Ln("$ZodCheckLessThan",(n,t)=>{Hh.init(n,t);let r=Sht[typeof t.value];n._zod.onattach.push(a=>{let i=a._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),n._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:r,code:"too_big",maximum:t.value,input:a.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),jFe=Ln("$ZodCheckGreaterThan",(n,t)=>{Hh.init(n,t);let r=Sht[typeof t.value];n._zod.onattach.push(a=>{let i=a._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),n._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:r,code:"too_small",minimum:t.value,input:a.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),Bht=Ln("$ZodCheckMultipleOf",(n,t)=>{Hh.init(n,t),n._zod.onattach.push(r=>{var a;(a=r._zod.bag).multipleOf??(a.multipleOf=t.value)}),n._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):VFe(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:n,continue:!t.abort})}}),Dht=Ln("$ZodCheckNumberFormat",(n,t)=>{Hh.init(n,t),t.format=t.format||"float64";let r=t.format?.includes("int"),a=r?"int":"number",[i,s]=LFe[t.format];n._zod.onattach.push(e=>{let c=e._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,r&&(c.pattern=Qht)}),n._zod.check=e=>{let c=e.value;if(r){if(!Number.isInteger(c)){e.issues.push({expected:a,format:t.format,code:"invalid_type",input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?e.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:a,continue:!t.abort}):e.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:a,continue:!t.abort});return}}c<i&&e.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&e.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:n})}}),Tht=Ln("$ZodCheckMaxLength",(n,t)=>{var r;Hh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!vO(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(a._zod.bag.maximum=t.maximum)}),n._zod.check=a=>{let i=a.value;if(i.length<=t.maximum)return;let e=NO(i);a.issues.push({origin:e,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),Oht=Ln("$ZodCheckMinLength",(n,t)=>{var r;Hh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!vO(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(a._zod.bag.minimum=t.minimum)}),n._zod.check=a=>{let i=a.value;if(i.length>=t.minimum)return;let e=NO(i);a.issues.push({origin:e,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),Uht=Ln("$ZodCheckLengthEquals",(n,t)=>{var r;Hh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!vO(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),n._zod.check=a=>{let i=a.value,s=i.length;if(s===t.length)return;let e=NO(i),c=s>t.length;a.issues.push({origin:e,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:n,continue:!t.abort})}}),AO=Ln("$ZodCheckStringFormat",(n,t)=>{var r,a;Hh.init(n,t),n._zod.onattach.push(i=>{let s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=n._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:n,continue:!t.abort})}):(a=n._zod).check??(a.check=()=>{})}),Mht=Ln("$ZodCheckRegex",(n,t)=>{AO.init(n,t),n._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:n,continue:!t.abort})}}),zht=Ln("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=Lht),AO.init(n,t)}),_ht=Ln("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=Jht),AO.init(n,t)}),Pht=Ln("$ZodCheckIncludes",(n,t)=>{Hh.init(n,t);let r=Ty(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=a,n._zod.onattach.push(i=>{let s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(a)}),n._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:n,continue:!t.abort})}}),jht=Ln("$ZodCheckStartsWith",(n,t)=>{Hh.init(n,t);let r=new RegExp(`^${Ty(t.prefix)}.*`);t.pattern??(t.pattern=r),n._zod.onattach.push(a=>{let i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),n._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:n,continue:!t.abort})}}),Kht=Ln("$ZodCheckEndsWith",(n,t)=>{Hh.init(n,t);let r=new RegExp(`.*${Ty(t.suffix)}$`);t.pattern??(t.pattern=r),n._zod.onattach.push(a=>{let i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),n._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:n,continue:!t.abort})}}),qht=Ln("$ZodCheckOverwrite",(n,t)=>{Hh.init(n,t),n._zod.check=r=>{r.value=t.tx(r.value)}})});var Rie,KFe=ct(()=>{Rie=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let a=t.split(`
|
|
661
|
+
`);s=f.pop()||"";for(let E of f)if(E.startsWith("data: ")){let F=E.slice(6);if(F==="[DONE]")return;try{let w=JSON.parse(F);if(w.type==="connection_established")continue;if(w.error)throw new Error(w.error);w.usageMetadata&&(c=w.usageMetadata);let A=this.convertStreamChunkToGenAI(w);A&&(yield A)}catch(w){nr.warn("[DeepV Server] Stream chunk parse error",{data:F.substring(0,100)+"...",error:w instanceof Error?w.message:w})}}}}finally{d&&r&&r.removeEventListener("abort",d);try{a.releaseLock()}catch{}}}convertStreamChunkToGenAI(t){if(!t.candidates||!Array.isArray(t.candidates)||t.candidates.length===0)return null;let r={candidates:t.candidates,usageMetadata:t.usageMetadata};if(r.candidates?.[0]?.content?.parts){for(let a of r.candidates[0].content.parts)if(a.functionCall&&!a.functionCall.id){let i=`call_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;console.log(`[DeepV Server] \u8865\u5168\u7F3A\u5931\u7684\u5DE5\u5177 ID (Chunk): ${a.functionCall.name} -> ${i}`),a.functionCall.id=i}}return r.functionCalls||Object.defineProperty(r,"functionCalls",{get:function(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning function calls from the first one.");let a=this.candidates?.[0]?.content?.parts?.filter(i=>i.functionCall).map(i=>i.functionCall).filter(i=>i!==void 0);if(a?.length!==0)return a},enumerable:!1,configurable:!0}),r}mergeStreamContent(t,r){if(!t)return r;let a=t.candidates?.[0]?.content?.parts||[],i=r.candidates?.[0]?.content?.parts||[];if(i.length>0&&i[0].text){let s=a[a.length-1];s&&s.text&&!s.functionCall?s.text+=i[0].text:a.push(...i)}else if(i.length>0&&i[0].functionCall){let s=a[a.length-1],e=i[0];if(s&&s.functionCall){let c=s.functionCall,u=e.functionCall;u&&(u.name&&(c.name=u.name),u.id&&(c.id=u.id),u.args&&(typeof u.args=="string"&&typeof c.args=="string"?c.args+=u.args:typeof u.args=="object"&&u.args!==null?c.args={...typeof c.args=="object"?c.args:{},...u.args}:c.args=u.args))}else{let c={...e};if(c.functionCall&&!c.functionCall.id){let u=`call_${Date.now()}_${Math.random().toString(36).substring(2,9)}`;console.log(`[DeepV Server] \u8865\u5168\u7F3A\u5931\u7684\u5DE5\u5177 ID: ${c.functionCall.name} -> ${u}`),c.functionCall.id=u}a.push(c)}}return r.usageMetadata&&(t.usageMetadata=r.usageMetadata),r.candidates?.[0]?.finishReason&&(t.candidates[0].finishReason=r.candidates[0].finishReason),t}buildUnifiedRequest(t,r){let a=ad.getModelForScene(r);return{model:t.model||a||"auto",contents:t.contents,config:{...t.config,httpOptions:{...t.config?.httpOptions,headers:{...t.config?.httpOptions?.headers,"X-Scene-Type":r,"X-Scene-Display":ad.getSceneDisplayName(r)}}}}}async*handleStreamError(t){this.handleError(t)}async countTokens(t){try{let r={model:t.model||"auto",contents:t.contents};(t.config?.systemInstruction||t.config?.tools)&&(r.config={},t.config.systemInstruction&&(r.config.systemInstruction=t.config.systemInstruction),t.config.tools&&(r.config.tools=t.config.tools));let a=await this.callUnifiedTokenCountAPI(r);return o2.emitRealTimeToken({inputTokens:a.totalTokens||0,outputTokens:0,totalTokens:a.totalTokens||0,timestamp:Date.now()}),a}catch(r){return nr.error("[DeepV Server] Token count failed:",r),this.estimateTokensAsFailback(t)}}async callUnifiedTokenCountAPI(t){let r=await ms.getUserHeaders(),a=`${ms.getProxyServerUrl()}/v1/chat/count-tokens`;try{let i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(t)});if(!i.ok){let e=await i.text();throw i.status===401?(console.error("[DeepV Server] Token count 401 Unauthorized"),this.authHandler&&await this.authHandler(),new HI("Authentication required - please re-authenticate")):new Error(`Token count API failed (${i.status}): ${e}`)}let s=await i.json();return nr.debug("[DeepV Server] Token count response",{totalTokens:s.totalTokens}),{totalTokens:s.totalTokens||0}}catch(i){throw nr.error("[DeepV Server] Token count API call failed:",i),i}}estimateTokensAsFailback(t){try{let r=Array.isArray(t.contents)?t.contents:[{role:oa.USER,parts:[{text:t.contents}]}],a=0,i=0,s=0,e=0;for(let o of r)if(typeof o=="object"&&o&&"parts"in o&&Array.isArray(o.parts)){for(let f of o.parts)if(typeof f=="object"&&f&&"text"in f&&typeof f.text=="string")a+=f.text.length,e++;else if(typeof f=="object"&&f&&"functionCall"in f&&f.functionCall){let E=f.functionCall,F=`[Tool: ${E.name}]`+JSON.stringify(E.args||{});a+=F.length,i++}else if(typeof f=="object"&&f&&"functionResponse"in f&&f.functionResponse){let w=`[Tool Result: ${f.functionResponse.response?.output||"result"}]`;a+=w.length+20,s++}}else typeof o=="string"&&(a+=o.length,e++);let c=JSON.stringify(r),u=/[\u4e00-\u9fff]/.test(c),d=/```|function|class|import|export|\{|\}|\[|\]/.test(c),I=4;return u?I=2:d&&(I=3),{totalTokens:Math.ceil(a/I)}}catch(r){return console.error("[DeepV Server] Fallback estimation error:",r),{totalTokens:1e3}}}async embedContent(t){throw new Error("Claude models do not support embedding content")}withTimeout(t,r,a){let i=null,s=new Promise((e,c)=>{i=setTimeout(()=>{c(new Error(a))},r)});return Promise.race([t,s]).finally(()=>{i!==null&&clearTimeout(i)})}}});function gFe(n,t){let r=n.getModel()||"auto",a={authType:t,proxy:n?.getProxy()};return t===Vl.USE_PROXY_AUTH,a}async function vFe(n,t,r){let i={headers:{"User-Agent":`GeminiCLI/1.0.268 (${process.platform}; ${process.arch})`}};if(!0){let e=t.getCustomProxyServerUrl(),c;if(e)c=e,console.log(`[DeepX] Using custom proxy server: ${c}`);else{if(!rNe())throw new Error("DeepV Code server is required for all models but is not available. Please start the DeepV Code server or use proxy authentication.");c=G3(),console.log(`[DeepX] Connecting to DeepV Code server: ${c}`)}let u=process.env.GOOGLE_CLOUD_LOCATION||"us-central1",d=process.env.GOOGLE_CLOUD_PROJECT||"default-project";return new EX(u,d,c,t)}throw new Error(`Error creating contentGenerator: Unsupported authType: ${n.authType}`)}var Vl,lie=ct(()=>{"use strict";fFe();JH();(function(n){n.USE_PROXY_AUTH="proxy-auth"})(Vl||(Vl={}))});var sie,D0t=ct(()=>{"use strict";sie=class{prompts=new Map;registerPrompt(t){if(this.prompts.has(t.name)){let r=`${t.serverName}_${t.name}`;console.warn(`Prompt with name "${t.name}" is already registered. Renaming to "${r}".`),this.prompts.set(r,{...t,name:r})}else this.prompts.set(t.name,t)}getAllPrompts(){return Array.from(this.prompts.values()).sort((t,r)=>t.name.localeCompare(r.name))}getPrompt(t){return this.prompts.get(t)}getPromptsByServer(t){let r=[];for(let a of this.prompts.values())a.serverName===t&&r.push(a);return r.sort((a,i)=>a.name.localeCompare(i.name))}removePromptsByServer(t){for(let[r,a]of this.prompts.entries())a.serverName===t&&this.prompts.delete(r)}}});function av(n){let t={type:"subagent_update",data:n,timestamp:Date.now()};return JSON.stringify(t)}function T0t(n){let t={type:"text",data:n,timestamp:Date.now()};return JSON.stringify(t)}function oie(n){try{let t=JSON.parse(n);if(t&&typeof t=="object"&&t.type&&t.data!==void 0)return t}catch{}return{type:"text",data:n,timestamp:Date.now()}}function cie(n){return n.type==="subagent_update"}function Iie(n){return n.type==="text"}var ZFe=ct(()=>{"use strict";});var Br,Jr,Dr,dl=ct(()=>{"use strict";ZFe();Br=class{name;displayName;description;icon;parameterSchema;isOutputMarkdown;forceMarkdown;canUpdateOutput;allowSubAgentUse;constructor(t,r,a,i,s,e=!0,c=!1,u=!1,d=!0){this.name=t,this.displayName=r,this.description=a,this.icon=i,this.parameterSchema=s,this.isOutputMarkdown=e,this.forceMarkdown=c,this.canUpdateOutput=u,this.allowSubAgentUse=d}get schema(){return{name:this.name,description:this.description,parameters:this.parameterSchema}}validateToolParams(t){return null}getDescription(t){return JSON.stringify(t)}shouldConfirmExecute(t,r){return Promise.resolve(!1)}toolLocations(t){return[]}};(function(n){n.ProceedOnce="proceed_once",n.ProceedAlways="proceed_always",n.ProceedAlwaysServer="proceed_always_server",n.ProceedAlwaysTool="proceed_always_tool",n.ProceedAlwaysProject="proceed_always_project",n.ModifyWithEditor="modify_with_editor",n.Cancel="cancel"})(Jr||(Jr={}));(function(n){n.FileSearch="fileSearch",n.Folder="folder",n.Globe="globe",n.Hammer="hammer",n.LightBulb="lightBulb",n.Pencil="pencil",n.Regex="regex",n.Terminal="terminal",n.Clipboard="clipboard",n.Tasks="tasks",n.Wrench="wrench",n.Trash="trash",n.List="list",n.Info="info"})(Dr||(Dr={}))});var hl,NFe,Tr,k3,mO=ct(()=>{(function(n){n.assertEqual=i=>{};function t(i){}n.assertIs=t;function r(i){throw new Error}n.assertNever=r,n.arrayToEnum=i=>{let s={};for(let e of i)s[e]=e;return s},n.getValidEnumValues=i=>{let s=n.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),e={};for(let c of s)e[c]=i[c];return n.objectValues(e)},n.objectValues=i=>n.objectKeys(i).map(function(s){return i[s]}),n.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&s.push(e);return s},n.find=(i,s)=>{for(let e of i)if(s(e))return e},n.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function a(i,s=" | "){return i.map(e=>typeof e=="string"?`'${e}'`:e).join(s)}n.joinValues=a,n.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(hl||(hl={}));(function(n){n.mergeShapes=(t,r)=>({...t,...r})})(NFe||(NFe={}));Tr=hl.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),k3=n=>{switch(typeof n){case"undefined":return Tr.undefined;case"string":return Tr.string;case"number":return Number.isNaN(n)?Tr.nan:Tr.number;case"boolean":return Tr.boolean;case"function":return Tr.function;case"bigint":return Tr.bigint;case"symbol":return Tr.symbol;case"object":return Array.isArray(n)?Tr.array:n===null?Tr.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?Tr.promise:typeof Map<"u"&&n instanceof Map?Tr.map:typeof Set<"u"&&n instanceof Set?Tr.set:typeof Date<"u"&&n instanceof Date?Tr.date:Tr.object;default:return Tr.unknown}}});var mr,I7n,G2,uie=ct(()=>{mO();mr=hl.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"]),I7n=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),G2=class n extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(s){return s.message},a={_errors:[]},i=s=>{for(let e of s.issues)if(e.code==="invalid_union")e.unionErrors.map(i);else if(e.code==="invalid_return_type")i(e.returnTypeError);else if(e.code==="invalid_arguments")i(e.argumentsError);else if(e.path.length===0)a._errors.push(r(e));else{let c=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(r(e))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}};return i(this),a}static assert(t){if(!(t instanceof n))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,hl.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},a=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];r[s]=r[s]||[],r[s].push(t(i))}else a.push(t(i));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}};G2.create=n=>new G2(n)});var u7n,pA,WFe=ct(()=>{uie();mO();u7n=(n,t)=>{let r;switch(n.code){case mr.invalid_type:n.received===Tr.undefined?r="Required":r=`Expected ${n.expected}, received ${n.received}`;break;case mr.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(n.expected,hl.jsonStringifyReplacer)}`;break;case mr.unrecognized_keys:r=`Unrecognized key(s) in object: ${hl.joinValues(n.keys,", ")}`;break;case mr.invalid_union:r="Invalid input";break;case mr.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${hl.joinValues(n.options)}`;break;case mr.invalid_enum_value:r=`Invalid enum value. Expected ${hl.joinValues(n.options)}, received '${n.received}'`;break;case mr.invalid_arguments:r="Invalid function arguments";break;case mr.invalid_return_type:r="Invalid function return type";break;case mr.invalid_date:r="Invalid date";break;case mr.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(r=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?r=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?r=`Invalid input: must end with "${n.validation.endsWith}"`:hl.assertNever(n.validation):n.validation!=="regex"?r=`Invalid ${n.validation}`:r="Invalid";break;case mr.too_small:n.type==="array"?r=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?r=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?r=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="bigint"?r=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?r=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:r="Invalid input";break;case mr.too_big:n.type==="array"?r=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?r=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?r=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?r=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?r=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:r="Invalid input";break;case mr.custom:r="Invalid input";break;case mr.invalid_intersection_types:r="Intersection results could not be merged";break;case mr.not_multiple_of:r=`Number must be a multiple of ${n.multipleOf}`;break;case mr.not_finite:r="Number must be finite";break;default:r=t.defaultError,hl.assertNever(n)}return{message:r}},pA=u7n});function d7n(n){O0t=n}function wX(){return O0t}var O0t,die=ct(()=>{WFe();O0t=pA});function Qr(n,t){let r=wX(),a=pO({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,r,r===pA?void 0:pA].filter(i=>!!i)});n.common.issues.push(a)}var pO,h7n,k0,ka,uC,Qh,hie,mie,Jy,CX,AFe=ct(()=>{die();WFe();pO=n=>{let{data:t,path:r,errorMaps:a,issueData:i}=n,s=[...r,...i.path||[]],e={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="",u=a.filter(d=>!!d).slice().reverse();for(let d of u)c=d(e,{data:t,defaultError:c}).message;return{...i,path:s,message:c}},h7n=[];k0=class n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let a=[];for(let i of r){if(i.status==="aborted")return ka;i.status==="dirty"&&t.dirty(),a.push(i.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,r){let a=[];for(let i of r){let s=await i.key,e=await i.value;a.push({key:s,value:e})}return n.mergeObjectSync(t,a)}static mergeObjectSync(t,r){let a={};for(let i of r){let{key:s,value:e}=i;if(s.status==="aborted"||e.status==="aborted")return ka;s.status==="dirty"&&t.dirty(),e.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof e.value<"u"||i.alwaysSet)&&(a[s.value]=e.value)}return{status:t.value,value:a}}},ka=Object.freeze({status:"aborted"}),uC=n=>({status:"dirty",value:n}),Qh=n=>({status:"valid",value:n}),hie=n=>n.status==="aborted",mie=n=>n.status==="dirty",Jy=n=>n.status==="valid",CX=n=>typeof Promise<"u"&&n instanceof Promise});var U0t=ct(()=>{});var Ia,M0t=ct(()=>{(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t?.message})(Ia||(Ia={}))});function Ei(n){if(!n)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:i}=n;if(t&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(e,c)=>{let{message:u}=n;return e.code==="invalid_enum_value"?{message:u??c.defaultError}:typeof c.data>"u"?{message:u??a??c.defaultError}:e.code!=="invalid_type"?{message:c.defaultError}:{message:u??r??c.defaultError}},description:i}}function j0t(n){let t="[0-5]\\d";n.precision?t=`${t}\\.\\d{${n.precision}}`:n.precision==null&&(t=`${t}(\\.\\d+)?`);let r=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function C7n(n){return new RegExp(`^${j0t(n)}$`)}function K0t(n){let t=`${P0t}T${j0t(n)}`,r=[];return r.push(n.local?"Z?":"Z"),n.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function Y7n(n,t){return!!((t==="v4"||!t)&&W7n.test(n)||(t==="v6"||!t)&&F7n.test(n))}function x7n(n,t){if(!g7n.test(n))return!1;try{let[r]=n.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(a));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function V7n(n,t){return!!((t==="v4"||!t)&&A7n.test(n)||(t==="v6"||!t)&&y7n.test(n))}function Q7n(n,t){let r=(n.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a,s=Number.parseInt(n.toFixed(i).replace(".","")),e=Number.parseInt(t.toFixed(i).replace(".",""));return s%e/10**i}function YX(n){if(n instanceof f2){let t={};for(let r in n.shape){let a=n.shape[r];t[r]=U1.create(YX(a))}return new f2({...n._def,shape:()=>t})}else return n instanceof fA?new fA({...n._def,type:YX(n.element)}):n instanceof U1?U1.create(YX(n.unwrap())):n instanceof J3?J3.create(YX(n.unwrap())):n instanceof L3?L3.create(n.items.map(t=>YX(t))):n}function yFe(n,t){let r=k3(n),a=k3(t);if(n===t)return{valid:!0,data:n};if(r===Tr.object&&a===Tr.object){let i=hl.objectKeys(t),s=hl.objectKeys(n).filter(c=>i.indexOf(c)!==-1),e={...n,...t};for(let c of s){let u=yFe(n[c],t[c]);if(!u.valid)return{valid:!1};e[c]=u.data}return{valid:!0,data:e}}else if(r===Tr.array&&a===Tr.array){if(n.length!==t.length)return{valid:!1};let i=[];for(let s=0;s<n.length;s++){let e=n[s],c=t[s],u=yFe(e,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===Tr.date&&a===Tr.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}function q0t(n,t){return new NC({values:n,typeName:Ta.ZodEnum,...Ei(t)})}function _0t(n,t){let r=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof r=="string"?{message:r}:r}function $0t(n,t={},r){return n?By.create().superRefine((a,i)=>{let s=n(a);if(s instanceof Promise)return s.then(e=>{if(!e){let c=_0t(t,a),u=c.fatal??r??!0;i.addIssue({code:"custom",...c,fatal:u})}});if(!s){let e=_0t(t,a),c=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:c})}}):By.create()}var M1,z0t,Di,m7n,p7n,b7n,G7n,f7n,g7n,v7n,Z7n,N7n,FFe,W7n,A7n,F7n,y7n,R7n,E7n,P0t,w7n,Sy,dC,hC,mC,pC,xX,bC,GC,By,GA,iv,VX,fA,f2,fC,bA,pie,gC,L3,bie,QX,HX,Gie,vC,ZC,NC,WC,Dy,z1,U1,J3,AC,FC,XX,H7n,bO,GO,yC,X7n,Ta,k7n,eht,tht,L7n,J7n,nht,S7n,B7n,D7n,T7n,O7n,U7n,M7n,z7n,_7n,P7n,j7n,K7n,q7n,$7n,eDn,tDn,nDn,rDn,aDn,iDn,lDn,sDn,oDn,cDn,IDn,uDn,dDn,hDn,mDn,pDn,bDn,GDn,fDn,gDn,rht=ct(()=>{uie();die();M0t();AFe();mO();M1=class{constructor(t,r,a,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=a,this._key=i}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}},z0t=(n,t)=>{if(Jy(t))return{success:!0,data:t.value};if(!n.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 G2(n.common.issues);return this._error=r,this._error}}};Di=class{get description(){return this._def.description}_getType(t){return k3(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:k3(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new k0,ctx:{common:t.parent.common,data:t.data,parsedType:k3(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(CX(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let a=this.safeParse(t,r);if(a.success)return a.data;throw a.error}safeParse(t,r){let a={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:k3(t)},i=this._parseSync({data:t,path:a.path,parent:a});return z0t(a,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:k3(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:r});return Jy(a)?{value:a.value}:{issues:r.common.issues}}catch(a){a?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(a=>Jy(a)?{value:a.value}:{issues:r.common.issues})}async parseAsync(t,r){let a=await this.safeParseAsync(t,r);if(a.success)return a.data;throw a.error}async safeParseAsync(t,r){let a={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:k3(t)},i=this._parse({data:t,path:a.path,parent:a}),s=await(CX(i)?i:Promise.resolve(i));return z0t(a,s)}refine(t,r){let a=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,s)=>{let e=t(i),c=()=>s.addIssue({code:mr.custom,...a(i)});return typeof Promise<"u"&&e instanceof Promise?e.then(u=>u?!0:(c(),!1)):e?!0:(c(),!1)})}refinement(t,r){return this._refinement((a,i)=>t(a)?!0:(i.addIssue(typeof r=="function"?r(a,i):r),!1))}_refinement(t){return new z1({schema:this,typeName:Ta.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return U1.create(this,this._def)}nullable(){return J3.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return fA.create(this)}promise(){return Dy.create(this,this._def)}or(t){return fC.create([this,t],this._def)}and(t){return gC.create(this,t,this._def)}transform(t){return new z1({...Ei(this._def),schema:this,typeName:Ta.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new AC({...Ei(this._def),innerType:this,defaultValue:r,typeName:Ta.ZodDefault})}brand(){return new bO({typeName:Ta.ZodBranded,type:this,...Ei(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new FC({...Ei(this._def),innerType:this,catchValue:r,typeName:Ta.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return GO.create(this,t)}readonly(){return yC.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},m7n=/^c[^\s-]{8,}$/i,p7n=/^[0-9a-z]+$/,b7n=/^[0-9A-HJKMNP-TV-Z]{26}$/i,G7n=/^[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,f7n=/^[a-z0-9_-]{21}$/i,g7n=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,v7n=/^[-+]?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)?)??$/,Z7n=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,N7n="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",W7n=/^(?:(?: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])$/,A7n=/^(?:(?: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])$/,F7n=/^(([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]))$/,y7n=/^(([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])$/,R7n=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,E7n=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,P0t="((\\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])))",w7n=new RegExp(`^${P0t}$`);Sy=class n extends Di{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Tr.string){let s=this._getOrReturnCtx(t);return Qr(s,{code:mr.invalid_type,expected:Tr.string,received:s.parsedType}),ka}let a=new k0,i;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="length"){let e=t.data.length>s.value,c=t.data.length<s.value;(e||c)&&(i=this._getOrReturnCtx(t,i),e?Qr(i,{code:mr.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&Qr(i,{code:mr.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")Z7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"email",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")FFe||(FFe=new RegExp(N7n,"u")),FFe.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"emoji",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")G7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"uuid",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")f7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"nanoid",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")m7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"cuid",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")p7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"cuid2",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")b7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"ulid",code:mr.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Qr(i,{validation:"url",code:mr.invalid_string,message:s.message}),a.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"regex",code:mr.invalid_string,message:s.message}),a.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?K0t(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?w7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?C7n(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?v7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"duration",code:mr.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?Y7n(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"ip",code:mr.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?x7n(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"jwt",code:mr.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?V7n(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"cidr",code:mr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?R7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"base64",code:mr.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?E7n.test(t.data)||(i=this._getOrReturnCtx(t,i),Qr(i,{validation:"base64url",code:mr.invalid_string,message:s.message}),a.dirty()):hl.assertNever(s);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(i=>t.test(i),{validation:r,code:mr.invalid_string,...Ia.errToObj(a)})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ia.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ia.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ia.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ia.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ia.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ia.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ia.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ia.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ia.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ia.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ia.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ia.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ia.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...Ia.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...Ia.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...Ia.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...Ia.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...Ia.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...Ia.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...Ia.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...Ia.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...Ia.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...Ia.errToObj(r)})}nonempty(t){return this.min(1,Ia.errToObj(t))}trim(){return new n({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new n({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Sy.create=n=>new Sy({checks:[],typeName:Ta.ZodString,coerce:n?.coerce??!1,...Ei(n)});dC=class n extends Di{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Tr.number){let s=this._getOrReturnCtx(t);return Qr(s,{code:mr.invalid_type,expected:Tr.number,received:s.parsedType}),ka}let a,i=new k0;for(let s of this._def.checks)s.kind==="int"?hl.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Q7n(t.data,s.value)!==0&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.not_finite,message:s.message}),i.dirty()):hl.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,Ia.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Ia.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Ia.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Ia.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:Ia.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ia.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ia.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ia.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ia.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ia.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Ia.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:Ia.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ia.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ia.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&hl.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(r)&&Number.isFinite(t)}};dC.create=n=>new dC({checks:[],typeName:Ta.ZodNumber,coerce:n?.coerce||!1,...Ei(n)});hC=class n extends Di{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Tr.bigint)return this._getInvalidInput(t);let a,i=new k0;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),Qr(a,{code:mr.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):hl.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return Qr(r,{code:mr.invalid_type,expected:Tr.bigint,received:r.parsedType}),ka}gte(t,r){return this.setLimit("min",t,!0,Ia.toString(r))}gt(t,r){return this.setLimit("min",t,!1,Ia.toString(r))}lte(t,r){return this.setLimit("max",t,!0,Ia.toString(r))}lt(t,r){return this.setLimit("max",t,!1,Ia.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:Ia.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ia.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ia.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ia.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ia.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:Ia.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};hC.create=n=>new hC({checks:[],typeName:Ta.ZodBigInt,coerce:n?.coerce??!1,...Ei(n)});mC=class extends Di{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Tr.boolean){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.boolean,received:a.parsedType}),ka}return Qh(t.data)}};mC.create=n=>new mC({typeName:Ta.ZodBoolean,coerce:n?.coerce||!1,...Ei(n)});pC=class n extends Di{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Tr.date){let s=this._getOrReturnCtx(t);return Qr(s,{code:mr.invalid_type,expected:Tr.date,received:s.parsedType}),ka}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return Qr(s,{code:mr.invalid_date}),ka}let a=new k0,i;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),Qr(i,{code:mr.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):hl.assertNever(s);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:Ia.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:Ia.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};pC.create=n=>new pC({checks:[],coerce:n?.coerce||!1,typeName:Ta.ZodDate,...Ei(n)});xX=class extends Di{_parse(t){if(this._getType(t)!==Tr.symbol){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.symbol,received:a.parsedType}),ka}return Qh(t.data)}};xX.create=n=>new xX({typeName:Ta.ZodSymbol,...Ei(n)});bC=class extends Di{_parse(t){if(this._getType(t)!==Tr.undefined){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.undefined,received:a.parsedType}),ka}return Qh(t.data)}};bC.create=n=>new bC({typeName:Ta.ZodUndefined,...Ei(n)});GC=class extends Di{_parse(t){if(this._getType(t)!==Tr.null){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.null,received:a.parsedType}),ka}return Qh(t.data)}};GC.create=n=>new GC({typeName:Ta.ZodNull,...Ei(n)});By=class extends Di{constructor(){super(...arguments),this._any=!0}_parse(t){return Qh(t.data)}};By.create=n=>new By({typeName:Ta.ZodAny,...Ei(n)});GA=class extends Di{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Qh(t.data)}};GA.create=n=>new GA({typeName:Ta.ZodUnknown,...Ei(n)});iv=class extends Di{_parse(t){let r=this._getOrReturnCtx(t);return Qr(r,{code:mr.invalid_type,expected:Tr.never,received:r.parsedType}),ka}};iv.create=n=>new iv({typeName:Ta.ZodNever,...Ei(n)});VX=class extends Di{_parse(t){if(this._getType(t)!==Tr.undefined){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.void,received:a.parsedType}),ka}return Qh(t.data)}};VX.create=n=>new VX({typeName:Ta.ZodVoid,...Ei(n)});fA=class n extends Di{_parse(t){let{ctx:r,status:a}=this._processInputParams(t),i=this._def;if(r.parsedType!==Tr.array)return Qr(r,{code:mr.invalid_type,expected:Tr.array,received:r.parsedType}),ka;if(i.exactLength!==null){let e=r.data.length>i.exactLength.value,c=r.data.length<i.exactLength.value;(e||c)&&(Qr(r,{code:e?mr.too_big:mr.too_small,minimum:c?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),a.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(Qr(r,{code:mr.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),a.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(Qr(r,{code:mr.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((e,c)=>i.type._parseAsync(new M1(r,e,r.path,c)))).then(e=>k0.mergeArray(a,e));let s=[...r.data].map((e,c)=>i.type._parseSync(new M1(r,e,r.path,c)));return k0.mergeArray(a,s)}get element(){return this._def.type}min(t,r){return new n({...this._def,minLength:{value:t,message:Ia.toString(r)}})}max(t,r){return new n({...this._def,maxLength:{value:t,message:Ia.toString(r)}})}length(t,r){return new n({...this._def,exactLength:{value:t,message:Ia.toString(r)}})}nonempty(t){return this.min(1,t)}};fA.create=(n,t)=>new fA({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Ta.ZodArray,...Ei(t)});f2=class n extends Di{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=hl.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==Tr.object){let d=this._getOrReturnCtx(t);return Qr(d,{code:mr.invalid_type,expected:Tr.object,received:d.parsedType}),ka}let{status:a,ctx:i}=this._processInputParams(t),{shape:s,keys:e}=this._getCached(),c=[];if(!(this._def.catchall instanceof iv&&this._def.unknownKeys==="strip"))for(let d in i.data)e.includes(d)||c.push(d);let u=[];for(let d of e){let I=s[d],h=i.data[d];u.push({key:{status:"valid",value:d},value:I._parse(new M1(i,h,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof iv){let d=this._def.unknownKeys;if(d==="passthrough")for(let I of c)u.push({key:{status:"valid",value:I},value:{status:"valid",value:i.data[I]}});else if(d==="strict")c.length>0&&(Qr(i,{code:mr.unrecognized_keys,keys:c}),a.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let I of c){let h=i.data[I];u.push({key:{status:"valid",value:I},value:d._parse(new M1(i,h,i.path,I)),alwaysSet:I in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let d=[];for(let I of u){let h=await I.key,o=await I.value;d.push({key:h,value:o,alwaysSet:I.alwaysSet})}return d}).then(d=>k0.mergeObjectSync(a,d)):k0.mergeObjectSync(a,u)}get shape(){return this._def.shape()}strict(t){return Ia.errToObj,new n({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,a)=>{let i=this._def.errorMap?.(r,a).message??a.defaultError;return r.code==="unrecognized_keys"?{message:Ia.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new n({...this._def,unknownKeys:"strip"})}passthrough(){return new n({...this._def,unknownKeys:"passthrough"})}extend(t){return new n({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new n({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ta.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new n({...this._def,catchall:t})}pick(t){let r={};for(let a of hl.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}omit(t){let r={};for(let a of hl.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}deepPartial(){return YX(this)}partial(t){let r={};for(let a of hl.objectKeys(this.shape)){let i=this.shape[a];t&&!t[a]?r[a]=i:r[a]=i.optional()}return new n({...this._def,shape:()=>r})}required(t){let r={};for(let a of hl.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof U1;)s=s._def.innerType;r[a]=s}return new n({...this._def,shape:()=>r})}keyof(){return q0t(hl.objectKeys(this.shape))}};f2.create=(n,t)=>new f2({shape:()=>n,unknownKeys:"strip",catchall:iv.create(),typeName:Ta.ZodObject,...Ei(t)});f2.strictCreate=(n,t)=>new f2({shape:()=>n,unknownKeys:"strict",catchall:iv.create(),typeName:Ta.ZodObject,...Ei(t)});f2.lazycreate=(n,t)=>new f2({shape:n,unknownKeys:"strip",catchall:iv.create(),typeName:Ta.ZodObject,...Ei(t)});fC=class extends Di{_parse(t){let{ctx:r}=this._processInputParams(t),a=this._def.options;function i(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let e=s.map(c=>new G2(c.ctx.common.issues));return Qr(r,{code:mr.invalid_union,unionErrors:e}),ka}if(r.common.async)return Promise.all(a.map(async s=>{let e={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:e}),ctx:e}})).then(i);{let s,e=[];for(let u of a){let d={...r,common:{...r.common,issues:[]},parent:null},I=u._parseSync({data:r.data,path:r.path,parent:d});if(I.status==="valid")return I;I.status==="dirty"&&!s&&(s={result:I,ctx:d}),d.common.issues.length&&e.push(d.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let c=e.map(u=>new G2(u));return Qr(r,{code:mr.invalid_union,unionErrors:c}),ka}}get options(){return this._def.options}};fC.create=(n,t)=>new fC({options:n,typeName:Ta.ZodUnion,...Ei(t)});bA=n=>n instanceof vC?bA(n.schema):n instanceof z1?bA(n.innerType()):n instanceof ZC?[n.value]:n instanceof NC?n.options:n instanceof WC?hl.objectValues(n.enum):n instanceof AC?bA(n._def.innerType):n instanceof bC?[void 0]:n instanceof GC?[null]:n instanceof U1?[void 0,...bA(n.unwrap())]:n instanceof J3?[null,...bA(n.unwrap())]:n instanceof bO||n instanceof yC?bA(n.unwrap()):n instanceof FC?bA(n._def.innerType):[],pie=class n extends Di{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Tr.object)return Qr(r,{code:mr.invalid_type,expected:Tr.object,received:r.parsedType}),ka;let a=this.discriminator,i=r.data[a],s=this.optionsMap.get(i);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(Qr(r,{code:mr.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),ka)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,a){let i=new Map;for(let s of r){let e=bA(s.shape[t]);if(!e.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let c of e){if(i.has(c))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(c)}`);i.set(c,s)}}return new n({typeName:Ta.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Ei(a)})}};gC=class extends Di{_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=(s,e)=>{if(hie(s)||hie(e))return ka;let c=yFe(s.value,e.value);return c.valid?((mie(s)||mie(e))&&r.dirty(),{status:r.value,value:c.data}):(Qr(a,{code:mr.invalid_intersection_types}),ka)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([s,e])=>i(s,e)):i(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};gC.create=(n,t,r)=>new gC({left:n,right:t,typeName:Ta.ZodIntersection,...Ei(r)});L3=class n extends Di{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Tr.array)return Qr(a,{code:mr.invalid_type,expected:Tr.array,received:a.parsedType}),ka;if(a.data.length<this._def.items.length)return Qr(a,{code:mr.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ka;!this._def.rest&&a.data.length>this._def.items.length&&(Qr(a,{code:mr.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...a.data].map((e,c)=>{let u=this._def.items[c]||this._def.rest;return u?u._parse(new M1(a,e,a.path,c)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>k0.mergeArray(r,e)):k0.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new n({...this._def,rest:t})}};L3.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new L3({items:n,typeName:Ta.ZodTuple,rest:null,...Ei(t)})};bie=class n extends Di{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Tr.object)return Qr(a,{code:mr.invalid_type,expected:Tr.object,received:a.parsedType}),ka;let i=[],s=this._def.keyType,e=this._def.valueType;for(let c in a.data)i.push({key:s._parse(new M1(a,c,a.path,c)),value:e._parse(new M1(a,a.data[c],a.path,c)),alwaysSet:c in a.data});return a.common.async?k0.mergeObjectAsync(r,i):k0.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof Di?new n({keyType:t,valueType:r,typeName:Ta.ZodRecord,...Ei(a)}):new n({keyType:Sy.create(),valueType:t,typeName:Ta.ZodRecord,...Ei(r)})}},QX=class extends Di{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Tr.map)return Qr(a,{code:mr.invalid_type,expected:Tr.map,received:a.parsedType}),ka;let i=this._def.keyType,s=this._def.valueType,e=[...a.data.entries()].map(([c,u],d)=>({key:i._parse(new M1(a,c,a.path,[d,"key"])),value:s._parse(new M1(a,u,a.path,[d,"value"]))}));if(a.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let u of e){let d=await u.key,I=await u.value;if(d.status==="aborted"||I.status==="aborted")return ka;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),c.set(d.value,I.value)}return{status:r.value,value:c}})}else{let c=new Map;for(let u of e){let d=u.key,I=u.value;if(d.status==="aborted"||I.status==="aborted")return ka;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),c.set(d.value,I.value)}return{status:r.value,value:c}}}};QX.create=(n,t,r)=>new QX({valueType:t,keyType:n,typeName:Ta.ZodMap,...Ei(r)});HX=class n extends Di{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==Tr.set)return Qr(a,{code:mr.invalid_type,expected:Tr.set,received:a.parsedType}),ka;let i=this._def;i.minSize!==null&&a.data.size<i.minSize.value&&(Qr(a,{code:mr.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&a.data.size>i.maxSize.value&&(Qr(a,{code:mr.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let s=this._def.valueType;function e(u){let d=new Set;for(let I of u){if(I.status==="aborted")return ka;I.status==="dirty"&&r.dirty(),d.add(I.value)}return{status:r.value,value:d}}let c=[...a.data.values()].map((u,d)=>s._parse(new M1(a,u,a.path,d)));return a.common.async?Promise.all(c).then(u=>e(u)):e(c)}min(t,r){return new n({...this._def,minSize:{value:t,message:Ia.toString(r)}})}max(t,r){return new n({...this._def,maxSize:{value:t,message:Ia.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};HX.create=(n,t)=>new HX({valueType:n,minSize:null,maxSize:null,typeName:Ta.ZodSet,...Ei(t)});Gie=class n extends Di{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Tr.function)return Qr(r,{code:mr.invalid_type,expected:Tr.function,received:r.parsedType}),ka;function a(c,u){return pO({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,wX(),pA].filter(d=>!!d),issueData:{code:mr.invalid_arguments,argumentsError:u}})}function i(c,u){return pO({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,wX(),pA].filter(d=>!!d),issueData:{code:mr.invalid_return_type,returnTypeError:u}})}let s={errorMap:r.common.contextualErrorMap},e=r.data;if(this._def.returns instanceof Dy){let c=this;return Qh(async function(...u){let d=new G2([]),I=await c._def.args.parseAsync(u,s).catch(f=>{throw d.addIssue(a(u,f)),d}),h=await Reflect.apply(e,this,I);return await c._def.returns._def.type.parseAsync(h,s).catch(f=>{throw d.addIssue(i(h,f)),d})})}else{let c=this;return Qh(function(...u){let d=c._def.args.safeParse(u,s);if(!d.success)throw new G2([a(u,d.error)]);let I=Reflect.apply(e,this,d.data),h=c._def.returns.safeParse(I,s);if(!h.success)throw new G2([i(I,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new n({...this._def,args:L3.create(t).rest(GA.create())})}returns(t){return new n({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,a){return new n({args:t||L3.create([]).rest(GA.create()),returns:r||GA.create(),typeName:Ta.ZodFunction,...Ei(a)})}},vC=class extends Di{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};vC.create=(n,t)=>new vC({getter:n,typeName:Ta.ZodLazy,...Ei(t)});ZC=class extends Di{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return Qr(r,{received:r.data,code:mr.invalid_literal,expected:this._def.value}),ka}return{status:"valid",value:t.data}}get value(){return this._def.value}};ZC.create=(n,t)=>new ZC({value:n,typeName:Ta.ZodLiteral,...Ei(t)});NC=class n extends Di{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),a=this._def.values;return Qr(r,{expected:hl.joinValues(a),received:r.parsedType,code:mr.invalid_type}),ka}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),a=this._def.values;return Qr(r,{received:r.data,code:mr.invalid_enum_value,options:a}),ka}return Qh(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return n.create(t,{...this._def,...r})}exclude(t,r=this._def){return n.create(this.options.filter(a=>!t.includes(a)),{...this._def,...r})}};NC.create=q0t;WC=class extends Di{_parse(t){let r=hl.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==Tr.string&&a.parsedType!==Tr.number){let i=hl.objectValues(r);return Qr(a,{expected:hl.joinValues(i),received:a.parsedType,code:mr.invalid_type}),ka}if(this._cache||(this._cache=new Set(hl.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=hl.objectValues(r);return Qr(a,{received:a.data,code:mr.invalid_enum_value,options:i}),ka}return Qh(t.data)}get enum(){return this._def.values}};WC.create=(n,t)=>new WC({values:n,typeName:Ta.ZodNativeEnum,...Ei(t)});Dy=class extends Di{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==Tr.promise&&r.common.async===!1)return Qr(r,{code:mr.invalid_type,expected:Tr.promise,received:r.parsedType}),ka;let a=r.parsedType===Tr.promise?r.data:Promise.resolve(r.data);return Qh(a.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Dy.create=(n,t)=>new Dy({type:n,typeName:Ta.ZodPromise,...Ei(t)});z1=class extends Di{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ta.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:e=>{Qr(a,e),e.fatal?r.abort():r.dirty()},get path(){return a.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let e=i.transform(a.data,s);if(a.common.async)return Promise.resolve(e).then(async c=>{if(r.value==="aborted")return ka;let u=await this._def.schema._parseAsync({data:c,path:a.path,parent:a});return u.status==="aborted"?ka:u.status==="dirty"?uC(u.value):r.value==="dirty"?uC(u.value):u});{if(r.value==="aborted")return ka;let c=this._def.schema._parseSync({data:e,path:a.path,parent:a});return c.status==="aborted"?ka:c.status==="dirty"?uC(c.value):r.value==="dirty"?uC(c.value):c}}if(i.type==="refinement"){let e=c=>{let u=i.refinement(c,s);if(a.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(a.common.async===!1){let c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return c.status==="aborted"?ka:(c.status==="dirty"&&r.dirty(),e(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>c.status==="aborted"?ka:(c.status==="dirty"&&r.dirty(),e(c.value).then(()=>({status:r.value,value:c.value}))))}if(i.type==="transform")if(a.common.async===!1){let e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Jy(e))return ka;let c=i.transform(e.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:c}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(e=>Jy(e)?Promise.resolve(i.transform(e.value,s)).then(c=>({status:r.value,value:c})):ka);hl.assertNever(i)}};z1.create=(n,t,r)=>new z1({schema:n,typeName:Ta.ZodEffects,effect:t,...Ei(r)});z1.createWithPreprocess=(n,t,r)=>new z1({schema:t,effect:{type:"preprocess",transform:n},typeName:Ta.ZodEffects,...Ei(r)});U1=class extends Di{_parse(t){return this._getType(t)===Tr.undefined?Qh(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};U1.create=(n,t)=>new U1({innerType:n,typeName:Ta.ZodOptional,...Ei(t)});J3=class extends Di{_parse(t){return this._getType(t)===Tr.null?Qh(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};J3.create=(n,t)=>new J3({innerType:n,typeName:Ta.ZodNullable,...Ei(t)});AC=class extends Di{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return r.parsedType===Tr.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};AC.create=(n,t)=>new AC({innerType:n,typeName:Ta.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Ei(t)});FC=class extends Di{_parse(t){let{ctx:r}=this._processInputParams(t),a={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return CX(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new G2(a.common.issues)},input:a.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new G2(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};FC.create=(n,t)=>new FC({innerType:n,typeName:Ta.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Ei(t)});XX=class extends Di{_parse(t){if(this._getType(t)!==Tr.nan){let a=this._getOrReturnCtx(t);return Qr(a,{code:mr.invalid_type,expected:Tr.nan,received:a.parsedType}),ka}return{status:"valid",value:t.data}}};XX.create=n=>new XX({typeName:Ta.ZodNaN,...Ei(n)});H7n=Symbol("zod_brand"),bO=class extends Di{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}},GO=class n extends Di{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?ka:s.status==="dirty"?(r.dirty(),uC(s.value)):this._def.out._parseAsync({data:s.value,path:a.path,parent:a})})();{let i=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?ka:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:a.path,parent:a})}}static create(t,r){return new n({in:t,out:r,typeName:Ta.ZodPipeline})}},yC=class extends Di{_parse(t){let r=this._def.innerType._parse(t),a=i=>(Jy(i)&&(i.value=Object.freeze(i.value)),i);return CX(r)?r.then(i=>a(i)):a(r)}unwrap(){return this._def.innerType}};yC.create=(n,t)=>new yC({innerType:n,typeName:Ta.ZodReadonly,...Ei(t)});X7n={object:f2.lazycreate};(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(Ta||(Ta={}));k7n=(n,t={message:`Input not instance of ${n.name}`})=>$0t(r=>r instanceof n,t),eht=Sy.create,tht=dC.create,L7n=XX.create,J7n=hC.create,nht=mC.create,S7n=pC.create,B7n=xX.create,D7n=bC.create,T7n=GC.create,O7n=By.create,U7n=GA.create,M7n=iv.create,z7n=VX.create,_7n=fA.create,P7n=f2.create,j7n=f2.strictCreate,K7n=fC.create,q7n=pie.create,$7n=gC.create,eDn=L3.create,tDn=bie.create,nDn=QX.create,rDn=HX.create,aDn=Gie.create,iDn=vC.create,lDn=ZC.create,sDn=NC.create,oDn=WC.create,cDn=Dy.create,IDn=z1.create,uDn=U1.create,dDn=J3.create,hDn=z1.createWithPreprocess,mDn=GO.create,pDn=()=>eht().optional(),bDn=()=>tht().optional(),GDn=()=>nht().optional(),fDn={string:(n=>Sy.create({...n,coerce:!0})),number:(n=>dC.create({...n,coerce:!0})),boolean:(n=>mC.create({...n,coerce:!0})),bigint:(n=>hC.create({...n,coerce:!0})),date:(n=>pC.create({...n,coerce:!0}))},gDn=ka});var zc={};so(zc,{BRAND:()=>H7n,DIRTY:()=>uC,EMPTY_PATH:()=>h7n,INVALID:()=>ka,NEVER:()=>gDn,OK:()=>Qh,ParseStatus:()=>k0,Schema:()=>Di,ZodAny:()=>By,ZodArray:()=>fA,ZodBigInt:()=>hC,ZodBoolean:()=>mC,ZodBranded:()=>bO,ZodCatch:()=>FC,ZodDate:()=>pC,ZodDefault:()=>AC,ZodDiscriminatedUnion:()=>pie,ZodEffects:()=>z1,ZodEnum:()=>NC,ZodError:()=>G2,ZodFirstPartyTypeKind:()=>Ta,ZodFunction:()=>Gie,ZodIntersection:()=>gC,ZodIssueCode:()=>mr,ZodLazy:()=>vC,ZodLiteral:()=>ZC,ZodMap:()=>QX,ZodNaN:()=>XX,ZodNativeEnum:()=>WC,ZodNever:()=>iv,ZodNull:()=>GC,ZodNullable:()=>J3,ZodNumber:()=>dC,ZodObject:()=>f2,ZodOptional:()=>U1,ZodParsedType:()=>Tr,ZodPipeline:()=>GO,ZodPromise:()=>Dy,ZodReadonly:()=>yC,ZodRecord:()=>bie,ZodSchema:()=>Di,ZodSet:()=>HX,ZodString:()=>Sy,ZodSymbol:()=>xX,ZodTransformer:()=>z1,ZodTuple:()=>L3,ZodType:()=>Di,ZodUndefined:()=>bC,ZodUnion:()=>fC,ZodUnknown:()=>GA,ZodVoid:()=>VX,addIssueToContext:()=>Qr,any:()=>O7n,array:()=>_7n,bigint:()=>J7n,boolean:()=>nht,coerce:()=>fDn,custom:()=>$0t,date:()=>S7n,datetimeRegex:()=>K0t,defaultErrorMap:()=>pA,discriminatedUnion:()=>q7n,effect:()=>IDn,enum:()=>sDn,function:()=>aDn,getErrorMap:()=>wX,getParsedType:()=>k3,instanceof:()=>k7n,intersection:()=>$7n,isAborted:()=>hie,isAsync:()=>CX,isDirty:()=>mie,isValid:()=>Jy,late:()=>X7n,lazy:()=>iDn,literal:()=>lDn,makeIssue:()=>pO,map:()=>nDn,nan:()=>L7n,nativeEnum:()=>oDn,never:()=>M7n,null:()=>T7n,nullable:()=>dDn,number:()=>tht,object:()=>P7n,objectUtil:()=>NFe,oboolean:()=>GDn,onumber:()=>bDn,optional:()=>uDn,ostring:()=>pDn,pipeline:()=>mDn,preprocess:()=>hDn,promise:()=>cDn,quotelessJson:()=>I7n,record:()=>tDn,set:()=>rDn,setErrorMap:()=>d7n,strictObject:()=>j7n,string:()=>eht,symbol:()=>B7n,transformer:()=>IDn,tuple:()=>eDn,undefined:()=>D7n,union:()=>K7n,unknown:()=>U7n,util:()=>hl,void:()=>z7n});var RFe=ct(()=>{die();AFe();U0t();mO();rht();uie()});function Ln(n,t,r){function a(c,u){var d;Object.defineProperty(c,"_zod",{value:c._zod??{},enumerable:!1}),(d=c._zod).traits??(d.traits=new Set),c._zod.traits.add(n),t(c,u);for(let I in e.prototype)I in c||Object.defineProperty(c,I,{value:e.prototype[I].bind(c)});c._zod.constr=e,c._zod.def=u}let i=r?.Parent??Object;class s extends i{}Object.defineProperty(s,"name",{value:n});function e(c){var u;let d=r?.Parent?new s:this;a(d,c),(u=d._zod).deferred??(u.deferred=[]);for(let I of d._zod.deferred)I();return d}return Object.defineProperty(e,"init",{value:a}),Object.defineProperty(e,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(n)}),Object.defineProperty(e,"name",{value:n}),e}function aG(n){return n&&Object.assign(fie,n),fie}var EFe,vDn,gA,fie,kX=ct(()=>{EFe=Object.freeze({status:"aborted"});vDn=Symbol("zod_brand"),gA=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},fie={}});var ps={};so(ps,{BIGINT_FORMAT_RANGES:()=>iht,Class:()=>CFe,NUMBER_FORMAT_RANGES:()=>LFe,aborted:()=>EC,allowsEval:()=>HFe,assert:()=>FDn,assertEqual:()=>ZDn,assertIs:()=>WDn,assertNever:()=>ADn,assertNotEqual:()=>NDn,assignProp:()=>QFe,cached:()=>gO,captureStackTrace:()=>vie,cleanEnum:()=>LDn,cleanRegex:()=>ZO,clone:()=>lv,createTransparentProxy:()=>YDn,defineLazy:()=>Uo,esc:()=>RC,escapeRegex:()=>Ty,extend:()=>QDn,finalizeIssue:()=>sv,floatSafeRemainder:()=>VFe,getElementAtPath:()=>yDn,getEnumValues:()=>YFe,getLengthableOrigin:()=>NO,getParsedType:()=>CDn,getSizableOrigin:()=>lht,isObject:()=>LX,isPlainObject:()=>JX,issue:()=>JFe,joinValues:()=>gie,jsonStringifyReplacer:()=>xFe,merge:()=>HDn,normalizeParams:()=>Wa,nullish:()=>vO,numKeys:()=>wDn,omit:()=>VDn,optionalKeys:()=>kFe,partial:()=>XDn,pick:()=>xDn,prefixIssues:()=>S3,primitiveTypes:()=>aht,promiseAllObject:()=>RDn,propertyKeyTypes:()=>XFe,randomString:()=>EDn,required:()=>kDn,stringifyPrimitive:()=>Zie,unwrapMessage:()=>fO});function ZDn(n){return n}function NDn(n){return n}function WDn(n){}function ADn(n){throw new Error}function FDn(n){}function YFe(n){let t=Object.values(n).filter(a=>typeof a=="number");return Object.entries(n).filter(([a,i])=>t.indexOf(+a)===-1).map(([a,i])=>i)}function gie(n,t="|"){return n.map(r=>Zie(r)).join(t)}function xFe(n,t){return typeof t=="bigint"?t.toString():t}function gO(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function vO(n){return n==null}function ZO(n){let t=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(t,r)}function VFe(n,t){let r=(n.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,i=r>a?r:a,s=Number.parseInt(n.toFixed(i).replace(".","")),e=Number.parseInt(t.toFixed(i).replace(".",""));return s%e/10**i}function Uo(n,t,r){Object.defineProperty(n,t,{get(){{let i=r();return n[t]=i,i}throw new Error("cached value already set")},set(i){Object.defineProperty(n,t,{value:i})},configurable:!0})}function QFe(n,t,r){Object.defineProperty(n,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function yDn(n,t){return t?t.reduce((r,a)=>r?.[a],n):n}function RDn(n){let t=Object.keys(n),r=t.map(a=>n[a]);return Promise.all(r).then(a=>{let i={};for(let s=0;s<t.length;s++)i[t[s]]=a[s];return i})}function EDn(n=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<n;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function RC(n){return JSON.stringify(n)}function LX(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function JX(n){if(LX(n)===!1)return!1;let t=n.constructor;if(t===void 0)return!0;let r=t.prototype;return!(LX(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function wDn(n){let t=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&t++;return t}function Ty(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lv(n,t,r){let a=new n._zod.constr(t??n._zod.def);return(!t||r?.parent)&&(a._zod.parent=n),a}function Wa(n){let t=n;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function YDn(n){let t;return new Proxy({},{get(r,a,i){return t??(t=n()),Reflect.get(t,a,i)},set(r,a,i,s){return t??(t=n()),Reflect.set(t,a,i,s)},has(r,a){return t??(t=n()),Reflect.has(t,a)},deleteProperty(r,a){return t??(t=n()),Reflect.deleteProperty(t,a)},ownKeys(r){return t??(t=n()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,a){return t??(t=n()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(r,a,i){return t??(t=n()),Reflect.defineProperty(t,a,i)}})}function Zie(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function kFe(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}function xDn(n,t){let r={},a=n._zod.def;for(let i in t){if(!(i in a.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=a.shape[i])}return lv(n,{...n._zod.def,shape:r,checks:[]})}function VDn(n,t){let r={...n._zod.def.shape},a=n._zod.def;for(let i in t){if(!(i in a.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return lv(n,{...n._zod.def,shape:r,checks:[]})}function QDn(n,t){if(!JX(t))throw new Error("Invalid input to extend: expected a plain object");let r={...n._zod.def,get shape(){let a={...n._zod.def.shape,...t};return QFe(this,"shape",a),a},checks:[]};return lv(n,r)}function HDn(n,t){return lv(n,{...n._zod.def,get shape(){let r={...n._zod.def.shape,...t._zod.def.shape};return QFe(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function XDn(n,t,r){let a=t._zod.def.shape,i={...a};if(r)for(let s in r){if(!(s in a))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=n?new n({type:"optional",innerType:a[s]}):a[s])}else for(let s in a)i[s]=n?new n({type:"optional",innerType:a[s]}):a[s];return lv(t,{...t._zod.def,shape:i,checks:[]})}function kDn(n,t,r){let a=t._zod.def.shape,i={...a};if(r)for(let s in r){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(i[s]=new n({type:"nonoptional",innerType:a[s]}))}else for(let s in a)i[s]=new n({type:"nonoptional",innerType:a[s]});return lv(t,{...t._zod.def,shape:i,checks:[]})}function EC(n,t=0){for(let r=t;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function S3(n,t){return t.map(r=>{var a;return(a=r).path??(a.path=[]),r.path.unshift(n),r})}function fO(n){return typeof n=="string"?n:n?.message}function sv(n,t,r){let a={...n,path:n.path??[]};if(!n.message){let i=fO(n.inst?._zod.def?.error?.(n))??fO(t?.error?.(n))??fO(r.customError?.(n))??fO(r.localeError?.(n))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function lht(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function NO(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function JFe(...n){let[t,r,a]=n;return typeof t=="string"?{message:t,code:"custom",input:r,inst:a}:{...t}}function LDn(n){return Object.entries(n).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var vie,HFe,CDn,XFe,aht,LFe,iht,CFe,vA=ct(()=>{vie=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};HFe=gO(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});CDn=n=>{let t=typeof n;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(n)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(n)?"array":n===null?"null":n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?"promise":typeof Map<"u"&&n instanceof Map?"map":typeof Set<"u"&&n instanceof Set?"set":typeof Date<"u"&&n instanceof Date?"date":typeof File<"u"&&n instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},XFe=new Set(["string","number","symbol"]),aht=new Set(["string","number","bigint","boolean","symbol","undefined"]);LFe={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},iht={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};CFe=class{constructor(...t){}}});function BFe(n,t=r=>r.message){let r={},a=[];for(let i of n.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:r}}function DFe(n,t){let r=t||function(s){return s.message},a={_errors:[]},i=s=>{for(let e of s.issues)if(e.code==="invalid_union"&&e.errors.length)e.errors.map(c=>i({issues:c}));else if(e.code==="invalid_key")i({issues:e.issues});else if(e.code==="invalid_element")i({issues:e.issues});else if(e.path.length===0)a._errors.push(r(e));else{let c=a,u=0;for(;u<e.path.length;){let d=e.path[u];u===e.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(r(e))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}};return i(n),a}var sht,Nie,SFe,TFe=ct(()=>{kX();vA();sht=(n,t)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:t,enumerable:!1}),Object.defineProperty(n,"message",{get(){return JSON.stringify(t,xFe,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},Nie=Ln("$ZodError",sht),SFe=Ln("$ZodError",sht,{Parent:Error})});var oht,cht,OFe,WO,UFe,Wie,MFe=ct(()=>{kX();TFe();vA();oht=n=>(t,r,a,i)=>{let s=a?Object.assign(a,{async:!1}):{async:!1},e=t._zod.run({value:r,issues:[]},s);if(e instanceof Promise)throw new gA;if(e.issues.length){let c=new(i?.Err??n)(e.issues.map(u=>sv(u,s,aG())));throw vie(c,i?.callee),c}return e.value},cht=n=>async(t,r,a,i)=>{let s=a?Object.assign(a,{async:!0}):{async:!0},e=t._zod.run({value:r,issues:[]},s);if(e instanceof Promise&&(e=await e),e.issues.length){let c=new(i?.Err??n)(e.issues.map(u=>sv(u,s,aG())));throw vie(c,i?.callee),c}return e.value},OFe=n=>(t,r,a)=>{let i=a?{...a,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new gA;return s.issues.length?{success:!1,error:new(n??Nie)(s.issues.map(e=>sv(e,i,aG())))}:{success:!0,data:s.value}},WO=OFe(SFe),UFe=n=>async(t,r,a)=>{let i=a?Object.assign(a,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new n(s.issues.map(e=>sv(e,i,aG())))}:{success:!0,data:s.value}},Wie=UFe(SFe)});function ght(){return new RegExp(SDn,"u")}function wht(n){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${t}`:n.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${n.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Cht(n){return new RegExp(`^${wht(n)}$`)}function Yht(n){let t=wht({precision:n.precision}),r=["Z"];n.local&&r.push(""),n.offset&&r.push("([+-]\\d{2}:\\d{2})");let a=`${t}(?:${r.join("|")})`;return new RegExp(`^${Rht}T(?:${a})$`)}var Iht,uht,dht,hht,mht,pht,bht,Ght,zFe,fht,SDn,vht,Zht,Nht,Wht,Aht,_Fe,Fht,yht,Rht,Eht,xht,Vht,Qht,Hht,Xht,kht,Lht,Jht,Fie=ct(()=>{Iht=/^[cC][^\s-]{8,}$/,uht=/^[0-9a-z]+$/,dht=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hht=/^[0-9a-vA-V]{20}$/,mht=/^[A-Za-z0-9]{27}$/,pht=/^[a-zA-Z0-9_-]{21}$/,bht=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ght=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zFe=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,fht=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,SDn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";vht=/^(?:(?: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])$/,Zht=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Nht=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Wht=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Aht=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,_Fe=/^[A-Za-z0-9_-]*$/,Fht=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,yht=/^\+(?:[0-9]){6,14}[0-9]$/,Rht="(?:(?:\\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])))",Eht=new RegExp(`^${Rht}$`);xht=n=>{let t=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Vht=/^\d+n?$/,Qht=/^\d+$/,Hht=/^-?\d+(?:\.\d+)?/i,Xht=/true|false/i,kht=/null/i,Lht=/^[^A-Z]*$/,Jht=/^[^a-z]*$/});var Hh,Sht,PFe,jFe,Bht,Dht,Tht,Oht,Uht,AO,Mht,zht,_ht,Pht,jht,Kht,qht,yie=ct(()=>{kX();Fie();vA();Hh=Ln("$ZodCheck",(n,t)=>{var r;n._zod??(n._zod={}),n._zod.def=t,(r=n._zod).onattach??(r.onattach=[])}),Sht={number:"number",bigint:"bigint",object:"date"},PFe=Ln("$ZodCheckLessThan",(n,t)=>{Hh.init(n,t);let r=Sht[typeof t.value];n._zod.onattach.push(a=>{let i=a._zod.bag,s=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),n._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:r,code:"too_big",maximum:t.value,input:a.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),jFe=Ln("$ZodCheckGreaterThan",(n,t)=>{Hh.init(n,t);let r=Sht[typeof t.value];n._zod.onattach.push(a=>{let i=a._zod.bag,s=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),n._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:r,code:"too_small",minimum:t.value,input:a.value,inclusive:t.inclusive,inst:n,continue:!t.abort})}}),Bht=Ln("$ZodCheckMultipleOf",(n,t)=>{Hh.init(n,t),n._zod.onattach.push(r=>{var a;(a=r._zod.bag).multipleOf??(a.multipleOf=t.value)}),n._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):VFe(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:n,continue:!t.abort})}}),Dht=Ln("$ZodCheckNumberFormat",(n,t)=>{Hh.init(n,t),t.format=t.format||"float64";let r=t.format?.includes("int"),a=r?"int":"number",[i,s]=LFe[t.format];n._zod.onattach.push(e=>{let c=e._zod.bag;c.format=t.format,c.minimum=i,c.maximum=s,r&&(c.pattern=Qht)}),n._zod.check=e=>{let c=e.value;if(r){if(!Number.isInteger(c)){e.issues.push({expected:a,format:t.format,code:"invalid_type",input:c,inst:n});return}if(!Number.isSafeInteger(c)){c>0?e.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:a,continue:!t.abort}):e.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:a,continue:!t.abort});return}}c<i&&e.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:n,continue:!t.abort}),c>s&&e.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:n})}}),Tht=Ln("$ZodCheckMaxLength",(n,t)=>{var r;Hh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!vO(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(a._zod.bag.maximum=t.maximum)}),n._zod.check=a=>{let i=a.value;if(i.length<=t.maximum)return;let e=NO(i);a.issues.push({origin:e,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),Oht=Ln("$ZodCheckMinLength",(n,t)=>{var r;Hh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!vO(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(a._zod.bag.minimum=t.minimum)}),n._zod.check=a=>{let i=a.value;if(i.length>=t.minimum)return;let e=NO(i);a.issues.push({origin:e,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),Uht=Ln("$ZodCheckLengthEquals",(n,t)=>{var r;Hh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!vO(i)&&i.length!==void 0}),n._zod.onattach.push(a=>{let i=a._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),n._zod.check=a=>{let i=a.value,s=i.length;if(s===t.length)return;let e=NO(i),c=s>t.length;a.issues.push({origin:e,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:n,continue:!t.abort})}}),AO=Ln("$ZodCheckStringFormat",(n,t)=>{var r,a;Hh.init(n,t),n._zod.onattach.push(i=>{let s=i._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=n._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:n,continue:!t.abort})}):(a=n._zod).check??(a.check=()=>{})}),Mht=Ln("$ZodCheckRegex",(n,t)=>{AO.init(n,t),n._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:n,continue:!t.abort})}}),zht=Ln("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=Lht),AO.init(n,t)}),_ht=Ln("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=Jht),AO.init(n,t)}),Pht=Ln("$ZodCheckIncludes",(n,t)=>{Hh.init(n,t);let r=Ty(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=a,n._zod.onattach.push(i=>{let s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(a)}),n._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:n,continue:!t.abort})}}),jht=Ln("$ZodCheckStartsWith",(n,t)=>{Hh.init(n,t);let r=new RegExp(`^${Ty(t.prefix)}.*`);t.pattern??(t.pattern=r),n._zod.onattach.push(a=>{let i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),n._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:n,continue:!t.abort})}}),Kht=Ln("$ZodCheckEndsWith",(n,t)=>{Hh.init(n,t);let r=new RegExp(`.*${Ty(t.suffix)}$`);t.pattern??(t.pattern=r),n._zod.onattach.push(a=>{let i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),n._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:n,continue:!t.abort})}}),qht=Ln("$ZodCheckOverwrite",(n,t)=>{Hh.init(n,t),n._zod.check=r=>{r.value=t.tx(r.value)}})});var Rie,KFe=ct(()=>{Rie=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let a=t.split(`
|
|
662
662
|
`).filter(e=>e),i=Math.min(...a.map(e=>e.length-e.trimStart().length)),s=a.map(e=>e.slice(i)).map(e=>" ".repeat(this.indent*2)+e);for(let e of s)this.content.push(e)}compile(){let t=Function,r=this?.args,i=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...r,i.join(`
|
|
663
663
|
`))}}});var emt,qFe=ct(()=>{emt={major:4,minor:0,patch:0}});function wmt(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}function BDn(n){if(!_Fe.test(n))return!1;let t=n.replace(/[-_]/g,a=>a==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return wmt(r)}function DDn(n,t=null){try{let r=n.split(".");if(r.length!==3)return!1;let[a]=r;if(!a)return!1;let i=JSON.parse(atob(a));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}function tmt(n,t,r){n.issues.length&&t.issues.push(...S3(r,n.issues)),t.value[r]=n.value}function Eie(n,t,r){n.issues.length&&t.issues.push(...S3(r,n.issues)),t.value[r]=n.value}function nmt(n,t,r,a){n.issues.length?a[r]===void 0?r in a?t.value[r]=void 0:t.value[r]=n.value:t.issues.push(...S3(r,n.issues)):n.value===void 0?r in a&&(t.value[r]=void 0):t.value[r]=n.value}function rmt(n,t,r,a){for(let i of n)if(i.issues.length===0)return t.value=i.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:n.map(i=>i.issues.map(s=>sv(s,a,aG())))}),t}function $Fe(n,t){if(n===t)return{valid:!0,data:n};if(n instanceof Date&&t instanceof Date&&+n==+t)return{valid:!0,data:n};if(JX(n)&&JX(t)){let r=Object.keys(t),a=Object.keys(n).filter(s=>r.indexOf(s)!==-1),i={...n,...t};for(let s of a){let e=$Fe(n[s],t[s]);if(!e.valid)return{valid:!1,mergeErrorPath:[s,...e.mergeErrorPath]};i[s]=e.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let a=0;a<n.length;a++){let i=n[a],s=t[a],e=$Fe(i,s);if(!e.valid)return{valid:!1,mergeErrorPath:[a,...e.mergeErrorPath]};r.push(e.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function amt(n,t,r){if(t.issues.length&&n.issues.push(...t.issues),r.issues.length&&n.issues.push(...r.issues),EC(n))return n;let a=$Fe(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return n.value=a.data,n}function imt(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}function lmt(n,t){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:t}),n}function smt(n,t,r){return EC(n)?n:t.out._zod.run({value:n.value,issues:n.issues},r)}function omt(n){return n.value=Object.freeze(n.value),n}function cmt(n,t,r,a){if(!n){let i={code:"custom",input:r,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(i.params=a._zod.def.params),t.issues.push(JFe(i))}}var $s,wie,sc,Imt,umt,dmt,hmt,mmt,pmt,bmt,Gmt,fmt,gmt,vmt,Zmt,Nmt,Wmt,Amt,Fmt,ymt,Rmt,Emt,Cmt,Ymt,xmt,Vmt,eye,Qmt,Hmt,Xmt,kmt,Lmt,Jmt,Smt,Bmt,Dmt,Tmt,tye,Omt,Umt,Mmt,zmt,_mt,Pmt,jmt,Kmt,qmt,$mt,ept,tpt,npt,rpt,apt,ipt=ct(()=>{yie();kX();KFe();MFe();Fie();vA();qFe();vA();$s=Ln("$ZodType",(n,t)=>{var r;n??(n={}),n._zod.def=t,n._zod.bag=n._zod.bag||{},n._zod.version=emt;let a=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&a.unshift(n);for(let i of a)for(let s of i._zod.onattach)s(n);if(a.length===0)(r=n._zod).deferred??(r.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{let i=(s,e,c)=>{let u=EC(s),d;for(let I of e){if(I._zod.def.when){if(!I._zod.def.when(s))continue}else if(u)continue;let h=s.issues.length,o=I._zod.check(s);if(o instanceof Promise&&c?.async===!1)throw new gA;if(d||o instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await o,s.issues.length!==h&&(u||(u=EC(s,h)))});else{if(s.issues.length===h)continue;u||(u=EC(s,h))}}return d?d.then(()=>s):s};n._zod.run=(s,e)=>{let c=n._zod.parse(s,e);if(c instanceof Promise){if(e.async===!1)throw new gA;return c.then(u=>i(u,a,e))}return i(c,a,e)}}n["~standard"]={validate:i=>{try{let s=WO(n,i);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Wie(n,i).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),wie=Ln("$ZodString",(n,t)=>{$s.init(n,t),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??xht(n._zod.bag),n._zod.parse=(r,a)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:n}),r}}),sc=Ln("$ZodStringFormat",(n,t)=>{AO.init(n,t),wie.init(n,t)}),Imt=Ln("$ZodGUID",(n,t)=>{t.pattern??(t.pattern=Ght),sc.init(n,t)}),umt=Ln("$ZodUUID",(n,t)=>{if(t.version){let a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=zFe(a))}else t.pattern??(t.pattern=zFe());sc.init(n,t)}),dmt=Ln("$ZodEmail",(n,t)=>{t.pattern??(t.pattern=fht),sc.init(n,t)}),hmt=Ln("$ZodURL",(n,t)=>{sc.init(n,t),n._zod.check=r=>{try{let a=r.value,i=new URL(a),s=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Fht.source,input:r.value,inst:n,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:n,continue:!t.abort})),!a.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:n,continue:!t.abort})}}}),mmt=Ln("$ZodEmoji",(n,t)=>{t.pattern??(t.pattern=ght()),sc.init(n,t)}),pmt=Ln("$ZodNanoID",(n,t)=>{t.pattern??(t.pattern=pht),sc.init(n,t)}),bmt=Ln("$ZodCUID",(n,t)=>{t.pattern??(t.pattern=Iht),sc.init(n,t)}),Gmt=Ln("$ZodCUID2",(n,t)=>{t.pattern??(t.pattern=uht),sc.init(n,t)}),fmt=Ln("$ZodULID",(n,t)=>{t.pattern??(t.pattern=dht),sc.init(n,t)}),gmt=Ln("$ZodXID",(n,t)=>{t.pattern??(t.pattern=hht),sc.init(n,t)}),vmt=Ln("$ZodKSUID",(n,t)=>{t.pattern??(t.pattern=mht),sc.init(n,t)}),Zmt=Ln("$ZodISODateTime",(n,t)=>{t.pattern??(t.pattern=Yht(t)),sc.init(n,t)}),Nmt=Ln("$ZodISODate",(n,t)=>{t.pattern??(t.pattern=Eht),sc.init(n,t)}),Wmt=Ln("$ZodISOTime",(n,t)=>{t.pattern??(t.pattern=Cht(t)),sc.init(n,t)}),Amt=Ln("$ZodISODuration",(n,t)=>{t.pattern??(t.pattern=bht),sc.init(n,t)}),Fmt=Ln("$ZodIPv4",(n,t)=>{t.pattern??(t.pattern=vht),sc.init(n,t),n._zod.onattach.push(r=>{let a=r._zod.bag;a.format="ipv4"})}),ymt=Ln("$ZodIPv6",(n,t)=>{t.pattern??(t.pattern=Zht),sc.init(n,t),n._zod.onattach.push(r=>{let a=r._zod.bag;a.format="ipv6"}),n._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:n,continue:!t.abort})}}}),Rmt=Ln("$ZodCIDRv4",(n,t)=>{t.pattern??(t.pattern=Nht),sc.init(n,t)}),Emt=Ln("$ZodCIDRv6",(n,t)=>{t.pattern??(t.pattern=Wht),sc.init(n,t),n._zod.check=r=>{let[a,i]=r.value.split("/");try{if(!i)throw new Error;let s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${a}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:n,continue:!t.abort})}}});Cmt=Ln("$ZodBase64",(n,t)=>{t.pattern??(t.pattern=Aht),sc.init(n,t),n._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),n._zod.check=r=>{wmt(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:n,continue:!t.abort})}});Ymt=Ln("$ZodBase64URL",(n,t)=>{t.pattern??(t.pattern=_Fe),sc.init(n,t),n._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),n._zod.check=r=>{BDn(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:n,continue:!t.abort})}}),xmt=Ln("$ZodE164",(n,t)=>{t.pattern??(t.pattern=yht),sc.init(n,t)});Vmt=Ln("$ZodJWT",(n,t)=>{sc.init(n,t),n._zod.check=r=>{DDn(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:n,continue:!t.abort})}}),eye=Ln("$ZodNumber",(n,t)=>{$s.init(n,t),n._zod.pattern=n._zod.bag.pattern??Hht,n._zod.parse=(r,a)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let s=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:n,...s?{received:s}:{}}),r}}),Qmt=Ln("$ZodNumber",(n,t)=>{Dht.init(n,t),eye.init(n,t)}),Hmt=Ln("$ZodBoolean",(n,t)=>{$s.init(n,t),n._zod.pattern=Xht,n._zod.parse=(r,a)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:n}),r}}),Xmt=Ln("$ZodBigInt",(n,t)=>{$s.init(n,t),n._zod.pattern=Vht,n._zod.parse=(r,a)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:n}),r}}),kmt=Ln("$ZodNull",(n,t)=>{$s.init(n,t),n._zod.pattern=kht,n._zod.values=new Set([null]),n._zod.parse=(r,a)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:n}),r}}),Lmt=Ln("$ZodAny",(n,t)=>{$s.init(n,t),n._zod.parse=r=>r}),Jmt=Ln("$ZodUnknown",(n,t)=>{$s.init(n,t),n._zod.parse=r=>r}),Smt=Ln("$ZodNever",(n,t)=>{$s.init(n,t),n._zod.parse=(r,a)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:n}),r)}),Bmt=Ln("$ZodDate",(n,t)=>{$s.init(n,t),n._zod.parse=(r,a)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let i=r.value,s=i instanceof Date;return s&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...s?{received:"Invalid Date"}:{},inst:n}),r}});Dmt=Ln("$ZodArray",(n,t)=>{$s.init(n,t),n._zod.parse=(r,a)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:n}),r;r.value=Array(i.length);let s=[];for(let e=0;e<i.length;e++){let c=i[e],u=t.element._zod.run({value:c,issues:[]},a);u instanceof Promise?s.push(u.then(d=>tmt(d,r,e))):tmt(u,r,e)}return s.length?Promise.all(s).then(()=>r):r}});Tmt=Ln("$ZodObject",(n,t)=>{$s.init(n,t);let r=gO(()=>{let h=Object.keys(t.shape);for(let f of h)if(!(t.shape[f]instanceof $s))throw new Error(`Invalid element at key "${f}": expected a Zod schema`);let o=kFe(t.shape);return{shape:t.shape,keys:h,keySet:new Set(h),numKeys:h.length,optionalKeys:new Set(o)}});Uo(n._zod,"propValues",()=>{let h=t.shape,o={};for(let f in h){let E=h[f]._zod;if(E.values){o[f]??(o[f]=new Set);for(let F of E.values)o[f].add(F)}}return o});let a=h=>{let o=new Rie(["shape","payload","ctx"]),f=r.value,E=C=>{let W=RC(C);return`shape[${W}]._zod.run({ value: input[${W}], issues: [] }, ctx)`};o.write("const input = payload.value;");let F=Object.create(null),w=0;for(let C of f.keys)F[C]=`key_${w++}`;o.write("const newResult = {}");for(let C of f.keys)if(f.optionalKeys.has(C)){let W=F[C];o.write(`const ${W} = ${E(C)};`);let y=RC(C);o.write(`
|
|
664
664
|
if (${W}.issues.length) {
|
|
@@ -4269,7 +4269,7 @@ ${Oe("model.command.auto.mode")}`),a({type:"info",text:o},Date.now()),r(null)}ca
|
|
|
4269
4269
|
`,t-1),[i,s]=tXr(r);return{line:a===-1?i:n.slice(0,a+1).match(/\n/g).length+i,column:t-a-1+s}}function q7e(n,t,r){if(typeof n!="string")throw new TypeError("Text parameter should be a string");if(!Number.isInteger(t))throw new TypeError("Index parameter should be an integer");if(t<0||t>n.length)throw new RangeError("Index out of bounds");return nXr(n,t,r)}var rXr=n=>`\\u{${n.codePointAt(0).toString(16)}}`,$7e=class n extends Error{name="JSONError";fileName;#e;#t;#n;#r;#a;constructor(t){if(typeof t=="string")super(),this.#n=t;else{let{jsonParseError:r,fileName:a,input:i}=t;super(void 0,{cause:r}),this.#e=i,this.#t=r,this.fileName=a}Error.captureStackTrace?.(this,n)}get message(){this.#n??=`${iXr(this.#t.message)}${this.#e===""?" while parsing empty string":""}`;let{codeFrame:t}=this;return`${this.#n}${this.fileName?` in ${this.fileName}`:""}${t?`
|
|
4270
4270
|
|
|
4271
4271
|
${t}
|
|
4272
|
-
`:""}`}set message(t){this.#n=t}#i(t){if(!this.#t)return;let r=this.#e,a=aXr(r,this.#t.message);if(a)return(0,Prn.codeFrameColumns)(r,{start:a},{highlightCode:t})}get codeFrame(){return this.#r??=this.#i(!0),this.#r}get rawCodeFrame(){return this.#a??=this.#i(!1),this.#a}},aXr=(n,t)=>{let r=t.match(/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/);if(!r)return;let{index:a,line:i,column:s}=r.groups;return i&&s?{line:Number(i),column:Number(s)}:q7e(n,Number(a),{oneBased:!0})},iXr=n=>n.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,r,a)=>`"${a}"(${rXr(a)})`);function eDe(n,t,r){typeof t=="string"&&(r=t,t=void 0);try{return JSON.parse(n,t)}catch(a){throw new $7e({jsonParseError:a,fileName:r,input:n})}}var iin=Ht(rin(),1);import{fileURLToPath as E6r}from"node:url";function ain(n){return n instanceof URL?E6r(n):n}var Y6r=n=>C6r.resolve(ain(n)??".","package.json"),x6r=(n,t)=>{let r=typeof n=="string"?eDe(n):n;return t&&(0,iin.default)(r),r};async function lin({cwd:n,normalize:t=!0}={}){let r=await w6r.readFile(Y6r(n),"utf8");return x6r(r,t)}async function sin(n){let t=await Arn("package.json",n);if(t)return{packageJson:await lin({...n,cwd:V6r.dirname(t)}),path:t}}import{fileURLToPath as Q6r}from"url";import H6r from"path";var X6r=Q6r(import.meta.url),k6r=H6r.dirname(X6r),s2e;async function EB(){if(s2e)return s2e;let n=await sin({cwd:k6r});if(n)return s2e=n.packageJson,s2e}async function wB(){let n=await EB();return"1.0.
|
|
4272
|
+
`:""}`}set message(t){this.#n=t}#i(t){if(!this.#t)return;let r=this.#e,a=aXr(r,this.#t.message);if(a)return(0,Prn.codeFrameColumns)(r,{start:a},{highlightCode:t})}get codeFrame(){return this.#r??=this.#i(!0),this.#r}get rawCodeFrame(){return this.#a??=this.#i(!1),this.#a}},aXr=(n,t)=>{let r=t.match(/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/);if(!r)return;let{index:a,line:i,column:s}=r.groups;return i&&s?{line:Number(i),column:Number(s)}:q7e(n,Number(a),{oneBased:!0})},iXr=n=>n.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,r,a)=>`"${a}"(${rXr(a)})`);function eDe(n,t,r){typeof t=="string"&&(r=t,t=void 0);try{return JSON.parse(n,t)}catch(a){throw new $7e({jsonParseError:a,fileName:r,input:n})}}var iin=Ht(rin(),1);import{fileURLToPath as E6r}from"node:url";function ain(n){return n instanceof URL?E6r(n):n}var Y6r=n=>C6r.resolve(ain(n)??".","package.json"),x6r=(n,t)=>{let r=typeof n=="string"?eDe(n):n;return t&&(0,iin.default)(r),r};async function lin({cwd:n,normalize:t=!0}={}){let r=await w6r.readFile(Y6r(n),"utf8");return x6r(r,t)}async function sin(n){let t=await Arn("package.json",n);if(t)return{packageJson:await lin({...n,cwd:V6r.dirname(t)}),path:t}}import{fileURLToPath as Q6r}from"url";import H6r from"path";var X6r=Q6r(import.meta.url),k6r=H6r.dirname(X6r),s2e;async function EB(){if(s2e)return s2e;let n=await sin({cwd:k6r});if(n)return s2e=n.packageJson,s2e}async function wB(){let n=await EB();return"1.0.268"}fi();import AV from"node:process";gr();var oin={name:"about",description:Oe("command.about.description"),kind:"built-in",action:async n=>{let t=AV.platform,r="no sandbox";AV.env.SANDBOX&&AV.env.SANDBOX!=="sandbox-exec"?r=AV.env.SANDBOX:AV.env.SANDBOX==="sandbox-exec"&&(r=`sandbox-exec (${AV.env.SEATBELT_PROFILE||"unknown"})`);let a=n.services.config?.getModel()||"Unknown",i=await wB(),s=n.services.settings.merged.selectedAuthType||"",e=AV.env.GOOGLE_CLOUD_PROJECT||"",c={type:"about",cliVersion:i,osVersion:t,sandboxEnv:r,modelVersion:a,selectedAuthType:s,gcpProject:e};n.ui.addItem(c,Date.now())}};fi();gr();var cin={name:"auth",description:Oe("command.auth.description"),kind:"built-in",action:(n,t)=>({type:"dialog",dialog:"auth"})};fi();gr();var Iin={name:"clear",description:Oe("command.clear.description"),kind:"built-in",action:async(n,t)=>{n.ui.setDebugMessage("Clearing terminal screen."),n.ui.clear()}};fi();gr();var uin={name:"compress",altNames:["summarize"],description:Oe("command.compress.description"),kind:"built-in",action:async n=>{let{ui:t}=n,r=n.services.config?.getGeminiClient();if(t.pendingItem){t.addItem({type:"error",text:"Already compressing, wait for previous request to complete"},Date.now());return}if(r?.isCompressionInProgress()){t.addItem({type:"error",text:"Compression already in progress at client level, please wait"},Date.now());return}t.addItem({type:"info",text:Oe("command.compress.starting")},Date.now());let a={type:"compression",compression:{isPending:!0,originalTokenCount:null,newTokenCount:null}};try{t.setPendingItem(a);let i=`compress-${Date.now()}`,s=await r?.tryCompressChat(i,new AbortController().signal,!0);s?t.addItem({type:"compression",compression:{isPending:!1,originalTokenCount:s.originalTokenCount,newTokenCount:s.newTokenCount}},Date.now()):t.addItem({type:"error",text:"Failed to compress chat history."},Date.now())}catch(i){t.addItem({type:"error",text:`Failed to compress chat history: ${i instanceof Error?i.message:String(i)}`},Date.now())}finally{t.setPendingItem(null)}}};fi();gr();var din={name:"copy",description:Oe("command.copy.description"),kind:"built-in",action:async(n,t)=>{let a=(await n.services.config?.getGeminiClient()?.getChat())?.getHistory(),i=a?a.filter(e=>e.role==="model").pop():void 0;if(!i)return{type:"message",messageType:"info",content:"No output in history"};let s=i.parts?.filter(e=>e.text).map(e=>e.text).join("");if(s)try{return await $tn(s),{type:"message",messageType:"info",content:"\u{1F4CB}\u5DF2\u590D\u5236\u5230\u7C98\u8D34\u677F"}}catch(e){let c=e instanceof Error?e.message:String(e);return console.debug(c),{type:"message",messageType:"error",content:"Failed to copy to the clipboard."}}else return{type:"message",messageType:"info",content:"Last AI output contains no text to copy."}}};fi();gr();var hin={name:"editor",description:Oe("command.editor.description"),kind:"built-in",action:()=>({type:"dialog",dialog:"editor"})};fi();gr();vr();import{promises as NDe}from"fs";import*as CB from"path";import{execFile as WDe}from"child_process";function L6r(n){return new Promise(t=>{let r=process.platform;try{if(r==="darwin")WDe("open",["-R",n],a=>{a&&console.warn(`Unable to open file in Finder: ${a.message}`),t()});else if(r==="win32"){let a=CB.win32.normalize(n);WDe("explorer.exe",[`/select,${a}`],i=>{i&&console.warn(`Unable to open file in Explorer: ${i.message}`),t()})}else WDe("xdg-open",[CB.dirname(n)],a=>{a&&console.warn(`Unable to open file browser: ${a.message}`),t()})}catch(a){console.warn(`Error opening file browser: ${a instanceof Error?a.message:String(a)}`),t()}})}async function o2e(n,t){try{await NDe.access(t,NDe.constants.W_OK)}catch(h){throw new Error(`No write permission for project root: ${t}. Error: ${h instanceof Error?h.message:String(h)}`)}let r=new Bs(t),a;try{a=await r.loadSession(n)}catch(h){throw new Error(`Failed to load session ${n}. Error: ${h instanceof Error?h.message:String(h)}`)}if(!a)throw new Error(`Session ${n} not found or returned null.`);if(!a.history)throw new Error(`Session ${n} has no history. Session data may be corrupted.`);if(a.history.length===0)throw new Error(`Session ${n} has empty history.`);a.metadata||(console.warn(`Session ${n} metadata is missing. Using defaults.`),a.metadata={title:n,createdAt:new Date().toISOString(),model:"Unknown"});let i=`
|
|
4273
4273
|
`,s="# Session Log: "+(a.metadata.title||n)+i+i;s+="- **Session ID:** "+n+i,s+="- **Date:** "+new Date(a.metadata.createdAt||new Date).toLocaleString()+i,s+="- **Model:** "+(a.metadata.model||"Unknown")+i+i,s+="---"+i+i;let e=new Map;if(a.clientHistory&&Array.isArray(a.clientHistory)){for(let h of a.clientHistory)if(h.parts&&Array.isArray(h.parts))for(let o of h.parts)o.functionCall&&o.functionCall.id&&e.set(o.functionCall.id,o.functionCall.args)}function c(h,o=0){let f="",E=" ".repeat(o);for(let F of h){let w=e.get(F.callId)||F.confirmationDetails?.args||{},A=w.absolute_path||w.file_path||w.path||w.filePath,C=A?`${F.name}: ${A}`:F.name;f+=E+"<details>"+i,f+=E+"<summary>"+C+" ("+(F.status||"Success")+")</summary>"+i+i;let y=JSON.stringify(w,null,2).split(`
|
|
4274
4274
|
`).map(b=>E+b).join(i);if(f+=E+"**Arguments:**"+i+E+"```json"+i+y+i+E+"```"+i+i,F.resultDisplay){let b=(F.resultDisplay.content||"").split(`
|
|
4275
4275
|
`).map(g=>E+g).join(i);f+=E+"**Result:**"+i+b+i+i}F.subToolCalls&&Array.isArray(F.subToolCalls)&&F.subToolCalls.length>0&&(f+=E+"#### \u21B3 Sub-tool Calls"+i+i,f+=c(F.subToolCalls,o+2)),f+=E+"</details>"+i+i}return f}for(let h of a.history)if(h.type==="user"){let o=(h.text||"").trim();o&&(s+="### \u{1F464} User"+i+i+o+i+i)}else if(h.type==="gemini"||h.type==="gemini_content"){let o=(h.text||"").trim();o&&(s+="### \u{1F916} Assistant"+i+i+o+i+i)}else if(h.type==="deepv"){let o=(h.content||"").trim();o&&(s+="### \u{1F916} Assistant (System)"+i+i+o+i+i)}else if(h.type==="tool_group"&&h.tools&&Array.isArray(h.tools)&&h.tools.length>0){let o=c(h.tools,0);o.trim()&&(s+="#### \u{1F6E0}\uFE0F Tool Calls"+i+i,s+=o)}let u=new Date().toISOString().slice(0,19).replace(/[T:]/g,"-"),d="session_export_"+n.substring(0,8)+"_"+u+".md",I=CB.resolve(t,d);try{await NDe.writeFile(I,s,"utf-8")}catch(h){throw new Error(`Failed to write session export file to ${I}. Error: ${h instanceof Error?h.message:String(h)}`)}return await L6r(I),I}var min={name:"export",description:Oe("command.export.description"),kind:"built-in",action:async n=>{let{config:t}=n.services;if(!t)return{type:"message",messageType:"error",content:Oe("export.no_config")};let r=t.getSessionId(),a=t.getProjectRoot()||process.cwd();try{let i=await o2e(r,a);return{type:"message",messageType:"info",content:rn("export.success",{path:i})}}catch(i){return{type:"message",messageType:"error",content:rn("export.failed",{error:i instanceof Error?i.message:String(i)})}}}};fi();gr();import{promises as ADe}from"fs";import*as YB from"path";import{execFile as FDe}from"child_process";function J6r(n){return new Promise(t=>{let r=process.platform;try{if(r==="darwin")FDe("open",["-R",n],a=>{a&&console.warn(`Unable to open file in Finder: ${a.message}`),t()});else if(r==="win32"){let a=YB.win32.normalize(n);FDe("explorer.exe",[`/select,${a}`],i=>{i&&console.warn(`Unable to open file in Explorer: ${i.message}`),t()})}else FDe("xdg-open",[YB.dirname(n)],a=>{a&&console.warn(`Unable to open file browser: ${a.message}`),t()})}catch(a){console.warn(`Error opening file browser: ${a instanceof Error?a.message:String(a)}`),t()}})}async function pin(n,t,r){try{await ADe.access(t,ADe.constants.W_OK)}catch(d){throw new Error(`No write permission for project root: ${t}. Error: ${d instanceof Error?d.message:String(d)}`)}if(!n||n.length===0)throw new Error("No debug messages to export.");let a=n.filter(d=>!d||typeof d!="object"?(console.warn("Skipping invalid debug message item."),!1):!d.type||!d.content?(console.warn("Skipping debug message with missing type or content. Message:",d),!1):d.type==="error"||d.type==="warn");if(a.length===0)throw new Error("NO_ERRORS_OR_WARNINGS");let i=`
|