deepv-code 1.0.247 → 1.0.248
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 +7 -5
- package/package.json +1 -1
package/bundle/dvcode.js
CHANGED
|
@@ -492,7 +492,7 @@ https://cloud.google.com/docs/authentication/getting-started`,NO_CREDENTIALS_FOU
|
|
|
492
492
|
To learn more about authentication and Google APIs, visit:
|
|
493
493
|
https://cloud.google.com/docs/authentication/getting-started`,NO_ADC_FOUND:"Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.",NO_UNIVERSE_DOMAIN_FOUND:`Unable to detect a Universe Domain in the current environment.
|
|
494
494
|
To learn more about Universe Domain retrieval, visit:
|
|
495
|
-
https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};var Hfe=class{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#e=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(t={}){if(this._cachedProjectId=t.projectId||null,this.cachedCredential=t.authClient||null,this.keyFilename=t.keyFilename||t.keyFile,this.scopes=t.scopes,this.clientOptions=t.clientOptions||{},this.jsonContent=t.credentials||null,this.apiKey=t.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw new RangeError(Kf.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);t.universeDomain&&(this.clientOptions.universeDomain=t.universeDomain)}setGapicJWTValues(t){t.defaultServicePath=this.defaultServicePath,t.useJWTAccessWithScope=this.useJWTAccessWithScope,t.defaultScopes=this.defaultScopes}getProjectId(t){if(t)this.getProjectIdAsync().then(r=>t(null,r),t);else return this.getProjectIdAsync()}async getProjectIdOptional(){try{return await this.getProjectId()}catch(t){if(t instanceof Error&&t.message===Kf.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;throw t}}async findAndCacheProjectId(){let t=null;if(t||=await this.getProductionProjectId(),t||=await this.getFileProjectId(),t||=await this.getDefaultServiceProjectId(),t||=await this.getGCEProjectId(),t||=await this.getExternalAccountClientProjectId(),t)return this._cachedProjectId=t,t;throw new Error(Kf.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){return this._cachedProjectId?this._cachedProjectId:(this._findProjectIdPromise||(this._findProjectIdPromise=this.findAndCacheProjectId()),this._findProjectIdPromise)}async getUniverseDomainFromMetadataServer(){let t;try{t=await D8.universe("universe-domain"),t||=Qfe.DEFAULT_UNIVERSE}catch(r){if(r&&r?.response?.status===404)t=Qfe.DEFAULT_UNIVERSE;else throw r}return t}async getUniverseDomain(){let t=(0,qPe.originalOrCamelOptions)(this.clientOptions).get("universe_domain");try{t??=(await this.getClient()).universeDomain}catch{t??=Qfe.DEFAULT_UNIVERSE}return t}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(t={},r){let a;if(typeof t=="function"?r=t:a=t,r)this.getApplicationDefaultAsync(a).then(i=>r(null,i.credential,i.projectId),r);else return this.getApplicationDefaultAsync(a)}async getApplicationDefaultAsync(t={}){if(this.cachedCredential)return await this.#t(this.cachedCredential,null);let r;if(r=await this._tryGetApplicationCredentialsFromEnvironmentVariable(t),r)return r instanceof _Q.JWT?r.scopes=this.scopes:r instanceof T8.BaseExternalAccountClient&&(r.scopes=this.getAnyScopes()),await this.#t(r);if(r=await this._tryGetApplicationCredentialsFromWellKnownFile(t),r)return r instanceof _Q.JWT?r.scopes=this.scopes:r instanceof T8.BaseExternalAccountClient&&(r.scopes=this.getAnyScopes()),await this.#t(r);if(await this._checkIsGCE())return t.scopes=this.getAnyScopes(),await this.#t(new QZn.Compute(t));throw new Error(Kf.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async#t(t,r=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let a=await this.getProjectIdOptional();return r&&(t.quotaProjectId=r),this.cachedCredential=t,{credential:t,projectId:a}}async _checkIsGCE(){return this.checkIsGCE===void 0&&(this.checkIsGCE=D8.getGCPResidency()||await D8.isAvailable()),this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(t){let r=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!r||r.length===0)return null;try{return this._getApplicationCredentialsFromFilePath(r,t)}catch(a){throw a instanceof Error&&(a.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${a.message}`),a}}async _tryGetApplicationCredentialsFromWellKnownFile(t){let r=null;if(this._isWindows())r=process.env.APPDATA;else{let i=process.env.HOME;i&&(r=xfe.join(i,".config"))}return r&&(r=xfe.join(r,"gcloud","application_default_credentials.json"),S8.existsSync(r)||(r=null)),r?await this._getApplicationCredentialsFromFilePath(r,t):null}async _getApplicationCredentialsFromFilePath(t,r={}){if(!t||t.length===0)throw new Error("The file path is invalid.");try{if(t=S8.realpathSync(t),!S8.lstatSync(t).isFile())throw new Error}catch(i){throw i instanceof Error&&(i.message=`The file at ${t} does not exist, or it is not a file. ${i.message}`),i}let a=S8.createReadStream(t);return this.fromStream(a,r)}fromImpersonatedJSON(t){if(!t)throw new Error("Must pass in a JSON object containing an impersonated refresh token");if(t.type!==PQ.IMPERSONATED_ACCOUNT_TYPE)throw new Error(`The incoming JSON object does not have the "${PQ.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!t.source_credentials)throw new Error("The incoming JSON object does not contain a source_credentials field");if(!t.service_account_impersonation_url)throw new Error("The incoming JSON object does not contain a service_account_impersonation_url field");let r=this.fromJSON(t.source_credentials);if(t.service_account_impersonation_url?.length>256)throw new RangeError(`Target principal is too long: ${t.service_account_impersonation_url}`);let a=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(t.service_account_impersonation_url)?.groups?.target;if(!a)throw new RangeError(`Cannot extract target principal from ${t.service_account_impersonation_url}`);let i=(this.scopes||t.scopes||this.defaultScopes)??[];return new PQ.Impersonated({...t,sourceClient:r,targetPrincipal:a,targetScopes:Array.isArray(i)?i:[i]})}fromJSON(t,r={}){let a,i=(0,qPe.originalOrCamelOptions)(r).get("universe_domain");return t.type===jPe.USER_REFRESH_ACCOUNT_TYPE?(a=new jPe.UserRefreshClient(r),a.fromJSON(t)):t.type===PQ.IMPERSONATED_ACCOUNT_TYPE?a=this.fromImpersonatedJSON(t):t.type===T8.EXTERNAL_ACCOUNT_TYPE?(a=kZn.ExternalAccountClient.fromJSON({...t,...r}),a.scopes=this.getAnyScopes()):t.type===KPe.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE?a=new KPe.ExternalAccountAuthorizedUserClient({...t,...r}):(r.scopes=this.scopes,a=new _Q.JWT(r),this.setGapicJWTValues(a),a.fromJSON(t)),i&&(a.universeDomain=i),a}_cacheClientFromJSON(t,r){let a=this.fromJSON(t,r);return this.jsonContent=t,this.cachedCredential=a,a}fromStream(t,r={},a){let i={};if(typeof r=="function"?a=r:i=r,a)this.fromStreamAsync(t,i).then(s=>a(null,s),a);else return this.fromStreamAsync(t,i)}fromStreamAsync(t,r){return new Promise((a,i)=>{if(!t)throw new Error("Must pass in a stream containing the Google auth settings.");let s=[];t.setEncoding("utf8").on("error",i).on("data",e=>s.push(e)).on("end",()=>{try{try{let e=JSON.parse(s.join("")),c=this._cacheClientFromJSON(e,r);return a(c)}catch(e){if(!this.keyFilename)throw e;let c=new _Q.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=c,this.setGapicJWTValues(c),a(c)}}catch(e){return i(e)}})})}fromAPIKey(t,r={}){return new _Q.JWT({...r,apiKey:t})}_isWindows(){let t=VZn.platform();return!!(t&&t.length>=3&&t.substring(0,3).toLowerCase()==="win")}async getDefaultServiceProjectId(){return new Promise(t=>{(0,YZn.exec)("gcloud config config-helper --format json",(r,a)=>{if(!r&&a)try{let i=JSON.parse(a).configuration.properties.core.project;t(i);return}catch{}t(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let r=await this.getClient();if(r&&r.projectId)return r.projectId}let t=await this._tryGetApplicationCredentialsFromEnvironmentVariable();return t?t.projectId:null}async getExternalAccountClientProjectId(){return!this.jsonContent||this.jsonContent.type!==T8.EXTERNAL_ACCOUNT_TYPE?null:await(await this.getClient()).getProjectId()}async getGCEProjectId(){try{return await D8.project("project-id")}catch{return null}}getCredentials(t){if(t)this.getCredentialsAsync().then(r=>t(null,r),t);else return this.getCredentialsAsync()}async getCredentialsAsync(){let t=await this.getClient();if(t instanceof PQ.Impersonated)return{client_email:t.getTargetPrincipal()};if(t instanceof T8.BaseExternalAccountClient){let r=t.getServiceAccountEmail();if(r)return{client_email:r,universe_domain:t.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[r,a]=await Promise.all([D8.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:r,universe_domain:a}}throw new Error(Kf.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#e=this.#e||this.#n();try{return await this.#e}finally{this.#e=null}}async#n(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);if(this.keyFilename){let t=xfe.resolve(this.keyFilename),r=S8.createReadStream(t);return await this.fromStreamAsync(r,this.clientOptions)}else if(this.apiKey){let t=await this.fromAPIKey(this.apiKey,this.clientOptions);t.scopes=this.scopes;let{credential:r}=await this.#t(t);return r}else{let{credential:t}=await this.getApplicationDefaultAsync(this.clientOptions);return t}}async getIdTokenClient(t){let r=await this.getClient();if(!("fetchIdToken"in r))throw new Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new HZn.IdTokenClient({targetAudience:t,idTokenProvider:r})}async getAccessToken(){return(await(await this.getClient()).getAccessToken()).token}async getRequestHeaders(t){return(await this.getClient()).getRequestHeaders(t)}async authorizeRequest(t={}){let r=t.url,i=await(await this.getClient()).getRequestHeaders(r);return t.headers=CZn.Gaxios.mergeHeaders(t.headers,i),t}async fetch(...t){return(await this.getClient()).fetch(...t)}async request(t){return(await this.getClient()).request(t)}getEnv(){return(0,XZn.getEnv)()}async sign(t,r){let a=await this.getClient(),i=await this.getUniverseDomain();if(r=r||`https://iamcredentials.${i}/v1/projects/-/serviceAccounts/`,a instanceof PQ.Impersonated)return(await a.sign(t)).signedBlob;let s=(0,xZn.createCrypto)();if(a instanceof _Q.JWT&&a.key)return await s.sign(a.key,t);let e=await this.getCredentials();if(!e.client_email)throw new Error("Cannot sign data without `client_email`.");return this.signBlob(s,e.client_email,t,r)}async signBlob(t,r,a,i){let s=new URL(i+`${r}:signBlob`);return(await this.request({method:"POST",url:s.href,data:{payload:t.encodeBase64StringUtf8(a)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}};Kf.GoogleAuth=Hfe});var eje=ke(_$=>{"use strict";Object.defineProperty(_$,"__esModule",{value:!0});_$.IAMAuth=void 0;var Xfe=class{selector;token;constructor(t,r){this.selector=t,this.token=r,this.selector=t,this.token=r}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}};_$.IAMAuth=Xfe});var tje=ke(uZ=>{"use strict";Object.defineProperty(uZ,"__esModule",{value:!0});uZ.DownscopedClient=uZ.EXPIRATION_TIME_OFFSET=uZ.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;var LZn=l0(),JZn=Ct("stream"),kfe=q2(),BZn=E$(),SZn="urn:ietf:params:oauth:grant-type:token-exchange",DZn="urn:ietf:params:oauth:token-type:access_token",TZn="urn:ietf:params:oauth:token-type:access_token";uZ.MAX_ACCESS_BOUNDARY_RULES_COUNT=10;uZ.EXPIRATION_TIME_OFFSET=300*1e3;var Lfe=class extends kfe.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(t,r={accessBoundary:{accessBoundaryRules:[]}}){if(super(t instanceof kfe.AuthClient?{}:t),t instanceof kfe.AuthClient?(this.authClient=t,this.credentialAccessBoundary=r):(this.authClient=t.authClient,this.credentialAccessBoundary=t.credentialAccessBoundary),this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length===0)throw new Error("At least one access boundary rule needs to be defined.");if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>uZ.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw new Error(`The provided access boundary has more than ${uZ.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(let a of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(a.availablePermissions.length===0)throw new Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new BZn.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(t){if(!t.expiry_date)throw new Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(t),this.cachedDownscopedAccessToken=t}async getAccessToken(){return(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let t=await this.getAccessToken(),r=new Headers({authorization:`Bearer ${t.token}`});return this.addSharedMetadataHeaders(r)}request(t,r){if(r)this.requestAsync(t).then(a=>r(null,a),a=>r(a,a.response));else return this.requestAsync(t)}async requestAsync(t,r=!1){let a;try{let i=await this.getRequestHeaders();t.headers=LZn.Gaxios.mergeHeaders(t.headers),this.addUserProjectAndAuthHeaders(t.headers,i),a=await this.transporter.request(t)}catch(i){let s=i.response;if(s){let e=s.status,c=s.config.data instanceof JZn.Readable;if(!r&&(e===401||e===403)&&!c&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(t,!0)}throw i}return a}async refreshAccessTokenAsync(){let t=(await this.authClient.getAccessToken()).token,r={grantType:SZn,requestedTokenType:DZn,subjectToken:t,subjectTokenType:TZn},a=await this.stsCredential.exchangeToken(r,void 0,this.credentialAccessBoundary),i=this.authClient.credentials?.expiry_date||null,s=a.expires_in?new Date().getTime()+a.expires_in*1e3:i;return this.cachedDownscopedAccessToken={access_token:a.access_token,expiry_date:s,res:a.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(t){let r=new Date().getTime();return t.expiry_date?r>=t.expiry_date-this.eagerRefreshThresholdMillis:!1}};uZ.DownscopedClient=Lfe});var nje=ke(P$=>{"use strict";Object.defineProperty(P$,"__esModule",{value:!0});P$.PassThroughClient=void 0;var OZn=q2(),Jfe=class extends OZn.AuthClient{async request(t){return this.transporter.request(t)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}};P$.PassThroughClient=Jfe});var sje=ke(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});Ia.GoogleAuth=Ia.auth=Ia.PassThroughClient=Ia.ExternalAccountAuthorizedUserClient=Ia.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=Ia.ExecutableError=Ia.PluggableAuthClient=Ia.DownscopedClient=Ia.BaseExternalAccountClient=Ia.ExternalAccountClient=Ia.IdentityPoolClient=Ia.AwsRequestSigner=Ia.AwsClient=Ia.UserRefreshClient=Ia.LoginTicket=Ia.ClientAuthentication=Ia.OAuth2Client=Ia.CodeChallengeMethod=Ia.Impersonated=Ia.JWT=Ia.JWTAccess=Ia.IdTokenClient=Ia.IAMAuth=Ia.GCPEnv=Ia.Compute=Ia.DEFAULT_UNIVERSE=Ia.AuthClient=Ia.gaxios=Ia.gcpMetadata=void 0;var rje=$Pe();Object.defineProperty(Ia,"GoogleAuth",{enumerable:!0,get:function(){return rje.GoogleAuth}});Ia.gcpMetadata=R8();Ia.gaxios=l0();var aje=q2();Object.defineProperty(Ia,"AuthClient",{enumerable:!0,get:function(){return aje.AuthClient}});Object.defineProperty(Ia,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return aje.DEFAULT_UNIVERSE}});var UZn=y1e();Object.defineProperty(Ia,"Compute",{enumerable:!0,get:function(){return UZn.Compute}});var MZn=w1e();Object.defineProperty(Ia,"GCPEnv",{enumerable:!0,get:function(){return MZn.GCPEnv}});var zZn=eje();Object.defineProperty(Ia,"IAMAuth",{enumerable:!0,get:function(){return zZn.IAMAuth}});var _Zn=E1e();Object.defineProperty(Ia,"IdTokenClient",{enumerable:!0,get:function(){return _Zn.IdTokenClient}});var PZn=M1e();Object.defineProperty(Ia,"JWTAccess",{enumerable:!0,get:function(){return PZn.JWTAccess}});var jZn=_1e();Object.defineProperty(Ia,"JWT",{enumerable:!0,get:function(){return jZn.JWT}});var KZn=q1e();Object.defineProperty(Ia,"Impersonated",{enumerable:!0,get:function(){return KZn.Impersonated}});var Bfe=hE();Object.defineProperty(Ia,"CodeChallengeMethod",{enumerable:!0,get:function(){return Bfe.CodeChallengeMethod}});Object.defineProperty(Ia,"OAuth2Client",{enumerable:!0,get:function(){return Bfe.OAuth2Client}});Object.defineProperty(Ia,"ClientAuthentication",{enumerable:!0,get:function(){return Bfe.ClientAuthentication}});var qZn=N1e();Object.defineProperty(Ia,"LoginTicket",{enumerable:!0,get:function(){return qZn.LoginTicket}});var $Zn=j1e();Object.defineProperty(Ia,"UserRefreshClient",{enumerable:!0,get:function(){return $Zn.UserRefreshClient}});var e3n=Gfe();Object.defineProperty(Ia,"AwsClient",{enumerable:!0,get:function(){return e3n.AwsClient}});var t3n=mfe();Object.defineProperty(Ia,"AwsRequestSigner",{enumerable:!0,get:function(){return t3n.AwsRequestSigner}});var n3n=dfe();Object.defineProperty(Ia,"IdentityPoolClient",{enumerable:!0,get:function(){return n3n.IdentityPoolClient}});var r3n=wfe();Object.defineProperty(Ia,"ExternalAccountClient",{enumerable:!0,get:function(){return r3n.ExternalAccountClient}});var a3n=IF();Object.defineProperty(Ia,"BaseExternalAccountClient",{enumerable:!0,get:function(){return a3n.BaseExternalAccountClient}});var i3n=tje();Object.defineProperty(Ia,"DownscopedClient",{enumerable:!0,get:function(){return i3n.DownscopedClient}});var ije=Rfe();Object.defineProperty(Ia,"PluggableAuthClient",{enumerable:!0,get:function(){return ije.PluggableAuthClient}});Object.defineProperty(Ia,"ExecutableError",{enumerable:!0,get:function(){return ije.ExecutableError}});var lje=Vfe();Object.defineProperty(Ia,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return lje.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}});Object.defineProperty(Ia,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return lje.ExternalAccountAuthorizedUserClient}});var l3n=nje();Object.defineProperty(Ia,"PassThroughClient",{enumerable:!0,get:function(){return l3n.PassThroughClient}});var s3n=new rje.GoogleAuth;Ia.auth=s3n});function lKe(n){return{text:n}}function sKe(n){return typeof n=="object"&&n!==null?"fileData"in n||"text"in n||"functionCall"in n||"functionResponse"in n||"inlineData"in n||"videoMetadata"in n||"codeExecutionResult"in n||"executableCode"in n:!1}function c3n(n){let t=[];if(typeof n=="string")t.push(lKe(n));else if(sKe(n))t.push(n);else if(Array.isArray(n)){if(n.length===0)throw new Error("partOrString cannot be an empty array");for(let r of n)if(typeof r=="string")t.push(lKe(r));else if(sKe(r))t.push(r);else throw new Error("element in PartUnion must be a Part object or string")}else throw new Error("partOrString must be a Part object, string, or array");return t}function Sfe(n){return{role:"user",parts:c3n(n)}}function I3n(n,t={}){let r=n,a={name:r.name,description:r.description,parametersJsonSchema:r.inputSchema};return r.outputSchema&&(a.responseJsonSchema=r.outputSchema),t.behavior&&(a.behavior=t.behavior),{functionDeclarations:[a]}}function u3n(n,t={}){let r=[],a=new Set;for(let i of n){let s=i.name;if(a.has(s))throw new Error(`Duplicate function name ${s} found in MCP tools. Please ensure function names are unique.`);a.add(s);let e=I3n(i,t);e.functionDeclarations&&r.push(...e.functionDeclarations)}return{functionDeclarations:r}}function cKe(n){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&n[t],a=0;if(r)return r.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&a>=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function O8(n){return this instanceof O8?(this.v=n,this):new O8(n)}function d3n(n,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=r.apply(n,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",e),i[Symbol.asyncIterator]=function(){return this},i;function e(v){return function(w){return Promise.resolve(w).then(v,h)}}function c(v,w){a[v]&&(i[v]=function(R){return new Promise(function(E,A){s.push([v,R,E,A])>1||u(v,R)})},w&&(i[v]=w(i[v])))}function u(v,w){try{d(a[v](w))}catch(R){o(s[0][3],R)}}function d(v){v.value instanceof O8?Promise.resolve(v.value.v).then(I,h):o(s[0][2],v)}function I(v){u("next",v)}function h(v){u("throw",v)}function o(v,w){v(w),s.shift(),s.length&&u(s[0][0],s[0][1])}}function h3n(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],r;return t?t.call(n):(n=typeof cKe=="function"?cKe(n):n[Symbol.iterator](),r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r);function a(s){r[s]=n[s]&&function(e){return new Promise(function(c,u){e=n[s](e),i(c,u,e.done,e.value)})}}function i(s,e,c,u){Promise.resolve(u).then(function(d){s({value:d,done:c})},e)}}function b3n(n,t=100){return d3n(this,arguments,function*(){let a,i=0;for(;i<t;){let s=yield O8(n.listTools({cursor:a}));for(let e of s.tools)yield yield O8(e),i++;if(!s.nextCursor)break;a=s.nextCursor}})}function G3n(n){return n!==null&&typeof n=="object"&&"listTools"in n&&typeof n.listTools=="function"}function IKe(...n){if(p3n=!0,n.length===0)throw new Error("No MCP clients provided");let t=n[n.length-1];return G3n(t)?K$.create(n,{}):K$.create(n.slice(0,n.length-1),t)}var o3n,oje,cje,Ije,xn,uje,dje,hje,mje,pje,bje,Gje,fje,gje,mI,vje,Zje,Nje,Wje,Aje,Fje,yje,Rje,Eje,wje,Yje,Cje,Vje,xje,Qje,Hje,jQ,Xje,kje,Lje,Jje,Bje,Sje,Dje,Tje,Oje,Uje,Mje,zje,_je,Pje,jje,Kje,qje,$je,eKe,tKe,nKe,rKe,aKe,iKe,j$,KQ,oKe,m3n,lKr,p3n,K$,sKr,Ol=ut(()=>{o3n=Tt(sje(),1);i8();(function(n){n.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",n.OUTCOME_OK="OUTCOME_OK",n.OUTCOME_FAILED="OUTCOME_FAILED",n.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(oje||(oje={}));(function(n){n.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",n.PYTHON="PYTHON"})(cje||(cje={}));(function(n){n.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",n.SILENT="SILENT",n.WHEN_IDLE="WHEN_IDLE",n.INTERRUPT="INTERRUPT"})(Ije||(Ije={}));(function(n){n.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",n.STRING="STRING",n.NUMBER="NUMBER",n.INTEGER="INTEGER",n.BOOLEAN="BOOLEAN",n.ARRAY="ARRAY",n.OBJECT="OBJECT",n.NULL="NULL"})(xn||(xn={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.MODE_DYNAMIC="MODE_DYNAMIC"})(uje||(uje={}));(function(n){n.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",n.SIMPLE_SEARCH="SIMPLE_SEARCH",n.ELASTIC_SEARCH="ELASTIC_SEARCH"})(dje||(dje={}));(function(n){n.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",n.NO_AUTH="NO_AUTH",n.API_KEY_AUTH="API_KEY_AUTH",n.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",n.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",n.OAUTH="OAUTH",n.OIDC_AUTH="OIDC_AUTH"})(hje||(hje={}));(function(n){n.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",n.HTTP_IN_QUERY="HTTP_IN_QUERY",n.HTTP_IN_HEADER="HTTP_IN_HEADER",n.HTTP_IN_PATH="HTTP_IN_PATH",n.HTTP_IN_BODY="HTTP_IN_BODY",n.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(mje||(mje={}));(function(n){n.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",n.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",n.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",n.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(pje||(pje={}));(function(n){n.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",n.LOW="LOW",n.HIGH="HIGH"})(bje||(bje={}));(function(n){n.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",n.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",n.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",n.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",n.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",n.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",n.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",n.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",n.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",n.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",n.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(Gje||(Gje={}));(function(n){n.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",n.SEVERITY="SEVERITY",n.PROBABILITY="PROBABILITY"})(fje||(fje={}));(function(n){n.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",n.BLOCK_NONE="BLOCK_NONE",n.OFF="OFF"})(gje||(gje={}));(function(n){n.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",n.STOP="STOP",n.MAX_TOKENS="MAX_TOKENS",n.SAFETY="SAFETY",n.RECITATION="RECITATION",n.LANGUAGE="LANGUAGE",n.OTHER="OTHER",n.BLOCKLIST="BLOCKLIST",n.PROHIBITED_CONTENT="PROHIBITED_CONTENT",n.SPII="SPII",n.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",n.IMAGE_SAFETY="IMAGE_SAFETY",n.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",n.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",n.NO_IMAGE="NO_IMAGE"})(mI||(mI={}));(function(n){n.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",n.NEGLIGIBLE="NEGLIGIBLE",n.LOW="LOW",n.MEDIUM="MEDIUM",n.HIGH="HIGH"})(vje||(vje={}));(function(n){n.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",n.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",n.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",n.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",n.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(Zje||(Zje={}));(function(n){n.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",n.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",n.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",n.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",n.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(Nje||(Nje={}));(function(n){n.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",n.SAFETY="SAFETY",n.OTHER="OTHER",n.BLOCKLIST="BLOCKLIST",n.PROHIBITED_CONTENT="PROHIBITED_CONTENT",n.IMAGE_SAFETY="IMAGE_SAFETY",n.MODEL_ARMOR="MODEL_ARMOR",n.JAILBREAK="JAILBREAK"})(Wje||(Wje={}));(function(n){n.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",n.ON_DEMAND="ON_DEMAND",n.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Aje||(Aje={}));(function(n){n.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",n.TEXT="TEXT",n.IMAGE="IMAGE",n.AUDIO="AUDIO"})(Fje||(Fje={}));(function(n){n.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",n.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",n.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",n.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(yje||(yje={}));(function(n){n.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",n.TUNING_MODE_FULL="TUNING_MODE_FULL",n.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(Rje||(Rje={}));(function(n){n.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",n.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",n.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",n.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",n.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",n.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",n.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(Eje||(Eje={}));(function(n){n.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",n.JOB_STATE_QUEUED="JOB_STATE_QUEUED",n.JOB_STATE_PENDING="JOB_STATE_PENDING",n.JOB_STATE_RUNNING="JOB_STATE_RUNNING",n.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",n.JOB_STATE_FAILED="JOB_STATE_FAILED",n.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",n.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",n.JOB_STATE_PAUSED="JOB_STATE_PAUSED",n.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",n.JOB_STATE_UPDATING="JOB_STATE_UPDATING",n.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(wje||(wje={}));(function(n){n.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",n.TUNING_TASK_I2V="TUNING_TASK_I2V",n.TUNING_TASK_T2V="TUNING_TASK_T2V",n.TUNING_TASK_R2V="TUNING_TASK_R2V"})(Yje||(Yje={}));(function(n){n.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",n.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",n.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",n.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(Cje||(Cje={}));(function(n){n.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",n.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",n.BALANCED="BALANCED",n.PRIORITIZE_COST="PRIORITIZE_COST"})(Vje||(Vje={}));(function(n){n.UNSPECIFIED="UNSPECIFIED",n.BLOCKING="BLOCKING",n.NON_BLOCKING="NON_BLOCKING"})(xje||(xje={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.MODE_DYNAMIC="MODE_DYNAMIC"})(Qje||(Qje={}));(function(n){n.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",n.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(Hje||(Hje={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.AUTO="AUTO",n.ANY="ANY",n.NONE="NONE",n.VALIDATED="VALIDATED"})(jQ||(jQ={}));(function(n){n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",n.BLOCK_NONE="BLOCK_NONE"})(Xje||(Xje={}));(function(n){n.DONT_ALLOW="DONT_ALLOW",n.ALLOW_ADULT="ALLOW_ADULT",n.ALLOW_ALL="ALLOW_ALL"})(kje||(kje={}));(function(n){n.auto="auto",n.en="en",n.ja="ja",n.ko="ko",n.hi="hi",n.zh="zh",n.pt="pt",n.es="es"})(Lje||(Lje={}));(function(n){n.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",n.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",n.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",n.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",n.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(Jje||(Jje={}));(function(n){n.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",n.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",n.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",n.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(Bje||(Bje={}));(function(n){n.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",n.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",n.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",n.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(Sje||(Sje={}));(function(n){n.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",n.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",n.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",n.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",n.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",n.EDIT_MODE_STYLE="EDIT_MODE_STYLE",n.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",n.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(Dje||(Dje={}));(function(n){n.FOREGROUND="FOREGROUND",n.BACKGROUND="BACKGROUND",n.PROMPT="PROMPT",n.SEMANTIC="SEMANTIC",n.INTERACTIVE="INTERACTIVE"})(Tje||(Tje={}));(function(n){n.ASSET="ASSET",n.STYLE="STYLE"})(Oje||(Oje={}));(function(n){n.INSERT="INSERT",n.REMOVE="REMOVE",n.REMOVE_STATIC="REMOVE_STATIC",n.OUTPAINT="OUTPAINT"})(Uje||(Uje={}));(function(n){n.OPTIMIZED="OPTIMIZED",n.LOSSLESS="LOSSLESS"})(Mje||(Mje={}));(function(n){n.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",n.PREFERENCE_TUNING="PREFERENCE_TUNING"})(zje||(zje={}));(function(n){n.STATE_UNSPECIFIED="STATE_UNSPECIFIED",n.STATE_PENDING="STATE_PENDING",n.STATE_ACTIVE="STATE_ACTIVE",n.STATE_FAILED="STATE_FAILED"})(_je||(_je={}));(function(n){n.STATE_UNSPECIFIED="STATE_UNSPECIFIED",n.PROCESSING="PROCESSING",n.ACTIVE="ACTIVE",n.FAILED="FAILED"})(Pje||(Pje={}));(function(n){n.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",n.UPLOADED="UPLOADED",n.GENERATED="GENERATED"})(jje||(jje={}));(function(n){n.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",n.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",n.RESPONSE_REJECTED="RESPONSE_REJECTED",n.NEED_MORE_INPUT="NEED_MORE_INPUT"})(Kje||(Kje={}));(function(n){n.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",n.TEXT="TEXT",n.IMAGE="IMAGE",n.VIDEO="VIDEO",n.AUDIO="AUDIO",n.DOCUMENT="DOCUMENT"})(qje||(qje={}));(function(n){n.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",n.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",n.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})($je||($je={}));(function(n){n.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",n.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",n.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(eKe||(eKe={}));(function(n){n.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",n.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",n.NO_INTERRUPTION="NO_INTERRUPTION"})(tKe||(tKe={}));(function(n){n.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",n.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",n.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(nKe||(nKe={}));(function(n){n.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",n.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",n.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",n.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",n.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",n.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",n.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",n.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",n.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",n.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",n.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",n.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",n.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(rKe||(rKe={}));(function(n){n.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",n.QUALITY="QUALITY",n.DIVERSITY="DIVERSITY",n.VOCALIZATION="VOCALIZATION"})(aKe||(aKe={}));(function(n){n.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",n.PLAY="PLAY",n.PAUSE="PAUSE",n.STOP="STOP",n.RESET_CONTEXT="RESET_CONTEXT"})(iKe||(iKe={}));j$=class{},KQ=class{get text(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let d="",I=!1,h=[];for(let o of(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)!==null&&u!==void 0?u:[]){for(let[v,w]of Object.entries(o))v!=="text"&&v!=="thought"&&v!=="thoughtSignature"&&(w!==null||w!==void 0)&&h.push(v);if(typeof o.text=="string"){if(typeof o.thought=="boolean"&&o.thought)continue;I=!0,d+=o.text}}return h.length>0&&console.warn(`there are non-text parts ${h} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),I?d:void 0}get data(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let d="",I=[];for(let h of(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)!==null&&u!==void 0?u:[]){for(let[o,v]of Object.entries(h))o!=="inlineData"&&(v!==null||v!==void 0)&&I.push(o);h.inlineData&&typeof h.inlineData.data=="string"&&(d+=atob(h.inlineData.data))}return I.length>0&&console.warn(`there are non-data parts ${I} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),d.length>0?btoa(d):void 0}get functionCalls(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.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 d=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(I=>I.functionCall).map(I=>I.functionCall).filter(I=>I!==void 0);if(d?.length!==0)return d}get executableCode(){var t,r,a,i,s,e,c,u,d;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");let I=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(h=>h.executableCode).map(h=>h.executableCode).filter(h=>h!==void 0);if(I?.length!==0)return(d=I?.[0])===null||d===void 0?void 0:d.code}get codeExecutionResult(){var t,r,a,i,s,e,c,u,d;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");let I=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(h=>h.codeExecutionResult).map(h=>h.codeExecutionResult).filter(h=>h!==void 0);if(I?.length!==0)return(d=I?.[0])===null||d===void 0?void 0:d.output}};(function(n){n.PAGED_ITEM_BATCH_JOBS="batchJobs",n.PAGED_ITEM_MODELS="models",n.PAGED_ITEM_TUNING_JOBS="tuningJobs",n.PAGED_ITEM_FILES="files",n.PAGED_ITEM_CACHED_CONTENTS="cachedContents",n.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",n.PAGED_ITEM_DOCUMENTS="documents"})(oKe||(oKe={}));m3n="1.30.0",lKr=`google-genai-sdk/${m3n}`;p3n=!1;K$=class n{constructor(t=[],r){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=t,this.config=r}static create(t,r){return new n(t,r)}async initialize(){var t,r,a,i;if(this.mcpTools.length>0)return;let s={},e=[];for(let I of this.mcpClients)try{for(var c=!0,u=(r=void 0,h3n(b3n(I))),d;d=await u.next(),t=d.done,!t;c=!0){i=d.value,c=!1;let h=i;e.push(h);let o=h.name;if(s[o])throw new Error(`Duplicate function name ${o} found in MCP tools. Please ensure function names are unique.`);s[o]=I}}catch(h){r={error:h}}finally{try{!c&&!t&&(a=u.return)&&await a.call(u)}finally{if(r)throw r.error}}this.mcpTools=e,this.functionNameToMcpClient=s}async tool(){return await this.initialize(),u3n(this.mcpTools,this.config)}async callTool(t){await this.initialize();let r=[];for(let a of t)if(a.name in this.functionNameToMcpClient){let i=this.functionNameToMcpClient[a.name],s;this.config.timeout&&(s={timeout:this.config.timeout});let e=await i.callTool({name:a.name,arguments:a.args},void 0,s);r.push({functionResponse:{name:a.name,response:e.isError?{error:e}:e}})}return r}};sKr=1024*1024*8;});function f3n(n,t){return{...n,...t}}function uKe(n){let{prompt_id:t,...r}=n;return r}function pE(n){return Array.isArray(n)?n.map(uKe):n}var q$=ut(()=>{"use strict";Ol();});var dKe={};Ms(dKe,{DEFAULT_PROXY_CONFIG:()=>Z3n,getActiveProxyServerUrl:()=>dZ,getAvailableProxyServers:()=>g3n,getProxyServerInfo:()=>v3n,getProxyServers:()=>U8,hasAvailableProxyServer:()=>Dfe});function U8(){return[{url:"https://api-code.deepvlab.ai",name:"Primary Development Server",region:"default",status:"active"}]}function dZ(){let t=U8().find(r=>r.status==="active");if(!t)throw new Error("No active proxy server available. Please contact support.");return t.url}function g3n(){return U8().filter(t=>t.status==="active")}function Dfe(){return U8().some(t=>t.status==="active")}function v3n(n){return U8().find(r=>r.url===n)}var Z3n,qQ=ut(()=>{"use strict";Z3n={serverUrl:dZ(),timeout:2e5,retryAttempts:3,retryDelay:1e3}});import*as yo from"fs";import*as qf from"path";import*as bE from"os";function N3n(n){ns.configure(n)}function W3n(n){ns.setUserInfo(n)}function A3n(n){ns.setCliVersion(n)}async function F3n(){return await ns.getUserHeaders()}function y3n(){return ns.getStatus()}var M8,ys,ns,uF=ut(()=>{"use strict";qQ();M8=259200,ys=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=qf.join(bE.homedir(),".deepv","user-info-dev.json"),this.jwtTokenFilePath=qf.join(bE.homedir(),".deepv","jwt-token-dev.json"),this.usageStatsFilePath=qf.join(bE.homedir(),".deepv","usage-stats-dev.json")):(this.userInfoFilePath=qf.join(bE.homedir(),".deepv","user-info.json"),this.jwtTokenFilePath=qf.join(bE.homedir(),".deepv","jwt-token.json"),this.usageStatsFilePath=qf.join(bE.homedir(),".deepv","usage-stats.json")),this.cliVersion="1.0.247",this.config={proxyServerUrl:dZ()},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-M8*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(yo.existsSync(this.userInfoFilePath)){let t=yo.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=qf.dirname(this.userInfoFilePath);yo.existsSync(t)||yo.mkdirSync(t,{recursive:!0}),yo.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(yo.existsSync(this.jwtTokenFilePath)){let t=yo.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=qf.dirname(this.jwtTokenFilePath);yo.existsSync(t)||yo.mkdirSync(t,{recursive:!0}),yo.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(yo.existsSync(this.usageStatsFilePath)){let t=yo.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=qf.dirname(this.usageStatsFilePath);yo.existsSync(t)||yo.mkdirSync(t,{recursive:!0}),yo.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-M8*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-M8*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=M8){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-M8*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{yo.existsSync(this.jwtTokenFilePath)&&yo.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{yo.existsSync(this.userInfoFilePath)&&yo.unlinkSync(this.userInfoFilePath)}catch(t){console.warn("[Login Check] Failed to delete user info file:",t)}try{yo.existsSync(this.jwtTokenFilePath)&&yo.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}console.log("[Login Check] Authentication cleared")}},ns=ys.getInstance()});import{promises as GE}from"node:fs";import z8 from"node:path";import R3n from"os";var rb,$$,er,xG=ut(()=>{"use strict";(function(n){n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR"})(rb||(rb={}));$$=class{config;logBuffer=[];constructor(t={}){if(this.config={level:rb.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=z8.join(R3n.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 GE.mkdir(z8.dirname(this.config.filePath),{recursive:!0}),await this.rotateLogIfNeeded(),await GE.appendFile(this.config.filePath,t+`
|
|
495
|
+
https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};var Hfe=class{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#e=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(t={}){if(this._cachedProjectId=t.projectId||null,this.cachedCredential=t.authClient||null,this.keyFilename=t.keyFilename||t.keyFile,this.scopes=t.scopes,this.clientOptions=t.clientOptions||{},this.jsonContent=t.credentials||null,this.apiKey=t.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw new RangeError(Kf.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);t.universeDomain&&(this.clientOptions.universeDomain=t.universeDomain)}setGapicJWTValues(t){t.defaultServicePath=this.defaultServicePath,t.useJWTAccessWithScope=this.useJWTAccessWithScope,t.defaultScopes=this.defaultScopes}getProjectId(t){if(t)this.getProjectIdAsync().then(r=>t(null,r),t);else return this.getProjectIdAsync()}async getProjectIdOptional(){try{return await this.getProjectId()}catch(t){if(t instanceof Error&&t.message===Kf.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;throw t}}async findAndCacheProjectId(){let t=null;if(t||=await this.getProductionProjectId(),t||=await this.getFileProjectId(),t||=await this.getDefaultServiceProjectId(),t||=await this.getGCEProjectId(),t||=await this.getExternalAccountClientProjectId(),t)return this._cachedProjectId=t,t;throw new Error(Kf.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){return this._cachedProjectId?this._cachedProjectId:(this._findProjectIdPromise||(this._findProjectIdPromise=this.findAndCacheProjectId()),this._findProjectIdPromise)}async getUniverseDomainFromMetadataServer(){let t;try{t=await D8.universe("universe-domain"),t||=Qfe.DEFAULT_UNIVERSE}catch(r){if(r&&r?.response?.status===404)t=Qfe.DEFAULT_UNIVERSE;else throw r}return t}async getUniverseDomain(){let t=(0,qPe.originalOrCamelOptions)(this.clientOptions).get("universe_domain");try{t??=(await this.getClient()).universeDomain}catch{t??=Qfe.DEFAULT_UNIVERSE}return t}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(t={},r){let a;if(typeof t=="function"?r=t:a=t,r)this.getApplicationDefaultAsync(a).then(i=>r(null,i.credential,i.projectId),r);else return this.getApplicationDefaultAsync(a)}async getApplicationDefaultAsync(t={}){if(this.cachedCredential)return await this.#t(this.cachedCredential,null);let r;if(r=await this._tryGetApplicationCredentialsFromEnvironmentVariable(t),r)return r instanceof _Q.JWT?r.scopes=this.scopes:r instanceof T8.BaseExternalAccountClient&&(r.scopes=this.getAnyScopes()),await this.#t(r);if(r=await this._tryGetApplicationCredentialsFromWellKnownFile(t),r)return r instanceof _Q.JWT?r.scopes=this.scopes:r instanceof T8.BaseExternalAccountClient&&(r.scopes=this.getAnyScopes()),await this.#t(r);if(await this._checkIsGCE())return t.scopes=this.getAnyScopes(),await this.#t(new QZn.Compute(t));throw new Error(Kf.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async#t(t,r=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let a=await this.getProjectIdOptional();return r&&(t.quotaProjectId=r),this.cachedCredential=t,{credential:t,projectId:a}}async _checkIsGCE(){return this.checkIsGCE===void 0&&(this.checkIsGCE=D8.getGCPResidency()||await D8.isAvailable()),this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(t){let r=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!r||r.length===0)return null;try{return this._getApplicationCredentialsFromFilePath(r,t)}catch(a){throw a instanceof Error&&(a.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${a.message}`),a}}async _tryGetApplicationCredentialsFromWellKnownFile(t){let r=null;if(this._isWindows())r=process.env.APPDATA;else{let i=process.env.HOME;i&&(r=xfe.join(i,".config"))}return r&&(r=xfe.join(r,"gcloud","application_default_credentials.json"),S8.existsSync(r)||(r=null)),r?await this._getApplicationCredentialsFromFilePath(r,t):null}async _getApplicationCredentialsFromFilePath(t,r={}){if(!t||t.length===0)throw new Error("The file path is invalid.");try{if(t=S8.realpathSync(t),!S8.lstatSync(t).isFile())throw new Error}catch(i){throw i instanceof Error&&(i.message=`The file at ${t} does not exist, or it is not a file. ${i.message}`),i}let a=S8.createReadStream(t);return this.fromStream(a,r)}fromImpersonatedJSON(t){if(!t)throw new Error("Must pass in a JSON object containing an impersonated refresh token");if(t.type!==PQ.IMPERSONATED_ACCOUNT_TYPE)throw new Error(`The incoming JSON object does not have the "${PQ.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!t.source_credentials)throw new Error("The incoming JSON object does not contain a source_credentials field");if(!t.service_account_impersonation_url)throw new Error("The incoming JSON object does not contain a service_account_impersonation_url field");let r=this.fromJSON(t.source_credentials);if(t.service_account_impersonation_url?.length>256)throw new RangeError(`Target principal is too long: ${t.service_account_impersonation_url}`);let a=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(t.service_account_impersonation_url)?.groups?.target;if(!a)throw new RangeError(`Cannot extract target principal from ${t.service_account_impersonation_url}`);let i=(this.scopes||t.scopes||this.defaultScopes)??[];return new PQ.Impersonated({...t,sourceClient:r,targetPrincipal:a,targetScopes:Array.isArray(i)?i:[i]})}fromJSON(t,r={}){let a,i=(0,qPe.originalOrCamelOptions)(r).get("universe_domain");return t.type===jPe.USER_REFRESH_ACCOUNT_TYPE?(a=new jPe.UserRefreshClient(r),a.fromJSON(t)):t.type===PQ.IMPERSONATED_ACCOUNT_TYPE?a=this.fromImpersonatedJSON(t):t.type===T8.EXTERNAL_ACCOUNT_TYPE?(a=kZn.ExternalAccountClient.fromJSON({...t,...r}),a.scopes=this.getAnyScopes()):t.type===KPe.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE?a=new KPe.ExternalAccountAuthorizedUserClient({...t,...r}):(r.scopes=this.scopes,a=new _Q.JWT(r),this.setGapicJWTValues(a),a.fromJSON(t)),i&&(a.universeDomain=i),a}_cacheClientFromJSON(t,r){let a=this.fromJSON(t,r);return this.jsonContent=t,this.cachedCredential=a,a}fromStream(t,r={},a){let i={};if(typeof r=="function"?a=r:i=r,a)this.fromStreamAsync(t,i).then(s=>a(null,s),a);else return this.fromStreamAsync(t,i)}fromStreamAsync(t,r){return new Promise((a,i)=>{if(!t)throw new Error("Must pass in a stream containing the Google auth settings.");let s=[];t.setEncoding("utf8").on("error",i).on("data",e=>s.push(e)).on("end",()=>{try{try{let e=JSON.parse(s.join("")),c=this._cacheClientFromJSON(e,r);return a(c)}catch(e){if(!this.keyFilename)throw e;let c=new _Q.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=c,this.setGapicJWTValues(c),a(c)}}catch(e){return i(e)}})})}fromAPIKey(t,r={}){return new _Q.JWT({...r,apiKey:t})}_isWindows(){let t=VZn.platform();return!!(t&&t.length>=3&&t.substring(0,3).toLowerCase()==="win")}async getDefaultServiceProjectId(){return new Promise(t=>{(0,YZn.exec)("gcloud config config-helper --format json",(r,a)=>{if(!r&&a)try{let i=JSON.parse(a).configuration.properties.core.project;t(i);return}catch{}t(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let r=await this.getClient();if(r&&r.projectId)return r.projectId}let t=await this._tryGetApplicationCredentialsFromEnvironmentVariable();return t?t.projectId:null}async getExternalAccountClientProjectId(){return!this.jsonContent||this.jsonContent.type!==T8.EXTERNAL_ACCOUNT_TYPE?null:await(await this.getClient()).getProjectId()}async getGCEProjectId(){try{return await D8.project("project-id")}catch{return null}}getCredentials(t){if(t)this.getCredentialsAsync().then(r=>t(null,r),t);else return this.getCredentialsAsync()}async getCredentialsAsync(){let t=await this.getClient();if(t instanceof PQ.Impersonated)return{client_email:t.getTargetPrincipal()};if(t instanceof T8.BaseExternalAccountClient){let r=t.getServiceAccountEmail();if(r)return{client_email:r,universe_domain:t.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[r,a]=await Promise.all([D8.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:r,universe_domain:a}}throw new Error(Kf.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#e=this.#e||this.#n();try{return await this.#e}finally{this.#e=null}}async#n(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);if(this.keyFilename){let t=xfe.resolve(this.keyFilename),r=S8.createReadStream(t);return await this.fromStreamAsync(r,this.clientOptions)}else if(this.apiKey){let t=await this.fromAPIKey(this.apiKey,this.clientOptions);t.scopes=this.scopes;let{credential:r}=await this.#t(t);return r}else{let{credential:t}=await this.getApplicationDefaultAsync(this.clientOptions);return t}}async getIdTokenClient(t){let r=await this.getClient();if(!("fetchIdToken"in r))throw new Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new HZn.IdTokenClient({targetAudience:t,idTokenProvider:r})}async getAccessToken(){return(await(await this.getClient()).getAccessToken()).token}async getRequestHeaders(t){return(await this.getClient()).getRequestHeaders(t)}async authorizeRequest(t={}){let r=t.url,i=await(await this.getClient()).getRequestHeaders(r);return t.headers=CZn.Gaxios.mergeHeaders(t.headers,i),t}async fetch(...t){return(await this.getClient()).fetch(...t)}async request(t){return(await this.getClient()).request(t)}getEnv(){return(0,XZn.getEnv)()}async sign(t,r){let a=await this.getClient(),i=await this.getUniverseDomain();if(r=r||`https://iamcredentials.${i}/v1/projects/-/serviceAccounts/`,a instanceof PQ.Impersonated)return(await a.sign(t)).signedBlob;let s=(0,xZn.createCrypto)();if(a instanceof _Q.JWT&&a.key)return await s.sign(a.key,t);let e=await this.getCredentials();if(!e.client_email)throw new Error("Cannot sign data without `client_email`.");return this.signBlob(s,e.client_email,t,r)}async signBlob(t,r,a,i){let s=new URL(i+`${r}:signBlob`);return(await this.request({method:"POST",url:s.href,data:{payload:t.encodeBase64StringUtf8(a)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}};Kf.GoogleAuth=Hfe});var eje=ke(_$=>{"use strict";Object.defineProperty(_$,"__esModule",{value:!0});_$.IAMAuth=void 0;var Xfe=class{selector;token;constructor(t,r){this.selector=t,this.token=r,this.selector=t,this.token=r}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}};_$.IAMAuth=Xfe});var tje=ke(uZ=>{"use strict";Object.defineProperty(uZ,"__esModule",{value:!0});uZ.DownscopedClient=uZ.EXPIRATION_TIME_OFFSET=uZ.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;var LZn=l0(),JZn=Ct("stream"),kfe=q2(),BZn=E$(),SZn="urn:ietf:params:oauth:grant-type:token-exchange",DZn="urn:ietf:params:oauth:token-type:access_token",TZn="urn:ietf:params:oauth:token-type:access_token";uZ.MAX_ACCESS_BOUNDARY_RULES_COUNT=10;uZ.EXPIRATION_TIME_OFFSET=300*1e3;var Lfe=class extends kfe.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(t,r={accessBoundary:{accessBoundaryRules:[]}}){if(super(t instanceof kfe.AuthClient?{}:t),t instanceof kfe.AuthClient?(this.authClient=t,this.credentialAccessBoundary=r):(this.authClient=t.authClient,this.credentialAccessBoundary=t.credentialAccessBoundary),this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length===0)throw new Error("At least one access boundary rule needs to be defined.");if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>uZ.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw new Error(`The provided access boundary has more than ${uZ.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(let a of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(a.availablePermissions.length===0)throw new Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new BZn.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(t){if(!t.expiry_date)throw new Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(t),this.cachedDownscopedAccessToken=t}async getAccessToken(){return(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))&&await this.refreshAccessTokenAsync(),{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let t=await this.getAccessToken(),r=new Headers({authorization:`Bearer ${t.token}`});return this.addSharedMetadataHeaders(r)}request(t,r){if(r)this.requestAsync(t).then(a=>r(null,a),a=>r(a,a.response));else return this.requestAsync(t)}async requestAsync(t,r=!1){let a;try{let i=await this.getRequestHeaders();t.headers=LZn.Gaxios.mergeHeaders(t.headers),this.addUserProjectAndAuthHeaders(t.headers,i),a=await this.transporter.request(t)}catch(i){let s=i.response;if(s){let e=s.status,c=s.config.data instanceof JZn.Readable;if(!r&&(e===401||e===403)&&!c&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(t,!0)}throw i}return a}async refreshAccessTokenAsync(){let t=(await this.authClient.getAccessToken()).token,r={grantType:SZn,requestedTokenType:DZn,subjectToken:t,subjectTokenType:TZn},a=await this.stsCredential.exchangeToken(r,void 0,this.credentialAccessBoundary),i=this.authClient.credentials?.expiry_date||null,s=a.expires_in?new Date().getTime()+a.expires_in*1e3:i;return this.cachedDownscopedAccessToken={access_token:a.access_token,expiry_date:s,res:a.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(t){let r=new Date().getTime();return t.expiry_date?r>=t.expiry_date-this.eagerRefreshThresholdMillis:!1}};uZ.DownscopedClient=Lfe});var nje=ke(P$=>{"use strict";Object.defineProperty(P$,"__esModule",{value:!0});P$.PassThroughClient=void 0;var OZn=q2(),Jfe=class extends OZn.AuthClient{async request(t){return this.transporter.request(t)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}};P$.PassThroughClient=Jfe});var sje=ke(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});Ia.GoogleAuth=Ia.auth=Ia.PassThroughClient=Ia.ExternalAccountAuthorizedUserClient=Ia.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=Ia.ExecutableError=Ia.PluggableAuthClient=Ia.DownscopedClient=Ia.BaseExternalAccountClient=Ia.ExternalAccountClient=Ia.IdentityPoolClient=Ia.AwsRequestSigner=Ia.AwsClient=Ia.UserRefreshClient=Ia.LoginTicket=Ia.ClientAuthentication=Ia.OAuth2Client=Ia.CodeChallengeMethod=Ia.Impersonated=Ia.JWT=Ia.JWTAccess=Ia.IdTokenClient=Ia.IAMAuth=Ia.GCPEnv=Ia.Compute=Ia.DEFAULT_UNIVERSE=Ia.AuthClient=Ia.gaxios=Ia.gcpMetadata=void 0;var rje=$Pe();Object.defineProperty(Ia,"GoogleAuth",{enumerable:!0,get:function(){return rje.GoogleAuth}});Ia.gcpMetadata=R8();Ia.gaxios=l0();var aje=q2();Object.defineProperty(Ia,"AuthClient",{enumerable:!0,get:function(){return aje.AuthClient}});Object.defineProperty(Ia,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return aje.DEFAULT_UNIVERSE}});var UZn=y1e();Object.defineProperty(Ia,"Compute",{enumerable:!0,get:function(){return UZn.Compute}});var MZn=w1e();Object.defineProperty(Ia,"GCPEnv",{enumerable:!0,get:function(){return MZn.GCPEnv}});var zZn=eje();Object.defineProperty(Ia,"IAMAuth",{enumerable:!0,get:function(){return zZn.IAMAuth}});var _Zn=E1e();Object.defineProperty(Ia,"IdTokenClient",{enumerable:!0,get:function(){return _Zn.IdTokenClient}});var PZn=M1e();Object.defineProperty(Ia,"JWTAccess",{enumerable:!0,get:function(){return PZn.JWTAccess}});var jZn=_1e();Object.defineProperty(Ia,"JWT",{enumerable:!0,get:function(){return jZn.JWT}});var KZn=q1e();Object.defineProperty(Ia,"Impersonated",{enumerable:!0,get:function(){return KZn.Impersonated}});var Bfe=hE();Object.defineProperty(Ia,"CodeChallengeMethod",{enumerable:!0,get:function(){return Bfe.CodeChallengeMethod}});Object.defineProperty(Ia,"OAuth2Client",{enumerable:!0,get:function(){return Bfe.OAuth2Client}});Object.defineProperty(Ia,"ClientAuthentication",{enumerable:!0,get:function(){return Bfe.ClientAuthentication}});var qZn=N1e();Object.defineProperty(Ia,"LoginTicket",{enumerable:!0,get:function(){return qZn.LoginTicket}});var $Zn=j1e();Object.defineProperty(Ia,"UserRefreshClient",{enumerable:!0,get:function(){return $Zn.UserRefreshClient}});var e3n=Gfe();Object.defineProperty(Ia,"AwsClient",{enumerable:!0,get:function(){return e3n.AwsClient}});var t3n=mfe();Object.defineProperty(Ia,"AwsRequestSigner",{enumerable:!0,get:function(){return t3n.AwsRequestSigner}});var n3n=dfe();Object.defineProperty(Ia,"IdentityPoolClient",{enumerable:!0,get:function(){return n3n.IdentityPoolClient}});var r3n=wfe();Object.defineProperty(Ia,"ExternalAccountClient",{enumerable:!0,get:function(){return r3n.ExternalAccountClient}});var a3n=IF();Object.defineProperty(Ia,"BaseExternalAccountClient",{enumerable:!0,get:function(){return a3n.BaseExternalAccountClient}});var i3n=tje();Object.defineProperty(Ia,"DownscopedClient",{enumerable:!0,get:function(){return i3n.DownscopedClient}});var ije=Rfe();Object.defineProperty(Ia,"PluggableAuthClient",{enumerable:!0,get:function(){return ije.PluggableAuthClient}});Object.defineProperty(Ia,"ExecutableError",{enumerable:!0,get:function(){return ije.ExecutableError}});var lje=Vfe();Object.defineProperty(Ia,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return lje.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}});Object.defineProperty(Ia,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return lje.ExternalAccountAuthorizedUserClient}});var l3n=nje();Object.defineProperty(Ia,"PassThroughClient",{enumerable:!0,get:function(){return l3n.PassThroughClient}});var s3n=new rje.GoogleAuth;Ia.auth=s3n});function lKe(n){return{text:n}}function sKe(n){return typeof n=="object"&&n!==null?"fileData"in n||"text"in n||"functionCall"in n||"functionResponse"in n||"inlineData"in n||"videoMetadata"in n||"codeExecutionResult"in n||"executableCode"in n:!1}function c3n(n){let t=[];if(typeof n=="string")t.push(lKe(n));else if(sKe(n))t.push(n);else if(Array.isArray(n)){if(n.length===0)throw new Error("partOrString cannot be an empty array");for(let r of n)if(typeof r=="string")t.push(lKe(r));else if(sKe(r))t.push(r);else throw new Error("element in PartUnion must be a Part object or string")}else throw new Error("partOrString must be a Part object, string, or array");return t}function Sfe(n){return{role:"user",parts:c3n(n)}}function I3n(n,t={}){let r=n,a={name:r.name,description:r.description,parametersJsonSchema:r.inputSchema};return r.outputSchema&&(a.responseJsonSchema=r.outputSchema),t.behavior&&(a.behavior=t.behavior),{functionDeclarations:[a]}}function u3n(n,t={}){let r=[],a=new Set;for(let i of n){let s=i.name;if(a.has(s))throw new Error(`Duplicate function name ${s} found in MCP tools. Please ensure function names are unique.`);a.add(s);let e=I3n(i,t);e.functionDeclarations&&r.push(...e.functionDeclarations)}return{functionDeclarations:r}}function cKe(n){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&n[t],a=0;if(r)return r.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&a>=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function O8(n){return this instanceof O8?(this.v=n,this):new O8(n)}function d3n(n,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var a=r.apply(n,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",e),i[Symbol.asyncIterator]=function(){return this},i;function e(v){return function(w){return Promise.resolve(w).then(v,h)}}function c(v,w){a[v]&&(i[v]=function(R){return new Promise(function(E,A){s.push([v,R,E,A])>1||u(v,R)})},w&&(i[v]=w(i[v])))}function u(v,w){try{d(a[v](w))}catch(R){o(s[0][3],R)}}function d(v){v.value instanceof O8?Promise.resolve(v.value.v).then(I,h):o(s[0][2],v)}function I(v){u("next",v)}function h(v){u("throw",v)}function o(v,w){v(w),s.shift(),s.length&&u(s[0][0],s[0][1])}}function h3n(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],r;return t?t.call(n):(n=typeof cKe=="function"?cKe(n):n[Symbol.iterator](),r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r);function a(s){r[s]=n[s]&&function(e){return new Promise(function(c,u){e=n[s](e),i(c,u,e.done,e.value)})}}function i(s,e,c,u){Promise.resolve(u).then(function(d){s({value:d,done:c})},e)}}function b3n(n,t=100){return d3n(this,arguments,function*(){let a,i=0;for(;i<t;){let s=yield O8(n.listTools({cursor:a}));for(let e of s.tools)yield yield O8(e),i++;if(!s.nextCursor)break;a=s.nextCursor}})}function G3n(n){return n!==null&&typeof n=="object"&&"listTools"in n&&typeof n.listTools=="function"}function IKe(...n){if(p3n=!0,n.length===0)throw new Error("No MCP clients provided");let t=n[n.length-1];return G3n(t)?K$.create(n,{}):K$.create(n.slice(0,n.length-1),t)}var o3n,oje,cje,Ije,xn,uje,dje,hje,mje,pje,bje,Gje,fje,gje,mI,vje,Zje,Nje,Wje,Aje,Fje,yje,Rje,Eje,wje,Yje,Cje,Vje,xje,Qje,Hje,jQ,Xje,kje,Lje,Jje,Bje,Sje,Dje,Tje,Oje,Uje,Mje,zje,_je,Pje,jje,Kje,qje,$je,eKe,tKe,nKe,rKe,aKe,iKe,j$,KQ,oKe,m3n,lKr,p3n,K$,sKr,Ol=ut(()=>{o3n=Tt(sje(),1);i8();(function(n){n.OUTCOME_UNSPECIFIED="OUTCOME_UNSPECIFIED",n.OUTCOME_OK="OUTCOME_OK",n.OUTCOME_FAILED="OUTCOME_FAILED",n.OUTCOME_DEADLINE_EXCEEDED="OUTCOME_DEADLINE_EXCEEDED"})(oje||(oje={}));(function(n){n.LANGUAGE_UNSPECIFIED="LANGUAGE_UNSPECIFIED",n.PYTHON="PYTHON"})(cje||(cje={}));(function(n){n.SCHEDULING_UNSPECIFIED="SCHEDULING_UNSPECIFIED",n.SILENT="SILENT",n.WHEN_IDLE="WHEN_IDLE",n.INTERRUPT="INTERRUPT"})(Ije||(Ije={}));(function(n){n.TYPE_UNSPECIFIED="TYPE_UNSPECIFIED",n.STRING="STRING",n.NUMBER="NUMBER",n.INTEGER="INTEGER",n.BOOLEAN="BOOLEAN",n.ARRAY="ARRAY",n.OBJECT="OBJECT",n.NULL="NULL"})(xn||(xn={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.MODE_DYNAMIC="MODE_DYNAMIC"})(uje||(uje={}));(function(n){n.API_SPEC_UNSPECIFIED="API_SPEC_UNSPECIFIED",n.SIMPLE_SEARCH="SIMPLE_SEARCH",n.ELASTIC_SEARCH="ELASTIC_SEARCH"})(dje||(dje={}));(function(n){n.AUTH_TYPE_UNSPECIFIED="AUTH_TYPE_UNSPECIFIED",n.NO_AUTH="NO_AUTH",n.API_KEY_AUTH="API_KEY_AUTH",n.HTTP_BASIC_AUTH="HTTP_BASIC_AUTH",n.GOOGLE_SERVICE_ACCOUNT_AUTH="GOOGLE_SERVICE_ACCOUNT_AUTH",n.OAUTH="OAUTH",n.OIDC_AUTH="OIDC_AUTH"})(hje||(hje={}));(function(n){n.HTTP_IN_UNSPECIFIED="HTTP_IN_UNSPECIFIED",n.HTTP_IN_QUERY="HTTP_IN_QUERY",n.HTTP_IN_HEADER="HTTP_IN_HEADER",n.HTTP_IN_PATH="HTTP_IN_PATH",n.HTTP_IN_BODY="HTTP_IN_BODY",n.HTTP_IN_COOKIE="HTTP_IN_COOKIE"})(mje||(mje={}));(function(n){n.PHISH_BLOCK_THRESHOLD_UNSPECIFIED="PHISH_BLOCK_THRESHOLD_UNSPECIFIED",n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_HIGH_AND_ABOVE="BLOCK_HIGH_AND_ABOVE",n.BLOCK_HIGHER_AND_ABOVE="BLOCK_HIGHER_AND_ABOVE",n.BLOCK_VERY_HIGH_AND_ABOVE="BLOCK_VERY_HIGH_AND_ABOVE",n.BLOCK_ONLY_EXTREMELY_HIGH="BLOCK_ONLY_EXTREMELY_HIGH"})(pje||(pje={}));(function(n){n.THINKING_LEVEL_UNSPECIFIED="THINKING_LEVEL_UNSPECIFIED",n.LOW="LOW",n.HIGH="HIGH"})(bje||(bje={}));(function(n){n.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",n.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",n.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",n.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",n.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",n.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY",n.HARM_CATEGORY_IMAGE_HATE="HARM_CATEGORY_IMAGE_HATE",n.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT="HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT",n.HARM_CATEGORY_IMAGE_HARASSMENT="HARM_CATEGORY_IMAGE_HARASSMENT",n.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT="HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT",n.HARM_CATEGORY_JAILBREAK="HARM_CATEGORY_JAILBREAK"})(Gje||(Gje={}));(function(n){n.HARM_BLOCK_METHOD_UNSPECIFIED="HARM_BLOCK_METHOD_UNSPECIFIED",n.SEVERITY="SEVERITY",n.PROBABILITY="PROBABILITY"})(fje||(fje={}));(function(n){n.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",n.BLOCK_NONE="BLOCK_NONE",n.OFF="OFF"})(gje||(gje={}));(function(n){n.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",n.STOP="STOP",n.MAX_TOKENS="MAX_TOKENS",n.SAFETY="SAFETY",n.RECITATION="RECITATION",n.LANGUAGE="LANGUAGE",n.OTHER="OTHER",n.BLOCKLIST="BLOCKLIST",n.PROHIBITED_CONTENT="PROHIBITED_CONTENT",n.SPII="SPII",n.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",n.IMAGE_SAFETY="IMAGE_SAFETY",n.UNEXPECTED_TOOL_CALL="UNEXPECTED_TOOL_CALL",n.IMAGE_PROHIBITED_CONTENT="IMAGE_PROHIBITED_CONTENT",n.NO_IMAGE="NO_IMAGE"})(mI||(mI={}));(function(n){n.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",n.NEGLIGIBLE="NEGLIGIBLE",n.LOW="LOW",n.MEDIUM="MEDIUM",n.HIGH="HIGH"})(vje||(vje={}));(function(n){n.HARM_SEVERITY_UNSPECIFIED="HARM_SEVERITY_UNSPECIFIED",n.HARM_SEVERITY_NEGLIGIBLE="HARM_SEVERITY_NEGLIGIBLE",n.HARM_SEVERITY_LOW="HARM_SEVERITY_LOW",n.HARM_SEVERITY_MEDIUM="HARM_SEVERITY_MEDIUM",n.HARM_SEVERITY_HIGH="HARM_SEVERITY_HIGH"})(Zje||(Zje={}));(function(n){n.URL_RETRIEVAL_STATUS_UNSPECIFIED="URL_RETRIEVAL_STATUS_UNSPECIFIED",n.URL_RETRIEVAL_STATUS_SUCCESS="URL_RETRIEVAL_STATUS_SUCCESS",n.URL_RETRIEVAL_STATUS_ERROR="URL_RETRIEVAL_STATUS_ERROR",n.URL_RETRIEVAL_STATUS_PAYWALL="URL_RETRIEVAL_STATUS_PAYWALL",n.URL_RETRIEVAL_STATUS_UNSAFE="URL_RETRIEVAL_STATUS_UNSAFE"})(Nje||(Nje={}));(function(n){n.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",n.SAFETY="SAFETY",n.OTHER="OTHER",n.BLOCKLIST="BLOCKLIST",n.PROHIBITED_CONTENT="PROHIBITED_CONTENT",n.IMAGE_SAFETY="IMAGE_SAFETY",n.MODEL_ARMOR="MODEL_ARMOR",n.JAILBREAK="JAILBREAK"})(Wje||(Wje={}));(function(n){n.TRAFFIC_TYPE_UNSPECIFIED="TRAFFIC_TYPE_UNSPECIFIED",n.ON_DEMAND="ON_DEMAND",n.PROVISIONED_THROUGHPUT="PROVISIONED_THROUGHPUT"})(Aje||(Aje={}));(function(n){n.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",n.TEXT="TEXT",n.IMAGE="IMAGE",n.AUDIO="AUDIO"})(Fje||(Fje={}));(function(n){n.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",n.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",n.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",n.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(yje||(yje={}));(function(n){n.TUNING_MODE_UNSPECIFIED="TUNING_MODE_UNSPECIFIED",n.TUNING_MODE_FULL="TUNING_MODE_FULL",n.TUNING_MODE_PEFT_ADAPTER="TUNING_MODE_PEFT_ADAPTER"})(Rje||(Rje={}));(function(n){n.ADAPTER_SIZE_UNSPECIFIED="ADAPTER_SIZE_UNSPECIFIED",n.ADAPTER_SIZE_ONE="ADAPTER_SIZE_ONE",n.ADAPTER_SIZE_TWO="ADAPTER_SIZE_TWO",n.ADAPTER_SIZE_FOUR="ADAPTER_SIZE_FOUR",n.ADAPTER_SIZE_EIGHT="ADAPTER_SIZE_EIGHT",n.ADAPTER_SIZE_SIXTEEN="ADAPTER_SIZE_SIXTEEN",n.ADAPTER_SIZE_THIRTY_TWO="ADAPTER_SIZE_THIRTY_TWO"})(Eje||(Eje={}));(function(n){n.JOB_STATE_UNSPECIFIED="JOB_STATE_UNSPECIFIED",n.JOB_STATE_QUEUED="JOB_STATE_QUEUED",n.JOB_STATE_PENDING="JOB_STATE_PENDING",n.JOB_STATE_RUNNING="JOB_STATE_RUNNING",n.JOB_STATE_SUCCEEDED="JOB_STATE_SUCCEEDED",n.JOB_STATE_FAILED="JOB_STATE_FAILED",n.JOB_STATE_CANCELLING="JOB_STATE_CANCELLING",n.JOB_STATE_CANCELLED="JOB_STATE_CANCELLED",n.JOB_STATE_PAUSED="JOB_STATE_PAUSED",n.JOB_STATE_EXPIRED="JOB_STATE_EXPIRED",n.JOB_STATE_UPDATING="JOB_STATE_UPDATING",n.JOB_STATE_PARTIALLY_SUCCEEDED="JOB_STATE_PARTIALLY_SUCCEEDED"})(wje||(wje={}));(function(n){n.TUNING_TASK_UNSPECIFIED="TUNING_TASK_UNSPECIFIED",n.TUNING_TASK_I2V="TUNING_TASK_I2V",n.TUNING_TASK_T2V="TUNING_TASK_T2V",n.TUNING_TASK_R2V="TUNING_TASK_R2V"})(Yje||(Yje={}));(function(n){n.MEDIA_RESOLUTION_UNSPECIFIED="MEDIA_RESOLUTION_UNSPECIFIED",n.MEDIA_RESOLUTION_LOW="MEDIA_RESOLUTION_LOW",n.MEDIA_RESOLUTION_MEDIUM="MEDIA_RESOLUTION_MEDIUM",n.MEDIA_RESOLUTION_HIGH="MEDIA_RESOLUTION_HIGH"})(Cje||(Cje={}));(function(n){n.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED="FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",n.PRIORITIZE_QUALITY="PRIORITIZE_QUALITY",n.BALANCED="BALANCED",n.PRIORITIZE_COST="PRIORITIZE_COST"})(Vje||(Vje={}));(function(n){n.UNSPECIFIED="UNSPECIFIED",n.BLOCKING="BLOCKING",n.NON_BLOCKING="NON_BLOCKING"})(xje||(xje={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.MODE_DYNAMIC="MODE_DYNAMIC"})(Qje||(Qje={}));(function(n){n.ENVIRONMENT_UNSPECIFIED="ENVIRONMENT_UNSPECIFIED",n.ENVIRONMENT_BROWSER="ENVIRONMENT_BROWSER"})(Hje||(Hje={}));(function(n){n.MODE_UNSPECIFIED="MODE_UNSPECIFIED",n.AUTO="AUTO",n.ANY="ANY",n.NONE="NONE",n.VALIDATED="VALIDATED"})(jQ||(jQ={}));(function(n){n.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",n.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",n.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",n.BLOCK_NONE="BLOCK_NONE"})(Xje||(Xje={}));(function(n){n.DONT_ALLOW="DONT_ALLOW",n.ALLOW_ADULT="ALLOW_ADULT",n.ALLOW_ALL="ALLOW_ALL"})(kje||(kje={}));(function(n){n.auto="auto",n.en="en",n.ja="ja",n.ko="ko",n.hi="hi",n.zh="zh",n.pt="pt",n.es="es"})(Lje||(Lje={}));(function(n){n.MASK_MODE_DEFAULT="MASK_MODE_DEFAULT",n.MASK_MODE_USER_PROVIDED="MASK_MODE_USER_PROVIDED",n.MASK_MODE_BACKGROUND="MASK_MODE_BACKGROUND",n.MASK_MODE_FOREGROUND="MASK_MODE_FOREGROUND",n.MASK_MODE_SEMANTIC="MASK_MODE_SEMANTIC"})(Jje||(Jje={}));(function(n){n.CONTROL_TYPE_DEFAULT="CONTROL_TYPE_DEFAULT",n.CONTROL_TYPE_CANNY="CONTROL_TYPE_CANNY",n.CONTROL_TYPE_SCRIBBLE="CONTROL_TYPE_SCRIBBLE",n.CONTROL_TYPE_FACE_MESH="CONTROL_TYPE_FACE_MESH"})(Bje||(Bje={}));(function(n){n.SUBJECT_TYPE_DEFAULT="SUBJECT_TYPE_DEFAULT",n.SUBJECT_TYPE_PERSON="SUBJECT_TYPE_PERSON",n.SUBJECT_TYPE_ANIMAL="SUBJECT_TYPE_ANIMAL",n.SUBJECT_TYPE_PRODUCT="SUBJECT_TYPE_PRODUCT"})(Sje||(Sje={}));(function(n){n.EDIT_MODE_DEFAULT="EDIT_MODE_DEFAULT",n.EDIT_MODE_INPAINT_REMOVAL="EDIT_MODE_INPAINT_REMOVAL",n.EDIT_MODE_INPAINT_INSERTION="EDIT_MODE_INPAINT_INSERTION",n.EDIT_MODE_OUTPAINT="EDIT_MODE_OUTPAINT",n.EDIT_MODE_CONTROLLED_EDITING="EDIT_MODE_CONTROLLED_EDITING",n.EDIT_MODE_STYLE="EDIT_MODE_STYLE",n.EDIT_MODE_BGSWAP="EDIT_MODE_BGSWAP",n.EDIT_MODE_PRODUCT_IMAGE="EDIT_MODE_PRODUCT_IMAGE"})(Dje||(Dje={}));(function(n){n.FOREGROUND="FOREGROUND",n.BACKGROUND="BACKGROUND",n.PROMPT="PROMPT",n.SEMANTIC="SEMANTIC",n.INTERACTIVE="INTERACTIVE"})(Tje||(Tje={}));(function(n){n.ASSET="ASSET",n.STYLE="STYLE"})(Oje||(Oje={}));(function(n){n.INSERT="INSERT",n.REMOVE="REMOVE",n.REMOVE_STATIC="REMOVE_STATIC",n.OUTPAINT="OUTPAINT"})(Uje||(Uje={}));(function(n){n.OPTIMIZED="OPTIMIZED",n.LOSSLESS="LOSSLESS"})(Mje||(Mje={}));(function(n){n.SUPERVISED_FINE_TUNING="SUPERVISED_FINE_TUNING",n.PREFERENCE_TUNING="PREFERENCE_TUNING"})(zje||(zje={}));(function(n){n.STATE_UNSPECIFIED="STATE_UNSPECIFIED",n.STATE_PENDING="STATE_PENDING",n.STATE_ACTIVE="STATE_ACTIVE",n.STATE_FAILED="STATE_FAILED"})(_je||(_je={}));(function(n){n.STATE_UNSPECIFIED="STATE_UNSPECIFIED",n.PROCESSING="PROCESSING",n.ACTIVE="ACTIVE",n.FAILED="FAILED"})(Pje||(Pje={}));(function(n){n.SOURCE_UNSPECIFIED="SOURCE_UNSPECIFIED",n.UPLOADED="UPLOADED",n.GENERATED="GENERATED"})(jje||(jje={}));(function(n){n.TURN_COMPLETE_REASON_UNSPECIFIED="TURN_COMPLETE_REASON_UNSPECIFIED",n.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",n.RESPONSE_REJECTED="RESPONSE_REJECTED",n.NEED_MORE_INPUT="NEED_MORE_INPUT"})(Kje||(Kje={}));(function(n){n.MODALITY_UNSPECIFIED="MODALITY_UNSPECIFIED",n.TEXT="TEXT",n.IMAGE="IMAGE",n.VIDEO="VIDEO",n.AUDIO="AUDIO",n.DOCUMENT="DOCUMENT"})(qje||(qje={}));(function(n){n.START_SENSITIVITY_UNSPECIFIED="START_SENSITIVITY_UNSPECIFIED",n.START_SENSITIVITY_HIGH="START_SENSITIVITY_HIGH",n.START_SENSITIVITY_LOW="START_SENSITIVITY_LOW"})($je||($je={}));(function(n){n.END_SENSITIVITY_UNSPECIFIED="END_SENSITIVITY_UNSPECIFIED",n.END_SENSITIVITY_HIGH="END_SENSITIVITY_HIGH",n.END_SENSITIVITY_LOW="END_SENSITIVITY_LOW"})(eKe||(eKe={}));(function(n){n.ACTIVITY_HANDLING_UNSPECIFIED="ACTIVITY_HANDLING_UNSPECIFIED",n.START_OF_ACTIVITY_INTERRUPTS="START_OF_ACTIVITY_INTERRUPTS",n.NO_INTERRUPTION="NO_INTERRUPTION"})(tKe||(tKe={}));(function(n){n.TURN_COVERAGE_UNSPECIFIED="TURN_COVERAGE_UNSPECIFIED",n.TURN_INCLUDES_ONLY_ACTIVITY="TURN_INCLUDES_ONLY_ACTIVITY",n.TURN_INCLUDES_ALL_INPUT="TURN_INCLUDES_ALL_INPUT"})(nKe||(nKe={}));(function(n){n.SCALE_UNSPECIFIED="SCALE_UNSPECIFIED",n.C_MAJOR_A_MINOR="C_MAJOR_A_MINOR",n.D_FLAT_MAJOR_B_FLAT_MINOR="D_FLAT_MAJOR_B_FLAT_MINOR",n.D_MAJOR_B_MINOR="D_MAJOR_B_MINOR",n.E_FLAT_MAJOR_C_MINOR="E_FLAT_MAJOR_C_MINOR",n.E_MAJOR_D_FLAT_MINOR="E_MAJOR_D_FLAT_MINOR",n.F_MAJOR_D_MINOR="F_MAJOR_D_MINOR",n.G_FLAT_MAJOR_E_FLAT_MINOR="G_FLAT_MAJOR_E_FLAT_MINOR",n.G_MAJOR_E_MINOR="G_MAJOR_E_MINOR",n.A_FLAT_MAJOR_F_MINOR="A_FLAT_MAJOR_F_MINOR",n.A_MAJOR_G_FLAT_MINOR="A_MAJOR_G_FLAT_MINOR",n.B_FLAT_MAJOR_G_MINOR="B_FLAT_MAJOR_G_MINOR",n.B_MAJOR_A_FLAT_MINOR="B_MAJOR_A_FLAT_MINOR"})(rKe||(rKe={}));(function(n){n.MUSIC_GENERATION_MODE_UNSPECIFIED="MUSIC_GENERATION_MODE_UNSPECIFIED",n.QUALITY="QUALITY",n.DIVERSITY="DIVERSITY",n.VOCALIZATION="VOCALIZATION"})(aKe||(aKe={}));(function(n){n.PLAYBACK_CONTROL_UNSPECIFIED="PLAYBACK_CONTROL_UNSPECIFIED",n.PLAY="PLAY",n.PAUSE="PAUSE",n.STOP="STOP",n.RESET_CONTEXT="RESET_CONTEXT"})(iKe||(iKe={}));j$=class{},KQ=class{get text(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning text from the first one.");let d="",I=!1,h=[];for(let o of(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)!==null&&u!==void 0?u:[]){for(let[v,w]of Object.entries(o))v!=="text"&&v!=="thought"&&v!=="thoughtSignature"&&(w!==null||w!==void 0)&&h.push(v);if(typeof o.text=="string"){if(typeof o.thought=="boolean"&&o.thought)continue;I=!0,d+=o.text}}return h.length>0&&console.warn(`there are non-text parts ${h} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),I?d:void 0}get data(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning data from the first one.");let d="",I=[];for(let h of(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)!==null&&u!==void 0?u:[]){for(let[o,v]of Object.entries(h))o!=="inlineData"&&(v!==null||v!==void 0)&&I.push(o);h.inlineData&&typeof h.inlineData.data=="string"&&(d+=atob(h.inlineData.data))}return I.length>0&&console.warn(`there are non-data parts ${I} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),d.length>0?btoa(d):void 0}get functionCalls(){var t,r,a,i,s,e,c,u;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.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 d=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(I=>I.functionCall).map(I=>I.functionCall).filter(I=>I!==void 0);if(d?.length!==0)return d}get executableCode(){var t,r,a,i,s,e,c,u,d;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning executable code from the first one.");let I=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(h=>h.executableCode).map(h=>h.executableCode).filter(h=>h!==void 0);if(I?.length!==0)return(d=I?.[0])===null||d===void 0?void 0:d.code}get codeExecutionResult(){var t,r,a,i,s,e,c,u,d;if(((i=(a=(r=(t=this.candidates)===null||t===void 0?void 0:t[0])===null||r===void 0?void 0:r.content)===null||a===void 0?void 0:a.parts)===null||i===void 0?void 0:i.length)===0)return;this.candidates&&this.candidates.length>1&&console.warn("there are multiple candidates in the response, returning code execution result from the first one.");let I=(u=(c=(e=(s=this.candidates)===null||s===void 0?void 0:s[0])===null||e===void 0?void 0:e.content)===null||c===void 0?void 0:c.parts)===null||u===void 0?void 0:u.filter(h=>h.codeExecutionResult).map(h=>h.codeExecutionResult).filter(h=>h!==void 0);if(I?.length!==0)return(d=I?.[0])===null||d===void 0?void 0:d.output}};(function(n){n.PAGED_ITEM_BATCH_JOBS="batchJobs",n.PAGED_ITEM_MODELS="models",n.PAGED_ITEM_TUNING_JOBS="tuningJobs",n.PAGED_ITEM_FILES="files",n.PAGED_ITEM_CACHED_CONTENTS="cachedContents",n.PAGED_ITEM_FILE_SEARCH_STORES="fileSearchStores",n.PAGED_ITEM_DOCUMENTS="documents"})(oKe||(oKe={}));m3n="1.30.0",lKr=`google-genai-sdk/${m3n}`;p3n=!1;K$=class n{constructor(t=[],r){this.mcpTools=[],this.functionNameToMcpClient={},this.mcpClients=t,this.config=r}static create(t,r){return new n(t,r)}async initialize(){var t,r,a,i;if(this.mcpTools.length>0)return;let s={},e=[];for(let I of this.mcpClients)try{for(var c=!0,u=(r=void 0,h3n(b3n(I))),d;d=await u.next(),t=d.done,!t;c=!0){i=d.value,c=!1;let h=i;e.push(h);let o=h.name;if(s[o])throw new Error(`Duplicate function name ${o} found in MCP tools. Please ensure function names are unique.`);s[o]=I}}catch(h){r={error:h}}finally{try{!c&&!t&&(a=u.return)&&await a.call(u)}finally{if(r)throw r.error}}this.mcpTools=e,this.functionNameToMcpClient=s}async tool(){return await this.initialize(),u3n(this.mcpTools,this.config)}async callTool(t){await this.initialize();let r=[];for(let a of t)if(a.name in this.functionNameToMcpClient){let i=this.functionNameToMcpClient[a.name],s;this.config.timeout&&(s={timeout:this.config.timeout});let e=await i.callTool({name:a.name,arguments:a.args},void 0,s);r.push({functionResponse:{name:a.name,response:e.isError?{error:e}:e}})}return r}};sKr=1024*1024*8;});function f3n(n,t){return{...n,...t}}function uKe(n){let{prompt_id:t,...r}=n;return r}function pE(n){return Array.isArray(n)?n.map(uKe):n}var q$=ut(()=>{"use strict";Ol();});var dKe={};Ms(dKe,{DEFAULT_PROXY_CONFIG:()=>Z3n,getActiveProxyServerUrl:()=>dZ,getAvailableProxyServers:()=>g3n,getProxyServerInfo:()=>v3n,getProxyServers:()=>U8,hasAvailableProxyServer:()=>Dfe});function U8(){return[{url:"https://api-code.deepvlab.ai",name:"Primary Development Server",region:"default",status:"active"}]}function dZ(){let t=U8().find(r=>r.status==="active");if(!t)throw new Error("No active proxy server available. Please contact support.");return t.url}function g3n(){return U8().filter(t=>t.status==="active")}function Dfe(){return U8().some(t=>t.status==="active")}function v3n(n){return U8().find(r=>r.url===n)}var Z3n,qQ=ut(()=>{"use strict";Z3n={serverUrl:dZ(),timeout:2e5,retryAttempts:3,retryDelay:1e3}});import*as yo from"fs";import*as qf from"path";import*as bE from"os";function N3n(n){ns.configure(n)}function W3n(n){ns.setUserInfo(n)}function A3n(n){ns.setCliVersion(n)}async function F3n(){return await ns.getUserHeaders()}function y3n(){return ns.getStatus()}var M8,ys,ns,uF=ut(()=>{"use strict";qQ();M8=259200,ys=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=qf.join(bE.homedir(),".deepv","user-info-dev.json"),this.jwtTokenFilePath=qf.join(bE.homedir(),".deepv","jwt-token-dev.json"),this.usageStatsFilePath=qf.join(bE.homedir(),".deepv","usage-stats-dev.json")):(this.userInfoFilePath=qf.join(bE.homedir(),".deepv","user-info.json"),this.jwtTokenFilePath=qf.join(bE.homedir(),".deepv","jwt-token.json"),this.usageStatsFilePath=qf.join(bE.homedir(),".deepv","usage-stats.json")),this.cliVersion="1.0.248",this.config={proxyServerUrl:dZ()},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-M8*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(yo.existsSync(this.userInfoFilePath)){let t=yo.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=qf.dirname(this.userInfoFilePath);yo.existsSync(t)||yo.mkdirSync(t,{recursive:!0}),yo.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(yo.existsSync(this.jwtTokenFilePath)){let t=yo.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=qf.dirname(this.jwtTokenFilePath);yo.existsSync(t)||yo.mkdirSync(t,{recursive:!0}),yo.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(yo.existsSync(this.usageStatsFilePath)){let t=yo.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=qf.dirname(this.usageStatsFilePath);yo.existsSync(t)||yo.mkdirSync(t,{recursive:!0}),yo.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-M8*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-M8*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=M8){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-M8*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{yo.existsSync(this.jwtTokenFilePath)&&yo.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{yo.existsSync(this.userInfoFilePath)&&yo.unlinkSync(this.userInfoFilePath)}catch(t){console.warn("[Login Check] Failed to delete user info file:",t)}try{yo.existsSync(this.jwtTokenFilePath)&&yo.unlinkSync(this.jwtTokenFilePath)}catch(t){console.warn("[Login Check] Failed to delete access credential file:",t)}console.log("[Login Check] Authentication cleared")}},ns=ys.getInstance()});import{promises as GE}from"node:fs";import z8 from"node:path";import R3n from"os";var rb,$$,er,xG=ut(()=>{"use strict";(function(n){n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR"})(rb||(rb={}));$$=class{config;logBuffer=[];constructor(t={}){if(this.config={level:rb.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=z8.join(R3n.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 GE.mkdir(z8.dirname(this.config.filePath),{recursive:!0}),await this.rotateLogIfNeeded(),await GE.appendFile(this.config.filePath,t+`
|
|
496
496
|
`,"utf-8")}catch(r){console.error("\u5199\u5165\u65E5\u5FD7\u6587\u4EF6\u5931\u8D25:",r)}}async rotateLogIfNeeded(){if(this.config.filePath)try{if((await GE.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 GE.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=z8.dirname(this.config.filePath),a=(await GE.readdir(t)).filter(e=>e.startsWith("deepv-")&&e.endsWith(".log")).map(e=>({name:e,path:z8.join(t,e),time:GE.stat(z8.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 GE.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>=rb.ERROR?console.error:t>=rb.WARN?console.warn:t>=rb.INFO?console.log:console.debug)(s),this.config.enableFile&&this.writeToFile(s)}debug(t,...r){this.log(rb.DEBUG,"DEBUG",t,...r)}info(t,...r){this.log(rb.INFO,"INFO",t,...r)}warn(t,...r){this.log(rb.WARN,"WARN",t,...r)}error(t,...r){this.log(rb.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}:{}})}},er=new $$({level:process.env.FILE_DEBUG==="1"?rb.DEBUG:rb.INFO,enableConsole:!0,enableFile:process.env.LOG_TO_FILE==="true",filePath:process.env.LOG_FILE_PATH})});function Xs(n){return n instanceof Error&&"code"in n}function rr(n){if(n instanceof Error)return n.message;try{return String(n)}catch{return"Failed to get error details"}}function Tfe(n){if(n&&typeof n=="object"&&"response"in n){let r=E3n(n);if(r.error&&r.error.message&&r.error.code)switch(r.error.code){case 400:return new tee(r.error.message);case 401:return new pI(r.error.message);case 403:return new eee(r.error.message);default:}}return n}function E3n(n){return typeof n.response?.data=="string"?JSON.parse(n.response?.data):n.response?.data}var eee,pI,tee,Ro=ut(()=>{"use strict";eee=class extends Error{},pI=class extends Error{},tee=class extends Error{}});var Za,hKe,Qu,hZ=ut(()=>{"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"})(Za||(Za={}));hKe={[Za.CHAT_CONVERSATION]:"auto",[Za.WEB_FETCH]:"gemini-2.5-flash",[Za.WEB_SEARCH]:"gemini-2.5-flash",[Za.CODE_ASSIST]:"auto",[Za.CONTENT_SUMMARY]:"gemini-2.5-flash-lite",[Za.EDIT_CORRECTION]:"auto",[Za.JSON_GENERATION]:"gemini-2.5-flash",[Za.COMPRESSION]:"gemini-2.5-flash",[Za.SUB_AGENT]:"auto"},Qu=class{static getModelForScene(t){if(t)return hKe[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{[Za.CHAT_CONVERSATION]:"\u804A\u5929\u5BF9\u8BDD",[Za.WEB_FETCH]:"Web\u5185\u5BB9\u83B7\u53D6",[Za.WEB_SEARCH]:"Web\u641C\u7D22",[Za.CODE_ASSIST]:"\u4EE3\u7801\u52A9\u624B",[Za.CONTENT_SUMMARY]:"\u5185\u5BB9\u6458\u8981",[Za.EDIT_CORRECTION]:"\u7F16\u8F91\u6821\u6B63",[Za.JSON_GENERATION]:"JSON\u751F\u6210",[Za.COMPRESSION]:"\u5BF9\u8BDD\u538B\u7F29",[Za.SUB_AGENT]:"SubAgent\u5B50\u4EE3\u7406"}[t]||t}}});function dF(n){return typeof n=="object"&&n!==null&&"error"in n&&typeof n.error=="object"&&"message"in n.error}function QG(n){return typeof n=="object"&&n!==null&&"message"in n&&typeof n.message=="string"}function KN(n){let t=r=>r.includes("Quota exceeded for quota metric 'Gemini")&&r.includes("Pro Requests'");if(typeof n=="string")return t(n);if(QG(n))return t(n.message);if(dF(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 qN(n){return typeof n=="string"?n.includes("Quota exceeded for quota metric"):QG(n)?n.message.includes("Quota exceeded for quota metric"):dF(n)?n.error.message.includes("Quota exceeded for quota metric"):!1}function $N(n){if(n&&typeof n=="object"&&"response"in n){let t=n;if(t.response?.status===429&&t.response.data){let r=t.response.data;if(r&&typeof r.error=="string"&&r.error==="Quota limit exceeded"&&typeof r.message=="string")return!0}if(t.response?.status===403&&t.response.data){let r=t.response.data;if(r&&typeof r.error=="string"&&r.error==="No quota configuration"&&typeof r.message=="string")return!0}}if(n instanceof Error&&n.message&&(n.message.includes("API request failed (429):")&&n.message.includes('"error":"Quota limit exceeded"')||n.message.includes("API request failed (403):")&&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 (429):")&&t.message.includes('"error":"Quota limit exceeded"')||t.message.includes("API request failed (403):")&&t.message.includes('"error":"No quota configuration"')||t.message.includes("API error (403):")&&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 _8(n){let t=null;if(n&&typeof n=="object"&&"response"in n){let r=n;(r.response?.status===429||r.response?.status===403)&&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 (429):")&&r.message.includes('"error":"Quota limit exceeded"')||r.message.includes("API request failed (403):")&&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 (429):")&&n.message.includes('"error":"Quota limit exceeded"')||n.message.includes("API request failed (403):")&&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 (429):")&&n.includes('"error":"Quota limit exceeded"')||n.includes("API request failed (403):")&&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?w3n(t):null}function w3n(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
|
|
497
497
|
\u{1F6AB} \u5F53\u524D\u8D26\u6237\u53EF\u7528\u7684 Credit\uFF08\u79EF\u5206\uFF09\u4E0D\u8DB3\u4EE5\u7EE7\u7EED\u4F7F\u7528\u672C\u670D\u52A1
|
|
498
498
|
\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/
|
|
@@ -641,7 +641,7 @@ ${s}`;break;case"retry":Tit(s)&&(r[i]=s);break;case"id":Oit(s)&&(r[i]=s);break;c
|
|
|
641
641
|
|
|
642
642
|
Please check your Feishu authentication token and try again.
|
|
643
643
|
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):WQn(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=Qu.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(pE(t.contents)),config:{...t.config,stream:!0,httpOptions:{...t.config?.httpOptions,headers:{...t.config?.httpOptions?.headers,"X-Scene-Type":r,"X-Scene-Display":Qu.getSceneDisplayName(r)}}}};er.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 er.error("[DeepV Server] Stream request failed",{error:a}),this.handleStreamError(a)}}async callStreamAPI(t,r,a){return mZ(()=>this.executeStreamAPICall(t,r,a),{shouldRetry:i=>i.message.includes("cancelled by user")||i.name==="AbortError"||i.message.includes("401")||i instanceof pI||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 ns.getUserHeaders(),s=`${ns.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,alt.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{er.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 pI("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 v=d.headers.get("retry-after");throw v&&(o.response={status:d.status,headers:{"retry-after":v}}),o}let I=Date.now()-u;return er.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")?er.warn("[DeepV Server] Stream API aborted",{endpoint:t,duration:`${I}ms`,reason:d.message}):er.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(w){if(w instanceof Error&&(w.name==="AbortError"||w.message.includes("cancelled"))){console.log("[DeepV Server] Stream read cancelled - exiting");break}throw w}let{done:h,value:o}=I;if(h)break;e+=o.length,s+=i.decode(o,{stream:!0});let v=s.split(`
|
|
644
|
-
`);s=v.pop()||"";for(let w of v)if(w.startsWith("data: ")){let R=w.slice(6);if(R==="[DONE]")return;try{let E=JSON.parse(R);if(E.type==="connection_established")continue;if(E.error)throw new Error(E.error);E.usageMetadata&&(c=E.usageMetadata);let A=this.convertStreamChunkToGenAI(E);A&&(yield A)}catch(E){er.warn("[DeepV Server] Stream chunk parse error",{data:R.substring(0,100)+"...",error:E instanceof Error?E.message:E})}}}}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=Qu.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":Qu.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 Ep.emitRealTimeToken({inputTokens:a.totalTokens||0,outputTokens:0,totalTokens:a.totalTokens||0,timestamp:Date.now()}),a}catch(r){return er.error("[DeepV Server] Token count failed:",r),this.estimateTokensAsFailback(t)}}async callUnifiedTokenCountAPI(t){let r=await ns.getUserHeaders(),a=`${ns.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 pI("Authentication required - please re-authenticate")):new Error(`Token count API failed (${i.status}): ${e}`)}let s=await i.json();return er.debug("[DeepV Server] Token count response",{totalTokens:s.totalTokens}),{totalTokens:s.totalTokens||0}}catch(i){throw er.error("[DeepV Server] Token count API call failed:",i),i}}estimateTokensAsFailback(t){try{let r=Array.isArray(t.contents)?t.contents:[{role:ia.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 v of o.parts)if(typeof v=="object"&&v&&"text"in v&&typeof v.text=="string")a+=v.text.length,e++;else if(typeof v=="object"&&v&&"functionCall"in v&&v.functionCall){let w=v.functionCall,R=`[Tool: ${w.name}]`+JSON.stringify(w.args||{});a+=R.length,i++}else if(typeof v=="object"&&v&&"functionResponse"in v&&v.functionResponse){let E=`[Tool Result: ${v.functionResponse.response?.output||"result"}]`;a+=E.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 D3e(n,t){let r=n.getModel()||"auto",a={authType:t,proxy:n?.getProxy()};return t===vl.USE_PROXY_AUTH,a}async function T3e(n,t,r){let i={headers:{"User-Agent":`GeminiCLI/1.0.247 (${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(!Dfe())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=dZ(),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 S9(u,d,c,t)}throw new Error(`Error creating contentGenerator: Unsupported authType: ${n.authType}`)}var vl,ane=ut(()=>{"use strict";S3e();qQ();(function(n){n.USE_PROXY_AUTH="proxy-auth"})(vl||(vl={}))});var ine,ilt=ut(()=>{"use strict";ine=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 lg(n){let t={type:"subagent_update",data:n,timestamp:Date.now()};return JSON.stringify(t)}function llt(n){let t={type:"text",data:n,timestamp:Date.now()};return JSON.stringify(t)}function lne(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 sne(n){return n.type==="subagent_update"}function one(n){return n.type==="text"}var O3e=ut(()=>{"use strict";});var La,Xr,Ja,Eo=ut(()=>{"use strict";O3e();La=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"})(Xr||(Xr={}));(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"})(Ja||(Ja={}))});var el,U3e,kr,wZ,j7=ut(()=>{(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})(el||(el={}));(function(n){n.mergeShapes=(t,r)=>({...t,...r})})(U3e||(U3e={}));kr=el.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wZ=n=>{switch(typeof n){case"undefined":return kr.undefined;case"string":return kr.string;case"number":return Number.isNaN(n)?kr.nan:kr.number;case"boolean":return kr.boolean;case"function":return kr.function;case"bigint":return kr.bigint;case"symbol":return kr.symbol;case"object":return Array.isArray(n)?kr.array:n===null?kr.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?kr.promise:typeof Map<"u"&&n instanceof Map?kr.map:typeof Set<"u"&&n instanceof Set?kr.set:typeof Date<"u"&&n instanceof Date?kr.date:kr.object;default:return kr.unknown}}});var ur,AQn,Qp,cne=ut(()=>{j7();ur=el.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"]),AQn=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),Qp=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,el.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()}};Qp.create=n=>new Qp(n)});var FQn,hW,M3e=ut(()=>{cne();j7();FQn=(n,t)=>{let r;switch(n.code){case ur.invalid_type:n.received===kr.undefined?r="Required":r=`Expected ${n.expected}, received ${n.received}`;break;case ur.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(n.expected,el.jsonStringifyReplacer)}`;break;case ur.unrecognized_keys:r=`Unrecognized key(s) in object: ${el.joinValues(n.keys,", ")}`;break;case ur.invalid_union:r="Invalid input";break;case ur.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${el.joinValues(n.options)}`;break;case ur.invalid_enum_value:r=`Invalid enum value. Expected ${el.joinValues(n.options)}, received '${n.received}'`;break;case ur.invalid_arguments:r="Invalid function arguments";break;case ur.invalid_return_type:r="Invalid function return type";break;case ur.invalid_date:r="Invalid date";break;case ur.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}"`:el.assertNever(n.validation):n.validation!=="regex"?r=`Invalid ${n.validation}`:r="Invalid";break;case ur.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 ur.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 ur.custom:r="Invalid input";break;case ur.invalid_intersection_types:r="Intersection results could not be merged";break;case ur.not_multiple_of:r=`Number must be a multiple of ${n.multipleOf}`;break;case ur.not_finite:r="Number must be finite";break;default:r=t.defaultError,el.assertNever(n)}return{message:r}},hW=FQn});function yQn(n){slt=n}function D9(){return slt}var slt,Ine=ut(()=>{M3e();slt=hW});function Cr(n,t){let r=D9(),a=K7({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,r,r===hW?void 0:hW].filter(i=>!!i)});n.common.issues.push(a)}var K7,RQn,o0,Va,_E,sh,une,dne,wF,T9,z3e=ut(()=>{Ine();M3e();K7=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}},RQn=[];o0=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 Va;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 Va;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}}},Va=Object.freeze({status:"aborted"}),_E=n=>({status:"dirty",value:n}),sh=n=>({status:"valid",value:n}),une=n=>n.status==="aborted",dne=n=>n.status==="dirty",wF=n=>n.status==="valid",T9=n=>typeof Promise<"u"&&n instanceof Promise});var olt=ut(()=>{});var la,clt=ut(()=>{(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t?.message})(la||(la={}))});function fi(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 hlt(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 OQn(n){return new RegExp(`^${hlt(n)}$`)}function mlt(n){let t=`${dlt}T${hlt(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 UQn(n,t){return!!((t==="v4"||!t)&&kQn.test(n)||(t==="v6"||!t)&&JQn.test(n))}function MQn(n,t){if(!xQn.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 zQn(n,t){return!!((t==="v4"||!t)&&LQn.test(n)||(t==="v6"||!t)&&BQn.test(n))}function _Qn(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 O9(n){if(n instanceof Hp){let t={};for(let r in n.shape){let a=n.shape[r];t[r]=MG.create(O9(a))}return new Hp({...n._def,shape:()=>t})}else return n instanceof bW?new bW({...n._def,type:O9(n.element)}):n instanceof MG?MG.create(O9(n.unwrap())):n instanceof CZ?CZ.create(O9(n.unwrap())):n instanceof YZ?YZ.create(n.items.map(t=>O9(t))):n}function P3e(n,t){let r=wZ(n),a=wZ(t);if(n===t)return{valid:!0,data:n};if(r===kr.object&&a===kr.object){let i=el.objectKeys(t),s=el.objectKeys(n).filter(c=>i.indexOf(c)!==-1),e={...n,...t};for(let c of s){let u=P3e(n[c],t[c]);if(!u.valid)return{valid:!1};e[c]=u.data}return{valid:!0,data:e}}else if(r===kr.array&&a===kr.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=P3e(e,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===kr.date&&a===kr.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}function plt(n,t){return new iw({values:n,typeName:Ba.ZodEnum,...fi(t)})}function ult(n,t){let r=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof r=="string"?{message:r}:r}function blt(n,t={},r){return n?CF.create().superRefine((a,i)=>{let s=n(a);if(s instanceof Promise)return s.then(e=>{if(!e){let c=ult(t,a),u=c.fatal??r??!0;i.addIssue({code:"custom",...c,fatal:u})}});if(!s){let e=ult(t,a),c=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:c})}}):CF.create()}var zG,Ilt,wi,EQn,wQn,YQn,CQn,VQn,xQn,QQn,HQn,XQn,_3e,kQn,LQn,JQn,BQn,SQn,DQn,dlt,TQn,YF,PE,jE,KE,qE,U9,$E,ew,CF,pW,sg,M9,bW,Hp,tw,mW,hne,nw,YZ,mne,z9,_9,pne,rw,aw,iw,lw,VF,_G,MG,CZ,sw,ow,P9,PQn,q7,$7,cw,jQn,Ba,KQn,Glt,flt,qQn,$Qn,glt,e9n,t9n,n9n,r9n,a9n,i9n,l9n,s9n,o9n,c9n,I9n,u9n,d9n,h9n,m9n,p9n,b9n,G9n,f9n,g9n,v9n,Z9n,N9n,W9n,A9n,F9n,y9n,R9n,E9n,w9n,Y9n,C9n,V9n,x9n,vlt=ut(()=>{cne();Ine();clt();z3e();j7();zG=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}},Ilt=(n,t)=>{if(wF(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 Qp(n.common.issues);return this._error=r,this._error}}};wi=class{get description(){return this._def.description}_getType(t){return wZ(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:wZ(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new o0,ctx:{common:t.parent.common,data:t.data,parsedType:wZ(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(T9(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:wZ(t)},i=this._parseSync({data:t,path:a.path,parent:a});return Ilt(a,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wZ(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:r});return wF(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=>wF(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:wZ(t)},i=this._parse({data:t,path:a.path,parent:a}),s=await(T9(i)?i:Promise.resolve(i));return Ilt(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:ur.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 _G({schema:this,typeName:Ba.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 MG.create(this,this._def)}nullable(){return CZ.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return bW.create(this)}promise(){return VF.create(this,this._def)}or(t){return tw.create([this,t],this._def)}and(t){return nw.create(this,t,this._def)}transform(t){return new _G({...fi(this._def),schema:this,typeName:Ba.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new sw({...fi(this._def),innerType:this,defaultValue:r,typeName:Ba.ZodDefault})}brand(){return new q7({typeName:Ba.ZodBranded,type:this,...fi(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new ow({...fi(this._def),innerType:this,catchValue:r,typeName:Ba.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return $7.create(this,t)}readonly(){return cw.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},EQn=/^c[^\s-]{8,}$/i,wQn=/^[0-9a-z]+$/,YQn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,CQn=/^[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,VQn=/^[a-z0-9_-]{21}$/i,xQn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,QQn=/^[-+]?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)?)??$/,HQn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,XQn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",kQn=/^(?:(?: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])$/,LQn=/^(?:(?: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])$/,JQn=/^(([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]))$/,BQn=/^(([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])$/,SQn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,DQn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dlt="((\\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])))",TQn=new RegExp(`^${dlt}$`);YF=class n extends wi{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==kr.string){let s=this._getOrReturnCtx(t);return Cr(s,{code:ur.invalid_type,expected:kr.string,received:s.parsedType}),Va}let a=new o0,i;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.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),Cr(i,{code:ur.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?Cr(i,{code:ur.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&Cr(i,{code:ur.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")HQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"email",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")_3e||(_3e=new RegExp(XQn,"u")),_3e.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"emoji",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")CQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"uuid",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")VQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"nanoid",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")EQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"cuid",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")wQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"cuid2",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")YQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"ulid",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Cr(i,{validation:"url",code:ur.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),Cr(i,{validation:"regex",code:ur.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),Cr(i,{code:ur.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),Cr(i,{code:ur.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?mlt(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?TQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?OQn(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?QQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"duration",code:ur.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?UQn(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"ip",code:ur.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?MQn(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"jwt",code:ur.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?zQn(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"cidr",code:ur.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?SQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"base64",code:ur.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?DQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"base64url",code:ur.invalid_string,message:s.message}),a.dirty()):el.assertNever(s);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(i=>t.test(i),{validation:r,code:ur.invalid_string,...la.errToObj(a)})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...la.errToObj(t)})}url(t){return this._addCheck({kind:"url",...la.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...la.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...la.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...la.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...la.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...la.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...la.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...la.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...la.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...la.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...la.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...la.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,...la.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,...la.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...la.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...la.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...la.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...la.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...la.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...la.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...la.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...la.errToObj(r)})}nonempty(t){return this.min(1,la.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}};YF.create=n=>new YF({checks:[],typeName:Ba.ZodString,coerce:n?.coerce??!1,...fi(n)});PE=class n extends wi{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)!==kr.number){let s=this._getOrReturnCtx(t);return Cr(s,{code:ur.invalid_type,expected:kr.number,received:s.parsedType}),Va}let a,i=new o0;for(let s of this._def.checks)s.kind==="int"?el.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),Cr(a,{code:ur.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),Cr(a,{code:ur.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),Cr(a,{code:ur.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?_Qn(t.data,s.value)!==0&&(a=this._getOrReturnCtx(t,a),Cr(a,{code:ur.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),Cr(a,{code:ur.not_finite,message:s.message}),i.dirty()):el.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,la.toString(r))}gt(t,r){return this.setLimit("min",t,!1,la.toString(r))}lte(t,r){return this.setLimit("max",t,!0,la.toString(r))}lt(t,r){return this.setLimit("max",t,!1,la.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:la.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:la.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:la.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:la.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:la.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:la.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:la.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:la.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:la.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:la.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"&&el.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)}};PE.create=n=>new PE({checks:[],typeName:Ba.ZodNumber,coerce:n?.coerce||!1,...fi(n)});jE=class n extends wi{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)!==kr.bigint)return this._getInvalidInput(t);let a,i=new o0;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),Cr(a,{code:ur.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),Cr(a,{code:ur.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),Cr(a,{code:ur.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):el.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return Cr(r,{code:ur.invalid_type,expected:kr.bigint,received:r.parsedType}),Va}gte(t,r){return this.setLimit("min",t,!0,la.toString(r))}gt(t,r){return this.setLimit("min",t,!1,la.toString(r))}lte(t,r){return this.setLimit("max",t,!0,la.toString(r))}lt(t,r){return this.setLimit("max",t,!1,la.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:la.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:la.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:la.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:la.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:la.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:la.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}};jE.create=n=>new jE({checks:[],typeName:Ba.ZodBigInt,coerce:n?.coerce??!1,...fi(n)});KE=class extends wi{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==kr.boolean){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.boolean,received:a.parsedType}),Va}return sh(t.data)}};KE.create=n=>new KE({typeName:Ba.ZodBoolean,coerce:n?.coerce||!1,...fi(n)});qE=class n extends wi{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==kr.date){let s=this._getOrReturnCtx(t);return Cr(s,{code:ur.invalid_type,expected:kr.date,received:s.parsedType}),Va}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return Cr(s,{code:ur.invalid_date}),Va}let a=new o0,i;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.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),Cr(i,{code:ur.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):el.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:la.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:la.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}};qE.create=n=>new qE({checks:[],coerce:n?.coerce||!1,typeName:Ba.ZodDate,...fi(n)});U9=class extends wi{_parse(t){if(this._getType(t)!==kr.symbol){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.symbol,received:a.parsedType}),Va}return sh(t.data)}};U9.create=n=>new U9({typeName:Ba.ZodSymbol,...fi(n)});$E=class extends wi{_parse(t){if(this._getType(t)!==kr.undefined){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.undefined,received:a.parsedType}),Va}return sh(t.data)}};$E.create=n=>new $E({typeName:Ba.ZodUndefined,...fi(n)});ew=class extends wi{_parse(t){if(this._getType(t)!==kr.null){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.null,received:a.parsedType}),Va}return sh(t.data)}};ew.create=n=>new ew({typeName:Ba.ZodNull,...fi(n)});CF=class extends wi{constructor(){super(...arguments),this._any=!0}_parse(t){return sh(t.data)}};CF.create=n=>new CF({typeName:Ba.ZodAny,...fi(n)});pW=class extends wi{constructor(){super(...arguments),this._unknown=!0}_parse(t){return sh(t.data)}};pW.create=n=>new pW({typeName:Ba.ZodUnknown,...fi(n)});sg=class extends wi{_parse(t){let r=this._getOrReturnCtx(t);return Cr(r,{code:ur.invalid_type,expected:kr.never,received:r.parsedType}),Va}};sg.create=n=>new sg({typeName:Ba.ZodNever,...fi(n)});M9=class extends wi{_parse(t){if(this._getType(t)!==kr.undefined){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.void,received:a.parsedType}),Va}return sh(t.data)}};M9.create=n=>new M9({typeName:Ba.ZodVoid,...fi(n)});bW=class n extends wi{_parse(t){let{ctx:r,status:a}=this._processInputParams(t),i=this._def;if(r.parsedType!==kr.array)return Cr(r,{code:ur.invalid_type,expected:kr.array,received:r.parsedType}),Va;if(i.exactLength!==null){let e=r.data.length>i.exactLength.value,c=r.data.length<i.exactLength.value;(e||c)&&(Cr(r,{code:e?ur.too_big:ur.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&&(Cr(r,{code:ur.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&&(Cr(r,{code:ur.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 zG(r,e,r.path,c)))).then(e=>o0.mergeArray(a,e));let s=[...r.data].map((e,c)=>i.type._parseSync(new zG(r,e,r.path,c)));return o0.mergeArray(a,s)}get element(){return this._def.type}min(t,r){return new n({...this._def,minLength:{value:t,message:la.toString(r)}})}max(t,r){return new n({...this._def,maxLength:{value:t,message:la.toString(r)}})}length(t,r){return new n({...this._def,exactLength:{value:t,message:la.toString(r)}})}nonempty(t){return this.min(1,t)}};bW.create=(n,t)=>new bW({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Ba.ZodArray,...fi(t)});Hp=class n extends wi{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=el.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==kr.object){let d=this._getOrReturnCtx(t);return Cr(d,{code:ur.invalid_type,expected:kr.object,received:d.parsedType}),Va}let{status:a,ctx:i}=this._processInputParams(t),{shape:s,keys:e}=this._getCached(),c=[];if(!(this._def.catchall instanceof sg&&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 zG(i,h,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof sg){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&&(Cr(i,{code:ur.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 zG(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=>o0.mergeObjectSync(a,d)):o0.mergeObjectSync(a,u)}get shape(){return this._def.shape()}strict(t){return la.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:la.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:Ba.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 el.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 el.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}deepPartial(){return O9(this)}partial(t){let r={};for(let a of el.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 el.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof MG;)s=s._def.innerType;r[a]=s}return new n({...this._def,shape:()=>r})}keyof(){return plt(el.objectKeys(this.shape))}};Hp.create=(n,t)=>new Hp({shape:()=>n,unknownKeys:"strip",catchall:sg.create(),typeName:Ba.ZodObject,...fi(t)});Hp.strictCreate=(n,t)=>new Hp({shape:()=>n,unknownKeys:"strict",catchall:sg.create(),typeName:Ba.ZodObject,...fi(t)});Hp.lazycreate=(n,t)=>new Hp({shape:n,unknownKeys:"strip",catchall:sg.create(),typeName:Ba.ZodObject,...fi(t)});tw=class extends wi{_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 Qp(c.ctx.common.issues));return Cr(r,{code:ur.invalid_union,unionErrors:e}),Va}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 Qp(u));return Cr(r,{code:ur.invalid_union,unionErrors:c}),Va}}get options(){return this._def.options}};tw.create=(n,t)=>new tw({options:n,typeName:Ba.ZodUnion,...fi(t)});mW=n=>n instanceof rw?mW(n.schema):n instanceof _G?mW(n.innerType()):n instanceof aw?[n.value]:n instanceof iw?n.options:n instanceof lw?el.objectValues(n.enum):n instanceof sw?mW(n._def.innerType):n instanceof $E?[void 0]:n instanceof ew?[null]:n instanceof MG?[void 0,...mW(n.unwrap())]:n instanceof CZ?[null,...mW(n.unwrap())]:n instanceof q7||n instanceof cw?mW(n.unwrap()):n instanceof ow?mW(n._def.innerType):[],hne=class n extends wi{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==kr.object)return Cr(r,{code:ur.invalid_type,expected:kr.object,received:r.parsedType}),Va;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}):(Cr(r,{code:ur.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),Va)}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=mW(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:Ba.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...fi(a)})}};nw=class extends wi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=(s,e)=>{if(une(s)||une(e))return Va;let c=P3e(s.value,e.value);return c.valid?((dne(s)||dne(e))&&r.dirty(),{status:r.value,value:c.data}):(Cr(a,{code:ur.invalid_intersection_types}),Va)};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}))}};nw.create=(n,t,r)=>new nw({left:n,right:t,typeName:Ba.ZodIntersection,...fi(r)});YZ=class n extends wi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==kr.array)return Cr(a,{code:ur.invalid_type,expected:kr.array,received:a.parsedType}),Va;if(a.data.length<this._def.items.length)return Cr(a,{code:ur.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Va;!this._def.rest&&a.data.length>this._def.items.length&&(Cr(a,{code:ur.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 zG(a,e,a.path,c)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>o0.mergeArray(r,e)):o0.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new n({...this._def,rest:t})}};YZ.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new YZ({items:n,typeName:Ba.ZodTuple,rest:null,...fi(t)})};mne=class n extends wi{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!==kr.object)return Cr(a,{code:ur.invalid_type,expected:kr.object,received:a.parsedType}),Va;let i=[],s=this._def.keyType,e=this._def.valueType;for(let c in a.data)i.push({key:s._parse(new zG(a,c,a.path,c)),value:e._parse(new zG(a,a.data[c],a.path,c)),alwaysSet:c in a.data});return a.common.async?o0.mergeObjectAsync(r,i):o0.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof wi?new n({keyType:t,valueType:r,typeName:Ba.ZodRecord,...fi(a)}):new n({keyType:YF.create(),valueType:t,typeName:Ba.ZodRecord,...fi(r)})}},z9=class extends wi{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!==kr.map)return Cr(a,{code:ur.invalid_type,expected:kr.map,received:a.parsedType}),Va;let i=this._def.keyType,s=this._def.valueType,e=[...a.data.entries()].map(([c,u],d)=>({key:i._parse(new zG(a,c,a.path,[d,"key"])),value:s._parse(new zG(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 Va;(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 Va;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),c.set(d.value,I.value)}return{status:r.value,value:c}}}};z9.create=(n,t,r)=>new z9({valueType:t,keyType:n,typeName:Ba.ZodMap,...fi(r)});_9=class n extends wi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==kr.set)return Cr(a,{code:ur.invalid_type,expected:kr.set,received:a.parsedType}),Va;let i=this._def;i.minSize!==null&&a.data.size<i.minSize.value&&(Cr(a,{code:ur.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&&(Cr(a,{code:ur.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 Va;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 zG(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:la.toString(r)}})}max(t,r){return new n({...this._def,maxSize:{value:t,message:la.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};_9.create=(n,t)=>new _9({valueType:n,minSize:null,maxSize:null,typeName:Ba.ZodSet,...fi(t)});pne=class n extends wi{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==kr.function)return Cr(r,{code:ur.invalid_type,expected:kr.function,received:r.parsedType}),Va;function a(c,u){return K7({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,D9(),hW].filter(d=>!!d),issueData:{code:ur.invalid_arguments,argumentsError:u}})}function i(c,u){return K7({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,D9(),hW].filter(d=>!!d),issueData:{code:ur.invalid_return_type,returnTypeError:u}})}let s={errorMap:r.common.contextualErrorMap},e=r.data;if(this._def.returns instanceof VF){let c=this;return sh(async function(...u){let d=new Qp([]),I=await c._def.args.parseAsync(u,s).catch(v=>{throw d.addIssue(a(u,v)),d}),h=await Reflect.apply(e,this,I);return await c._def.returns._def.type.parseAsync(h,s).catch(v=>{throw d.addIssue(i(h,v)),d})})}else{let c=this;return sh(function(...u){let d=c._def.args.safeParse(u,s);if(!d.success)throw new Qp([a(u,d.error)]);let I=Reflect.apply(e,this,d.data),h=c._def.returns.safeParse(I,s);if(!h.success)throw new Qp([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:YZ.create(t).rest(pW.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||YZ.create([]).rest(pW.create()),returns:r||pW.create(),typeName:Ba.ZodFunction,...fi(a)})}},rw=class extends wi{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})}};rw.create=(n,t)=>new rw({getter:n,typeName:Ba.ZodLazy,...fi(t)});aw=class extends wi{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return Cr(r,{received:r.data,code:ur.invalid_literal,expected:this._def.value}),Va}return{status:"valid",value:t.data}}get value(){return this._def.value}};aw.create=(n,t)=>new aw({value:n,typeName:Ba.ZodLiteral,...fi(t)});iw=class n extends wi{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),a=this._def.values;return Cr(r,{expected:el.joinValues(a),received:r.parsedType,code:ur.invalid_type}),Va}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 Cr(r,{received:r.data,code:ur.invalid_enum_value,options:a}),Va}return sh(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})}};iw.create=plt;lw=class extends wi{_parse(t){let r=el.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==kr.string&&a.parsedType!==kr.number){let i=el.objectValues(r);return Cr(a,{expected:el.joinValues(i),received:a.parsedType,code:ur.invalid_type}),Va}if(this._cache||(this._cache=new Set(el.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=el.objectValues(r);return Cr(a,{received:a.data,code:ur.invalid_enum_value,options:i}),Va}return sh(t.data)}get enum(){return this._def.values}};lw.create=(n,t)=>new lw({values:n,typeName:Ba.ZodNativeEnum,...fi(t)});VF=class extends wi{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==kr.promise&&r.common.async===!1)return Cr(r,{code:ur.invalid_type,expected:kr.promise,received:r.parsedType}),Va;let a=r.parsedType===kr.promise?r.data:Promise.resolve(r.data);return sh(a.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};VF.create=(n,t)=>new VF({type:n,typeName:Ba.ZodPromise,...fi(t)});_G=class extends wi{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ba.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=>{Cr(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 Va;let u=await this._def.schema._parseAsync({data:c,path:a.path,parent:a});return u.status==="aborted"?Va:u.status==="dirty"?_E(u.value):r.value==="dirty"?_E(u.value):u});{if(r.value==="aborted")return Va;let c=this._def.schema._parseSync({data:e,path:a.path,parent:a});return c.status==="aborted"?Va:c.status==="dirty"?_E(c.value):r.value==="dirty"?_E(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"?Va:(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"?Va:(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(!wF(e))return Va;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=>wF(e)?Promise.resolve(i.transform(e.value,s)).then(c=>({status:r.value,value:c})):Va);el.assertNever(i)}};_G.create=(n,t,r)=>new _G({schema:n,typeName:Ba.ZodEffects,effect:t,...fi(r)});_G.createWithPreprocess=(n,t,r)=>new _G({schema:t,effect:{type:"preprocess",transform:n},typeName:Ba.ZodEffects,...fi(r)});MG=class extends wi{_parse(t){return this._getType(t)===kr.undefined?sh(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};MG.create=(n,t)=>new MG({innerType:n,typeName:Ba.ZodOptional,...fi(t)});CZ=class extends wi{_parse(t){return this._getType(t)===kr.null?sh(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};CZ.create=(n,t)=>new CZ({innerType:n,typeName:Ba.ZodNullable,...fi(t)});sw=class extends wi{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return r.parsedType===kr.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};sw.create=(n,t)=>new sw({innerType:n,typeName:Ba.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...fi(t)});ow=class extends wi{_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 T9(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Qp(a.common.issues)},input:a.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Qp(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};ow.create=(n,t)=>new ow({innerType:n,typeName:Ba.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...fi(t)});P9=class extends wi{_parse(t){if(this._getType(t)!==kr.nan){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.nan,received:a.parsedType}),Va}return{status:"valid",value:t.data}}};P9.create=n=>new P9({typeName:Ba.ZodNaN,...fi(n)});PQn=Symbol("zod_brand"),q7=class extends wi{_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}},$7=class n extends wi{_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"?Va:s.status==="dirty"?(r.dirty(),_E(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"?Va: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:Ba.ZodPipeline})}},cw=class extends wi{_parse(t){let r=this._def.innerType._parse(t),a=i=>(wF(i)&&(i.value=Object.freeze(i.value)),i);return T9(r)?r.then(i=>a(i)):a(r)}unwrap(){return this._def.innerType}};cw.create=(n,t)=>new cw({innerType:n,typeName:Ba.ZodReadonly,...fi(t)});jQn={object:Hp.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"})(Ba||(Ba={}));KQn=(n,t={message:`Input not instance of ${n.name}`})=>blt(r=>r instanceof n,t),Glt=YF.create,flt=PE.create,qQn=P9.create,$Qn=jE.create,glt=KE.create,e9n=qE.create,t9n=U9.create,n9n=$E.create,r9n=ew.create,a9n=CF.create,i9n=pW.create,l9n=sg.create,s9n=M9.create,o9n=bW.create,c9n=Hp.create,I9n=Hp.strictCreate,u9n=tw.create,d9n=hne.create,h9n=nw.create,m9n=YZ.create,p9n=mne.create,b9n=z9.create,G9n=_9.create,f9n=pne.create,g9n=rw.create,v9n=aw.create,Z9n=iw.create,N9n=lw.create,W9n=VF.create,A9n=_G.create,F9n=MG.create,y9n=CZ.create,R9n=_G.createWithPreprocess,E9n=$7.create,w9n=()=>Glt().optional(),Y9n=()=>flt().optional(),C9n=()=>glt().optional(),V9n={string:(n=>YF.create({...n,coerce:!0})),number:(n=>PE.create({...n,coerce:!0})),boolean:(n=>KE.create({...n,coerce:!0})),bigint:(n=>jE.create({...n,coerce:!0})),date:(n=>qE.create({...n,coerce:!0}))},x9n=Va});var xc={};Ms(xc,{BRAND:()=>PQn,DIRTY:()=>_E,EMPTY_PATH:()=>RQn,INVALID:()=>Va,NEVER:()=>x9n,OK:()=>sh,ParseStatus:()=>o0,Schema:()=>wi,ZodAny:()=>CF,ZodArray:()=>bW,ZodBigInt:()=>jE,ZodBoolean:()=>KE,ZodBranded:()=>q7,ZodCatch:()=>ow,ZodDate:()=>qE,ZodDefault:()=>sw,ZodDiscriminatedUnion:()=>hne,ZodEffects:()=>_G,ZodEnum:()=>iw,ZodError:()=>Qp,ZodFirstPartyTypeKind:()=>Ba,ZodFunction:()=>pne,ZodIntersection:()=>nw,ZodIssueCode:()=>ur,ZodLazy:()=>rw,ZodLiteral:()=>aw,ZodMap:()=>z9,ZodNaN:()=>P9,ZodNativeEnum:()=>lw,ZodNever:()=>sg,ZodNull:()=>ew,ZodNullable:()=>CZ,ZodNumber:()=>PE,ZodObject:()=>Hp,ZodOptional:()=>MG,ZodParsedType:()=>kr,ZodPipeline:()=>$7,ZodPromise:()=>VF,ZodReadonly:()=>cw,ZodRecord:()=>mne,ZodSchema:()=>wi,ZodSet:()=>_9,ZodString:()=>YF,ZodSymbol:()=>U9,ZodTransformer:()=>_G,ZodTuple:()=>YZ,ZodType:()=>wi,ZodUndefined:()=>$E,ZodUnion:()=>tw,ZodUnknown:()=>pW,ZodVoid:()=>M9,addIssueToContext:()=>Cr,any:()=>a9n,array:()=>o9n,bigint:()=>$Qn,boolean:()=>glt,coerce:()=>V9n,custom:()=>blt,date:()=>e9n,datetimeRegex:()=>mlt,defaultErrorMap:()=>hW,discriminatedUnion:()=>d9n,effect:()=>A9n,enum:()=>Z9n,function:()=>f9n,getErrorMap:()=>D9,getParsedType:()=>wZ,instanceof:()=>KQn,intersection:()=>h9n,isAborted:()=>une,isAsync:()=>T9,isDirty:()=>dne,isValid:()=>wF,late:()=>jQn,lazy:()=>g9n,literal:()=>v9n,makeIssue:()=>K7,map:()=>b9n,nan:()=>qQn,nativeEnum:()=>N9n,never:()=>l9n,null:()=>r9n,nullable:()=>y9n,number:()=>flt,object:()=>c9n,objectUtil:()=>U3e,oboolean:()=>C9n,onumber:()=>Y9n,optional:()=>F9n,ostring:()=>w9n,pipeline:()=>E9n,preprocess:()=>R9n,promise:()=>W9n,quotelessJson:()=>AQn,record:()=>p9n,set:()=>G9n,setErrorMap:()=>yQn,strictObject:()=>I9n,string:()=>Glt,symbol:()=>t9n,transformer:()=>A9n,tuple:()=>m9n,undefined:()=>n9n,union:()=>u9n,unknown:()=>i9n,util:()=>el,void:()=>s9n});var j3e=ut(()=>{Ine();z3e();olt();j7();vlt();cne()});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 hb(n){return n&&Object.assign(bne,n),bne}var K3e,Q9n,GW,bne,j9=ut(()=>{K3e=Object.freeze({status:"aborted"});Q9n=Symbol("zod_brand"),GW=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},bne={}});var rs={};Ms(rs,{BIGINT_FORMAT_RANGES:()=>Nlt,Class:()=>$3e,NUMBER_FORMAT_RANGES:()=>sNe,aborted:()=>uw,allowsEval:()=>aNe,assert:()=>J9n,assertEqual:()=>H9n,assertIs:()=>k9n,assertNever:()=>L9n,assertNotEqual:()=>X9n,assignProp:()=>rNe,cached:()=>tD,captureStackTrace:()=>fne,cleanEnum:()=>q9n,cleanRegex:()=>rD,clone:()=>og,createTransparentProxy:()=>U9n,defineLazy:()=>wo,esc:()=>Iw,escapeRegex:()=>xF,extend:()=>_9n,finalizeIssue:()=>cg,floatSafeRemainder:()=>nNe,getElementAtPath:()=>B9n,getEnumValues:()=>eNe,getLengthableOrigin:()=>aD,getParsedType:()=>O9n,getSizableOrigin:()=>Wlt,isObject:()=>K9,isPlainObject:()=>q9,issue:()=>oNe,joinValues:()=>Gne,jsonStringifyReplacer:()=>tNe,merge:()=>P9n,normalizeParams:()=>ga,nullish:()=>nD,numKeys:()=>T9n,omit:()=>z9n,optionalKeys:()=>lNe,partial:()=>j9n,pick:()=>M9n,prefixIssues:()=>VZ,primitiveTypes:()=>Zlt,promiseAllObject:()=>S9n,propertyKeyTypes:()=>iNe,randomString:()=>D9n,required:()=>K9n,stringifyPrimitive:()=>gne,unwrapMessage:()=>eD});function H9n(n){return n}function X9n(n){return n}function k9n(n){}function L9n(n){throw new Error}function J9n(n){}function eNe(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 Gne(n,t="|"){return n.map(r=>gne(r)).join(t)}function tNe(n,t){return typeof t=="bigint"?t.toString():t}function tD(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function nD(n){return n==null}function rD(n){let t=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(t,r)}function nNe(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 wo(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 rNe(n,t,r){Object.defineProperty(n,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function B9n(n,t){return t?t.reduce((r,a)=>r?.[a],n):n}function S9n(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 D9n(n=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<n;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function Iw(n){return JSON.stringify(n)}function K9(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function q9(n){if(K9(n)===!1)return!1;let t=n.constructor;if(t===void 0)return!0;let r=t.prototype;return!(K9(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function T9n(n){let t=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&t++;return t}function xF(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function og(n,t,r){let a=new n._zod.constr(t??n._zod.def);return(!t||r?.parent)&&(a._zod.parent=n),a}function ga(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 U9n(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 gne(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function lNe(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}function M9n(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 og(n,{...n._zod.def,shape:r,checks:[]})}function z9n(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 og(n,{...n._zod.def,shape:r,checks:[]})}function _9n(n,t){if(!q9(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 rNe(this,"shape",a),a},checks:[]};return og(n,r)}function P9n(n,t){return og(n,{...n._zod.def,get shape(){let r={...n._zod.def.shape,...t._zod.def.shape};return rNe(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function j9n(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 og(t,{...t._zod.def,shape:i,checks:[]})}function K9n(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 og(t,{...t._zod.def,shape:i,checks:[]})}function uw(n,t=0){for(let r=t;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function VZ(n,t){return t.map(r=>{var a;return(a=r).path??(a.path=[]),r.path.unshift(n),r})}function eD(n){return typeof n=="string"?n:n?.message}function cg(n,t,r){let a={...n,path:n.path??[]};if(!n.message){let i=eD(n.inst?._zod.def?.error?.(n))??eD(t?.error?.(n))??eD(r.customError?.(n))??eD(r.localeError?.(n))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function Wlt(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function aD(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function oNe(...n){let[t,r,a]=n;return typeof t=="string"?{message:t,code:"custom",input:r,inst:a}:{...t}}function q9n(n){return Object.entries(n).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var fne,aNe,O9n,iNe,Zlt,sNe,Nlt,$3e,fW=ut(()=>{fne=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};aNe=tD(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});O9n=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}`)}},iNe=new Set(["string","number","symbol"]),Zlt=new Set(["string","number","bigint","boolean","symbol","undefined"]);sNe={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]},Nlt={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};$3e=class{constructor(...t){}}});function INe(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 uNe(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 Alt,vne,cNe,dNe=ut(()=>{j9();fW();Alt=(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,tNe,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},vne=Ln("$ZodError",Alt),cNe=Ln("$ZodError",Alt,{Parent:Error})});var Flt,ylt,hNe,iD,mNe,Zne,pNe=ut(()=>{j9();dNe();fW();Flt=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 GW;if(e.issues.length){let c=new(i?.Err??n)(e.issues.map(u=>cg(u,s,hb())));throw fne(c,i?.callee),c}return e.value},ylt=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=>cg(u,s,hb())));throw fne(c,i?.callee),c}return e.value},hNe=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 GW;return s.issues.length?{success:!1,error:new(n??vne)(s.issues.map(e=>cg(e,i,hb())))}:{success:!0,data:s.value}},iD=hNe(cNe),mNe=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=>cg(e,i,hb())))}:{success:!0,data:s.value}},Zne=mNe(cNe)});function Xlt(){return new RegExp(eHn,"u")}function Mlt(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 zlt(n){return new RegExp(`^${Mlt(n)}$`)}function _lt(n){let t=Mlt({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(`^${Olt}T(?:${a})$`)}var Rlt,Elt,wlt,Ylt,Clt,Vlt,xlt,Qlt,bNe,Hlt,eHn,klt,Llt,Jlt,Blt,Slt,GNe,Dlt,Tlt,Olt,Ult,Plt,jlt,Klt,qlt,$lt,est,tst,nst,Wne=ut(()=>{Rlt=/^[cC][^\s-]{8,}$/,Elt=/^[0-9a-z]+$/,wlt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ylt=/^[0-9a-vA-V]{20}$/,Clt=/^[A-Za-z0-9]{27}$/,Vlt=/^[a-zA-Z0-9_-]{21}$/,xlt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qlt=/^([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})$/,bNe=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)$/,Hlt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,eHn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";klt=/^(?:(?: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])$/,Llt=/^(([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})$/,Jlt=/^((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])$/,Blt=/^(([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])$/,Slt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,GNe=/^[A-Za-z0-9_-]*$/,Dlt=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Tlt=/^\+(?:[0-9]){6,14}[0-9]$/,Olt="(?:(?:\\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])))",Ult=new RegExp(`^${Olt}$`);Plt=n=>{let t=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},jlt=/^\d+n?$/,Klt=/^\d+$/,qlt=/^-?\d+(?:\.\d+)?/i,$lt=/true|false/i,est=/null/i,tst=/^[^A-Z]*$/,nst=/^[^a-z]*$/});var oh,rst,fNe,gNe,ast,ist,lst,sst,ost,lD,cst,Ist,ust,dst,hst,mst,pst,Ane=ut(()=>{j9();Wne();fW();oh=Ln("$ZodCheck",(n,t)=>{var r;n._zod??(n._zod={}),n._zod.def=t,(r=n._zod).onattach??(r.onattach=[])}),rst={number:"number",bigint:"bigint",object:"date"},fNe=Ln("$ZodCheckLessThan",(n,t)=>{oh.init(n,t);let r=rst[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})}}),gNe=Ln("$ZodCheckGreaterThan",(n,t)=>{oh.init(n,t);let r=rst[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})}}),ast=Ln("$ZodCheckMultipleOf",(n,t)=>{oh.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):nNe(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})}}),ist=Ln("$ZodCheckNumberFormat",(n,t)=>{oh.init(n,t),t.format=t.format||"float64";let r=t.format?.includes("int"),a=r?"int":"number",[i,s]=sNe[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=Klt)}),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})}}),lst=Ln("$ZodCheckMaxLength",(n,t)=>{var r;oh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!nD(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=aD(i);a.issues.push({origin:e,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),sst=Ln("$ZodCheckMinLength",(n,t)=>{var r;oh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!nD(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=aD(i);a.issues.push({origin:e,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),ost=Ln("$ZodCheckLengthEquals",(n,t)=>{var r;oh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!nD(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=aD(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})}}),lD=Ln("$ZodCheckStringFormat",(n,t)=>{var r,a;oh.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=()=>{})}),cst=Ln("$ZodCheckRegex",(n,t)=>{lD.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})}}),Ist=Ln("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=tst),lD.init(n,t)}),ust=Ln("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=nst),lD.init(n,t)}),dst=Ln("$ZodCheckIncludes",(n,t)=>{oh.init(n,t);let r=xF(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})}}),hst=Ln("$ZodCheckStartsWith",(n,t)=>{oh.init(n,t);let r=new RegExp(`^${xF(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})}}),mst=Ln("$ZodCheckEndsWith",(n,t)=>{oh.init(n,t);let r=new RegExp(`.*${xF(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})}}),pst=Ln("$ZodCheckOverwrite",(n,t)=>{oh.init(n,t),n._zod.check=r=>{r.value=t.tx(r.value)}})});var Fne,vNe=ut(()=>{Fne=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(`
|
|
644
|
+
`);s=v.pop()||"";for(let w of v)if(w.startsWith("data: ")){let R=w.slice(6);if(R==="[DONE]")return;try{let E=JSON.parse(R);if(E.type==="connection_established")continue;if(E.error)throw new Error(E.error);E.usageMetadata&&(c=E.usageMetadata);let A=this.convertStreamChunkToGenAI(E);A&&(yield A)}catch(E){er.warn("[DeepV Server] Stream chunk parse error",{data:R.substring(0,100)+"...",error:E instanceof Error?E.message:E})}}}}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=Qu.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":Qu.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 Ep.emitRealTimeToken({inputTokens:a.totalTokens||0,outputTokens:0,totalTokens:a.totalTokens||0,timestamp:Date.now()}),a}catch(r){return er.error("[DeepV Server] Token count failed:",r),this.estimateTokensAsFailback(t)}}async callUnifiedTokenCountAPI(t){let r=await ns.getUserHeaders(),a=`${ns.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 pI("Authentication required - please re-authenticate")):new Error(`Token count API failed (${i.status}): ${e}`)}let s=await i.json();return er.debug("[DeepV Server] Token count response",{totalTokens:s.totalTokens}),{totalTokens:s.totalTokens||0}}catch(i){throw er.error("[DeepV Server] Token count API call failed:",i),i}}estimateTokensAsFailback(t){try{let r=Array.isArray(t.contents)?t.contents:[{role:ia.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 v of o.parts)if(typeof v=="object"&&v&&"text"in v&&typeof v.text=="string")a+=v.text.length,e++;else if(typeof v=="object"&&v&&"functionCall"in v&&v.functionCall){let w=v.functionCall,R=`[Tool: ${w.name}]`+JSON.stringify(w.args||{});a+=R.length,i++}else if(typeof v=="object"&&v&&"functionResponse"in v&&v.functionResponse){let E=`[Tool Result: ${v.functionResponse.response?.output||"result"}]`;a+=E.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 D3e(n,t){let r=n.getModel()||"auto",a={authType:t,proxy:n?.getProxy()};return t===vl.USE_PROXY_AUTH,a}async function T3e(n,t,r){let i={headers:{"User-Agent":`GeminiCLI/1.0.248 (${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(!Dfe())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=dZ(),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 S9(u,d,c,t)}throw new Error(`Error creating contentGenerator: Unsupported authType: ${n.authType}`)}var vl,ane=ut(()=>{"use strict";S3e();qQ();(function(n){n.USE_PROXY_AUTH="proxy-auth"})(vl||(vl={}))});var ine,ilt=ut(()=>{"use strict";ine=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 lg(n){let t={type:"subagent_update",data:n,timestamp:Date.now()};return JSON.stringify(t)}function llt(n){let t={type:"text",data:n,timestamp:Date.now()};return JSON.stringify(t)}function lne(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 sne(n){return n.type==="subagent_update"}function one(n){return n.type==="text"}var O3e=ut(()=>{"use strict";});var La,Xr,Ja,Eo=ut(()=>{"use strict";O3e();La=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"})(Xr||(Xr={}));(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"})(Ja||(Ja={}))});var el,U3e,kr,wZ,j7=ut(()=>{(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})(el||(el={}));(function(n){n.mergeShapes=(t,r)=>({...t,...r})})(U3e||(U3e={}));kr=el.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wZ=n=>{switch(typeof n){case"undefined":return kr.undefined;case"string":return kr.string;case"number":return Number.isNaN(n)?kr.nan:kr.number;case"boolean":return kr.boolean;case"function":return kr.function;case"bigint":return kr.bigint;case"symbol":return kr.symbol;case"object":return Array.isArray(n)?kr.array:n===null?kr.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?kr.promise:typeof Map<"u"&&n instanceof Map?kr.map:typeof Set<"u"&&n instanceof Set?kr.set:typeof Date<"u"&&n instanceof Date?kr.date:kr.object;default:return kr.unknown}}});var ur,AQn,Qp,cne=ut(()=>{j7();ur=el.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"]),AQn=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:"),Qp=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,el.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()}};Qp.create=n=>new Qp(n)});var FQn,hW,M3e=ut(()=>{cne();j7();FQn=(n,t)=>{let r;switch(n.code){case ur.invalid_type:n.received===kr.undefined?r="Required":r=`Expected ${n.expected}, received ${n.received}`;break;case ur.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(n.expected,el.jsonStringifyReplacer)}`;break;case ur.unrecognized_keys:r=`Unrecognized key(s) in object: ${el.joinValues(n.keys,", ")}`;break;case ur.invalid_union:r="Invalid input";break;case ur.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${el.joinValues(n.options)}`;break;case ur.invalid_enum_value:r=`Invalid enum value. Expected ${el.joinValues(n.options)}, received '${n.received}'`;break;case ur.invalid_arguments:r="Invalid function arguments";break;case ur.invalid_return_type:r="Invalid function return type";break;case ur.invalid_date:r="Invalid date";break;case ur.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}"`:el.assertNever(n.validation):n.validation!=="regex"?r=`Invalid ${n.validation}`:r="Invalid";break;case ur.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 ur.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 ur.custom:r="Invalid input";break;case ur.invalid_intersection_types:r="Intersection results could not be merged";break;case ur.not_multiple_of:r=`Number must be a multiple of ${n.multipleOf}`;break;case ur.not_finite:r="Number must be finite";break;default:r=t.defaultError,el.assertNever(n)}return{message:r}},hW=FQn});function yQn(n){slt=n}function D9(){return slt}var slt,Ine=ut(()=>{M3e();slt=hW});function Cr(n,t){let r=D9(),a=K7({issueData:t,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,r,r===hW?void 0:hW].filter(i=>!!i)});n.common.issues.push(a)}var K7,RQn,o0,Va,_E,sh,une,dne,wF,T9,z3e=ut(()=>{Ine();M3e();K7=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}},RQn=[];o0=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 Va;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 Va;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}}},Va=Object.freeze({status:"aborted"}),_E=n=>({status:"dirty",value:n}),sh=n=>({status:"valid",value:n}),une=n=>n.status==="aborted",dne=n=>n.status==="dirty",wF=n=>n.status==="valid",T9=n=>typeof Promise<"u"&&n instanceof Promise});var olt=ut(()=>{});var la,clt=ut(()=>{(function(n){n.errToObj=t=>typeof t=="string"?{message:t}:t||{},n.toString=t=>typeof t=="string"?t:t?.message})(la||(la={}))});function fi(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 hlt(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 OQn(n){return new RegExp(`^${hlt(n)}$`)}function mlt(n){let t=`${dlt}T${hlt(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 UQn(n,t){return!!((t==="v4"||!t)&&kQn.test(n)||(t==="v6"||!t)&&JQn.test(n))}function MQn(n,t){if(!xQn.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 zQn(n,t){return!!((t==="v4"||!t)&&LQn.test(n)||(t==="v6"||!t)&&BQn.test(n))}function _Qn(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 O9(n){if(n instanceof Hp){let t={};for(let r in n.shape){let a=n.shape[r];t[r]=MG.create(O9(a))}return new Hp({...n._def,shape:()=>t})}else return n instanceof bW?new bW({...n._def,type:O9(n.element)}):n instanceof MG?MG.create(O9(n.unwrap())):n instanceof CZ?CZ.create(O9(n.unwrap())):n instanceof YZ?YZ.create(n.items.map(t=>O9(t))):n}function P3e(n,t){let r=wZ(n),a=wZ(t);if(n===t)return{valid:!0,data:n};if(r===kr.object&&a===kr.object){let i=el.objectKeys(t),s=el.objectKeys(n).filter(c=>i.indexOf(c)!==-1),e={...n,...t};for(let c of s){let u=P3e(n[c],t[c]);if(!u.valid)return{valid:!1};e[c]=u.data}return{valid:!0,data:e}}else if(r===kr.array&&a===kr.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=P3e(e,c);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===kr.date&&a===kr.date&&+n==+t?{valid:!0,data:n}:{valid:!1}}function plt(n,t){return new iw({values:n,typeName:Ba.ZodEnum,...fi(t)})}function ult(n,t){let r=typeof n=="function"?n(t):typeof n=="string"?{message:n}:n;return typeof r=="string"?{message:r}:r}function blt(n,t={},r){return n?CF.create().superRefine((a,i)=>{let s=n(a);if(s instanceof Promise)return s.then(e=>{if(!e){let c=ult(t,a),u=c.fatal??r??!0;i.addIssue({code:"custom",...c,fatal:u})}});if(!s){let e=ult(t,a),c=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:c})}}):CF.create()}var zG,Ilt,wi,EQn,wQn,YQn,CQn,VQn,xQn,QQn,HQn,XQn,_3e,kQn,LQn,JQn,BQn,SQn,DQn,dlt,TQn,YF,PE,jE,KE,qE,U9,$E,ew,CF,pW,sg,M9,bW,Hp,tw,mW,hne,nw,YZ,mne,z9,_9,pne,rw,aw,iw,lw,VF,_G,MG,CZ,sw,ow,P9,PQn,q7,$7,cw,jQn,Ba,KQn,Glt,flt,qQn,$Qn,glt,e9n,t9n,n9n,r9n,a9n,i9n,l9n,s9n,o9n,c9n,I9n,u9n,d9n,h9n,m9n,p9n,b9n,G9n,f9n,g9n,v9n,Z9n,N9n,W9n,A9n,F9n,y9n,R9n,E9n,w9n,Y9n,C9n,V9n,x9n,vlt=ut(()=>{cne();Ine();clt();z3e();j7();zG=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}},Ilt=(n,t)=>{if(wF(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 Qp(n.common.issues);return this._error=r,this._error}}};wi=class{get description(){return this._def.description}_getType(t){return wZ(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:wZ(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new o0,ctx:{common:t.parent.common,data:t.data,parsedType:wZ(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(T9(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:wZ(t)},i=this._parseSync({data:t,path:a.path,parent:a});return Ilt(a,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wZ(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:r});return wF(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=>wF(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:wZ(t)},i=this._parse({data:t,path:a.path,parent:a}),s=await(T9(i)?i:Promise.resolve(i));return Ilt(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:ur.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 _G({schema:this,typeName:Ba.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 MG.create(this,this._def)}nullable(){return CZ.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return bW.create(this)}promise(){return VF.create(this,this._def)}or(t){return tw.create([this,t],this._def)}and(t){return nw.create(this,t,this._def)}transform(t){return new _G({...fi(this._def),schema:this,typeName:Ba.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new sw({...fi(this._def),innerType:this,defaultValue:r,typeName:Ba.ZodDefault})}brand(){return new q7({typeName:Ba.ZodBranded,type:this,...fi(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new ow({...fi(this._def),innerType:this,catchValue:r,typeName:Ba.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return $7.create(this,t)}readonly(){return cw.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},EQn=/^c[^\s-]{8,}$/i,wQn=/^[0-9a-z]+$/,YQn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,CQn=/^[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,VQn=/^[a-z0-9_-]{21}$/i,xQn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,QQn=/^[-+]?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)?)??$/,HQn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,XQn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",kQn=/^(?:(?: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])$/,LQn=/^(?:(?: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])$/,JQn=/^(([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]))$/,BQn=/^(([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])$/,SQn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,DQn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dlt="((\\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])))",TQn=new RegExp(`^${dlt}$`);YF=class n extends wi{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==kr.string){let s=this._getOrReturnCtx(t);return Cr(s,{code:ur.invalid_type,expected:kr.string,received:s.parsedType}),Va}let a=new o0,i;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.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),Cr(i,{code:ur.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?Cr(i,{code:ur.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&Cr(i,{code:ur.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")HQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"email",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")_3e||(_3e=new RegExp(XQn,"u")),_3e.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"emoji",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")CQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"uuid",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")VQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"nanoid",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")EQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"cuid",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")wQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"cuid2",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")YQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"ulid",code:ur.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),Cr(i,{validation:"url",code:ur.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),Cr(i,{validation:"regex",code:ur.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),Cr(i,{code:ur.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),Cr(i,{code:ur.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?mlt(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?TQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?OQn(s).test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?QQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"duration",code:ur.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?UQn(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"ip",code:ur.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?MQn(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"jwt",code:ur.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?zQn(t.data,s.version)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"cidr",code:ur.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?SQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"base64",code:ur.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?DQn.test(t.data)||(i=this._getOrReturnCtx(t,i),Cr(i,{validation:"base64url",code:ur.invalid_string,message:s.message}),a.dirty()):el.assertNever(s);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(i=>t.test(i),{validation:r,code:ur.invalid_string,...la.errToObj(a)})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...la.errToObj(t)})}url(t){return this._addCheck({kind:"url",...la.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...la.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...la.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...la.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...la.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...la.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...la.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...la.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...la.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...la.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...la.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...la.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,...la.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,...la.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...la.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...la.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...la.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...la.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...la.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...la.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...la.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...la.errToObj(r)})}nonempty(t){return this.min(1,la.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}};YF.create=n=>new YF({checks:[],typeName:Ba.ZodString,coerce:n?.coerce??!1,...fi(n)});PE=class n extends wi{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)!==kr.number){let s=this._getOrReturnCtx(t);return Cr(s,{code:ur.invalid_type,expected:kr.number,received:s.parsedType}),Va}let a,i=new o0;for(let s of this._def.checks)s.kind==="int"?el.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),Cr(a,{code:ur.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),Cr(a,{code:ur.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),Cr(a,{code:ur.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?_Qn(t.data,s.value)!==0&&(a=this._getOrReturnCtx(t,a),Cr(a,{code:ur.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),Cr(a,{code:ur.not_finite,message:s.message}),i.dirty()):el.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,la.toString(r))}gt(t,r){return this.setLimit("min",t,!1,la.toString(r))}lte(t,r){return this.setLimit("max",t,!0,la.toString(r))}lt(t,r){return this.setLimit("max",t,!1,la.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:la.toString(i)}]})}_addCheck(t){return new n({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:la.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:la.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:la.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:la.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:la.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:la.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:la.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:la.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:la.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"&&el.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)}};PE.create=n=>new PE({checks:[],typeName:Ba.ZodNumber,coerce:n?.coerce||!1,...fi(n)});jE=class n extends wi{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)!==kr.bigint)return this._getInvalidInput(t);let a,i=new o0;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),Cr(a,{code:ur.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),Cr(a,{code:ur.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),Cr(a,{code:ur.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):el.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return Cr(r,{code:ur.invalid_type,expected:kr.bigint,received:r.parsedType}),Va}gte(t,r){return this.setLimit("min",t,!0,la.toString(r))}gt(t,r){return this.setLimit("min",t,!1,la.toString(r))}lte(t,r){return this.setLimit("max",t,!0,la.toString(r))}lt(t,r){return this.setLimit("max",t,!1,la.toString(r))}setLimit(t,r,a,i){return new n({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:la.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:la.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:la.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:la.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:la.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:la.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}};jE.create=n=>new jE({checks:[],typeName:Ba.ZodBigInt,coerce:n?.coerce??!1,...fi(n)});KE=class extends wi{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==kr.boolean){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.boolean,received:a.parsedType}),Va}return sh(t.data)}};KE.create=n=>new KE({typeName:Ba.ZodBoolean,coerce:n?.coerce||!1,...fi(n)});qE=class n extends wi{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==kr.date){let s=this._getOrReturnCtx(t);return Cr(s,{code:ur.invalid_type,expected:kr.date,received:s.parsedType}),Va}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return Cr(s,{code:ur.invalid_date}),Va}let a=new o0,i;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),Cr(i,{code:ur.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),Cr(i,{code:ur.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):el.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:la.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:la.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}};qE.create=n=>new qE({checks:[],coerce:n?.coerce||!1,typeName:Ba.ZodDate,...fi(n)});U9=class extends wi{_parse(t){if(this._getType(t)!==kr.symbol){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.symbol,received:a.parsedType}),Va}return sh(t.data)}};U9.create=n=>new U9({typeName:Ba.ZodSymbol,...fi(n)});$E=class extends wi{_parse(t){if(this._getType(t)!==kr.undefined){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.undefined,received:a.parsedType}),Va}return sh(t.data)}};$E.create=n=>new $E({typeName:Ba.ZodUndefined,...fi(n)});ew=class extends wi{_parse(t){if(this._getType(t)!==kr.null){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.null,received:a.parsedType}),Va}return sh(t.data)}};ew.create=n=>new ew({typeName:Ba.ZodNull,...fi(n)});CF=class extends wi{constructor(){super(...arguments),this._any=!0}_parse(t){return sh(t.data)}};CF.create=n=>new CF({typeName:Ba.ZodAny,...fi(n)});pW=class extends wi{constructor(){super(...arguments),this._unknown=!0}_parse(t){return sh(t.data)}};pW.create=n=>new pW({typeName:Ba.ZodUnknown,...fi(n)});sg=class extends wi{_parse(t){let r=this._getOrReturnCtx(t);return Cr(r,{code:ur.invalid_type,expected:kr.never,received:r.parsedType}),Va}};sg.create=n=>new sg({typeName:Ba.ZodNever,...fi(n)});M9=class extends wi{_parse(t){if(this._getType(t)!==kr.undefined){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.void,received:a.parsedType}),Va}return sh(t.data)}};M9.create=n=>new M9({typeName:Ba.ZodVoid,...fi(n)});bW=class n extends wi{_parse(t){let{ctx:r,status:a}=this._processInputParams(t),i=this._def;if(r.parsedType!==kr.array)return Cr(r,{code:ur.invalid_type,expected:kr.array,received:r.parsedType}),Va;if(i.exactLength!==null){let e=r.data.length>i.exactLength.value,c=r.data.length<i.exactLength.value;(e||c)&&(Cr(r,{code:e?ur.too_big:ur.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&&(Cr(r,{code:ur.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&&(Cr(r,{code:ur.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 zG(r,e,r.path,c)))).then(e=>o0.mergeArray(a,e));let s=[...r.data].map((e,c)=>i.type._parseSync(new zG(r,e,r.path,c)));return o0.mergeArray(a,s)}get element(){return this._def.type}min(t,r){return new n({...this._def,minLength:{value:t,message:la.toString(r)}})}max(t,r){return new n({...this._def,maxLength:{value:t,message:la.toString(r)}})}length(t,r){return new n({...this._def,exactLength:{value:t,message:la.toString(r)}})}nonempty(t){return this.min(1,t)}};bW.create=(n,t)=>new bW({type:n,minLength:null,maxLength:null,exactLength:null,typeName:Ba.ZodArray,...fi(t)});Hp=class n extends wi{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=el.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==kr.object){let d=this._getOrReturnCtx(t);return Cr(d,{code:ur.invalid_type,expected:kr.object,received:d.parsedType}),Va}let{status:a,ctx:i}=this._processInputParams(t),{shape:s,keys:e}=this._getCached(),c=[];if(!(this._def.catchall instanceof sg&&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 zG(i,h,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof sg){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&&(Cr(i,{code:ur.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 zG(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=>o0.mergeObjectSync(a,d)):o0.mergeObjectSync(a,u)}get shape(){return this._def.shape()}strict(t){return la.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:la.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:Ba.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 el.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 el.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new n({...this._def,shape:()=>r})}deepPartial(){return O9(this)}partial(t){let r={};for(let a of el.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 el.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof MG;)s=s._def.innerType;r[a]=s}return new n({...this._def,shape:()=>r})}keyof(){return plt(el.objectKeys(this.shape))}};Hp.create=(n,t)=>new Hp({shape:()=>n,unknownKeys:"strip",catchall:sg.create(),typeName:Ba.ZodObject,...fi(t)});Hp.strictCreate=(n,t)=>new Hp({shape:()=>n,unknownKeys:"strict",catchall:sg.create(),typeName:Ba.ZodObject,...fi(t)});Hp.lazycreate=(n,t)=>new Hp({shape:n,unknownKeys:"strip",catchall:sg.create(),typeName:Ba.ZodObject,...fi(t)});tw=class extends wi{_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 Qp(c.ctx.common.issues));return Cr(r,{code:ur.invalid_union,unionErrors:e}),Va}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 Qp(u));return Cr(r,{code:ur.invalid_union,unionErrors:c}),Va}}get options(){return this._def.options}};tw.create=(n,t)=>new tw({options:n,typeName:Ba.ZodUnion,...fi(t)});mW=n=>n instanceof rw?mW(n.schema):n instanceof _G?mW(n.innerType()):n instanceof aw?[n.value]:n instanceof iw?n.options:n instanceof lw?el.objectValues(n.enum):n instanceof sw?mW(n._def.innerType):n instanceof $E?[void 0]:n instanceof ew?[null]:n instanceof MG?[void 0,...mW(n.unwrap())]:n instanceof CZ?[null,...mW(n.unwrap())]:n instanceof q7||n instanceof cw?mW(n.unwrap()):n instanceof ow?mW(n._def.innerType):[],hne=class n extends wi{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==kr.object)return Cr(r,{code:ur.invalid_type,expected:kr.object,received:r.parsedType}),Va;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}):(Cr(r,{code:ur.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),Va)}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=mW(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:Ba.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...fi(a)})}};nw=class extends wi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t),i=(s,e)=>{if(une(s)||une(e))return Va;let c=P3e(s.value,e.value);return c.valid?((dne(s)||dne(e))&&r.dirty(),{status:r.value,value:c.data}):(Cr(a,{code:ur.invalid_intersection_types}),Va)};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}))}};nw.create=(n,t,r)=>new nw({left:n,right:t,typeName:Ba.ZodIntersection,...fi(r)});YZ=class n extends wi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==kr.array)return Cr(a,{code:ur.invalid_type,expected:kr.array,received:a.parsedType}),Va;if(a.data.length<this._def.items.length)return Cr(a,{code:ur.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Va;!this._def.rest&&a.data.length>this._def.items.length&&(Cr(a,{code:ur.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 zG(a,e,a.path,c)):null}).filter(e=>!!e);return a.common.async?Promise.all(s).then(e=>o0.mergeArray(r,e)):o0.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new n({...this._def,rest:t})}};YZ.create=(n,t)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new YZ({items:n,typeName:Ba.ZodTuple,rest:null,...fi(t)})};mne=class n extends wi{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!==kr.object)return Cr(a,{code:ur.invalid_type,expected:kr.object,received:a.parsedType}),Va;let i=[],s=this._def.keyType,e=this._def.valueType;for(let c in a.data)i.push({key:s._parse(new zG(a,c,a.path,c)),value:e._parse(new zG(a,a.data[c],a.path,c)),alwaysSet:c in a.data});return a.common.async?o0.mergeObjectAsync(r,i):o0.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof wi?new n({keyType:t,valueType:r,typeName:Ba.ZodRecord,...fi(a)}):new n({keyType:YF.create(),valueType:t,typeName:Ba.ZodRecord,...fi(r)})}},z9=class extends wi{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!==kr.map)return Cr(a,{code:ur.invalid_type,expected:kr.map,received:a.parsedType}),Va;let i=this._def.keyType,s=this._def.valueType,e=[...a.data.entries()].map(([c,u],d)=>({key:i._parse(new zG(a,c,a.path,[d,"key"])),value:s._parse(new zG(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 Va;(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 Va;(d.status==="dirty"||I.status==="dirty")&&r.dirty(),c.set(d.value,I.value)}return{status:r.value,value:c}}}};z9.create=(n,t,r)=>new z9({valueType:t,keyType:n,typeName:Ba.ZodMap,...fi(r)});_9=class n extends wi{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==kr.set)return Cr(a,{code:ur.invalid_type,expected:kr.set,received:a.parsedType}),Va;let i=this._def;i.minSize!==null&&a.data.size<i.minSize.value&&(Cr(a,{code:ur.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&&(Cr(a,{code:ur.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 Va;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 zG(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:la.toString(r)}})}max(t,r){return new n({...this._def,maxSize:{value:t,message:la.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};_9.create=(n,t)=>new _9({valueType:n,minSize:null,maxSize:null,typeName:Ba.ZodSet,...fi(t)});pne=class n extends wi{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==kr.function)return Cr(r,{code:ur.invalid_type,expected:kr.function,received:r.parsedType}),Va;function a(c,u){return K7({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,D9(),hW].filter(d=>!!d),issueData:{code:ur.invalid_arguments,argumentsError:u}})}function i(c,u){return K7({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,D9(),hW].filter(d=>!!d),issueData:{code:ur.invalid_return_type,returnTypeError:u}})}let s={errorMap:r.common.contextualErrorMap},e=r.data;if(this._def.returns instanceof VF){let c=this;return sh(async function(...u){let d=new Qp([]),I=await c._def.args.parseAsync(u,s).catch(v=>{throw d.addIssue(a(u,v)),d}),h=await Reflect.apply(e,this,I);return await c._def.returns._def.type.parseAsync(h,s).catch(v=>{throw d.addIssue(i(h,v)),d})})}else{let c=this;return sh(function(...u){let d=c._def.args.safeParse(u,s);if(!d.success)throw new Qp([a(u,d.error)]);let I=Reflect.apply(e,this,d.data),h=c._def.returns.safeParse(I,s);if(!h.success)throw new Qp([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:YZ.create(t).rest(pW.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||YZ.create([]).rest(pW.create()),returns:r||pW.create(),typeName:Ba.ZodFunction,...fi(a)})}},rw=class extends wi{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})}};rw.create=(n,t)=>new rw({getter:n,typeName:Ba.ZodLazy,...fi(t)});aw=class extends wi{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return Cr(r,{received:r.data,code:ur.invalid_literal,expected:this._def.value}),Va}return{status:"valid",value:t.data}}get value(){return this._def.value}};aw.create=(n,t)=>new aw({value:n,typeName:Ba.ZodLiteral,...fi(t)});iw=class n extends wi{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),a=this._def.values;return Cr(r,{expected:el.joinValues(a),received:r.parsedType,code:ur.invalid_type}),Va}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 Cr(r,{received:r.data,code:ur.invalid_enum_value,options:a}),Va}return sh(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})}};iw.create=plt;lw=class extends wi{_parse(t){let r=el.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==kr.string&&a.parsedType!==kr.number){let i=el.objectValues(r);return Cr(a,{expected:el.joinValues(i),received:a.parsedType,code:ur.invalid_type}),Va}if(this._cache||(this._cache=new Set(el.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=el.objectValues(r);return Cr(a,{received:a.data,code:ur.invalid_enum_value,options:i}),Va}return sh(t.data)}get enum(){return this._def.values}};lw.create=(n,t)=>new lw({values:n,typeName:Ba.ZodNativeEnum,...fi(t)});VF=class extends wi{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==kr.promise&&r.common.async===!1)return Cr(r,{code:ur.invalid_type,expected:kr.promise,received:r.parsedType}),Va;let a=r.parsedType===kr.promise?r.data:Promise.resolve(r.data);return sh(a.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};VF.create=(n,t)=>new VF({type:n,typeName:Ba.ZodPromise,...fi(t)});_G=class extends wi{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ba.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=>{Cr(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 Va;let u=await this._def.schema._parseAsync({data:c,path:a.path,parent:a});return u.status==="aborted"?Va:u.status==="dirty"?_E(u.value):r.value==="dirty"?_E(u.value):u});{if(r.value==="aborted")return Va;let c=this._def.schema._parseSync({data:e,path:a.path,parent:a});return c.status==="aborted"?Va:c.status==="dirty"?_E(c.value):r.value==="dirty"?_E(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"?Va:(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"?Va:(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(!wF(e))return Va;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=>wF(e)?Promise.resolve(i.transform(e.value,s)).then(c=>({status:r.value,value:c})):Va);el.assertNever(i)}};_G.create=(n,t,r)=>new _G({schema:n,typeName:Ba.ZodEffects,effect:t,...fi(r)});_G.createWithPreprocess=(n,t,r)=>new _G({schema:t,effect:{type:"preprocess",transform:n},typeName:Ba.ZodEffects,...fi(r)});MG=class extends wi{_parse(t){return this._getType(t)===kr.undefined?sh(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};MG.create=(n,t)=>new MG({innerType:n,typeName:Ba.ZodOptional,...fi(t)});CZ=class extends wi{_parse(t){return this._getType(t)===kr.null?sh(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};CZ.create=(n,t)=>new CZ({innerType:n,typeName:Ba.ZodNullable,...fi(t)});sw=class extends wi{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return r.parsedType===kr.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};sw.create=(n,t)=>new sw({innerType:n,typeName:Ba.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...fi(t)});ow=class extends wi{_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 T9(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Qp(a.common.issues)},input:a.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Qp(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};ow.create=(n,t)=>new ow({innerType:n,typeName:Ba.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...fi(t)});P9=class extends wi{_parse(t){if(this._getType(t)!==kr.nan){let a=this._getOrReturnCtx(t);return Cr(a,{code:ur.invalid_type,expected:kr.nan,received:a.parsedType}),Va}return{status:"valid",value:t.data}}};P9.create=n=>new P9({typeName:Ba.ZodNaN,...fi(n)});PQn=Symbol("zod_brand"),q7=class extends wi{_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}},$7=class n extends wi{_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"?Va:s.status==="dirty"?(r.dirty(),_E(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"?Va: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:Ba.ZodPipeline})}},cw=class extends wi{_parse(t){let r=this._def.innerType._parse(t),a=i=>(wF(i)&&(i.value=Object.freeze(i.value)),i);return T9(r)?r.then(i=>a(i)):a(r)}unwrap(){return this._def.innerType}};cw.create=(n,t)=>new cw({innerType:n,typeName:Ba.ZodReadonly,...fi(t)});jQn={object:Hp.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"})(Ba||(Ba={}));KQn=(n,t={message:`Input not instance of ${n.name}`})=>blt(r=>r instanceof n,t),Glt=YF.create,flt=PE.create,qQn=P9.create,$Qn=jE.create,glt=KE.create,e9n=qE.create,t9n=U9.create,n9n=$E.create,r9n=ew.create,a9n=CF.create,i9n=pW.create,l9n=sg.create,s9n=M9.create,o9n=bW.create,c9n=Hp.create,I9n=Hp.strictCreate,u9n=tw.create,d9n=hne.create,h9n=nw.create,m9n=YZ.create,p9n=mne.create,b9n=z9.create,G9n=_9.create,f9n=pne.create,g9n=rw.create,v9n=aw.create,Z9n=iw.create,N9n=lw.create,W9n=VF.create,A9n=_G.create,F9n=MG.create,y9n=CZ.create,R9n=_G.createWithPreprocess,E9n=$7.create,w9n=()=>Glt().optional(),Y9n=()=>flt().optional(),C9n=()=>glt().optional(),V9n={string:(n=>YF.create({...n,coerce:!0})),number:(n=>PE.create({...n,coerce:!0})),boolean:(n=>KE.create({...n,coerce:!0})),bigint:(n=>jE.create({...n,coerce:!0})),date:(n=>qE.create({...n,coerce:!0}))},x9n=Va});var xc={};Ms(xc,{BRAND:()=>PQn,DIRTY:()=>_E,EMPTY_PATH:()=>RQn,INVALID:()=>Va,NEVER:()=>x9n,OK:()=>sh,ParseStatus:()=>o0,Schema:()=>wi,ZodAny:()=>CF,ZodArray:()=>bW,ZodBigInt:()=>jE,ZodBoolean:()=>KE,ZodBranded:()=>q7,ZodCatch:()=>ow,ZodDate:()=>qE,ZodDefault:()=>sw,ZodDiscriminatedUnion:()=>hne,ZodEffects:()=>_G,ZodEnum:()=>iw,ZodError:()=>Qp,ZodFirstPartyTypeKind:()=>Ba,ZodFunction:()=>pne,ZodIntersection:()=>nw,ZodIssueCode:()=>ur,ZodLazy:()=>rw,ZodLiteral:()=>aw,ZodMap:()=>z9,ZodNaN:()=>P9,ZodNativeEnum:()=>lw,ZodNever:()=>sg,ZodNull:()=>ew,ZodNullable:()=>CZ,ZodNumber:()=>PE,ZodObject:()=>Hp,ZodOptional:()=>MG,ZodParsedType:()=>kr,ZodPipeline:()=>$7,ZodPromise:()=>VF,ZodReadonly:()=>cw,ZodRecord:()=>mne,ZodSchema:()=>wi,ZodSet:()=>_9,ZodString:()=>YF,ZodSymbol:()=>U9,ZodTransformer:()=>_G,ZodTuple:()=>YZ,ZodType:()=>wi,ZodUndefined:()=>$E,ZodUnion:()=>tw,ZodUnknown:()=>pW,ZodVoid:()=>M9,addIssueToContext:()=>Cr,any:()=>a9n,array:()=>o9n,bigint:()=>$Qn,boolean:()=>glt,coerce:()=>V9n,custom:()=>blt,date:()=>e9n,datetimeRegex:()=>mlt,defaultErrorMap:()=>hW,discriminatedUnion:()=>d9n,effect:()=>A9n,enum:()=>Z9n,function:()=>f9n,getErrorMap:()=>D9,getParsedType:()=>wZ,instanceof:()=>KQn,intersection:()=>h9n,isAborted:()=>une,isAsync:()=>T9,isDirty:()=>dne,isValid:()=>wF,late:()=>jQn,lazy:()=>g9n,literal:()=>v9n,makeIssue:()=>K7,map:()=>b9n,nan:()=>qQn,nativeEnum:()=>N9n,never:()=>l9n,null:()=>r9n,nullable:()=>y9n,number:()=>flt,object:()=>c9n,objectUtil:()=>U3e,oboolean:()=>C9n,onumber:()=>Y9n,optional:()=>F9n,ostring:()=>w9n,pipeline:()=>E9n,preprocess:()=>R9n,promise:()=>W9n,quotelessJson:()=>AQn,record:()=>p9n,set:()=>G9n,setErrorMap:()=>yQn,strictObject:()=>I9n,string:()=>Glt,symbol:()=>t9n,transformer:()=>A9n,tuple:()=>m9n,undefined:()=>n9n,union:()=>u9n,unknown:()=>i9n,util:()=>el,void:()=>s9n});var j3e=ut(()=>{Ine();z3e();olt();j7();vlt();cne()});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 hb(n){return n&&Object.assign(bne,n),bne}var K3e,Q9n,GW,bne,j9=ut(()=>{K3e=Object.freeze({status:"aborted"});Q9n=Symbol("zod_brand"),GW=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},bne={}});var rs={};Ms(rs,{BIGINT_FORMAT_RANGES:()=>Nlt,Class:()=>$3e,NUMBER_FORMAT_RANGES:()=>sNe,aborted:()=>uw,allowsEval:()=>aNe,assert:()=>J9n,assertEqual:()=>H9n,assertIs:()=>k9n,assertNever:()=>L9n,assertNotEqual:()=>X9n,assignProp:()=>rNe,cached:()=>tD,captureStackTrace:()=>fne,cleanEnum:()=>q9n,cleanRegex:()=>rD,clone:()=>og,createTransparentProxy:()=>U9n,defineLazy:()=>wo,esc:()=>Iw,escapeRegex:()=>xF,extend:()=>_9n,finalizeIssue:()=>cg,floatSafeRemainder:()=>nNe,getElementAtPath:()=>B9n,getEnumValues:()=>eNe,getLengthableOrigin:()=>aD,getParsedType:()=>O9n,getSizableOrigin:()=>Wlt,isObject:()=>K9,isPlainObject:()=>q9,issue:()=>oNe,joinValues:()=>Gne,jsonStringifyReplacer:()=>tNe,merge:()=>P9n,normalizeParams:()=>ga,nullish:()=>nD,numKeys:()=>T9n,omit:()=>z9n,optionalKeys:()=>lNe,partial:()=>j9n,pick:()=>M9n,prefixIssues:()=>VZ,primitiveTypes:()=>Zlt,promiseAllObject:()=>S9n,propertyKeyTypes:()=>iNe,randomString:()=>D9n,required:()=>K9n,stringifyPrimitive:()=>gne,unwrapMessage:()=>eD});function H9n(n){return n}function X9n(n){return n}function k9n(n){}function L9n(n){throw new Error}function J9n(n){}function eNe(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 Gne(n,t="|"){return n.map(r=>gne(r)).join(t)}function tNe(n,t){return typeof t=="bigint"?t.toString():t}function tD(n){return{get value(){{let r=n();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function nD(n){return n==null}function rD(n){let t=n.startsWith("^")?1:0,r=n.endsWith("$")?n.length-1:n.length;return n.slice(t,r)}function nNe(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 wo(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 rNe(n,t,r){Object.defineProperty(n,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function B9n(n,t){return t?t.reduce((r,a)=>r?.[a],n):n}function S9n(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 D9n(n=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<n;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function Iw(n){return JSON.stringify(n)}function K9(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function q9(n){if(K9(n)===!1)return!1;let t=n.constructor;if(t===void 0)return!0;let r=t.prototype;return!(K9(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function T9n(n){let t=0;for(let r in n)Object.prototype.hasOwnProperty.call(n,r)&&t++;return t}function xF(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function og(n,t,r){let a=new n._zod.constr(t??n._zod.def);return(!t||r?.parent)&&(a._zod.parent=n),a}function ga(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 U9n(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 gne(n){return typeof n=="bigint"?n.toString()+"n":typeof n=="string"?`"${n}"`:`${n}`}function lNe(n){return Object.keys(n).filter(t=>n[t]._zod.optin==="optional"&&n[t]._zod.optout==="optional")}function M9n(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 og(n,{...n._zod.def,shape:r,checks:[]})}function z9n(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 og(n,{...n._zod.def,shape:r,checks:[]})}function _9n(n,t){if(!q9(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 rNe(this,"shape",a),a},checks:[]};return og(n,r)}function P9n(n,t){return og(n,{...n._zod.def,get shape(){let r={...n._zod.def.shape,...t._zod.def.shape};return rNe(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function j9n(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 og(t,{...t._zod.def,shape:i,checks:[]})}function K9n(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 og(t,{...t._zod.def,shape:i,checks:[]})}function uw(n,t=0){for(let r=t;r<n.issues.length;r++)if(n.issues[r]?.continue!==!0)return!0;return!1}function VZ(n,t){return t.map(r=>{var a;return(a=r).path??(a.path=[]),r.path.unshift(n),r})}function eD(n){return typeof n=="string"?n:n?.message}function cg(n,t,r){let a={...n,path:n.path??[]};if(!n.message){let i=eD(n.inst?._zod.def?.error?.(n))??eD(t?.error?.(n))??eD(r.customError?.(n))??eD(r.localeError?.(n))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function Wlt(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function aD(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function oNe(...n){let[t,r,a]=n;return typeof t=="string"?{message:t,code:"custom",input:r,inst:a}:{...t}}function q9n(n){return Object.entries(n).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var fne,aNe,O9n,iNe,Zlt,sNe,Nlt,$3e,fW=ut(()=>{fne=Error.captureStackTrace?Error.captureStackTrace:(...n)=>{};aNe=tD(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let n=Function;return new n(""),!0}catch{return!1}});O9n=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}`)}},iNe=new Set(["string","number","symbol"]),Zlt=new Set(["string","number","bigint","boolean","symbol","undefined"]);sNe={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]},Nlt={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};$3e=class{constructor(...t){}}});function INe(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 uNe(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 Alt,vne,cNe,dNe=ut(()=>{j9();fW();Alt=(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,tNe,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},vne=Ln("$ZodError",Alt),cNe=Ln("$ZodError",Alt,{Parent:Error})});var Flt,ylt,hNe,iD,mNe,Zne,pNe=ut(()=>{j9();dNe();fW();Flt=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 GW;if(e.issues.length){let c=new(i?.Err??n)(e.issues.map(u=>cg(u,s,hb())));throw fne(c,i?.callee),c}return e.value},ylt=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=>cg(u,s,hb())));throw fne(c,i?.callee),c}return e.value},hNe=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 GW;return s.issues.length?{success:!1,error:new(n??vne)(s.issues.map(e=>cg(e,i,hb())))}:{success:!0,data:s.value}},iD=hNe(cNe),mNe=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=>cg(e,i,hb())))}:{success:!0,data:s.value}},Zne=mNe(cNe)});function Xlt(){return new RegExp(eHn,"u")}function Mlt(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 zlt(n){return new RegExp(`^${Mlt(n)}$`)}function _lt(n){let t=Mlt({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(`^${Olt}T(?:${a})$`)}var Rlt,Elt,wlt,Ylt,Clt,Vlt,xlt,Qlt,bNe,Hlt,eHn,klt,Llt,Jlt,Blt,Slt,GNe,Dlt,Tlt,Olt,Ult,Plt,jlt,Klt,qlt,$lt,est,tst,nst,Wne=ut(()=>{Rlt=/^[cC][^\s-]{8,}$/,Elt=/^[0-9a-z]+$/,wlt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ylt=/^[0-9a-vA-V]{20}$/,Clt=/^[A-Za-z0-9]{27}$/,Vlt=/^[a-zA-Z0-9_-]{21}$/,xlt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qlt=/^([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})$/,bNe=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)$/,Hlt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,eHn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";klt=/^(?:(?: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])$/,Llt=/^(([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})$/,Jlt=/^((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])$/,Blt=/^(([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])$/,Slt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,GNe=/^[A-Za-z0-9_-]*$/,Dlt=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Tlt=/^\+(?:[0-9]){6,14}[0-9]$/,Olt="(?:(?:\\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])))",Ult=new RegExp(`^${Olt}$`);Plt=n=>{let t=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},jlt=/^\d+n?$/,Klt=/^\d+$/,qlt=/^-?\d+(?:\.\d+)?/i,$lt=/true|false/i,est=/null/i,tst=/^[^A-Z]*$/,nst=/^[^a-z]*$/});var oh,rst,fNe,gNe,ast,ist,lst,sst,ost,lD,cst,Ist,ust,dst,hst,mst,pst,Ane=ut(()=>{j9();Wne();fW();oh=Ln("$ZodCheck",(n,t)=>{var r;n._zod??(n._zod={}),n._zod.def=t,(r=n._zod).onattach??(r.onattach=[])}),rst={number:"number",bigint:"bigint",object:"date"},fNe=Ln("$ZodCheckLessThan",(n,t)=>{oh.init(n,t);let r=rst[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})}}),gNe=Ln("$ZodCheckGreaterThan",(n,t)=>{oh.init(n,t);let r=rst[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})}}),ast=Ln("$ZodCheckMultipleOf",(n,t)=>{oh.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):nNe(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})}}),ist=Ln("$ZodCheckNumberFormat",(n,t)=>{oh.init(n,t),t.format=t.format||"float64";let r=t.format?.includes("int"),a=r?"int":"number",[i,s]=sNe[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=Klt)}),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})}}),lst=Ln("$ZodCheckMaxLength",(n,t)=>{var r;oh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!nD(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=aD(i);a.issues.push({origin:e,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),sst=Ln("$ZodCheckMinLength",(n,t)=>{var r;oh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!nD(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=aD(i);a.issues.push({origin:e,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:n,continue:!t.abort})}}),ost=Ln("$ZodCheckLengthEquals",(n,t)=>{var r;oh.init(n,t),(r=n._zod.def).when??(r.when=a=>{let i=a.value;return!nD(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=aD(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})}}),lD=Ln("$ZodCheckStringFormat",(n,t)=>{var r,a;oh.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=()=>{})}),cst=Ln("$ZodCheckRegex",(n,t)=>{lD.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})}}),Ist=Ln("$ZodCheckLowerCase",(n,t)=>{t.pattern??(t.pattern=tst),lD.init(n,t)}),ust=Ln("$ZodCheckUpperCase",(n,t)=>{t.pattern??(t.pattern=nst),lD.init(n,t)}),dst=Ln("$ZodCheckIncludes",(n,t)=>{oh.init(n,t);let r=xF(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})}}),hst=Ln("$ZodCheckStartsWith",(n,t)=>{oh.init(n,t);let r=new RegExp(`^${xF(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})}}),mst=Ln("$ZodCheckEndsWith",(n,t)=>{oh.init(n,t);let r=new RegExp(`.*${xF(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})}}),pst=Ln("$ZodCheckOverwrite",(n,t)=>{oh.init(n,t),n._zod.check=r=>{r.value=t.tx(r.value)}})});var Fne,vNe=ut(()=>{Fne=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(`
|
|
645
645
|
`).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(`
|
|
646
646
|
`))}}});var Gst,ZNe=ut(()=>{Gst={major:4,minor:0,patch:0}});function Mst(n){if(n==="")return!0;if(n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}function tHn(n){if(!GNe.test(n))return!1;let t=n.replace(/[-_]/g,a=>a==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Mst(r)}function nHn(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 fst(n,t,r){n.issues.length&&t.issues.push(...VZ(r,n.issues)),t.value[r]=n.value}function yne(n,t,r){n.issues.length&&t.issues.push(...VZ(r,n.issues)),t.value[r]=n.value}function gst(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(...VZ(r,n.issues)):n.value===void 0?r in a&&(t.value[r]=void 0):t.value[r]=n.value}function vst(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=>cg(s,a,hb())))}),t}function NNe(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(q9(n)&&q9(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=NNe(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=NNe(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 Zst(n,t,r){if(t.issues.length&&n.issues.push(...t.issues),r.issues.length&&n.issues.push(...r.issues),uw(n))return n;let a=NNe(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 Nst(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}function Wst(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 Ast(n,t,r){return uw(n)?n:t.out._zod.run({value:n.value,issues:n.issues},r)}function Fst(n){return n.value=Object.freeze(n.value),n}function yst(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(oNe(i))}}var Ls,Rne,Mo,Rst,Est,wst,Yst,Cst,Vst,xst,Qst,Hst,Xst,kst,Lst,Jst,Bst,Sst,Dst,Tst,Ost,Ust,zst,_st,Pst,jst,WNe,Kst,qst,$st,eot,tot,not,rot,aot,iot,lot,ANe,sot,oot,cot,Iot,uot,dot,hot,mot,pot,bot,Got,fot,got,vot,Zot,Not=ut(()=>{Ane();j9();vNe();pNe();Wne();fW();ZNe();fW();Ls=Ln("$ZodType",(n,t)=>{var r;n??(n={}),n._zod.def=t,n._zod.bag=n._zod.bag||{},n._zod.version=Gst;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=uw(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 GW;if(d||o instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await o,s.issues.length!==h&&(u||(u=uw(s,h)))});else{if(s.issues.length===h)continue;u||(u=uw(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 GW;return c.then(u=>i(u,a,e))}return i(c,a,e)}}n["~standard"]={validate:i=>{try{let s=iD(n,i);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Zne(n,i).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Rne=Ln("$ZodString",(n,t)=>{Ls.init(n,t),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??Plt(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}}),Mo=Ln("$ZodStringFormat",(n,t)=>{lD.init(n,t),Rne.init(n,t)}),Rst=Ln("$ZodGUID",(n,t)=>{t.pattern??(t.pattern=Qlt),Mo.init(n,t)}),Est=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=bNe(a))}else t.pattern??(t.pattern=bNe());Mo.init(n,t)}),wst=Ln("$ZodEmail",(n,t)=>{t.pattern??(t.pattern=Hlt),Mo.init(n,t)}),Yst=Ln("$ZodURL",(n,t)=>{Mo.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:Dlt.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})}}}),Cst=Ln("$ZodEmoji",(n,t)=>{t.pattern??(t.pattern=Xlt()),Mo.init(n,t)}),Vst=Ln("$ZodNanoID",(n,t)=>{t.pattern??(t.pattern=Vlt),Mo.init(n,t)}),xst=Ln("$ZodCUID",(n,t)=>{t.pattern??(t.pattern=Rlt),Mo.init(n,t)}),Qst=Ln("$ZodCUID2",(n,t)=>{t.pattern??(t.pattern=Elt),Mo.init(n,t)}),Hst=Ln("$ZodULID",(n,t)=>{t.pattern??(t.pattern=wlt),Mo.init(n,t)}),Xst=Ln("$ZodXID",(n,t)=>{t.pattern??(t.pattern=Ylt),Mo.init(n,t)}),kst=Ln("$ZodKSUID",(n,t)=>{t.pattern??(t.pattern=Clt),Mo.init(n,t)}),Lst=Ln("$ZodISODateTime",(n,t)=>{t.pattern??(t.pattern=_lt(t)),Mo.init(n,t)}),Jst=Ln("$ZodISODate",(n,t)=>{t.pattern??(t.pattern=Ult),Mo.init(n,t)}),Bst=Ln("$ZodISOTime",(n,t)=>{t.pattern??(t.pattern=zlt(t)),Mo.init(n,t)}),Sst=Ln("$ZodISODuration",(n,t)=>{t.pattern??(t.pattern=xlt),Mo.init(n,t)}),Dst=Ln("$ZodIPv4",(n,t)=>{t.pattern??(t.pattern=klt),Mo.init(n,t),n._zod.onattach.push(r=>{let a=r._zod.bag;a.format="ipv4"})}),Tst=Ln("$ZodIPv6",(n,t)=>{t.pattern??(t.pattern=Llt),Mo.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})}}}),Ost=Ln("$ZodCIDRv4",(n,t)=>{t.pattern??(t.pattern=Jlt),Mo.init(n,t)}),Ust=Ln("$ZodCIDRv6",(n,t)=>{t.pattern??(t.pattern=Blt),Mo.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})}}});zst=Ln("$ZodBase64",(n,t)=>{t.pattern??(t.pattern=Slt),Mo.init(n,t),n._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),n._zod.check=r=>{Mst(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:n,continue:!t.abort})}});_st=Ln("$ZodBase64URL",(n,t)=>{t.pattern??(t.pattern=GNe),Mo.init(n,t),n._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),n._zod.check=r=>{tHn(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:n,continue:!t.abort})}}),Pst=Ln("$ZodE164",(n,t)=>{t.pattern??(t.pattern=Tlt),Mo.init(n,t)});jst=Ln("$ZodJWT",(n,t)=>{Mo.init(n,t),n._zod.check=r=>{nHn(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:n,continue:!t.abort})}}),WNe=Ln("$ZodNumber",(n,t)=>{Ls.init(n,t),n._zod.pattern=n._zod.bag.pattern??qlt,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}}),Kst=Ln("$ZodNumber",(n,t)=>{ist.init(n,t),WNe.init(n,t)}),qst=Ln("$ZodBoolean",(n,t)=>{Ls.init(n,t),n._zod.pattern=$lt,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}}),$st=Ln("$ZodBigInt",(n,t)=>{Ls.init(n,t),n._zod.pattern=jlt,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}}),eot=Ln("$ZodNull",(n,t)=>{Ls.init(n,t),n._zod.pattern=est,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}}),tot=Ln("$ZodAny",(n,t)=>{Ls.init(n,t),n._zod.parse=r=>r}),not=Ln("$ZodUnknown",(n,t)=>{Ls.init(n,t),n._zod.parse=r=>r}),rot=Ln("$ZodNever",(n,t)=>{Ls.init(n,t),n._zod.parse=(r,a)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:n}),r)}),aot=Ln("$ZodDate",(n,t)=>{Ls.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}});iot=Ln("$ZodArray",(n,t)=>{Ls.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=>fst(d,r,e))):fst(u,r,e)}return s.length?Promise.all(s).then(()=>r):r}});lot=Ln("$ZodObject",(n,t)=>{Ls.init(n,t);let r=tD(()=>{let h=Object.keys(t.shape);for(let v of h)if(!(t.shape[v]instanceof Ls))throw new Error(`Invalid element at key "${v}": expected a Zod schema`);let o=lNe(t.shape);return{shape:t.shape,keys:h,keySet:new Set(h),numKeys:h.length,optionalKeys:new Set(o)}});wo(n._zod,"propValues",()=>{let h=t.shape,o={};for(let v in h){let w=h[v]._zod;if(w.values){o[v]??(o[v]=new Set);for(let R of w.values)o[v].add(R)}}return o});let a=h=>{let o=new Fne(["shape","payload","ctx"]),v=r.value,w=Y=>{let W=Iw(Y);return`shape[${W}]._zod.run({ value: input[${W}], issues: [] }, ctx)`};o.write("const input = payload.value;");let R=Object.create(null),E=0;for(let Y of v.keys)R[Y]=`key_${E++}`;o.write("const newResult = {}");for(let Y of v.keys)if(v.optionalKeys.has(Y)){let W=R[Y];o.write(`const ${W} = ${w(Y)};`);let y=Iw(Y);o.write(`
|
|
647
647
|
if (${W}.issues.length) {
|
|
@@ -1639,7 +1639,7 @@ Each todo object must have:
|
|
|
1639
1639
|
|
|
1640
1640
|
`)}return t.totalFixes===0&&(a=`\u2728 **No fixable lint issues found** ${r.files?"in specified files":"in the workspace"}.
|
|
1641
1641
|
|
|
1642
|
-
All code appears to be in good shape! \u{1F389}`),a.trim()}generateSummary(t,r){if(t.totalFixes===0)return"No fixable lint issues found";if(r.preview){let a=t.previews?.length||0;return`Found ${t.totalFixes} fixable issues across ${a} files (preview mode)`}else{let a=t.results?.reduce((s,e)=>s+e.appliedFixes,0)||0,i=t.results?.reduce((s,e)=>s+e.failedFixes,0)||0;return`Applied ${a} fixes, ${i} failed`}}getDescription(t){let r=t.autoFix?"Apply":"Preview",a=t.files?`${t.files.length} specified files`:"all files",i=t.fixTypes?` (${t.fixTypes.join(", ")})`:"";return`${r} lint fixes for ${a}${i}`}}});function Ovr(n,t,r,a,i){return new VL(n,t,r,a,i)}var VL,bXe=ut(()=>{"use strict";VL=class{outputUpdateHandler;allToolCallsCompleteHandler;toolCallsUpdateHandler;preToolExecutionHandler;preferredEditorGetter;constructor(t,r,a,i,s){this.outputUpdateHandler=t,this.allToolCallsCompleteHandler=r,this.toolCallsUpdateHandler=a,this.preToolExecutionHandler=i,this.preferredEditorGetter=s}onToolStatusChanged(t,r,a,i){}onOutputUpdate(t,r,a){this.outputUpdateHandler?.(t,r)}getPreferredEditor(t){return this.preferredEditorGetter?.()}getStatusUpdateCallback(){}async onPreToolExecution(t,r,a,i){this.preToolExecutionHandler&&await this.preToolExecutionHandler({callId:t,tool:r,args:a})}onAllToolsComplete(t,r){this.allToolCallsCompleteHandler?.(t)}onToolCallsUpdate(t,r){this.toolCallsUpdateHandler?.(t)}}});function d4(n,t,r){return{functionResponse:{id:n,name:t,response:{output:r}}}}function AC(n,t,r){let a=Array.isArray(r)&&r.length===1?r[0]:r;if(typeof a=="string")return d4(t,n,a);if(Array.isArray(a)){if(a.length===0)return[d4(t,n,"Tool execution succeeded."),...a];if(a.every(s=>typeof s=="string")){let s=a.join("");return d4(t,n,s)}else return[d4(t,n,"Tool execution succeeded."),...a]}if(a.functionResponse){if(a.functionResponse.response?.content){let i=aXt(a.functionResponse.response.content)||"";return d4(t,n,i)}return a.functionResponse.id=t,a}if(a.inlineData||a.fileData){let i=a.inlineData?.mimeType||a.fileData?.mimeType||"unknown";return[d4(t,n,`Binary content of type ${i} was processed.`),a]}return a.text!==void 0?d4(t,n,a.text):d4(t,n,"Tool execution succeeded.")}var WC,cue=ut(()=>{"use strict";s_();Jz();Iue();bXe();WC=class{executionEngine;adapter;executionContext;constructor(t){this.executionContext={agentId:"main-agent",agentType:"main"},this.adapter=new VL(t.outputUpdateHandler,t.onAllToolCallsComplete,t.onToolCallsUpdate,t.onPreToolExecution,t.getPreferredEditor),this.executionEngine=new h4({toolRegistry:t.toolRegistry,adapter:this.adapter,config:t.config,hookEventHandler:t.hookEventHandler,approvalMode:t.approvalMode??Ha.DEFAULT,getPreferredEditor:t.getPreferredEditor})}async schedule(t,r){let a=Array.isArray(t)?t:[t];await this.executionEngine.executeTools(a,this.executionContext,r)}async handleConfirmationResponse(t,r,a,i){await this.executionEngine.handleConfirmationResponse(t,r,a,i)}getToolCalls(){return this.executionEngine.getToolCalls()}}});function Jm(n,t){if(t){let r=t.getCloudModelInfo(n);if(r)return r.maxToken}return Uvr.maxToken}var Uvr,o_=ut(()=>{"use strict";Uvr={name:"auto",displayName:"Auto",creditsPerRequest:6,available:!0,maxToken:2e5,highVolumeThreshold:2e5,highVolumeCredits:12}});import A3 from"fs";import BA from"path";var xL,Mvr,GXe=ut(()=>{"use strict";o_();xG();xL=class{maxResponseSize;contextLowThreshold;contextCriticalThreshold;tempDir;enableTempFileStorage;tempFileTTL;tempFiles=new Map;constructor(t={}){if(this.maxResponseSize=t.maxResponseSize??100*1024,this.contextLowThreshold=t.contextLowThreshold??.2,this.contextCriticalThreshold=t.contextCriticalThreshold??.1,this.tempDir=t.tempDir||this.getProjectTempDir(),this.enableTempFileStorage=t.enableTempFileStorage??!0,this.tempFileTTL=t.tempFileTTL??1800*1e3,this.enableTempFileStorage&&!A3.existsSync(this.tempDir))try{A3.mkdirSync(this.tempDir,{recursive:!0}),er.info(`[MCPResponseGuard] Created temp directory: ${this.tempDir}`)}catch(r){er.warn(`[MCPResponseGuard] Failed to create temp directory: ${r}`)}this.startCleanupTask()}getProjectTempDir(){try{let r=process.cwd(),a=0,i=10;for(;a<i;){let s=BA.join(r,".deepvcode");if(A3.existsSync(s))return BA.join(s,"mcp-tmp");let e=BA.dirname(r);if(e===r)break;r=e,a++}}catch{}let t=process.env.HOME||process.env.USERPROFILE||process.env.HOMEPATH;return t?BA.join(t,".deepvcode","mcp-tmp"):process.platform==="win32"?BA.join(process.env.TEMP||process.env.TMP||"C:\\Windows\\Temp","deepvcode-mcp"):BA.join(process.env.TMPDIR||"/tmp","deepvcode-mcp")}async guardResponse(t,r,a="unknown",i=50,s){let e=a||"unknown",c=i??50,u=JSON.stringify(t).length,d=(u/1024).toFixed(2);er.info(`[MCPResponseGuard] Processing response from tool '${e}': ${d}KB, context usage: ${c.toFixed(1)}%`);let I={parts:t,originalSize:u,processedSize:u,wasTruncated:!1,estimatedTokens:0};try{I.estimatedTokens=await this.estimateTokens(t,s,r),er.info(`[MCPResponseGuard] Estimated tokens for response: ${I.estimatedTokens}`)}catch(w){er.warn(`[MCPResponseGuard] Failed to estimate tokens: ${w}`),I.estimatedTokens=Math.ceil(u/4)}let h=100-c,o=Jm(r.getModel(),r),v=Math.floor(h/100*o);return u<=this.maxResponseSize&&I.estimatedTokens<=v*.5?(er.info("[MCPResponseGuard] Response is within safe limits, no processing needed"),I):h<this.contextCriticalThreshold*100?(er.warn(`[MCPResponseGuard] Context CRITICAL (${h.toFixed(1)}% remaining). Applying aggressive truncation.`),await this.handleCriticalContext(t,e,u,v,s,r)):h<this.contextLowThreshold*100?(er.warn(`[MCPResponseGuard] Context low (${h.toFixed(1)}% remaining). Applying moderate truncation.`),await this.handleLowContext(t,e,u,v,s,r)):u>this.maxResponseSize?(er.warn(`[MCPResponseGuard] Response exceeds max size (${d}KB > ${(this.maxResponseSize/1024).toFixed(2)}KB). Using file storage.`),await this.storeAsFile(t,e,u,v,s,r)):I}async handleCriticalContext(t,r,a,i,s,e){return await this.storeAsFile(t,r,a,i,s,e,!0)}async handleLowContext(t,r,a,i,s,e){let c=i*2;return a>c?a>this.maxResponseSize*2?await this.storeAsFile(t,r,a,i,s,e):this.truncateResponse(t,c,"\u4E0A\u4E0B\u6587\u7A7A\u95F4\u4E0D\u8DB3\uFF0C\u54CD\u5E94\u5DF2\u88AB\u622A\u65AD\u3002\u4F7F\u7528\u641C\u7D22\u5DE5\u5177\u4ECE\u6587\u4EF6\u4E2D\u83B7\u53D6\u8BE6\u7EC6\u4FE1\u606F\u3002",a,i):{parts:t,originalSize:a,processedSize:a,wasTruncated:!1,estimatedTokens:Math.ceil(a/2)}}async storeAsFile(t,r,a,i,s,e,c=!1){if(!this.enableTempFileStorage)return this.truncateResponse(t,i*2,"\u54CD\u5E94\u8FC7\u5927\u4E14\u65E0\u6CD5\u5B58\u50A8\u4E3A\u4E34\u65F6\u6587\u4EF6\uFF0C\u5DF2\u88AB\u6FC0\u8FDB\u622A\u65AD\u3002\u5EFA\u8BAE\u4F7F\u7528\u641C\u7D22\u5DE5\u5177\u83B7\u53D6\u7279\u5B9A\u4FE1\u606F\u3002",a,i);try{let u=this.isSingleLineMassiveContent(t),d,I=!1,h=!1,o=Date.now();if(u){let R=this.extractHtmlContent(t);if(R){h=!0;let E=`mcp-response-${r.replace(/[^a-z0-9-]/gi,"_")}-${o}.html`;d=BA.join(this.tempDir,E);let A=this.formatHtml(R);A3.writeFileSync(d,A,"utf-8"),er.info(`[MCPResponseGuard] Stored HTML/DOM content as formatted HTML file: ${d}`)}else{I=!0;let E=`mcp-response-${r.replace(/[^a-z0-9-]/gi,"_")}-${o}.txt`;d=BA.join(this.tempDir,E);let A=this.extractPlainText(t);A3.writeFileSync(d,A,"utf-8"),er.info(`[MCPResponseGuard] Stored single-line massive content as plain text: ${d}`)}}else{let R=`mcp-response-${r.replace(/[^a-z0-9-]/gi,"_")}-${o}.json`;d=BA.join(this.tempDir,R);let E=JSON.stringify(t,null,2);A3.writeFileSync(d,E,"utf-8"),er.info(`[MCPResponseGuard] Stored response as JSON file: ${d}`)}this.tempFiles.set(d,o);let v=this.buildFileGuidanceMessage(d,a,r,c,I,h),w={text:v};return{parts:[w],originalSize:a,processedSize:JSON.stringify([w]).length,wasTruncated:!0,truncationReason:`Response stored as file due to size (${(a/1024).toFixed(2)}KB)`,wasStoredAsFile:!0,guidanceMessage:v,tempFilePath:d,estimatedTokens:await this.estimateTokens([w],s,e).catch(()=>Math.ceil(v.length/4))}}catch(u){return er.error(`[MCPResponseGuard] Failed to store response as file: ${u}`),this.truncateResponse(t,i*2,"\u54CD\u5E94\u8FC7\u5927\u4E14\u6587\u4EF6\u5B58\u50A8\u5931\u8D25\uFF0C\u5DF2\u88AB\u622A\u65AD\u3002",a,i)}}truncateResponse(t,r,a,i,s){let e=this.truncateParts(t,r),c=JSON.stringify(e).length;return{parts:e,originalSize:i,processedSize:c,wasTruncated:!0,truncationReason:a,estimatedTokens:Math.ceil(c/2)}}buildFileGuidanceMessage(t,r,a,i=!1,s=!1,e=!1){let c=(r/1024).toFixed(2),u=i?"\u26A0\uFE0F [CRITICAL]":"\u{1F4CB}",d=e?"HTML":s?"plain text":"JSON",I;return e?I='- Find all div elements: `pattern: "<div[^>]*>"`\n- Find elements with specific class: `pattern: "class=\\"[^\\"]*button[^\\"]*\\""`\n- Find all links: `pattern: "<a\\s+[^>]*href=\\"([^\\"]*)\\""`\n- Find text content inside tags: `pattern: ">([^<]+)</"`\n- Find specific attribute values: `pattern: "data-id=\\"([^\\"]*)\\""`\n- Find style attributes: `pattern: "style=\\"([^\\"]*)\\""`':s?I='- Find all div elements: `pattern: "<div[^>]*>"`\n- Find elements with specific class: `pattern: "class=\\"[^"]*button[^"]*\\""`\n- Find all links: `pattern: "<a\\s+[^>]*href=\\"([^\\"]*)\\""`\n- Find text content: `pattern: ">([^<]+)</"`\n- Find specific attribute: `pattern: "data-id=\\"([^"]*)\\""`':I='- Search for specific filename: `pattern: ".ts$"` or `pattern: "component"`\n- Search for errors: `pattern: "error|Error|ERROR"`\n- Search for specific function: `pattern: "function.*myFunction"`\n- Search for imports: `pattern: "^import|^from"`',`${u} **Large response from ${a} stored as temporary ${d} file**
|
|
1642
|
+
All code appears to be in good shape! \u{1F389}`),a.trim()}generateSummary(t,r){if(t.totalFixes===0)return"No fixable lint issues found";if(r.preview){let a=t.previews?.length||0;return`Found ${t.totalFixes} fixable issues across ${a} files (preview mode)`}else{let a=t.results?.reduce((s,e)=>s+e.appliedFixes,0)||0,i=t.results?.reduce((s,e)=>s+e.failedFixes,0)||0;return`Applied ${a} fixes, ${i} failed`}}getDescription(t){let r=t.autoFix?"Apply":"Preview",a=t.files?`${t.files.length} specified files`:"all files",i=t.fixTypes?` (${t.fixTypes.join(", ")})`:"";return`${r} lint fixes for ${a}${i}`}}});function Ovr(n,t,r,a,i){return new VL(n,t,r,a,i)}var VL,bXe=ut(()=>{"use strict";VL=class{outputUpdateHandler;allToolCallsCompleteHandler;toolCallsUpdateHandler;preToolExecutionHandler;preferredEditorGetter;constructor(t,r,a,i,s){this.outputUpdateHandler=t,this.allToolCallsCompleteHandler=r,this.toolCallsUpdateHandler=a,this.preToolExecutionHandler=i,this.preferredEditorGetter=s}onToolStatusChanged(t,r,a,i){}onOutputUpdate(t,r,a){this.outputUpdateHandler?.(t,r)}getPreferredEditor(t){return this.preferredEditorGetter?.()}getStatusUpdateCallback(){}async onPreToolExecution(t,r,a,i){this.preToolExecutionHandler&&await this.preToolExecutionHandler({callId:t,tool:r,args:a})}onAllToolsComplete(t,r){this.allToolCallsCompleteHandler?.(t)}onToolCallsUpdate(t,r){this.toolCallsUpdateHandler?.(t)}}});function d4(n,t,r){return{functionResponse:{id:n,name:t,response:{output:r}}}}function AC(n,t,r){let a=Array.isArray(r)&&r.length===1?r[0]:r;if(typeof a=="string")return d4(t,n,a);if(Array.isArray(a)){if(a.length===0)return[d4(t,n,"Tool execution succeeded."),...a];if(a.every(s=>typeof s=="string")){let s=a.join("");return d4(t,n,s)}else return[d4(t,n,"Tool execution succeeded."),...a]}if(a.functionResponse){if(a.functionResponse.response?.content){let i=aXt(a.functionResponse.response.content)||"";return d4(t,n,i)}return a.functionResponse.id=t,a}if(a.inlineData||a.fileData){let i=a.inlineData?.mimeType||a.fileData?.mimeType||"unknown";return[d4(t,n,`Binary content of type ${i} was processed.`),a]}return a.text!==void 0?d4(t,n,a.text):d4(t,n,"Tool execution succeeded.")}var WC,cue=ut(()=>{"use strict";s_();Jz();Iue();bXe();WC=class{executionEngine;adapter;executionContext;constructor(t){this.executionContext={agentId:"main-agent",agentType:"main"},this.adapter=new VL(t.outputUpdateHandler,t.onAllToolCallsComplete,t.onToolCallsUpdate,t.onPreToolExecution,t.getPreferredEditor),this.executionEngine=new h4({toolRegistry:t.toolRegistry,adapter:this.adapter,config:t.config,hookEventHandler:t.hookEventHandler,approvalMode:t.approvalMode??Ha.DEFAULT,getPreferredEditor:t.getPreferredEditor})}async schedule(t,r){let a=Array.isArray(t)?t:[t];await this.executionEngine.executeTools(a,this.executionContext,r)}async handleConfirmationResponse(t,r,a,i){await this.executionEngine.handleConfirmationResponse(t,r,a,i)}getToolCalls(){return this.executionEngine.getToolCalls()}reset(){this.executionEngine.reset()}}});function Jm(n,t){if(t){let r=t.getCloudModelInfo(n);if(r)return r.maxToken}return Uvr.maxToken}var Uvr,o_=ut(()=>{"use strict";Uvr={name:"auto",displayName:"Auto",creditsPerRequest:6,available:!0,maxToken:2e5,highVolumeThreshold:2e5,highVolumeCredits:12}});import A3 from"fs";import BA from"path";var xL,Mvr,GXe=ut(()=>{"use strict";o_();xG();xL=class{maxResponseSize;contextLowThreshold;contextCriticalThreshold;tempDir;enableTempFileStorage;tempFileTTL;tempFiles=new Map;constructor(t={}){if(this.maxResponseSize=t.maxResponseSize??100*1024,this.contextLowThreshold=t.contextLowThreshold??.2,this.contextCriticalThreshold=t.contextCriticalThreshold??.1,this.tempDir=t.tempDir||this.getProjectTempDir(),this.enableTempFileStorage=t.enableTempFileStorage??!0,this.tempFileTTL=t.tempFileTTL??1800*1e3,this.enableTempFileStorage&&!A3.existsSync(this.tempDir))try{A3.mkdirSync(this.tempDir,{recursive:!0}),er.info(`[MCPResponseGuard] Created temp directory: ${this.tempDir}`)}catch(r){er.warn(`[MCPResponseGuard] Failed to create temp directory: ${r}`)}this.startCleanupTask()}getProjectTempDir(){try{let r=process.cwd(),a=0,i=10;for(;a<i;){let s=BA.join(r,".deepvcode");if(A3.existsSync(s))return BA.join(s,"mcp-tmp");let e=BA.dirname(r);if(e===r)break;r=e,a++}}catch{}let t=process.env.HOME||process.env.USERPROFILE||process.env.HOMEPATH;return t?BA.join(t,".deepvcode","mcp-tmp"):process.platform==="win32"?BA.join(process.env.TEMP||process.env.TMP||"C:\\Windows\\Temp","deepvcode-mcp"):BA.join(process.env.TMPDIR||"/tmp","deepvcode-mcp")}async guardResponse(t,r,a="unknown",i=50,s){let e=a||"unknown",c=i??50,u=JSON.stringify(t).length,d=(u/1024).toFixed(2);er.info(`[MCPResponseGuard] Processing response from tool '${e}': ${d}KB, context usage: ${c.toFixed(1)}%`);let I={parts:t,originalSize:u,processedSize:u,wasTruncated:!1,estimatedTokens:0};try{I.estimatedTokens=await this.estimateTokens(t,s,r),er.info(`[MCPResponseGuard] Estimated tokens for response: ${I.estimatedTokens}`)}catch(w){er.warn(`[MCPResponseGuard] Failed to estimate tokens: ${w}`),I.estimatedTokens=Math.ceil(u/4)}let h=100-c,o=Jm(r.getModel(),r),v=Math.floor(h/100*o);return u<=this.maxResponseSize&&I.estimatedTokens<=v*.5?(er.info("[MCPResponseGuard] Response is within safe limits, no processing needed"),I):h<this.contextCriticalThreshold*100?(er.warn(`[MCPResponseGuard] Context CRITICAL (${h.toFixed(1)}% remaining). Applying aggressive truncation.`),await this.handleCriticalContext(t,e,u,v,s,r)):h<this.contextLowThreshold*100?(er.warn(`[MCPResponseGuard] Context low (${h.toFixed(1)}% remaining). Applying moderate truncation.`),await this.handleLowContext(t,e,u,v,s,r)):u>this.maxResponseSize?(er.warn(`[MCPResponseGuard] Response exceeds max size (${d}KB > ${(this.maxResponseSize/1024).toFixed(2)}KB). Using file storage.`),await this.storeAsFile(t,e,u,v,s,r)):I}async handleCriticalContext(t,r,a,i,s,e){return await this.storeAsFile(t,r,a,i,s,e,!0)}async handleLowContext(t,r,a,i,s,e){let c=i*2;return a>c?a>this.maxResponseSize*2?await this.storeAsFile(t,r,a,i,s,e):this.truncateResponse(t,c,"\u4E0A\u4E0B\u6587\u7A7A\u95F4\u4E0D\u8DB3\uFF0C\u54CD\u5E94\u5DF2\u88AB\u622A\u65AD\u3002\u4F7F\u7528\u641C\u7D22\u5DE5\u5177\u4ECE\u6587\u4EF6\u4E2D\u83B7\u53D6\u8BE6\u7EC6\u4FE1\u606F\u3002",a,i):{parts:t,originalSize:a,processedSize:a,wasTruncated:!1,estimatedTokens:Math.ceil(a/2)}}async storeAsFile(t,r,a,i,s,e,c=!1){if(!this.enableTempFileStorage)return this.truncateResponse(t,i*2,"\u54CD\u5E94\u8FC7\u5927\u4E14\u65E0\u6CD5\u5B58\u50A8\u4E3A\u4E34\u65F6\u6587\u4EF6\uFF0C\u5DF2\u88AB\u6FC0\u8FDB\u622A\u65AD\u3002\u5EFA\u8BAE\u4F7F\u7528\u641C\u7D22\u5DE5\u5177\u83B7\u53D6\u7279\u5B9A\u4FE1\u606F\u3002",a,i);try{let u=this.isSingleLineMassiveContent(t),d,I=!1,h=!1,o=Date.now();if(u){let R=this.extractHtmlContent(t);if(R){h=!0;let E=`mcp-response-${r.replace(/[^a-z0-9-]/gi,"_")}-${o}.html`;d=BA.join(this.tempDir,E);let A=this.formatHtml(R);A3.writeFileSync(d,A,"utf-8"),er.info(`[MCPResponseGuard] Stored HTML/DOM content as formatted HTML file: ${d}`)}else{I=!0;let E=`mcp-response-${r.replace(/[^a-z0-9-]/gi,"_")}-${o}.txt`;d=BA.join(this.tempDir,E);let A=this.extractPlainText(t);A3.writeFileSync(d,A,"utf-8"),er.info(`[MCPResponseGuard] Stored single-line massive content as plain text: ${d}`)}}else{let R=`mcp-response-${r.replace(/[^a-z0-9-]/gi,"_")}-${o}.json`;d=BA.join(this.tempDir,R);let E=JSON.stringify(t,null,2);A3.writeFileSync(d,E,"utf-8"),er.info(`[MCPResponseGuard] Stored response as JSON file: ${d}`)}this.tempFiles.set(d,o);let v=this.buildFileGuidanceMessage(d,a,r,c,I,h),w={text:v};return{parts:[w],originalSize:a,processedSize:JSON.stringify([w]).length,wasTruncated:!0,truncationReason:`Response stored as file due to size (${(a/1024).toFixed(2)}KB)`,wasStoredAsFile:!0,guidanceMessage:v,tempFilePath:d,estimatedTokens:await this.estimateTokens([w],s,e).catch(()=>Math.ceil(v.length/4))}}catch(u){return er.error(`[MCPResponseGuard] Failed to store response as file: ${u}`),this.truncateResponse(t,i*2,"\u54CD\u5E94\u8FC7\u5927\u4E14\u6587\u4EF6\u5B58\u50A8\u5931\u8D25\uFF0C\u5DF2\u88AB\u622A\u65AD\u3002",a,i)}}truncateResponse(t,r,a,i,s){let e=this.truncateParts(t,r),c=JSON.stringify(e).length;return{parts:e,originalSize:i,processedSize:c,wasTruncated:!0,truncationReason:a,estimatedTokens:Math.ceil(c/2)}}buildFileGuidanceMessage(t,r,a,i=!1,s=!1,e=!1){let c=(r/1024).toFixed(2),u=i?"\u26A0\uFE0F [CRITICAL]":"\u{1F4CB}",d=e?"HTML":s?"plain text":"JSON",I;return e?I='- Find all div elements: `pattern: "<div[^>]*>"`\n- Find elements with specific class: `pattern: "class=\\"[^\\"]*button[^\\"]*\\""`\n- Find all links: `pattern: "<a\\s+[^>]*href=\\"([^\\"]*)\\""`\n- Find text content inside tags: `pattern: ">([^<]+)</"`\n- Find specific attribute values: `pattern: "data-id=\\"([^\\"]*)\\""`\n- Find style attributes: `pattern: "style=\\"([^\\"]*)\\""`':s?I='- Find all div elements: `pattern: "<div[^>]*>"`\n- Find elements with specific class: `pattern: "class=\\"[^"]*button[^"]*\\""`\n- Find all links: `pattern: "<a\\s+[^>]*href=\\"([^\\"]*)\\""`\n- Find text content: `pattern: ">([^<]+)</"`\n- Find specific attribute: `pattern: "data-id=\\"([^"]*)\\""`':I='- Search for specific filename: `pattern: ".ts$"` or `pattern: "component"`\n- Search for errors: `pattern: "error|Error|ERROR"`\n- Search for specific function: `pattern: "function.*myFunction"`\n- Search for imports: `pattern: "^import|^from"`',`${u} **Large response from ${a} stored as temporary ${d} file**
|
|
1643
1643
|
|
|
1644
1644
|
**File location:** \`${t}\`
|
|
1645
1645
|
**Original size:** ${c}KB (too large to include directly due to context limitations)
|
|
@@ -1699,7 +1699,7 @@ read_file(
|
|
|
1699
1699
|
`),e=0,c=[];for(let u of s){let d=u.trim();if(!d)continue;d.startsWith("</")&&(e=Math.max(0,e-1));let I=" ".repeat(e)+d;c.push(I),d.startsWith("<")&&!d.startsWith("</")&&!d.endsWith("/>")&&(d.includes(`</${d.match(/<(\w+)/)?.[1]}>`)||d.endsWith("/>")||e++)}return c.join(`
|
|
1700
1700
|
`)}extractPlainText(t){if(!t||t.length===0)return"";let r=[];for(let a of t)if(a.text)r.push(a.text);else if(a.functionResponse?.response?.content){let i=a.functionResponse.response.content;if(Array.isArray(i))for(let s of i)typeof s=="string"?r.push(s):s&&typeof s=="object"&&"text"in s&&r.push(s.text)}return r.join(`
|
|
1701
1701
|
`)}truncateParts(t,r){let a=0,i=[];for(let s of t){let e=JSON.stringify(s).length;if(a+e<=r)i.push(s),a+=e;else if(a<r){if(s.text){let c=r-a,u=s.text.substring(0,Math.max(50,c-20));i.push({text:u+`
|
|
1702
|
-
... [TRUNCATED - use search_file_content to find specific information]`})}break}else break}return i.length===0&&t.length>0&&i.push({text:"... [Response too large, use search tools to find specific information]"}),i}async estimateTokens(t,r,a){if(r)try{return(await r.countTokens({model:a.getModel(),contents:[{role:"user",parts:t}]})).totalTokens||0}catch(s){er.warn(`[MCPResponseGuard] Token estimation failed: ${s}`)}let i=JSON.stringify(t).length;return Math.ceil(i/4)}startCleanupTask(){setInterval(()=>{this.cleanupExpiredTempFiles()},300*1e3)}cleanupExpiredTempFiles(){let t=Date.now(),r=[];for(let[a,i]of this.tempFiles.entries())t-i>this.tempFileTTL&&r.push(a);for(let a of r)try{A3.existsSync(a)&&(A3.unlinkSync(a),er.info(`[MCPResponseGuard] Cleaned up expired temp file: ${a}`)),this.tempFiles.delete(a)}catch(i){er.warn(`[MCPResponseGuard] Failed to delete temp file ${a}: ${i}`)}}async cleanup(){for(let t of this.tempFiles.keys())try{A3.existsSync(t)&&A3.unlinkSync(t)}catch(r){er.warn(`[MCPResponseGuard] Failed to cleanup temp file ${t}: ${r}`)}this.tempFiles.clear()}getTempFiles(){return Array.from(this.tempFiles.keys())}},Mvr=new xL});import{execSync as S6t,spawn as zvr}from"child_process";function D6t(n){return["vscode","vscodium","windsurf","cursor","vim","neovim","zed"].includes(n)}function T6t(n){try{return S6t(process.platform==="win32"?`where.exe ${n}`:`command -v ${n}`,{stdio:"ignore"}),!0}catch{return!1}}function QL(n){let t=O6t[n];return(process.platform==="win32"?t.win32:t.default).some(a=>T6t(a))}function HL(n){let t=!process.env.SANDBOX;return["vscode","vscodium","windsurf","cursor","zed"].includes(n)?t:!0}function c_(n){return n&&D6t(n)?QL(n)&&HL(n):!1}function U6t(n,t,r){if(!D6t(r))return null;let a=O6t[r],i=process.platform==="win32"?a.win32:a.default,s=i.slice(0,-1).find(e=>T6t(e))||i[i.length-1];switch(r){case"vscode":case"vscodium":case"windsurf":case"cursor":case"zed":return{command:s,args:["--wait","--diff",n,t]};case"vim":case"neovim":return{command:s,args:["-d","-i","NONE","-c","wincmd h | set readonly | wincmd l","-c","highlight DiffAdd cterm=bold ctermbg=22 guibg=#005f00 | highlight DiffChange cterm=bold ctermbg=24 guibg=#005f87 | highlight DiffText ctermbg=21 guibg=#0000af | highlight DiffDelete ctermbg=52 guibg=#5f0000","-c","set showtabline=2 | set tabline=[Instructions]\\ :wqa(save\\ &\\ quit)\\ \\|\\ i/esc(toggle\\ edit\\ mode)","-c","wincmd h | setlocal statusline=OLD\\ FILE","-c","wincmd l | setlocal statusline=%#StatusBold#NEW\\ FILE\\ :wqa(save\\ &\\ quit)\\ \\|\\ i/esc(toggle\\ edit\\ mode)","-c","autocmd WinClosed * wqa",n,t]};default:return null}}async function fXe(n,t,r){let a=U6t(n,t,r);if(!a){console.error("No diff tool available. Install a supported editor.");return}try{switch(r){case"vscode":case"vscodium":case"windsurf":case"cursor":case"zed":return new Promise((i,s)=>{let e=zvr(a.command,a.args,{stdio:"inherit",shell:!0});e.on("close",c=>{c===0?i():s(new Error(`${r} exited with code ${c}`))}),e.on("error",c=>{s(c)})});case"vim":case"neovim":{let i=process.platform==="win32"?`${a.command} ${a.args.join(" ")}`:`${a.command} ${a.args.map(s=>`"${s}"`).join(" ")}`;S6t(i,{stdio:"inherit",encoding:"utf8"});break}default:throw new Error(`Unsupported editor: ${r}`)}}catch(i){console.error(i)}}var O6t,gXe=ut(()=>{"use strict";O6t={vscode:{win32:["code.cmd"],default:["code"]},vscodium:{win32:["codium.cmd"],default:["codium"]},windsurf:{win32:["windsurf"],default:["windsurf"]},cursor:{win32:["cursor"],default:["cursor"]},vim:{win32:["vim"],default:["vim"]},neovim:{win32:["nvim"],default:["nvim"]},zed:{win32:["zed"],default:["zed","zeditor"]}}});import _vr from"os";import XL from"path";import m4 from"fs";function M6t(n){return"getModifyContext"in n}function Pvr(n,t,r){let a=_vr.tmpdir(),i=XL.join(a,"gemini-cli-tool-modify-diffs");m4.existsSync(i)||m4.mkdirSync(i,{recursive:!0});let s=XL.extname(r),e=XL.basename(r,s),c=Date.now(),u=XL.join(i,`gemini-cli-modify-${e}-old-${c}${s}`),d=XL.join(i,`gemini-cli-modify-${e}-new-${c}${s}`);return m4.writeFileSync(u,n,"utf8"),m4.writeFileSync(d,t,"utf8"),{oldPath:u,newPath:d}}function jvr(n,t,r,a){let i="",s="";try{i=m4.readFileSync(n,"utf8")}catch(u){if(!Xs(u)||u.code!=="ENOENT")throw u;i=""}try{s=m4.readFileSync(t,"utf8")}catch(u){if(!Xs(u)||u.code!=="ENOENT")throw u;s=""}let e=a.createUpdatedParams(i,s,r),c=G3(XL.basename(a.getFilePath(r)),i,s,"Current","Proposed",f3);return{updatedParams:e,updatedDiff:c}}function Kvr(n,t){try{m4.unlinkSync(n)}catch{console.error(`Error deleting temp diff file: ${n}`)}try{m4.unlinkSync(t)}catch{console.error(`Error deleting temp diff file: ${t}`)}}async function z6t(n,t,r,a){let i=await t.getCurrentContent(n),s=await t.getProposedContent(n),{oldPath:e,newPath:c}=Pvr(i,s,t.getFilePath(n));try{return await fXe(e,c,r),jvr(e,c,n,t)}finally{Kvr(e,c)}}var _6t=ut(()=>{"use strict";gXe();Az();yz();Ro();});import*as P6t from"path";function qvr(){return I_||(I_=new kL),I_}function $vr(){I_?.clear(),I_=null}var kL,I_,vXe=ut(()=>{"use strict";kL=class{fileQueues=new Map;normalizePath(t){let r=P6t.normalize(t);return process.platform==="win32"?r.toLowerCase():r}async enqueue(t,r){let a=this.normalizePath(t),i=this.fileQueues.get(a)??Promise.resolve(),s,e,c=new Promise((d,I)=>{s=d,e=I}),u=i.catch(()=>{}).then(async()=>{try{let d=await r();return s(),d}catch(d){throw e(d),d}});return this.fileQueues.set(a,c.catch(()=>{})),u}async enqueueMultiple(t,r){if(t.length===0)return r();if(t.length===1)return this.enqueue(t[0],r);let a=[...t].map(c=>this.normalizePath(c)).sort(),i=a.map(c=>this.fileQueues.get(c)??Promise.resolve());await Promise.all(i.map(c=>c.catch(()=>{})));let s,e=new Promise(c=>{s=c});for(let c of a)this.fileQueues.set(c,e.catch(()=>{}));try{let c=await r();return s(),c}catch(c){throw s(),c}}clear(){this.fileQueues.clear()}get size(){return this.fileQueues.size}},I_=null});var uue,h4,Iue=ut(()=>{"use strict";s_();cue();GXe();_6t();vXe();uue=(n,t)=>({callId:n.callId,error:t,responseParts:{functionResponse:{id:n.callId,name:n.name,response:{error:t.message}}},resultDisplay:t.message}),h4=class{toolCalls=[];toolRegistry;adapter;approvalMode;config;getPreferredEditor;hookEventHandler;mcpResponseGuard;fileOperationQueue;completionResolvers=[];constructor(t){this.config=t.config,this.toolRegistry=t.toolRegistry,this.adapter=t.adapter,this.hookEventHandler=t.hookEventHandler,this.approvalMode=t.approvalMode??Ha.DEFAULT,this.getPreferredEditor=t.getPreferredEditor,this.mcpResponseGuard=new xL({maxResponseSize:100*1024,contextLowThreshold:.2,contextCriticalThreshold:.1}),this.fileOperationQueue=new kL}getToolCalls(){return[...this.toolCalls]}getConfirmationPriority(t){return t.agentContext.agentType==="sub"?1:2}getActiveConfirmation(){let t=this.toolCalls.filter(r=>r.status==="awaiting_approval");return t.length===0?null:t.sort((r,a)=>this.getConfirmationPriority(r)-this.getConfirmationPriority(a))[0]}createStatusUpdateCallback(t,r){return(a,i)=>{let s=this.toolCalls.findIndex(e=>e.request.callId===r);s>=0&&(this.toolCalls[s]={...this.toolCalls[s],subToolCalls:a.map(e=>({...e,agentContext:{...e.agentContext,parentAgentId:r}}))},this.adapter.onToolCallsUpdate([...this.toolCalls],t))}}isRunning(){return this.toolCalls.some(t=>t.status==="executing"||t.status==="awaiting_approval")}setStatusInternal(t,r,a,i){let s=this.toolCalls.find(u=>u.request.callId===t);if(!s){console.warn(`setStatusInternal: Cannot find tool call with ID ${t}`);return}let e;switch(r){case"success":e={...s,status:"success",response:a,durationMs:s.startTime?Date.now()-s.startTime:void 0};break;case"error":e={...s,status:"error",response:a,durationMs:s.startTime?Date.now()-s.startTime:void 0};break;case"awaiting_approval":e={...s,status:"awaiting_approval",confirmationDetails:a};break;case"cancelled":let u=a;e={...s,status:"cancelled",response:uue(s.request,new Error(u)),durationMs:s.startTime?Date.now()-s.startTime:void 0};break;default:e={...s,status:r};break}this.toolCalls=this.toolCalls.map(u=>u.request.callId===t?e:u);let c=i||{agentId:"unknown",agentType:"main"};this.adapter.onToolStatusChanged(t,r,e,c),this.adapter.onToolCallsUpdate([...this.toolCalls],c),this.checkAndNotifyCompletion(c)}checkAndNotifyCompletion(t){let r=this.toolCalls.every(a=>a.status==="success"||a.status==="error"||a.status==="cancelled");if(this.toolCalls.length>0&&r){let a=[...this.toolCalls],i=[...this.completionResolvers];this.completionResolvers=[];for(let s of a)av(this.config,new LL(s));this.adapter.onAllToolsComplete(a,t),i.forEach(s=>{s(a)}),this.toolCalls=[],this.adapter.onToolCallsUpdate([...this.toolCalls],t)}}async executeTools(t,r,a){if(this.isRunning())throw new Error("Cannot schedule new tool calls while other tool calls are actively running (executing or awaiting approval).");let i=await this.toolRegistry,s=t.map(c=>{let u=i.getTool(c.name),d={agentId:r.agentId,agentType:r.agentType,parentAgentId:r.agentType==="sub"?"main-agent":void 0,taskDescription:r.taskDescription};if(!u){let I=i.getAllTools().map(o=>o.name).join(", "),h=`Tool "${c.name}" not found in registry. Available tools: ${I}`;return{status:"error",request:c,response:uue(c,new Error(h)),durationMs:0,agentContext:d}}return{status:"validating",request:c,tool:u,startTime:Date.now(),agentContext:d}});this.toolCalls=this.toolCalls.concat(s),this.adapter.onToolCallsUpdate([...this.toolCalls],r);for(let c of s){if(c.status!=="validating")continue;let{request:u,tool:d}=c;try{if(this.config.getApprovalMode()===Ha.YOLO)this.setStatusInternal(u.callId,"scheduled",void 0,r);else{let I=await d.shouldConfirmExecute(u.args,a);if(!I)this.setStatusInternal(u.callId,"scheduled",void 0,r);else{let h=I.onConfirm,o={...I,originalOnConfirm:h,onConfirm:(v,w)=>this.handleConfirmationResponse(u.callId,v,w,a)};this.setStatusInternal(u.callId,"awaiting_approval",o,r)}}}catch(I){this.setStatusInternal(u.callId,"error",uue(u,I instanceof Error?I:new Error(String(I))),r)}}if(s.length===0)return[];let e=new Promise(c=>{this.completionResolvers.push(c)});return await this.attemptExecutionOfScheduledCalls(a,r),this.checkAndNotifyCompletion(r),e}async handleConfirmationResponse(t,r,a,i){let s=this.toolCalls.find(d=>d.request.callId===t&&d.status==="awaiting_approval");if(!s||s.status!=="awaiting_approval")return;let e=s,c=e.confirmationDetails;c.originalOnConfirm?await c.originalOnConfirm(r,a):await e.confirmationDetails.onConfirm(r,a),this.toolCalls=this.toolCalls.map(d=>d.request.callId!==t?d:{...d,outcome:r});let u={agentId:"main",agentType:"main"};if(r===Xr.Cancel||i?.aborted)this.setStatusInternal(t,"cancelled","User cancelled",u);else if(r===Xr.ProceedAlwaysProject)this.config.setApprovalModeWithProjectSync(Ha.YOLO,!0),this.setStatusInternal(t,"scheduled",void 0,u),await this.attemptExecutionOfScheduledCalls(i||new AbortController().signal,u);else if(r===Xr.ModifyWithEditor){if(M6t(e.tool)){let d=e.tool.getModifyContext(i||new AbortController().signal),I=this.getPreferredEditor();if(!I)return;this.setStatusInternal(t,"awaiting_approval",{...e.confirmationDetails,isModifying:!0},u);let{updatedParams:h}=await z6t(e.request.args,d,I,i||new AbortController().signal);this.toolCalls=this.toolCalls.map(o=>o.request.callId!==t?o:{...o,request:{...o.request,args:h}}),this.setStatusInternal(t,"scheduled",void 0,u),await this.attemptExecutionOfScheduledCalls(i||new AbortController().signal,u)}}else this.setStatusInternal(t,"scheduled",void 0,u),await this.attemptExecutionOfScheduledCalls(i||new AbortController().signal,u)}getToolFilePaths(t,r){try{return t.toolLocations(r).filter(i=>i.path).map(i=>i.path)}catch{return[]}}async executeSingleToolCall(t,r,a){let{request:i,tool:s}=t;try{this.setStatusInternal(i.callId,"executing",void 0,a);let e={getExecutionContext:()=>({agentId:a.agentId,agentType:a.agentType,taskDescription:a.taskDescription}),statusUpdateCallback:this.createStatusUpdateCallback(a,i.callId),onPreToolExecution:async o=>{await this.adapter.onPreToolExecution(o.callId,o.tool,o.args,a)}};if(this.hookEventHandler)try{await this.hookEventHandler.fireBeforeToolEvent(i.name,i.args)}catch(o){console.warn(`[ToolExecutionEngine] BeforeTool hook execution failed: ${o}`)}let c=await s.execute(i.args,r,o=>{this.adapter.onOutputUpdate(i.callId,o,a),this.toolCalls=this.toolCalls.map(v=>{if(v.request.callId===i.callId){let w=o;if(v.request.name==="task")try{w=JSON.parse(o)}catch{w=o}return{...v,liveOutput:w}}return v})},e);if(r.aborted){this.setStatusInternal(i.callId,"cancelled","User cancelled tool execution.");return}let u=c.llmContent||"",d="";try{if(Array.isArray(c.llmContent)&&c.llmContent.length>0&&typeof c.llmContent[0]=="object"&&c.llmContent[0]!==null&&!Array.isArray(c.llmContent[0])&&typeof c.llmContent[0]!="string"){let v=await this.mcpResponseGuard.guardResponse(c.llmContent,this.config,i.name,50);u=v.parts,v.wasTruncated?(d=`[GUARD] ${v.truncationReason||"\u65E0\u539F\u56E0"} | \u539F\u59CB: ${(v.originalSize/1024).toFixed(2)}KB -> ${(v.processedSize/1024).toFixed(2)}KB`,v.wasStoredAsFile&&(d+=` | \u5DF2\u5B58\u50A8\u4E3A: ${v.tempFilePath}`)):d=`[GUARD] \u54CD\u5E94\u5B89\u5168 | \u5927\u5C0F: ${(v.originalSize/1024).toFixed(2)}KB`,console.log(`[ToolExecutionEngine] ${d}`)}}catch(o){console.warn(`[ToolExecutionEngine] MCP\u54CD\u5E94\u4FDD\u62A4\u5931\u8D25: ${o}`),u=c.llmContent||""}let I=AC(i.name,i.callId,u),h={callId:i.callId,responseParts:I,resultDisplay:c.returnDisplay,error:void 0};if(this.setStatusInternal(i.callId,"success",h,a),this.hookEventHandler)try{let o=typeof c.llmContent=="string"?{content:c.llmContent}:{content:c.llmContent||{}};await this.hookEventHandler.fireAfterToolEvent(i.name,i.args,o)}catch(o){console.warn(`[ToolExecutionEngine] AfterTool hook execution failed: ${o}`)}}catch(e){let c=uue(i,e instanceof Error?e:new Error(String(e)));if(this.setStatusInternal(i.callId,"error",c,a),this.hookEventHandler)try{await this.hookEventHandler.fireAfterToolEvent(i.name,i.args,{error:c.error?.message||"Unknown error"})}catch(u){console.warn(`[ToolExecutionEngine] AfterTool hook execution failed: ${u}`)}}}async attemptExecutionOfScheduledCalls(t,r){let a=this.toolCalls.filter(s=>s.status==="scheduled");if(a.length===0)return;for(let s of a)await this.adapter.onPreToolExecution(s.request.callId,s.tool,s.request.args,r);let i=a.map(async s=>{let{tool:e,request:c}=s,u=this.getToolFilePaths(e,c.args);return u.length===0?this.executeSingleToolCall(s,t,r):u.length===1?this.fileOperationQueue.enqueue(u[0],()=>this.executeSingleToolCall(s,t,r)):this.fileOperationQueue.enqueueMultiple(u,()=>this.executeSingleToolCall(s,t,r))});await Promise.all(i)}}});function eZr(n,t,r){return new JL(n,t,r)}var JL,ZXe=ut(()=>{"use strict";JL=class{updateOutput;logCallback;toolCompletionHandler;toolRegistry;externalPreToolExecutionHandler;executionLog=[];filesCreated=[];commandsRun=[];statusUpdateCallback;constructor(t,r,a,i,s){this.updateOutput=t,this.logCallback=r,this.toolCompletionHandler=a,this.toolRegistry=i,this.externalPreToolExecutionHandler=s}setStatusUpdateCallback(t){this.statusUpdateCallback=t}getStatusUpdateCallback(){return this.statusUpdateCallback}onToolStatusChanged(t,r,a,i){this.statusUpdateCallback?.([a],i);let s=this.createDetailedToolInfo(t,r,a),e=`TOOL_CALL_UPDATE:${JSON.stringify(s)}`;if(this.log(`\u5DE5\u5177 ${a.request.name}: ${r}`),this.updateOutput?.(e),r==="success"){if(a.request.name==="write_file"||a.request.name==="edit_file"){let c=a.request.args?.file_path||a.request.args?.path;c&&typeof c=="string"&&this.filesCreated.push(c)}else if(a.request.name==="shell"){let c=a.request.args?.command;c&&typeof c=="string"&&this.commandsRun.push(c)}}}createDetailedToolInfo(t,r,a){let s={validating:"Pending",scheduled:"Pending",awaiting_approval:"Confirming",executing:"Executing",success:"Success",error:"Error",cancelled:"Canceled"}[r]||"Pending",c=this.formatToolArgs(a.request.name,a.request.args)||"",u={callId:t,toolName:a.request.name,description:c,status:s,startTime:a.startTime};if(r==="success"&&a.response){let d=a.response;u.result=typeof d.resultDisplay=="string"?d.resultDisplay:"\u6267\u884C\u6210\u529F",u.startTime&&(u.durationMs=Date.now()-u.startTime)}else r==="error"&&a.response?.error&&(u.error=a.response.error.message||"\u6267\u884C\u5931\u8D25",u.startTime&&(u.durationMs=Date.now()-u.startTime));return u}formatToolArgs(t,r){if(this.toolRegistry)try{let s=this.toolRegistry.getTool(t);if(s&&s.getDescription){let e=s.getDescription(r);if(e&&e.length>0){let c=e.match(/\((.*)\)$/);return c?c[1]:e.replace(new RegExp(`^${t}\\s*`,"i"),"").trim()}}}catch(s){console.warn(`Failed to get description for tool ${t}:`,s)}let a=["file_path","path","absolute_path","command","content","query","pattern","prompt","description"],i=[];for(let s of a)if(r[s]&&typeof r[s]=="string"){let e=r[s];e.length>50?i.push(`${e.substring(0,50)}...`):i.push(e)}return i.join(", ")}onOutputUpdate(t,r,a){this.log(`[${t}] ${r}`);let i={callId:t,output:r,timestamp:Date.now()},s=`TOOL_OUTPUT_UPDATE:${JSON.stringify(i)}`;this.updateOutput?.(s)}getPreferredEditor(t){}async onPreToolExecution(t,r,a,i){if(this.externalPreToolExecutionHandler)try{await this.externalPreToolExecutionHandler({callId:t,tool:r,args:a})}catch(c){console.warn("[SubAgent] Failed to execute external pre-tool handler:",c)}this.log(`\u51C6\u5907\u6267\u884C\u5DE5\u5177: ${r.displayName||r.name}`);let s={type:"tool_preparation",callId:t,toolName:r.name,toolDisplayName:r.displayName||r.name,args:this.sanitizeArgs(a),agentId:i.agentId,taskDescription:i.taskDescription,timestamp:Date.now()},e=`SUBAGENT_EVENT:${JSON.stringify(s)}`;this.updateOutput?.(e)}sanitizeArgs(t){let r={};for(let[a,i]of Object.entries(t))typeof i=="string"||typeof i=="number"||typeof i=="boolean"?typeof i=="string"&&i.length>200?r[a]=i.substring(0,200)+"...":r[a]=i:i==null?r[a]=i:r[a]="[\u590D\u6742\u5BF9\u8C61]";return r}onAllToolsComplete(t,r){let a=t.filter(u=>u.status==="success").length,i=t.filter(u=>u.status==="error").length,s=t.filter(u=>u.status==="cancelled").length;this.log(`\u5DE5\u5177\u6279\u6B21\u6267\u884C\u5B8C\u6210: ${a} \u6210\u529F, ${i} \u5931\u8D25, ${s} \u53D6\u6D88`);let e={type:"tools_batch_complete",agentId:r.agentId,statistics:{total:t.length,success:a,error:i,cancelled:s},filesCreated:[...this.filesCreated],commandsRun:[...this.commandsRun],completedCalls:t.map(u=>({callId:u.request.callId,toolName:u.request.name,status:u.status,durationMs:u.durationMs})),timestamp:Date.now()},c=`SUBAGENT_EVENT:${JSON.stringify(e)}`;this.updateOutput?.(c),this.toolCompletionHandler&&this.toolCompletionHandler(t)}onToolCallsUpdate(t,r){this.statusUpdateCallback?.(t,r);let a={validating:0,scheduled:0,awaiting_approval:0,executing:0,success:0,error:0,cancelled:0};t.forEach(c=>{c.status in a&&a[c.status]++});let i=a.executing+a.awaiting_approval;i>0&&this.log(`${i} \u4E2A\u5DE5\u5177\u8C03\u7528\u6B63\u5728\u5904\u7406\u4E2D`);let s={type:"tools_status_overview",agentId:r.agentId,totalTools:t.length,statusCounts:a,activeTools:i,timestamp:Date.now()},e=`SUBAGENT_EVENT:${JSON.stringify(s)}`;this.updateOutput?.(e)}log(t){this.executionLog.push(t),this.logCallback?.(t)}getExecutionLog(){return[...this.executionLog]}getFilesCreated(){return[...this.filesCreated]}getCommandsRun(){return[...this.commandsRun]}cleanup(){this.executionLog=[],this.filesCreated=[],this.commandsRun=[]}}});var F3,NXe=ut(()=>{"use strict";F3=class{static getSuccessResultSummary(t){return`\u2705 Sub-agent task completed: ${t}`}static getErrorResultSummary(t){return`\u274C Sub-agent task failed: ${t}`}static buildResultDisplay(t,r,a,i,s,e,c){let I=`## ${a?"\u2705":"\u274C"} Sub-Agent Task ${a?"Execution Successful":"Execution Failed"}
|
|
1702
|
+
... [TRUNCATED - use search_file_content to find specific information]`})}break}else break}return i.length===0&&t.length>0&&i.push({text:"... [Response too large, use search tools to find specific information]"}),i}async estimateTokens(t,r,a){if(r)try{return(await r.countTokens({model:a.getModel(),contents:[{role:"user",parts:t}]})).totalTokens||0}catch(s){er.warn(`[MCPResponseGuard] Token estimation failed: ${s}`)}let i=JSON.stringify(t).length;return Math.ceil(i/4)}startCleanupTask(){setInterval(()=>{this.cleanupExpiredTempFiles()},300*1e3)}cleanupExpiredTempFiles(){let t=Date.now(),r=[];for(let[a,i]of this.tempFiles.entries())t-i>this.tempFileTTL&&r.push(a);for(let a of r)try{A3.existsSync(a)&&(A3.unlinkSync(a),er.info(`[MCPResponseGuard] Cleaned up expired temp file: ${a}`)),this.tempFiles.delete(a)}catch(i){er.warn(`[MCPResponseGuard] Failed to delete temp file ${a}: ${i}`)}}async cleanup(){for(let t of this.tempFiles.keys())try{A3.existsSync(t)&&A3.unlinkSync(t)}catch(r){er.warn(`[MCPResponseGuard] Failed to cleanup temp file ${t}: ${r}`)}this.tempFiles.clear()}getTempFiles(){return Array.from(this.tempFiles.keys())}},Mvr=new xL});import{execSync as S6t,spawn as zvr}from"child_process";function D6t(n){return["vscode","vscodium","windsurf","cursor","vim","neovim","zed"].includes(n)}function T6t(n){try{return S6t(process.platform==="win32"?`where.exe ${n}`:`command -v ${n}`,{stdio:"ignore"}),!0}catch{return!1}}function QL(n){let t=O6t[n];return(process.platform==="win32"?t.win32:t.default).some(a=>T6t(a))}function HL(n){let t=!process.env.SANDBOX;return["vscode","vscodium","windsurf","cursor","zed"].includes(n)?t:!0}function c_(n){return n&&D6t(n)?QL(n)&&HL(n):!1}function U6t(n,t,r){if(!D6t(r))return null;let a=O6t[r],i=process.platform==="win32"?a.win32:a.default,s=i.slice(0,-1).find(e=>T6t(e))||i[i.length-1];switch(r){case"vscode":case"vscodium":case"windsurf":case"cursor":case"zed":return{command:s,args:["--wait","--diff",n,t]};case"vim":case"neovim":return{command:s,args:["-d","-i","NONE","-c","wincmd h | set readonly | wincmd l","-c","highlight DiffAdd cterm=bold ctermbg=22 guibg=#005f00 | highlight DiffChange cterm=bold ctermbg=24 guibg=#005f87 | highlight DiffText ctermbg=21 guibg=#0000af | highlight DiffDelete ctermbg=52 guibg=#5f0000","-c","set showtabline=2 | set tabline=[Instructions]\\ :wqa(save\\ &\\ quit)\\ \\|\\ i/esc(toggle\\ edit\\ mode)","-c","wincmd h | setlocal statusline=OLD\\ FILE","-c","wincmd l | setlocal statusline=%#StatusBold#NEW\\ FILE\\ :wqa(save\\ &\\ quit)\\ \\|\\ i/esc(toggle\\ edit\\ mode)","-c","autocmd WinClosed * wqa",n,t]};default:return null}}async function fXe(n,t,r){let a=U6t(n,t,r);if(!a){console.error("No diff tool available. Install a supported editor.");return}try{switch(r){case"vscode":case"vscodium":case"windsurf":case"cursor":case"zed":return new Promise((i,s)=>{let e=zvr(a.command,a.args,{stdio:"inherit",shell:!0});e.on("close",c=>{c===0?i():s(new Error(`${r} exited with code ${c}`))}),e.on("error",c=>{s(c)})});case"vim":case"neovim":{let i=process.platform==="win32"?`${a.command} ${a.args.join(" ")}`:`${a.command} ${a.args.map(s=>`"${s}"`).join(" ")}`;S6t(i,{stdio:"inherit",encoding:"utf8"});break}default:throw new Error(`Unsupported editor: ${r}`)}}catch(i){console.error(i)}}var O6t,gXe=ut(()=>{"use strict";O6t={vscode:{win32:["code.cmd"],default:["code"]},vscodium:{win32:["codium.cmd"],default:["codium"]},windsurf:{win32:["windsurf"],default:["windsurf"]},cursor:{win32:["cursor"],default:["cursor"]},vim:{win32:["vim"],default:["vim"]},neovim:{win32:["nvim"],default:["nvim"]},zed:{win32:["zed"],default:["zed","zeditor"]}}});import _vr from"os";import XL from"path";import m4 from"fs";function M6t(n){return"getModifyContext"in n}function Pvr(n,t,r){let a=_vr.tmpdir(),i=XL.join(a,"gemini-cli-tool-modify-diffs");m4.existsSync(i)||m4.mkdirSync(i,{recursive:!0});let s=XL.extname(r),e=XL.basename(r,s),c=Date.now(),u=XL.join(i,`gemini-cli-modify-${e}-old-${c}${s}`),d=XL.join(i,`gemini-cli-modify-${e}-new-${c}${s}`);return m4.writeFileSync(u,n,"utf8"),m4.writeFileSync(d,t,"utf8"),{oldPath:u,newPath:d}}function jvr(n,t,r,a){let i="",s="";try{i=m4.readFileSync(n,"utf8")}catch(u){if(!Xs(u)||u.code!=="ENOENT")throw u;i=""}try{s=m4.readFileSync(t,"utf8")}catch(u){if(!Xs(u)||u.code!=="ENOENT")throw u;s=""}let e=a.createUpdatedParams(i,s,r),c=G3(XL.basename(a.getFilePath(r)),i,s,"Current","Proposed",f3);return{updatedParams:e,updatedDiff:c}}function Kvr(n,t){try{m4.unlinkSync(n)}catch{console.error(`Error deleting temp diff file: ${n}`)}try{m4.unlinkSync(t)}catch{console.error(`Error deleting temp diff file: ${t}`)}}async function z6t(n,t,r,a){let i=await t.getCurrentContent(n),s=await t.getProposedContent(n),{oldPath:e,newPath:c}=Pvr(i,s,t.getFilePath(n));try{return await fXe(e,c,r),jvr(e,c,n,t)}finally{Kvr(e,c)}}var _6t=ut(()=>{"use strict";gXe();Az();yz();Ro();});import*as P6t from"path";function qvr(){return I_||(I_=new kL),I_}function $vr(){I_?.clear(),I_=null}var kL,I_,vXe=ut(()=>{"use strict";kL=class{fileQueues=new Map;normalizePath(t){let r=P6t.normalize(t);return process.platform==="win32"?r.toLowerCase():r}async enqueue(t,r){let a=this.normalizePath(t),i=this.fileQueues.get(a)??Promise.resolve(),s,e,c=new Promise((d,I)=>{s=d,e=I}),u=i.catch(()=>{}).then(async()=>{try{let d=await r();return s(),d}catch(d){throw e(d),d}});return this.fileQueues.set(a,c.catch(()=>{})),u}async enqueueMultiple(t,r){if(t.length===0)return r();if(t.length===1)return this.enqueue(t[0],r);let a=[...t].map(c=>this.normalizePath(c)).sort(),i=a.map(c=>this.fileQueues.get(c)??Promise.resolve());await Promise.all(i.map(c=>c.catch(()=>{})));let s,e=new Promise(c=>{s=c});for(let c of a)this.fileQueues.set(c,e.catch(()=>{}));try{let c=await r();return s(),c}catch(c){throw s(),c}}clear(){this.fileQueues.clear()}get size(){return this.fileQueues.size}},I_=null});var uue,h4,Iue=ut(()=>{"use strict";s_();cue();GXe();_6t();vXe();uue=(n,t)=>({callId:n.callId,error:t,responseParts:{functionResponse:{id:n.callId,name:n.name,response:{error:t.message}}},resultDisplay:t.message}),h4=class{toolCalls=[];toolRegistry;adapter;approvalMode;config;getPreferredEditor;hookEventHandler;mcpResponseGuard;fileOperationQueue;completionResolvers=[];constructor(t){this.config=t.config,this.toolRegistry=t.toolRegistry,this.adapter=t.adapter,this.hookEventHandler=t.hookEventHandler,this.approvalMode=t.approvalMode??Ha.DEFAULT,this.getPreferredEditor=t.getPreferredEditor,this.mcpResponseGuard=new xL({maxResponseSize:100*1024,contextLowThreshold:.2,contextCriticalThreshold:.1}),this.fileOperationQueue=new kL}getToolCalls(){return[...this.toolCalls]}reset(){if(this.toolCalls.length===0)return;let t={agentId:"system-reset",agentType:"main"};this.toolCalls=[];let r=[...this.completionResolvers];this.completionResolvers=[],r.forEach(a=>{a([])}),this.adapter.onToolCallsUpdate([...this.toolCalls],t)}getConfirmationPriority(t){return t.agentContext.agentType==="sub"?1:2}getActiveConfirmation(){let t=this.toolCalls.filter(r=>r.status==="awaiting_approval");return t.length===0?null:t.sort((r,a)=>this.getConfirmationPriority(r)-this.getConfirmationPriority(a))[0]}createStatusUpdateCallback(t,r){return(a,i)=>{let s=this.toolCalls.findIndex(e=>e.request.callId===r);s>=0&&(this.toolCalls[s]={...this.toolCalls[s],subToolCalls:a.map(e=>({...e,agentContext:{...e.agentContext,parentAgentId:r}}))},this.adapter.onToolCallsUpdate([...this.toolCalls],t))}}isRunning(){return this.toolCalls.some(t=>t.status==="executing"||t.status==="awaiting_approval")}setStatusInternal(t,r,a,i){let s=this.toolCalls.find(u=>u.request.callId===t);if(!s){console.warn(`setStatusInternal: Cannot find tool call with ID ${t}`);return}let e;switch(r){case"success":e={...s,status:"success",response:a,durationMs:s.startTime?Date.now()-s.startTime:void 0};break;case"error":e={...s,status:"error",response:a,durationMs:s.startTime?Date.now()-s.startTime:void 0};break;case"awaiting_approval":e={...s,status:"awaiting_approval",confirmationDetails:a};break;case"cancelled":let u=a;e={...s,status:"cancelled",response:uue(s.request,new Error(u)),durationMs:s.startTime?Date.now()-s.startTime:void 0};break;default:e={...s,status:r};break}this.toolCalls=this.toolCalls.map(u=>u.request.callId===t?e:u);let c=i||{agentId:"unknown",agentType:"main"};this.adapter.onToolStatusChanged(t,r,e,c),this.adapter.onToolCallsUpdate([...this.toolCalls],c),this.checkAndNotifyCompletion(c)}checkAndNotifyCompletion(t){let r=this.toolCalls.every(a=>a.status==="success"||a.status==="error"||a.status==="cancelled");if(this.toolCalls.length>0&&r){let a=[...this.toolCalls],i=[...this.completionResolvers];this.completionResolvers=[];for(let s of a)av(this.config,new LL(s));this.adapter.onAllToolsComplete(a,t),i.forEach(s=>{s(a)}),this.toolCalls=[],this.adapter.onToolCallsUpdate([...this.toolCalls],t)}}async executeTools(t,r,a){if(this.isRunning())throw new Error("Cannot schedule new tool calls while other tool calls are actively running (executing or awaiting approval).");let i=await this.toolRegistry,s=t.map(c=>{let u=i.getTool(c.name),d={agentId:r.agentId,agentType:r.agentType,parentAgentId:r.agentType==="sub"?"main-agent":void 0,taskDescription:r.taskDescription};if(!u){let I=i.getAllTools().map(o=>o.name).join(", "),h=`Tool "${c.name}" not found in registry. Available tools: ${I}`;return{status:"error",request:c,response:uue(c,new Error(h)),durationMs:0,agentContext:d}}return{status:"validating",request:c,tool:u,startTime:Date.now(),agentContext:d}});this.toolCalls=this.toolCalls.concat(s),this.adapter.onToolCallsUpdate([...this.toolCalls],r);for(let c of s){if(c.status!=="validating")continue;let{request:u,tool:d}=c;try{if(this.config.getApprovalMode()===Ha.YOLO)this.setStatusInternal(u.callId,"scheduled",void 0,r);else{let I=await d.shouldConfirmExecute(u.args,a);if(!I)this.setStatusInternal(u.callId,"scheduled",void 0,r);else{let h=I.onConfirm,o={...I,originalOnConfirm:h,onConfirm:(v,w)=>this.handleConfirmationResponse(u.callId,v,w,a)};this.setStatusInternal(u.callId,"awaiting_approval",o,r)}}}catch(I){this.setStatusInternal(u.callId,"error",uue(u,I instanceof Error?I:new Error(String(I))),r)}}if(s.length===0)return[];let e=new Promise(c=>{this.completionResolvers.push(c)});return await this.attemptExecutionOfScheduledCalls(a,r),this.checkAndNotifyCompletion(r),e}async handleConfirmationResponse(t,r,a,i){let s=this.toolCalls.find(d=>d.request.callId===t&&d.status==="awaiting_approval");if(!s||s.status!=="awaiting_approval")return;let e=s,c=e.confirmationDetails;c.originalOnConfirm?await c.originalOnConfirm(r,a):await e.confirmationDetails.onConfirm(r,a),this.toolCalls=this.toolCalls.map(d=>d.request.callId!==t?d:{...d,outcome:r});let u={agentId:"main",agentType:"main"};if(r===Xr.Cancel||i?.aborted)this.setStatusInternal(t,"cancelled","User cancelled",u);else if(r===Xr.ProceedAlwaysProject)this.config.setApprovalModeWithProjectSync(Ha.YOLO,!0),this.setStatusInternal(t,"scheduled",void 0,u),await this.attemptExecutionOfScheduledCalls(i||new AbortController().signal,u);else if(r===Xr.ModifyWithEditor){if(M6t(e.tool)){let d=e.tool.getModifyContext(i||new AbortController().signal),I=this.getPreferredEditor();if(!I)return;this.setStatusInternal(t,"awaiting_approval",{...e.confirmationDetails,isModifying:!0},u);let{updatedParams:h}=await z6t(e.request.args,d,I,i||new AbortController().signal);this.toolCalls=this.toolCalls.map(o=>o.request.callId!==t?o:{...o,request:{...o.request,args:h}}),this.setStatusInternal(t,"scheduled",void 0,u),await this.attemptExecutionOfScheduledCalls(i||new AbortController().signal,u)}}else this.setStatusInternal(t,"scheduled",void 0,u),await this.attemptExecutionOfScheduledCalls(i||new AbortController().signal,u)}getToolFilePaths(t,r){try{return t.toolLocations(r).filter(i=>i.path).map(i=>i.path)}catch{return[]}}async executeSingleToolCall(t,r,a){let{request:i,tool:s}=t;try{this.setStatusInternal(i.callId,"executing",void 0,a);let e={getExecutionContext:()=>({agentId:a.agentId,agentType:a.agentType,taskDescription:a.taskDescription}),statusUpdateCallback:this.createStatusUpdateCallback(a,i.callId),onPreToolExecution:async o=>{await this.adapter.onPreToolExecution(o.callId,o.tool,o.args,a)}};if(this.hookEventHandler)try{await this.hookEventHandler.fireBeforeToolEvent(i.name,i.args)}catch(o){console.warn(`[ToolExecutionEngine] BeforeTool hook execution failed: ${o}`)}let c=await s.execute(i.args,r,o=>{this.adapter.onOutputUpdate(i.callId,o,a),this.toolCalls=this.toolCalls.map(v=>{if(v.request.callId===i.callId){let w=o;if(v.request.name==="task")try{w=JSON.parse(o)}catch{w=o}return{...v,liveOutput:w}}return v})},e);if(r.aborted){this.setStatusInternal(i.callId,"cancelled","User cancelled tool execution.");return}let u=c.llmContent||"",d="";try{if(Array.isArray(c.llmContent)&&c.llmContent.length>0&&typeof c.llmContent[0]=="object"&&c.llmContent[0]!==null&&!Array.isArray(c.llmContent[0])&&typeof c.llmContent[0]!="string"){let v=await this.mcpResponseGuard.guardResponse(c.llmContent,this.config,i.name,50);u=v.parts,v.wasTruncated?(d=`[GUARD] ${v.truncationReason||"\u65E0\u539F\u56E0"} | \u539F\u59CB: ${(v.originalSize/1024).toFixed(2)}KB -> ${(v.processedSize/1024).toFixed(2)}KB`,v.wasStoredAsFile&&(d+=` | \u5DF2\u5B58\u50A8\u4E3A: ${v.tempFilePath}`)):d=`[GUARD] \u54CD\u5E94\u5B89\u5168 | \u5927\u5C0F: ${(v.originalSize/1024).toFixed(2)}KB`,console.log(`[ToolExecutionEngine] ${d}`)}}catch(o){console.warn(`[ToolExecutionEngine] MCP\u54CD\u5E94\u4FDD\u62A4\u5931\u8D25: ${o}`),u=c.llmContent||""}let I=AC(i.name,i.callId,u),h={callId:i.callId,responseParts:I,resultDisplay:c.returnDisplay,error:void 0};if(this.setStatusInternal(i.callId,"success",h,a),this.hookEventHandler)try{let o=typeof c.llmContent=="string"?{content:c.llmContent}:{content:c.llmContent||{}};await this.hookEventHandler.fireAfterToolEvent(i.name,i.args,o)}catch(o){console.warn(`[ToolExecutionEngine] AfterTool hook execution failed: ${o}`)}}catch(e){let c=uue(i,e instanceof Error?e:new Error(String(e)));if(this.setStatusInternal(i.callId,"error",c,a),this.hookEventHandler)try{await this.hookEventHandler.fireAfterToolEvent(i.name,i.args,{error:c.error?.message||"Unknown error"})}catch(u){console.warn(`[ToolExecutionEngine] AfterTool hook execution failed: ${u}`)}}}async attemptExecutionOfScheduledCalls(t,r){let a=this.toolCalls.filter(s=>s.status==="scheduled");if(a.length===0)return;for(let s of a)await this.adapter.onPreToolExecution(s.request.callId,s.tool,s.request.args,r);let i=a.map(async s=>{let{tool:e,request:c}=s,u=this.getToolFilePaths(e,c.args);return u.length===0?this.executeSingleToolCall(s,t,r):u.length===1?this.fileOperationQueue.enqueue(u[0],()=>this.executeSingleToolCall(s,t,r)):this.fileOperationQueue.enqueueMultiple(u,()=>this.executeSingleToolCall(s,t,r))});await Promise.all(i)}}});function eZr(n,t,r){return new JL(n,t,r)}var JL,ZXe=ut(()=>{"use strict";JL=class{updateOutput;logCallback;toolCompletionHandler;toolRegistry;externalPreToolExecutionHandler;executionLog=[];filesCreated=[];commandsRun=[];statusUpdateCallback;constructor(t,r,a,i,s){this.updateOutput=t,this.logCallback=r,this.toolCompletionHandler=a,this.toolRegistry=i,this.externalPreToolExecutionHandler=s}setStatusUpdateCallback(t){this.statusUpdateCallback=t}getStatusUpdateCallback(){return this.statusUpdateCallback}onToolStatusChanged(t,r,a,i){this.statusUpdateCallback?.([a],i);let s=this.createDetailedToolInfo(t,r,a),e=`TOOL_CALL_UPDATE:${JSON.stringify(s)}`;if(this.log(`\u5DE5\u5177 ${a.request.name}: ${r}`),this.updateOutput?.(e),r==="success"){if(a.request.name==="write_file"||a.request.name==="edit_file"){let c=a.request.args?.file_path||a.request.args?.path;c&&typeof c=="string"&&this.filesCreated.push(c)}else if(a.request.name==="shell"){let c=a.request.args?.command;c&&typeof c=="string"&&this.commandsRun.push(c)}}}createDetailedToolInfo(t,r,a){let s={validating:"Pending",scheduled:"Pending",awaiting_approval:"Confirming",executing:"Executing",success:"Success",error:"Error",cancelled:"Canceled"}[r]||"Pending",c=this.formatToolArgs(a.request.name,a.request.args)||"",u={callId:t,toolName:a.request.name,description:c,status:s,startTime:a.startTime};if(r==="success"&&a.response){let d=a.response;u.result=typeof d.resultDisplay=="string"?d.resultDisplay:"\u6267\u884C\u6210\u529F",u.startTime&&(u.durationMs=Date.now()-u.startTime)}else r==="error"&&a.response?.error&&(u.error=a.response.error.message||"\u6267\u884C\u5931\u8D25",u.startTime&&(u.durationMs=Date.now()-u.startTime));return u}formatToolArgs(t,r){if(this.toolRegistry)try{let s=this.toolRegistry.getTool(t);if(s&&s.getDescription){let e=s.getDescription(r);if(e&&e.length>0){let c=e.match(/\((.*)\)$/);return c?c[1]:e.replace(new RegExp(`^${t}\\s*`,"i"),"").trim()}}}catch(s){console.warn(`Failed to get description for tool ${t}:`,s)}let a=["file_path","path","absolute_path","command","content","query","pattern","prompt","description"],i=[];for(let s of a)if(r[s]&&typeof r[s]=="string"){let e=r[s];e.length>50?i.push(`${e.substring(0,50)}...`):i.push(e)}return i.join(", ")}onOutputUpdate(t,r,a){this.log(`[${t}] ${r}`);let i={callId:t,output:r,timestamp:Date.now()},s=`TOOL_OUTPUT_UPDATE:${JSON.stringify(i)}`;this.updateOutput?.(s)}getPreferredEditor(t){}async onPreToolExecution(t,r,a,i){if(this.externalPreToolExecutionHandler)try{await this.externalPreToolExecutionHandler({callId:t,tool:r,args:a})}catch(c){console.warn("[SubAgent] Failed to execute external pre-tool handler:",c)}this.log(`\u51C6\u5907\u6267\u884C\u5DE5\u5177: ${r.displayName||r.name}`);let s={type:"tool_preparation",callId:t,toolName:r.name,toolDisplayName:r.displayName||r.name,args:this.sanitizeArgs(a),agentId:i.agentId,taskDescription:i.taskDescription,timestamp:Date.now()},e=`SUBAGENT_EVENT:${JSON.stringify(s)}`;this.updateOutput?.(e)}sanitizeArgs(t){let r={};for(let[a,i]of Object.entries(t))typeof i=="string"||typeof i=="number"||typeof i=="boolean"?typeof i=="string"&&i.length>200?r[a]=i.substring(0,200)+"...":r[a]=i:i==null?r[a]=i:r[a]="[\u590D\u6742\u5BF9\u8C61]";return r}onAllToolsComplete(t,r){let a=t.filter(u=>u.status==="success").length,i=t.filter(u=>u.status==="error").length,s=t.filter(u=>u.status==="cancelled").length;this.log(`\u5DE5\u5177\u6279\u6B21\u6267\u884C\u5B8C\u6210: ${a} \u6210\u529F, ${i} \u5931\u8D25, ${s} \u53D6\u6D88`);let e={type:"tools_batch_complete",agentId:r.agentId,statistics:{total:t.length,success:a,error:i,cancelled:s},filesCreated:[...this.filesCreated],commandsRun:[...this.commandsRun],completedCalls:t.map(u=>({callId:u.request.callId,toolName:u.request.name,status:u.status,durationMs:u.durationMs})),timestamp:Date.now()},c=`SUBAGENT_EVENT:${JSON.stringify(e)}`;this.updateOutput?.(c),this.toolCompletionHandler&&this.toolCompletionHandler(t)}onToolCallsUpdate(t,r){this.statusUpdateCallback?.(t,r);let a={validating:0,scheduled:0,awaiting_approval:0,executing:0,success:0,error:0,cancelled:0};t.forEach(c=>{c.status in a&&a[c.status]++});let i=a.executing+a.awaiting_approval;i>0&&this.log(`${i} \u4E2A\u5DE5\u5177\u8C03\u7528\u6B63\u5728\u5904\u7406\u4E2D`);let s={type:"tools_status_overview",agentId:r.agentId,totalTools:t.length,statusCounts:a,activeTools:i,timestamp:Date.now()},e=`SUBAGENT_EVENT:${JSON.stringify(s)}`;this.updateOutput?.(e)}log(t){this.executionLog.push(t),this.logCallback?.(t)}getExecutionLog(){return[...this.executionLog]}getFilesCreated(){return[...this.filesCreated]}getCommandsRun(){return[...this.commandsRun]}cleanup(){this.executionLog=[],this.filesCreated=[],this.commandsRun=[]}}});var F3,NXe=ut(()=>{"use strict";F3=class{static getSuccessResultSummary(t){return`\u2705 Sub-agent task completed: ${t}`}static getErrorResultSummary(t){return`\u274C Sub-agent task failed: ${t}`}static buildResultDisplay(t,r,a,i,s,e,c){let I=`## ${a?"\u2705":"\u274C"} Sub-Agent Task ${a?"Execution Successful":"Execution Failed"}
|
|
1703
1703
|
|
|
1704
1704
|
**Task**: ${t}
|
|
1705
1705
|
|
|
@@ -1845,6 +1845,7 @@ When requested to perform tasks like fixing bugs, adding features, refactoring,
|
|
|
1845
1845
|
- **Political and Social Topics:** Politely decline to engage with political topics, social controversies, or discussions about national leaders from any country. Redirect the conversation toward technical and software engineering topics. Example: "I focus on technical assistance. Let's discuss your coding or development needs instead."
|
|
1846
1846
|
|
|
1847
1847
|
## Tool Usage
|
|
1848
|
+
- **CRITICAL - NATIVE TOOL CALLS ONLY:** NEVER output tool calls as text like \`[tool_call: ...]\` or \`CALL: ...\` in your response. You MUST use the system's function calling API. Text tool calls will NOT be executed.
|
|
1848
1849
|
- **CRITICAL: TODO Management:** Use '${Ec.Name}' VERY frequently to ensure task tracking and completion. If you do not use this tool for complex tasks, you WILL forget important steps. Mark tasks in_progress before starting, completed immediately after finishing. MANDATORY for logs/errors, debug sessions, or any content requiring systematic analysis.
|
|
1849
1850
|
- **File Paths:** Always use absolute paths when referring to files with tools like '${ls.Name}' or '${Xo.Name}'. Relative paths are not supported. You must provide an absolute path.
|
|
1850
1851
|
- **File Editing Strategy:** If a file already exists, first read it with '${ls.Name}' and then use '${ko.Name}' to modify it. Use '${Xo.Name}' only to create a new file when no suitable file exists or the user explicitly requests a new file. Do not create variant filenames (e.g., *_fix.py, *_v2.ts) unless explicitly requested.
|
|
@@ -2078,6 +2079,7 @@ When requested to perform tasks like fixing bugs, adding features, refactoring,
|
|
|
2078
2079
|
- **Political and Social Topics:** Politely decline to engage with political topics, social controversies, or discussions about national leaders from any country. Redirect the conversation toward technical and software engineering topics. Example: "I focus on technical assistance. Let's discuss your coding or development needs instead."
|
|
2079
2080
|
|
|
2080
2081
|
## Tool Usage
|
|
2082
|
+
- **CRITICAL - NATIVE TOOL CALLS ONLY:** NEVER output tool calls as text like \`[tool_call: ...]\` or \`CALL: ...\` in your response. You MUST use the system's function calling API. Text tool calls will NOT be executed.
|
|
2081
2083
|
- **CRITICAL: TODO Management:** Use '${Ec.Name}' VERY frequently to ensure task tracking and completion. If you do not use this tool for complex tasks, you WILL forget important steps. Mark tasks in_progress before starting, completed immediately after finishing. MANDATORY for logs/errors, debug sessions, or any content requiring systematic analysis.
|
|
2082
2084
|
- **File Paths:** Always use absolute paths when referring to files with tools like '${ls.Name}' or '${Xo.Name}'. Relative paths are not supported. You must provide an absolute path.
|
|
2083
2085
|
- **File Editing Strategy:** If a file already exists, first read it with '${ls.Name}' and then use '${ko.Name}' to modify it. Use '${Xo.Name}' only to create a new file when no suitable file exists or the user explicitly requests a new file. Do not create variant filenames (e.g., *_fix.py, *_v2.ts) unless explicitly requested.
|
|
@@ -3991,7 +3993,7 @@ ${Ke("model.command.auto.mode")}`),a({type:"info",text:o},Date.now()),r(null)}ca
|
|
|
3991
3993
|
`,t-1),[i,s]=i4r(r);return{line:a===-1?i:n.slice(0,a+1).match(/\n/g).length+i,column:t-a-1+s}}function lLe(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 l4r(n,t,r)}var s4r=n=>`\\u{${n.codePointAt(0).toString(16)}}`,sLe=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??=`${c4r(this.#t.message)}${this.#e===""?" while parsing empty string":""}`;let{codeFrame:t}=this;return`${this.#n}${this.fileName?` in ${this.fileName}`:""}${t?`
|
|
3992
3994
|
|
|
3993
3995
|
${t}
|
|
3994
|
-
`:""}`}set message(t){this.#n=t}#i(t){if(!this.#t)return;let r=this.#e,a=o4r(r,this.#t.message);if(a)return(0,QPt.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}},o4r=(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)}:lLe(n,Number(a),{oneBased:!0})},c4r=n=>n.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,r,a)=>`"${a}"(${s4r(a)})`);function oLe(n,t,r){typeof t=="string"&&(r=t,t=void 0);try{return JSON.parse(n,t)}catch(a){throw new sLe({jsonParseError:a,fileName:r,input:n})}}var Ojt=Tt(Djt(),1);import{fileURLToPath as VRr}from"node:url";function Tjt(n){return n instanceof URL?VRr(n):n}var HRr=n=>QRr.resolve(Tjt(n)??".","package.json"),XRr=(n,t)=>{let r=typeof n=="string"?oLe(n):n;return t&&(0,Ojt.default)(r),r};async function Ujt({cwd:n,normalize:t=!0}={}){let r=await xRr.readFile(HRr(n),"utf8");return XRr(r,t)}async function Mjt(n){let t=await cPt("package.json",n);if(t)return{packageJson:await Ujt({...n,cwd:kRr.dirname(t)}),path:t}}import{fileURLToPath as LRr}from"url";import JRr from"path";var BRr=LRr(import.meta.url),SRr=JRr.dirname(BRr),Y0e;async function xJ(){if(Y0e)return Y0e;let n=await Mjt({cwd:SRr});if(n)return Y0e=n.packageJson,Y0e}async function QJ(){let n=await xJ();return"1.0.
|
|
3996
|
+
`:""}`}set message(t){this.#n=t}#i(t){if(!this.#t)return;let r=this.#e,a=o4r(r,this.#t.message);if(a)return(0,QPt.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}},o4r=(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)}:lLe(n,Number(a),{oneBased:!0})},c4r=n=>n.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(t,r,a)=>`"${a}"(${s4r(a)})`);function oLe(n,t,r){typeof t=="string"&&(r=t,t=void 0);try{return JSON.parse(n,t)}catch(a){throw new sLe({jsonParseError:a,fileName:r,input:n})}}var Ojt=Tt(Djt(),1);import{fileURLToPath as VRr}from"node:url";function Tjt(n){return n instanceof URL?VRr(n):n}var HRr=n=>QRr.resolve(Tjt(n)??".","package.json"),XRr=(n,t)=>{let r=typeof n=="string"?oLe(n):n;return t&&(0,Ojt.default)(r),r};async function Ujt({cwd:n,normalize:t=!0}={}){let r=await xRr.readFile(HRr(n),"utf8");return XRr(r,t)}async function Mjt(n){let t=await cPt("package.json",n);if(t)return{packageJson:await Ujt({...n,cwd:kRr.dirname(t)}),path:t}}import{fileURLToPath as LRr}from"url";import JRr from"path";var BRr=LRr(import.meta.url),SRr=JRr.dirname(BRr),Y0e;async function xJ(){if(Y0e)return Y0e;let n=await Mjt({cwd:SRr});if(n)return Y0e=n.packageJson,Y0e}async function QJ(){let n=await xJ();return"1.0.248"}Vi();import eV from"node:process";Ar();var zjt={name:"about",description:Ke("command.about.description"),kind:"built-in",action:async n=>{let t=eV.platform,r="no sandbox";eV.env.SANDBOX&&eV.env.SANDBOX!=="sandbox-exec"?r=eV.env.SANDBOX:eV.env.SANDBOX==="sandbox-exec"&&(r=`sandbox-exec (${eV.env.SEATBELT_PROFILE||"unknown"})`);let a=n.services.config?.getModel()||"Unknown",i=await QJ(),s=n.services.settings.merged.selectedAuthType||"",e=eV.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())}};Vi();Ar();var _jt={name:"auth",description:Ke("command.auth.description"),kind:"built-in",action:(n,t)=>({type:"dialog",dialog:"auth"})};Vi();Ar();var Pjt={name:"clear",description:Ke("command.clear.description"),kind:"built-in",action:async(n,t)=>{n.ui.setDebugMessage("Clearing terminal screen."),n.ui.clear()}};Vi();Ar();var jjt={name:"compress",altNames:["summarize"],description:Ke("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:Ke("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)}}};Vi();Ar();var Kjt={name:"copy",description:Ke("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 kzt(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."}}};Vi();Ar();var qjt={name:"editor",description:Ke("command.editor.description"),kind:"built-in",action:()=>({type:"dialog",dialog:"editor"})};Vi();Ar();var DRr={name:"list",description:"List all active extensions",kind:"built-in",action:async n=>{let t=n.services.config?.getExtensions().filter(i=>i.isActive);if(!t||t.length===0){n.ui.addItem({type:"info",text:"No active extensions."},Date.now());return}let a=`Active extensions:
|
|
3995
3997
|
|
|
3996
3998
|
${t.map(i=>` - \x1B[36m${i.name} (v${i.version})\x1B[0m`).join(`
|
|
3997
3999
|
`)}
|