@shipstatic/ship 3.4.0-beta.19 → 3.4.0-beta.20

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/dist/cli.cjs CHANGED
@@ -228,7 +228,7 @@ source '${a.completionFile}'
228
228
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){o(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){o(a);continue}}if(e.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}if(s.count>1&&e.reused==="ref"){o(a);continue}}}function Xe(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},f=c.ref;if(c.ref=null,f){i(f);let _=e.seen.get(f),b=_.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(b)):Object.assign(u,b),Object.assign(u,l),s._zod.parent===f)for(let D in u)D==="$ref"||D==="allOf"||D in l||delete u[D];if(b.$ref&&_.def)for(let D in u)D==="$ref"||D==="allOf"||D in _.def&&JSON.stringify(u[D])===JSON.stringify(_.def[D])&&delete u[D]}let p=s._zod.parent;if(p&&p!==f){i(p);let _=e.seen.get(p);if(_?.schema.$ref&&(u.$ref=_.schema.$ref,_.def))for(let b in u)b==="$ref"||b==="allOf"||b in _.def&&JSON.stringify(u[b])===JSON.stringify(_.def[b])&&delete u[b]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};for(let s of[...e.seen.entries()].reverse())i(s[0]);let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}Object.assign(n,r.def??r.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&n.id===o&&delete n.id;let a=e.external?.defs??{};for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,a[c.defId]=c.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?n.$defs=a:n.definitions=a);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Rt(t,"input",e.processors),output:Rt(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function ne(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return ne(i.element,r);if(i.type==="set")return ne(i.valueType,r);if(i.type==="lazy")return ne(i.getter(),r);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return ne(i.innerType,r);if(i.type==="intersection")return ne(i.left,r)||ne(i.right,r);if(i.type==="record"||i.type==="map")return ne(i.keyType,r)||ne(i.valueType,r);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ne(i.in,r)||ne(i.out,r);if(i.type==="object"){for(let n in i.shape)if(ne(i.shape[n],r))return!0;return!1}if(i.type==="union"){for(let n of i.options)if(ne(n,r))return!0;return!1}if(i.type==="tuple"){for(let n of i.items)if(ne(n,r))return!0;return!!(i.rest&&ne(i.rest,r))}return!1}var tu=(e,t={})=>r=>{let i=qe({...r,processors:t});return U(e,i),Ke(i,e),Xe(i,e)},Rt=(e,t,r={})=>i=>{let{libraryOptions:n,target:o}=i??{},a=qe({...n??{},target:o,io:t,processors:r});return U(e,a),Ke(a,e),Xe(a,e)};var mx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},nu=(e,t,r,i)=>{let n=r;n.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof o=="number"&&(n.minLength=o),typeof a=="number"&&(n.maxLength=a),s&&(n.format=mx[s]??s,n.format===""&&delete n.format,s==="time"&&delete n.format),u&&(n.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?n.pattern=l[0].source:l.length>1&&(n.allOf=[...l.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},ru=(e,t,r,i)=>{let n=r,{minimum:o,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?n.type="integer":n.type="number";let f=typeof l=="number"&&l>=(o??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),_=t.target==="draft-04"||t.target==="openapi-3.0";f?_?(n.minimum=l,n.exclusiveMinimum=!0):n.exclusiveMinimum=l:typeof o=="number"&&(n.minimum=o),p?_?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof a=="number"&&(n.maximum=a),typeof c=="number"&&(n.multipleOf=c)},iu=(e,t,r,i)=>{r.type="boolean"},ou=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},au=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},su=(e,t,r,i)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},cu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},uu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},lu=(e,t,r,i)=>{r.not={}},du=(e,t,r,i)=>{},pu=(e,t,r,i)=>{},mu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},fu=(e,t,r,i)=>{let n=e._zod.def,o=pn(n.entries);o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),r.enum=o},hu=(e,t,r,i)=>{let n=e._zod.def,o=[];for(let a of n.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),o.every(a=>typeof a=="boolean")&&(r.type="boolean"),o.every(a=>a===null)&&(r.type="null"),r.enum=o},gu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},vu=(e,t,r,i)=>{let n=r,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=o.source},_u=(e,t,r,i)=>{let n=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=e._zod.bag;a!==void 0&&(o.minLength=a),s!==void 0&&(o.maxLength=s),c?c.length===1?(o.contentMediaType=c[0],Object.assign(n,o)):(Object.assign(n,o),n.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(n,o)},yu=(e,t,r,i)=>{r.type="boolean"},$u=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},xu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},bu=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Su=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},ku=(e,t,r,i)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},wu=(e,t,r,i)=>{let n=r,o=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=U(o.element,t,{...i,path:[...i.path,"items"]})},Iu=(e,t,r,i)=>{let n=r,o=e._zod.def;n.type="object",n.properties={};let a=o.shape;for(let u in a)n.properties[u]=U(a[u],t,{...i,path:[...i.path,"properties",u]});let s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{let l=o.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(n.required=Array.from(c)),o.catchall?._zod.def.type==="never"?n.additionalProperties=!1:o.catchall?o.catchall&&(n.additionalProperties=U(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},di=(e,t,r,i)=>{let n=e._zod.def,o=n.inclusive===!1,a=n.options.map((s,c)=>U(s,t,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=a:r.anyOf=a},Ou=(e,t,r,i)=>{let n=e._zod.def,o=U(n.left,t,{...i,path:[...i.path,"allOf",0]}),a=U(n.right,t,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=c},zu=(e,t,r,i)=>{let n=r,o=e._zod.def;n.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((p,_)=>U(p,t,{...i,path:[...i.path,a,_]})),u=o.rest?U(o.rest,t,{...i,path:[...i.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;t.target==="draft-2020-12"?(n.prefixItems=c,u&&(n.items=u)):t.target==="openapi-3.0"?(n.items={anyOf:c},u&&n.items.anyOf.push(u),n.minItems=c.length,u||(n.maxItems=c.length)):(n.items=c,u&&(n.additionalItems=u));let{minimum:l,maximum:f}=e._zod.bag;typeof l=="number"&&(n.minItems=l),typeof f=="number"&&(n.maxItems=f)},Eu=(e,t,r,i)=>{let n=r,o=e._zod.def;n.type="object";let a=o.keyType,c=a._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let l=U(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});n.patternProperties={};for(let f of c)n.patternProperties[f.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=U(o.keyType,t,{...i,path:[...i.path,"propertyNames"]})),n.additionalProperties=U(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]});let u=a._zod.values;if(u){let l=[...u].filter(f=>typeof f=="string"||typeof f=="number");l.length>0&&(n.required=l)}},Du=(e,t,r,i)=>{let n=e._zod.def,o=U(n.innerType,t,i),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Tu=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType},Pu=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},Au=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},Cu=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},ju=(e,t,r,i)=>{let n=e._zod.def,o=n.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?o?n.out:n.in:n.out;U(a,t,i);let s=t.seen.get(e);s.ref=a},Nu=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType,r.readOnly=!0},Uu=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType},pi=(e,t,r,i)=>{let n=e._zod.def;U(n.innerType,t,i);let o=t.seen.get(e);o.ref=n.innerType},Ru=(e,t,r,i)=>{let n=e._zod.innerType;U(n,t,i);let o=t.seen.get(e);o.ref=n},li={string:nu,number:ru,boolean:iu,bigint:ou,symbol:au,null:su,undefined:cu,void:uu,never:lu,any:du,unknown:pu,date:mu,enum:fu,literal:hu,nan:gu,template_literal:vu,file:_u,success:yu,custom:$u,function:xu,transform:bu,map:Su,set:ku,array:wu,object:Iu,union:di,intersection:Ou,tuple:zu,record:Eu,nullable:Du,nonoptional:Tu,default:Pu,prefault:Au,catch:Cu,pipe:ju,readonly:Nu,promise:Uu,optional:pi,lazy:Ru};function mi(e,t){if("_idmap"in e){let i=e,n=qe({...t,processors:li}),o={};for(let c of i._idmap.entries()){let[u,l]=c;U(l,n)}let a={},s={registry:i,uri:t?.uri,defs:o};n.external=s;for(let c of i._idmap.entries()){let[u,l]=c;Ke(n,l),a[u]=Xe(n,l)}if(Object.keys(o).length>0){let c=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let r=qe({...t,processors:li});return U(e,r),Ke(r,e),Xe(r,e)}var fi=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=qe({processors:li,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return U(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),Ke(this.ctx,t);let i=Xe(this.ctx,t),{"~standard":n,...o}=i;return o}};var Qm={};var Dn={};pe(Dn,{ZodAny:()=>cl,ZodArray:()=>pl,ZodBase64:()=>ji,ZodBase64URL:()=>Ni,ZodBigInt:()=>Ht,ZodBigIntFormat:()=>Li,ZodBoolean:()=>Gt,ZodCIDRv4:()=>Ai,ZodCIDRv6:()=>Ci,ZodCUID:()=>Ii,ZodCUID2:()=>Oi,ZodCatch:()=>Cl,ZodCodec:()=>Mn,ZodCustom:()=>Vn,ZodCustomStringFormat:()=>Vt,ZodDate:()=>Un,ZodDefault:()=>zl,ZodDiscriminatedUnion:()=>fl,ZodE164:()=>Ui,ZodEmail:()=>Si,ZodEmoji:()=>ki,ZodEnum:()=>Zt,ZodExactOptional:()=>wl,ZodFile:()=>Sl,ZodFunction:()=>Bl,ZodGUID:()=>Pn,ZodIPv4:()=>Ti,ZodIPv6:()=>Pi,ZodIntersection:()=>hl,ZodJWT:()=>Ri,ZodKSUID:()=>Di,ZodLazy:()=>Zl,ZodLiteral:()=>bl,ZodMAC:()=>tl,ZodMap:()=>$l,ZodNaN:()=>Nl,ZodNanoID:()=>wi,ZodNever:()=>ll,ZodNonOptional:()=>Gi,ZodNull:()=>al,ZodNullable:()=>Ol,ZodNumber:()=>Bt,ZodNumberFormat:()=>ut,ZodObject:()=>Ln,ZodOptional:()=>Bi,ZodPipe:()=>Zn,ZodPrefault:()=>Dl,ZodPreprocess:()=>Ul,ZodPromise:()=>Vl,ZodReadonly:()=>Rl,ZodRecord:()=>Ft,ZodSet:()=>xl,ZodString:()=>Mt,ZodStringFormat:()=>L,ZodSuccess:()=>Al,ZodSymbol:()=>il,ZodTemplateLiteral:()=>Fl,ZodTransform:()=>kl,ZodTuple:()=>vl,ZodType:()=>C,ZodULID:()=>zi,ZodURL:()=>Nn,ZodUUID:()=>Oe,ZodUndefined:()=>ol,ZodUnion:()=>Fn,ZodUnknown:()=>ul,ZodVoid:()=>dl,ZodXID:()=>Ei,ZodXor:()=>ml,_ZodString:()=>bi,_default:()=>El,_function:()=>uh,any:()=>Ff,array:()=>Rn,base64:()=>Sf,base64url:()=>kf,bigint:()=>jf,boolean:()=>rl,catch:()=>jl,check:()=>lh,cidrv4:()=>xf,cidrv6:()=>bf,codec:()=>oh,cuid:()=>mf,cuid2:()=>ff,custom:()=>dh,date:()=>Mf,describe:()=>ph,discriminatedUnion:()=>Wf,e164:()=>wf,email:()=>nf,emoji:()=>df,enum:()=>Mi,exactOptional:()=>Il,file:()=>th,float32:()=>Tf,float64:()=>Pf,function:()=>uh,guid:()=>rf,hash:()=>Df,hex:()=>Ef,hostname:()=>zf,httpUrl:()=>lf,instanceof:()=>fh,int:()=>$i,int32:()=>Af,int64:()=>Nf,intersection:()=>gl,invertCodec:()=>ah,ipv4:()=>_f,ipv6:()=>$f,json:()=>gh,jwt:()=>If,keyof:()=>Vf,ksuid:()=>vf,lazy:()=>Ml,literal:()=>eh,looseObject:()=>Hf,looseRecord:()=>Kf,mac:()=>yf,map:()=>Xf,meta:()=>mh,nan:()=>ih,nanoid:()=>pf,nativeEnum:()=>Qf,never:()=>Fi,nonoptional:()=>Pl,null:()=>sl,nullable:()=>Cn,nullish:()=>nh,number:()=>nl,object:()=>Bf,optional:()=>An,partialRecord:()=>qf,pipe:()=>xi,prefault:()=>Tl,preprocess:()=>vh,promise:()=>ch,readonly:()=>Ll,record:()=>yl,refine:()=>Gl,set:()=>Yf,strictObject:()=>Gf,string:()=>Tn,stringFormat:()=>Of,stringbool:()=>hh,success:()=>rh,superRefine:()=>Hl,symbol:()=>Rf,templateLiteral:()=>sh,transform:()=>Vi,tuple:()=>_l,uint32:()=>Cf,uint64:()=>Uf,ulid:()=>hf,undefined:()=>Lf,union:()=>Zi,unknown:()=>ct,url:()=>uf,uuid:()=>of,uuidv4:()=>af,uuidv6:()=>sf,uuidv7:()=>cf,void:()=>Zf,xid:()=>gf,xor:()=>Jf});var hi={};pe(hi,{endsWith:()=>Dt,gt:()=>we,gte:()=>te,includes:()=>zt,length:()=>st,lowercase:()=>It,lt:()=>ke,lte:()=>le,maxLength:()=>at,maxSize:()=>We,mime:()=>Tt,minLength:()=>Ce,minSize:()=>Ie,multipleOf:()=>Je,negative:()=>ai,nonnegative:()=>ci,nonpositive:()=>si,normalize:()=>Pt,overwrite:()=>$e,positive:()=>oi,property:()=>ui,regex:()=>wt,size:()=>ot,slugify:()=>Nt,startsWith:()=>Et,toLowerCase:()=>Ct,toUpperCase:()=>jt,trim:()=>At,uppercase:()=>Ot});var Lt={};pe(Lt,{ZodISODate:()=>vi,ZodISODateTime:()=>gi,ZodISODuration:()=>yi,ZodISOTime:()=>_i,date:()=>Fu,datetime:()=>Lu,duration:()=>Mu,time:()=>Zu});var gi=v("ZodISODateTime",(e,t)=>{gs.init(e,t),L.init(e,t)});function Lu(e){return $c(gi,e)}var vi=v("ZodISODate",(e,t)=>{vs.init(e,t),L.init(e,t)});function Fu(e){return xc(vi,e)}var _i=v("ZodISOTime",(e,t)=>{_s.init(e,t),L.init(e,t)});function Zu(e){return bc(_i,e)}var yi=v("ZodISODuration",(e,t)=>{ys.init(e,t),L.init(e,t)});function Mu(e){return Sc(yi,e)}var ef=(e,t)=>{vn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>yn(e,r)},flatten:{value:r=>_n(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,gt,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,gt,2)}},isEmpty:{get(){return e.issues.length===0}}})},hx=v("ZodError",ef),ae=v("ZodError",ef,{Parent:Error});var Vu=yt(ae),Bu=$t(ae),Gu=xt(ae),Hu=bt(ae),Ju=mr(ae),Wu=fr(ae),qu=hr(ae),Ku=gr(ae),Xu=vr(ae),Yu=_r(ae),Qu=yr(ae),el=$r(ae);var tf=new WeakMap;function jn(e,t,r){let i=Object.getPrototypeOf(e),n=tf.get(i);if(n||(n=new Set,tf.set(i,n)),!n.has(t)){n.add(t);for(let o in r){let a=r[o];Object.defineProperty(i,o,{configurable:!0,enumerable:!1,get(){let s=a.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:s}),s},set(s){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:s})}})}}}var C=v("ZodType",(e,t)=>(A.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Rt(e,"input"),output:Rt(e,"output")}}),e.toJSONSchema=tu(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,i)=>Vu(e,r,i,{callee:e.parse}),e.safeParse=(r,i)=>Gu(e,r,i),e.parseAsync=async(r,i)=>Bu(e,r,i,{callee:e.parseAsync}),e.safeParseAsync=async(r,i)=>Hu(e,r,i),e.spa=e.safeParseAsync,e.encode=(r,i)=>Ju(e,r,i),e.decode=(r,i)=>Wu(e,r,i),e.encodeAsync=async(r,i)=>qu(e,r,i),e.decodeAsync=async(r,i)=>Ku(e,r,i),e.safeEncode=(r,i)=>Xu(e,r,i),e.safeDecode=(r,i)=>Yu(e,r,i),e.safeEncodeAsync=async(r,i)=>Qu(e,r,i),e.safeDecodeAsync=async(r,i)=>el(e,r,i),jn(e,"ZodType",{check(...r){let i=this.def;return this.clone(I.mergeDefs(i,{checks:[...i.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,i){return Q(this,r,i)},brand(){return this},register(r,i){return r.add(this,i),this},refine(r,i){return this.check(Gl(r,i))},superRefine(r,i){return this.check(Hl(r,i))},overwrite(r){return this.check($e(r))},optional(){return An(this)},exactOptional(){return Il(this)},nullable(){return Cn(this)},nullish(){return An(Cn(this))},nonoptional(r){return Pl(this,r)},array(){return Rn(this)},or(r){return Zi([this,r])},and(r){return gl(this,r)},transform(r){return xi(this,Vi(r))},default(r){return El(this,r)},prefault(r){return Tl(this,r)},catch(r){return jl(this,r)},pipe(r){return xi(this,r)},readonly(){return Ll(this)},describe(r){let i=this.clone();return K.add(i,{description:r}),i},meta(...r){if(r.length===0)return K.get(this);let i=this.clone();return K.add(i,r[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return K.get(e)?.description},configurable:!0}),e)),bi=v("_ZodString",(e,t)=>{it.init(e,t),C.init(e,t),e._zod.processJSONSchema=(i,n,o)=>nu(e,i,n,o);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,jn(e,"_ZodString",{regex(...i){return this.check(wt(...i))},includes(...i){return this.check(zt(...i))},startsWith(...i){return this.check(Et(...i))},endsWith(...i){return this.check(Dt(...i))},min(...i){return this.check(Ce(...i))},max(...i){return this.check(at(...i))},length(...i){return this.check(st(...i))},nonempty(...i){return this.check(Ce(1,...i))},lowercase(i){return this.check(It(i))},uppercase(i){return this.check(Ot(i))},trim(){return this.check(At())},normalize(...i){return this.check(Pt(...i))},toLowerCase(){return this.check(Ct())},toUpperCase(){return this.check(jt())},slugify(){return this.check(Nt())}})}),Mt=v("ZodString",(e,t)=>{it.init(e,t),bi.init(e,t),e.email=r=>e.check(Lr(Si,r)),e.url=r=>e.check(En(Nn,r)),e.jwt=r=>e.check(ii(Ri,r)),e.emoji=r=>e.check(Br(ki,r)),e.guid=r=>e.check(zn(Pn,r)),e.uuid=r=>e.check(Fr(Oe,r)),e.uuidv4=r=>e.check(Zr(Oe,r)),e.uuidv6=r=>e.check(Mr(Oe,r)),e.uuidv7=r=>e.check(Vr(Oe,r)),e.nanoid=r=>e.check(Gr(wi,r)),e.guid=r=>e.check(zn(Pn,r)),e.cuid=r=>e.check(Hr(Ii,r)),e.cuid2=r=>e.check(Jr(Oi,r)),e.ulid=r=>e.check(Wr(zi,r)),e.base64=r=>e.check(ti(ji,r)),e.base64url=r=>e.check(ni(Ni,r)),e.xid=r=>e.check(qr(Ei,r)),e.ksuid=r=>e.check(Kr(Di,r)),e.ipv4=r=>e.check(Xr(Ti,r)),e.ipv6=r=>e.check(Yr(Pi,r)),e.cidrv4=r=>e.check(Qr(Ai,r)),e.cidrv6=r=>e.check(ei(Ci,r)),e.e164=r=>e.check(ri(Ui,r)),e.datetime=r=>e.check(Lu(r)),e.date=r=>e.check(Fu(r)),e.time=r=>e.check(Zu(r)),e.duration=r=>e.check(Mu(r))});function Tn(e){return gc(Mt,e)}var L=v("ZodStringFormat",(e,t)=>{R.init(e,t),bi.init(e,t)}),Si=v("ZodEmail",(e,t)=>{ss.init(e,t),L.init(e,t)});function nf(e){return Lr(Si,e)}var Pn=v("ZodGUID",(e,t)=>{os.init(e,t),L.init(e,t)});function rf(e){return zn(Pn,e)}var Oe=v("ZodUUID",(e,t)=>{as.init(e,t),L.init(e,t)});function of(e){return Fr(Oe,e)}function af(e){return Zr(Oe,e)}function sf(e){return Mr(Oe,e)}function cf(e){return Vr(Oe,e)}var Nn=v("ZodURL",(e,t)=>{cs.init(e,t),L.init(e,t)});function uf(e){return En(Nn,e)}function lf(e){return En(Nn,{protocol:ue.httpProtocol,hostname:ue.domain,...I.normalizeParams(e)})}var ki=v("ZodEmoji",(e,t)=>{us.init(e,t),L.init(e,t)});function df(e){return Br(ki,e)}var wi=v("ZodNanoID",(e,t)=>{ls.init(e,t),L.init(e,t)});function pf(e){return Gr(wi,e)}var Ii=v("ZodCUID",(e,t)=>{ds.init(e,t),L.init(e,t)});function mf(e){return Hr(Ii,e)}var Oi=v("ZodCUID2",(e,t)=>{ps.init(e,t),L.init(e,t)});function ff(e){return Jr(Oi,e)}var zi=v("ZodULID",(e,t)=>{ms.init(e,t),L.init(e,t)});function hf(e){return Wr(zi,e)}var Ei=v("ZodXID",(e,t)=>{fs.init(e,t),L.init(e,t)});function gf(e){return qr(Ei,e)}var Di=v("ZodKSUID",(e,t)=>{hs.init(e,t),L.init(e,t)});function vf(e){return Kr(Di,e)}var Ti=v("ZodIPv4",(e,t)=>{$s.init(e,t),L.init(e,t)});function _f(e){return Xr(Ti,e)}var tl=v("ZodMAC",(e,t)=>{bs.init(e,t),L.init(e,t)});function yf(e){return _c(tl,e)}var Pi=v("ZodIPv6",(e,t)=>{xs.init(e,t),L.init(e,t)});function $f(e){return Yr(Pi,e)}var Ai=v("ZodCIDRv4",(e,t)=>{Ss.init(e,t),L.init(e,t)});function xf(e){return Qr(Ai,e)}var Ci=v("ZodCIDRv6",(e,t)=>{ks.init(e,t),L.init(e,t)});function bf(e){return ei(Ci,e)}var ji=v("ZodBase64",(e,t)=>{Is.init(e,t),L.init(e,t)});function Sf(e){return ti(ji,e)}var Ni=v("ZodBase64URL",(e,t)=>{Os.init(e,t),L.init(e,t)});function kf(e){return ni(Ni,e)}var Ui=v("ZodE164",(e,t)=>{zs.init(e,t),L.init(e,t)});function wf(e){return ri(Ui,e)}var Ri=v("ZodJWT",(e,t)=>{Es.init(e,t),L.init(e,t)});function If(e){return ii(Ri,e)}var Vt=v("ZodCustomStringFormat",(e,t)=>{Ds.init(e,t),L.init(e,t)});function Of(e,t,r={}){return Ut(Vt,e,t,r)}function zf(e){return Ut(Vt,"hostname",ue.hostname,e)}function Ef(e){return Ut(Vt,"hex",ue.hex,e)}function Df(e,t){let r=t?.enc??"hex",i=`${e}_${r}`,n=ue[i];if(!n)throw new Error(`Unrecognized hash format: ${i}`);return Ut(Vt,i,n,t)}var Bt=v("ZodNumber",(e,t)=>{Er.init(e,t),C.init(e,t),e._zod.processJSONSchema=(i,n,o)=>ru(e,i,n,o),jn(e,"ZodNumber",{gt(i,n){return this.check(we(i,n))},gte(i,n){return this.check(te(i,n))},min(i,n){return this.check(te(i,n))},lt(i,n){return this.check(ke(i,n))},lte(i,n){return this.check(le(i,n))},max(i,n){return this.check(le(i,n))},int(i){return this.check($i(i))},safe(i){return this.check($i(i))},positive(i){return this.check(we(0,i))},nonnegative(i){return this.check(te(0,i))},negative(i){return this.check(ke(0,i))},nonpositive(i){return this.check(le(0,i))},multipleOf(i,n){return this.check(Je(i,n))},step(i,n){return this.check(Je(i,n))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function nl(e){return kc(Bt,e)}var ut=v("ZodNumberFormat",(e,t)=>{Ts.init(e,t),Bt.init(e,t)});function $i(e){return Ic(ut,e)}function Tf(e){return Oc(ut,e)}function Pf(e){return zc(ut,e)}function Af(e){return Ec(ut,e)}function Cf(e){return Dc(ut,e)}var Gt=v("ZodBoolean",(e,t)=>{Sn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>iu(e,r,i,n)});function rl(e){return Tc(Gt,e)}var Ht=v("ZodBigInt",(e,t)=>{Dr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(i,n,o)=>ou(e,i,n,o),e.gte=(i,n)=>e.check(te(i,n)),e.min=(i,n)=>e.check(te(i,n)),e.gt=(i,n)=>e.check(we(i,n)),e.gte=(i,n)=>e.check(te(i,n)),e.min=(i,n)=>e.check(te(i,n)),e.lt=(i,n)=>e.check(ke(i,n)),e.lte=(i,n)=>e.check(le(i,n)),e.max=(i,n)=>e.check(le(i,n)),e.positive=i=>e.check(we(BigInt(0),i)),e.negative=i=>e.check(ke(BigInt(0),i)),e.nonpositive=i=>e.check(le(BigInt(0),i)),e.nonnegative=i=>e.check(te(BigInt(0),i)),e.multipleOf=(i,n)=>e.check(Je(i,n));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function jf(e){return Ac(Ht,e)}var Li=v("ZodBigIntFormat",(e,t)=>{Ps.init(e,t),Ht.init(e,t)});function Nf(e){return jc(Li,e)}function Uf(e){return Nc(Li,e)}var il=v("ZodSymbol",(e,t)=>{As.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>au(e,r,i,n)});function Rf(e){return Uc(il,e)}var ol=v("ZodUndefined",(e,t)=>{Cs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>cu(e,r,i,n)});function Lf(e){return Rc(ol,e)}var al=v("ZodNull",(e,t)=>{js.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>su(e,r,i,n)});function sl(e){return Lc(al,e)}var cl=v("ZodAny",(e,t)=>{Ns.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>du(e,r,i,n)});function Ff(){return Fc(cl)}var ul=v("ZodUnknown",(e,t)=>{Us.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pu(e,r,i,n)});function ct(){return Zc(ul)}var ll=v("ZodNever",(e,t)=>{Rs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>lu(e,r,i,n)});function Fi(e){return Mc(ll,e)}var dl=v("ZodVoid",(e,t)=>{Ls.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>uu(e,r,i,n)});function Zf(e){return Vc(dl,e)}var Un=v("ZodDate",(e,t)=>{Fs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(i,n,o)=>mu(e,i,n,o),e.min=(i,n)=>e.check(te(i,n)),e.max=(i,n)=>e.check(le(i,n));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function Mf(e){return Bc(Un,e)}var pl=v("ZodArray",(e,t)=>{Zs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>wu(e,r,i,n),e.element=t.element,jn(e,"ZodArray",{min(r,i){return this.check(Ce(r,i))},nonempty(r){return this.check(Ce(1,r))},max(r,i){return this.check(at(r,i))},length(r,i){return this.check(st(r,i))},unwrap(){return this.element}})});function Rn(e,t){return Jc(pl,e,t)}function Vf(e){let t=e._zod.def.shape;return Mi(Object.keys(t))}var Ln=v("ZodObject",(e,t)=>{Ms.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Iu(e,r,i,n),I.defineLazy(e,"shape",()=>t.shape),jn(e,"ZodObject",{keyof(){return Mi(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:ct()})},loose(){return this.clone({...this._zod.def,catchall:ct()})},strict(){return this.clone({...this._zod.def,catchall:Fi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return I.extend(this,r)},safeExtend(r){return I.safeExtend(this,r)},merge(r){return I.merge(this,r)},pick(r){return I.pick(this,r)},omit(r){return I.omit(this,r)},partial(...r){return I.partial(Bi,this,r[0])},required(...r){return I.required(Gi,this,r[0])}})});function Bf(e,t){let r={type:"object",shape:e??{},...I.normalizeParams(t)};return new Ln(r)}function Gf(e,t){return new Ln({type:"object",shape:e,catchall:Fi(),...I.normalizeParams(t)})}function Hf(e,t){return new Ln({type:"object",shape:e,catchall:ct(),...I.normalizeParams(t)})}var Fn=v("ZodUnion",(e,t)=>{kn.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>di(e,r,i,n),e.options=t.options});function Zi(e,t){return new Fn({type:"union",options:e,...I.normalizeParams(t)})}var ml=v("ZodXor",(e,t)=>{Fn.init(e,t),Vs.init(e,t),e._zod.processJSONSchema=(r,i,n)=>di(e,r,i,n),e.options=t.options});function Jf(e,t){return new ml({type:"union",options:e,inclusive:!1,...I.normalizeParams(t)})}var fl=v("ZodDiscriminatedUnion",(e,t)=>{Fn.init(e,t),Bs.init(e,t)});function Wf(e,t,r){return new fl({type:"union",options:t,discriminator:e,...I.normalizeParams(r)})}var hl=v("ZodIntersection",(e,t)=>{Gs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ou(e,r,i,n)});function gl(e,t){return new hl({type:"intersection",left:e,right:t})}var vl=v("ZodTuple",(e,t)=>{Tr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>zu(e,r,i,n),e.rest=r=>e.clone({...e._zod.def,rest:r})});function _l(e,t,r){let i=t instanceof A,n=i?r:t,o=i?t:null;return new vl({type:"tuple",items:e,rest:o,...I.normalizeParams(n)})}var Ft=v("ZodRecord",(e,t)=>{Hs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Eu(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType});function yl(e,t,r){return!t||!t._zod?new Ft({type:"record",keyType:Tn(),valueType:e,...I.normalizeParams(t)}):new Ft({type:"record",keyType:e,valueType:t,...I.normalizeParams(r)})}function qf(e,t,r){let i=Q(e);return i._zod.values=void 0,new Ft({type:"record",keyType:i,valueType:t,...I.normalizeParams(r)})}function Kf(e,t,r){return new Ft({type:"record",keyType:e,valueType:t,mode:"loose",...I.normalizeParams(r)})}var $l=v("ZodMap",(e,t)=>{Js.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Su(e,r,i,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Ie(...r)),e.nonempty=r=>e.check(Ie(1,r)),e.max=(...r)=>e.check(We(...r)),e.size=(...r)=>e.check(ot(...r))});function Xf(e,t,r){return new $l({type:"map",keyType:e,valueType:t,...I.normalizeParams(r)})}var xl=v("ZodSet",(e,t)=>{Ws.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ku(e,r,i,n),e.min=(...r)=>e.check(Ie(...r)),e.nonempty=r=>e.check(Ie(1,r)),e.max=(...r)=>e.check(We(...r)),e.size=(...r)=>e.check(ot(...r))});function Yf(e,t){return new xl({type:"set",valueType:e,...I.normalizeParams(t)})}var Zt=v("ZodEnum",(e,t)=>{qs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(i,n,o)=>fu(e,i,n,o),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(i,n)=>{let o={};for(let a of i)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Zt({...t,checks:[],...I.normalizeParams(n),entries:o})},e.exclude=(i,n)=>{let o={...t.entries};for(let a of i)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new Zt({...t,checks:[],...I.normalizeParams(n),entries:o})}});function Mi(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Zt({type:"enum",entries:r,...I.normalizeParams(t)})}function Qf(e,t){return new Zt({type:"enum",entries:e,...I.normalizeParams(t)})}var bl=v("ZodLiteral",(e,t)=>{Ks.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>hu(e,r,i,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function eh(e,t){return new bl({type:"literal",values:Array.isArray(e)?e:[e],...I.normalizeParams(t)})}var Sl=v("ZodFile",(e,t)=>{Xs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>_u(e,r,i,n),e.min=(r,i)=>e.check(Ie(r,i)),e.max=(r,i)=>e.check(We(r,i)),e.mime=(r,i)=>e.check(Tt(Array.isArray(r)?r:[r],i))});function th(e){return Wc(Sl,e)}var kl=v("ZodTransform",(e,t)=>{Ys.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>bu(e,r,i,n),e._zod.parse=(r,i)=>{if(i.direction==="backward")throw new Me(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(I.issue(o,r.value,t));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(I.issue(a))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(o=>(r.value=o,r.fallback=!0,r)):(r.value=n,r.fallback=!0,r)}});function Vi(e){return new kl({type:"transform",transform:e})}var Bi=v("ZodOptional",(e,t)=>{Pr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pi(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function An(e){return new Bi({type:"optional",innerType:e})}var wl=v("ZodExactOptional",(e,t)=>{Qs.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>pi(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Il(e){return new wl({type:"optional",innerType:e})}var Ol=v("ZodNullable",(e,t)=>{ec.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Du(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Cn(e){return new Ol({type:"nullable",innerType:e})}function nh(e){return An(Cn(e))}var zl=v("ZodDefault",(e,t)=>{tc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Pu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function El(e,t){return new zl({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():I.shallowClone(t)}})}var Dl=v("ZodPrefault",(e,t)=>{nc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Au(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Tl(e,t){return new Dl({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():I.shallowClone(t)}})}var Gi=v("ZodNonOptional",(e,t)=>{rc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Tu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Pl(e,t){return new Gi({type:"nonoptional",innerType:e,...I.normalizeParams(t)})}var Al=v("ZodSuccess",(e,t)=>{ic.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>yu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function rh(e){return new Al({type:"success",innerType:e})}var Cl=v("ZodCatch",(e,t)=>{oc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Cu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function jl(e,t){return new Cl({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Nl=v("ZodNaN",(e,t)=>{ac.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>gu(e,r,i,n)});function ih(e){return Hc(Nl,e)}var Zn=v("ZodPipe",(e,t)=>{Ar.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>ju(e,r,i,n),e.in=t.in,e.out=t.out});function xi(e,t){return new Zn({type:"pipe",in:e,out:t})}var Mn=v("ZodCodec",(e,t)=>{Zn.init(e,t),wn.init(e,t)});function oh(e,t,r){return new Mn({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function ah(e){let t=e._zod.def;return new Mn({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var Ul=v("ZodPreprocess",(e,t)=>{Zn.init(e,t),sc.init(e,t)}),Rl=v("ZodReadonly",(e,t)=>{cc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Nu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function Ll(e){return new Rl({type:"readonly",innerType:e})}var Fl=v("ZodTemplateLiteral",(e,t)=>{uc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>vu(e,r,i,n)});function sh(e,t){return new Fl({type:"template_literal",parts:e,...I.normalizeParams(t)})}var Zl=v("ZodLazy",(e,t)=>{pc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Ru(e,r,i,n),e.unwrap=()=>e._zod.def.getter()});function Ml(e){return new Zl({type:"lazy",getter:e})}var Vl=v("ZodPromise",(e,t)=>{dc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>Uu(e,r,i,n),e.unwrap=()=>e._zod.def.innerType});function ch(e){return new Vl({type:"promise",innerType:e})}var Bl=v("ZodFunction",(e,t)=>{lc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>xu(e,r,i,n)});function uh(e){return new Bl({type:"function",input:Array.isArray(e?.input)?_l(e?.input):e?.input??Rn(ct()),output:e?.output??ct()})}var Vn=v("ZodCustom",(e,t)=>{mc.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,i,n)=>$u(e,r,i,n)});function lh(e){let t=new F({check:"custom"});return t._zod.check=e,t}function dh(e,t){return qc(Vn,e??(()=>!0),t)}function Gl(e,t={}){return Kc(Vn,e,t)}function Hl(e,t){return Xc(e,t)}var ph=Yc,mh=Qc;function fh(e,t={}){let r=new Vn({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...I.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:r,path:[...r._zod.def.path??[]]})},r}var hh=(...e)=>eu({Codec:Mn,Boolean:Gt,String:Mt},...e);function gh(e){let t=Ml(()=>Zi([Tn(e),nl(),rl(),sl(),Rn(t),yl(Tn(),t)]));return t}function vh(e,t){return new Ul({type:"pipe",in:Vi(e),out:t})}var vx={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function _x(e){V({customError:e})}function yx(){return V().customError}var Jl;Jl||(Jl={});var z={...Dn,...hi,iso:Lt},$x=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function xx(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function bx(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===i){let n=r[1];if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function _h(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return z.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return z.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let o=bx(n,t),a=X(o,t);return t.refs.set(n,a),t.processing.delete(n),a}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return z.null();if(n.length===0)return z.never();if(n.length===1)return z.literal(n[0]);if(n.every(a=>typeof a=="string"))return z.enum(n);let o=n.map(a=>z.literal(a));return o.length<2?o[0]:z.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return z.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(o=>{let a={...e,type:o};return _h(a,t)});return n.length===0?z.never():n.length===1?n[0]:z.union(n)}if(!r)return z.any();let i;switch(r){case"string":{let n=z.string();if(e.format){let o=e.format;o==="email"?n=n.check(z.email()):o==="uri"||o==="uri-reference"?n=n.check(z.url()):o==="uuid"||o==="guid"?n=n.check(z.uuid()):o==="date-time"?n=n.check(z.iso.datetime()):o==="date"?n=n.check(z.iso.date()):o==="time"?n=n.check(z.iso.time()):o==="duration"?n=n.check(z.iso.duration()):o==="ipv4"?n=n.check(z.ipv4()):o==="ipv6"?n=n.check(z.ipv6()):o==="mac"?n=n.check(z.mac()):o==="cidr"?n=n.check(z.cidrv4()):o==="cidr-v6"?n=n.check(z.cidrv6()):o==="base64"?n=n.check(z.base64()):o==="base64url"?n=n.check(z.base64url()):o==="e164"?n=n.check(z.e164()):o==="jwt"?n=n.check(z.jwt()):o==="emoji"?n=n.check(z.emoji()):o==="nanoid"?n=n.check(z.nanoid()):o==="cuid"?n=n.check(z.cuid()):o==="cuid2"?n=n.check(z.cuid2()):o==="ulid"?n=n.check(z.ulid()):o==="xid"?n=n.check(z.xid()):o==="ksuid"&&(n=n.check(z.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),i=n;break}case"number":case"integer":{let n=r==="integer"?z.number().int():z.number();typeof e.minimum=="number"&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),i=n;break}case"boolean":{i=z.boolean();break}case"null":{i=z.null();break}case"object":{let n={},o=e.properties||{},a=new Set(e.required||[]);for(let[c,u]of Object.entries(o)){let l=X(u,t);n[c]=a.has(c)?l:l.optional()}if(e.propertyNames){let c=X(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?X(e.additionalProperties,t):z.any();if(Object.keys(n).length===0){i=z.record(c,u);break}let l=z.object(n).passthrough(),f=z.looseRecord(c,u);i=z.intersection(l,f);break}if(e.patternProperties){let c=e.patternProperties,u=Object.keys(c),l=[];for(let p of u){let _=X(c[p],t),b=z.string().regex(new RegExp(p));l.push(z.looseRecord(b,_))}let f=[];if(Object.keys(n).length>0&&f.push(z.object(n).passthrough()),f.push(...l),f.length===0)i=z.object({}).passthrough();else if(f.length===1)i=f[0];else{let p=z.intersection(f[0],f[1]);for(let _=2;_<f.length;_++)p=z.intersection(p,f[_]);i=p}break}let s=z.object(n);e.additionalProperties===!1?i=s.strict():typeof e.additionalProperties=="object"?i=s.catchall(X(e.additionalProperties,t)):i=s.passthrough();break}case"array":{let n=e.prefixItems,o=e.items;if(n&&Array.isArray(n)){let a=n.map(c=>X(c,t)),s=o&&typeof o=="object"&&!Array.isArray(o)?X(o,t):void 0;s?i=z.tuple(a).rest(s):i=z.tuple(a),typeof e.minItems=="number"&&(i=i.check(z.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(z.maxLength(e.maxItems)))}else if(Array.isArray(o)){let a=o.map(c=>X(c,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?X(e.additionalItems,t):void 0;s?i=z.tuple(a).rest(s):i=z.tuple(a),typeof e.minItems=="number"&&(i=i.check(z.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(z.maxLength(e.maxItems)))}else if(o!==void 0){let a=X(o,t),s=z.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=z.array(z.any());break}default:throw new Error(`Unsupported type: ${r}`)}return i}function X(e,t){if(typeof e=="boolean")return e?z.any():z.never();let r=_h(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>X(u,t)),c=z.union(s);r=i?z.intersection(r,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>X(u,t)),c=z.xor(s);r=i?z.intersection(r,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=i?r:z.any();else{let s=i?r:X(e.allOf[0],t),c=i?0:1;for(let u=c;u<e.allOf.length;u++)s=z.intersection(s,X(e.allOf[u],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=z.nullable(r)),e.readOnly===!0&&(r=z.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(n[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(n[s]=e[s]);for(let s of Object.keys(e))$x.has(s)||(n[s]=e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function yh(e,t){if(typeof e=="boolean")return e?z.any():z.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=xx(r,t?.defaultTarget),n=r.$defs||r.definitions||{},o={version:i,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??K};return X(r,o)}var Wl={};pe(Wl,{bigint:()=>Ix,boolean:()=>wx,date:()=>Ox,number:()=>kx,string:()=>Sx});function Sx(e){return vc(Mt,e)}function kx(e){return wc(Bt,e)}function wx(e){return Pc(Gt,e)}function Ix(e){return Cc(Ht,e)}function Ox(e){return Gc(Un,e)}V(Cr());var Jt={apiUrl:xe.string().url().optional(),token:xe.string().min(1).optional()};var Ji=require("fs"),bh=require("os"),Sh=require("path");M();var zx=xe.object(Jt).strict(),Ex=()=>(0,Sh.join)((0,bh.homedir)(),".shiprc"),$h=e=>e instanceof Error?e.message:String(e);function Hi(e){let t;try{t=(0,Ji.readFileSync)(e,"utf-8")}catch(i){throw k.config(`Failed to read ship config (${e}): ${$h(i)}`)}if(!t.trim())return{};let r;try{r=JSON.parse(t)}catch(i){throw k.config(`Invalid config in ${e}: ${$h(i)}`)}if(r===null||typeof r!="object"||Array.isArray(r))throw k.config(`Invalid config in ${e}: expected a JSON object`);return r}function xh(e,t){try{return zx.parse(e)}catch(r){if(r instanceof xe.ZodError){let i=r.issues[0];if(i.code==="unrecognized_keys"){let o=i.keys.filter(a=>a==="apiKey"||a==="deployToken");if(o.length>0){let a=o.map(s=>`"${s}"`).join(" and ");throw k.config(`Invalid config in ${t}: ${a} ${o.length>1?"are":"is"} no longer supported \u2014 the key is now "token". Run \`ship config\` to rewrite it.`)}}let n=i.path.length>0?` at ${i.path.join(".")}`:"";throw k.config(`Invalid config in ${t}${n}: ${i.message}`)}throw k.config(`Invalid config in ${t}`)}}function ql(e){let t=e||void 0;if(t)return xh(Hi(t),t);let r=Ex();return(0,Ji.existsSync)(r)?xh(Hi(r),r):{}}var Kl=Object.keys(Jt),Dx=()=>(0,wh.join)((0,kh.homedir)(),".shiprc"),Xl=tn.HINT_LENGTH;function Tx(e){let r=(e.startsWith(nn.PREFIX)?nn.PREFIX:tn.PREFIX).length+Xl;return e.length<r+Xl+1?"...":`${e.slice(0,r)}...${e.slice(-Xl)}`}function Px(e){if(!(0,Wt.existsSync)(e))return{};try{return Hi(e)}catch(t){throw ce(t)?k.config(`${t.message} \u2014 the file was left unchanged`):t}}async function Oh(e={}){let{noColor:t}=e,r=e.configFile||Dx(),i=p=>t?p:Le(p),n=p=>t?p:an(p),o=Px(r),a=typeof o.token=="string"?o.token:void 0,s=Object.keys(o).filter(p=>!Kl.includes(p)),c=(0,Ih.createInterface)({input:process.stdin,output:process.stdout});console.log(""),console.log(` ${i("Create a free API key at")} ${Zd}`),console.log("");let u=a?` Token (${i(Tx(a))}): `:" Token: ",l;try{l=(await c.question(u)).trim()}finally{c.close()}l&&Ye(l);let f={};for(let p of Kl)o[p]!==void 0&&(f[p]=o[p]);l&&(f.token=l),s.length>0&&ft(`dropped ${s.map(p=>`"${p}"`).join(", ")} \u2014 a ship config holds only ${Kl.join(" and ")}`,!1,t),(0,Wt.writeFileSync)(r,`${JSON.stringify(f,null,2)}
229
229
  `,{mode:384}),(0,Wt.chmodSync)(r,384),console.log(`
230
230
  ${n("saved to")} ${i(r)}
231
- `)}M();M();Wi();var Cx=xe.object(Jt).strict(),jx={apiUrl:rn.API_URL,token:rn.TOKEN};function Bn(){if(qt()!=="node")return{};let e={apiUrl:process.env[rn.API_URL]||void 0,token:process.env[rn.TOKEN]||void 0};try{return Cx.parse(e)}catch(t){if(t instanceof xe.ZodError){let r=t.issues[0],i=r.path[0],n=(i&&jx[i])??"SHIP environment configuration";throw k.config(`Invalid ${n}: ${r.message}`)}throw k.config("Invalid environment configuration")}}M();M();M();var qi=class{constructor(){this.handlers=new Map}on(t,r){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t)?.add(r)}off(t,r){let i=this.handlers.get(t);i&&(i.delete(r),i.size===0&&this.handlers.delete(t))}emit(t,...r){let i=this.handlers.get(t);if(!i)return;let n=Array.from(i);for(let o of n)try{o(...r)}catch(a){i.delete(o),t!=="error"&&setTimeout(()=>{let s=a instanceof Error?a:new Error(String(a));this.emit("error",s,String(t))},0)}}};var Nx=3e4,Ux=2,Rx=300,Lx=2e3,Fx=new Set([500,502,503,504]);function Zx(e,t){return new Promise((r,i)=>{if(t?.aborted){i(t.reason);return}let n=()=>{clearTimeout(a),t?.removeEventListener("abort",o)},o=()=>{n(),i(t?.reason)},a=setTimeout(()=>{n(),r()},e);t?.addEventListener("abort",o)})}var Eh=3e5,Mx=3e5,Vx=Eh+Mx,Ki=class extends qi{constructor(r){super();this.globalHeaders={};this.apiUrl=r.apiUrl||Ld,this.getAuthHeadersCallback=r.getAuthHeaders,this.session=r.session??!1,this.caller=r.caller,this.timeout=r.timeout??Nx,this.maxRetries=Math.max(0,r.maxRetries??Ux),this.fetch=r.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:r.deployEndpoint||Z.DEPLOYMENTS,timeout:r.timeout??Eh,buildTimeout:r.timeout??Vx}}setGlobalHeaders(r){this.globalHeaders=r}async executeRequest(r,i,n,o=this.timeout){for(let a=0;;a++)try{return await this.attemptOnce(r,i,n,o)}catch(s){let c=k.fromFetchError(s,n);if(a>=this.maxRetries||!this.isRetryable(c,i))throw this.emit("error",c,r),c;this.emit("retry",c,r,a+1);let u=Math.min(Lx,Rx*2**a);try{await Zx(Math.random()*u,i.signal)}catch(l){let f=k.fromFetchError(l,n);throw this.emit("error",f,r),f}}}isRetryable(r,i){if(i.signal?.aborted||r.isType(P.Maintenance)||r.isType(P.Cancelled)||!(r.isNetworkError()||r.status!==void 0&&Fx.has(r.status)))return!1;let o=(i.method??"GET").toUpperCase();return o==="GET"||o==="HEAD"?!0:o==="PUT"||o==="DELETE"?!1:this.hasIdempotencyKey(i.headers)}hasIdempotencyKey(r){if(!r)return!1;let i=dt.HEADER.toLowerCase();return Object.keys(r).some(n=>n.toLowerCase()===i)}async attemptOnce(r,i,n,o=this.timeout){let a=()=>{};try{let s=await this.mergeHeaders(i.headers),c=this.createTimeoutSignal(i.signal,o);a=c.cleanup;let u={...i,headers:s,credentials:this.session&&!s.Authorization?"include":void 0,signal:c.signal};this.emit("request",r,u);let l=await this.fetch(r,u);if(a(),!l.ok)throw await k.fromHttpResponse(l,n);return this.emit("response",this.safeClone(l),r),{data:await this.parseResponse(this.safeClone(l)),status:l.status}}catch(s){throw a(),k.fromFetchError(s,n)}}async request(r,i,n,o){let{data:a}=await this.executeRequest(`${this.apiUrl}${r}`,i,n,o);return a}async requestWithStatus(r,i,n){return this.executeRequest(`${this.apiUrl}${r}`,i,n)}async mergeHeaders(r={}){return{...this.globalHeaders,...this.caller?{[Yt.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...r}}createTimeoutSignal(r,i=this.timeout){let n=new AbortController,o=setTimeout(()=>n.abort(new DOMException(`Timed out after ${i}ms`,"TimeoutError")),i),a=r?()=>n.abort(r.reason):void 0;return r&&a&&(r.addEventListener("abort",a),r.aborted&&n.abort(r.reason)),{signal:n.signal,cleanup:()=>{clearTimeout(o),r&&a&&r.removeEventListener("abort",a)}}}safeClone(r){try{return r.clone()}catch{return r}}async parseResponse(r){if(!(r.headers.get("Content-Length")==="0"||r.status===204))return r.json()}};M();M();async function Dh(e,t={}){let{labels:r,via:i,password:n,ttl:o,flags:a,captcha:s}=t,c=new FormData,u=[];for(let l of e){if(typeof l.content=="string"||l.content===null||l.content===void 0)throw k.file(`Unsupported file.content type: ${l.path}`,{filePath:l.path});if(!l.md5)throw k.file(`File missing md5 checksum: ${l.path}`,{filePath:l.path});c.append(se.FILES,new File([l.content],l.path,{type:"application/octet-stream"})),u.push(l.md5)}return c.append(se.CHECKSUMS,JSON.stringify(u)),r&&r.length>0&&c.append(se.LABELS,JSON.stringify(r)),i&&c.append(se.VIA,i),n&&c.append(se.PASSWORD,n),o!==void 0&&c.append(se.TTL,String(o)),a?.build&&c.append(se.BUILD,"true"),a?.prerender&&c.append(se.PRERENDER,"true"),a?.spa&&c.append(se.SPA,"true"),a?.buildCommand&&c.append(se.BUILD_COMMAND,a.buildCommand),a?.outputDir&&c.append(se.OUTPUT_DIR,a.outputDir),s&&c.append(se.CAPTCHA,s),c}M();Yl();async function Jx(){let e=JSON.stringify(Nd,null,2),t;typeof Buffer<"u"?t=Buffer.from(e,"utf-8"):t=new Blob([e],{type:"application/json"});let{md5:r}=await Xi(t);return{path:De,content:t,size:e.length,md5:r}}async function Wx(e,t,r){let i=e.find(s=>s.path===er.INDEX_FILE||s.path===`/${er.INDEX_FILE}`);if(!i||i.size>er.MAX_INDEX_BYTES)return!1;let n;if(typeof Buffer<"u"&&Buffer.isBuffer(i.content))n=i.content.toString("utf-8");else if(typeof Blob<"u"&&i.content instanceof Blob)n=await i.content.text();else if(typeof File<"u"&&i.content instanceof File)n=await i.content.text();else return!1;let o={files:e.map(s=>s.path),index:n};return(await t.request(Z.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),signal:r??null},"SPA check")).isSPA}async function Ch(e,t,r){if(r.spaDetect===!1||r.spa||r.build||r.prerender||e.some(i=>i.path===De))return e;try{if(await Wx(e,t,r.signal)){let n=await Jx();return[...e,n]}}catch(i){if(r.signal?.aborted)throw i}return e}M();M();function Gn(e){if(e==null)return;if(e.length===0)return e;if(e.length>Re.MAX_COUNT)throw k.validation(`Maximum ${Re.MAX_COUNT} labels allowed`);let t=e.map((i,n)=>{if(typeof i!="string")throw k.validation(`Label at index ${n} must be a string`);let o=i.trim().toLowerCase();if(o.length<Re.MIN_LENGTH)throw k.validation(`Labels must be at least ${Re.MIN_LENGTH} characters long`);if(o.length>Re.MAX_LENGTH)throw k.validation(`Labels must be no more than ${Re.MAX_LENGTH} characters long`);if(!Vd.test(o))throw k.validation(`Labels must start and end with alphanumeric characters, with optional separators (${Re.SEPARATORS}) between segments`);return o}),r=[...new Set(t)];if(r.length!==t.length)throw k.validation("Duplicate labels are not allowed");return r}async function jh(e){let t=e.find(n=>n.path===De||n.path===`/${De}`);if(!t)return;let r=t.content,i=typeof r.text=="function"?await r.text():t.content.toString("utf8");Ud(i)}var Yi={"Content-Type":"application/json"},qx="sdk";function Ql(e){let t=new URLSearchParams;e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.cursor!==void 0&&t.set("cursor",e.cursor);let r=t.toString();return r?`?${r}`:""}function Nh(e){let{getApi:t,processInput:r}=e;return{upload:async(i,n={})=>{if(!r)throw k.config("processInput function is not provided.");let o=t(),a=await r(i,n),s=await Ch(a,o,n);if(!s.length)throw k.business("No files to deploy");for(let E of s)if(!E.md5)throw k.file(`MD5 checksum missing for file: ${E.path}`,{filePath:E.path});jo(n.password);let c=Co(n.ttl),u=Pd(n.idempotencyKey),l=Gn(n.labels);await jh(s);let f=Bd(n.buildCommand),p=Gd(n.outputDir),_=n.build||n.prerender||n.spa?{build:n.build,prerender:n.prerender,spa:n.spa,buildCommand:f,outputDir:p}:void 0,b=await Dh(s,{labels:l,via:n.via??qx,password:n.password,ttl:c,flags:_,captcha:n.captcha});return o.request(o.deploy.endpoint,{method:"POST",body:b,...u?{headers:{[dt.HEADER]:u}}:{},signal:n.signal||null},"Deploy",n.build||n.prerender?o.deploy.buildTimeout:o.deploy.timeout)},list:async i=>t().request(`${Z.DEPLOYMENTS}${Ql(i)}`,{method:"GET"},"List deployments"),get:async i=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"GET"},"Get deployment"),set:async(i,n)=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"PATCH",headers:Yi,body:JSON.stringify({labels:Gn(n.labels)})},"Update deployment labels"),delete:async i=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"DELETE"},"Delete deployment")}}function Uh(e){let{getApi:t}=e;return{set:async(r,i={})=>{let n=Gn(i.labels),o={};i.deployment&&(o.deployment=i.deployment),n!==void 0&&(o.labels=n);let{data:a,status:s}=await t().requestWithStatus(Z.DOMAIN(encodeURIComponent(r)),{method:"PUT",headers:Yi,body:JSON.stringify(o)},"Set domain");return{...a,isCreate:s===201}},list:async r=>t().request(`${Z.DOMAINS}${Ql(r)}`,{method:"GET"},"List domains"),get:async r=>t().request(Z.DOMAIN(encodeURIComponent(r)),{method:"GET"},"Get domain"),delete:async r=>t().request(Z.DOMAIN(encodeURIComponent(r)),{method:"DELETE"},"Delete domain"),verify:async r=>t().request(Z.DOMAIN_VERIFY(encodeURIComponent(r)),{method:"POST"},"Verify domain"),validate:async r=>t().request(Z.DOMAINS_VALIDATE,{method:"POST",headers:Yi,body:JSON.stringify({domain:r})},"Validate domain"),dns:async r=>t().request(Z.DOMAIN_DNS(encodeURIComponent(r)),{method:"GET"},"Get domain DNS"),records:async r=>t().request(Z.DOMAIN_RECORDS(encodeURIComponent(r)),{method:"GET"},"Get domain records"),share:async r=>t().request(Z.DOMAIN_SHARE(encodeURIComponent(r)),{method:"GET"},"Get domain share")}}function Rh(e){let{getApi:t}=e;return{get:async()=>t().request(Z.ACCOUNT,{method:"GET"},"Get account")}}function Lh(e){let{getApi:t}=e;return{create:async(r={})=>{let i=Co(r.ttl),n=Gn(r.labels),o={};return i!==void 0&&(o.ttl=i),n!==void 0&&(o.labels=n),t().request(Z.TOKENS,{method:"POST",headers:Yi,body:JSON.stringify(o)},"Create token")},list:async r=>t().request(`${Z.TOKENS}${Ql(r)}`,{method:"GET"},"List tokens"),get:async r=>t().request(Z.TOKEN(encodeURIComponent(r)),{method:"GET"},"Get token"),delete:async r=>t().request(Z.TOKEN(encodeURIComponent(r)),{method:"DELETE"},"Delete token")}}var Qi=class{constructor(t={}){this.credential=null;if(t={...t,apiUrl:t.apiUrl||void 0,token:t.token||void 0,caller:t.caller||void 0},this.clientOptions=t,t.caller!==void 0&&Rd(t.caller),t.token&&t.session)throw k.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(Ye(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new Ki({...t,getAuthHeaders:()=>this.getAuthHeaders()});let r={getApi:()=>this.http};this.deployments=Nh({...r,processInput:async(i,n)=>this.processInput(i,n,await this.getLimits({signal:n.signal}))}),this.domains=Uh(r),this.account=Rh(r),this.tokens=Lh(r)}async ping(){return this.http.request(Z.PING,{method:"GET"},"Ping")}async deploy(t,r){return this.deployments.upload(t,r)}async whoami(){return this.account.get()}async getLimits(t={}){return this.http.request(Z.LIMITS,{method:"GET",signal:t.signal??null},"Get limits")}on(t,r){this.http.on(t,r)}off(t,r){this.http.off(t,r)}setHeaders(t){this.http.setGlobalHeaders(t)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(t){if(this.clientOptions.session)throw k.config("Provide either `token` or `session`, not both.");if(typeof t=="string"){if(!t)throw k.business("Invalid token provided. Token must be a non-empty string.");Ye(t),this.credential=t;return}if(typeof t!="function")throw k.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=t}async getAuthHeaders(){if(this.credential===null)return{};let t=typeof this.credential=="function"?await this.credential():this.credential;if(!t)throw k.authentication("Token provider returned no token.");if(typeof t!="string")throw k.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${t}`}}};Wi();var to=class extends Qi{constructor(t={}){if(qt()!=="node")throw k.business("Node.js Ship class can only be used in Node.js environment.");let r=Bn();super({...t,apiUrl:t.apiUrl||r.apiUrl,token:t.token||(t.session?void 0:r.token)})}async deploy(t,r){return super.deploy(t,r)}async processInput(t,r,i){let n=typeof t=="string"?[t]:t;if(!Array.isArray(n)||!n.every(a=>typeof a=="string"))throw k.business("Invalid input type for Node.js environment. Expected string or string[].");if(n.length===0)throw k.business("No files to deploy.");let{processFilesForNode:o}=await Promise.resolve().then(()=>(ig(),rg));return o(n,r,i)}};function og(e,t,r){return{apiUrl:e.apiUrl||t.apiUrl||r.apiUrl,token:e.token||t.token||r.token}}function ag(e={}){let t=og(e,Bn(),ql(e.config));return t.apiUrl&&tr(t.apiUrl),new to(t)}function no(e){let t={};try{t=ql(e.config)}catch{}let r=og(e,Bn(),t).token;return typeof r=="string"?r:void 0}M();function sg(e){return ce(e)?e:e instanceof Error?k.business(e.message):k.business(String(e??"Unknown error"))}var ro="pass --token, set SHIP_TOKEN, or run ship config";function cg(e,t){return e.isAuthError()?t?.token?"authentication failed: invalid or expired token":`authentication required: ${ro}`:e.isType(P.Timeout)?e.message:e.isNetworkError()?"network error: could not reach the API. check your internet connection":e.isType(P.Maintenance)?`${e.message.replace(/\.$/,"")} \u2014 check https://status.shipstatic.com`:e.isClientError()?e.message:`${e.message.replace(/\.$/,"")} \u2014 try again, or check https://status.shipstatic.com`}M();function od(e,t){return e[t]}var ab={[Dd.DELETING]:"served until cleanup completes"},sb={upload:"uploaded",create:"created",delete:"deleted",verify:"verification queued"};function dg(e,t){let{operation:r,resource:i}=t;if(!i||e===null||typeof e!="object")return null;let n=r==="set"?od(e,"isCreate")?"created":"updated":sb[r];if(!n)return null;let o=od(e,i);if(typeof o!="string")return null;let a=od(e,"status"),s=typeof a=="string"?ab[a]:void 0;return`${o} ${i} ${s?`${a} \u2014 ${s}`:n}`}function pg(e,t,r){if(r.json||r.quiet)return;let i=dg(e,t);i&&Se(i,!1,r.noColor)}function cb(e,t){let{noColor:r}=t;if(e.deployments.length===0){console.log("no deployments found"),console.log();return}let i=["deployment","labels","files","size","created","via"];console.log(ln(e.deployments,i,r)),sd(e.cursor,r)}function sd(e,t){e&&_e(`more results available \u2014 rerun with --cursor ${e}`,!1,t)}function ub(e,t){let{noColor:r}=t;if(e.domains.length===0){console.log("no domains found"),console.log();return}let i=["domain","status","deployment","labels","linked","links","created"];console.log(ln(e.domains,i,r)),sd(e.cursor,r)}function ug(e,t){let{noColor:r}=t,{_dnsRecords:i,_shareUrl:n,isCreate:o,...a}=e;i&&i.length>0&&(console.log(),_e("DNS records to configure:",!1,r),i.forEach(s=>{console.log(` ${s.type}: ${s.name} \u2192 ${s.value}`)})),n&&(console.log(),_e(`Setup instructions: ${n}`,!1,r)),console.log(Fe(a,r)),db(a,r)}var lb={[en.LIVE]:()=>null,[en.UNVERIFIED]:e=>`DNS for ${e} is not pointing here yet. See the records to configure: ship domains records ${e}`,[en.UNLINKED]:e=>`Nothing is linked to ${e} yet. Point it at a deployment: ship domains set ${e} <deployment>`,[en.PAUSED]:e=>`${e} is paused: your plan has no room for it, so it serves nothing. Delete another domain, or upgrade your plan.`};function db(e,t){let r=lb[e.status]?.(e.domain);r&&(console.log(),_e(r,!1,t))}function pb(e,t){let{noColor:r}=t;_e(`It runs in the background. Check with: ship domains get ${e.domain}`,!1,r),e._deployment===null&&(console.log(),_e(`Nothing is linked to ${e.domain} yet. Once it verifies, point it at a deployment: ship domains set ${e.domain} <deployment>`,!1,r))}function ad(e,t){let{noColor:r}=t;console.log(Fe(e,r));let i=e.claim;if(i){let n=e.expires?Md(e.expires):null;console.log(`IMPORTANT: this deployment ${n?`expires in ${n}`:"will expire"}, claim it to keep permanently:
231
+ `)}M();M();Wi();var Cx=xe.object(Jt).strict(),jx={apiUrl:rn.API_URL,token:rn.TOKEN};function Bn(){if(qt()!=="node")return{};let e={apiUrl:process.env[rn.API_URL]||void 0,token:process.env[rn.TOKEN]||void 0};try{return Cx.parse(e)}catch(t){if(t instanceof xe.ZodError){let r=t.issues[0],i=r.path[0],n=(i&&jx[i])??"SHIP environment configuration";throw k.config(`Invalid ${n}: ${r.message}`)}throw k.config("Invalid environment configuration")}}M();M();M();var qi=class{constructor(){this.handlers=new Map}on(t,r){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t)?.add(r)}off(t,r){let i=this.handlers.get(t);i&&(i.delete(r),i.size===0&&this.handlers.delete(t))}emit(t,...r){let i=this.handlers.get(t);if(!i)return;let n=Array.from(i);for(let o of n)try{o(...r)}catch(a){i.delete(o),t!=="error"&&setTimeout(()=>{let s=a instanceof Error?a:new Error(String(a));this.emit("error",s,String(t))},0)}}};var Nx=3e4,Ux=2,Rx=300,Lx=2e3,Fx=new Set([500,502,503,504]);function Zx(e,t){return new Promise((r,i)=>{if(t?.aborted){i(t.reason);return}let n=()=>{clearTimeout(a),t?.removeEventListener("abort",o)},o=()=>{n(),i(t?.reason)},a=setTimeout(()=>{n(),r()},e);t?.addEventListener("abort",o)})}var Eh=3e5,Mx=3e5,Vx=Eh+Mx,Ki=class extends qi{constructor(r){super();this.globalHeaders={};this.apiUrl=r.apiUrl||Ld,this.getAuthHeadersCallback=r.getAuthHeaders,this.session=r.session??!1,this.caller=r.caller,this.timeout=r.timeout??Nx,this.maxRetries=Math.max(0,r.maxRetries??Ux),this.fetch=r.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:r.deployEndpoint||Z.DEPLOYMENTS,timeout:r.timeout??Eh,buildTimeout:r.timeout??Vx}}setGlobalHeaders(r){this.globalHeaders=r}async executeRequest(r,i,n,o=this.timeout){for(let a=0;;a++)try{return await this.attemptOnce(r,i,n,o)}catch(s){let c=k.fromFetchError(s,n);if(a>=this.maxRetries||!this.isRetryable(c,i))throw this.emit("error",c,r),c;this.emit("retry",c,r,a+1);let u=Math.min(Lx,Rx*2**a);try{await Zx(Math.random()*u,i.signal)}catch(l){let f=k.fromFetchError(l,n);throw this.emit("error",f,r),f}}}isRetryable(r,i){if(i.signal?.aborted||r.isType(P.Maintenance)||r.isType(P.Cancelled)||!(r.isNetworkError()||r.status!==void 0&&Fx.has(r.status)))return!1;let o=(i.method??"GET").toUpperCase();return o==="GET"||o==="HEAD"?!0:o==="PUT"||o==="DELETE"?!1:this.hasIdempotencyKey(i.headers)}hasIdempotencyKey(r){if(!r)return!1;let i=dt.HEADER.toLowerCase();return Object.keys(r).some(n=>n.toLowerCase()===i)}async attemptOnce(r,i,n,o=this.timeout){let a=()=>{};try{let s=await this.mergeHeaders(i.headers),c=this.createTimeoutSignal(i.signal,o);a=c.cleanup;let u={...i,headers:s,credentials:this.session&&!s.Authorization?"include":void 0,signal:c.signal};this.emit("request",r,u);let l=await this.fetch(r,u);if(a(),!l.ok)throw await k.fromHttpResponse(l,n);return this.emit("response",this.safeClone(l),r),{data:await this.parseResponse(this.safeClone(l)),status:l.status}}catch(s){throw a(),k.fromFetchError(s,n)}}async request(r,i,n,o){let{data:a}=await this.executeRequest(`${this.apiUrl}${r}`,i,n,o);return a}async requestWithStatus(r,i,n){return this.executeRequest(`${this.apiUrl}${r}`,i,n)}async mergeHeaders(r={}){return{...this.globalHeaders,...this.caller?{[Yt.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...r}}createTimeoutSignal(r,i=this.timeout){let n=new AbortController,o=setTimeout(()=>n.abort(new DOMException(`Timed out after ${i}ms`,"TimeoutError")),i),a=r?()=>n.abort(r.reason):void 0;return r&&a&&(r.addEventListener("abort",a),r.aborted&&n.abort(r.reason)),{signal:n.signal,cleanup:()=>{clearTimeout(o),r&&a&&r.removeEventListener("abort",a)}}}safeClone(r){try{return r.clone()}catch{return r}}async parseResponse(r){if(!(r.headers.get("Content-Length")==="0"||r.status===204))return r.json()}};M();M();async function Dh(e,t={}){let{labels:r,via:i,password:n,ttl:o,flags:a,captcha:s}=t,c=new FormData,u=[];for(let l of e){if(typeof l.content=="string"||l.content===null||l.content===void 0)throw k.file(`Unsupported file.content type: ${l.path}`,{filePath:l.path});if(!l.md5)throw k.file(`File missing md5 checksum: ${l.path}`,{filePath:l.path});c.append(se.FILES,new File([l.content],l.path,{type:"application/octet-stream"})),u.push(l.md5)}return c.append(se.CHECKSUMS,JSON.stringify(u)),r&&r.length>0&&c.append(se.LABELS,JSON.stringify(r)),i&&c.append(se.VIA,i),n&&c.append(se.PASSWORD,n),o!==void 0&&c.append(se.TTL,String(o)),a?.build&&c.append(se.BUILD,"true"),a?.prerender&&c.append(se.PRERENDER,"true"),a?.spa&&c.append(se.SPA,"true"),a?.buildCommand&&c.append(se.BUILD_COMMAND,a.buildCommand),a?.outputDir&&c.append(se.OUTPUT_DIR,a.outputDir),s&&c.append(se.CAPTCHA,s),c}M();Yl();async function Jx(){let e=JSON.stringify(Nd,null,2),t;typeof Buffer<"u"?t=Buffer.from(e,"utf-8"):t=new Blob([e],{type:"application/json"});let{md5:r}=await Xi(t);return{path:De,content:t,size:e.length,md5:r}}async function Wx(e,t,r){let i=e.find(s=>s.path===er.INDEX_FILE||s.path===`/${er.INDEX_FILE}`);if(!i||i.size>er.MAX_INDEX_BYTES)return!1;let n;if(typeof Buffer<"u"&&Buffer.isBuffer(i.content))n=i.content.toString("utf-8");else if(typeof Blob<"u"&&i.content instanceof Blob)n=await i.content.text();else if(typeof File<"u"&&i.content instanceof File)n=await i.content.text();else return!1;let o={files:e.map(s=>s.path),index:n};return(await t.request(Z.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),signal:r??null},"SPA check")).isSPA}async function Ch(e,t,r){return r.spaDetect===!1||r.spa||r.build||r.prerender||e.some(i=>i.path===De)?e:await Wx(e,t,r.signal)?[...e,await Jx()]:e}M();M();function Gn(e){if(e==null)return;if(e.length===0)return e;if(e.length>Re.MAX_COUNT)throw k.validation(`Maximum ${Re.MAX_COUNT} labels allowed`);let t=e.map((i,n)=>{if(typeof i!="string")throw k.validation(`Label at index ${n} must be a string`);let o=i.trim().toLowerCase();if(o.length<Re.MIN_LENGTH)throw k.validation(`Labels must be at least ${Re.MIN_LENGTH} characters long`);if(o.length>Re.MAX_LENGTH)throw k.validation(`Labels must be no more than ${Re.MAX_LENGTH} characters long`);if(!Vd.test(o))throw k.validation(`Labels must start and end with alphanumeric characters, with optional separators (${Re.SEPARATORS}) between segments`);return o}),r=[...new Set(t)];if(r.length!==t.length)throw k.validation("Duplicate labels are not allowed");return r}async function jh(e){let t=e.find(n=>n.path===De||n.path===`/${De}`);if(!t)return;let r=t.content,i=typeof r.text=="function"?await r.text():t.content.toString("utf8");Ud(i)}var Yi={"Content-Type":"application/json"},qx="sdk";function Ql(e){let t=new URLSearchParams;e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.cursor!==void 0&&t.set("cursor",e.cursor);let r=t.toString();return r?`?${r}`:""}function Nh(e){let{getApi:t,processInput:r}=e;return{upload:async(i,n={})=>{if(!r)throw k.config("processInput function is not provided.");let o=t(),a=await r(i,n),s=await Ch(a,o,n);if(!s.length)throw k.business("No files to deploy");for(let E of s)if(!E.md5)throw k.file(`MD5 checksum missing for file: ${E.path}`,{filePath:E.path});jo(n.password);let c=Co(n.ttl),u=Pd(n.idempotencyKey),l=Gn(n.labels);await jh(s);let f=Bd(n.buildCommand),p=Gd(n.outputDir),_=n.build||n.prerender||n.spa?{build:n.build,prerender:n.prerender,spa:n.spa,buildCommand:f,outputDir:p}:void 0,b=await Dh(s,{labels:l,via:n.via??qx,password:n.password,ttl:c,flags:_,captcha:n.captcha});return o.request(o.deploy.endpoint,{method:"POST",body:b,...u?{headers:{[dt.HEADER]:u}}:{},signal:n.signal||null},"Deploy",n.build||n.prerender?o.deploy.buildTimeout:o.deploy.timeout)},list:async i=>t().request(`${Z.DEPLOYMENTS}${Ql(i)}`,{method:"GET"},"List deployments"),get:async i=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"GET"},"Get deployment"),set:async(i,n)=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"PATCH",headers:Yi,body:JSON.stringify({labels:Gn(n.labels)})},"Update deployment labels"),delete:async i=>t().request(Z.DEPLOYMENT(encodeURIComponent(i)),{method:"DELETE"},"Delete deployment")}}function Uh(e){let{getApi:t}=e;return{set:async(r,i={})=>{let n=Gn(i.labels),o={};i.deployment&&(o.deployment=i.deployment),n!==void 0&&(o.labels=n);let{data:a,status:s}=await t().requestWithStatus(Z.DOMAIN(encodeURIComponent(r)),{method:"PUT",headers:Yi,body:JSON.stringify(o)},"Set domain");return{...a,isCreate:s===201}},list:async r=>t().request(`${Z.DOMAINS}${Ql(r)}`,{method:"GET"},"List domains"),get:async r=>t().request(Z.DOMAIN(encodeURIComponent(r)),{method:"GET"},"Get domain"),delete:async r=>t().request(Z.DOMAIN(encodeURIComponent(r)),{method:"DELETE"},"Delete domain"),verify:async r=>t().request(Z.DOMAIN_VERIFY(encodeURIComponent(r)),{method:"POST"},"Verify domain"),validate:async r=>t().request(Z.DOMAINS_VALIDATE,{method:"POST",headers:Yi,body:JSON.stringify({domain:r})},"Validate domain"),dns:async r=>t().request(Z.DOMAIN_DNS(encodeURIComponent(r)),{method:"GET"},"Get domain DNS"),records:async r=>t().request(Z.DOMAIN_RECORDS(encodeURIComponent(r)),{method:"GET"},"Get domain records"),share:async r=>t().request(Z.DOMAIN_SHARE(encodeURIComponent(r)),{method:"GET"},"Get domain share")}}function Rh(e){let{getApi:t}=e;return{get:async()=>t().request(Z.ACCOUNT,{method:"GET"},"Get account")}}function Lh(e){let{getApi:t}=e;return{create:async(r={})=>{let i=Co(r.ttl),n=Gn(r.labels),o={};return i!==void 0&&(o.ttl=i),n!==void 0&&(o.labels=n),t().request(Z.TOKENS,{method:"POST",headers:Yi,body:JSON.stringify(o)},"Create token")},list:async r=>t().request(`${Z.TOKENS}${Ql(r)}`,{method:"GET"},"List tokens"),get:async r=>t().request(Z.TOKEN(encodeURIComponent(r)),{method:"GET"},"Get token"),delete:async r=>t().request(Z.TOKEN(encodeURIComponent(r)),{method:"DELETE"},"Delete token")}}var Qi=class{constructor(t={}){this.credential=null;if(t={...t,apiUrl:t.apiUrl||void 0,token:t.token||void 0,caller:t.caller||void 0},this.clientOptions=t,t.caller!==void 0&&Rd(t.caller),t.token&&t.session)throw k.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(Ye(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new Ki({...t,getAuthHeaders:()=>this.getAuthHeaders()});let r={getApi:()=>this.http};this.deployments=Nh({...r,processInput:async(i,n)=>this.processInput(i,n,await this.getLimits({signal:n.signal}))}),this.domains=Uh(r),this.account=Rh(r),this.tokens=Lh(r)}async ping(){return this.http.request(Z.PING,{method:"GET"},"Ping")}async deploy(t,r){return this.deployments.upload(t,r)}async whoami(){return this.account.get()}async getLimits(t={}){return this.http.request(Z.LIMITS,{method:"GET",signal:t.signal??null},"Get limits")}on(t,r){this.http.on(t,r)}off(t,r){this.http.off(t,r)}setHeaders(t){this.http.setGlobalHeaders(t)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(t){if(this.clientOptions.session)throw k.config("Provide either `token` or `session`, not both.");if(typeof t=="string"){if(!t)throw k.business("Invalid token provided. Token must be a non-empty string.");Ye(t),this.credential=t;return}if(typeof t!="function")throw k.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=t}async getAuthHeaders(){if(this.credential===null)return{};let t=typeof this.credential=="function"?await this.credential():this.credential;if(!t)throw k.authentication("Token provider returned no token.");if(typeof t!="string")throw k.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${t}`}}};Wi();var to=class extends Qi{constructor(t={}){if(qt()!=="node")throw k.business("Node.js Ship class can only be used in Node.js environment.");let r=Bn();super({...t,apiUrl:t.apiUrl||r.apiUrl,token:t.token||(t.session?void 0:r.token)})}async deploy(t,r){return super.deploy(t,r)}async processInput(t,r,i){let n=typeof t=="string"?[t]:t;if(!Array.isArray(n)||!n.every(a=>typeof a=="string"))throw k.business("Invalid input type for Node.js environment. Expected string or string[].");if(n.length===0)throw k.business("No files to deploy.");let{processFilesForNode:o}=await Promise.resolve().then(()=>(ig(),rg));return o(n,r,i)}};function og(e,t,r){return{apiUrl:e.apiUrl||t.apiUrl||r.apiUrl,token:e.token||t.token||r.token}}function ag(e={}){let t=og(e,Bn(),ql(e.config));return t.apiUrl&&tr(t.apiUrl),new to(t)}function no(e){let t={};try{t=ql(e.config)}catch{}let r=og(e,Bn(),t).token;return typeof r=="string"?r:void 0}M();function sg(e){return ce(e)?e:e instanceof Error?k.business(e.message):k.business(String(e??"Unknown error"))}var ro="pass --token, set SHIP_TOKEN, or run ship config";function cg(e,t){return e.isAuthError()?t?.token?"authentication failed: invalid or expired token":`authentication required: ${ro}`:e.isType(P.Timeout)?e.message:e.isNetworkError()?"network error: could not reach the API. check your internet connection":e.isType(P.Maintenance)?`${e.message.replace(/\.$/,"")} \u2014 check https://status.shipstatic.com`:e.isClientError()?e.message:`${e.message.replace(/\.$/,"")} \u2014 try again, or check https://status.shipstatic.com`}M();function od(e,t){return e[t]}var ab={[Dd.DELETING]:"served until cleanup completes"},sb={upload:"uploaded",create:"created",delete:"deleted",verify:"verification queued"};function dg(e,t){let{operation:r,resource:i}=t;if(!i||e===null||typeof e!="object")return null;let n=r==="set"?od(e,"isCreate")?"created":"updated":sb[r];if(!n)return null;let o=od(e,i);if(typeof o!="string")return null;let a=od(e,"status"),s=typeof a=="string"?ab[a]:void 0;return`${o} ${i} ${s?`${a} \u2014 ${s}`:n}`}function pg(e,t,r){if(r.json||r.quiet)return;let i=dg(e,t);i&&Se(i,!1,r.noColor)}function cb(e,t){let{noColor:r}=t;if(e.deployments.length===0){console.log("no deployments found"),console.log();return}let i=["deployment","labels","files","size","created","via"];console.log(ln(e.deployments,i,r)),sd(e.cursor,r)}function sd(e,t){e&&_e(`more results available \u2014 rerun with --cursor ${e}`,!1,t)}function ub(e,t){let{noColor:r}=t;if(e.domains.length===0){console.log("no domains found"),console.log();return}let i=["domain","status","deployment","labels","linked","links","created"];console.log(ln(e.domains,i,r)),sd(e.cursor,r)}function ug(e,t){let{noColor:r}=t,{_dnsRecords:i,_shareUrl:n,isCreate:o,...a}=e;i&&i.length>0&&(console.log(),_e("DNS records to configure:",!1,r),i.forEach(s=>{console.log(` ${s.type}: ${s.name} \u2192 ${s.value}`)})),n&&(console.log(),_e(`Setup instructions: ${n}`,!1,r)),console.log(Fe(a,r)),db(a,r)}var lb={[en.LIVE]:()=>null,[en.UNVERIFIED]:e=>`DNS for ${e} is not pointing here yet. See the records to configure: ship domains records ${e}`,[en.UNLINKED]:e=>`Nothing is linked to ${e} yet. Point it at a deployment: ship domains set ${e} <deployment>`,[en.PAUSED]:e=>`${e} is paused: your plan has no room for it, so it serves nothing. Delete another domain, or upgrade your plan.`};function db(e,t){let r=lb[e.status]?.(e.domain);r&&(console.log(),_e(r,!1,t))}function pb(e,t){let{noColor:r}=t;_e(`It runs in the background. Check with: ship domains get ${e.domain}`,!1,r),e._deployment===null&&(console.log(),_e(`Nothing is linked to ${e.domain} yet. Once it verifies, point it at a deployment: ship domains set ${e.domain} <deployment>`,!1,r))}function ad(e,t){let{noColor:r}=t;console.log(Fe(e,r));let i=e.claim;if(i){let n=e.expires?Md(e.expires):null;console.log(`IMPORTANT: this deployment ${n?`expires in ${n}`:"will expire"}, claim it to keep permanently:
232
232
  ${i}
233
233
  `),_e("configure a free API key with 'ship config' to deploy to your own account",!1,r)}}function mb(e,t){let{noColor:r}=t;console.log(Fe(e,r))}function fb(e,t){let{noColor:r}=t;if(e.valid){if(Se(`${e.normalized??"domain"} domain is valid`,!1,r),console.log(),e.available!==null){let i=e.reason===null?r?"available":"available \u2713":e.reason;console.log(` availability: ${i}`)}console.log()}else console.log(`${mt(e.reason??"domain is invalid")}
234
234
  `)}function hb(e,t){let{noColor:r}=t;if(e.records.length===0){console.log("no records found"),console.log();return}let i=["type","name","value"];console.log(ln(e.records,i,r))}function gb(e,t){let{noColor:r}=t,i=e.dns?.provider?.name||null;console.log(Fe({domain:e.domain,provider:i},r))}function vb(e,t){let{noColor:r}=t;console.log(Fe(e,r))}function _b(e,t){let{noColor:r}=t;if(e.tokens.length===0){console.log("no tokens found"),console.log();return}let i=["token","labels","created","expires"];console.log(ln(e.tokens,i,r)),sd(e.cursor,r)}function lg(e,t){let{noColor:r}=t;console.log(Fe(e,r))}var G=e=>e,yb=e=>e.resource?`${e.resource}.${e.operation}`:e.operation,$b={"deployment.list":G({quiet:e=>e.deployments.map(t=>t.deployment),text:cb}),"deployment.upload":G({quiet:e=>[e.deployment],text:ad}),"deployment.get":G({quiet:e=>[e.deployment],text:ad}),"deployment.set":G({quiet:e=>[e.deployment],text:ad}),"deployment.delete":G({quiet:e=>[e.deployment],text:()=>{}}),"domain.list":G({quiet:e=>e.domains.map(t=>t.domain),text:ub}),"domain.get":G({quiet:e=>[e.domain],text:ug}),"domain.set":G({quiet:e=>[e.domain],text:ug}),"domain.validate":G({quiet:e=>e.valid&&e.normalized?[e.normalized]:[],text:fb}),"domain.verify":G({quiet:e=>[e.domain],text:pb}),"domain.records":G({quiet:e=>e.records.map(t=>`${t.type} ${t.name} ${t.value}`),text:hb}),"domain.dns":G({quiet:e=>e.dns?.provider?.name?[e.dns.provider.name]:[],text:gb}),"domain.share":G({quiet:e=>[e.url],text:vb}),"domain.delete":G({quiet:e=>[e.domain],text:()=>{}}),"token.list":G({quiet:e=>e.tokens.map(t=>t.token),text:_b}),"token.create":G({quiet:e=>[e.secret],text:lg}),"token.get":G({quiet:e=>[e.token],text:lg}),"token.delete":G({quiet:e=>[e.token],text:()=>{}}),"account.get":G({quiet:e=>[e.email],text:mb}),ping:G({quiet:()=>[],text:(e,t)=>Se("api reachable",!1,t.noColor)})};function mg(e,t,r){let{json:i,quiet:n,noColor:o}=r,a=$b[yb(t)];if(n){for(let c of a?.quiet(e)??[])console.log(c);return}if(i&&e!==null&&typeof e=="object"){let c={...e};delete c._dnsRecords,delete c._shareUrl,delete c.isCreate,console.log(JSON.stringify(c,null,2)),console.log();return}let s=dg(e,t);s&&Se(s,!1,o),a?a.text(e,r):e!==null&&typeof e=="object"&&console.log(Fe(e,o))}function zb(){let e=[pd.resolve(__dirname,"../package.json"),pd.resolve(__dirname,"../../package.json")];for(let t of e)try{return JSON.parse((0,lt.readFileSync)(t,"utf-8"))}catch{}return{version:"0.0.0"}}var Eb=zb();function Db(e){let t=o=>e?o:No(o),r=o=>e?o:Le(o),i=o=>e?"":`${o} `;return`${t("USAGE")}