@inkly-org/cli 0.5.1 → 0.5.3
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/README.md +1 -1
- package/dist/capture-listener.js +23 -23
- package/dist/cli.js +331 -224
- package/dist/template/demo.html +1 -1
- package/package.json +5 -5
- package/template/demo.html +1 -1
- package/vendor/react-dom-client.mjs +0 -1
- package/vendor/react-dom.mjs +0 -1
- package/vendor/react-jsx-runtime.mjs +0 -1
- package/vendor/react.mjs +0 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Pitch-ready demos from one prompt.
|
|
4
4
|
|
|
5
|
-
The command-line companion to **[Inkly](https://inklyai.dev)** — the AI-native interactive demo tool you build once and iterate with AI.
|
|
5
|
+
The command-line companion to **[Inkly](https://www.inklyai.dev)** — the AI-native interactive demo tool you build once and iterate with AI.
|
|
6
6
|
|
|
7
7
|
Your demos are **yours, as code**, living right next to your product. Scaffold a demo hub, preview it locally, capture a walkthrough, and ship it — all from your terminal. Then keep it alive by pointing your coding agent (Claude, Cursor, Codex) at the demo files, or with the no-code editor on the web.
|
|
8
8
|
|
package/dist/capture-listener.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var An=Object.defineProperty;var Pn=(t,e)=>{for(var n in e)An(t,n,{get:e[n],enumerable:!0})};import Ds from"mri";import{spawn as rs}from"child_process";import{createHash as Yo,randomUUID as Xo}from"crypto";import{mkdir as Ye,mkdtemp as ec,open as tc,readFile as Xe,readdir as nc,rm as is,writeFile as Ue}from"fs/promises";import{existsSync as ss}from"fs";import{dirname as fn,isAbsolute as sc,join as N,resolve as as,sep as ac}from"path";import{tmpdir as cc,homedir as os}from"os";import{fileURLToPath as cs}from"url";import{unzipSync as dc,zipSync as pc}from"fflate";import ls from"ws";import hc from"sharp";import yc from"subset-font";var a={};Pn(a,{BRAND:()=>tr,DIRTY:()=>te,EMPTY_PATH:()=>On,INVALID:()=>g,NEVER:()=>jr,OK:()=>P,ParseStatus:()=>A,Schema:()=>b,ZodAny:()=>Q,ZodArray:()=>K,ZodBigInt:()=>re,ZodBoolean:()=>ie,ZodBranded:()=>Oe,ZodCatch:()=>he,ZodDate:()=>se,ZodDefault:()=>fe,ZodDiscriminatedUnion:()=>ze,ZodEffects:()=>$,ZodEnum:()=>pe,ZodError:()=>D,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>Be,ZodIntersection:()=>le,ZodIssueCode:()=>u,ZodLazy:()=>ue,ZodLiteral:()=>de,ZodMap:()=>ke,ZodNaN:()=>Ce,ZodNativeEnum:()=>me,ZodNever:()=>F,ZodNull:()=>oe,ZodNullable:()=>B,ZodNumber:()=>ne,ZodObject:()=>O,ZodOptional:()=>M,ZodParsedType:()=>m,ZodPipeline:()=>Ne,ZodPromise:()=>ee,ZodReadonly:()=>ge,ZodRecord:()=>He,ZodSchema:()=>b,ZodSet:()=>Se,ZodString:()=>X,ZodSymbol:()=>xe,ZodTransformer:()=>$,ZodTuple:()=>H,ZodType:()=>b,ZodUndefined:()=>ae,ZodUnion:()=>ce,ZodUnknown:()=>Z,ZodVoid:()=>_e,addIssueToContext:()=>p,any:()=>ur,array:()=>fr,bigint:()=>sr,boolean:()=>Ot,coerce:()=>$r,custom:()=>Et,date:()=>ar,datetimeRegex:()=>At,defaultErrorMap:()=>W,discriminatedUnion:()=>wr,effect:()=>Er,enum:()=>Tr,function:()=>Sr,getErrorMap:()=>we,getParsedType:()=>z,instanceof:()=>rr,intersection:()=>br,isAborted:()=>je,isAsync:()=>be,isDirty:()=>Fe,isValid:()=>Y,late:()=>nr,lazy:()=>Cr,literal:()=>Ir,makeIssue:()=>De,map:()=>_r,nan:()=>ir,nativeEnum:()=>Ar,never:()=>pr,null:()=>lr,nullable:()=>Dr,number:()=>Dt,object:()=>hr,objectUtil:()=>it,oboolean:()=>Ur,onumber:()=>Mr,optional:()=>Rr,ostring:()=>Lr,pipeline:()=>Nr,preprocess:()=>Or,promise:()=>Pr,quotelessJson:()=>En,record:()=>xr,set:()=>kr,setErrorMap:()=>Dn,strictObject:()=>gr,string:()=>Rt,symbol:()=>or,transformer:()=>Er,tuple:()=>vr,undefined:()=>cr,union:()=>yr,unknown:()=>dr,util:()=>v,void:()=>mr});var v;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{let s={};for(let o of i)s[o]=o;return s},t.getValidEnumValues=i=>{let s=t.objectKeys(i).filter(c=>typeof i[i[c]]!="number"),o={};for(let c of s)o[c]=i[c];return t.objectValues(o)},t.objectValues=i=>t.objectKeys(i).map(function(s){return i[s]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},t.find=(i,s)=>{for(let o of i)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(v||(v={}));var it;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(it||(it={}));var m=v.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),z=t=>{switch(typeof t){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN(t)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(t)?m.array:t===null?m.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?m.promise:typeof Map<"u"&&t instanceof Map?m.map:typeof Set<"u"&&t instanceof Set?m.set:typeof Date<"u"&&t instanceof Date?m.date:m.object;default:return m.unknown}};var u=v.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"]),En=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),D=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(s){return s.message},r={_errors:[]},i=s=>{for(let o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let c=r,l=0;for(;l<o.path.length;){let d=o.path[l];l===o.path.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(n(o))):c[d]=c[d]||{_errors:[]},c=c[d],l++}}};return i(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,v.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];n[s]=n[s]||[],n[s].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};D.create=t=>new D(t);var Rn=(t,e)=>{let n;switch(t.code){case u.invalid_type:t.received===m.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,v.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:n=`Unrecognized key(s) in object: ${v.joinValues(t.keys,", ")}`;break;case u.invalid_union:n="Invalid input";break;case u.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${v.joinValues(t.options)}`;break;case u.invalid_enum_value:n=`Invalid enum value. Expected ${v.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:n="Invalid function arguments";break;case u.invalid_return_type:n="Invalid function return type";break;case u.invalid_date:n="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:v.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case u.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case u.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case u.custom:n="Invalid input";break;case u.invalid_intersection_types:n="Intersection results could not be merged";break;case u.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:n="Number must be finite";break;default:n=e.defaultError,v.assertNever(t)}return{message:n}},W=Rn;var kt=W;function Dn(t){kt=t}function we(){return kt}var De=t=>{let{data:e,path:n,errorMaps:r,issueData:i}=t,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let c="",l=r.filter(d=>!!d).slice().reverse();for(let d of l)c=d(o,{data:e,defaultError:c}).message;return{...i,path:s,message:c}},On=[];function p(t,e){let n=we(),r=De({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===W?void 0:W].filter(i=>!!i)});t.common.issues.push(r)}var A=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let i of n){if(i.status==="aborted")return g;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let i of n){let s=await i.key,o=await i.value;r.push({key:s,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let i of n){let{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return g;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}},g=Object.freeze({status:"aborted"}),te=t=>({status:"dirty",value:t}),P=t=>({status:"valid",value:t}),je=t=>t.status==="aborted",Fe=t=>t.status==="dirty",Y=t=>t.status==="valid",be=t=>typeof Promise<"u"&&t instanceof Promise;var h;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));var U=class{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,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}},St=(t,e)=>{if(Y(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new D(t.common.issues);return this._error=n,this._error}}};function w(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,c)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:l??r??c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:l??n??c.defaultError}},description:i}}var b=class{get description(){return this._def.description}_getType(e){return z(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new A,ctx:{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(be(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},i=this._parseSync({data:e,path:r.path,parent:r});return St(r,i)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Y(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Y(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(be(i)?i:Promise.resolve(i));return St(r,s)}refine(e,n){let r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{let o=e(i),c=()=>s.addIssue({code:u.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new $({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return M.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return K.create(this)}promise(){return ee.create(this,this._def)}or(e){return ce.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new $({...w(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new fe({...w(this._def),innerType:this,defaultValue:n,typeName:y.ZodDefault})}brand(){return new Oe({typeName:y.ZodBranded,type:this,...w(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new he({...w(this._def),innerType:this,catchValue:n,typeName:y.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ne.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Nn=/^c[^\s-]{8,}$/i,Ln=/^[0-9a-z]+$/,Mn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Un=/^[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,$n=/^[a-z0-9_-]{21}$/i,jn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Fn=/^[-+]?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)?)??$/,zn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",st,Bn=/^(?:(?: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])$/,Wn=/^(?:(?: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])$/,Vn=/^(([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]))$/,Zn=/^(([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])$/,Kn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Gn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,It="((\\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])))",Jn=new RegExp(`^${It}$`);function Tt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function qn(t){return new RegExp(`^${Tt(t)}$`)}function At(t){let e=`${It}T${Tt(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Yn(t,e){return!!((e==="v4"||!e)&&Bn.test(t)||(e==="v6"||!e)&&Vn.test(t))}function Xn(t,e){if(!jn.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function Qn(t,e){return!!((e==="v4"||!e)&&Wn.test(t)||(e==="v6"||!e)&&Zn.test(t))}var X=class t extends b{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){let s=this._getOrReturnCtx(e);return p(s,{code:u.invalid_type,expected:m.string,received:s.parsedType}),g}let r=new A,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),p(i,{code:u.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),p(i,{code:u.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let o=e.data.length>s.value,c=e.data.length<s.value;(o||c)&&(i=this._getOrReturnCtx(e,i),o?p(i,{code:u.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):c&&p(i,{code:u.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")zn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"email",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")st||(st=new RegExp(Hn,"u")),st.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"emoji",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Un.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"uuid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")$n.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"nanoid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")Nn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"cuid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Ln.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"cuid2",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Mn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"ulid",code:u.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),p(i,{validation:"url",code:u.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"regex",code:u.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?At(s).test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Jn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?qn(s).test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{code:u.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?Fn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"duration",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?Yn(e.data,s.version)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"ip",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?Xn(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"jwt",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?Qn(e.data,s.version)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"cidr",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Kn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"base64",code:u.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?Gn.test(e.data)||(i=this._getOrReturnCtx(e,i),p(i,{validation:"base64url",code:u.invalid_string,message:s.message}),r.dirty()):v.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:u.invalid_string,...h.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...h.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...h.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...h.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...h.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...h.errToObj(n)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};X.create=t=>new X({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,...w(t)});function er(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(t.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return s%o/10**i}var ne=class t extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==m.number){let s=this._getOrReturnCtx(e);return p(s,{code:u.invalid_type,expected:m.number,received:s.parsedType}),g}let r,i=new A;for(let s of this._def.checks)s.kind==="int"?v.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:u.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?er(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),p(r,{code:u.not_finite,message:s.message}),i.dirty()):v.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,h.toString(n))}gt(e,n){return this.setLimit("min",e,!1,h.toString(n))}lte(e,n){return this.setLimit("max",e,!0,h.toString(n))}lt(e,n){return this.setLimit("max",e,!1,h.toString(n))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:h.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&v.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};ne.create=t=>new ne({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,...w(t)});var re=class t extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==m.bigint)return this._getInvalidInput(e);let r,i=new A;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),p(r,{code:u.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):v.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return p(n,{code:u.invalid_type,expected:m.bigint,received:n.parsedType}),g}gte(e,n){return this.setLimit("min",e,!0,h.toString(n))}gt(e,n){return this.setLimit("min",e,!1,h.toString(n))}lte(e,n){return this.setLimit("max",e,!0,h.toString(n))}lt(e,n){return this.setLimit("max",e,!1,h.toString(n))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:h.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};re.create=t=>new re({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,...w(t)});var ie=class extends b{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.boolean,received:r.parsedType}),g}return P(e.data)}};ie.create=t=>new ie({typeName:y.ZodBoolean,coerce:t?.coerce||!1,...w(t)});var se=class t extends b{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){let s=this._getOrReturnCtx(e);return p(s,{code:u.invalid_type,expected:m.date,received:s.parsedType}),g}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return p(s,{code:u.invalid_date}),g}let r=new A,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),p(i,{code:u.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),p(i,{code:u.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):v.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};se.create=t=>new se({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,...w(t)});var xe=class extends b{_parse(e){if(this._getType(e)!==m.symbol){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.symbol,received:r.parsedType}),g}return P(e.data)}};xe.create=t=>new xe({typeName:y.ZodSymbol,...w(t)});var ae=class extends b{_parse(e){if(this._getType(e)!==m.undefined){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.undefined,received:r.parsedType}),g}return P(e.data)}};ae.create=t=>new ae({typeName:y.ZodUndefined,...w(t)});var oe=class extends b{_parse(e){if(this._getType(e)!==m.null){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.null,received:r.parsedType}),g}return P(e.data)}};oe.create=t=>new oe({typeName:y.ZodNull,...w(t)});var Q=class extends b{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}};Q.create=t=>new Q({typeName:y.ZodAny,...w(t)});var Z=class extends b{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}};Z.create=t=>new Z({typeName:y.ZodUnknown,...w(t)});var F=class extends b{_parse(e){let n=this._getOrReturnCtx(e);return p(n,{code:u.invalid_type,expected:m.never,received:n.parsedType}),g}};F.create=t=>new F({typeName:y.ZodNever,...w(t)});var _e=class extends b{_parse(e){if(this._getType(e)!==m.undefined){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.void,received:r.parsedType}),g}return P(e.data)}};_e.create=t=>new _e({typeName:y.ZodVoid,...w(t)});var K=class t extends b{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==m.array)return p(n,{code:u.invalid_type,expected:m.array,received:n.parsedType}),g;if(i.exactLength!==null){let o=n.data.length>i.exactLength.value,c=n.data.length<i.exactLength.value;(o||c)&&(p(n,{code:o?u.too_big:u.too_small,minimum:c?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(p(n,{code:u.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(p(n,{code:u.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,c)=>i.type._parseAsync(new U(n,o,n.path,c)))).then(o=>A.mergeArray(r,o));let s=[...n.data].map((o,c)=>i.type._parseSync(new U(n,o,n.path,c)));return A.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:h.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:h.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:h.toString(n)}})}nonempty(e){return this.min(1,e)}};K.create=(t,e)=>new K({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...w(e)});function ve(t){if(t instanceof O){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=M.create(ve(r))}return new O({...t._def,shape:()=>e})}else return t instanceof K?new K({...t._def,type:ve(t.element)}):t instanceof M?M.create(ve(t.unwrap())):t instanceof B?B.create(ve(t.unwrap())):t instanceof H?H.create(t.items.map(e=>ve(e))):t}var O=class t extends b{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=v.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==m.object){let d=this._getOrReturnCtx(e);return p(d,{code:u.invalid_type,expected:m.object,received:d.parsedType}),g}let{status:r,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(let d in i.data)o.includes(d)||c.push(d);let l=[];for(let d of o){let f=s[d],x=i.data[d];l.push({key:{status:"valid",value:d},value:f._parse(new U(i,x,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof F){let d=this._def.unknownKeys;if(d==="passthrough")for(let f of c)l.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(d==="strict")c.length>0&&(p(i,{code:u.unrecognized_keys,keys:c}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let f of c){let x=i.data[f];l.push({key:{status:"valid",value:f},value:d._parse(new U(i,x,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let d=[];for(let f of l){let x=await f.key,I=await f.value;d.push({key:x,value:I,alwaysSet:f.alwaysSet})}return d}).then(d=>A.mergeObjectSync(r,d)):A.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let i=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:h.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of v.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of v.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return ve(this)}partial(e){let n={};for(let r of v.objectKeys(this.shape)){let i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of v.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof M;)s=s._def.innerType;n[r]=s}return new t({...this._def,shape:()=>n})}keyof(){return Pt(v.objectKeys(this.shape))}};O.create=(t,e)=>new O({shape:()=>t,unknownKeys:"strip",catchall:F.create(),typeName:y.ZodObject,...w(e)});O.strictCreate=(t,e)=>new O({shape:()=>t,unknownKeys:"strict",catchall:F.create(),typeName:y.ZodObject,...w(e)});O.lazycreate=(t,e)=>new O({shape:t,unknownKeys:"strip",catchall:F.create(),typeName:y.ZodObject,...w(e)});var ce=class extends b{_parse(e){let{ctx:n}=this._processInputParams(e),r=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 n.common.issues.push(...c.ctx.common.issues),c.result;let o=s.map(c=>new D(c.ctx.common.issues));return p(n,{code:u.invalid_union,unionErrors:o}),g}if(n.common.async)return Promise.all(r.map(async s=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s,o=[];for(let l of r){let d={...n,common:{...n.common,issues:[]},parent:null},f=l._parseSync({data:n.data,path:n.path,parent:d});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let c=o.map(l=>new D(l));return p(n,{code:u.invalid_union,unionErrors:c}),g}}get options(){return this._def.options}};ce.create=(t,e)=>new ce({options:t,typeName:y.ZodUnion,...w(e)});var V=t=>t instanceof ue?V(t.schema):t instanceof $?V(t.innerType()):t instanceof de?[t.value]:t instanceof pe?t.options:t instanceof me?v.objectValues(t.enum):t instanceof fe?V(t._def.innerType):t instanceof ae?[void 0]:t instanceof oe?[null]:t instanceof M?[void 0,...V(t.unwrap())]:t instanceof B?[null,...V(t.unwrap())]:t instanceof Oe||t instanceof ge?V(t.unwrap()):t instanceof he?V(t._def.innerType):[],ze=class t extends b{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==m.object)return p(n,{code:u.invalid_type,expected:m.object,received:n.parsedType}),g;let r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(p(n,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let i=new Map;for(let s of n){let o=V(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of o){if(i.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);i.set(c,s)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:i,...w(r)})}};function at(t,e){let n=z(t),r=z(e);if(t===e)return{valid:!0,data:t};if(n===m.object&&r===m.object){let i=v.objectKeys(e),s=v.objectKeys(t).filter(c=>i.indexOf(c)!==-1),o={...t,...e};for(let c of s){let l=at(t[c],e[c]);if(!l.valid)return{valid:!1};o[c]=l.data}return{valid:!0,data:o}}else if(n===m.array&&r===m.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<t.length;s++){let o=t[s],c=e[s],l=at(o,c);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===m.date&&r===m.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var le=class extends b{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=(s,o)=>{if(je(s)||je(o))return g;let c=at(s.value,o.value);return c.valid?((Fe(s)||Fe(o))&&n.dirty(),{status:n.value,value:c.data}):(p(r,{code:u.invalid_intersection_types}),g)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};le.create=(t,e,n)=>new le({left:t,right:e,typeName:y.ZodIntersection,...w(n)});var H=class t extends b{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.array)return p(r,{code:u.invalid_type,expected:m.array,received:r.parsedType}),g;if(r.data.length<this._def.items.length)return p(r,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&r.data.length>this._def.items.length&&(p(r,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((o,c)=>{let l=this._def.items[c]||this._def.rest;return l?l._parse(new U(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>A.mergeArray(n,o)):A.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};H.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new H({items:t,typeName:y.ZodTuple,rest:null,...w(e)})};var He=class t extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.object)return p(r,{code:u.invalid_type,expected:m.object,received:r.parsedType}),g;let i=[],s=this._def.keyType,o=this._def.valueType;for(let c in r.data)i.push({key:s._parse(new U(r,c,r.path,c)),value:o._parse(new U(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?A.mergeObjectAsync(n,i):A.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof b?new t({keyType:e,valueType:n,typeName:y.ZodRecord,...w(r)}):new t({keyType:X.create(),valueType:e,typeName:y.ZodRecord,...w(n)})}},ke=class extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.map)return p(r,{code:u.invalid_type,expected:m.map,received:r.parsedType}),g;let i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([c,l],d)=>({key:i._parse(new U(r,c,r.path,[d,"key"])),value:s._parse(new U(r,l,r.path,[d,"value"]))}));if(r.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let l of o){let d=await l.key,f=await l.value;if(d.status==="aborted"||f.status==="aborted")return g;(d.status==="dirty"||f.status==="dirty")&&n.dirty(),c.set(d.value,f.value)}return{status:n.value,value:c}})}else{let c=new Map;for(let l of o){let d=l.key,f=l.value;if(d.status==="aborted"||f.status==="aborted")return g;(d.status==="dirty"||f.status==="dirty")&&n.dirty(),c.set(d.value,f.value)}return{status:n.value,value:c}}}};ke.create=(t,e,n)=>new ke({valueType:e,keyType:t,typeName:y.ZodMap,...w(n)});var Se=class t extends b{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.set)return p(r,{code:u.invalid_type,expected:m.set,received:r.parsedType}),g;let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(p(r,{code:u.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(p(r,{code:u.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let s=this._def.valueType;function o(l){let d=new Set;for(let f of l){if(f.status==="aborted")return g;f.status==="dirty"&&n.dirty(),d.add(f.value)}return{status:n.value,value:d}}let c=[...r.data.values()].map((l,d)=>s._parse(new U(r,l,r.path,d)));return r.common.async?Promise.all(c).then(l=>o(l)):o(c)}min(e,n){return new t({...this._def,minSize:{value:e,message:h.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:h.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Se.create=(t,e)=>new Se({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,...w(e)});var Be=class t extends b{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==m.function)return p(n,{code:u.invalid_type,expected:m.function,received:n.parsedType}),g;function r(c,l){return De({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,we(),W].filter(d=>!!d),issueData:{code:u.invalid_arguments,argumentsError:l}})}function i(c,l){return De({data:c,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,we(),W].filter(d=>!!d),issueData:{code:u.invalid_return_type,returnTypeError:l}})}let s={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof ee){let c=this;return P(async function(...l){let d=new D([]),f=await c._def.args.parseAsync(l,s).catch(T=>{throw d.addIssue(r(l,T)),d}),x=await Reflect.apply(o,this,f);return await c._def.returns._def.type.parseAsync(x,s).catch(T=>{throw d.addIssue(i(x,T)),d})})}else{let c=this;return P(function(...l){let d=c._def.args.safeParse(l,s);if(!d.success)throw new D([r(l,d.error)]);let f=Reflect.apply(o,this,d.data),x=c._def.returns.safeParse(f,s);if(!x.success)throw new D([i(f,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:H.create(e).rest(Z.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||H.create([]).rest(Z.create()),returns:n||Z.create(),typeName:y.ZodFunction,...w(r)})}},ue=class extends b{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};ue.create=(t,e)=>new ue({getter:t,typeName:y.ZodLazy,...w(e)});var de=class extends b{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return p(n,{received:n.data,code:u.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};de.create=(t,e)=>new de({value:t,typeName:y.ZodLiteral,...w(e)});function Pt(t,e){return new pe({values:t,typeName:y.ZodEnum,...w(e)})}var pe=class t extends b{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return p(n,{expected:v.joinValues(r),received:n.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return p(n,{received:n.data,code:u.invalid_enum_value,options:r}),g}return P(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};pe.create=Pt;var me=class extends b{_parse(e){let n=v.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==m.string&&r.parsedType!==m.number){let i=v.objectValues(n);return p(r,{expected:v.joinValues(i),received:r.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(v.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=v.objectValues(n);return p(r,{received:r.data,code:u.invalid_enum_value,options:i}),g}return P(e.data)}get enum(){return this._def.values}};me.create=(t,e)=>new me({values:t,typeName:y.ZodNativeEnum,...w(e)});var ee=class extends b{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==m.promise&&n.common.async===!1)return p(n,{code:u.invalid_type,expected:m.promise,received:n.parsedType}),g;let r=n.parsedType===m.promise?n.data:Promise.resolve(n.data);return P(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}};ee.create=(t,e)=>new ee({type:t,typeName:y.ZodPromise,...w(e)});var $=class extends b{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{p(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async c=>{if(n.value==="aborted")return g;let l=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return l.status==="aborted"?g:l.status==="dirty"?te(l.value):n.value==="dirty"?te(l.value):l});{if(n.value==="aborted")return g;let c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?g:c.status==="dirty"?te(c.value):n.value==="dirty"?te(c.value):c}}if(i.type==="refinement"){let o=c=>{let l=i.refinement(c,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){let c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?g:(c.status==="dirty"&&n.dirty(),o(c.value),{status:n.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?g:(c.status==="dirty"&&n.dirty(),o(c.value).then(()=>({status:n.value,value:c.value}))))}if(i.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Y(o))return g;let c=i.transform(o.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Y(o)?Promise.resolve(i.transform(o.value,s)).then(c=>({status:n.value,value:c})):g);v.assertNever(i)}};$.create=(t,e,n)=>new $({schema:t,typeName:y.ZodEffects,effect:e,...w(n)});$.createWithPreprocess=(t,e,n)=>new $({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,...w(n)});var M=class extends b{_parse(e){return this._getType(e)===m.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};M.create=(t,e)=>new M({innerType:t,typeName:y.ZodOptional,...w(e)});var B=class extends b{_parse(e){return this._getType(e)===m.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(t,e)=>new B({innerType:t,typeName:y.ZodNullable,...w(e)});var fe=class extends b{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===m.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};fe.create=(t,e)=>new fe({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...w(e)});var he=class extends b{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return be(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new D(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new D(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};he.create=(t,e)=>new he({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...w(e)});var Ce=class extends b{_parse(e){if(this._getType(e)!==m.nan){let r=this._getOrReturnCtx(e);return p(r,{code:u.invalid_type,expected:m.nan,received:r.parsedType}),g}return{status:"valid",value:e.data}}};Ce.create=t=>new Ce({typeName:y.ZodNaN,...w(t)});var tr=Symbol("zod_brand"),Oe=class extends b{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Ne=class t extends b{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?g:s.status==="dirty"?(n.dirty(),te(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?g:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:y.ZodPipeline})}},ge=class extends b{_parse(e){let n=this._def.innerType._parse(e),r=i=>(Y(i)&&(i.value=Object.freeze(i.value)),i);return be(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:y.ZodReadonly,...w(e)});function Ct(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Et(t,e={},n){return t?Q.create().superRefine((r,i)=>{let s=t(r);if(s instanceof Promise)return s.then(o=>{if(!o){let c=Ct(e,r),l=c.fatal??n??!0;i.addIssue({code:"custom",...c,fatal:l})}});if(!s){let o=Ct(e,r),c=o.fatal??n??!0;i.addIssue({code:"custom",...o,fatal:c})}}):Q.create()}var nr={object:O.lazycreate},y;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(y||(y={}));var rr=(t,e={message:`Input not instance of ${t.name}`})=>Et(n=>n instanceof t,e),Rt=X.create,Dt=ne.create,ir=Ce.create,sr=re.create,Ot=ie.create,ar=se.create,or=xe.create,cr=ae.create,lr=oe.create,ur=Q.create,dr=Z.create,pr=F.create,mr=_e.create,fr=K.create,hr=O.create,gr=O.strictCreate,yr=ce.create,wr=ze.create,br=le.create,vr=H.create,xr=He.create,_r=ke.create,kr=Se.create,Sr=Be.create,Cr=ue.create,Ir=de.create,Tr=pe.create,Ar=me.create,Pr=ee.create,Er=$.create,Rr=M.create,Dr=B.create,Or=$.createWithPreprocess,Nr=Ne.create,Lr=()=>Rt().optional(),Mr=()=>Dt().optional(),Ur=()=>Ot().optional(),$r={string:(t=>X.create({...t,coerce:!0})),number:(t=>ne.create({...t,coerce:!0})),boolean:(t=>ie.create({...t,coerce:!0})),bigint:(t=>re.create({...t,coerce:!0})),date:(t=>se.create({...t,coerce:!0}))};var jr=g;var ot=a.object({id:a.string()}),Fr=a.enum(["top","right","bottom","left","auto"]).default("auto"),ct=a.enum(["left","middle","right"]),zr=ct.default("left"),Nt=a.object({label:a.string().optional(),hidden:a.boolean().default(!1)}),Hr={background:a.string().optional(),textColor:a.string().optional(),borderRadius:a.string().optional(),textAlign:zr,anchor:Fr,showNavigation:a.boolean().default(!0),prevButton:Nt.optional(),nextButton:Nt.optional()},Br=a.enum(["pointer","callout","area"]),Wr=a.discriminatedUnion("type",[a.object({type:a.literal("html-element"),alphaId:a.string().min(1)})]),Vr=ot.extend({type:a.literal("message"),variant:Br.default("callout"),x:a.number().min(0).max(1),y:a.number().min(0).max(1),w:a.number().min(0).max(1).optional(),h:a.number().min(0).max(1).optional(),text:a.string().optional(),target:Wr.optional(),advancesStep:a.boolean().default(!0),...Hr}),Zr=ot.extend({type:a.literal("blur"),x:a.number().min(0).max(1),y:a.number().min(0).max(1),w:a.number().min(0).max(1),h:a.number().min(0).max(1),intensity:a.number().min(0).max(20).default(8)}),Kr=ot.extend({type:a.literal("text"),x:a.number().min(0).max(1),y:a.number().min(0).max(1),text:a.string(),fontSize:a.number().positive().default(16),color:a.string().optional()}),Lt=a.discriminatedUnion("type",[Vr,Zr,Kr]),Mt=new Set(["message","blur","text"]),Ut=a.object({type:a.string()}).passthrough();function $t(t){return typeof t=="object"&&t!==null?t.type:void 0}var jt=a.any().superRefine((t,e)=>{let i=(Mt.has($t(t))?Lt:Ut).safeParse(t);if(!i.success)for(let s of i.error.issues)e.addIssue(s)}).transform(t=>(Mt.has($t(t))?Lt:Ut).parse(t));var lt=a.object({label:a.string().min(1),href:a.string().refine(t=>/^(https?:|mailto:)/i.test(t),"href must be an http(s) or mailto URL")}),ut=a.object({logo:a.string().min(1).optional(),name:a.string().min(1).optional(),logoHref:a.string().refine(t=>/^(https?:|mailto:)/i.test(t),"logoHref must be an http(s) or mailto URL").optional(),favicon:a.string().min(1).optional(),cta:lt.optional(),secondaryCta:lt.optional()}),Ft=ut.omit({favicon:!0});var Gr=a.object({type:a.literal("next")}),Jr=a.object({type:a.literal("prev")}),qr=a.object({type:a.literal("step"),stepId:a.string().min(1)}),Yr=a.object({type:a.literal("chapter"),chapterId:a.string().min(1)}),Xr=a.object({type:a.literal("url"),href:a.string().min(1),target:a.enum(["_self","_blank"]).default("_blank")}),Qr=a.object({type:a.literal("restart")}),ei=a.discriminatedUnion("type",[Gr,Jr,qr,Yr,Xr,Qr]),ti=a.enum(["shimmer"]),We=a.object({label:a.string().min(1),action:ei.default({type:"next"}),animation:ti.optional(),background:a.string().optional(),textColor:a.string().optional()});var zt=/^[A-Za-z0-9_-]{12}$/;var Bt=a.object({id:a.string(),text:a.string(),start:a.number().nonnegative().optional(),end:a.number().nonnegative().optional()});var ni=a.enum(["screenshot","image","video","audio","font","other"]),ri=a.object({id:a.string().min(1),path:a.string().min(1).optional(),uri:a.string().min(1).optional(),sha256:a.string().regex(/^[0-9a-f]{64}$/),kind:ni,contentType:a.string().min(1).optional(),publicUrl:a.string().min(1).optional(),cdnPath:a.string().min(1).optional(),size:a.number().int().nonnegative().optional(),createdAt:a.string().min(1).optional(),updatedAt:a.string().min(1).optional(),viewport:a.object({w:a.number().int().positive(),h:a.number().int().positive()}).optional()}),ii=a.object({version:a.literal(1),assets:a.array(ri),screens:a.array(a.unknown()).optional()});var dt=a.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,{message:"must be a hex color like #5b3df5"}),si=a.enum(["color","image","glassmorphism"]),Wt=a.object({type:si,color:dt.optional(),from:dt.optional(),to:dt.optional(),src:a.string().min(1).optional(),alt:a.string().optional(),intensity:a.number().min(-5).max(48).optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,r=!!t.from&&!!t.to;!n&&!r&&e.addIssue({code:a.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:a.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:a.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),Vt=a.object({src:a.string(),alt:a.string().optional()});var pt=a.object({src:a.string().min(1),duration:a.number().positive().optional()});var ai=a.enum(["text","dropdown"]),oi=a.object({value:a.string().min(1),label:a.string().min(1)}),ci=a.object({id:a.string(),label:a.string(),type:ai.default("text"),placeholder:a.string().optional(),required:a.boolean().default(!1),options:a.array(oi).optional()}).superRefine((t,e)=>{t.type==="dropdown"&&(!t.options||t.options.length===0)&&e.addIssue({code:a.ZodIssueCode.custom,message:"Dropdown field requires at least one option.",path:["options"]})}),qt=a.object({src:a.string().min(1),alt:a.string().optional(),height:a.number().int().positive().optional()}),li=a.enum(["left","right","top"]),ui=a.enum(["standard","hero"]),Yt=a.object({src:a.string().min(1),alt:a.string().optional(),naturalWidth:a.number().positive().optional(),naturalHeight:a.number().positive().optional(),position:li.default("right"),layout:ui.default("hero")}),di=a.object({type:a.literal("headline"),id:a.string(),logo:qt.optional(),image:Yt.optional(),title:a.string(),titleColor:a.string().optional(),description:a.string().optional(),descriptionColor:a.string().optional(),textAlign:ct.optional(),cta:We.optional(),secondaryCta:We.optional()}),pi=a.object({type:a.literal("form"),id:a.string(),logo:qt.optional(),image:Yt.optional(),title:a.string().optional(),description:a.string().optional(),fields:a.array(ci).min(1),submit:We.default({label:"Submit",action:{type:"next"}})}),mi="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",fi="camera; microphone; fullscreen; payment; clipboard-write",hi=a.object({type:a.literal("embed"),id:a.string(),src:a.string(),iframeTitle:a.string().optional(),sandbox:a.string().default(mi),allow:a.string().default(fi)}),gi=a.object({type:a.literal("custom"),id:a.string(),name:a.string().min(1),data:a.record(a.unknown()).optional()}),Zt=a.discriminatedUnion("type",[di,pi,hi,gi]),Kt=new Set(["headline","form","embed","custom"]),Gt=a.object({type:a.string()}).passthrough();function Jt(t){return typeof t=="object"&&t!==null?t.type:void 0}var Xt=a.any().superRefine((t,e)=>{let i=(Kt.has(Jt(t))?Zt:Gt).safeParse(t);if(!i.success)for(let s of i.error.issues)e.addIssue(s)}).transform(t=>(Kt.has(Jt(t))?Zt:Gt).parse(t));var Qt=a.enum(["contain","cover","fill"]),en=a.enum(["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"]),yi=a.object({type:a.literal("image"),src:a.string().min(1),naturalWidth:a.number().positive(),naturalHeight:a.number().positive(),alt:a.string().optional(),sourceUrl:a.string().optional(),title:a.string().optional(),objectFit:Qt.optional(),objectPosition:en.optional()}),wi=a.object({type:a.literal("video"),src:a.string().min(1),posterSrc:a.string().min(1).optional(),naturalWidth:a.number().positive(),naturalHeight:a.number().positive(),alt:a.string().optional(),sourceUrl:a.string().optional(),title:a.string().optional(),autoplay:a.boolean().default(!0),muted:a.boolean().default(!0),objectFit:Qt.optional(),objectPosition:en.optional()}),bi=a.object({x:a.number().nonnegative().default(0),y:a.number().nonnegative().default(0),maxX:a.number().nonnegative().default(0),maxY:a.number().nonnegative().default(0)}),vi=a.object({type:a.literal("html"),path:a.string().min(1),naturalWidth:a.number().positive(),naturalHeight:a.number().positive(),zoom:a.number().positive().default(1),scroll:bi.default({x:0,y:0,maxX:0,maxY:0}),sourceUrl:a.string().optional(),title:a.string().optional()}),xi=a.discriminatedUnion("type",[yi,wi,vi]),_i=a.object({zoom:a.number().min(1).default(1),x:a.number().min(0).max(1).default(.5),y:a.number().min(0).max(1).default(.5)}),ki=a.object({trigger:a.enum(["auto","click"]).default("auto")}).default({trigger:"auto"}),Si=a.object({kind:a.literal("content").default("content"),id:a.string(),label:a.string().optional(),duration:a.number().positive().optional(),background:xi,script:a.string().optional(),voiceover:pt.optional(),transform:_i.optional(),advance:ki,annotations:a.array(jt).default([]),captions:a.array(Bt).optional()}).passthrough(),Ci=a.object({kind:a.literal("cover"),id:a.string(),label:a.string().optional(),widgets:a.array(Xt).length(1),background:Wt.optional(),backgroundImage:Vt.optional(),backgroundDim:a.number().min(0).max(1).optional(),script:a.string().optional(),voiceover:pt.optional(),duration:a.number().positive().optional(),advance:a.object({trigger:a.enum(["auto","click"]).default("click")}).default({trigger:"click"})}).passthrough(),tn=a.discriminatedUnion("kind",[Si,Ci]);var Ii=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,nn=a.string().regex(Ii,"must be a hex color like #5b3df5"),Ve=a.object({primary:nn.optional(),secondary:nn.optional(),font:a.string().min(1).optional(),radius:a.string().min(1).optional()}).partial();var Ze=a.string().regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,{message:"must be a hex color like #5b3df5"}),Ti=a.object({id:a.string(),title:a.string(),stepIds:a.array(a.string()).min(1)}),Ai=a.object({hideHeader:a.boolean().default(!1),hideControls:a.boolean().default(!1),controls:a.enum(["full","minimal","hidden"]).optional(),showHubBreadcrumb:a.boolean().default(!1),mobileFooterMessage:a.boolean().default(!0),autoplay:a.boolean().default(!1)}),Pi=a.object({width:a.number().positive(),height:a.number().positive()}),Ei=a.enum(["public","private"]),Ri=a.enum(["none","color","image"]),Di=a.object({type:Ri,color:Ze.optional(),from:Ze.optional(),to:Ze.optional(),src:a.string().min(1).optional(),alt:a.string().optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,r=!!t.from&&!!t.to;!n&&!r&&e.addIssue({code:a.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:a.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:a.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),Ba=a.object({id:a.string().regex(zt,{message:"must be a 12-character URL-safe demo id (see generateDemoId)"}),version:a.number().int().min(1),title:a.string().optional(),subtitle:a.string().optional(),runtime:a.string().min(1).optional(),visibility:Ei.default("public"),backgroundColor:Ze.optional(),background:Di.optional(),theme:a.object({preset:a.string().min(1).optional(),tokens:Ve.optional(),brand:Ft.optional()}).optional(),chrome:Ai.default({}),aspectRatio:Pi.optional(),chapters:a.array(Ti).default([]),steps:a.array(tn).min(1)}).passthrough().superRefine((t,e)=>{let n=new Set(t.steps.map(i=>i.id)),r=new Set(t.chapters.map(i=>i.id));t.chapters.forEach((i,s)=>{i.stepIds.forEach(o=>{n.has(o)||e.addIssue({code:a.ZodIssueCode.custom,path:["chapters",s,"stepIds"],message:`Chapter "${i.id}" references unknown step "${o}"`})})}),t.steps.forEach((i,s)=>{i.kind==="cover"&&i.widgets.forEach((o,c)=>{o.type==="headline"&&["cta","secondaryCta"].forEach(l=>{let d=o[l]?.action;d&&(d.type==="step"&&!n.has(d.stepId)&&e.addIssue({code:a.ZodIssueCode.custom,path:["steps",s,"widgets",c,l,"action","stepId"],message:`Widget "${o.id}" CTA targets unknown step "${d.stepId}"`}),d.type==="chapter"&&!r.has(d.chapterId)&&e.addIssue({code:a.ZodIssueCode.custom,path:["steps",s,"widgets",c,l,"action","chapterId"],message:`Widget "${o.id}" CTA targets unknown chapter "${d.chapterId}"`}))})})})});var Oi=a.enum(["sidebar","tabs"]),Ni=a.object({name:a.string().min(1),description:a.string().min(1).optional(),icon:a.string().min(1).optional(),demos:a.array(a.string().min(1))}),Ga=a.object({$schema:a.string().optional(),name:a.string().min(1),runtime:a.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,"runtime must be an exact semver version"),runtimeRange:a.string().min(1).optional(),layout:Oi.optional(),theme:a.string().min(1).optional(),tokens:Ve.optional(),brand:ut.optional(),title:a.string().min(1).optional(),subtitle:a.string().min(1).optional(),collections:a.array(Ni).optional()});var Le=a.string().regex(/^sha(?:256|384|512)-[A-Za-z0-9+/]+=*$/,{message:"must be an SRI string like sha384-<base64>"}),Ke=a.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,{message:"must be an exact semver like 0.1.0"}),Li=a.object({version:Ke,url:a.string().url(),integrity:Le}),eo=a.object({$schema:a.string().optional(),runtime:Li});var rn=a.string().regex(/^[0-9a-f]{64}$/,{message:"must be lowercase sha-256 hex (64 chars)"}),io=a.object({version:Ke,externals:a.array(a.string().min(1)),jsHash:rn,cssHash:rn,jsBytes:a.number().int().nonnegative(),cssBytes:a.number().int().nonnegative(),integrity:Le,cssIntegrity:Le,minSchema:Ke,codemodsIntegrity:Le.optional(),codemodsBytes:a.number().int().nonnegative().optional()});var Me={demoSlug:a.string().min(1),timestamp:a.number().int().nonnegative()},co=a.discriminatedUnion("type",[a.object({type:a.literal("inkly:ready"),...Me,runtimeVersion:a.string().min(1),schemaVersion:a.string().min(1),stepIds:a.array(a.string().min(1))}),a.object({type:a.literal("inkly:step"),...Me,stepId:a.string().min(1),stepIndex:a.number().int().nonnegative()}),a.object({type:a.literal("inkly:heartbeat"),...Me,stepId:a.string().min(1)}),a.object({type:a.literal("inkly:action"),...Me,stepId:a.string().min(1),widgetId:a.string().min(1),kind:a.string().min(1),payload:a.unknown().optional()}),a.object({type:a.literal("inkly:complete"),...Me})]);import{randomUUID as Mi}from"crypto";import{mkdir as Ui,readFile as $i,writeFile as ji}from"fs/promises";import{dirname as Fi,join as zi}from"path";import{homedir as Hi}from"os";import{PostHog as Bi}from"posthog-node";var an=process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN??process.env.POSTHOG_PROJECT_TOKEN??"phc_Dmh4w8YFNosi3YHD4Sv7ShHX7ccS8kmtRcm8XSVmB5jT",Wi=process.env.NEXT_PUBLIC_POSTHOG_HOST??process.env.POSTHOG_HOST??"https://us.i.posthog.com",Vi="@inkly-org/cli@0.5.1",mt=zi(Hi(),".inkly","analytics.json"),sn=null,Ge=null,on=null;function Zi(){return!!an&&process.env.INKLY_TELEMETRY_DISABLED!=="1"}function Ki(){return Zi()?(sn??=new Bi(an,{host:Wi,flushAt:1,flushInterval:0}),sn):null}async function Gi(){try{let t=await $i(mt,"utf8");return JSON.parse(t)}catch{return{}}}async function Ji(t){await Ui(Fi(mt),{recursive:!0}),await ji(mt,JSON.stringify(t,null,2)+`
|
|
3
|
-
`,{encoding:"utf8",mode:384})}async function
|
|
2
|
+
import vt from"mri";import{spawn as Ve}from"child_process";import{createHash as Ft,randomUUID as Ht}from"crypto";import{mkdir as O,mkdtemp as Bt,open as Wt,readFile as F,readdir as zt,rm as Ge,writeFile as U}from"fs/promises";import{existsSync as Ze}from"fs";import{dirname as ue,isAbsolute as Zt,join as b,resolve as Ke,sep as Kt}from"path";import{tmpdir as qt,homedir as Je}from"os";import{fileURLToPath as qe}from"url";import{unzipSync as Qt,zipSync as en}from"fflate";import Ye from"ws";import rn from"sharp";import sn from"subset-font";import{zipSync as At}from"fflate";import{JSDOM as un}from"jsdom";import{randomUUID as Ae}from"crypto";import{mkdir as Pe,readFile as xe,writeFile as Te}from"fs/promises";import{dirname as Ie,join as _e}from"path";import{homedir as Ee}from"os";import{PostHog as De}from"posthog-node";var ne=process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN??process.env.POSTHOG_PROJECT_TOKEN??"phc_Dmh4w8YFNosi3YHD4Sv7ShHX7ccS8kmtRcm8XSVmB5jT",Le=process.env.NEXT_PUBLIC_POSTHOG_HOST??process.env.POSTHOG_HOST??"https://us.i.posthog.com",Ue="@inkly-org/cli@0.5.1",V=_e(Ee(),".inkly","analytics.json"),te=null,$=null,re=null;function Re(){return!!ne&&process.env.INKLY_TELEMETRY_DISABLED!=="1"}function $e(){return Re()?(te??=new De(ne,{host:Le,flushAt:1,flushInterval:0}),te):null}async function Me(){try{let e=await xe(V,"utf8");return JSON.parse(e)}catch{return{}}}async function Ne(e){await Pe(Ie(V),{recursive:!0}),await Te(V,JSON.stringify(e,null,2)+`
|
|
3
|
+
`,{encoding:"utf8",mode:384})}async function Oe(){return $||($=(async()=>{let e=await Me();if(typeof e.platformUserId=="string"&&e.platformUserId&&(re=e.platformUserId),typeof e.distinctId=="string"&&e.distinctId)return e.distinctId;let r=`cli_${Ae()}`;return await Ne({...e,distinctId:r}),r})(),$)}async function Fe(){let e=await Oe();return re??e}function He(){return{surface:"cli",release:process.env.POSTHOG_RELEASE??Ue,node_version:process.versions.node,platform:process.platform,arch:process.arch,ci:!!process.env.CI}}async function ie(e,r={}){let i=$e();if(i)try{i.capture({distinctId:await Fe(),event:e,properties:{...He(),...r}})}catch{}}import{mkdir as je,rename as Be,writeFile as We}from"fs/promises";import{dirname as ze}from"path";async function oe(e,r,i){await je(ze(e),{recursive:!0});let n=`${e}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await We(n,r,i?.mode!=null?{mode:i.mode}:void 0),await Be(n,e)}var de=`Options:
|
|
4
4
|
--url <url> URL to open and arm for recording.
|
|
5
5
|
--name <name> Demo name written into the exported ZIP.
|
|
6
6
|
--session <id> Session id printed by start.
|
|
@@ -20,7 +20,7 @@ var An=Object.defineProperty;var Pn=(t,e)=>{for(var n in e)An(t,n,{get:e[n],enum
|
|
|
20
20
|
done once in this profile survives, so later captures of the same site need
|
|
21
21
|
no re-login. Implies --keep-profile. Run --headed the first time so the user
|
|
22
22
|
can sign in; reuse can run headless.
|
|
23
|
-
--no-unpack On stop, write only the ZIP.`,
|
|
23
|
+
--no-unpack On stop, write only the ZIP.`,Xe=`inkly capture - capture an image/video walkthrough for an external browser agent
|
|
24
24
|
|
|
25
25
|
Usage:
|
|
26
26
|
inkly capture start --url <url> --name <name>
|
|
@@ -28,14 +28,16 @@ Usage:
|
|
|
28
28
|
inkly capture cancel --session <id>
|
|
29
29
|
inkly capture profiles
|
|
30
30
|
|
|
31
|
-
${
|
|
31
|
+
${de}
|
|
32
32
|
--video, --record-video Record motion segments. Enabled by default; use --no-video to disable.
|
|
33
33
|
--zoom Apply click zoom/pan to screenshot steps. Enabled by default; use --no-zoom to disable.
|
|
34
|
+
--compress-images Re-encode captured PNG/JPEG screenshots to WebP (smaller, near-lossless).
|
|
35
|
+
--subset-fonts Subset any captured font assets to the glyphs used and convert to WOFF2.
|
|
34
36
|
|
|
35
37
|
Output:
|
|
36
38
|
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
37
39
|
For self-contained HTML snapshot capture, use \`inkly capture-html\`.
|
|
38
|
-
`,
|
|
40
|
+
`,mn=`inkly capture-html - capture a self-contained HTML walkthrough for an external browser agent
|
|
39
41
|
|
|
40
42
|
Usage:
|
|
41
43
|
inkly capture-html start --url <url> --name <name>
|
|
@@ -43,21 +45,19 @@ Usage:
|
|
|
43
45
|
inkly capture-html cancel --session <id>
|
|
44
46
|
inkly capture-html profiles
|
|
45
47
|
|
|
46
|
-
${
|
|
48
|
+
${de}
|
|
47
49
|
--block-videos Replace <video> with its poster frame instead of inlining the video.
|
|
48
|
-
--compress-images Re-encode captured PNG/JPEG images to WebP (smaller, near-lossless).
|
|
49
|
-
--subset-fonts Subset fonts to the glyphs used and convert to WOFF2.
|
|
50
50
|
|
|
51
51
|
Output:
|
|
52
52
|
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
53
|
-
`,
|
|
53
|
+
`,Qe=ue(qe(import.meta.url));var pe=1440,me=900;var fe=4e3,M=30,se=480,et=7e3,tt=20,nt=1200,rt=1500;function T(e){return new Promise(r=>setTimeout(r,e))}function it(e,r){if(!Object.prototype.hasOwnProperty.call(e,r))return;let i=e[r];return typeof i=="string"?i:""}function ot(e){return{click_tag:e?.tag??null,has_click_label:!!e?.label,has_click_selector:!!e?.selector,has_click_alpha_id:!!e?.alphaId}}async function N(e){await ie("inkly_cli_capture_step_captured",{runtime:e.session.runtime??"cli",capture_kind:e.session.cliCaptureKind??e.stepKind,step_kind:e.stepKind,action:e.action,step_count:e.session.cliScreens?.length??null,window_width:e.session.width,window_height:e.session.height,record_video:e.session.cliRecordVideo===!0,auto_apply_zoom:e.session.autoApplyZoom!==!1,...ot(e.click)})}function ae(e){let r=e.cliScreens??[],i=r[r.length-1]?.kind;return i==="video"||i==="html"?i:"image"}function st(e,r,i){let n=it(e,r);if(!n)throw new Error(`missing --${r} <value>
|
|
54
54
|
|
|
55
|
-
${
|
|
55
|
+
${i}`);return n}function le(e,r){let i=Ke(e);for(;;){let n=b(i,r);if(Ze(n))return n;let t=ue(i);if(t===i)return null;i=t}}var I=class{constructor(r){this.nextId=1;this.pending=new Map;this.listeners=new Map;this.ws=new Ye(r,{perMessageDeflate:!1,maxPayload:512*1024*1024}),this.ready=new Promise((i,n)=>{this.ws.once("open",()=>i()),this.ws.once("error",t=>n(t))}),this.ws.on("message",i=>{let n=JSON.parse(i.toString());if(typeof n.id=="number"&&this.pending.has(n.id)){let o=this.pending.get(n.id);if(this.pending.delete(n.id),!o)return;n.error?o.reject(new Error(`${n.error.message??"CDP error"}: ${JSON.stringify(n.error.data??"")}`)):o.resolve(n.result??{});return}if(!n.method)return;let t=this.listeners.get(n.method);if(t)for(let o of t)o(n.params,n.sessionId)})}async send(r,i={},n){await this.ready;let t=this.nextId;this.nextId+=1;let o={id:t,method:r,params:i};return n&&(o.sessionId=n),new Promise((s,d)=>{this.pending.set(t,{resolve:s,reject:d}),this.ws.send(JSON.stringify(o),a=>{a&&(this.pending.delete(t),d(a))})})}on(r,i){let n=this.listeners.get(r)??new Set;return n.add(i),this.listeners.set(r,n),()=>n.delete(i)}close(){try{this.ws.close()}catch{}}};async function S(e,r,i,n=3e4){let t=await e.send("Runtime.evaluate",{expression:i,awaitPromise:!0,returnByValue:!0,timeout:n,userGesture:!0},r);if(t.exceptionDetails)throw new Error(`Runtime.evaluate failed: ${JSON.stringify(t.exceptionDetails)}`);return t.result?.value}async function H(e,r){let n=(await e.send("Target.attachToTarget",{targetId:r,flatten:!0})).sessionId;if(typeof n!="string")throw new Error("Target.attachToTarget returned no sessionId");return n}async function ce(e){return((await e.send("Target.getTargets",{filter:[{type:"page"}]})).targetInfos??[]).filter(n=>n.type==="page")}async function at(e,r){let i=await S(e,r,`JSON.stringify({
|
|
56
56
|
innerWidth: window.innerWidth,
|
|
57
57
|
innerHeight: window.innerHeight,
|
|
58
58
|
outerWidth: window.outerWidth,
|
|
59
59
|
outerHeight: window.outerHeight
|
|
60
|
-
})`,5e3),
|
|
60
|
+
})`,5e3),n=JSON.parse(String(i)),t={innerWidth:Number(n.innerWidth),innerHeight:Number(n.innerHeight),outerWidth:Number(n.outerWidth),outerHeight:Number(n.outerHeight)};if(!Number.isFinite(t.innerWidth)||!Number.isFinite(t.innerHeight)||!Number.isFinite(t.outerWidth)||!Number.isFinite(t.outerHeight))throw new Error(`could not measure Chrome viewport: ${JSON.stringify(n)}`);return t}async function j(e,r,i,n,t){try{let s=(await e.send("Browser.getWindowForTarget",{targetId:i})).windowId;if(typeof s!="number")throw new Error("Browser.getWindowForTarget returned no windowId");for(let d=0;d<4;d+=1){let a=await at(e,r),g=Math.max(0,a.outerWidth-a.innerWidth),p=Math.max(0,a.outerHeight-a.innerHeight),m=n+g,y=t+p;if(Math.abs(a.innerWidth-n)<=1&&Math.abs(a.innerHeight-t)<=1)return;await e.send("Browser.setWindowBounds",{windowId:s,bounds:{windowState:"normal",width:m,height:y}}),await T(250)}}catch{}await e.send("Emulation.setDeviceMetricsOverride",{width:n,height:t,deviceScaleFactor:1,mobile:!1},r).catch(()=>{}),await T(100)}function J(e){if(e.length<24)return null;let r=[137,80,78,71,13,10,26,10];for(let s=0;s<r.length;s+=1)if(e[s]!==r[s])return null;if(String.fromCharCode(e[12],e[13],e[14],e[15])!=="IHDR")return null;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=n.getUint32(16,!1),o=n.getUint32(20,!1);return t>0&&o>0?{width:t,height:o}:null}var Z=`(() => {
|
|
61
61
|
if (window.__inklyCliRecorderInstalled) return;
|
|
62
62
|
window.__inklyCliRecorderInstalled = true;
|
|
63
63
|
window.__inklyCliLastClick = null;
|
|
@@ -241,7 +241,7 @@ function selectorFor(el) {
|
|
|
241
241
|
window.addEventListener("scroll", onMotionScroll, true);
|
|
242
242
|
window.addEventListener("wheel", onMotionScroll, true);
|
|
243
243
|
window.addEventListener("touchmove", onMotionScroll, true);
|
|
244
|
-
})();`;async function
|
|
244
|
+
})();`;async function B(e,r,i=!1){i&&(await e.send("Runtime.addBinding",{name:"__inklyCliCaptureEvent"},r).catch(()=>{}),await e.send("Runtime.addBinding",{name:"__inklyCliCaptureClick"},r).catch(()=>{})),await e.send("Page.addScriptToEvaluateOnNewDocument",{source:Z},r),await S(e,r,Z,5e3).catch(()=>{})}async function W(e,r){await S(e,r,Z,5e3).catch(()=>{});let i=await S(e,r,`JSON.stringify({
|
|
245
245
|
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
246
246
|
sourceUrl: location.href,
|
|
247
247
|
title: document.title || "Captured screen",
|
|
@@ -252,7 +252,7 @@ function selectorFor(el) {
|
|
|
252
252
|
maxX: Math.max(0, document.documentElement.scrollWidth - window.innerWidth),
|
|
253
253
|
maxY: Math.max(0, document.documentElement.scrollHeight - window.innerHeight)
|
|
254
254
|
}
|
|
255
|
-
})`,5e3),
|
|
255
|
+
})`,5e3),n=JSON.parse(String(i));return{viewport:{width:Number(n.viewport?.width)||pe,height:Number(n.viewport?.height)||me},sourceUrl:typeof n.sourceUrl=="string"?n.sourceUrl:"",title:typeof n.title=="string"?n.title:"Captured screen",click:n.click??null,scroll:{x:Number(n.scroll?.x)||0,y:Number(n.scroll?.y)||0,maxX:Number(n.scroll?.maxX)||0,maxY:Number(n.scroll?.maxY)||0}}}function lt(){let e=le(process.cwd(),"packages/capture-extension/dist/singlefile-injected.js"),r=le(Qe,"packages/capture-extension/dist/singlefile-injected.js"),i=e??r;if(!i)throw new Error("SingleFile bundle not found. Run `npm run extension:build` before --html capture.");return i}var ct={removeFrames:!0,removeImports:!0,blockScripts:!0,compressHTML:!1,compressCSS:!1,saveRawPage:!1,loadDeferredImages:!1,loadDeferredImagesMaxIdleTime:1500,loadDeferredImagesKeepZoomLevel:!1,loadDeferredImagesBlockCookies:!1,loadDeferredImagesBlockStorage:!1,blockMixedContent:!1,insertMetaCSP:!0,insertMetaNoIndex:!1,insertSingleFileComment:!1,removeAlternativeFonts:!0,removeAlternativeImages:!0,removeAlternativeMedias:!0,removeUnusedFonts:!0,backgroundSave:!1,removeUnusedStyles:!0,removeHiddenElements:!0,compressContent:!1},K="__inklySingleFileFetch",ut=`(() => {
|
|
256
256
|
if (globalThis.__inklyFetchInstalled) return;
|
|
257
257
|
globalThis.__inklyFetchInstalled = true;
|
|
258
258
|
const pending = new Map();
|
|
@@ -272,7 +272,7 @@ function selectorFor(el) {
|
|
|
272
272
|
const id = nextId++;
|
|
273
273
|
pending.set(id, { resolve, reject });
|
|
274
274
|
try {
|
|
275
|
-
globalThis.${
|
|
275
|
+
globalThis.${K}(JSON.stringify({
|
|
276
276
|
id,
|
|
277
277
|
url: String(url),
|
|
278
278
|
options: {
|
|
@@ -295,7 +295,7 @@ function selectorFor(el) {
|
|
|
295
295
|
return viaNode(url, options);
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
|
-
})();`;function
|
|
298
|
+
})();`;function dt(e,r){let i,n,t;try{let o=new URL(e);i=o.hostname,n=o.pathname||"/",t=o.protocol==="https:"}catch{return""}return r.filter(o=>{let s=o.domain.replace(/^\./,""),d=i===s||i.endsWith(`.${s}`),a=n.startsWith(o.path||"/"),g=!o.secure||t;return d&&a&&g}).map(o=>`${o.name}=${o.value}`).join("; ")}async function pt(e,r,i,n){let t;try{let o=JSON.parse(i);t=o.id;let s={...o.options?.headers??{}},d=dt(o.url,n);d&&(s.cookie=d),o.options?.referrer&&(s.referer=o.options.referrer);let a=await fetch(o.url,{headers:s,redirect:"follow"}),g=Buffer.from(await a.arrayBuffer()),p={};a.headers.forEach((y,v)=>{p[v]=y});let m={status:a.status,headers:p,data:g.toString("base64")};await S(e,r,`globalThis.__inklyResolveFetch(${t}, ${JSON.stringify(m)})`,2e4)}catch(o){if(t===void 0)return;await S(e,r,`globalThis.__inklyRejectFetch(${t}, ${JSON.stringify({error:String(o)})})`,2e4).catch(()=>{})}}var G=Math.max(6e4,Number(process.env.INKLY_CAPTURE_TIMEOUT_MS)||24e4);async function mt(e,r,i=!1){let n=await F(lt(),"utf8");await e.send("Network.enable",{},r).catch(()=>{}),await e.send("Runtime.addBinding",{name:K},r).catch(()=>{});let t=[];try{t=(await e.send("Network.getAllCookies",{},r)).cookies??[]}catch{}let o=e.on("Runtime.bindingCalled",(s,d)=>{if(d!==r)return;let a=s;a.name!==K||typeof a.payload!="string"||pt(e,r,a.payload,t)});try{await S(e,r,n,3e4),await S(e,r,ut,1e4);let s=await S(e,r,`(async () => {
|
|
299
299
|
const sf = globalThis.__inklySingleFile;
|
|
300
300
|
if (!sf || typeof sf.getPageData !== "function") throw new Error("SingleFile not loaded");
|
|
301
301
|
// initOptions (2nd arg) is forwarded to single-file-core/core/util.js
|
|
@@ -306,15 +306,15 @@ function selectorFor(el) {
|
|
|
306
306
|
frameFetch: globalThis.__inklyPrivilegedFetch,
|
|
307
307
|
};
|
|
308
308
|
const data = await Promise.race([
|
|
309
|
-
sf.getPageData(${JSON.stringify({...
|
|
310
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error("SingleFile getPageData exceeded ${
|
|
309
|
+
sf.getPageData(${JSON.stringify({...ct,blockVideos:i})}, initOptions),
|
|
310
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("SingleFile getPageData exceeded ${G}ms")), ${G}))
|
|
311
311
|
]);
|
|
312
312
|
if (typeof data.content === "string") return data.content;
|
|
313
313
|
return new TextDecoder().decode(new Uint8Array(data.content));
|
|
314
|
-
})()`,
|
|
315
|
-
`)}async function
|
|
316
|
-
`)});let
|
|
317
|
-
`)}))}),
|
|
318
|
-
`)})}
|
|
319
|
-
`)})}});let
|
|
314
|
+
})()`,G+15e3);return String(s)}finally{o()}}async function ft(e,r){if(e.runtime!=="cli")throw new Error("HTML capture is only available for --runtime cli sessions");if(!e.captureDir)throw new Error("CLI capture session has no captureDir");let i=new I(e.browserWsUrl);try{let n=await H(i,e.targetId);await i.send("Page.enable",{},n).catch(()=>{}),await i.send("Runtime.enable",{},n).catch(()=>{}),await B(i,n),await j(i,n,e.targetId,e.width,e.height);let t=await W(i,n),o=await mt(i,n,e.cliBlockVideos===!0),s=(e.cliScreens?.length??0)+1,d=b(e.captureDir,`html-${String(s).padStart(3,"0")}`),a=b(d,"index.html");await O(d,{recursive:!0}),await U(a,o,"utf8");let g={...e,cliScreens:[...e.cliScreens??[],{kind:"html",pngPath:null,htmlPath:a,viewport:t.viewport,naturalSize:t.viewport,sourceUrl:t.sourceUrl,title:t.title,click:r??t.click,scroll:t.scroll,capturedAt:new Date().toISOString()}],tabUrl:t.sourceUrl};return await i.send("Target.detachFromTarget",{sessionId:n}).catch(()=>{}),await _(g),g}finally{i.close()}}async function gt(e){await new Promise((r,i)=>{let n=Ve("ffmpeg",e,{stdio:["ignore","ignore","pipe"]}),t=[];n.stderr.on("data",o=>t.push(o)),n.on("error",i),n.on("close",o=>{if(o===0){r();return}i(new Error(`ffmpeg exited ${o}: ${Buffer.concat(t).toString("utf8").slice(-2e3)}`))})})}async function ht(e){let r=[...e.frames].sort((h,k)=>h.receivedAt-k.receivedAt),i=[],n=r[0]?.receivedAt;if(n!==void 0){let h=1e3/M,k=n;for(let A of r)A.receivedAt<k&&A!==r[r.length-1]||(i.push(A),k=A.receivedAt+h)}let t=i.slice(-Math.ceil(fe/1e3*M)-2),o=t[0]?.receivedAt,s=t[t.length-1]?.receivedAt,d=o!==void 0&&s!==void 0?s-o:0;if(t.length<tt||d<nt||new Set(t.map(h=>h.data)).size<=1)return null;let a=Math.ceil(rt/1e3*M),g=t.length>=a?t:t.concat(Array.from({length:a-t.length},()=>t[t.length-1])),p=b(e.captureDir,`video-${String(e.index).padStart(3,"0")}`);await Ge(p,{recursive:!0,force:!0}).catch(()=>{}),await O(p,{recursive:!0});for(let[h,k]of g.entries())await U(b(p,`frame-${String(h+1).padStart(5,"0")}.png`),Buffer.from(k.data,"base64"));let m=b(p,"poster.png");await U(m,Buffer.from(t[0].data,"base64"));let y=b(e.captureDir,`video-${String(e.index).padStart(3,"0")}.webm`);await gt(["-y","-framerate",String(M),"-i",b(p,"frame-%05d.png"),"-c:v","libvpx-vp9","-pix_fmt","yuv420p","-deadline","realtime","-cpu-used","6",y]);let v=new Uint8Array(await F(m));return{videoPath:y,posterPngPath:m,naturalSize:J(v)??{width:pe,height:me}}}async function ge(e,r,i,n){if(!e.captureDir)throw new Error("CLI capture session has no captureDir");let t=Buffer.from(r,"base64"),o=(e.cliScreens?.length??0)+1,s=b(e.captureDir,`screen-${String(o).padStart(3,"0")}.png`);await O(e.captureDir,{recursive:!0}),await U(s,t);let d=J(t)??i.viewport,a={...e,cliScreens:[...e.cliScreens??[],{kind:"image",pngPath:s,viewport:i.viewport,naturalSize:d,sourceUrl:i.sourceUrl,title:i.title,click:n,scroll:i.scroll,capturedAt:new Date().toISOString()}],tabUrl:i.sourceUrl};return await _(a),a}async function wt(e,r,i,n,t){if(e.runtime!=="cli")throw new Error("video capture is only available for --runtime cli sessions");if(!e.captureDir)throw new Error("CLI capture session has no captureDir");let o=n??null,s=null;try{if(!o){s=new I(e.browserWsUrl);let p=await H(s,e.targetId);await s.send("Page.enable",{},p).catch(()=>{}),await s.send("Runtime.enable",{},p).catch(()=>{}),await B(s,p),await j(s,p,e.targetId,e.width,e.height),o=await W(s,p),await s.send("Target.detachFromTarget",{sessionId:p}).catch(()=>{})}let d=(e.cliScreens?.length??0)+1,a=await ht({frames:r,captureDir:e.captureDir,index:d});if(!a)return t&&n?ge(e,t,n,i??null):he(e,void 0,i,"click");let g={...e,cliScreens:[...e.cliScreens??[],{kind:"video",pngPath:a.posterPngPath,videoPath:a.videoPath,posterPngPath:a.posterPngPath,viewport:o.viewport,naturalSize:a.naturalSize,sourceUrl:o.sourceUrl,title:o.title,click:i??o.click,scroll:o.scroll,capturedAt:new Date().toISOString()}],tabUrl:o.sourceUrl};return await _(g),g}finally{s?.close()}}async function he(e,r,i,n="click"){if(e.runtime!=="cli")throw new Error("capture is only available for --runtime cli sessions");if(!e.captureDir)throw new Error("CLI capture session has no captureDir");let t=new I(e.browserWsUrl);try{let o=await H(t,e.targetId);await t.send("Page.enable",{},o).catch(()=>{}),await t.send("Runtime.enable",{},o).catch(()=>{}),await B(t,o),await j(t,o,e.targetId,e.width,e.height);let s=await W(t,o),a=(await t.send("Page.captureScreenshot",{format:"png",fromSurface:!0,captureBeyondViewport:!1},o)).data;if(typeof a!="string")throw new Error("Page.captureScreenshot returned no data");let g=Buffer.from(a,"base64"),p=(e.cliScreens?.length??0)+1,m=b(e.captureDir,`screen-${String(p).padStart(3,"0")}.png`);await O(e.captureDir,{recursive:!0}),await U(m,g);let y=J(g)??s.viewport,v=n==="click"?i??s.click:null,h=r&&n==="click"?{...v??{x:.5,y:.5},label:r}:v,k={...e,cliScreens:[...e.cliScreens??[],{kind:"image",pngPath:m,viewport:s.viewport,naturalSize:y,sourceUrl:s.sourceUrl,title:s.title,click:h,scroll:s.scroll,capturedAt:new Date().toISOString()}],tabUrl:s.sourceUrl};return await t.send("Target.detachFromTarget",{sessionId:o}).catch(()=>{}),await _(k),k}finally{t.close()}}function we(){return b(process.env.INKLY_CAPTURE_AGENT_HOME||b(Je(),".inkly"),"capture-agent","sessions")}function ye(e){if(!/^[a-zA-Z0-9._:-]+$/.test(e))throw new Error(`invalid session id: ${e}`);return b(we(),`${e}.json`)}function yt(e){return b(we(),`${e}.listener.json`)}async function bt(e){try{let r=await F(yt(e),"utf8");return JSON.parse(r)}catch{return null}}async function _(e){await oe(ye(e.id),`${JSON.stringify(e,null,2)}
|
|
315
|
+
`)}async function x(e){let r=await F(ye(e),"utf8");return JSON.parse(r)}async function be(e){let r=st(e,"session",Xe),i=await x(r);if(i.runtime!=="cli")throw new Error("listen subcommand is only available for cli runtime sessions");let n=await bt(r),t=new I(i.browserWsUrl),o=null,s=i.targetId,d=Promise.resolve(),a=Promise.resolve(),g=0,p=new Set,m=[],y=!1,v=null,h=null,k=!1;async function A(u){o&&(await t.send("Page.stopScreencast",{},o).catch(()=>{}),await t.send("Target.detachFromTarget",{sessionId:o}).catch(()=>{})),m=[],y=!1,v=null,h=null,s=u,o=await H(t,u),await t.send("Page.enable",{},o).catch(()=>{}),await t.send("Runtime.enable",{},o).catch(()=>{});let w=await x(r).catch(()=>i);await j(t,o,u,w.width,w.height),await B(t,o,!0),m=[],y=!1,v=null,h=null;let c=await x(r).catch(()=>w);c.cliRecordVideo&&c.cliCaptureKind!=="html"&&await t.send("Page.startScreencast",{format:"png",quality:90,maxWidth:c.width,maxHeight:c.height,everyNthFrame:1},o).catch(f=>{process.stderr.write(`capture video start failed: ${f.message}
|
|
316
|
+
`)});let l=await x(r).catch(()=>i);await _({...l,targetId:u,cliListenerPid:l.cliListenerPid??n?.cliListenerPid??null,cliListenerLogPath:l.cliListenerLogPath??n?.cliListenerLogPath??null,cliListenerReadyAt:l.cliListenerReadyAt??new Date().toISOString()})}async function R(u){k||(k=!0,o&&(await t.send("Page.stopScreencast",{},o).catch(()=>{}),await t.send("Target.detachFromTarget",{sessionId:o}).catch(()=>{})),t.close(),process.exit(u))}process.once("SIGTERM",()=>{R(0)}),process.once("SIGINT",()=>{R(0)}),await t.send("Target.setDiscoverTargets",{discover:!0}).catch(()=>{});for(let u of await ce(t).catch(()=>[]))p.add(u.targetId);await A(i.targetId);{let u=await x(r).catch(()=>i);await _({...u,targetId:s,cliListenerPid:u.cliListenerPid??n?.cliListenerPid??null,cliListenerLogPath:u.cliListenerLogPath??n?.cliListenerLogPath??null,cliListenerReadyAt:u.cliListenerReadyAt??new Date().toISOString()})}t.on("Target.targetCreated",u=>{let c=u.targetInfo;!c||c.type!=="page"||!(c.openerId===s||Date.now()<g)||(a=a.then(async()=>{await T(250),await A(c.targetId),p.add(c.targetId)}).catch(f=>{process.stderr.write(`capture target follow failed: ${f.message}
|
|
317
|
+
`)}))}),t.on("Page.screencastFrame",(u,w)=>{if(w!==o)return;let c=u;typeof c.sessionId=="number"&&t.send("Page.screencastFrameAck",{sessionId:c.sessionId},w).catch(()=>{}),typeof c.data=="string"&&(m.push({data:c.data,receivedAt:Date.now()}),m.length>se&&(m=m.slice(-se)))});async function q(){let u=await ce(t).catch(()=>[]),w=u.find(c=>c.openerId===s)??u.find(c=>c.targetId!==s&&!p.has(c.targetId));for(let c of u)p.add(c.targetId);!w||w.targetId===s||await A(w.targetId)}async function Y(u){!u||!o||await t.send("Page.navigate",{url:u},o).catch(w=>{process.stderr.write(`capture post-click navigation failed: ${w.message}
|
|
318
|
+
`)})}t.on("Runtime.bindingCalled",(u,w)=>{if(w!==o)return;let c=u;if(c.name!=="__inklyCliCaptureEvent"&&c.name!=="__inklyCliCaptureClick"||typeof c.payload!="string")return;let l=null;try{let f=JSON.parse(c.payload);c.name==="__inklyCliCaptureClick"?l={type:"click",click:f,page:null}:l={type:f.type==="input"||f.type==="scroll"?f.type:"click",click:typeof f.click=="object"&&f.click?f.click:null,page:typeof f.page=="object"&&f.page?f.page:null}}catch{l=null}if(l){if(l.type==="click")g=Date.now()+3e3;else{let f=Date.now();v=v??f,h=f,y=!0}d=d.then(async()=>{if(l.type!=="click")return;let f=Date.now(),E=v,X=h,ke=y&&E!==null&&X!==null&&f-X<=et;y=!1,v=null,h=null;let Ce=Math.max(E?E-250:0,f-fe),Se=E?m.filter(C=>C.receivedAt>=Ce):[...m],z=l.page?.navigationUrl??null,D=m.length?m[m.length-1].data:null,L=l.page?{viewport:l.page.viewport,sourceUrl:l.page.url,title:l.page.title,click:l.click,scroll:l.page.scroll}:null;if(o&&(L||(L=await W(t,o).catch(()=>null)),!D)){let C=await t.send("Page.captureScreenshot",{format:"png",fromSurface:!0,captureBeyondViewport:!1},o).catch(()=>null),ee=C&&C.data;D=typeof ee=="string"?ee:null}m=[];let P=await x(r).catch(()=>null);if(!P||P.runtime!=="cli"){await R(0);return}if(P.cliCaptureKind==="html"){await T(z?500:2e3);let C=await ft(P,l.click);await N({session:C,stepKind:"html",action:l.type,click:l.click}),await Y(z),await T(2e3),await a,await q();return}if(await Y(z),await T(2e3),await a,await q(),P.cliRecordVideo&&ke){let C=await wt(P,Se,l.click,L??void 0,D);await N({session:C,stepKind:ae(C),action:l.type,click:l.click});return}if(D&&L){let C=await ge(P,D,L,l.click??null);await N({session:C,stepKind:"image",action:l.type,click:l.click});return}let Q=await he(P,void 0,l.click,"click");await N({session:Q,stepKind:ae(Q),action:l.type,click:l.click})}).catch(f=>{process.stderr.write(`capture listener failed: ${f.message}
|
|
319
|
+
`)})}});let ve=setInterval(()=>{x(r).catch(()=>{clearInterval(ve),R(0)})},1e3);return await new Promise(()=>{}),0}async function kt(){let e=vt(process.argv.slice(2));process.exit(await be(e))}kt().catch(e=>{process.stderr.write(`capture listener failed: ${e.message}
|
|
320
320
|
`),process.exit(1)});
|