@inkly-org/cli 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -6
- package/dist/capture-listener.js +33 -21
- package/dist/cli.js +239 -158
- package/package.json +3 -1
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Io=Object.defineProperty;var Po=(t,e)=>{for(var n in e)Io(t,n,{get:e[n],enumerable:!0})};import ih from"mri";import{existsSync as Zr,statSync as oh}from"fs";import{isAbsolute as sh,join as po,resolve as lh}from"path";import{Buffer as wd}from"buffer";import{mkdir as Ja,writeFile as vd,access as Sd}from"fs/promises";import{dirname as _d,join as Cd,resolve as Td,sep as Za}from"path";var l={};Po(l,{BRAND:()=>ts,DIRTY:()=>We,EMPTY_PATH:()=>Do,INVALID:()=>S,NEVER:()=>Us,OK:()=>G,ParseStatus:()=>Z,Schema:()=>A,ZodAny:()=>De,ZodArray:()=>ve,ZodBigInt:()=>Je,ZodBoolean:()=>Ze,ZodBranded:()=>Vt,ZodCatch:()=>at,ZodDate:()=>Ge,ZodDefault:()=>rt,ZodDiscriminatedUnion:()=>cn,ZodEffects:()=>se,ZodEnum:()=>tt,ZodError:()=>Q,ZodFirstPartyTypeKind:()=>_,ZodFunction:()=>pn,ZodIntersection:()=>Xe,ZodIssueCode:()=>m,ZodLazy:()=>Qe,ZodLiteral:()=>et,ZodMap:()=>wt,ZodNaN:()=>St,ZodNativeEnum:()=>nt,ZodNever:()=>de,ZodNull:()=>Ke,ZodNullable:()=>me,ZodNumber:()=>Ve,ZodObject:()=>ee,ZodOptional:()=>ie,ZodParsedType:()=>b,ZodPipeline:()=>Jt,ZodPromise:()=>je,ZodReadonly:()=>it,ZodRecord:()=>un,ZodSchema:()=>A,ZodSet:()=>vt,ZodString:()=>$e,ZodSymbol:()=>xt,ZodTransformer:()=>se,ZodTuple:()=>he,ZodType:()=>A,ZodUndefined:()=>qe,ZodUnion:()=>Ye,ZodUnknown:()=>we,ZodVoid:()=>kt,addIssueToContext:()=>f,any:()=>cs,array:()=>ms,bigint:()=>is,boolean:()=>oa,coerce:()=>zs,custom:()=>ra,date:()=>os,datetimeRegex:()=>ta,defaultErrorMap:()=>xe,discriminatedUnion:()=>ys,effect:()=>Es,enum:()=>As,function:()=>_s,getErrorMap:()=>gt,getParsedType:()=>pe,instanceof:()=>rs,intersection:()=>xs,isAborted:()=>ln,isAsync:()=>bt,isDirty:()=>dn,isValid:()=>Re,late:()=>ns,lazy:()=>Cs,literal:()=>Ts,makeIssue:()=>Wt,map:()=>vs,nan:()=>as,nativeEnum:()=>Is,never:()=>ps,null:()=>ds,nullable:()=>$s,number:()=>ia,object:()=>fs,objectUtil:()=>Fn,oboolean:()=>Ls,onumber:()=>Ns,optional:()=>Rs,ostring:()=>Os,pipeline:()=>js,preprocess:()=>Ds,promise:()=>Ps,quotelessJson:()=>Eo,record:()=>ws,set:()=>Ss,setErrorMap:()=>$o,strictObject:()=>gs,string:()=>aa,symbol:()=>ss,transformer:()=>Es,tuple:()=>ks,undefined:()=>ls,union:()=>bs,unknown:()=>us,util:()=>P,void:()=>hs});var P;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function n(a){throw new Error}t.assertNever=n,t.arrayToEnum=a=>{let i={};for(let o of a)i[o]=o;return i},t.getValidEnumValues=a=>{let i=t.objectKeys(a).filter(s=>typeof a[a[s]]!="number"),o={};for(let s of i)o[s]=a[s];return t.objectValues(o)},t.objectValues=a=>t.objectKeys(a).map(function(i){return a[i]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let i=[];for(let o in a)Object.prototype.hasOwnProperty.call(a,o)&&i.push(o);return i},t.find=(a,i)=>{for(let o of a)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function r(a,i=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(P||(P={}));var Fn;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Fn||(Fn={}));var b=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pe=t=>{switch(typeof t){case"undefined":return b.undefined;case"string":return b.string;case"number":return Number.isNaN(t)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(t)?b.array:t===null?b.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?b.promise:typeof Map<"u"&&t instanceof Map?b.map:typeof Set<"u"&&t instanceof Set?b.set:typeof Date<"u"&&t instanceof Date?b.date:b.object;default:return b.unknown}};var m=P.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"]),Eo=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Q=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(i){return i.message},r={_errors:[]},a=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let s=r,c=0;for(;c<o.path.length;){let d=o.path[c];c===o.path.length-1?(s[d]=s[d]||{_errors:[]},s[d]._errors.push(n(o))):s[d]=s[d]||{_errors:[]},s=s[d],c++}}};return a(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,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let a of this.issues)if(a.path.length>0){let i=a.path[0];n[i]=n[i]||[],n[i].push(e(a))}else r.push(e(a));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Q.create=t=>new Q(t);var Ro=(t,e)=>{let n;switch(t.code){case m.invalid_type:t.received===b.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,P.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${P.joinValues(t.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${P.joinValues(t.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${P.joinValues(t.options)}, received '${t.received}'`;break;case m.invalid_arguments:n="Invalid function arguments";break;case m.invalid_return_type:n="Invalid function return type";break;case m.invalid_date:n="Invalid date";break;case m.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}"`:P.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case m.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 m.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 m.custom:n="Invalid input";break;case m.invalid_intersection_types:n="Intersection results could not be merged";break;case m.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case m.not_finite:n="Number must be finite";break;default:n=e.defaultError,P.assertNever(t)}return{message:n}},xe=Ro;var Kr=xe;function $o(t){Kr=t}function gt(){return Kr}var Wt=t=>{let{data:e,path:n,errorMaps:r,issueData:a}=t,i=[...n,...a.path||[]],o={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let s="",c=r.filter(d=>!!d).slice().reverse();for(let d of c)s=d(o,{data:e,defaultError:s}).message;return{...a,path:i,message:s}},Do=[];function f(t,e){let n=gt(),r=Wt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===xe?void 0:xe].filter(a=>!!a)});t.common.issues.push(r)}var Z=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 a of n){if(a.status==="aborted")return S;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let a of n){let i=await a.key,o=await a.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let a of n){let{key:i,value:o}=a;if(i.status==="aborted"||o.status==="aborted")return S;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},S=Object.freeze({status:"aborted"}),We=t=>({status:"dirty",value:t}),G=t=>({status:"valid",value:t}),ln=t=>t.status==="aborted",dn=t=>t.status==="dirty",Re=t=>t.status==="valid",bt=t=>typeof Promise<"u"&&t instanceof Promise;var x;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(x||(x={}));var oe=class{constructor(e,n,r,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=a}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}},Yr=(t,e)=>{if(Re(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 Q(t.common.issues);return this._error=n,this._error}}};function T(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:a}=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:a}:{errorMap:(o,s)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??r??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:c??n??s.defaultError}},description:a}}var A=class{get description(){return this._def.description}_getType(e){return pe(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:pe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Z,ctx:{common:e.parent.common,data:e.data,parsedType:pe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(bt(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:pe(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Yr(r,a)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pe(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Re(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=>Re(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:pe(e)},a=this._parse({data:e,path:r.path,parent:r}),i=await(bt(a)?a:Promise.resolve(a));return Yr(r,i)}refine(e,n){let r=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,i)=>{let o=e(a),s=()=>i.addIssue({code:m.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(e,n){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof n=="function"?n(r,a):n),!1))}_refinement(e){return new se({schema:this,typeName:_.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 ie.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ve.create(this)}promise(){return je.create(this,this._def)}or(e){return Ye.create([this,e],this._def)}and(e){return Xe.create(this,e,this._def)}transform(e){return new se({...T(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new rt({...T(this._def),innerType:this,defaultValue:n,typeName:_.ZodDefault})}brand(){return new Vt({typeName:_.ZodBranded,type:this,...T(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new at({...T(this._def),innerType:this,catchValue:n,typeName:_.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Jt.create(this,e)}readonly(){return it.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},jo=/^c[^\s-]{8,}$/i,Oo=/^[0-9a-z]+$/,No=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Lo=/^[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,zo=/^[a-z0-9_-]{21}$/i,Uo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Mo=/^[-+]?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)?)??$/,Fo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ho="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Hn,Bo=/^(?:(?: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])$/,Wo=/^(?:(?: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])$/,Vo=/^(([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]))$/,Jo=/^(([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])$/,Zo=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Go=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Qr="((\\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])))",qo=new RegExp(`^${Qr}$`);function ea(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 Ko(t){return new RegExp(`^${ea(t)}$`)}function ta(t){let e=`${Qr}T${ea(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 Yo(t,e){return!!((e==="v4"||!e)&&Bo.test(t)||(e==="v6"||!e)&&Vo.test(t))}function Xo(t,e){if(!Uo.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,"="),a=JSON.parse(atob(r));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function Qo(t,e){return!!((e==="v4"||!e)&&Wo.test(t)||(e==="v6"||!e)&&Jo.test(t))}var $e=class t extends A{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:b.string,received:i.parsedType}),S}let r=new Z,a;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,s=e.data.length<i.value;(o||s)&&(a=this._getOrReturnCtx(e,a),o?f(a,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&f(a,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Fo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"email",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Hn||(Hn=new RegExp(Ho,"u")),Hn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"emoji",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Lo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"uuid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")zo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"nanoid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")jo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Oo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid2",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")No.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ulid",code:m.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),f(a,{validation:"url",code:m.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"regex",code:m.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?ta(i).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?qo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Ko(i).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:m.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Mo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"duration",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Yo(e.data,i.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ip",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Xo(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"jwt",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Qo(e.data,i.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cidr",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Zo.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64",code:m.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Go.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64url",code:m.invalid_string,message:i.message}),r.dirty()):P.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(a=>e.test(a),{validation:n,code:m.invalid_string,...x.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...x.errToObj(e)})}url(e){return this._addCheck({kind:"url",...x.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...x.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...x.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...x.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...x.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...x.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...x.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...x.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...x.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...x.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...x.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...x.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,...x.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,...x.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...x.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...x.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...x.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...x.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...x.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...x.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...x.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...x.errToObj(n)})}nonempty(e){return this.min(1,x.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}};$e.create=t=>new $e({checks:[],typeName:_.ZodString,coerce:t?.coerce??!1,...T(t)});function es(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=n>r?n:r,i=Number.parseInt(t.toFixed(a).replace(".","")),o=Number.parseInt(e.toFixed(a).replace(".",""));return i%o/10**a}var Ve=class t extends A{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)!==b.number){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:b.number,received:i.parsedType}),S}let r,a=new Z;for(let i of this._def.checks)i.kind==="int"?P.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?es(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_finite,message:i.message}),a.dirty()):P.assertNever(i);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,x.toString(n))}gt(e,n){return this.setLimit("min",e,!1,x.toString(n))}lte(e,n){return this.setLimit("max",e,!0,x.toString(n))}lt(e,n){return this.setLimit("max",e,!1,x.toString(n))}setLimit(e,n,r,a){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:x.toString(a)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:x.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:x.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.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"&&P.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)}};Ve.create=t=>new Ve({checks:[],typeName:_.ZodNumber,coerce:t?.coerce||!1,...T(t)});var Je=class t extends A{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)!==b.bigint)return this._getInvalidInput(e);let r,a=new Z;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):P.assertNever(i);return{status:a.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return f(n,{code:m.invalid_type,expected:b.bigint,received:n.parsedType}),S}gte(e,n){return this.setLimit("min",e,!0,x.toString(n))}gt(e,n){return this.setLimit("min",e,!1,x.toString(n))}lte(e,n){return this.setLimit("max",e,!0,x.toString(n))}lt(e,n){return this.setLimit("max",e,!1,x.toString(n))}setLimit(e,n,r,a){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:x.toString(a)}]})}_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:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:x.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}};Je.create=t=>new Je({checks:[],typeName:_.ZodBigInt,coerce:t?.coerce??!1,...T(t)});var Ze=class extends A{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:b.boolean,received:r.parsedType}),S}return G(e.data)}};Ze.create=t=>new Ze({typeName:_.ZodBoolean,coerce:t?.coerce||!1,...T(t)});var Ge=class t extends A{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_type,expected:b.date,received:i.parsedType}),S}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return f(i,{code:m.invalid_date}),S}let r=new Z,a;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:m.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):P.assertNever(i);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:x.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:x.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}};Ge.create=t=>new Ge({checks:[],coerce:t?.coerce||!1,typeName:_.ZodDate,...T(t)});var xt=class extends A{_parse(e){if(this._getType(e)!==b.symbol){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:b.symbol,received:r.parsedType}),S}return G(e.data)}};xt.create=t=>new xt({typeName:_.ZodSymbol,...T(t)});var qe=class extends A{_parse(e){if(this._getType(e)!==b.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:b.undefined,received:r.parsedType}),S}return G(e.data)}};qe.create=t=>new qe({typeName:_.ZodUndefined,...T(t)});var Ke=class extends A{_parse(e){if(this._getType(e)!==b.null){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:b.null,received:r.parsedType}),S}return G(e.data)}};Ke.create=t=>new Ke({typeName:_.ZodNull,...T(t)});var De=class extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return G(e.data)}};De.create=t=>new De({typeName:_.ZodAny,...T(t)});var we=class extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return G(e.data)}};we.create=t=>new we({typeName:_.ZodUnknown,...T(t)});var de=class extends A{_parse(e){let n=this._getOrReturnCtx(e);return f(n,{code:m.invalid_type,expected:b.never,received:n.parsedType}),S}};de.create=t=>new de({typeName:_.ZodNever,...T(t)});var kt=class extends A{_parse(e){if(this._getType(e)!==b.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:b.void,received:r.parsedType}),S}return G(e.data)}};kt.create=t=>new kt({typeName:_.ZodVoid,...T(t)});var ve=class t extends A{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),a=this._def;if(n.parsedType!==b.array)return f(n,{code:m.invalid_type,expected:b.array,received:n.parsedType}),S;if(a.exactLength!==null){let o=n.data.length>a.exactLength.value,s=n.data.length<a.exactLength.value;(o||s)&&(f(n,{code:o?m.too_big:m.too_small,minimum:s?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(f(n,{code:m.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(f(n,{code:m.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,s)=>a.type._parseAsync(new oe(n,o,n.path,s)))).then(o=>Z.mergeArray(r,o));let i=[...n.data].map((o,s)=>a.type._parseSync(new oe(n,o,n.path,s)));return Z.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:x.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:x.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:x.toString(n)}})}nonempty(e){return this.min(1,e)}};ve.create=(t,e)=>new ve({type:t,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...T(e)});function yt(t){if(t instanceof ee){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=ie.create(yt(r))}return new ee({...t._def,shape:()=>e})}else return t instanceof ve?new ve({...t._def,type:yt(t.element)}):t instanceof ie?ie.create(yt(t.unwrap())):t instanceof me?me.create(yt(t.unwrap())):t instanceof he?he.create(t.items.map(e=>yt(e))):t}var ee=class t extends A{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=P.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==b.object){let d=this._getOrReturnCtx(e);return f(d,{code:m.invalid_type,expected:b.object,received:d.parsedType}),S}let{status:r,ctx:a}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof de&&this._def.unknownKeys==="strip"))for(let d in a.data)o.includes(d)||s.push(d);let c=[];for(let d of o){let u=i[d],p=a.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new oe(a,p,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof de){let d=this._def.unknownKeys;if(d==="passthrough")for(let u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(d==="strict")s.length>0&&(f(a,{code:m.unrecognized_keys,keys:s}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let u of s){let p=a.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new oe(a,p,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let d=[];for(let u of c){let p=await u.key,h=await u.value;d.push({key:p,value:h,alwaysSet:u.alwaysSet})}return d}).then(d=>Z.mergeObjectSync(r,d)):Z.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return x.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let a=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:x.errToObj(e).message??a}:{message:a}}}:{}})}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:_.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 P.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 P.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return yt(this)}partial(e){let n={};for(let r of P.objectKeys(this.shape)){let a=this.shape[r];e&&!e[r]?n[r]=a:n[r]=a.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of P.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ie;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return na(P.objectKeys(this.shape))}};ee.create=(t,e)=>new ee({shape:()=>t,unknownKeys:"strip",catchall:de.create(),typeName:_.ZodObject,...T(e)});ee.strictCreate=(t,e)=>new ee({shape:()=>t,unknownKeys:"strict",catchall:de.create(),typeName:_.ZodObject,...T(e)});ee.lazycreate=(t,e)=>new ee({shape:t,unknownKeys:"strip",catchall:de.create(),typeName:_.ZodObject,...T(e)});var Ye=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function a(i){for(let s of i)if(s.result.status==="valid")return s.result;for(let s of i)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;let o=i.map(s=>new Q(s.ctx.common.issues));return f(n,{code:m.invalid_union,unionErrors:o}),S}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(a);{let i,o=[];for(let c of r){let d={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map(c=>new Q(c));return f(n,{code:m.invalid_union,unionErrors:s}),S}}get options(){return this._def.options}};Ye.create=(t,e)=>new Ye({options:t,typeName:_.ZodUnion,...T(e)});var ke=t=>t instanceof Qe?ke(t.schema):t instanceof se?ke(t.innerType()):t instanceof et?[t.value]:t instanceof tt?t.options:t instanceof nt?P.objectValues(t.enum):t instanceof rt?ke(t._def.innerType):t instanceof qe?[void 0]:t instanceof Ke?[null]:t instanceof ie?[void 0,...ke(t.unwrap())]:t instanceof me?[null,...ke(t.unwrap())]:t instanceof Vt||t instanceof it?ke(t.unwrap()):t instanceof at?ke(t._def.innerType):[],cn=class t extends A{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==b.object)return f(n,{code:m.invalid_type,expected:b.object,received:n.parsedType}),S;let r=this.discriminator,a=n.data[r],i=this.optionsMap.get(a);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),S)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let a=new Map;for(let i of n){let o=ke(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of o){if(a.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);a.set(s,i)}}return new t({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:a,...T(r)})}};function Bn(t,e){let n=pe(t),r=pe(e);if(t===e)return{valid:!0,data:t};if(n===b.object&&r===b.object){let a=P.objectKeys(e),i=P.objectKeys(t).filter(s=>a.indexOf(s)!==-1),o={...t,...e};for(let s of i){let c=Bn(t[s],e[s]);if(!c.valid)return{valid:!1};o[s]=c.data}return{valid:!0,data:o}}else if(n===b.array&&r===b.array){if(t.length!==e.length)return{valid:!1};let a=[];for(let i=0;i<t.length;i++){let o=t[i],s=e[i],c=Bn(o,s);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return n===b.date&&r===b.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Xe=class extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),a=(i,o)=>{if(ln(i)||ln(o))return S;let s=Bn(i.value,o.value);return s.valid?((dn(i)||dn(o))&&n.dirty(),{status:n.value,value:s.data}):(f(r,{code:m.invalid_intersection_types}),S)};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(([i,o])=>a(i,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Xe.create=(t,e,n)=>new Xe({left:t,right:e,typeName:_.ZodIntersection,...T(n)});var he=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.array)return f(r,{code:m.invalid_type,expected:b.array,received:r.parsedType}),S;if(r.data.length<this._def.items.length)return f(r,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new oe(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Z.mergeArray(n,o)):Z.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};he.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new he({items:t,typeName:_.ZodTuple,rest:null,...T(e)})};var un=class t extends A{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!==b.object)return f(r,{code:m.invalid_type,expected:b.object,received:r.parsedType}),S;let a=[],i=this._def.keyType,o=this._def.valueType;for(let s in r.data)a.push({key:i._parse(new oe(r,s,r.path,s)),value:o._parse(new oe(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?Z.mergeObjectAsync(n,a):Z.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof A?new t({keyType:e,valueType:n,typeName:_.ZodRecord,...T(r)}):new t({keyType:$e.create(),valueType:e,typeName:_.ZodRecord,...T(n)})}},wt=class extends A{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!==b.map)return f(r,{code:m.invalid_type,expected:b.map,received:r.parsedType}),S;let a=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([s,c],d)=>({key:a._parse(new oe(r,s,r.path,[d,"key"])),value:i._parse(new oe(r,c,r.path,[d,"value"]))}));if(r.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of o){let d=await c.key,u=await c.value;if(d.status==="aborted"||u.status==="aborted")return S;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(d.value,u.value)}return{status:n.value,value:s}})}else{let s=new Map;for(let c of o){let d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return S;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(d.value,u.value)}return{status:n.value,value:s}}}};wt.create=(t,e,n)=>new wt({valueType:e,keyType:t,typeName:_.ZodMap,...T(n)});var vt=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==b.set)return f(r,{code:m.invalid_type,expected:b.set,received:r.parsedType}),S;let a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(f(r,{code:m.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(f(r,{code:m.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let d=new Set;for(let u of c){if(u.status==="aborted")return S;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}let s=[...r.data.values()].map((c,d)=>i._parse(new oe(r,c,r.path,d)));return r.common.async?Promise.all(s).then(c=>o(c)):o(s)}min(e,n){return new t({...this._def,minSize:{value:e,message:x.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:x.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};vt.create=(t,e)=>new vt({valueType:t,minSize:null,maxSize:null,typeName:_.ZodSet,...T(e)});var pn=class t extends A{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==b.function)return f(n,{code:m.invalid_type,expected:b.function,received:n.parsedType}),S;function r(s,c){return Wt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,gt(),xe].filter(d=>!!d),issueData:{code:m.invalid_arguments,argumentsError:c}})}function a(s,c){return Wt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,gt(),xe].filter(d=>!!d),issueData:{code:m.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof je){let s=this;return G(async function(...c){let d=new Q([]),u=await s._def.args.parseAsync(c,i).catch(y=>{throw d.addIssue(r(c,y)),d}),p=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(p,i).catch(y=>{throw d.addIssue(a(p,y)),d})})}else{let s=this;return G(function(...c){let d=s._def.args.safeParse(c,i);if(!d.success)throw new Q([r(c,d.error)]);let u=Reflect.apply(o,this,d.data),p=s._def.returns.safeParse(u,i);if(!p.success)throw new Q([a(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:he.create(e).rest(we.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||he.create([]).rest(we.create()),returns:n||we.create(),typeName:_.ZodFunction,...T(r)})}},Qe=class extends A{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})}};Qe.create=(t,e)=>new Qe({getter:t,typeName:_.ZodLazy,...T(e)});var et=class extends A{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}};et.create=(t,e)=>new et({value:t,typeName:_.ZodLiteral,...T(e)});function na(t,e){return new tt({values:t,typeName:_.ZodEnum,...T(e)})}var tt=class t extends A{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{expected:P.joinValues(r),received:n.parsedType,code:m.invalid_type}),S}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 f(n,{received:n.data,code:m.invalid_enum_value,options:r}),S}return G(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})}};tt.create=na;var nt=class extends A{_parse(e){let n=P.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==b.string&&r.parsedType!==b.number){let a=P.objectValues(n);return f(r,{expected:P.joinValues(a),received:r.parsedType,code:m.invalid_type}),S}if(this._cache||(this._cache=new Set(P.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let a=P.objectValues(n);return f(r,{received:r.data,code:m.invalid_enum_value,options:a}),S}return G(e.data)}get enum(){return this._def.values}};nt.create=(t,e)=>new nt({values:t,typeName:_.ZodNativeEnum,...T(e)});var je=class extends A{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==b.promise&&n.common.async===!1)return f(n,{code:m.invalid_type,expected:b.promise,received:n.parsedType}),S;let r=n.parsedType===b.promise?n.data:Promise.resolve(n.data);return G(r.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};je.create=(t,e)=>new je({type:t,typeName:_.ZodPromise,...T(e)});var se=class extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:o=>{f(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){let o=a.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async s=>{if(n.value==="aborted")return S;let c=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return c.status==="aborted"?S:c.status==="dirty"?We(c.value):n.value==="dirty"?We(c.value):c});{if(n.value==="aborted")return S;let s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?S:s.status==="dirty"?We(s.value):n.value==="dirty"?We(s.value):s}}if(a.type==="refinement"){let o=s=>{let c=a.refinement(s,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?S:(s.status==="dirty"&&n.dirty(),o(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?S:(s.status==="dirty"&&n.dirty(),o(s.value).then(()=>({status:n.value,value:s.value}))))}if(a.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Re(o))return S;let s=a.transform(o.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Re(o)?Promise.resolve(a.transform(o.value,i)).then(s=>({status:n.value,value:s})):S);P.assertNever(a)}};se.create=(t,e,n)=>new se({schema:t,typeName:_.ZodEffects,effect:e,...T(n)});se.createWithPreprocess=(t,e,n)=>new se({schema:e,effect:{type:"preprocess",transform:t},typeName:_.ZodEffects,...T(n)});var ie=class extends A{_parse(e){return this._getType(e)===b.undefined?G(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ie.create=(t,e)=>new ie({innerType:t,typeName:_.ZodOptional,...T(e)});var me=class extends A{_parse(e){return this._getType(e)===b.null?G(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};me.create=(t,e)=>new me({innerType:t,typeName:_.ZodNullable,...T(e)});var rt=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===b.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};rt.create=(t,e)=>new rt({innerType:t,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...T(e)});var at=class extends A{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return bt(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Q(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Q(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};at.create=(t,e)=>new at({innerType:t,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...T(e)});var St=class extends A{_parse(e){if(this._getType(e)!==b.nan){let r=this._getOrReturnCtx(e);return f(r,{code:m.invalid_type,expected:b.nan,received:r.parsedType}),S}return{status:"valid",value:e.data}}};St.create=t=>new St({typeName:_.ZodNaN,...T(t)});var ts=Symbol("zod_brand"),Vt=class extends A{_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}},Jt=class t extends A{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?S:i.status==="dirty"?(n.dirty(),We(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?S:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:_.ZodPipeline})}},it=class extends A{_parse(e){let n=this._def.innerType._parse(e),r=a=>(Re(a)&&(a.value=Object.freeze(a.value)),a);return bt(n)?n.then(a=>r(a)):r(n)}unwrap(){return this._def.innerType}};it.create=(t,e)=>new it({innerType:t,typeName:_.ZodReadonly,...T(e)});function Xr(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function ra(t,e={},n){return t?De.create().superRefine((r,a)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let s=Xr(e,r),c=s.fatal??n??!0;a.addIssue({code:"custom",...s,fatal:c})}});if(!i){let o=Xr(e,r),s=o.fatal??n??!0;a.addIssue({code:"custom",...o,fatal:s})}}):De.create()}var ns={object:ee.lazycreate},_;(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"})(_||(_={}));var rs=(t,e={message:`Input not instance of ${t.name}`})=>ra(n=>n instanceof t,e),aa=$e.create,ia=Ve.create,as=St.create,is=Je.create,oa=Ze.create,os=Ge.create,ss=xt.create,ls=qe.create,ds=Ke.create,cs=De.create,us=we.create,ps=de.create,hs=kt.create,ms=ve.create,fs=ee.create,gs=ee.strictCreate,bs=Ye.create,ys=cn.create,xs=Xe.create,ks=he.create,ws=un.create,vs=wt.create,Ss=vt.create,_s=pn.create,Cs=Qe.create,Ts=et.create,As=tt.create,Is=nt.create,Ps=je.create,Es=se.create,Rs=ie.create,$s=me.create,Ds=se.createWithPreprocess,js=Jt.create,Os=()=>aa().optional(),Ns=()=>ia().optional(),Ls=()=>oa().optional(),zs={string:(t=>$e.create({...t,coerce:!0})),number:(t=>Ve.create({...t,coerce:!0})),boolean:(t=>Ze.create({...t,coerce:!0})),bigint:(t=>Je.create({...t,coerce:!0})),date:(t=>Ge.create({...t,coerce:!0}))};var Us=S;var Wn=l.object({id:l.string()}),Ms=l.enum(["top","right","bottom","left","auto"]).default("auto"),Vn=l.enum(["left","middle","right"]),Fs=Vn.default("left"),sa=l.object({label:l.string().optional(),hidden:l.boolean().default(!1)}),Hs={background:l.string().optional(),textColor:l.string().optional(),borderRadius:l.string().optional(),textAlign:Fs,anchor:Ms,showNavigation:l.boolean().default(!0),prevButton:sa.optional(),nextButton:sa.optional()},Bs=l.enum(["pointer","callout","area"]),Ws=l.discriminatedUnion("type",[l.object({type:l.literal("html-element"),alphaId:l.string().min(1)})]),Vs=Wn.extend({type:l.literal("message"),variant:Bs.default("callout"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),w:l.number().min(0).max(1).optional(),h:l.number().min(0).max(1).optional(),text:l.string().optional(),target:Ws.optional(),advancesStep:l.boolean().default(!0),...Hs}),Js=Wn.extend({type:l.literal("blur"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),w:l.number().min(0).max(1),h:l.number().min(0).max(1),intensity:l.number().min(0).max(20).default(8)}),Zs=Wn.extend({type:l.literal("text"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),text:l.string(),fontSize:l.number().positive().default(16),color:l.string().optional()}),la=l.discriminatedUnion("type",[Vs,Js,Zs]),da=new Set(["message","blur","text"]),ca=l.object({type:l.string()}).passthrough();function ua(t){return typeof t=="object"&&t!==null?t.type:void 0}var pa=l.any().superRefine((t,e)=>{let a=(da.has(ua(t))?la:ca).safeParse(t);if(!a.success)for(let i of a.error.issues)e.addIssue(i)}).transform(t=>(da.has(ua(t))?la:ca).parse(t));var ha=l.object({label:l.string().min(1),href:l.string().refine(t=>/^(https?:|mailto:)/i.test(t),"href must be an http(s) or mailto URL")}),Jn=l.object({logo:l.string().min(1).optional(),name:l.string().min(1).optional(),logoHref:l.string().refine(t=>/^(https?:|mailto:)/i.test(t),"logoHref must be an http(s) or mailto URL").optional(),favicon:l.string().min(1).optional(),cta:ha.optional(),secondaryCta:ha.optional(),watermark:l.boolean().optional()}),ma=Jn.omit({favicon:!0});var Gs=l.object({type:l.literal("next")}),qs=l.object({type:l.literal("prev")}),Ks=l.object({type:l.literal("step"),stepId:l.string().min(1)}),Ys=l.object({type:l.literal("chapter"),chapterId:l.string().min(1)}),Xs=l.object({type:l.literal("url"),href:l.string().min(1),target:l.enum(["_self","_blank"]).default("_blank")}),Qs=l.object({type:l.literal("restart")}),el=l.discriminatedUnion("type",[Gs,qs,Ks,Ys,Xs,Qs]),tl=l.enum(["shimmer"]),hn=l.object({label:l.string().min(1),action:el.default({type:"next"}),animation:tl.optional(),background:l.string().optional(),textColor:l.string().optional()});var nl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Zn=/^[A-Za-z0-9_-]{12}$/;function rl(t){let e=globalThis.crypto;if(!e||typeof e.getRandomValues!="function")throw new Error("generateDemoId requires globalThis.crypto.getRandomValues (Node 19+, browsers, or edge runtime).");e.getRandomValues(t)}function ne(){let t=new Uint8Array(12);rl(t);let e="";for(let n of t)e+=nl.charAt(n&63);return e}function fa(t){return typeof t=="string"&&Zn.test(t)}function ga(t){return String(t+1).padStart(4,"0")}function ba(t){return`snap-${t.toString().padStart(3,"0")}`}function mn(t){let e=((t??"").toLowerCase().split(";")[0]??"").trim();return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e.startsWith("font/")||e.includes("font")||e.includes("woff")?"font":"other"}function Gn(t){if(!t)return"";let e=t.replace(/^(?:tree\s*item|menu\s*item|menuitem|list\s*item|tab(?:\s*panel)?|button|link|option|region|combobox|radio|checkbox|switch|dialog|row|cell|columnheader|rowheader|navigation|article|banner|main|complementary|contentinfo)\s*:?\s+/i,"").trim();return(e.split(/\r?\n/).map(r=>r.trim()).find(Boolean)??e).replace(/\s+/g," ").trim().slice(0,48)}function qn(t){let{stepId:e,assetId:n,posterAssetId:r,kind:a,isLast:i}=t,o=`asset:${n}`,s=a==="video"?{type:"video",src:o,posterSrc:r?`asset:${r}`:void 0,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,alt:t.title,sourceUrl:t.sourceUrl??"",title:t.title,autoplay:!0,muted:!0,objectFit:"cover"}:{type:"image",src:o,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,alt:t.title,sourceUrl:t.sourceUrl??"",title:t.title,objectFit:"cover"},c=t.click,d=[];if(c){let h=Gn(c.label);d.push({id:`${e}_pointer`,type:"message",variant:"pointer",x:c.x,y:c.y,text:h?`Click on "${h}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}else d.push({id:`${e}_callout`,type:"message",variant:"callout",x:.5,y:.5,text:i?"End of walkthrough":"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});let u=!!c&&!(c.x===0&&c.y===0),p=a==="image"&&t.autoApplyZoom===!0&&u?{zoom:1.35,x:Number(Math.max(0,Math.min(1,c.x)).toFixed(4)),y:Number(Math.max(0,Math.min(1,c.y)).toFixed(4))}:void 0;return{id:e,kind:"content",background:s,...p?{transform:p}:{},annotations:d,advance:{trigger:"click"}}}function ya(t){let{stepId:e,htmlPath:n,click:r}=t,a=[];if(r?.alphaId)a.push({id:`${e}_area`,type:"message",variant:"area",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),w:0,h:0,text:Gn(r.label)||"Click here",target:{type:"html-element",alphaId:r.alphaId},anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});else if(r){let i=Gn(r.label);a.push({id:`${e}_pointer`,type:"message",variant:"pointer",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),text:i?`Click on "${i}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}return{id:e,kind:"content",background:{type:"html",path:n,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight,zoom:1,scroll:t.scroll,sourceUrl:t.sourceUrl??"",title:t.sourceUrl??""},annotations:a,advance:{trigger:"click"}}}function al(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Kn(t,e){let n=t;for(let[r,a]of e){let i=al(r);n=n.replace(new RegExp(`(?:\\.\\./)*assets/${i}`,"g"),a),n=n.replace(new RegExp(`assets/${i}`,"g"),a)}return n}function il(t){return`<script data-inkly-replay-scroll>(()=>{const c=${JSON.stringify(t).replace(/<\/(script)/gi,"<\\/$1")};function r(){const d=document.documentElement,b=document.body;const vw=innerWidth||d.clientWidth||0;const vh=innerHeight||d.clientHeight||0;const mx=Math.max(0,Math.max(d.scrollWidth,b?b.scrollWidth:0)-vw);const my=Math.max(0,Math.max(d.scrollHeight,b?b.scrollHeight:0)-vh);const x=c.maxX>0&&mx>0?c.x/c.maxX*mx:c.x;const y=c.maxY>0&&my>0?c.y/c.maxY*my:c.y;scrollTo(Math.max(0,x),Math.max(0,y));}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",r,{once:true});r();requestAnimationFrame(r);setTimeout(r,120);setTimeout(r,500);})();</script>`}function xa(t,e){let n=il(e);return/<\/body\s*>/i.test(t)?t.replace(/<\/body\s*>/i,`${n}</body>`):`${t}${n}`}function ka(t,e){if(!e||/data-inkly-document-css|document\.css/i.test(t))return t;let n='<link rel="stylesheet" href="./document.css?draft=1" data-inkly-document-css>';return/<\/head\s*>/i.test(t)?t.replace(/<\/head\s*>/i,`${n}</head>`):`${n}${t}`}var wa=l.object({id:l.string(),text:l.string(),start:l.number().nonnegative().optional(),end:l.number().nonnegative().optional()});var ol=l.enum(["screenshot","image","video","audio","font","other"]),sl=l.object({id:l.string().min(1),path:l.string().min(1).optional(),uri:l.string().min(1).optional(),sha256:l.string().regex(/^[0-9a-f]{64}$/),kind:ol,contentType:l.string().min(1).optional(),publicUrl:l.string().min(1).optional(),cdnPath:l.string().min(1).optional(),file:l.string().min(1).optional(),size:l.number().int().nonnegative().optional(),createdAt:l.string().min(1).optional(),updatedAt:l.string().min(1).optional(),viewport:l.object({w:l.number().int().positive(),h:l.number().int().positive()}).optional()}),_t=l.object({version:l.literal(1),assets:l.array(sl),screens:l.array(l.unknown()).optional()});var Yn=l.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"}),ll=l.enum(["color","image","glassmorphism"]),va=l.object({type:ll,color:Yn.optional(),from:Yn.optional(),to:Yn.optional(),src:l.string().min(1).optional(),alt:l.string().optional(),intensity:l.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:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:l.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),Sa=l.object({src:l.string(),alt:l.string().optional()});var Xn=l.object({src:l.string().min(1),duration:l.number().positive().optional()});var dl=l.enum(["text","dropdown"]),cl=l.object({value:l.string().min(1),label:l.string().min(1)}),ul=l.object({id:l.string(),label:l.string(),type:dl.default("text"),placeholder:l.string().optional(),required:l.boolean().default(!1),options:l.array(cl).optional()}).superRefine((t,e)=>{t.type==="dropdown"&&(!t.options||t.options.length===0)&&e.addIssue({code:l.ZodIssueCode.custom,message:"Dropdown field requires at least one option.",path:["options"]})}),Ia=l.object({src:l.string().min(1),alt:l.string().optional(),height:l.number().int().positive().optional()}),pl=l.enum(["left","right","top"]),hl=l.enum(["standard","hero"]),Pa=l.object({src:l.string().min(1),alt:l.string().optional(),naturalWidth:l.number().positive().optional(),naturalHeight:l.number().positive().optional(),position:pl.default("right"),layout:hl.default("hero")}),ml=l.object({type:l.literal("headline"),id:l.string(),logo:Ia.optional(),image:Pa.optional(),title:l.string(),titleColor:l.string().optional(),description:l.string().optional(),descriptionColor:l.string().optional(),textAlign:Vn.optional(),cta:hn.optional(),secondaryCta:hn.optional()}),fl=l.object({type:l.literal("form"),id:l.string(),logo:Ia.optional(),image:Pa.optional(),title:l.string().optional(),description:l.string().optional(),fields:l.array(ul).min(1),submit:hn.default({label:"Submit",action:{type:"next"}})}),gl="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",bl="camera; microphone; fullscreen; payment; clipboard-write",yl=l.object({type:l.literal("embed"),id:l.string(),src:l.string(),iframeTitle:l.string().optional(),sandbox:l.string().default(gl),allow:l.string().default(bl)}),xl=l.object({type:l.literal("custom"),id:l.string(),name:l.string().min(1),data:l.record(l.unknown()).optional()}),_a=l.discriminatedUnion("type",[ml,fl,yl,xl]),Ca=new Set(["headline","form","embed","custom"]),Ta=l.object({type:l.string()}).passthrough();function Aa(t){return typeof t=="object"&&t!==null?t.type:void 0}var Ea=l.any().superRefine((t,e)=>{let a=(Ca.has(Aa(t))?_a:Ta).safeParse(t);if(!a.success)for(let i of a.error.issues)e.addIssue(i)}).transform(t=>(Ca.has(Aa(t))?_a:Ta).parse(t));var Ra=l.enum(["contain","cover","fill"]),$a=l.enum(["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"]),kl=l.object({type:l.literal("image"),src:l.string().min(1),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),alt:l.string().optional(),sourceUrl:l.string().optional(),title:l.string().optional(),objectFit:Ra.optional(),objectPosition:$a.optional()}),wl=l.object({type:l.literal("video"),src:l.string().min(1),posterSrc:l.string().min(1).optional(),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),alt:l.string().optional(),sourceUrl:l.string().optional(),title:l.string().optional(),autoplay:l.boolean().default(!0),muted:l.boolean().default(!0),objectFit:Ra.optional(),objectPosition:$a.optional()}),vl=l.object({x:l.number().nonnegative().default(0),y:l.number().nonnegative().default(0),maxX:l.number().nonnegative().default(0),maxY:l.number().nonnegative().default(0)}),Sl=l.object({type:l.literal("html"),path:l.string().min(1),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),zoom:l.number().positive().default(1),scroll:vl.default({x:0,y:0,maxX:0,maxY:0}),sourceUrl:l.string().optional(),title:l.string().optional()}),_l=l.discriminatedUnion("type",[kl,wl,Sl]),Cl=l.object({zoom:l.number().min(1).default(1),x:l.number().min(0).max(1).default(.5),y:l.number().min(0).max(1).default(.5)}),Tl=l.object({trigger:l.enum(["auto","click"]).default("auto")}).default({trigger:"auto"}),Al=l.object({kind:l.literal("content").default("content"),id:l.string(),label:l.string().optional(),duration:l.number().positive().optional(),background:_l,script:l.string().optional(),voiceover:Xn.optional(),transform:Cl.optional(),advance:Tl,annotations:l.array(pa).default([]),captions:l.array(wa).optional()}).passthrough(),Il=l.object({kind:l.literal("cover"),id:l.string(),label:l.string().optional(),widgets:l.array(Ea).length(1),background:va.optional(),backgroundImage:Sa.optional(),backgroundDim:l.number().min(0).max(1).optional(),script:l.string().optional(),voiceover:Xn.optional(),duration:l.number().positive().optional(),advance:l.object({trigger:l.enum(["auto","click"]).default("click")}).default({trigger:"click"})}).passthrough(),Da=l.discriminatedUnion("kind",[Al,Il]);var Pl=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,ja=l.string().regex(Pl,"must be a hex color like #5b3df5"),fn=l.object({primary:ja.optional(),secondary:ja.optional(),font:l.string().min(1).optional(),radius:l.string().min(1).optional()}).partial();var gn=l.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"}),El=l.object({id:l.string(),title:l.string(),stepIds:l.array(l.string()).min(1)}),Rl=l.object({hideHeader:l.boolean().default(!1),hideControls:l.boolean().default(!1),controls:l.enum(["full","minimal","hidden"]).optional(),showHubBreadcrumb:l.boolean().default(!1),mobileFooterMessage:l.boolean().default(!0),autoplay:l.boolean().default(!1)}),$l=l.object({width:l.number().positive(),height:l.number().positive()}),Dl=l.enum(["public","private"]),jl=l.enum(["none","color","image"]),Ol=l.object({type:jl,color:gn.optional(),from:gn.optional(),to:gn.optional(),src:l.string().min(1).optional(),alt:l.string().optional()}).superRefine((t,e)=>{if(t.type==="color"){let n=!!t.color,r=!!t.from&&!!t.to;!n&&!r&&e.addIssue({code:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!t.from!=!!t.to&&e.addIssue({code:l.ZodIssueCode.custom,path:t.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}t.type==="image"&&!t.src&&e.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),ot=l.object({id:l.string().regex(Zn,{message:"must be a 12-character URL-safe demo id (see generateDemoId)"}),version:l.number().int().min(1),title:l.string().optional(),subtitle:l.string().optional(),runtime:l.string().min(1).optional(),visibility:Dl.default("public"),backgroundColor:gn.optional(),background:Ol.optional(),theme:l.object({preset:l.string().min(1).optional(),tokens:fn.optional(),brand:ma.optional()}).optional(),chrome:Rl.default({}),aspectRatio:$l.optional(),chapters:l.array(El).default([]),steps:l.array(Da).min(1)}).passthrough().superRefine((t,e)=>{let n=new Set(t.steps.map(a=>a.id)),r=new Set(t.chapters.map(a=>a.id));t.chapters.forEach((a,i)=>{a.stepIds.forEach(o=>{n.has(o)||e.addIssue({code:l.ZodIssueCode.custom,path:["chapters",i,"stepIds"],message:`Chapter "${a.id}" references unknown step "${o}"`})})}),t.steps.forEach((a,i)=>{a.kind==="cover"&&a.widgets.forEach((o,s)=>{o.type==="headline"&&["cta","secondaryCta"].forEach(c=>{let d=o[c]?.action;d&&(d.type==="step"&&!n.has(d.stepId)&&e.addIssue({code:l.ZodIssueCode.custom,path:["steps",i,"widgets",s,c,"action","stepId"],message:`Widget "${o.id}" CTA targets unknown step "${d.stepId}"`}),d.type==="chapter"&&!r.has(d.chapterId)&&e.addIssue({code:l.ZodIssueCode.custom,path:["steps",i,"widgets",s,c,"action","chapterId"],message:`Widget "${o.id}" CTA targets unknown chapter "${d.chapterId}"`}))})})})});function bn(t){return ot.parse(t)}function Ct(t){let e=typeof t=="object"&&t!==null?t:{},n=fa(e.id),r=n?e:{...e,id:ne()};return{config:ot.parse(r),changed:!n}}function Oa(t){let e=new Map;t.forEach((r,a)=>{let i=e.get(r.id);i?i.push({entry:r,index:a}):e.set(r.id,[{entry:r,index:a}])});let n=[];for(let r of e.values()){if(r.length<2)continue;let a=[...r].sort((o,s)=>o.entry.updatedAt!==s.entry.updatedAt?o.entry.updatedAt-s.entry.updatedAt:o.index-s.index),[,...i]=a;for(let{entry:o}of i)n.push({entry:o,newId:ne()})}return n}var Qn=l.enum(["sidebar","tabs"]),Nl=l.object({name:l.string().min(1),description:l.string().min(1).optional(),icon:l.string().min(1).optional(),demos:l.array(l.string().min(1))}),fe=l.object({$schema:l.string().optional(),name:l.string().min(1),runtime:l.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:l.string().min(1).optional(),layout:Qn.optional(),theme:l.string().min(1).optional(),tokens:fn.optional(),brand:Jn.optional(),title:l.string().min(1).optional(),subtitle:l.string().min(1).optional(),collections:l.array(Nl).optional()});function Na({slug:t,config:e,resolveAssetSrc:n}){let r=e.title??e.id??t;return{slug:t,title:r,description:Ll(e,r),thumbnail:Ml(e,r,n),visibility:e.visibility}}function yn(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function Ll(t,e){if(t.subtitle?.trim())return yn(t.subtitle.trim(),120);for(let n of t.steps){if(n.kind!=="content")continue;let r=n.captions?.[0]?.text;if(r&&r.trim())return yn(r.trim(),120);break}for(let n of t.steps)if(n.kind==="cover"){for(let r of n.widgets)if(r.type==="headline"&&r.description&&r.description.trim())return yn(r.description.trim(),120)}return yn(`Explore the ${e} workflow.`,120)}function zl(t){return t.background?t.background.type==="image":t.backgroundImage?!0:t.widgets.some(e=>e.type==="headline"?!!e.title:e.type==="embed"?!!e.src:e.type==="form")}function er(t,e){return t?e?e(t):t:null}function Ul(t,e){if(!e)return t;let n=t.widgets.map(o=>{if((o.type==="headline"||o.type==="form")&&o.image?.src){let s=e(o.image.src);return s&&s!==o.image.src?{...o,image:{...o.image,src:s}}:o}return o}),r=t.backgroundImage,a=t.background;if(a?.type==="image"&&a.src){let o=e(a.src);o&&o!==a.src&&(a={...a,src:o})}if(r?.src){let o=e(r.src);o&&o!==r.src&&(r={...r,src:o})}return!n.some((o,s)=>o!==t.widgets[s])&&a===t.background&&r===t.backgroundImage?t:{...t,widgets:n,background:a,backgroundImage:r}}function Ml(t,e,n){let r=t.steps[0];if(r){if(r.kind==="cover"&&zl(r))return{kind:"cover",cover:Ul(r,n),themeTokens:t.theme?.tokens};if(r.kind==="content"){let a=r.background;if(a?.type==="image"){let i=er(a.src,n);if(i)return{kind:"image",src:i}}else if(a?.type==="video"){let i=er(a.posterSrc,n);if(i)return{kind:"image",src:i};let o=er(a.src,n);if(o)return{kind:"video",src:o}}else if(a?.type==="html")return{kind:"html",path:a.path,naturalWidth:a.naturalWidth,naturalHeight:a.naturalHeight,zoom:a.zoom,scroll:a.scroll}}}return{kind:"placeholder",title:e}}function Fl(t){return!t||t==="null"?"":t.replace(/\/+$/,"")}function Hl(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Bl(t){return String(t||"").replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"")}function tr(t){let e=Bl(t);return/\/index\.html$/i.test(e)||/^index\.html$/i.test(e)?e.replace(/index\.html$/i,"document.css"):/\.html?$/i.test(e)?e.replace(/\.html?$/i,".css"):null}function Wl(t){return t.replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?content-security-policy\b)[^>]*>/gi,"")}var Vl=/\s+(?:href|xlink:href|target|rel|download|ping|referrerpolicy|data-inkly-href)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?/gi;function Zt(t){return String(t||"").replace(/<(a|area)\b[^>]*>/gi,e=>e.replace(Vl,""))}function st(t,e={}){let n=Fl(e.resourceOrigin),r=String(t||"");return n?r.replace(new RegExp(`(^|["'\\(\\s,=])${Hl("/api/hubs/")}`,"g"),`$1${n}/api/hubs/`):r}function Jl(t){return Wl(t).replace(/<style\b(?=[^>]*\bdata-inkly-document-css\b)[\s\S]*?<\/style>/gi,"").replace(/<link\b(?=[^>]*\bdata-inkly-document-css\b)[^>]*>/gi,"").replace(/<link\b(?=[^>]*\brel\s*=\s*["']?stylesheet\b)(?=[^>]*\bhref\s*=\s*["']?[^"'\s>]*document\.css(?:\?draft=1)?)[^>]*>/gi,"")}function La({htmlPath:t,html:e,css:n,cssHref:r,resourceOrigin:a}){let i=Jl(Zt(e)),o=tr(t)!=null,s=n?.trim()??"";if(o&&s){let d=`<style data-inkly-document-css>
|
|
3
|
-
${
|
|
4
|
-
</style>`,u=/<\/head\s*>/i.test(
|
|
2
|
+
var Fo=Object.defineProperty;var Ho=(e,t)=>{for(var n in t)Fo(e,n,{get:t[n],enumerable:!0})};import Dh from"mri";import{existsSync as si,statSync as Nh}from"fs";import{isAbsolute as Mh,join as Co,resolve as Lh}from"path";import{Buffer as Hc}from"buffer";import{mkdir as sa,writeFile as Bc,access as Wc}from"fs/promises";import{dirname as Vc,join as Jc,resolve as Zc,sep as la}from"path";var l={};Ho(l,{BRAND:()=>ms,DIRTY:()=>Xe,EMPTY_PATH:()=>Jo,INVALID:()=>v,NEVER:()=>Xs,OK:()=>Y,ParseStatus:()=>q,Schema:()=>T,ZodAny:()=>Fe,ZodArray:()=>Ee,ZodBigInt:()=>et,ZodBoolean:()=>tt,ZodBranded:()=>Kt,ZodCatch:()=>pt,ZodDate:()=>nt,ZodDefault:()=>ut,ZodDiscriminatedUnion:()=>gn,ZodEffects:()=>ue,ZodEnum:()=>ct,ZodError:()=>re,ZodFirstPartyTypeKind:()=>S,ZodFunction:()=>yn,ZodIntersection:()=>ot,ZodIssueCode:()=>m,ZodLazy:()=>st,ZodLiteral:()=>lt,ZodMap:()=>Pt,ZodNaN:()=>Et,ZodNativeEnum:()=>dt,ZodNever:()=>he,ZodNull:()=>it,ZodNullable:()=>ke,ZodNumber:()=>Qe,ZodObject:()=>ie,ZodOptional:()=>ce,ZodParsedType:()=>y,ZodPipeline:()=>Yt,ZodPromise:()=>He,ZodReadonly:()=>ht,ZodRecord:()=>bn,ZodSchema:()=>T,ZodSet:()=>It,ZodString:()=>Ue,ZodSymbol:()=>Tt,ZodTransformer:()=>ue,ZodTuple:()=>xe,ZodType:()=>T,ZodUndefined:()=>rt,ZodUnion:()=>at,ZodUnknown:()=>Ie,ZodVoid:()=>At,addIssueToContext:()=>g,any:()=>Ss,array:()=>As,bigint:()=>ys,boolean:()=>ki,coerce:()=>Ys,custom:()=>bi,date:()=>xs,datetimeRegex:()=>fi,defaultErrorMap:()=>Ae,discriminatedUnion:()=>Rs,effect:()=>Bs,enum:()=>Us,function:()=>Os,getErrorMap:()=>St,getParsedType:()=>ye,instanceof:()=>gs,intersection:()=>$s,isAborted:()=>mn,isAsync:()=>_t,isDirty:()=>fn,isValid:()=>ze,late:()=>fs,lazy:()=>js,literal:()=>zs,makeIssue:()=>Gt,map:()=>Ms,nan:()=>bs,nativeEnum:()=>Fs,never:()=>Cs,null:()=>vs,nullable:()=>Vs,number:()=>xi,object:()=>Ps,objectUtil:()=>Qn,oboolean:()=>Ks,onumber:()=>Gs,optional:()=>Ws,ostring:()=>qs,pipeline:()=>Zs,preprocess:()=>Js,promise:()=>Hs,quotelessJson:()=>Bo,record:()=>Ns,set:()=>Ls,setErrorMap:()=>Vo,strictObject:()=>Is,string:()=>yi,symbol:()=>ks,transformer:()=>Bs,tuple:()=>Ds,undefined:()=>ws,union:()=>Es,unknown:()=>_s,util:()=>P,void:()=>Ts});var P;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{let a={};for(let o of i)a[o]=o;return a},e.getValidEnumValues=i=>{let a=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(let s of a)o[s]=i[s];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},e.find=(i,a)=>{for(let o of i)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=r,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(P||(P={}));var Qn;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Qn||(Qn={}));var y=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ye=e=>{switch(typeof e){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(e)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(e)?y.array:e===null?y.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?y.promise:typeof Map<"u"&&e instanceof Map?y.map:typeof Set<"u"&&e instanceof Set?y.set:typeof Date<"u"&&e instanceof Date?y.date:y.object;default:return y.unknown}};var m=P.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"]),Bo=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),re=class e extends Error{get errors(){return this.issues}constructor(t){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=t}format(t){let n=t||function(a){return a.message},r={_errors:[]},i=a=>{for(let o of a.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 s=r,c=0;for(;c<o.path.length;){let d=o.path[c];c===o.path.length-1?(s[d]=s[d]||{_errors:[]},s[d]._errors.push(n(o))):s[d]=s[d]||{_errors:[]},s=s[d],c++}}};return i(this),r}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},r=[];for(let i of this.issues)if(i.path.length>0){let a=i.path[0];n[a]=n[a]||[],n[a].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};re.create=e=>new re(e);var Wo=(e,t)=>{let n;switch(e.code){case m.invalid_type:e.received===y.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,P.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${P.joinValues(e.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${P.joinValues(e.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${P.joinValues(e.options)}, received '${e.received}'`;break;case m.invalid_arguments:n="Invalid function arguments";break;case m.invalid_return_type:n="Invalid function return type";break;case m.invalid_date:n="Invalid date";break;case m.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:P.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case m.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case m.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case m.custom:n="Invalid input";break;case m.invalid_intersection_types:n="Intersection results could not be merged";break;case m.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case m.not_finite:n="Number must be finite";break;default:n=t.defaultError,P.assertNever(e)}return{message:n}},Ae=Wo;var di=Ae;function Vo(e){di=e}function St(){return di}var Gt=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s="",c=r.filter(d=>!!d).slice().reverse();for(let d of c)s=d(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},Jo=[];function g(e,t){let n=St(),r=Gt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Ae?void 0:Ae].filter(i=>!!i)});e.common.issues.push(r)}var q=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){let r=[];for(let i of n){if(i.status==="aborted")return v;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){let r=[];for(let i of n){let a=await i.key,o=await i.value;r.push({key:a,value:o})}return e.mergeObjectSync(t,r)}static mergeObjectSync(t,n){let r={};for(let i of n){let{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return v;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[a.value]=o.value)}return{status:t.value,value:r}}},v=Object.freeze({status:"aborted"}),Xe=e=>({status:"dirty",value:e}),Y=e=>({status:"valid",value:e}),mn=e=>e.status==="aborted",fn=e=>e.status==="dirty",ze=e=>e.status==="valid",_t=e=>typeof Promise<"u"&&e instanceof Promise;var k;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(k||(k={}));var de=class{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,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}},ui=(e,t)=>{if(ze(t))return{success:!0,data:t.value};if(!e.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 re(e.common.issues);return this._error=n,this._error}}};function C(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,s)=>{let{message:c}=e;return o.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??r??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:c??n??s.defaultError}},description:i}}var T=class{get description(){return this._def.description}_getType(t){return ye(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ye(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new q,ctx:{common:t.parent.common,data:t.data,parsedType:ye(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(_t(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){let n=this._parse(t);return Promise.resolve(n)}parse(t,n){let r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ye(t)},i=this._parseSync({data:t,path:r.path,parent:r});return ui(r,i)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ye(t)};if(!this["~standard"].async)try{let r=this._parseSync({data:t,path:[],parent:n});return ze(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:t,path:[],parent:n}).then(r=>ze(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(t,n){let r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ye(t)},i=this._parse({data:t,path:r.path,parent:r}),a=await(_t(i)?i:Promise.resolve(i));return ui(r,a)}refine(t,n){let r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,a)=>{let o=t(i),s=()=>a.addIssue({code:m.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new ue({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return ce.create(this,this._def)}nullable(){return ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ee.create(this)}promise(){return He.create(this,this._def)}or(t){return at.create([this,t],this._def)}and(t){return ot.create(this,t,this._def)}transform(t){return new ue({...C(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new ut({...C(this._def),innerType:this,defaultValue:n,typeName:S.ZodDefault})}brand(){return new Kt({typeName:S.ZodBranded,type:this,...C(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new pt({...C(this._def),innerType:this,catchValue:n,typeName:S.ZodCatch})}describe(t){let n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Yt.create(this,t)}readonly(){return ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Zo=/^c[^\s-]{8,}$/i,qo=/^[0-9a-z]+$/,Go=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ko=/^[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,Yo=/^[a-z0-9_-]{21}$/i,Xo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Qo=/^[-+]?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)?)??$/,es=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ts="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",er,ns=/^(?:(?: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])$/,rs=/^(?:(?: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])$/,is=/^(([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]))$/,as=/^(([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])$/,os=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ss=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,hi="((\\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])))",ls=new RegExp(`^${hi}$`);function mi(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function cs(e){return new RegExp(`^${mi(e)}$`)}function fi(e){let t=`${hi}T${mi(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function ds(e,t){return!!((t==="v4"||!t)&&ns.test(e)||(t==="v6"||!t)&&is.test(e))}function us(e,t){if(!Xo.test(e))return!1;try{let[n]=e.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||t&&i.alg!==t)}catch{return!1}}function ps(e,t){return!!((t==="v4"||!t)&&rs.test(e)||(t==="v6"||!t)&&as.test(e))}var Ue=class e extends T{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==y.string){let a=this._getOrReturnCtx(t);return g(a,{code:m.invalid_type,expected:y.string,received:a.parsedType}),v}let r=new q,i;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),g(i,{code:m.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")t.data.length>a.value&&(i=this._getOrReturnCtx(t,i),g(i,{code:m.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){let o=t.data.length>a.value,s=t.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(t,i),o?g(i,{code:m.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&g(i,{code:m.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")es.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"email",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")er||(er=new RegExp(ts,"u")),er.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"emoji",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Ko.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"uuid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Yo.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"nanoid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Zo.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"cuid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")qo.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"cuid2",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Go.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"ulid",code:m.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),g(i,{validation:"url",code:m.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"regex",code:m.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?fi(a).test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?ls.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?cs(a).test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{code:m.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?Qo.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"duration",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?ds(t.data,a.version)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"ip",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?us(t.data,a.alg)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"jwt",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?ps(t.data,a.version)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"cidr",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?os.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"base64",code:m.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?ss.test(t.data)||(i=this._getOrReturnCtx(t,i),g(i,{validation:"base64url",code:m.invalid_string,message:a.message}),r.dirty()):P.assertNever(a);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:m.invalid_string,...k.errToObj(r)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...k.errToObj(t)})}url(t){return this._addCheck({kind:"url",...k.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...k.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...k.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...k.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...k.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...k.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...k.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...k.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...k.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...k.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...k.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...k.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...k.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...k.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...k.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...k.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...k.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...k.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...k.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...k.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...k.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...k.errToObj(n)})}nonempty(t){return this.min(1,k.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};Ue.create=e=>new Ue({checks:[],typeName:S.ZodString,coerce:e?.coerce??!1,...C(e)});function hs(e,t){let n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,a=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return a%o/10**i}var Qe=class e extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==y.number){let a=this._getOrReturnCtx(t);return g(a,{code:m.invalid_type,expected:y.number,received:a.parsedType}),v}let r,i=new q;for(let a of this._def.checks)a.kind==="int"?P.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),g(r,{code:m.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?hs(t.data,a.value)!==0&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),g(r,{code:m.not_finite,message:a.message}),i.dirty()):P.assertNever(a);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,k.toString(n))}gt(t,n){return this.setLimit("min",t,!1,k.toString(n))}lte(t,n){return this.setLimit("max",t,!0,k.toString(n))}lt(t,n){return this.setLimit("max",t,!1,k.toString(n))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:k.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:k.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:k.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:k.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&P.isInteger(t.value))}get isFinite(){let t=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"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}};Qe.create=e=>new Qe({checks:[],typeName:S.ZodNumber,coerce:e?.coerce||!1,...C(e)});var et=class e extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==y.bigint)return this._getInvalidInput(t);let r,i=new q;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),g(r,{code:m.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):P.assertNever(a);return{status:i.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return g(n,{code:m.invalid_type,expected:y.bigint,received:n.parsedType}),v}gte(t,n){return this.setLimit("min",t,!0,k.toString(n))}gt(t,n){return this.setLimit("min",t,!1,k.toString(n))}lte(t,n){return this.setLimit("max",t,!0,k.toString(n))}lt(t,n){return this.setLimit("max",t,!1,k.toString(n))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:k.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:k.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};et.create=e=>new et({checks:[],typeName:S.ZodBigInt,coerce:e?.coerce??!1,...C(e)});var tt=class extends T{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==y.boolean){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.boolean,received:r.parsedType}),v}return Y(t.data)}};tt.create=e=>new tt({typeName:S.ZodBoolean,coerce:e?.coerce||!1,...C(e)});var nt=class e extends T{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==y.date){let a=this._getOrReturnCtx(t);return g(a,{code:m.invalid_type,expected:y.date,received:a.parsedType}),v}if(Number.isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return g(a,{code:m.invalid_date}),v}let r=new q,i;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),g(i,{code:m.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(i=this._getOrReturnCtx(t,i),g(i,{code:m.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):P.assertNever(a);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:k.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:k.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};nt.create=e=>new nt({checks:[],coerce:e?.coerce||!1,typeName:S.ZodDate,...C(e)});var Tt=class extends T{_parse(t){if(this._getType(t)!==y.symbol){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.symbol,received:r.parsedType}),v}return Y(t.data)}};Tt.create=e=>new Tt({typeName:S.ZodSymbol,...C(e)});var rt=class extends T{_parse(t){if(this._getType(t)!==y.undefined){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.undefined,received:r.parsedType}),v}return Y(t.data)}};rt.create=e=>new rt({typeName:S.ZodUndefined,...C(e)});var it=class extends T{_parse(t){if(this._getType(t)!==y.null){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.null,received:r.parsedType}),v}return Y(t.data)}};it.create=e=>new it({typeName:S.ZodNull,...C(e)});var Fe=class extends T{constructor(){super(...arguments),this._any=!0}_parse(t){return Y(t.data)}};Fe.create=e=>new Fe({typeName:S.ZodAny,...C(e)});var Ie=class extends T{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Y(t.data)}};Ie.create=e=>new Ie({typeName:S.ZodUnknown,...C(e)});var he=class extends T{_parse(t){let n=this._getOrReturnCtx(t);return g(n,{code:m.invalid_type,expected:y.never,received:n.parsedType}),v}};he.create=e=>new he({typeName:S.ZodNever,...C(e)});var At=class extends T{_parse(t){if(this._getType(t)!==y.undefined){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.void,received:r.parsedType}),v}return Y(t.data)}};At.create=e=>new At({typeName:S.ZodVoid,...C(e)});var Ee=class e extends T{_parse(t){let{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==y.array)return g(n,{code:m.invalid_type,expected:y.array,received:n.parsedType}),v;if(i.exactLength!==null){let o=n.data.length>i.exactLength.value,s=n.data.length<i.exactLength.value;(o||s)&&(g(n,{code:o?m.too_big:m.too_small,minimum:s?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&&(g(n,{code:m.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&&(g(n,{code:m.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,s)=>i.type._parseAsync(new de(n,o,n.path,s)))).then(o=>q.mergeArray(r,o));let a=[...n.data].map((o,s)=>i.type._parseSync(new de(n,o,n.path,s)));return q.mergeArray(r,a)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:k.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:k.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:k.toString(n)}})}nonempty(t){return this.min(1,t)}};Ee.create=(e,t)=>new Ee({type:e,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...C(t)});function Ct(e){if(e instanceof ie){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=ce.create(Ct(r))}return new ie({...e._def,shape:()=>t})}else return e instanceof Ee?new Ee({...e._def,type:Ct(e.element)}):e instanceof ce?ce.create(Ct(e.unwrap())):e instanceof ke?ke.create(Ct(e.unwrap())):e instanceof xe?xe.create(e.items.map(t=>Ct(t))):e}var ie=class e extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=P.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==y.object){let d=this._getOrReturnCtx(t);return g(d,{code:m.invalid_type,expected:y.object,received:d.parsedType}),v}let{status:r,ctx:i}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof he&&this._def.unknownKeys==="strip"))for(let d in i.data)o.includes(d)||s.push(d);let c=[];for(let d of o){let u=a[d],p=i.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new de(i,p,i.path,d)),alwaysSet:d in i.data})}if(this._def.catchall instanceof he){let d=this._def.unknownKeys;if(d==="passthrough")for(let u of s)c.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(d==="strict")s.length>0&&(g(i,{code:m.unrecognized_keys,keys:s}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let u of s){let p=i.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new de(i,p,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let d=[];for(let u of c){let p=await u.key,h=await u.value;d.push({key:p,value:h,alwaysSet:u.alwaysSet})}return d}).then(d=>q.mergeObjectSync(r,d)):q.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(t){return k.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{let i=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:k.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:S.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let r of P.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let r of P.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new e({...this._def,shape:()=>n})}deepPartial(){return Ct(this)}partial(t){let n={};for(let r of P.objectKeys(this.shape)){let i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let r of P.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof ce;)a=a._def.innerType;n[r]=a}return new e({...this._def,shape:()=>n})}keyof(){return gi(P.objectKeys(this.shape))}};ie.create=(e,t)=>new ie({shape:()=>e,unknownKeys:"strip",catchall:he.create(),typeName:S.ZodObject,...C(t)});ie.strictCreate=(e,t)=>new ie({shape:()=>e,unknownKeys:"strict",catchall:he.create(),typeName:S.ZodObject,...C(t)});ie.lazycreate=(e,t)=>new ie({shape:e,unknownKeys:"strip",catchall:he.create(),typeName:S.ZodObject,...C(t)});var at=class extends T{_parse(t){let{ctx:n}=this._processInputParams(t),r=this._def.options;function i(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(s=>new re(s.ctx.common.issues));return g(n,{code:m.invalid_union,unionErrors:o}),v}if(n.common.async)return Promise.all(r.map(async a=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let a,o=[];for(let c of r){let d={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(c=>new re(c));return g(n,{code:m.invalid_union,unionErrors:s}),v}}get options(){return this._def.options}};at.create=(e,t)=>new at({options:e,typeName:S.ZodUnion,...C(t)});var Pe=e=>e instanceof st?Pe(e.schema):e instanceof ue?Pe(e.innerType()):e instanceof lt?[e.value]:e instanceof ct?e.options:e instanceof dt?P.objectValues(e.enum):e instanceof ut?Pe(e._def.innerType):e instanceof rt?[void 0]:e instanceof it?[null]:e instanceof ce?[void 0,...Pe(e.unwrap())]:e instanceof ke?[null,...Pe(e.unwrap())]:e instanceof Kt||e instanceof ht?Pe(e.unwrap()):e instanceof pt?Pe(e._def.innerType):[],gn=class e extends T{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==y.object)return g(n,{code:m.invalid_type,expected:y.object,received:n.parsedType}),v;let r=this.discriminator,i=n.data[r],a=this.optionsMap.get(i);return a?n.common.async?a._parseAsync({data:n.data,path:n.path,parent:n}):a._parseSync({data:n.data,path:n.path,parent:n}):(g(n,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let a of n){let o=Pe(a.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of o){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,a)}}return new e({typeName:S.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...C(r)})}};function tr(e,t){let n=ye(e),r=ye(t);if(e===t)return{valid:!0,data:e};if(n===y.object&&r===y.object){let i=P.objectKeys(t),a=P.objectKeys(e).filter(s=>i.indexOf(s)!==-1),o={...e,...t};for(let s of a){let c=tr(e[s],t[s]);if(!c.valid)return{valid:!1};o[s]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=t[a],c=tr(o,s);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return n===y.date&&r===y.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var ot=class extends T{_parse(t){let{status:n,ctx:r}=this._processInputParams(t),i=(a,o)=>{if(mn(a)||mn(o))return v;let s=tr(a.value,o.value);return s.valid?((fn(a)||fn(o))&&n.dirty(),{status:n.value,value:s.data}):(g(r,{code:m.invalid_intersection_types}),v)};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(([a,o])=>i(a,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}))}};ot.create=(e,t,n)=>new ot({left:e,right:t,typeName:S.ZodIntersection,...C(n)});var xe=class e extends T{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==y.array)return g(r,{code:m.invalid_type,expected:y.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return g(r,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(g(r,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let a=[...r.data].map((o,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new de(r,o,r.path,s)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>q.mergeArray(n,o)):q.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};xe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xe({items:e,typeName:S.ZodTuple,rest:null,...C(t)})};var bn=class e extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==y.object)return g(r,{code:m.invalid_type,expected:y.object,received:r.parsedType}),v;let i=[],a=this._def.keyType,o=this._def.valueType;for(let s in r.data)i.push({key:a._parse(new de(r,s,r.path,s)),value:o._parse(new de(r,r.data[s],r.path,s)),alwaysSet:s in r.data});return r.common.async?q.mergeObjectAsync(n,i):q.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof T?new e({keyType:t,valueType:n,typeName:S.ZodRecord,...C(r)}):new e({keyType:Ue.create(),valueType:t,typeName:S.ZodRecord,...C(n)})}},Pt=class extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==y.map)return g(r,{code:m.invalid_type,expected:y.map,received:r.parsedType}),v;let i=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([s,c],d)=>({key:i._parse(new de(r,s,r.path,[d,"key"])),value:a._parse(new de(r,c,r.path,[d,"value"]))}));if(r.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of o){let d=await c.key,u=await c.value;if(d.status==="aborted"||u.status==="aborted")return v;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(d.value,u.value)}return{status:n.value,value:s}})}else{let s=new Map;for(let c of o){let d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return v;(d.status==="dirty"||u.status==="dirty")&&n.dirty(),s.set(d.value,u.value)}return{status:n.value,value:s}}}};Pt.create=(e,t,n)=>new Pt({valueType:t,keyType:e,typeName:S.ZodMap,...C(n)});var It=class e extends T{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==y.set)return g(r,{code:m.invalid_type,expected:y.set,received:r.parsedType}),v;let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(g(r,{code:m.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&&(g(r,{code:m.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let a=this._def.valueType;function o(c){let d=new Set;for(let u of c){if(u.status==="aborted")return v;u.status==="dirty"&&n.dirty(),d.add(u.value)}return{status:n.value,value:d}}let s=[...r.data.values()].map((c,d)=>a._parse(new de(r,c,r.path,d)));return r.common.async?Promise.all(s).then(c=>o(c)):o(s)}min(t,n){return new e({...this._def,minSize:{value:t,message:k.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:k.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};It.create=(e,t)=>new It({valueType:e,minSize:null,maxSize:null,typeName:S.ZodSet,...C(t)});var yn=class e extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==y.function)return g(n,{code:m.invalid_type,expected:y.function,received:n.parsedType}),v;function r(s,c){return Gt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,St(),Ae].filter(d=>!!d),issueData:{code:m.invalid_arguments,argumentsError:c}})}function i(s,c){return Gt({data:s,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,St(),Ae].filter(d=>!!d),issueData:{code:m.invalid_return_type,returnTypeError:c}})}let a={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof He){let s=this;return Y(async function(...c){let d=new re([]),u=await s._def.args.parseAsync(c,a).catch(f=>{throw d.addIssue(r(c,f)),d}),p=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(p,a).catch(f=>{throw d.addIssue(i(p,f)),d})})}else{let s=this;return Y(function(...c){let d=s._def.args.safeParse(c,a);if(!d.success)throw new re([r(c,d.error)]);let u=Reflect.apply(o,this,d.data),p=s._def.returns.safeParse(u,a);if(!p.success)throw new re([i(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:xe.create(t).rest(Ie.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new e({args:t||xe.create([]).rest(Ie.create()),returns:n||Ie.create(),typeName:S.ZodFunction,...C(r)})}},st=class extends T{get schema(){return this._def.getter()}_parse(t){let{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};st.create=(e,t)=>new st({getter:e,typeName:S.ZodLazy,...C(t)});var lt=class extends T{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return g(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:t.data}}get value(){return this._def.value}};lt.create=(e,t)=>new lt({value:e,typeName:S.ZodLiteral,...C(t)});function gi(e,t){return new ct({values:e,typeName:S.ZodEnum,...C(t)})}var ct=class e extends T{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),r=this._def.values;return g(n,{expected:P.joinValues(r),received:n.parsedType,code:m.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),r=this._def.values;return g(n,{received:n.data,code:m.invalid_enum_value,options:r}),v}return Y(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}};ct.create=gi;var dt=class extends T{_parse(t){let n=P.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==y.string&&r.parsedType!==y.number){let i=P.objectValues(n);return g(r,{expected:P.joinValues(i),received:r.parsedType,code:m.invalid_type}),v}if(this._cache||(this._cache=new Set(P.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=P.objectValues(n);return g(r,{received:r.data,code:m.invalid_enum_value,options:i}),v}return Y(t.data)}get enum(){return this._def.values}};dt.create=(e,t)=>new dt({values:e,typeName:S.ZodNativeEnum,...C(t)});var He=class extends T{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==y.promise&&n.common.async===!1)return g(n,{code:m.invalid_type,expected:y.promise,received:n.parsedType}),v;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return Y(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}};He.create=(e,t)=>new He({type:e,typeName:S.ZodPromise,...C(t)});var ue=class extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:o=>{g(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let o=i.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async s=>{if(n.value==="aborted")return v;let c=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"?Xe(c.value):n.value==="dirty"?Xe(c.value):c});{if(n.value==="aborted")return v;let s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?Xe(s.value):n.value==="dirty"?Xe(s.value):s}}if(i.type==="refinement"){let o=s=>{let c=i.refinement(s,a);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:(s.status==="dirty"&&n.dirty(),o(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?v:(s.status==="dirty"&&n.dirty(),o(s.value).then(()=>({status:n.value,value:s.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(!ze(o))return v;let s=i.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>ze(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:n.value,value:s})):v);P.assertNever(i)}};ue.create=(e,t,n)=>new ue({schema:e,typeName:S.ZodEffects,effect:t,...C(n)});ue.createWithPreprocess=(e,t,n)=>new ue({schema:t,effect:{type:"preprocess",transform:e},typeName:S.ZodEffects,...C(n)});var ce=class extends T{_parse(t){return this._getType(t)===y.undefined?Y(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};ce.create=(e,t)=>new ce({innerType:e,typeName:S.ZodOptional,...C(t)});var ke=class extends T{_parse(t){return this._getType(t)===y.null?Y(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};ke.create=(e,t)=>new ke({innerType:e,typeName:S.ZodNullable,...C(t)});var ut=class extends T{_parse(t){let{ctx:n}=this._processInputParams(t),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};ut.create=(e,t)=>new ut({innerType:e,typeName:S.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...C(t)});var pt=class extends T{_parse(t){let{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _t(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new re(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};pt.create=(e,t)=>new pt({innerType:e,typeName:S.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...C(t)});var Et=class extends T{_parse(t){if(this._getType(t)!==y.nan){let r=this._getOrReturnCtx(t);return g(r,{code:m.invalid_type,expected:y.nan,received:r.parsedType}),v}return{status:"valid",value:t.data}}};Et.create=e=>new Et({typeName:S.ZodNaN,...C(e)});var ms=Symbol("zod_brand"),Kt=class extends T{_parse(t){let{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Yt=class e extends T{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(n.dirty(),Xe(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?v:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new e({in:t,out:n,typeName:S.ZodPipeline})}},ht=class extends T{_parse(t){let n=this._def.innerType._parse(t),r=i=>(ze(i)&&(i.value=Object.freeze(i.value)),i);return _t(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}};ht.create=(e,t)=>new ht({innerType:e,typeName:S.ZodReadonly,...C(t)});function pi(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function bi(e,t={},n){return e?Fe.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(o=>{if(!o){let s=pi(t,r),c=s.fatal??n??!0;i.addIssue({code:"custom",...s,fatal:c})}});if(!a){let o=pi(t,r),s=o.fatal??n??!0;i.addIssue({code:"custom",...o,fatal:s})}}):Fe.create()}var fs={object:ie.lazycreate},S;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(S||(S={}));var gs=(e,t={message:`Input not instance of ${e.name}`})=>bi(n=>n instanceof e,t),yi=Ue.create,xi=Qe.create,bs=Et.create,ys=et.create,ki=tt.create,xs=nt.create,ks=Tt.create,ws=rt.create,vs=it.create,Ss=Fe.create,_s=Ie.create,Cs=he.create,Ts=At.create,As=Ee.create,Ps=ie.create,Is=ie.strictCreate,Es=at.create,Rs=gn.create,$s=ot.create,Ds=xe.create,Ns=bn.create,Ms=Pt.create,Ls=It.create,Os=yn.create,js=st.create,zs=lt.create,Us=ct.create,Fs=dt.create,Hs=He.create,Bs=ue.create,Ws=ce.create,Vs=ke.create,Js=ue.createWithPreprocess,Zs=Yt.create,qs=()=>yi().optional(),Gs=()=>xi().optional(),Ks=()=>ki().optional(),Ys={string:(e=>Ue.create({...e,coerce:!0})),number:(e=>Qe.create({...e,coerce:!0})),boolean:(e=>tt.create({...e,coerce:!0})),bigint:(e=>et.create({...e,coerce:!0})),date:(e=>nt.create({...e,coerce:!0}))};var Xs=v;var nr=l.object({id:l.string()}),Qs=l.enum(["top","right","bottom","left","auto"]).default("auto"),rr=l.enum(["left","middle","right"]),el=rr.default("left"),wi=l.object({label:l.string().optional(),hidden:l.boolean().default(!1)}),tl={background:l.string().optional(),textColor:l.string().optional(),borderRadius:l.string().optional(),textAlign:el,anchor:Qs,showNavigation:l.boolean().default(!0),prevButton:wi.optional(),nextButton:wi.optional()},nl=l.enum(["pointer","callout","area"]),rl=l.discriminatedUnion("type",[l.object({type:l.literal("html-element"),alphaId:l.string().min(1)})]),il=nr.extend({type:l.literal("message"),variant:nl.default("callout"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),w:l.number().min(0).max(1).optional(),h:l.number().min(0).max(1).optional(),text:l.string().optional(),target:rl.optional(),advancesStep:l.boolean().default(!0),...tl}),al=nr.extend({type:l.literal("blur"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),w:l.number().min(0).max(1),h:l.number().min(0).max(1),intensity:l.number().min(0).max(20).default(8)}),ol=nr.extend({type:l.literal("text"),x:l.number().min(0).max(1),y:l.number().min(0).max(1),text:l.string(),fontSize:l.number().positive().default(16),color:l.string().optional()}),vi=l.discriminatedUnion("type",[il,al,ol]),Si=new Set(["message","blur","text"]),_i=l.object({type:l.string()}).passthrough();function Ci(e){return typeof e=="object"&&e!==null?e.type:void 0}var Ti=l.any().superRefine((e,t)=>{let i=(Si.has(Ci(e))?vi:_i).safeParse(e);if(!i.success)for(let a of i.error.issues)t.addIssue(a)}).transform(e=>(Si.has(Ci(e))?vi:_i).parse(e));var Ai=l.object({label:l.string().min(1),href:l.string().refine(e=>/^(https?:|mailto:)/i.test(e),"href must be an http(s) or mailto URL")}),ir=l.object({logo:l.string().min(1).optional(),name:l.string().min(1).optional(),logoHref:l.string().refine(e=>/^(https?:|mailto:)/i.test(e),"logoHref must be an http(s) or mailto URL").optional(),favicon:l.string().min(1).optional(),cta:Ai.optional(),secondaryCta:Ai.optional(),watermark:l.boolean().optional()}),Pi=ir.omit({favicon:!0});var sl=l.object({type:l.literal("next")}),ll=l.object({type:l.literal("prev")}),cl=l.object({type:l.literal("step"),stepId:l.string().min(1)}),dl=l.object({type:l.literal("chapter"),chapterId:l.string().min(1)}),ul=l.object({type:l.literal("url"),href:l.string().min(1),target:l.enum(["_self","_blank"]).default("_blank")}),pl=l.object({type:l.literal("restart")}),hl=l.discriminatedUnion("type",[sl,ll,cl,dl,ul,pl]),ml=l.enum(["shimmer"]),xn=l.object({label:l.string().min(1),action:hl.default({type:"next"}),animation:ml.optional(),background:l.string().optional(),textColor:l.string().optional()});var fl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",ar=/^[A-Za-z0-9_-]{12}$/;function gl(e){let t=globalThis.crypto;if(!t||typeof t.getRandomValues!="function")throw new Error("generateDemoId requires globalThis.crypto.getRandomValues (Node 19+, browsers, or edge runtime).");t.getRandomValues(e)}function oe(){let e=new Uint8Array(12);gl(e);let t="";for(let n of e)t+=fl.charAt(n&63);return t}function Ii(e){return typeof e=="string"&&ar.test(e)}function Ei(e){return String(e+1).padStart(4,"0")}function Ri(e){return`snap-${e.toString().padStart(3,"0")}`}function kn(e){let t=((e??"").toLowerCase().split(";")[0]??"").trim();return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("font/")||t.includes("font")||t.includes("woff")?"font":"other"}function or(e){if(!e)return"";let t=e.replace(/^(?:tree\s*item|menu\s*item|menuitem|list\s*item|tab(?:\s*panel)?|button|link|option|region|combobox|radio|checkbox|switch|dialog|row|cell|columnheader|rowheader|navigation|article|banner|main|complementary|contentinfo)\s*:?\s+/i,"").trim();return(t.split(/\r?\n/).map(r=>r.trim()).find(Boolean)??t).replace(/\s+/g," ").trim().slice(0,48)}function sr(e){let{stepId:t,assetId:n,posterAssetId:r,kind:i,isLast:a}=e,o=`asset:${n}`,s=i==="video"?{type:"video",src:o,posterSrc:r?`asset:${r}`:void 0,naturalWidth:e.naturalWidth,naturalHeight:e.naturalHeight,alt:e.title,sourceUrl:e.sourceUrl??"",title:e.title,autoplay:!0,muted:!0,objectFit:"cover"}:{type:"image",src:o,naturalWidth:e.naturalWidth,naturalHeight:e.naturalHeight,alt:e.title,sourceUrl:e.sourceUrl??"",title:e.title,objectFit:"cover"},c=e.click,d=[];if(c){let h=or(c.label);d.push({id:`${t}_pointer`,type:"message",variant:"pointer",x:c.x,y:c.y,text:h?`Click on "${h}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}else d.push({id:`${t}_callout`,type:"message",variant:"callout",x:.5,y:.5,text:a?"End of walkthrough":"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});let u=!!c&&!(c.x===0&&c.y===0),p=i==="image"&&e.autoApplyZoom===!0&&u?{zoom:1.35,x:Number(Math.max(0,Math.min(1,c.x)).toFixed(4)),y:Number(Math.max(0,Math.min(1,c.y)).toFixed(4))}:void 0;return{id:t,kind:"content",background:s,...p?{transform:p}:{},annotations:d,advance:{trigger:"click"}}}function $i(e){let{stepId:t,htmlPath:n,click:r}=e,i=[];if(r?.alphaId)i.push({id:`${t}_area`,type:"message",variant:"area",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),w:0,h:0,text:or(r.label)||"Click here",target:{type:"html-element",alphaId:r.alphaId},anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0});else if(r){let a=or(r.label);i.push({id:`${t}_pointer`,type:"message",variant:"pointer",x:Number((r.x??.5).toFixed(4)),y:Number((r.y??.5).toFixed(4)),text:a?`Click on "${a}"`:"Continue",anchor:"auto",textAlign:"left",advancesStep:!0,showNavigation:!0})}return{id:t,kind:"content",background:{type:"html",path:n,naturalWidth:e.naturalWidth,naturalHeight:e.naturalHeight,zoom:1,scroll:e.scroll,sourceUrl:e.sourceUrl??"",title:e.sourceUrl??""},annotations:i,advance:{trigger:"click"}}}function bl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lr(e,t){let n=e;for(let[r,i]of t){let a=bl(r);n=n.replace(new RegExp(`(?:\\.\\./)*assets/${a}`,"g"),i),n=n.replace(new RegExp(`assets/${a}`,"g"),i)}return n}function yl(e){return`<script data-inkly-replay-scroll>(()=>{const c=${JSON.stringify(e).replace(/<\/(script)/gi,"<\\/$1")};function r(){const d=document.documentElement,b=document.body;const vw=innerWidth||d.clientWidth||0;const vh=innerHeight||d.clientHeight||0;const mx=Math.max(0,Math.max(d.scrollWidth,b?b.scrollWidth:0)-vw);const my=Math.max(0,Math.max(d.scrollHeight,b?b.scrollHeight:0)-vh);const x=c.maxX>0&&mx>0?c.x/c.maxX*mx:c.x;const y=c.maxY>0&&my>0?c.y/c.maxY*my:c.y;scrollTo(Math.max(0,x),Math.max(0,y));}if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",r,{once:true});r();requestAnimationFrame(r);setTimeout(r,120);setTimeout(r,500);})();</script>`}function Di(e,t){let n=yl(t);return/<\/body\s*>/i.test(e)?e.replace(/<\/body\s*>/i,`${n}</body>`):`${e}${n}`}function Ni(e,t){if(!t||/data-inkly-document-css|document\.css/i.test(e))return e;let n='<link rel="stylesheet" href="./document.css?draft=1" data-inkly-document-css>';return/<\/head\s*>/i.test(e)?e.replace(/<\/head\s*>/i,`${n}</head>`):`${n}${e}`}var Mi=l.object({id:l.string(),text:l.string(),start:l.number().nonnegative().optional(),end:l.number().nonnegative().optional()});var xl=l.enum(["screenshot","image","video","audio","font","other"]),kl=l.object({id:l.string().min(1),path:l.string().min(1).optional(),uri:l.string().min(1).optional(),sha256:l.string().regex(/^[0-9a-f]{64}$/),kind:xl,contentType:l.string().min(1).optional(),publicUrl:l.string().min(1).optional(),cdnPath:l.string().min(1).optional(),file:l.string().min(1).optional(),size:l.number().int().nonnegative().optional(),createdAt:l.string().min(1).optional(),updatedAt:l.string().min(1).optional(),viewport:l.object({w:l.number().int().positive(),h:l.number().int().positive()}).optional()}),Rt=l.object({version:l.literal(1),assets:l.array(kl),screens:l.array(l.unknown()).optional()});var cr=l.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"}),wl=l.enum(["color","image","glassmorphism"]),Li=l.object({type:wl,color:cr.optional(),from:cr.optional(),to:cr.optional(),src:l.string().min(1).optional(),alt:l.string().optional(),intensity:l.number().min(-5).max(48).optional()}).superRefine((e,t)=>{if(e.type==="color"){let n=!!e.color,r=!!e.from&&!!e.to;!n&&!r&&t.addIssue({code:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!e.from!=!!e.to&&t.addIssue({code:l.ZodIssueCode.custom,path:e.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}e.type==="image"&&!e.src&&t.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),Oi=l.object({src:l.string(),alt:l.string().optional()});var dr=l.object({src:l.string().min(1),duration:l.number().positive().optional()});var vl=l.enum(["text","dropdown"]),Sl=l.object({value:l.string().min(1),label:l.string().min(1)}),_l=l.object({id:l.string(),label:l.string(),type:vl.default("text"),placeholder:l.string().optional(),required:l.boolean().default(!1),options:l.array(Sl).optional()}).superRefine((e,t)=>{e.type==="dropdown"&&(!e.options||e.options.length===0)&&t.addIssue({code:l.ZodIssueCode.custom,message:"Dropdown field requires at least one option.",path:["options"]})}),Hi=l.object({src:l.string().min(1),alt:l.string().optional(),height:l.number().int().positive().optional()}),Cl=l.enum(["left","right","top"]),Tl=l.enum(["standard","hero"]),Bi=l.object({src:l.string().min(1),alt:l.string().optional(),naturalWidth:l.number().positive().optional(),naturalHeight:l.number().positive().optional(),position:Cl.default("right"),layout:Tl.default("hero")}),Al=l.object({type:l.literal("headline"),id:l.string(),logo:Hi.optional(),image:Bi.optional(),title:l.string(),titleColor:l.string().optional(),description:l.string().optional(),descriptionColor:l.string().optional(),textAlign:rr.optional(),cta:xn.optional(),secondaryCta:xn.optional()}),Pl=l.object({type:l.literal("form"),id:l.string(),logo:Hi.optional(),image:Bi.optional(),title:l.string().optional(),description:l.string().optional(),fields:l.array(_l).min(1),submit:xn.default({label:"Submit",action:{type:"next"}})}),Il="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",El="camera; microphone; fullscreen; payment; clipboard-write",Rl=l.object({type:l.literal("embed"),id:l.string(),src:l.string(),iframeTitle:l.string().optional(),sandbox:l.string().default(Il),allow:l.string().default(El)}),$l=l.object({type:l.literal("custom"),id:l.string(),name:l.string().min(1),data:l.record(l.unknown()).optional()}),ji=l.discriminatedUnion("type",[Al,Pl,Rl,$l]),zi=new Set(["headline","form","embed","custom"]),Ui=l.object({type:l.string()}).passthrough();function Fi(e){return typeof e=="object"&&e!==null?e.type:void 0}var Wi=l.any().superRefine((e,t)=>{let i=(zi.has(Fi(e))?ji:Ui).safeParse(e);if(!i.success)for(let a of i.error.issues)t.addIssue(a)}).transform(e=>(zi.has(Fi(e))?ji:Ui).parse(e));var Vi=l.enum(["contain","cover","fill"]),Ji=l.enum(["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"]),Dl=l.object({type:l.literal("image"),src:l.string().min(1),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),alt:l.string().optional(),sourceUrl:l.string().optional(),title:l.string().optional(),objectFit:Vi.optional(),objectPosition:Ji.optional()}),Nl=l.object({type:l.literal("video"),src:l.string().min(1),posterSrc:l.string().min(1).optional(),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),alt:l.string().optional(),sourceUrl:l.string().optional(),title:l.string().optional(),autoplay:l.boolean().default(!0),muted:l.boolean().default(!0),objectFit:Vi.optional(),objectPosition:Ji.optional()}),Ml=l.object({x:l.number().nonnegative().default(0),y:l.number().nonnegative().default(0),maxX:l.number().nonnegative().default(0),maxY:l.number().nonnegative().default(0)}),Ll=l.object({type:l.literal("html"),path:l.string().min(1),naturalWidth:l.number().positive(),naturalHeight:l.number().positive(),zoom:l.number().positive().default(1),scroll:Ml.default({x:0,y:0,maxX:0,maxY:0}),sourceUrl:l.string().optional(),title:l.string().optional()}),Ol=l.discriminatedUnion("type",[Dl,Nl,Ll]),jl=l.object({zoom:l.number().min(1).default(1),x:l.number().min(0).max(1).default(.5),y:l.number().min(0).max(1).default(.5)}),zl=l.object({trigger:l.enum(["auto","click"]).default("auto")}).default({trigger:"auto"}),Ul=l.object({kind:l.literal("content").default("content"),id:l.string(),label:l.string().optional(),duration:l.number().positive().optional(),background:Ol,script:l.string().optional(),voiceover:dr.optional(),transform:jl.optional(),advance:zl,annotations:l.array(Ti).default([]),captions:l.array(Mi).optional()}).passthrough(),Fl=l.object({kind:l.literal("cover"),id:l.string(),label:l.string().optional(),widgets:l.array(Wi).length(1),background:Li.optional(),backgroundImage:Oi.optional(),backgroundDim:l.number().min(0).max(1).optional(),script:l.string().optional(),voiceover:dr.optional(),duration:l.number().positive().optional(),advance:l.object({trigger:l.enum(["auto","click"]).default("click")}).default({trigger:"click"})}).passthrough(),Zi=l.discriminatedUnion("kind",[Ul,Fl]);var Hl=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,qi=l.string().regex(Hl,"must be a hex color like #5b3df5"),wn=l.object({primary:qi.optional(),secondary:qi.optional(),font:l.string().min(1).optional(),radius:l.string().min(1).optional()}).partial();var vn=l.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"}),Bl=l.object({id:l.string(),title:l.string(),stepIds:l.array(l.string()).min(1)}),Wl=l.object({hideHeader:l.boolean().default(!1),hideControls:l.boolean().default(!1),controls:l.enum(["full","minimal","hidden"]).optional(),showHubBreadcrumb:l.boolean().default(!1),mobileFooterMessage:l.boolean().default(!0),autoplay:l.boolean().default(!1)}),Vl=l.object({width:l.number().positive(),height:l.number().positive()}),Jl=l.enum(["public","private"]),Zl=l.enum(["none","color","image"]),ql=l.object({type:Zl,color:vn.optional(),from:vn.optional(),to:vn.optional(),src:l.string().min(1).optional(),alt:l.string().optional()}).superRefine((e,t)=>{if(e.type==="color"){let n=!!e.color,r=!!e.from&&!!e.to;!n&&!r&&t.addIssue({code:l.ZodIssueCode.custom,path:["color"],message:"color backgrounds require color or from/to"}),!!e.from!=!!e.to&&t.addIssue({code:l.ZodIssueCode.custom,path:e.from?["to"]:["from"],message:"gradient backgrounds require both from and to"})}e.type==="image"&&!e.src&&t.addIssue({code:l.ZodIssueCode.custom,path:["src"],message:"image backgrounds require src"})}),mt=l.object({id:l.string().regex(ar,{message:"must be a 12-character URL-safe demo id (see generateDemoId)"}),version:l.number().int().min(1),title:l.string().optional(),subtitle:l.string().optional(),runtime:l.string().min(1).optional(),visibility:Jl.default("public"),backgroundColor:vn.optional(),background:ql.optional(),theme:l.object({preset:l.string().min(1).optional(),tokens:wn.optional(),brand:Pi.optional()}).optional(),chrome:Wl.default({}),aspectRatio:Vl.optional(),chapters:l.array(Bl).default([]),steps:l.array(Zi).min(1)}).passthrough().superRefine((e,t)=>{let n=new Set(e.steps.map(i=>i.id)),r=new Set(e.chapters.map(i=>i.id));e.chapters.forEach((i,a)=>{i.stepIds.forEach(o=>{n.has(o)||t.addIssue({code:l.ZodIssueCode.custom,path:["chapters",a,"stepIds"],message:`Chapter "${i.id}" references unknown step "${o}"`})})}),e.steps.forEach((i,a)=>{i.kind==="cover"&&i.widgets.forEach((o,s)=>{o.type==="headline"&&["cta","secondaryCta"].forEach(c=>{let d=o[c]?.action;d&&(d.type==="step"&&!n.has(d.stepId)&&t.addIssue({code:l.ZodIssueCode.custom,path:["steps",a,"widgets",s,c,"action","stepId"],message:`Widget "${o.id}" CTA targets unknown step "${d.stepId}"`}),d.type==="chapter"&&!r.has(d.chapterId)&&t.addIssue({code:l.ZodIssueCode.custom,path:["steps",a,"widgets",s,c,"action","chapterId"],message:`Widget "${o.id}" CTA targets unknown chapter "${d.chapterId}"`}))})})})});function Sn(e){return mt.parse(e)}function $t(e){let t=typeof e=="object"&&e!==null?e:{},n=Ii(t.id),r=n?t:{...t,id:oe()};return{config:mt.parse(r),changed:!n}}function Gi(e){let t=new Map;e.forEach((r,i)=>{let a=t.get(r.id);a?a.push({entry:r,index:i}):t.set(r.id,[{entry:r,index:i}])});let n=[];for(let r of t.values()){if(r.length<2)continue;let i=[...r].sort((o,s)=>o.entry.updatedAt!==s.entry.updatedAt?o.entry.updatedAt-s.entry.updatedAt:o.index-s.index),[,...a]=i;for(let{entry:o}of a)n.push({entry:o,newId:oe()})}return n}var ur=l.enum(["sidebar","tabs"]),Gl=l.object({name:l.string().min(1),description:l.string().min(1).optional(),icon:l.string().min(1).optional(),demos:l.array(l.string().min(1))}),we=l.object({$schema:l.string().optional(),name:l.string().min(1),runtime:l.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:l.string().min(1).optional(),layout:ur.optional(),theme:l.string().min(1).optional(),tokens:wn.optional(),brand:ir.optional(),title:l.string().min(1).optional(),subtitle:l.string().min(1).optional(),collections:l.array(Gl).optional()});function Ki({slug:e,config:t,resolveAssetSrc:n}){let r=t.title??t.id??e;return{slug:e,title:r,description:Kl(t,r),thumbnail:Ql(t,r,n),visibility:t.visibility}}function _n(e,t){return e.length<=t?e:`${e.slice(0,t-1).trimEnd()}\u2026`}function Kl(e,t){if(e.subtitle?.trim())return _n(e.subtitle.trim(),120);for(let n of e.steps){if(n.kind!=="content")continue;let r=n.captions?.[0]?.text;if(r&&r.trim())return _n(r.trim(),120);break}for(let n of e.steps)if(n.kind==="cover"){for(let r of n.widgets)if(r.type==="headline"&&r.description&&r.description.trim())return _n(r.description.trim(),120)}return _n(`Explore the ${t} workflow.`,120)}function Yl(e){return e.background?e.background.type==="image":e.backgroundImage?!0:e.widgets.some(t=>t.type==="headline"?!!t.title:t.type==="embed"?!!t.src:t.type==="form")}function pr(e,t){return e?t?t(e):e:null}function Xl(e,t){if(!t)return e;let n=e.widgets.map(o=>{if((o.type==="headline"||o.type==="form")&&o.image?.src){let s=t(o.image.src);return s&&s!==o.image.src?{...o,image:{...o.image,src:s}}:o}return o}),r=e.backgroundImage,i=e.background;if(i?.type==="image"&&i.src){let o=t(i.src);o&&o!==i.src&&(i={...i,src:o})}if(r?.src){let o=t(r.src);o&&o!==r.src&&(r={...r,src:o})}return!n.some((o,s)=>o!==e.widgets[s])&&i===e.background&&r===e.backgroundImage?e:{...e,widgets:n,background:i,backgroundImage:r}}function Ql(e,t,n){let r=e.steps[0];if(r){if(r.kind==="cover"&&Yl(r))return{kind:"cover",cover:Xl(r,n),themeTokens:e.theme?.tokens};if(r.kind==="content"){let i=r.background;if(i?.type==="image"){let a=pr(i.src,n);if(a)return{kind:"image",src:a}}else if(i?.type==="video"){let a=pr(i.posterSrc,n);if(a)return{kind:"image",src:a};let o=pr(i.src,n);if(o)return{kind:"video",src:o}}else if(i?.type==="html")return{kind:"html",path:i.path,naturalWidth:i.naturalWidth,naturalHeight:i.naturalHeight,zoom:i.zoom,scroll:i.scroll}}}return{kind:"placeholder",title:t}}function ec(e){return!e||e==="null"?"":e.replace(/\/+$/,"")}function tc(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nc(e){return String(e||"").replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"")}function hr(e){let t=nc(e);return/\/index\.html$/i.test(t)||/^index\.html$/i.test(t)?t.replace(/index\.html$/i,"document.css"):/\.html?$/i.test(t)?t.replace(/\.html?$/i,".css"):null}function rc(e){return e.replace(/<meta\b(?=[^>]*\bhttp-equiv\s*=\s*["']?content-security-policy\b)[^>]*>/gi,"")}var ic=/\s+(?:href|xlink:href|target|rel|download|ping|referrerpolicy|data-inkly-href)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?/gi;function Xt(e){return String(e||"").replace(/<(a|area)\b[^>]*>/gi,t=>t.replace(ic,""))}function ft(e,t={}){let n=ec(t.resourceOrigin),r=String(e||"");return n?r.replace(new RegExp(`(^|["'\\(\\s,=])${tc("/api/hubs/")}`,"g"),`$1${n}/api/hubs/`):r}function ac(e){return rc(e).replace(/<style\b(?=[^>]*\bdata-inkly-document-css\b)[\s\S]*?<\/style>/gi,"").replace(/<link\b(?=[^>]*\bdata-inkly-document-css\b)[^>]*>/gi,"").replace(/<link\b(?=[^>]*\brel\s*=\s*["']?stylesheet\b)(?=[^>]*\bhref\s*=\s*["']?[^"'\s>]*document\.css(?:\?draft=1)?)[^>]*>/gi,"")}function Yi({htmlPath:e,html:t,css:n,cssHref:r,resourceOrigin:i}){let a=ac(Xt(t)),o=hr(e)!=null,s=n?.trim()??"";if(o&&s){let d=`<style data-inkly-document-css>
|
|
3
|
+
${ft(n??"",{resourceOrigin:i}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
4
|
+
</style>`,u=/<\/head\s*>/i.test(a)?a.replace(/<\/head\s*>/i,`${d}</head>`):`${d}${a}`;return ft(u,{resourceOrigin:i})}if(o&&r){let d=`<link rel="stylesheet" href="${ft(r,{resourceOrigin:i})}" data-inkly-document-css>`,u=/<\/head\s*>/i.test(a)?a.replace(/<\/head\s*>/i,`${d}</head>`):`${d}${a}`;return ft(u,{resourceOrigin:i})}return ft(a,{resourceOrigin:i})}var Qt=l.string().regex(/^sha(?:256|384|512)-[A-Za-z0-9+/]+=*$/,{message:"must be an SRI string like sha384-<base64>"}),Cn=l.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"}),oc=l.object({version:Cn,url:l.string().url(),integrity:Qt}),Tn=l.object({$schema:l.string().optional(),runtime:oc});var Xi=l.string().regex(/^[0-9a-f]{64}$/,{message:"must be lowercase sha-256 hex (64 chars)"}),Dt=l.object({version:Cn,externals:l.array(l.string().min(1)),jsHash:Xi,cssHash:Xi,jsBytes:l.number().int().nonnegative(),cssBytes:l.number().int().nonnegative(),integrity:Qt,cssIntegrity:Qt,minSchema:Cn,codemodsIntegrity:Qt.optional(),codemodsBytes:l.number().int().nonnegative().optional()});var gt=["__inkly","assets","api","c"],sc={__inkly:"'__inkly' is reserved for CLI internal endpoints",assets:"'assets' is reserved for hub static files",api:"'api' is reserved for future use",c:"'c' is reserved for future use"},lc=/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;function Re(e){return typeof e!="string"?{ok:!1,reason:"Name is required."}:e.length===0?{ok:!1,reason:"Name cannot be empty."}:/\s/.test(e)?{ok:!1,reason:"Name cannot contain spaces."}:e.includes("/")||e.includes("\\")?{ok:!1,reason:"Name cannot contain slashes."}:e.includes(".")?{ok:!1,reason:"Name cannot contain dots."}:gt.includes(e)?{ok:!1,reason:sc[e]}:e.startsWith("_")?{ok:!1,reason:"Name cannot start with '_' (reserved for internal use)."}:e!==e.toLowerCase()?{ok:!1,reason:'Name must be lowercase (e.g. "getting-started").'}:lc.test(e)?{ok:!0}:{ok:!1,reason:"Name must be kebab-case: lowercase letters, digits, and hyphens, starting and ending with a letter or digit."}}var Be={inkly:{primary:"#5b6cff",secondary:"#ebebeb",radius:"10px",font:"Geist, ui-sans-serif, system-ui, sans-serif"},editorial:{primary:"#d97757",secondary:"#f4f0e7",radius:"12px",font:"Inter, ui-sans-serif, system-ui, sans-serif"},mono:{primary:"#5b6cff",secondary:"#f5f5f5",radius:"10px",font:"Inter, ui-sans-serif, system-ui, sans-serif"},substack:{primary:"#ff6719",secondary:"#fdf1eb",radius:"4px",font:"Inter, ui-sans-serif, system-ui, sans-serif"}};var cc=`
|
|
5
5
|
/* \u2500\u2500 Editorial hub-index \u2014 designs 07 (sidebar) + 15 (top nav) \u2500\u2500\u2500\u2500\u2500\u2500
|
|
6
6
|
Design 07 (ClaudeHub) is the source of truth for tokens: cream
|
|
7
7
|
#FAF9F5 page, ink #1F1E1B, accent #D97757, sidebar #F4F0E7, hairline
|
|
@@ -1191,7 +1191,7 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
1191
1191
|
0 1px 2px rgba(91,55,21,0.07),
|
|
1192
1192
|
0 20px 40px -22px rgba(91,55,21,0.30);
|
|
1193
1193
|
}
|
|
1194
|
-
`,
|
|
1194
|
+
`,Qi={id:"editorial",label:"Editorial",theme:Be.editorial,css:cc};var dc=`
|
|
1195
1195
|
/* \u2500\u2500 Mono hub-index \u2014 designs 08 (sidebar) + 16 (top-nav filled pills) \u2500\u2500
|
|
1196
1196
|
White paper #FFFFFF, ink #0D0D0D, muted #5D5D5D, dim #8E8E8E,
|
|
1197
1197
|
hairline #ECECEC, sidebar bg #F9F9F9. CTAs use the primary token;
|
|
@@ -2333,7 +2333,7 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
2333
2333
|
border-radius: 10px;
|
|
2334
2334
|
box-shadow: none;
|
|
2335
2335
|
}
|
|
2336
|
-
`,
|
|
2336
|
+
`,ea={id:"mono",label:"Mono",theme:Be.mono,css:dc};var uc=`
|
|
2337
2337
|
/* Newsreader 600 \u2014 the true semi-bold cut for the "Built with Inkly"
|
|
2338
2338
|
wordmark. Self-hosted on the Inkly bundle CDN so the self-contained demo
|
|
2339
2339
|
document loads it without a Google Fonts round-trip; Georgia is the
|
|
@@ -4029,7 +4029,7 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
4029
4029
|
line-height: 1.45;
|
|
4030
4030
|
}
|
|
4031
4031
|
}
|
|
4032
|
-
`,
|
|
4032
|
+
`,ta={id:"inkly",label:"Inkly",theme:Be.inkly,css:uc};var pc=`
|
|
4033
4033
|
.hub-index[data-theme="substack"] {
|
|
4034
4034
|
background: #ffffff;
|
|
4035
4035
|
color: #1a1a1a;
|
|
@@ -4960,105 +4960,107 @@ ${st(n??"",{resourceOrigin:a}).replace(/<\/(style)/gi,"<\\/$1")}
|
|
|
4960
4960
|
--demo-watermark-mark-radius: 3px;
|
|
4961
4961
|
font-family: var(--demo-font);
|
|
4962
4962
|
}
|
|
4963
|
-
`,Ha={id:"substack",label:"Substack",theme:Oe.substack,css:Ql};var Ba=[Fa,Ua,Ma,Ha],le=Object.fromEntries(Ba.map(t=>[t.id,t]));import{createHash as ud}from"crypto";import{mkdir as pd,readFile as or,rm as af,stat as of}from"fs/promises";import{homedir as hd}from"os";import{join as Ne}from"path";import{fileURLToPath as md}from"url";import{access as ed,readFile as td,readdir as nd,stat as rd}from"fs/promises";import{dirname as ad,join as At,resolve as id,sep as od}from"path";async function V(t){return ed(t).then(()=>!0,()=>!1)}async function Ce(t){let e=id(t);for(;;){if(await V(At(e,"inkly.json")))return e;let n=ad(e);if(n===e)return null;e=n}}async function nr(t){let e=At(t,"demos");if(!await V(e))return[];let n=[];async function r(a){let i;try{i=await nd(a,{withFileTypes:!0})}catch{return}if(i.some(o=>o.isFile()&&o.name==="demo.config.json")){let o=a===e?"":a.slice(e.length+1).split(od).join("/");n.push({slug:o,dir:a,configPath:At(a,"demo.config.json")});return}for(let o of i)o.isDirectory()&&await r(At(a,o.name))}return await r(e),n.sort((a,i)=>a.slug.localeCompare(i.slug))}async function _e(t){let e=await td(t,"utf8");return JSON.parse(e)}async function It(t){let e=await Ce(t);if(!e)throw new Error(`No inkly.json found in ${t} or any parent directory.`);let n=At(e,"inkly.json"),r=fe.safeParse(await _e(n));if(!r.success)throw new Error(`inkly.json failed schema validation: ${r.error.message}`);let a=[];for(let i of await nr(e)){let o;try{o=Ct(await _e(i.configPath)).config}catch(d){throw new Error(`demos/${i.slug}/demo.config.json failed schema validation: ${d.message}`)}let s=At(i.dir,"assets.json"),c=null;if(await V(s)){let d=_t.safeParse(await _e(s));if(!d.success)throw new Error(`demos/${i.slug}/assets.json failed schema validation: ${d.error.message}`);c=d.data}a.push({slug:i.slug,dir:i.dir,configPath:i.configPath,config:o,assetsPath:s,assets:c})}return{root:e,inklyPath:n,inkly:r.data,demos:a}}function rr(t){let e=t.split("/")[0]??t,n=Se(e);return n.ok?lt.includes(t)?`Demo folder "${t}" uses a reserved slug.`:null:n.reason}async function wn(t){try{let e=await rd(t);return e.isFile()?e.size:null}catch{return null}}import{mkdir as sd,rename as ld,writeFile as dd}from"fs/promises";import{dirname as cd}from"path";async function K(t,e,n){await sd(cd(t),{recursive:!0});let r=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await dd(r,e,n?.mode!=null?{mode:n.mode}:void 0),await ld(r,t)}var fd="https://www.runtime.inklyai.dev";function ct(){let t=process.env.BUNDLES_R2_PUBLIC_BASE_URL;return typeof t=="string"&&t.length>0?t.replace(/\/+$/,""):fd}function sr(t,e,n=ct()){return`${n}/runtime/${t}/${e}`}function gd(t){return Ne(hd(),".inkly","cache","runtime",t)}function bd(t){let e=/^(sha(?:256|384|512))-([A-Za-z0-9+/]+=*)$/.exec(t);return e?{algorithm:e[1],expected:e[2]}:null}function Pt(t,e){let n=bd(e);return n?ud(n.algorithm).update(t).digest("base64")===n.expected:!1}var Et=class extends Error{constructor(n,r,a){super(`integrity mismatch for ${n}: expected ${r}`+(a?` (from ${a})`:"")+". The bundle does not match inkly.lock. Re-run `inkly lock` to refresh, or the CDN may have been tampered with.");this.file=n;this.expected=r;this.url=a;this.name="IntegrityMismatchError"}},dt=class extends Error{constructor(e){super(e),this.name="LockReadError"}};async function yd(t){let e=Ne(t,"inkly.lock");if(!await V(e))throw new dt(`no inkly.lock found in ${t}. Run \`inkly lock\` to generate one.`);let n;try{n=await _e(e)}catch(a){throw new dt(`failed to read ${e}: ${a.message}`)}let r=kn.safeParse(n);if(!r.success)throw new dt(`${e} failed InklyLockSchema validation: ${r.error.message}`);return r.data}function xd(t,e){let n=t.lastIndexOf("/");return n===-1?t:`${t.slice(0,n+1)}${e}`}async function Wa(t){try{return await or(t)}catch{return null}}async function kd(t){let e=Ne(t,"manifest.json");if(!await V(e))return null;try{let n=JSON.parse(await or(e,"utf8")),r=Tt.safeParse(n);return r.success?r.data:null}catch{return null}}async function ar(t,e){await K(t,e)}async function ir(t,e){if(t.startsWith("file://"))try{return await or(md(t))}catch(a){throw new Error(`failed to read ${t}: ${a.message}`)}let n;try{n=await e(t)}catch(a){throw new Error(`failed to fetch ${t}: ${a.message}`)}if(!n.ok)throw new Error(`fetch ${t} returned HTTP ${n.status}`);let r=await n.arrayBuffer();return Buffer.from(r)}async function Va(t){let e=t.fetchImpl??fetch,n=await yd(t.hubRoot),{version:r,url:a,integrity:i}=n.runtime,o=gd(r),s=await Wa(Ne(o,"runtime.js")),c=await Wa(Ne(o,"runtime.css")),d=await kd(o);if(s&&c&&d){let O=Pt(s,i),E=d.version===r,g=Pt(c,d.cssIntegrity);if(O&&E&&g)return{version:r,cacheDir:o,manifest:d,fetched:!1,bytesFetched:0,lock:n}}let u=O=>{let E=t.urlOverrides?.[O];return E||(O==="runtime.js"?a:xd(a,O))};await pd(o,{recursive:!0});let p=u("manifest.json"),h=await ir(p,e),y;try{let O=JSON.parse(h.toString("utf8")),E=Tt.safeParse(O);if(!E.success)throw new Error(`manifest from ${p} failed schema validation: ${E.error.message}`);y=E.data}catch(O){throw new Error(`manifest from ${p} is not valid JSON: ${O.message}`)}if(y.version!==r)throw new Error(`CDN manifest for ${p} reports version ${y.version} but inkly.lock pins ${r}. Re-run \`inkly lock\` to refresh.`);let k=u("runtime.js"),v=await ir(k,e);if(!Pt(v,i))throw new Et("runtime.js",i,k);let C=u("runtime.css"),$=await ir(C,e);if(!Pt($,y.cssIntegrity))throw new Et("runtime.css",y.cssIntegrity,C);return await ar(Ne(o,"runtime.js"),v),await ar(Ne(o,"runtime.css"),$),await ar(Ne(o,"manifest.json"),h),{version:r,cacheDir:o,manifest:y,fetched:!0,bytesFetched:v.byteLength+$.byteLength+h.byteLength,lock:n}}function vn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ad(t=ct()){return`${t}/runtime/latest.json`}function Ga(t){return Za==="/"?t:t.split("/").join(Za)}function Id(t){let e=t??globalThis.fetch;if(typeof e!="function")throw new Error("This Node runtime does not provide fetch; Node 20+ is required.");return e}async function qa(t,e){let n=await e(t);if(!n.ok)throw new Error(`failed to fetch ${t}: HTTP ${n.status}${n.statusText?` ${n.statusText}`:""}`);let r=wd.from(await n.arrayBuffer()),a;try{a=JSON.parse(r.toString("utf8"))}catch(i){throw new Error(`failed to parse JSON from ${t}: ${i.message}`)}return{json:a,bytes:r}}function Pd(t,e){if(!vn(t))throw new Error(`${e} is not an object`);let n=t.version,r=t.hubSkeleton;if(typeof n!="string"||n.length===0)throw new Error(`${e} is missing version`);if(!vn(r))throw new Error(`${e} is missing hubSkeleton`);if(typeof r.url!="string"||r.url.length===0)throw new Error(`${e} is missing hubSkeleton.url`);if(typeof r.integrity!="string"||r.integrity.length===0)throw new Error(`${e} is missing hubSkeleton.integrity`);if(typeof r.version!="number")throw new Error(`${e} is missing hubSkeleton.version`);let a=typeof r.bytes=="number"?r.bytes:void 0;return{version:n,hubSkeleton:{version:r.version,url:r.url,integrity:r.integrity,bytes:a}}}function Ed(t,e){if(!vn(t))throw new Error(`${e} is not an object`);if(t.version!==1)throw new Error(`${e} has unsupported skeleton version`);if(typeof t.runtime!="string"||t.runtime.length===0)throw new Error(`${e} is missing runtime`);if(!Array.isArray(t.files))throw new Error(`${e} is missing files`);let n=t.files.map((r,a)=>{if(!vn(r))throw new Error(`${e} files[${a}] is not an object`);if(typeof r.path!="string"||r.path.length===0)throw new Error(`${e} files[${a}].path is missing`);if(typeof r.contents!="string")throw new Error(`${e} files[${a}].contents is missing`);return{path:r.path,contents:r.contents}});return{version:1,runtime:t.runtime,files:n}}function Rd(t,e,n){return t.split(e).join(n)}function $d(t){if(t.startsWith("/")||t.startsWith("\\")||/^[A-Za-z]:/.test(t)||t.includes("\\")||t.split("/").some(e=>e===".."||e.length===0))throw new Error(`Unsafe skeleton path from runtime manifest: ${t}`)}function Dd(t,e){let n=t.runtime,r=ne(),a=[["{{hubName}}",e.hubName],["{{hubNameJson}}",JSON.stringify(e.hubName)],["{{runtimeVersionJson}}",JSON.stringify(n)],["{{layoutEntry}}",e.layout===void 0?"":` "layout": ${JSON.stringify(e.layout)},
|
|
4964
|
-
|
|
4963
|
+
`,na={id:"substack",label:"Substack",theme:Be.substack,css:pc};var ra=[ta,Qi,ea,na],pe=Object.fromEntries(ra.map(e=>[e.id,e]));import{createHash as _c}from"crypto";import{mkdir as Cc,readFile as yr,rm as Nf,stat as Mf}from"fs/promises";import{homedir as Tc}from"os";import{join as We}from"path";import{fileURLToPath as Ac}from"url";import{access as hc,readFile as mc,readdir as fc,stat as gc}from"fs/promises";import{dirname as bc,join as Nt,resolve as yc,sep as xc}from"path";async function Z(e){return hc(e).then(()=>!0,()=>!1)}async function De(e){let t=yc(e);for(;;){if(await Z(Nt(t,"inkly.json")))return t;let n=bc(t);if(n===t)return null;t=n}}async function mr(e){let t=Nt(e,"demos");if(!await Z(t))return[];let n=[];async function r(i){let a;try{a=await fc(i,{withFileTypes:!0})}catch{return}if(a.some(o=>o.isFile()&&o.name==="demo.config.json")){let o=i===t?"":i.slice(t.length+1).split(xc).join("/");n.push({slug:o,dir:i,configPath:Nt(i,"demo.config.json")});return}for(let o of a)o.isDirectory()&&await r(Nt(i,o.name))}return await r(t),n.sort((i,a)=>i.slug.localeCompare(a.slug))}async function $e(e){let t=await mc(e,"utf8");return JSON.parse(t)}async function Mt(e){let t=await De(e);if(!t)throw new Error(`No inkly.json found in ${e} or any parent directory.`);let n=Nt(t,"inkly.json"),r=we.safeParse(await $e(n));if(!r.success)throw new Error(`inkly.json failed schema validation: ${r.error.message}`);let i=[];for(let a of await mr(t)){let o;try{o=$t(await $e(a.configPath)).config}catch(d){throw new Error(`demos/${a.slug}/demo.config.json failed schema validation: ${d.message}`)}let s=Nt(a.dir,"assets.json"),c=null;if(await Z(s)){let d=Rt.safeParse(await $e(s));if(!d.success)throw new Error(`demos/${a.slug}/assets.json failed schema validation: ${d.error.message}`);c=d.data}i.push({slug:a.slug,dir:a.dir,configPath:a.configPath,config:o,assetsPath:s,assets:c})}return{root:t,inklyPath:n,inkly:r.data,demos:i}}function fr(e){let t=e.split("/")[0]??e,n=Re(t);return n.ok?gt.includes(e)?`Demo folder "${e}" uses a reserved slug.`:null:n.reason}async function An(e){try{let t=await gc(e);return t.isFile()?t.size:null}catch{return null}}import{mkdir as kc,rename as wc,writeFile as vc}from"fs/promises";import{dirname as Sc}from"path";async function te(e,t,n){await kc(Sc(e),{recursive:!0});let r=`${e}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;await vc(r,t,n?.mode!=null?{mode:n.mode}:void 0),await wc(r,e)}var Pc="https://www.runtime.inklyai.dev";function yt(){let e=process.env.BUNDLES_R2_PUBLIC_BASE_URL;return typeof e=="string"&&e.length>0?e.replace(/\/+$/,""):Pc}function xr(e,t,n=yt()){return`${n}/runtime/${e}/${t}`}function Ic(e){return We(Tc(),".inkly","cache","runtime",e)}function Ec(e){let t=/^(sha(?:256|384|512))-([A-Za-z0-9+/]+=*)$/.exec(e);return t?{algorithm:t[1],expected:t[2]}:null}function Lt(e,t){let n=Ec(t);return n?_c(n.algorithm).update(e).digest("base64")===n.expected:!1}var Ot=class extends Error{constructor(n,r,i){super(`integrity mismatch for ${n}: expected ${r}`+(i?` (from ${i})`:"")+". The bundle does not match inkly.lock. Re-run `inkly lock` to refresh, or the CDN may have been tampered with.");this.file=n;this.expected=r;this.url=i;this.name="IntegrityMismatchError"}},bt=class extends Error{constructor(t){super(t),this.name="LockReadError"}};async function Rc(e){let t=We(e,"inkly.lock");if(!await Z(t))throw new bt(`no inkly.lock found in ${e}. Run \`inkly lock\` to generate one.`);let n;try{n=await $e(t)}catch(i){throw new bt(`failed to read ${t}: ${i.message}`)}let r=Tn.safeParse(n);if(!r.success)throw new bt(`${t} failed InklyLockSchema validation: ${r.error.message}`);return r.data}function $c(e,t){let n=e.lastIndexOf("/");return n===-1?e:`${e.slice(0,n+1)}${t}`}async function ia(e){try{return await yr(e)}catch{return null}}async function Dc(e){let t=We(e,"manifest.json");if(!await Z(t))return null;try{let n=JSON.parse(await yr(t,"utf8")),r=Dt.safeParse(n);return r.success?r.data:null}catch{return null}}async function gr(e,t){await te(e,t)}async function br(e,t){if(e.startsWith("file://"))try{return await yr(Ac(e))}catch(i){throw new Error(`failed to read ${e}: ${i.message}`)}let n;try{n=await t(e)}catch(i){throw new Error(`failed to fetch ${e}: ${i.message}`)}if(!n.ok)throw new Error(`fetch ${e} returned HTTP ${n.status}`);let r=await n.arrayBuffer();return Buffer.from(r)}async function kr(e){let t=e.fetchImpl??fetch,n=e.lock??await Rc(e.hubRoot),{version:r,url:i,integrity:a}=n.runtime,o=Ic(r),s=await ia(We(o,"runtime.js")),c=await ia(We(o,"runtime.css")),d=await Dc(o);if(s&&c&&d){let $=Lt(s,a),R=d.version===r,b=Lt(c,d.cssIntegrity);if($&&R&&b)return{version:r,cacheDir:o,manifest:d,fetched:!1,bytesFetched:0,lock:n}}let u=$=>{let R=e.urlOverrides?.[$];return R||($==="runtime.js"?i:$c(i,$))};await Cc(o,{recursive:!0});let p=u("manifest.json"),h=await br(p,t),f;try{let $=JSON.parse(h.toString("utf8")),R=Dt.safeParse($);if(!R.success)throw new Error(`manifest from ${p} failed schema validation: ${R.error.message}`);f=R.data}catch($){throw new Error(`manifest from ${p} is not valid JSON: ${$.message}`)}if(f.version!==r)throw new Error(`CDN manifest for ${p} reports version ${f.version} but inkly.lock pins ${r}. Re-run \`inkly lock\` to refresh.`);let w=u("runtime.js"),x=await br(w,t);if(!Lt(x,a))throw new Ot("runtime.js",a,w);let _=u("runtime.css"),I=await br(_,t);if(!Lt(I,f.cssIntegrity))throw new Ot("runtime.css",f.cssIntegrity,_);return await gr(We(o,"runtime.js"),x),await gr(We(o,"runtime.css"),I),await gr(We(o,"manifest.json"),h),{version:r,cacheDir:o,manifest:f,fetched:!0,bytesFetched:x.byteLength+I.byteLength+h.byteLength,lock:n}}import{readFile as oa,writeFile as Nc}from"fs/promises";import{dirname as wr,isAbsolute as Mc,join as jt,resolve as Lc}from"path";import{fileURLToPath as Oc,pathToFileURL as jc}from"url";function Ve(e,t,n){e.push({level:t,message:n})}async function zc(){let e=wr(Oc(import.meta.url));for(let t=0;t<10;t+=1){let n=jt(e,"node_modules","@inkly","runtime","dist","manifest.json");if(await Z(n))return n;let r=jt(e,"packages","inkly-runtime","dist","manifest.json");if(await Z(r))return r;let i=wr(e);if(i===e)break;e=i}return null}async function aa(e){let t=JSON.parse(await oa(e,"utf8")),n=Dt.safeParse(t);if(!n.success)throw new Error(`${e} failed RuntimeManifestSchema validation: ${n.error.message}`);return n.data}async function Uc(e,t){let n=yt(),r=xr(e,"manifest.json",n);try{let i=await t(r);if(!i.ok)return null;let a=JSON.parse(await i.text()),o=Dt.safeParse(a);return o.success?{manifest:o.data,url:r}:null}catch{return null}}async function Fc(e,t){if(t.manifestPath)return{manifest:await aa(t.manifestPath),source:"local",manifestPath:t.manifestPath};if(!t.localOnly){let r=t.fetchImpl??fetch,i=await Uc(e,r);if(i){if(i.manifest.version!==e)throw new Error(`CDN manifest at ${i.url} reports version ${i.manifest.version} but inkly.json pins ${e}. Wait for the publish workflow to upload the matching artifact, or update inkly.json#runtime to match.`);return{manifest:i.manifest,source:"cdn"}}}let n=await zc();if(!n)throw new Error(`Could not fetch runtime manifest for ${e} from ${yt()} and no local @inkly/runtime/dist/manifest.json was found. Either publish the runtime to R2, run \`npm run build:runtime\` in @inkly/runtime, or pass \`inkly lock --local <path-to-inkly-runtime>\`.`);return{manifest:await aa(n),source:"local",manifestPath:n}}async function Pn(e,t={}){let n=jt(e,"inkly.json"),r=await $e(n),i=typeof r.runtime=="string"?r.runtime:null;if(!i)throw new Error('inkly.json is missing a string "runtime" pin.');if(!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(i))throw new Error(`inkly.json#runtime must be an exact semver (got "${i}"). Set runtime to an exact version and put your compatibility range in runtimeRange.`);let{manifest:a,source:o,manifestPath:s}=await Fc(i,t);if(a.version!==i)throw new Error(`Runtime manifest reports version ${a.version} but inkly.json pins ${i}. Build the matching Inkly runtime version (or upgrade the pin) and retry.`);return{lock:{$schema:"https://inklyai.dev/inkly.lock",runtime:{version:a.version,url:o==="local"&&s?jc(jt(wr(s),"runtime.js")).toString():xr(a.version,"runtime.js"),integrity:a.integrity}},manifest:a,source:o}}async function In(e){let t=[],n=await De(e.cwd);if(!n)return Ve(t,"error",`No inkly.json found in ${e.cwd} or any parent directory.`),ve({ok:!1,hubRoot:null,lockPath:null,lock:null,source:null,issues:t,drifted:!1,options:e});let r=jt(n,"inkly.lock"),i=e.manifestPath?Mc(e.manifestPath)?e.manifestPath:Lc(e.cwd,e.manifestPath):void 0;if(e.check){if(!await Z(r))return Ve(t,"error","inkly.lock is missing. Run `inkly lock` to create it."),ve({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:t,drifted:!0,options:e});let a=await $e(r),o=Tn.safeParse(a);if(!o.success)return Ve(t,"error",`inkly.lock failed schema validation: ${o.error.message}`),ve({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:t,drifted:!0,options:e});let s=jt(n,"inkly.json"),c=await $e(s),d=typeof c.runtime=="string"?c.runtime:null;if(!d)return Ve(t,"error",'inkly.json is missing a string "runtime" pin.'),ve({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:t,drifted:!0,options:e});if(o.data.runtime.version!==d)return Ve(t,"error",`inkly.lock pins runtime ${o.data.runtime.version}, but inkly.json pins ${d}. Re-run \`inkly lock\` to refresh.`),ve({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:null,issues:t,drifted:!0,options:e});try{let u=await Pn(n,{manifestPath:i,localOnly:!!i||e.localOnly,fetchImpl:e.fetchImpl});return u.lock.runtime.integrity!==o.data.runtime.integrity?(Ve(t,"error",`inkly.lock integrity does not match what ${u.source==="cdn"?yt():"the local build"} serves for runtime ${d}. Re-run \`inkly lock\` to refresh, or someone tampered with the source.`),ve({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:u.source,issues:t,drifted:!0,options:e})):ve({ok:!0,hubRoot:n,lockPath:r,lock:o.data,source:u.source,issues:t,drifted:!1,options:e})}catch(u){return Ve(t,"error",u.message),ve({ok:!1,hubRoot:n,lockPath:r,lock:o.data,source:null,issues:t,drifted:!0,options:e})}}try{let{lock:a,source:o}=await Pn(n,{manifestPath:i,localOnly:!!i||e.localOnly,fetchImpl:e.fetchImpl}),s=JSON.stringify(a,null,2)+`
|
|
4964
|
+
`,d=(await Z(r)?await oa(r,"utf8"):null)!==s;return d&&await Nc(r,s,"utf8"),ve({ok:!0,hubRoot:n,lockPath:r,lock:a,source:o,issues:t,drifted:d,options:e})}catch(a){return Ve(t,"error",a.message),ve({ok:!1,hubRoot:n,lockPath:r,lock:null,source:null,issues:t,drifted:!1,options:e})}}function ve(e){let{ok:t,hubRoot:n,lockPath:r,lock:i,source:a,issues:o,drifted:s,options:c}=e,d={ok:t,hubRoot:n,lockPath:r,lock:i,source:a,issues:o,drifted:s};if(!c.silent)if(c.json)process.stdout.write(JSON.stringify(d,null,2)+`
|
|
4965
|
+
`);else if(t)c.check?process.stdout.write(`inkly lock --check: inkly.lock matches inkly.json (runtime ${i?.runtime.version}, source: ${a??"unknown"}).
|
|
4966
|
+
`):s?process.stdout.write(`inkly lock: wrote ${r} (runtime ${i?.runtime.version}, source: ${a??"unknown"}).
|
|
4967
|
+
`):process.stdout.write(`inkly lock: ${r} already up to date (runtime ${i?.runtime.version}, source: ${a??"unknown"}).
|
|
4968
|
+
`);else{for(let u of o)process.stdout.write(`${u.level.toUpperCase()} ${u.message}
|
|
4969
|
+
`);process.stdout.write(`inkly lock failed
|
|
4970
|
+
`)}return d}function En(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function qc(e=yt()){return`${e}/runtime/latest.json`}function ca(e){return la==="/"?e:e.split("/").join(la)}function Gc(e){let t=e??globalThis.fetch;if(typeof t!="function")throw new Error("This Node runtime does not provide fetch; Node 20+ is required.");return t}async function da(e,t){let n=await t(e);if(!n.ok)throw new Error(`failed to fetch ${e}: HTTP ${n.status}${n.statusText?` ${n.statusText}`:""}`);let r=Hc.from(await n.arrayBuffer()),i;try{i=JSON.parse(r.toString("utf8"))}catch(a){throw new Error(`failed to parse JSON from ${e}: ${a.message}`)}return{json:i,bytes:r}}function Kc(e,t){if(!En(e))throw new Error(`${t} is not an object`);let n=e.version,r=e.hubSkeleton;if(typeof n!="string"||n.length===0)throw new Error(`${t} is missing version`);if(!En(r))throw new Error(`${t} is missing hubSkeleton`);if(typeof r.url!="string"||r.url.length===0)throw new Error(`${t} is missing hubSkeleton.url`);if(typeof r.integrity!="string"||r.integrity.length===0)throw new Error(`${t} is missing hubSkeleton.integrity`);if(typeof r.version!="number")throw new Error(`${t} is missing hubSkeleton.version`);let i=typeof r.bytes=="number"?r.bytes:void 0;return{version:n,hubSkeleton:{version:r.version,url:r.url,integrity:r.integrity,bytes:i}}}function Yc(e,t){if(!En(e))throw new Error(`${t} is not an object`);if(e.version!==1)throw new Error(`${t} has unsupported skeleton version`);if(typeof e.runtime!="string"||e.runtime.length===0)throw new Error(`${t} is missing runtime`);if(!Array.isArray(e.files))throw new Error(`${t} is missing files`);let n=e.files.map((r,i)=>{if(!En(r))throw new Error(`${t} files[${i}] is not an object`);if(typeof r.path!="string"||r.path.length===0)throw new Error(`${t} files[${i}].path is missing`);if(typeof r.contents!="string")throw new Error(`${t} files[${i}].contents is missing`);return{path:r.path,contents:r.contents}});return{version:1,runtime:e.runtime,files:n}}function Xc(e,t,n){return e.split(t).join(n)}function Qc(e){if(e.startsWith("/")||e.startsWith("\\")||/^[A-Za-z]:/.test(e)||e.includes("\\")||e.split("/").some(t=>t===".."||t.length===0))throw new Error(`Unsafe skeleton path from runtime manifest: ${e}`)}function ed(e,t){let n=e.runtime,r=oe(),i=[["{{hubName}}",t.hubName],["{{hubNameJson}}",JSON.stringify(t.hubName)],["{{runtimeVersionJson}}",JSON.stringify(n)],["{{layoutEntry}}",t.layout===void 0?"":` "layout": ${JSON.stringify(t.layout)},
|
|
4971
|
+
`],["{{themeJson}}",JSON.stringify(t.theme??"inkly")],["{{starterDemoIdJson}}",JSON.stringify(r)]],a=e.files.map(u=>{Qc(u.path);let p=u.contents;for(let[h,f]of i)p=Xc(p,h,f);if(/\{\{[A-Za-z][A-Za-z0-9]*\}\}/.test(p))throw new Error(`Unresolved placeholder in runtime skeleton file: ${u.path}`);return{path:u.path,contents:p}}),o=a.find(u=>u.path==="inkly.json");if(!o)throw new Error("Runtime skeleton is missing inkly.json");let s=we.safeParse(JSON.parse(o.contents));if(!s.success)throw new Error(`Runtime skeleton inkly.json is invalid: ${s.error.message}`);let c=a.find(u=>u.path==="demos/getting-started/demo.config.json");if(!c)throw new Error("Runtime skeleton is missing demos/getting-started/demo.config.json");let d=mt.safeParse(JSON.parse(c.contents));if(!d.success)throw new Error(`Runtime skeleton starter demo is invalid: ${d.error.message}`);return a}async function td(e){let{latestUrl:t,fetchImpl:n}=e,r=await da(t,n),i=Kc(r.json,t),a=new URL(i.hubSkeleton.url,t).toString(),o=await da(a,n);if(!Lt(o.bytes,i.hubSkeleton.integrity))throw new Error(`integrity mismatch for hub-skeleton.json from ${a}`);if(typeof i.hubSkeleton.bytes=="number"&&o.bytes.byteLength!==i.hubSkeleton.bytes)throw new Error(`byte length mismatch for hub-skeleton.json from ${a}`);let s=Yc(o.json,a);if(s.runtime!==i.version)throw new Error(`runtime/latest.json points at ${i.version}, but hub-skeleton.json declares ${s.runtime}`);return s}async function ua(e){let{name:t,cwd:n,layout:r,theme:i,silent:a}=e,o=Re(t);if(!o.ok)throw new Error(o.reason);let s=r===void 0?void 0:ur.safeParse(r);if(s&&!s.success)throw new Error("Invalid layout. Expected one of: sidebar, tabs.");if(i!==void 0){if(i.length===0)throw new Error("Invalid theme. Expected a theme preset id.");if(!pe[i]){let f=Object.keys(pe).join(", ");throw new Error(`Invalid theme "${i}". Expected one of: ${f}.`)}}let c=Zc(n,t);if(await Wc(c).then(()=>!0,()=>!1))throw new Error(`Directory already exists: ${c}. Refusing to overwrite \u2014 choose a different name or remove it first.`);let u=await td({latestUrl:e.runtimeManifestUrl??qc(),fetchImpl:Gc(e.fetchImpl)}),p=ed(u,{hubName:t,layout:s?.data,theme:i});await sa(c,{recursive:!0}),await Promise.all(p.map(async f=>{let w=ca(f.path),x=Jc(c,w);await sa(Vc(x),{recursive:!0}),await Bc(x,f.contents,"utf8")}));let h=!1;try{let f=await In({cwd:c,silent:!0,fetchImpl:e.fetchImpl});h=f.ok&&f.lockPath!==null}catch{}return a||(process.stdout.write(`Scaffolded hub ${t} at ${c}
|
|
4965
4972
|
|
|
4966
4973
|
Next steps:
|
|
4967
|
-
cd ${
|
|
4974
|
+
cd ${t}
|
|
4968
4975
|
inkly dev
|
|
4969
4976
|
open http://localhost:3000
|
|
4970
|
-
`),{dir:c,files:p.map(
|
|
4971
|
-
`)}var
|
|
4972
|
-
${
|
|
4977
|
+
`),h||process.stdout.write("\nNote: could not pin the runtime yet (inkly.lock not written). `inkly dev` will resolve it on first run; run `inkly lock` to pin it.\n")),{dir:c,files:p.map(f=>ca(f.path))}}import{createServer as id}from"vite";import ad from"chokidar";import{readFile as me,readdir as od,stat as nn,mkdtemp as sd,mkdir as ld,cp as cd,writeFile as dd,rm as ud}from"fs/promises";import{existsSync as xt,createReadStream as pd}from"fs";import{tmpdir as hd}from"os";import{basename as md,dirname as kt,extname as fd,join as j,relative as gd,resolve as Je,sep as Dn}from"path";import{fileURLToPath as ka}from"url";import{createRequire as bd}from"module";import{createConnection as yd,createServer as xd}from"net";import{readFile as pa,stat as nd}from"fs/promises";import{relative as rd}from"path";async function Rn(e){let t=await De(e);if(!t)throw new Error(`No inkly.json found in ${e} or any parent directory. Run \`inkly init <name>\` first or cd into your hub.`);let n=[],r=[],i=[],a=[];for(let s of await mr(t)){let c;try{c=await pa(s.configPath,"utf8")}catch(h){i.push({slug:s.slug,configPath:s.configPath,message:`failed to read demo.config.json (${h.message})`});continue}let d;try{d=JSON.parse(c)}catch(h){i.push({slug:s.slug,configPath:s.configPath,message:`demo.config.json is not valid JSON (${h.message})`});continue}let u;try{u=$t(d)}catch(h){i.push({slug:s.slug,configPath:s.configPath,message:`demo.config.json failed schema validation: ${h.message}`});continue}u.changed&&(await ha(s.configPath,u.config),n.push({slug:s.slug,configPath:s.configPath,reason:"heal"}));let p=(await nd(s.configPath)).mtimeMs;a.push({slug:s.slug,configPath:s.configPath,id:u.config.id,mtimeMs:p})}let o=Gi(a.map(s=>({...s,updatedAt:s.mtimeMs})));for(let{entry:s,newId:c}of o){let d=await pa(s.configPath,"utf8"),u=JSON.parse(d);u.id=c,await ha(s.configPath,u),r.push({slug:s.slug,configPath:s.configPath,reason:"remint"})}return{hubRoot:t,healed:n,reminted:r,skipped:i}}function en(e,t){return rd(e,t).split(/[\\/]/).join("/")}async function ha(e,t){await te(e,JSON.stringify(t,null,2)+`
|
|
4978
|
+
`)}var kd=ka(import.meta.url),zt=kt(kd),Sr="127.0.0.1";function ma(e){let t=Je(zt,"template",e);return xt(t)?t:Je(zt,"..","..","template",e)}function wd(e){let t=[Je(zt,"..","vendor",e),Je(zt,"..","..","vendor",e),Je(zt,"..","..","..","public","__inkly","vendor",e)];for(let n of t)if(xt(n))return n;return null}function vd(e){try{let r=bd(j(e,"package.json")).resolve("@inkly/runtime/package.json");return Je(kt(r),"dist")}catch{}let t=zt;for(let n=0;n<8;n++){let r=j(t,"packages","inkly-runtime","dist");if(xt(r))return r;let i=kt(t);if(i===t)break;t=i}return null}function fa(e,t){if(!t)return e;let{integrity:n}=t.lock.runtime,r=t.manifest.cssIntegrity,i=e;i=i.replace(/<link rel="stylesheet" href="\/__inkly\/runtime\.css" \/>/,`<link rel="stylesheet" href="/__inkly/runtime.css" integrity="${r}" crossorigin="anonymous" />`);let a=`<link rel="modulepreload" href="/__inkly/runtime.js" integrity="${n}" crossorigin="anonymous" />`;return/<link rel="prefetch" href="\/__inkly\/runtime\.js"[^>]*\/>/.test(i)?i=i.replace(/<link rel="prefetch" href="\/__inkly\/runtime\.js"[^>]*\/>/,a):i=i.replace(/<link rel="stylesheet" href="\/__inkly\/runtime\.css"[^>]*\/>/,o=>`${o}
|
|
4979
|
+
${a}`),i}function H(e,t,n,r){e.statusCode=t,e.setHeader("content-type",n),e.setHeader("cache-control","no-store"),e.end(r)}function rn(e,t,n){e.statusCode=200,e.setHeader("content-type",n),e.setHeader("cache-control","no-store");let r=pd(t);r.on("error",i=>{e.statusCode=500,e.end(`Failed to read ${t}: ${i.message}`)}),r.pipe(e)}var ga=`Inkly runtime artifact not found. Run:
|
|
4973
4980
|
npm run build:runtime -w @inkly/runtime
|
|
4974
4981
|
then restart \`inkly dev\`.
|
|
4975
|
-
`;function
|
|
4976
|
-
${
|
|
4977
|
-
</head>`)}function
|
|
4978
|
-
`),{hubRoot:r,slug:n}}async function
|
|
4979
|
-
`)},o=
|
|
4980
|
-
`)}else throw new Error(`No inkly.json found in ${o} or any parent directory. Run \`inkly init <name>\` first, cd into your hub, or point \`inkly dev\` at an exported demo folder (a directory containing demo.config.json).`);let d=await
|
|
4981
|
-
`);for(let
|
|
4982
|
-
`)}let u=await
|
|
4983
|
-
`)}else process.stdout.write(`[inkly dev] runtime ${
|
|
4984
|
-
`)}catch(
|
|
4985
|
-
`)
|
|
4986
|
-
`)
|
|
4982
|
+
`;function Sd(e){let t=Je(e);for(;;){if(xt(j(t,"inkly.json")))return t;let n=kt(t);if(n===t)return null;t=n}}function ba(e){if(!e)return null;let t=e.trim();return t?/^(?:[a-z][a-z0-9+.-]*:|\/\/|#)/i.test(t)||t.startsWith("/")?t:t.startsWith("public/")?`/${t.slice(7)}`:`/${t.replace(/^\.\/+/,"")}`:null}function _r(e){return e.brand?{...e,brand:{...e.brand,...e.brand.logo?{logo:ba(e.brand.logo)??e.brand.logo}:{},...e.brand.favicon?{favicon:ba(e.brand.favicon)??e.brand.favicon}:{}}}:e}function wa(e,t){return e.publicUrl&&/^(https?:)?\/\//i.test(e.publicUrl)?e.publicUrl:e.file?`/${t}/${e.file}`:e.publicUrl??null}function _d(e){let t=new Map(e.assets.map(n=>[n.id,n]));return Ki({slug:e.slug,config:e.config,resolveAssetSrc:n=>{if(!n.startsWith("asset:"))return n;let r=t.get(n.slice(6));return r?wa(r,e.slug):null}})}async function Cd(e){let t=j(kt(e),"assets.json");try{let n=await me(t,"utf8"),r=JSON.parse(n);return Array.isArray(r.assets)?r.assets.filter(i=>{if(!i||typeof i!="object")return!1;let a=i;return typeof a.id=="string"&&a.id.length>0}):[]}catch{return[]}}async function Td(e){let t=j(e,"demos");if(!xt(t))return[];let n=[];async function r(i){let a;try{a=await od(i,{withFileTypes:!0})}catch{return}if(a.some(s=>s.isFile()&&s.name==="demo.config.json")){let s=gd(t,i).split(Dn).join("/");n.push({slug:s,configPath:j(i,"demo.config.json")});return}for(let s of a)s.isDirectory()&&await r(j(i,s.name))}return await r(t),n}async function ya(e,t){let n=j(e,"inkly.json"),r;try{r=await me(n,"utf8")}catch(p){throw new Error(`Failed to read inkly.json at ${n}: ${p.message}`)}let i;try{i=JSON.parse(r)}catch(p){throw new Error(`inkly.json is not valid JSON: ${p.message}`)}let a=we.safeParse(i);if(!a.success)throw new Error(`inkly.json failed schema validation:
|
|
4983
|
+
${a.error.message}`);let o=a.data,s=await Td(e);for(let p of s){let h=an(p.slug);if(!h.ok)throw new Error(`Demo folder "${p.slug}" has an invalid slug: ${h.reason}`);if(gt.includes(p.slug))throw new Error(`Demo folder "${p.slug}" uses a reserved slug.`)}let c=[];for(let p of s){let h;try{h=await me(p.configPath,"utf8")}catch(x){t(`Skipping ${p.slug}: failed to read demo.config.json (${x.message})`);continue}let f;try{f=JSON.parse(h)}catch(x){t(`Skipping ${p.slug}: demo.config.json is not valid JSON (${x.message})`);continue}let w;try{w=$t(f).config}catch(x){t(`Skipping ${p.slug}: demo.config.json failed schema validation: ${x.message}`);continue}c.push({slug:p.slug,configPath:p.configPath,config:w,assets:await Cd(p.configPath)})}let d=c.map(p=>_d(p)),u=new Map;for(let p of c)u.set(p.slug,p);return{hub:o,hubPath:n,demos:c,index:d,bySlug:u}}function $n(e,t,n){let r=JSON.stringify(n).replace(/<\/(script)/gi,"<\\/$1"),i=`<script id="${t}" type="application/json">${r}</script>`;return e.includes(`id="${t}"`)?e.replace(new RegExp(`<script id="${t}"[^>]*>[\\s\\S]*?</script>`),i):e.replace("</head>",`${i}
|
|
4984
|
+
</head>`)}function Ad(e){let t=e.hub.theme??"inkly",n=pe[t];return{hub:_r(e.hub),demos:e.index,theme:{id:t,tokens:n?.theme??null,css:n?.css??""}}}var Pd={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".txt":"text/plain; charset=utf-8",".md":"text/markdown; charset=utf-8"};function tn(e){return Pd[fd(e).toLowerCase()]??"application/octet-stream"}function an(e){let t=e.split("/").filter(Boolean);if(t.length===0)return{ok:!1,reason:"Name cannot be empty."};for(let n of t){let r=Re(n);if(!r.ok)return r}return gt.includes(e)?{ok:!1,reason:`Demo folder "${e}" uses a reserved slug.`}:{ok:!0}}function xa(e,t){let n;try{n=decodeURIComponent(e)}catch{return null}let r=n.replace(/^\/+/,"").replace(/\/+$/,"");if(!r)return null;let i=r.split("/").filter(Boolean);for(let a=i.length;a>=1;a-=1){let o=i.slice(0,a).join("/");if(!an(o).ok)continue;let s=t.bySlug.get(o);if(s)return{slug:o,demo:s,rel:i.slice(a).join("/")}}return null}async function Id(e){return new Promise(t=>{let n=xd();n.once("error",()=>t(!1)),n.once("listening",()=>{n.close(()=>t(!0))}),n.listen(e,Sr)})}async function Ed(e,t){return new Promise(n=>{let r=!1,i=o=>{r||(r=!0,a.destroy(),n(o))},a=yd({port:e,host:t});a.setTimeout(250),a.once("connect",()=>i(!0)),a.once("timeout",()=>i(!1)),a.once("error",()=>i(!1))})}async function Rd(e){if(!await Id(e))return!1;for(let t of["localhost","127.0.0.1","::1"])if(await Ed(e,t))return!1;return!0}async function $d(e){if(e===0)return 0;if(!Number.isInteger(e)||e<0||e>65535)throw new Error(`invalid port: ${e}`);for(let t=e;t<=65535;t+=1)if(await Rd(t))return t;throw new Error(`No available port found at or above ${e}`)}function Dd(e,t){let n=e.httpServer?.address();return n&&typeof n=="object"?n.port:e.config.server.port??t}async function Nd(e){let t=md(e),n=/^[a-z0-9][a-z0-9-]*$/.test(t)&&!gt.includes(t)?t:"demo",r=await sd(j(hd(),"inkly-dev-"));await ld(j(r,"demos"),{recursive:!0}),await cd(e,j(r,"demos",n),{recursive:!0});let i=n;try{let o=JSON.parse(await me(j(e,"demo.config.json"),"utf8"));typeof o.title=="string"&&o.title.trim()&&(i=o.title.trim())}catch{}let a={$schema:"https://inklyai.dev/inkly.json",name:i,runtime:"0.6.1",theme:"inkly",collections:[{name:"Preview",demos:[n]}]};return await dd(j(r,"inkly.json"),`${JSON.stringify(a,null,2)}
|
|
4985
|
+
`),{hubRoot:r,slug:n}}async function va(e){let{cwd:t,port:n=3e3,silent:r,skipRuntimeResolve:i}=e,a=L=>{r||process.stderr.write(`[inkly dev] ${L}
|
|
4986
|
+
`)},o=e.path?Je(t,e.path):t,s=Sd(o),c=null;if(!s)if(xt(j(o,"demo.config.json"))){let L=await Nd(o);s=L.hubRoot,c=L.hubRoot,r||process.stdout.write(`[inkly dev] serving standalone demo "${L.slug}" via a temporary hub (no inkly.json required)
|
|
4987
|
+
`)}else throw new Error(`No inkly.json found in ${o} or any parent directory. Run \`inkly init <name>\` first, cd into your hub, or point \`inkly dev\` at an exported demo folder (a directory containing demo.config.json).`);let d=await Rn(s);if(!r){for(let L of d.healed)process.stdout.write(`[inkly dev] healed missing id: ${en(d.hubRoot,L.configPath)}
|
|
4988
|
+
`);for(let L of d.reminted)process.stdout.write(`[inkly dev] re-minted duplicate id: ${en(d.hubRoot,L.configPath)}
|
|
4989
|
+
`)}let u=await ya(s,a),p=j(s,"inkly.lock"),h=xt(p),f=null;if(h&&!i)try{if(f=await kr({hubRoot:s}),!r)if(f.fetched){let L=(f.bytesFetched/1048576).toFixed(2);process.stdout.write(`[inkly dev] fetched runtime ${f.version} from ${f.lock.runtime.url} (${L} MiB)
|
|
4990
|
+
`)}else process.stdout.write(`[inkly dev] runtime ${f.version} loaded from cache (${f.cacheDir})
|
|
4991
|
+
`)}catch(L){throw L instanceof bt||L instanceof Ot?L:new Error(`Failed to resolve runtime via inkly.lock: ${L.message}`)}else if(!i)try{let{lock:L,source:K}=await Pn(s);if(f=await kr({hubRoot:s,lock:L}),!r){let ge=f.fetched?`fetched ${(f.bytesFetched/1048576).toFixed(2)} MiB`:"from cache";process.stdout.write(`[inkly dev] no inkly.lock \u2014 resolved runtime ${f.version} from ${K==="cdn"?"the CDN":"a local build"} (${ge}). Run \`inkly lock\` to pin this version.
|
|
4992
|
+
`)}}catch(L){r||process.stdout.write(`[inkly dev] no inkly.lock and could not resolve a published runtime (${L.message}). Falling back to the in-workspace @inkly/runtime dist. Run \`inkly lock\` once a runtime is published to R2 to pin a version.
|
|
4993
|
+
`)}let w=f?.cacheDir??vd(s),x=fa(await me(ma("hub-index.html"),"utf8"),f),_=fa(await me(ma("demo.html"),"utf8"),f),I=await $d(n),$=I,R=async()=>{},b=await id({root:s,server:{port:I,strictPort:!0,host:Sr,hmr:{host:Sr},fs:{allow:[s,ka(new URL("../",import.meta.url))]}},appType:"custom",clearScreen:!1,logLevel:r?"silent":"info",configFile:!1,plugins:[{name:"inkly-dev-endpoints",configureServer(L){let K=(ge,A,le)=>{let N=(ge.url??"").split("?")[0]??"";if(N==="/"||N==="/index.html"){let E=$n(x,"__inkly_hub_data",Ad(u));H(A,200,"text/html; charset=utf-8",E);return}if(N.startsWith("/__inkly/cache/")){let E=decodeURIComponent(N.slice(15));if(!E||E.includes("..")||E.includes("/")){H(A,400,"text/plain; charset=utf-8","Invalid cache path");return}let F=j(s,".inkly","cache",E);nn(F).then(M=>{if(!M.isFile()){H(A,404,"text/plain; charset=utf-8",`Capture not found: ${E}`);return}rn(A,F,tn(F))},()=>H(A,404,"text/plain; charset=utf-8",`Capture not found: ${E}`));return}if(N.startsWith("/__inkly/snapshot/")){let E=decodeURIComponent(N.slice(18)),M=E.indexOf("/snapshots/"),J=M>0?E.slice(0,M):"",ee=M>0?E.slice(M+1):"";if(!an(J).ok||!u.bySlug.has(J)||!ee||ee.includes("..")||ee.startsWith("/")){H(A,400,"text/plain; charset=utf-8","Invalid snapshot path");return}if(!ee.startsWith("snapshots/")){H(A,400,"text/plain; charset=utf-8","Invalid snapshot path");return}let Te=j(s,"demos",...J.split("/")),be=j(Te,ee);if(!be.startsWith(Te+Dn)&&be!==Te){H(A,400,"text/plain; charset=utf-8","Invalid snapshot path");return}nn(be).then(async Jt=>{if(!Jt.isFile()){H(A,404,"text/plain; charset=utf-8",`Snapshot not found: ${ee}`);return}if(!/\.html?$/i.test(ee)){let Uo=await me(be,"utf8");H(A,200,tn(be),ft(Uo));return}let ae=hr(ee),Zt=ae?j(Te,ae):null,[Xn,qt]=await Promise.all([me(be,"utf8"),Zt?me(Zt,"utf8").catch(()=>null):Promise.resolve(null)]),hn=Yi({htmlPath:ee,html:Xn,css:qt,cssHref:ae?`/__inkly/snapshot/${encodeURIComponent(J)}/${ae.split("/").map(encodeURIComponent).join("/")}`:null});H(A,200,tn(be),hn)},()=>H(A,404,"text/plain; charset=utf-8",`Snapshot not found: ${ee}`));return}if(N==="/__inkly/hub"){H(A,200,"application/json; charset=utf-8",JSON.stringify(_r(u.hub)));return}if(N==="/__inkly/demos"){H(A,200,"application/json; charset=utf-8",JSON.stringify(u.index));return}if(N.startsWith("/__inkly/demo/")){let E=decodeURIComponent(N.slice(14)),F=an(E);if(!F.ok){H(A,400,"text/plain; charset=utf-8",F.reason);return}let M=u.bySlug.get(E);if(!M){H(A,404,"text/plain; charset=utf-8",`No such demo: ${E}`);return}let J=j(kt(M.configPath),"assets.json");me(J,"utf8").then(ee=>{let Vt=[];try{let Te=JSON.parse(ee);Array.isArray(Te.assets)&&(Vt=Te.assets)}catch{}H(A,200,"application/json; charset=utf-8",JSON.stringify({demo:M.config,assets:Vt}))},()=>{H(A,200,"application/json; charset=utf-8",JSON.stringify({demo:M.config,assets:[]}))});return}if(N==="/__inkly/runtime.js"){vr(A,w,"runtime.js","text/javascript; charset=utf-8");return}if(N==="/__inkly/runtime.css"){vr(A,w,"runtime.css","text/css; charset=utf-8");return}if(N==="/__inkly/manifest.json"){vr(A,w,"manifest.json","application/json; charset=utf-8");return}if(N.startsWith("/__inkly/vendor/")){let E=decodeURIComponent(N.slice(16));if(!/^(react|react-dom|react-dom-client|react-jsx-runtime)\.mjs$/.test(E)){H(A,404,"text/plain; charset=utf-8",`No such vendor module: ${E}`);return}let F=wd(E);if(!F){H(A,503,"text/plain; charset=utf-8",`Runtime vendor module not found: ${E}`);return}rn(A,F,"text/javascript; charset=utf-8");return}if(N.startsWith("/__inkly/theme/")&&N.endsWith(".css")){let E=decodeURIComponent(N.slice(15,-4)),F=pe[E];if(!F){let M=Object.keys(pe).join(", ");H(A,404,"text/plain; charset=utf-8",`No such theme: "${E}". Known themes: ${M}
|
|
4994
|
+
`);return}H(A,200,"text/css; charset=utf-8",F.css??"");return}let O=N.startsWith("/__inkly/")?null:xa(N,u);if(O&&O.rel){let{slug:E,rel:F}=O;if(F.includes("..")||F.startsWith("/")){H(A,400,"text/plain; charset=utf-8","Invalid path");return}let M=j(s,"demos",...E.split("/"),"public"),J=j(M,F);if(!J.startsWith(M+Dn)&&J!==M){H(A,400,"text/plain; charset=utf-8","Invalid path");return}nn(J).then(ee=>{if(!ee.isFile()){le();return}rn(A,J,tn(J))},()=>le());return}if(N.length>1&&!N.startsWith("/__inkly/")&&!N.endsWith("/")){let E=decodeURIComponent(N.slice(1)),F=j(s,"public"),M=j(F,E);if(!E.includes("..")&&(M.startsWith(F+Dn)||M===F)){nn(M).then(J=>{if(J.isFile()){rn(A,M,tn(M));return}vt()},()=>vt());return}}vt();function vt(){if(N.length>1&&!N.startsWith("/__inkly/")){let E=N.replace(/^\/+/,"").replace(/\/+$/,""),F=xa(N,u);if(F&&F.rel===""){let{slug:M,demo:J}=F;if(!an(M).ok){le();return}let Vt={hub:{name:u.hub.name,brand:_r(u.hub).brand??null,tokens:u.hub.tokens??null,theme:u.hub.theme??null,layout:u.hub.layout??null},demoSlug:M,demoTitle:J.config.title??J.config.id},Te=j(kt(J.configPath),"assets.json"),be=Jt=>{let ae=$n(_,"__inkly_hub_meta",Vt);ae=$n(ae,"__inkly_demo_config",J.config),ae=$n(ae,"__inkly_demo_assets",Jt),H(A,200,"text/html; charset=utf-8",ae)};me(Te,"utf8").then(Jt=>{let ae=[];try{let Zt=JSON.parse(Jt);Array.isArray(Zt.assets)&&(ae=Zt.assets.map(Xn=>{let qt=Xn,hn=wa(qt,M);return hn?{...qt,publicUrl:hn}:qt}))}catch{}be(ae)},()=>{be([])});return}if(E&&!E.includes("/")){if(!Re(E).ok){le();return}H(A,404,"text/plain; charset=utf-8",`No such demo: "${E}". Known demos: ${[...u.bySlug.keys()].join(", ")||"(none)"}
|
|
4995
|
+
`);return}}le()}};L.middlewares.use(K)}}]});await b.listen(),$=Dd(b,I);let z=`http://127.0.0.1:${$}/`,U=`http://localhost:${$}/`,D=ad.watch([j(s,"inkly.json"),j(s,"demos/**/demo.config.json"),j(s,"demos/**/assets.json")],{ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:60,pollInterval:20}}),V=!1,ne=async()=>{if(!V){V=!0;try{u=await ya(s,a);try{b.ws.send({type:"custom",event:"inkly:hub-changed"}),b.ws.send({type:"full-reload"})}catch{}}catch(L){a(`Reload failed: ${L.message}`)}finally{V=!1}}};if(R=ne,D.on("add",ne),D.on("change",ne),D.on("unlink",ne),!r){let L=u.hub.collections?.length??0,K=[...u.bySlug.keys()],ge=10,A=K.length>0?`
|
|
4987
4996
|
demos:
|
|
4988
|
-
`+
|
|
4989
|
-
`)+(
|
|
4990
|
-
\u2026and ${
|
|
4991
|
-
inkly dev running at ${
|
|
4997
|
+
`+K.slice(0,ge).map(le=>` ${U}${le}`).join(`
|
|
4998
|
+
`)+(K.length>ge?`
|
|
4999
|
+
\u2026and ${K.length-ge} more`:""):"";process.stdout.write(`
|
|
5000
|
+
inkly dev running at ${U}
|
|
4992
5001
|
hub: ${u.hub.name}
|
|
4993
|
-
demos: ${u.demos.length} in ${
|
|
5002
|
+
demos: ${u.demos.length} in ${L} collection(s)${A}
|
|
4994
5003
|
watching ${s}
|
|
4995
5004
|
|
|
4996
|
-
`)}let
|
|
4997
|
-
`),
|
|
4998
|
-
`),!
|
|
4999
|
-
`;
|
|
5000
|
-
`,
|
|
5001
|
-
`),
|
|
5002
|
-
`,process.stdout.write(
|
|
5003
|
-
`);else if(
|
|
5004
|
-
`);else{for(let o of
|
|
5005
|
-
`);process.stdout.write(`inkly validate failed (${r} errors, ${
|
|
5006
|
-
`)}return
|
|
5007
|
-
`)}return
|
|
5008
|
-
`);return}await new Promise((r,
|
|
5009
|
-
`,{mode:384})}async function
|
|
5010
|
-
`);else{for(let d of
|
|
5005
|
+
`)}let Ce=!1;return{url:z,port:$,server:b,hubRoot:s,close:async()=>{Ce||(Ce=!0,await D.close(),await b.close(),c&&await ud(c,{recursive:!0,force:!0}).catch(()=>{}))}}}function vr(e,t,n,r){if(!t){H(e,503,"text/plain; charset=utf-8",ga);return}let i=j(t,n);nn(i).then(()=>rn(e,i,r),()=>H(e,503,"text/plain; charset=utf-8",`${ga}(missing: ${n})`))}import{mkdir as Md,access as _a,readFile as Ld}from"fs/promises";import{dirname as Od,join as Nn,resolve as jd}from"path";function Cr(e){return e.split("-").filter(t=>t.length>0).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Sa(e,t){return{id:oe(),version:1,title:t??Cr(e),theme:{background:"#ffffff",foreground:"#0a0a0a",primary:"#5b6cff",primaryForeground:"#ffffff",secondary:"#f4f4f5",secondaryForeground:"#18181b",radius:"12px",font:"Inter, system-ui, sans-serif",fontSize:"14px"},chrome:{showHubBreadcrumb:!0},chapters:[{id:"create",title:"Create",stepIds:["s1"]},{id:"preview",title:"Preview",stepIds:["s2"]},{id:"ship",title:"Ship",stepIds:["s3"]}],steps:[{id:"intro",kind:"cover",widgets:[{type:"headline",id:"intro-headline",title:"Your demo in *60 seconds*.",description:"See how to spin up a sharable demo from a single prompt.",image:{src:"https://placehold.co/2800x1600/f8fafc/111827/png?text=Workspace&font=inter",alt:"Workspace preview",naturalWidth:2800,naturalHeight:1600,position:"right",layout:"hero"},cta:{label:"Get started",animation:"shimmer",action:{type:"next"}}}]},{id:"s1",kind:"content",background:{type:"image",src:"https://placehold.co/2800x1600/f8fafc/111827/png?text=Workspace&font=inter",naturalWidth:2800,naturalHeight:1600,alt:"Workspace overview"},annotations:[{id:"s1_pointer",type:"message",variant:"pointer",x:.28,y:.34,text:"Just **describe** the flow you want \u2014 the demo scaffolds the walkthrough in seconds.",anchor:"right",advancesStep:!0}]},{id:"s2",kind:"content",background:{type:"image",src:"https://placehold.co/2800x1600/ecfeff/111827/png?text=Live+Preview&font=inter",naturalWidth:2800,naturalHeight:1600,alt:"Live preview with editable files"},transform:{zoom:1.25,x:.62,y:.42},captions:[{id:"s2_caption",text:"See your changes come to life with our live preview."}],annotations:[{id:"s2_callout",type:"message",variant:"callout",x:.5,y:.5,text:"**Live preview that follows you.** Every edit lands in the preview *instantly* \u2014 tweak copy, swap assets, reorder steps, and watch the demo update **without a rebuild**.",advancesStep:!0}]},{id:"s3",kind:"content",background:{type:"image",src:"https://placehold.co/2800x1600/f0fdf4/111827/png?text=Export+and+Share&font=inter",naturalWidth:2800,naturalHeight:1600,alt:"Export and share demo"},captions:[{id:"s3_caption",text:"When you are ready, export your demo and share it with anyone."}],annotations:[{id:"s3_area",type:"message",variant:"area",x:.55,y:.45,w:.32,h:.22,text:"**Ready to share.** Export your demo as a **single sharable link** that runs anywhere \u2014 drop it in an email, embed it on your landing page, or paste it in Slack. Works in *any* browser, no install needed.",anchor:"top",advancesStep:!0}]}]}}async function zd(e){let t=jd(e);for(;;){let n=Nn(t,"inkly.json");if(await _a(n).then(()=>!0,()=>!1))return t;let i=Od(t);if(i===t)return null;t=i}}async function Ca(e){let{slug:t,cwd:n,collection:r,silent:i}=e,a=await zd(n);if(!a)throw new Error("Not inside a hub. Run `inkly init <name>` first.");let o=Re(t);if(!o.ok)throw new Error(o.reason);let s=Nn(a,"inkly.json"),c=await Ld(s,"utf8"),d;try{d=JSON.parse(c)}catch(b){throw new Error(`Failed to parse inkly.json: ${b.message}`)}let u=we.safeParse(d);if(!u.success)throw new Error(`Invalid inkly.json: ${u.error.issues.map(b=>`${b.path.join(".")||"<root>"}: ${b.message}`).join("; ")}`);let p=u.data,h=Nn(a,"demos",t);if(await _a(h).then(()=>!0,()=>!1))throw new Error(`Demo already exists: demos/${t}. Choose a different slug or remove it first.`);let w,x=p,_=p.collections??[];if(r){let b={...p,collections:_.map(U=>({...U,demos:[...U.demos]}))},z=b.collections.find(U=>U.name===r);z?z.demos.push(t):b.collections.push({name:r,demos:[t]}),x=b,w=r}if(w){let b=we.safeParse(x);if(!b.success)throw new Error(`Internal error: updated inkly.json failed schema validation. ${b.error.message}`)}let I=oe(),$={...Sa(t,Cr(t)),id:I},R=mt.safeParse($);if(!R.success)throw new Error(`Internal error: scaffolded demo failed schema validation. ${R.error.message}`);if(await Md(h,{recursive:!0}),await te(Nn(h,"demo.config.json"),JSON.stringify($,null,2)+`
|
|
5006
|
+
`),w&&await te(s,JSON.stringify(x,null,2)+`
|
|
5007
|
+
`),!i){let b=`Added ${h}
|
|
5008
|
+
`;b+=` id: ${I}
|
|
5009
|
+
`,w&&(b+=`Added to collection "${w}" in inkly.json
|
|
5010
|
+
`),b+=`Next: inkly dev
|
|
5011
|
+
`,process.stdout.write(b)}return{hubRoot:a,demoDir:h,collectionModified:w,id:I}}import{readdir as Ud}from"fs/promises";import{join as Fd}from"path";function Ne(e,t,n,r){e.push({level:t,file:n,message:r})}function Tr(e,t){if(typeof e=="string"){e.startsWith("asset:")&&t.add(e.slice(6));return}if(!(!e||typeof e!="object")){if(Array.isArray(e)){for(let n of e)Tr(n,t);return}for(let n of Object.values(e))Tr(n,t)}}async function Mn(e){let t=[],n=null;try{let o=await Mt(e.cwd);n=o.root,o.inkly.theme&&!pe[o.inkly.theme]&&Ne(t,"error","inkly.json",`Unknown theme "${o.inkly.theme}". Known themes: ${Object.keys(pe).join(", ")}.`);let s=new Set(o.demos.map(d=>d.slug)),c=new Map;for(let d of o.demos){let u=fr(d.slug);u&&Ne(t,"error",`demos/${d.slug}`,u);let p=c.get(d.config.id);p?p.push(d.slug):c.set(d.config.id,[d.slug]),d.config.theme?.preset&&!pe[d.config.theme.preset]&&Ne(t,"error",`demos/${d.slug}/demo.config.json`,`Unknown demo theme preset "${d.config.theme.preset}".`);let h=new Set;Tr(d.config,h);let f=new Set((d.assets?.assets??[]).map(w=>w.id));for(let w of h)f.has(w)||Ne(t,"error",`demos/${d.slug}/demo.config.json`,`References asset:${w}, but demos/${d.slug}/assets.json has no matching asset id.`);for(let w of d.assets?.assets??[])(await Hd(o.root,w.sha256)).length===0&&!Bd(w)&&Ne(t,"warning",`demos/${d.slug}/assets.json`,`Asset "${w.id}" has no local cache file and no CDN URL.`)}for(let[d,u]of c)if(!(u.length<2))for(let p of u)Ne(t,"warning",`demos/${p}/demo.config.json`,`Duplicate demo id "${d}" shared with ${u.filter(h=>h!==p).map(h=>`demos/${h}`).join(", ")}. Run \`inkly doctor\` to re-mint.`);for(let d of o.inkly.collections??[])for(let u of d.demos){let p=fr(u);if(p){Ne(t,"error","inkly.json",`Collection "${d.name}" references invalid slug "${u}": ${p}`);continue}s.has(u)||Ne(t,"warning","inkly.json",`Collection "${d.name}" references missing demo "${u}".`)}}catch(o){Ne(t,"error","hub",o.message)}let r=t.filter(o=>o.level==="error").length,i=t.filter(o=>o.level==="warning").length,a={ok:r===0&&(!e.strict||i===0),hubRoot:n,errors:r,warnings:i,issues:t};if(!e.silent)if(e.json)process.stdout.write(JSON.stringify(a,null,2)+`
|
|
5012
|
+
`);else if(a.ok)process.stdout.write(`inkly validate passed (${r} errors, ${i} warnings)
|
|
5013
|
+
`);else{for(let o of t)process.stdout.write(`${o.level.toUpperCase()} ${o.file}: ${o.message}
|
|
5014
|
+
`);process.stdout.write(`inkly validate failed (${r} errors, ${i} warnings)
|
|
5015
|
+
`)}return a}async function Hd(e,t){let n=Fd(e,".inkly","cache");if(!await Z(n))return[];try{return(await Ud(n)).filter(i=>i.startsWith(`${t}.`))}catch{return[]}}function Bd(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.publicUrl=="string"||typeof t.cdnPath=="string"}import{readFile as Wd}from"fs/promises";import{existsSync as Vd}from"fs";import{dirname as Ar,join as Ta}from"path";import{fileURLToPath as Jd}from"url";async function Pr(){let e=Ar(Jd(import.meta.url));for(let t=0;t<5;t+=1){let n=Ta(e,"package.json");try{let i=JSON.parse(await Wd(n,"utf8"));if(typeof i.version=="string"){let a=Vd(Ta(Ar(n),"src"));return{version:i.version,packagePath:n,isLocalBuild:a}}}catch{}let r=Ar(e);if(r===e)break;e=r}return{version:"0.0.0-unknown",packagePath:null,isLocalBuild:!1}}async function Ir(e={}){let t=await Pr();if(!e.silent){let n=t.isLocalBuild?" (local build)":"";process.stdout.write(`${t.version}${n}
|
|
5016
|
+
`)}return t}import{spawn as Zd}from"child_process";async function Aa(e={}){let t=e.packageName??"@inkly-org/cli@latest",n=process.env.npm_execpath?[process.execPath,process.env.npm_execpath,"install","-g",t]:["npm","install","-g",t];if(e.dryRun){e.silent||process.stdout.write(`${n.join(" ")}
|
|
5017
|
+
`);return}await new Promise((r,i)=>{let a=Zd(n[0],n.slice(1),{stdio:"inherit"});a.on("error",i),a.on("exit",o=>{o===0?r():i(new Error(`Update failed with exit code ${o??"unknown"}`))})})}import{join as Ea}from"path";import{readFile as qd,rm as Gd}from"fs/promises";import{join as Kd}from"path";import{homedir as Yd}from"os";var Er="https://app.inklyai.dev",Pa="http://localhost:3000",Me=Kd(Yd(),".inkly","config.json");async function Ze(){try{let e=await qd(Me,"utf8"),t=JSON.parse(e);return{apiBase:typeof t.apiBase=="string"?t.apiBase:void 0,token:typeof t.token=="string"?t.token:void 0}}catch{return{}}}async function Rr(e){await te(Me,JSON.stringify(e,null,2)+`
|
|
5018
|
+
`,{mode:384})}async function Ia(){await Gd(Me,{force:!0})}function qe(e){return(e||Er).replace(/\/+$/,"")}async function Ra(e){let t=[],n=await Pr();t.push({name:"cli-version",ok:n.version!=="0.0.0-unknown",message:n.version});let r=Number.parseInt(process.versions.node.split(".")[0]??"0",10);t.push({name:"node",ok:r>=20,message:process.version});let i=await De(e.cwd);t.push({name:"hub-root",ok:!!i,message:i??"No inkly.json found."});let a=await Ze();t.push({name:"login",ok:!!a.token,message:a.token?`Configured for ${a.apiBase??"(default API)"}`:"Not logged in."});let o=[],s=null;if(i){let d=await Rn(i);s={healed:d.healed.length,reminted:d.reminted.length,paths:[...d.healed,...d.reminted].map(f=>en(d.hubRoot,f.configPath))},t.push({name:"demo-ids",ok:!0,message:s.healed===0&&s.reminted===0?"all demos have a valid unique id":`healed ${s.healed}, re-minted ${s.reminted}`});let u=await Mn({cwd:i,silent:!0});o=u.issues,t.push({name:"schema",ok:u.ok,message:`${u.errors} errors, ${u.warnings} warnings`});let p=await Z(Ea(i,".inkly","cache"));t.push({name:"local-cache",ok:!0,message:p?".inkly/cache exists":".inkly/cache not present yet"});let h=await An(Ea(i,"node_modules","@inkly","runtime","dist","runtime.js"));h!==null&&t.push({name:"runtime-artifact",ok:!0,message:`${h} bytes`})}let c={ok:t.every(d=>d.ok||d.name==="login"),checks:t,validationIssues:o,demoIds:s};if(!e.silent)if(e.json)process.stdout.write(JSON.stringify(c,null,2)+`
|
|
5019
|
+
`);else{for(let d of t)process.stdout.write(`${d.ok?"OK":"WARN"} ${d.name}: ${d.message}
|
|
5011
5020
|
`);if(s&&s.paths.length>0)for(let d of s.paths)process.stdout.write(` fixed id in ${d}
|
|
5012
5021
|
`);if(o.length>0)for(let d of o)process.stdout.write(`${d.level.toUpperCase()} ${d.file}: ${d.message}
|
|
5013
|
-
`)}return c}import{randomBytes as
|
|
5014
|
-
`,{encoding:"utf8",mode:384})}async function
|
|
5015
|
-
`),{apiBase:
|
|
5016
|
-
`),{apiBase:r.apiBase,configPath:
|
|
5017
|
-
`)}async function
|
|
5018
|
-
`):(process.stdout.write(`Config: ${
|
|
5022
|
+
`)}return c}import{randomBytes as uu}from"crypto";import{createServer as pu}from"http";import{spawn as hu}from"child_process";import{randomUUID as Xd}from"crypto";import{mkdir as Qd,readFile as eu,writeFile as tu}from"fs/promises";import{dirname as nu,join as ru}from"path";import{homedir as iu}from"os";import{PostHog as au}from"posthog-node";var $a=process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN??process.env.POSTHOG_PROJECT_TOKEN??"phc_Dmh4w8YFNosi3YHD4Sv7ShHX7ccS8kmtRcm8XSVmB5jT",ou=process.env.NEXT_PUBLIC_POSTHOG_HOST??process.env.POSTHOG_HOST??"https://us.i.posthog.com",su="@inkly-org/cli@0.5.1",$r=ru(iu(),".inkly","analytics.json"),On=null,Ln=null,Ut=null;function lu(){return!!$a&&process.env.INKLY_TELEMETRY_DISABLED!=="1"}function Da(){return lu()?(On??=new au($a,{host:ou,flushAt:1,flushInterval:0}),On):null}async function Dr(){try{let e=await eu($r,"utf8");return JSON.parse(e)}catch{return{}}}async function Nr(e){await Qd(nu($r),{recursive:!0}),await tu($r,JSON.stringify(e,null,2)+`
|
|
5023
|
+
`,{encoding:"utf8",mode:384})}async function Na(){return Ln||(Ln=(async()=>{let e=await Dr();if(typeof e.platformUserId=="string"&&e.platformUserId&&(Ut=e.platformUserId),typeof e.distinctId=="string"&&e.distinctId)return e.distinctId;let t=`cli_${Xd()}`;return await Nr({...e,distinctId:t}),t})(),Ln)}async function cu(){let e=await Na();return Ut??e}async function Mr(e){if(!e||Ut===e){e&&(Ut=e);return}let t=Da();try{let n=await Na(),r=await Dr(),i=r.platformUserId!==e;Ut=e,i&&(await Nr({...r,platformUserId:e}),t?.alias({distinctId:e,alias:n}))}catch{}}async function Ma(){Ut=null;try{let e=await Dr();if(e.platformUserId){let{platformUserId:t,...n}=e;await Nr(n)}}catch{}}function du(){return{surface:"cli",release:process.env.POSTHOG_RELEASE??su,node_version:process.versions.node,platform:process.platform,arch:process.arch,ci:!!process.env.CI}}async function B(e,t={}){let n=Da();if(n)try{n.capture({distinctId:await cu(),event:e,properties:{...du(),...t}})}catch{}}async function Lr(){if(On)try{await On.shutdown(2e3)}catch{}}async function Oa(e){let t=qe(e.local?Pa:Er),n=e.token??process.env.INKLY_API_TOKEN;if(n){let a=await jr(t,n).catch(()=>({valid:!1,userId:null}));return await Rr({apiBase:t,token:n}),await La("token",a),e.silent||process.stdout.write(`Logged in to ${t}${a.valid?"":" (token saved without online verification)"}
|
|
5024
|
+
`),{apiBase:t,configPath:Me,verified:a.valid,method:"token"}}let r=await mu({apiBase:t,shouldOpen:e.open!==!1,silent:e.silent});await Rr({apiBase:r.apiBase,token:r.apiToken});let i=await jr(r.apiBase,r.apiToken).catch(()=>({valid:!1,userId:null}));return await La("browser",i),e.silent||process.stdout.write(`Logged in to ${r.apiBase}
|
|
5025
|
+
`),{apiBase:r.apiBase,configPath:Me,verified:i.valid,method:"browser"}}async function La(e,t){t.valid&&t.userId&&await Mr(t.userId),await B("inkly_cli_logged_in",{method:e,verified:t.valid})}async function ja(e={}){await B("inkly_cli_logged_out",{}),await Ma(),await Ia(),e.silent||process.stdout.write(`Removed ${Me}
|
|
5026
|
+
`)}async function za(e){let t=await Ze(),n=t.apiBase?qe(t.apiBase):null,r=await De(e.cwd),i="skipped",a;if(n&&t.token)try{let s=await jr(n,t.token);i=s.valid?"ok":"failed",i==="failed"&&(a="Token was rejected by the platform."),s.valid&&s.userId&&await Mr(s.userId)}catch(s){i="failed",a=s.message}let o={configPath:Me,apiBase:n,loggedIn:!!t.token,hubRoot:r,online:i,message:a};return e.silent||(e.json?process.stdout.write(JSON.stringify(o,null,2)+`
|
|
5027
|
+
`):(process.stdout.write(`Config: ${Me}
|
|
5019
5028
|
`),process.stdout.write(`Hub: ${r??"(not inside a hub)"}
|
|
5020
5029
|
`),process.stdout.write(`API: ${n??"(not configured)"}
|
|
5021
5030
|
`),process.stdout.write(`Login: ${o.loggedIn?"configured":"not configured"}
|
|
5022
|
-
`),process.stdout.write(`Online: ${
|
|
5023
|
-
`))),o}async function
|
|
5024
|
-
${
|
|
5025
|
-
`),
|
|
5026
|
-
`),await
|
|
5027
|
-
`);return}if(
|
|
5028
|
-
`),
|
|
5029
|
-
`),
|
|
5030
|
-
`);for(let
|
|
5031
|
-
`)}}import{readdir as
|
|
5032
|
-
`+
|
|
5033
|
-
`));let o=[];
|
|
5034
|
-
`),o=(await
|
|
5035
|
-
`):
|
|
5031
|
+
`),process.stdout.write(`Online: ${i}${a?` (${a})`:""}
|
|
5032
|
+
`))),o}async function jr(e,t){let n=await fetch(`${e}/api/captures/verify`,{method:"GET",headers:{authorization:`Bearer ${t}`}});if(!n.ok)return{valid:!1,userId:null};let r=null;try{let i=await n.json();typeof i.userId=="string"&&i.userId&&(r=i.userId)}catch{}return{valid:!0,userId:r}}async function mu(e){let t=uu(16).toString("hex"),n=pu(),r=await fu(n),i=new URL("/cli/login",e.apiBase);i.searchParams.set("callback",r.url),i.searchParams.set("state",t);let a=gu({server:n,state:t,apiBase:e.apiBase,timeoutMs:120*1e3});return e.silent||process.stdout.write(`Opening browser for Inkly login:
|
|
5033
|
+
${i.toString()}
|
|
5034
|
+
`),e.shouldOpen&&yu(i.toString()),a}async function fu(e){await new Promise((n,r)=>{e.once("error",r),e.listen(0,"127.0.0.1",()=>n())});let t=e.address();if(!t||typeof t=="string")throw new Error("Could not start local login callback server.");return{url:`http://127.0.0.1:${t.port}/callback`}}async function gu(e){return new Promise((t,n)=>{let r=setTimeout(()=>{Or(e.server),n(new Error("Timed out waiting for browser login."))},e.timeoutMs);e.server.on("request",(i,a)=>{(async()=>{try{let o=new URL(i.url??"/","http://127.0.0.1");if(o.pathname!=="/callback"){jn(a,404,"Not found.");return}let s=o.searchParams.get("state"),c=o.searchParams.get("pairingToken");if(!c||s!==e.state){jn(a,400,"Invalid Inkly CLI login callback. You can close this tab.");return}let d=await bu(e.apiBase,c);clearTimeout(r),jn(a,200,"Inkly CLI is connected. You can close this tab."),Or(e.server),t(d)}catch(o){clearTimeout(r),jn(a,500,`Inkly CLI login failed: ${o.message}`),Or(e.server),n(o)}})()})})}async function bu(e,t){let n=await fetch(`${e}/api/cli/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pairingToken:t})}),r=await n.json().catch(()=>null);if(!n.ok||!r?.apiToken)throw new Error(r?.error??`Login exchange failed: HTTP ${n.status}`);return{apiToken:r.apiToken,apiBase:qe(r.apiBase??e)}}function yu(e){let t=process.platform,i=hu(t==="darwin"?"open":t==="win32"?"cmd":"xdg-open",t==="win32"?["/c","start","",e]:[e],{stdio:"ignore",detached:!0});i.on("error",()=>{}),i.unref()}function jn(e,t,n){e.statusCode=t,e.setHeader("content-type","text/html; charset=utf-8"),e.end(`<!doctype html><meta charset="utf-8"><title>Inkly CLI</title><body style="font-family: system-ui, sans-serif; padding: 32px;">${xu(n)}</body>`)}function Or(e){try{e.close()}catch{}}function xu(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}import{readFile as Ha,readdir as Ba,writeFile as ku}from"fs/promises";import{join as on,extname as Wa}from"path";async function Un(e){let t=await Ze(),n=await Mt(e.cwd),r=e.demo?n.demos.filter(p=>p.slug===e.demo):n.demos;if(e.demo&&r.length===0)throw new Error(`No such demo: ${e.demo}`);let i=[],a=[];for(let p of r)for(let h of p.assets?.assets??[]){let f=await Su(n.root,h.sha256),w=_u(h);if(!f&&!w){a.push({demo:p.slug,id:h.id,sha256:h.sha256});continue}if(!f||w)continue;let x=await An(on(n.root,".inkly","cache",f));i.push({demo:p.slug,id:h.id,sha256:h.sha256,cacheFile:f,contentType:h.contentType??zn(f,h.kind),size:h.size??x??0,alreadyRemote:w})}let o={hubRoot:n.root,dryRun:!!e.dryRun,assets:i,unresolved:a,uploaded:0,updatedManifests:[]};if(e.dryRun||i.length===0)return e.silent||Ua(o,e.json),o;if(!t.token)throw new Error("Not logged in. Run `inkly login --token <token>` first.");let s=qe(t.apiBase??process.env.INKLY_API_BASE),c=await zr({apiBase:s,token:t.token,hubRoot:n.root,assets:i}),d=c.uploads,u=new Map(d.map(p=>[p.sha256,p]));for(let p of r){if(!p.assets)continue;let h=!1,f=p.assets.assets.map(x=>{let _=u.get(x.sha256);return _?(h=!0,{...x,contentType:x.contentType??zn(`${x.sha256}${_.ext}`,x.kind),publicUrl:_.publicUrl,cdnPath:_.cdnPath}):x});if(!h)continue;let w={...p.assets,assets:f};await te(p.assetsPath,JSON.stringify(w,null,2)+`
|
|
5035
|
+
`),await Cu(p.dir,d),o.updatedManifests.push(`demos/${p.slug}/assets.json`)}return o.uploaded=c.uploaded,e.silent||Ua(o,e.json),o}async function zr(e){let t=await vu(e.apiBase,e.token,e.assets),n=new Map(t.uploads.map(a=>[a.sha256,a])),r=0;for(let a of e.assets){let o=n.get(a.sha256);if(!o)throw new Error(`Platform did not return upload metadata for ${a.sha256}.`);if(o.uploadUrl){let s=await Ha(on(e.hubRoot,".inkly","cache",a.cacheFile)),c=await fetch(o.uploadUrl,{method:"PUT",headers:o.uploadHeaders??{"content-type":a.contentType},body:s});if(!c.ok)throw new Error(`Asset upload failed for ${a.id}: HTTP ${c.status}`);r+=1}}return{uploads:(await wu(e.apiBase,e.token,e.assets,t.uploads)).uploads,uploaded:r}}async function wu(e,t,n,r){let i=new Map(r.map(s=>[s.sha256,s])),a=await fetch(`${e}/api/cli/sync-assets/complete`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t}`},body:JSON.stringify({assets:n.map(s=>{let c=i.get(s.sha256);if(!c)throw new Error(`Platform did not return upload metadata for ${s.sha256}.`);return{sha256:s.sha256,ext:c.ext,contentType:s.contentType,size:s.size,cdnPath:c.cdnPath}})})}),o=await a.json().catch(()=>null);if(!a.ok||!o||!Array.isArray(o.uploads))throw new Error(o?.error??`Sync completion failed: HTTP ${a.status}`);return{uploads:o.uploads}}async function vu(e,t,n){let r=await fetch(`${e}/api/cli/sync-assets`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t}`},body:JSON.stringify({assets:n.map(a=>({sha256:a.sha256,ext:Wa(a.cacheFile)||Ur(a.contentType),contentType:a.contentType,size:a.size}))})}),i=await r.json().catch(()=>null);if(!r.ok||!i||!Array.isArray(i.uploads))throw new Error(i?.error??`Sync endpoint failed: HTTP ${r.status}`);return{uploads:i.uploads}}async function Su(e,t){let n=on(e,".inkly","cache");return await Z(n)?(await Ba(n)).find(i=>i.startsWith(`${t}.`))??null:null}function _u(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.publicUrl=="string"&&typeof t.cdnPath=="string"}function zn(e,t){let n=Wa(e).toLowerCase();return n===".png"?"image/png":n===".jpg"||n===".jpeg"?"image/jpeg":n===".webp"?"image/webp":n===".gif"?"image/gif":n===".svg"?"image/svg+xml":n===".webm"?"video/webm":n===".mp4"?"video/mp4":n===".mp3"?"audio/mpeg":n===".wav"?"audio/wav":t==="font"?"font/woff2":"application/octet-stream"}function Ur(e){let t=e.toLowerCase().split(";")[0]?.trim();return t==="image/png"?".png":t==="image/jpeg"?".jpg":t==="image/webp"?".webp":t==="image/gif"?".gif":t==="image/svg+xml"?".svg":t==="video/webm"?".webm":t==="video/mp4"?".mp4":t==="audio/mpeg"?".mp3":t==="audio/wav"?".wav":t==="font/woff2"?".woff2":".bin"}async function Cu(e,t){let n=on(e,"snapshots");if(!await Z(n))return;let r=t.map(i=>({local:`/__inkly/cache/${`${i.sha256}${i.ext}`}`,remote:i.publicUrl}));await Va(n,r)}async function Va(e,t){for(let n of await Ba(e,{withFileTypes:!0})){let r=on(e,n.name);if(n.isDirectory())await Va(r,t);else if(n.isFile()&&/\.(html|css)$/i.test(n.name)){let i=await Ha(r,"utf8"),a=i;for(let o of t)i=i.split(o.local).join(o.remote);i!==a&&await ku(r,i,"utf8")}}}function Ua(e,t){if(t){process.stdout.write(JSON.stringify(e,null,2)+`
|
|
5036
|
+
`);return}if(e.dryRun){process.stdout.write(`inkly sync dry run: ${e.assets.length} asset(s) need upload
|
|
5037
|
+
`),Fa(e);return}process.stdout.write(`inkly sync complete: ${e.uploaded} uploaded, ${e.updatedManifests.length} manifest(s) updated
|
|
5038
|
+
`),Fa(e)}function Fa(e){if(e.unresolved.length!==0){process.stderr.write(`inkly sync warning: ${e.unresolved.length} asset(s) have no local cache file and are not on the CDN:
|
|
5039
|
+
`);for(let t of e.unresolved)process.stderr.write(` - demos/${t.demo} "${t.id}" (${t.sha256})
|
|
5040
|
+
`)}}import{readdir as Tu,readFile as Au}from"fs/promises";import{extname as Hr,join as Ja,resolve as Za}from"path";function Fr(e,t){e||process.stdout.write(t)}function Pu(e,t){if(t.demo){let n=e.demos.find(r=>r.slug===t.demo);if(!n)throw new Error(`No such demo: ${t.demo}`);return n}if(t.path){let n=Za(t.cwd,t.path),r=e.demos.find(a=>Za(a.dir)===n);if(r)return r;let i=e.demos.find(a=>a.slug===t.path||a.slug===t.path?.replace(/^demos\//,""));if(i)return i;throw new Error(`No demo found at "${t.path}". Available demos: ${e.demos.map(a=>a.slug).join(", ")||"(none)"}`)}if(e.demos.length===1)return e.demos[0];throw new Error(`This hub has ${e.demos.length} demos \u2014 pass a demo path or --demo <slug>. Available: ${e.demos.map(n=>n.slug).join(", ")}`)}async function Iu(e,t=[]){let n=Ja(e,"snapshots");if(!await Z(n))return{};let r={};async function i(a){for(let o of await Tu(a,{withFileTypes:!0})){let s=Ja(a,o.name);if(o.isDirectory())await i(s);else if(o.isFile()&&/\.(html|css)$/i.test(o.name)){let c=s.slice(e.length+1).split(/[\\/]/).join("/");r[c]=Eu(await Au(s,"utf8"),t)}}}return await i(n),r}function Eu(e,t){let n=e;for(let r of t)n=n.split(r.local).join(r.remote);return n}function qa(e){if(!e)return null;try{let t=new URL(e);return Hr(t.pathname)||null}catch{return Hr(e)||null}}function Ru(e,t,n){let r=new Map,i=(o,s)=>{if(!s)return;let c=s.startsWith(".")?s:`.${s}`;r.has(o)||r.set(o,new Set),r.get(o).add(c)};for(let o of t)i(o.sha256,Hr(o.cacheFile));for(let o of n)i(o.sha256,o.ext);for(let o of e.assets)i(o.sha256,qa(o.cdnPath)),i(o.sha256,qa(o.publicUrl)),o.contentType&&i(o.sha256,Ur(o.contentType));let a=[];for(let o of e.assets)if(o.publicUrl)for(let s of r.get(o.sha256)??[])a.push({local:`/__inkly/cache/${o.sha256}${s}`,remote:o.publicUrl});return a}function $u(e,t,n){let r=e??{version:1,assets:[]},i=new Map(n.map(o=>[o.sha256,o])),a=new Map(t.map(o=>[o.sha256,o]));return{...r,assets:r.assets.map(o=>{let s=i.get(o.sha256);if(!s)return o;let c=a.get(o.sha256);return{...o,contentType:o.contentType??c?.contentType??zn(`${o.sha256}${s.ext}`,o.kind),publicUrl:s.publicUrl,cdnPath:s.cdnPath}})}}async function Ga(e){let t=await Ze();if(!t.token)throw new Error("Not logged in. Run `inkly login` first.");let n=qe(t.apiBase??process.env.INKLY_API_BASE),r=await Mt(e.cwd),i=Pu(r,e),a=await Un({cwd:r.root,demo:i.slug,dryRun:!0,silent:!0});if(a.unresolved.length>0)throw new Error(`${a.unresolved.length} asset(s) have no local bytes and are not on the CDN, so a hosted preview cannot be published:
|
|
5041
|
+
`+a.unresolved.map(f=>` - ${f.id} (${f.sha256})`).join(`
|
|
5042
|
+
`));let o=[];a.assets.length>0&&(Fr(e.silent,`Uploading ${a.assets.length} asset(s) to the CDN for this snapshot...
|
|
5043
|
+
`),o=(await zr({apiBase:n,token:t.token,hubRoot:r.root,assets:a.assets})).uploads);let s=$u(i.assets,a.assets,o),c=await Iu(i.dir,Ru(s,a.assets,o)),d=await fetch(`${n}/api/previews`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t.token}`},body:JSON.stringify({demoSlug:i.slug,title:i.config.title??null,config:i.config,assets:s,hub:r.inkly,snapshots:c})}),u=await d.json().catch(()=>null);if(!d.ok||!u?.id)throw new Error(u?.error??`Snapshot publish failed: HTTP ${d.status}`);let p=u.url??`${n}${u.path??`/p/${u.id}`}`,h={hubRoot:r.root,slug:i.slug,id:u.id,url:p};return e.json?Fr(e.silent,JSON.stringify(h,null,2)+`
|
|
5044
|
+
`):Fr(e.silent,`Snapshot published:
|
|
5036
5045
|
${p}
|
|
5037
|
-
`),h}import{readFile as
|
|
5038
|
-
|
|
5039
|
-
`)
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
`);
|
|
5043
|
-
`)
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
`)}function Uu(t){let e="",n=0,r="",a=!1,i=0,o=!0,s=()=>{o&&(e+=" ".repeat(n),o=!1)},c=()=>{e=e.replace(/[ \t]+$/,""),e+=`
|
|
5047
|
-
`,o=!0};for(let d of t){if(r){s(),e+=d,a?a=!1:d==="\\"?a=!0:d===r&&(r="");continue}if(a){s(),e+=d,a=!1;continue}if(d==="\\"){s(),e+=d,a=!0;continue}if(d==='"'||d==="'"){s(),r=d,e+=d;continue}if(d==="("&&(i+=1),d===")"&&(i=Math.max(0,i-1)),d==="{"){s(),e=e.replace(/[ \t]+$/,""),e+=` {
|
|
5048
|
-
`,n+=1,o=!0;continue}if(d==="}"){n=Math.max(0,n-1),c(),s(),e+="}",c();continue}if(d===";"&&i===0){s(),e+=";",c();continue}if(d===","&&i===0){s(),e+=",",c();continue}s(),e+=d}return`${e.trim()}
|
|
5049
|
-
`}function Hi(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function $r(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Bi(t){return t==="id"?0:t==="data-inkly-id"?1:t==="class"?2:t==="href"?3:t==="src"?4:t==="srcset"?5:t==="alt"?6:t==="aria-label"?7:t==="role"?8:t==="type"?9:t==="style"?10:20}function Mu(t){return Array.from(t.attributes).sort((n,r)=>Bi(n.name)-Bi(r.name)||n.name.localeCompare(r.name))}function Fu(t,e){let n=t.trim().split(/\s+/).filter(Boolean);if(n.length<=5&&t.length<=100)return`"${$r(t)}"`;let r=" ".repeat(e+2);return`"${n.map(a=>`
|
|
5050
|
-
${r}${$r(a)}`).join("")}
|
|
5051
|
-
${" ".repeat(e)}"`}function Wi(t,e){return t.name==="class"?`${t.name}=${Fu(t.value,e+t.name.length+2)}`:`${t.name}="${$r(t.value)}"`}function Hu(t,e){let n=Mu(t),r=t.tagName.toLowerCase();if(n.length===0)return`<${r}>`;let a=`<${r} ${n.map(o=>Wi(o,e)).join(" ")}>`;if(a.length<=110&&!n.some(o=>o.name==="class"&&o.value.length>100))return a;let i=[`<${r}`];for(let o of n)i.push(`${" ".repeat(e+2)}${Wi(o,e+2)}`);return i.push(`${" ".repeat(e)}>`),i.join(`
|
|
5052
|
-
`)}function Bu(t){let e=t.tagName.toLowerCase();if(e==="pre"||e==="code"||e==="textarea"||e==="style")return!0;let n=t.getAttribute("class")??"";if(/(^|\s)whitespace-(?:pre|pre-wrap|pre-line|break-spaces)(\s|$)/.test(n))return!0;let r=t.getAttribute("style")??"";return/(?:^|;)\s*white-space\s*:\s*(?:pre|pre-wrap|pre-line|break-spaces)\b/i.test(r)}function Dr(t,e){let n=" ".repeat(e*2);if(t.nodeType===Node.TEXT_NODE){let d=(t.nodeValue??"").replace(/\s+/g," ").trim();return d?`${n}${Hi(d)}`:""}if(t.nodeType===Node.COMMENT_NODE||t.nodeType!==Node.ELEMENT_NODE)return"";let r=t,a=r.tagName.toLowerCase(),i=`${n}${Hu(r,n.length)}`;if(vu.has(a))return i;if(a==="template"&&"content"in r){let d=r,u=[];for(let p of Array.from(d.content.childNodes)){let h=Dr(p,e+1);h&&u.push(h)}return u.length===0?`${i}</${a}>`:`${i}
|
|
5046
|
+
`),h}import*as wt from"@sentry/node";var Du="https://b3450c6a8fdcd02b8aee3b9f2c8425eb@o4511498910433280.ingest.us.sentry.io/4511498940252160",Nu="@inkly-org/cli@0.5.1";function Ka(){wt.init({dsn:Du,release:process.env.SENTRY_RELEASE??Nu,environment:process.env.SENTRY_ENVIRONMENT??"production",enabled:process.env.INKLY_SENTRY_DISABLED!=="1",sendDefaultPii:!1,tracesSampleRate:0,beforeSend(e){return e.server_name=void 0,e}})}async function se(e,t){wt.captureException(t,{tags:{command:e,surface:"cli"}}),await wt.flush(2e3)}async function Ya(){await wt.flush(2e3)}import{spawn as uo,execFile as Pp}from"child_process";import{createHash as Ip,randomUUID as Ep}from"crypto";import{mkdir as Ht,mkdtemp as Rp,open as po,readFile as _e,readdir as ho,rm as fe,writeFile as mo}from"fs/promises";import{existsSync as je}from"fs";import{dirname as Zn,isAbsolute as fo,join as W,resolve as Wn,sep as $p}from"path";import{tmpdir as Dp,homedir as ti}from"os";import{fileURLToPath as go}from"url";import{unzipSync as Np,zipSync as Mp}from"fflate";import Lp from"ws";import Op from"sharp";import jp from"subset-font";var Mu=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Lu=new Set(["a","button","input","select","textarea","label","p","h1","h2","h3","h4","h5","h6","img","li","nav","main","header","footer","section","article","aside","form","table","tr","td","th","ul","ol"]);function Ou(e){let t="";for(let n=0;n<e.length;n+=1)t+=(e[n]??0).toString(16).padStart(2,"0");return t}async function Fn(e,t=16){let n=new Uint8Array(e.byteLength);n.set(e);let r=await crypto.subtle.digest("SHA-256",n);return Ou(new Uint8Array(r)).slice(0,t)}function Zr(e){switch((e.toLowerCase().split(";")[0]??"").trim()){case"image/png":return".png";case"image/jpeg":case"image/jpg":return".jpg";case"image/webp":return".webp";case"image/gif":return".gif";case"image/svg+xml":return".svg";case"image/avif":return".avif";case"image/x-icon":case"image/vnd.microsoft.icon":return".ico";case"font/woff2":return".woff2";case"font/woff":return".woff";case"text/css":return".css";case"text/javascript":case"application/javascript":return".js";default:return".bin"}}function Br(e,t){let n=e.trim();if(!n||n.startsWith("data:")||n.startsWith("blob:")||n.startsWith("assets/")||n.startsWith("#"))return null;try{let r=new URL(n,t);return r.protocol!=="http:"&&r.protocol!=="https:"?null:r.href}catch{return null}}function no(e,t,n){if(t){let i=atob(n.replace(/\s+/g,"")),a=new Uint8Array(i.length);for(let o=0;o<i.length;o+=1)a[o]=i.charCodeAt(o);return a}let r=decodeURIComponent(n.replace(/\+/g,"%20"));return new TextEncoder().encode(r)}function ju(e){return/\s/.test(e)||e===")"||e==='"'||e==="<"||e===">"}function ro(e){return e.replace(/\\(?:\r\n|[\n\r\f])/g,"").replace(/\\([0-9a-fA-F]{1,6}\s?|[\s\S])/g,(t,n)=>{let r=n.match(/^([0-9a-fA-F]{1,6})\s?$/);if(r?.[1])try{return String.fromCodePoint(Number.parseInt(r[1],16))}catch{return""}return n})}function zu(e){let t=[],n=0;for(;n<e.length;){let r=e.toLowerCase().indexOf("data:",n);if(r<0)break;let i=r>0?e[r-1]:"",a=i==='"'||i==="'"?i:null,o=e.indexOf(",",r);if(o<0)break;let s=e.slice(r+5,o);if(!s||/[\s"'()<>]/.test(s)){n=r+5;continue}let c=o+1,d=!1;for(;c<e.length;){let x=e[c]??"";if(d){d=!1,c+=1;continue}if(x==="\\"){d=!0,c+=1;continue}if(a?x===a:ju(x))break;c+=1}let u=e.slice(r,c),p=ro(e.slice(o+1,c)),h=s.split(";"),f=h.shift()||"text/plain",w=h.some(x=>x.toLowerCase()==="base64");t.push({match:u,mime:f,isBase64:w,payload:p,index:r}),n=c}return t}function Uu(e){let t=e.trim();if(!t.toLowerCase().startsWith("data:"))return null;let n=t.indexOf(",");if(n<0)return null;let r=t.slice(5,n);if(!r||/[\s"'()<>]/.test(r))return null;let i=r.split(";"),a=i.shift()||"text/plain",o=i.some(s=>s.toLowerCase()==="base64");return{mime:a,isBase64:o,payload:ro(t.slice(n+1))}}async function Xa(e,t){let n=Uu(e);if(!n)return null;let r;try{r=no(n.mime,n.isBase64,n.payload)}catch{return null}let i=`${await Fn(r)}${Zr(n.mime)}`;return t.has(i)||t.set(i,{filename:i,bytes:r,contentType:n.mime||"application/octet-stream"}),`assets/${i}`}async function Wr(e,t,n){let r=n.get(e);if(r)return r;try{let i=await fetch(e,{cache:"force-cache",referrerPolicy:"strict-origin-when-cross-origin"});if(!i.ok)return null;let a=i.headers.get("content-type")?.split(";")[0]?.trim()||"application/octet-stream",o=new Uint8Array(await i.arrayBuffer());if(o.byteLength===0)return null;let s=`${await Fn(o)}${Zr(a)}`;t.has(s)||t.set(s,{filename:s,bytes:o,contentType:a});let c=`assets/${s}`;return n.set(e,c),c}catch{return null}}function Fu(e){let t=[],n=0,r=!1;for(let i=0;i<e.length;i+=1){if(e[i]!==",")continue;if(e.slice(n,i).trimStart().toLowerCase().startsWith("data:")&&!r){r=!0;continue}t.push(e.slice(n,i).trim()),n=i+1,r=!1}return t.push(e.slice(n).trim()),t.filter(Boolean).map(i=>{let a=i.match(/\s+(\d+(?:\.\d+)?[wx])$/);return a?.index?{url:i.slice(0,a.index).trim(),descriptor:a[1]??""}:{url:i,descriptor:""}}).filter(i=>i.url.length>0)}async function Hu(e,t,n,r){let i=Array.from(e.querySelectorAll("img[src],source[src],video[poster]"));for(let o of i){let s=o.hasAttribute("poster")?"poster":"src",c=o.getAttribute(s);if(!c)continue;let d=await Xa(c,n);if(d){o.setAttribute(s,d);continue}let u=Br(c,t);if(!u)continue;let p=await Wr(u,n,r);p&&o.setAttribute(s,p)}let a=Array.from(e.querySelectorAll("img[srcset],source[srcset]"));for(let o of a){let s=o.getAttribute("srcset");if(!s)continue;let c=[];for(let d of Fu(s)){let u=await Xa(d.url,n);if(u){c.push(`${u}${d.descriptor?` ${d.descriptor}`:""}`);continue}let p=Br(d.url,t),h=p?await Wr(p,n,r):null;c.push(`${h??d.url}${d.descriptor?` ${d.descriptor}`:""}`)}o.setAttribute("srcset",c.join(", "))}}async function Bu(e,t,n,r){let i=[],a=/url\(\s*(["']?)([^"')]+)\1\s*\)/gi,o;for(;o=a.exec(e);){let c=o[2]??"",d=Br(c,t);d&&i.push({raw:c,url:d})}let s=e;for(let c of i){let d=await Wr(c.url,n,r);d&&(s=s.split(c.raw).join(d))}return s}async function Wu(e){let t=new Map,n=zu(e),r=[];for(let o of n){let s;try{s=no(o.mime,o.isBase64,o.payload)}catch{continue}let c=`${await Fn(s)}${Zr(o.mime)}`;t.has(c)||t.set(c,{filename:c,bytes:s,contentType:o.mime||"application/octet-stream"}),r.push({match:o.match,replacement:`assets/${c}`})}let i=e,a=new Map;for(let o of r)a.set(o.match,o.replacement);for(let[o,s]of a)i=i.split(o).join(s);return{html:i,assets:t}}function Vu(e){return e.replace(/<script\b[\s\S]*?<\/script>/gi,"")}function Ju(e){return e.replace(/<script\b(?=[^>]*\bid=["']alpha-capture-index["'])[\s\S]*?<\/script>/i,"")}function Zu(e){return e.replace(/<link\b(?=[^>]*\brel=["'](?:preload|prefetch|preconnect|dns-prefetch|modulepreload|canonical|alternate)["'])[^>]*>/gi,"").replace(/<meta\b(?=[^>]*\b(?:property|name)=["'](?:og:[^"']+|twitter:[^"']+|description|keywords|robots|theme-color|generator)["'])[^>]*>/gi,"")}function qu(e){let t=1,n=e.createTreeWalker(e.documentElement,NodeFilter.SHOW_ELEMENT,null),r=e.documentElement;do{if(r&&r.nodeType===1){let i=r.tagName.toLowerCase();Lu.has(i)&&(r.setAttribute("data-inkly-id",String(t)),t+=1)}r=n.nextNode()}while(r)}function Gu(e){e.removeAttribute("href"),e.removeAttribute("xlink:href"),e.removeAttributeNS("http://www.w3.org/1999/xlink","href"),e.removeAttribute("target"),e.removeAttribute("rel"),e.removeAttribute("download"),e.removeAttribute("ping"),e.removeAttribute("referrerpolicy")}function Ku(e){for(let t of Array.from(e.querySelectorAll("*")))for(let n of Array.from(t.attributes))/^on/i.test(n.name)&&t.removeAttribute(n.name),/^formaction$/i.test(n.name)&&t.removeAttribute(n.name);for(let t of Array.from(e.querySelectorAll("base")))t.remove();for(let t of Array.from(e.querySelectorAll("link[href]")))(t.getAttribute("rel")??"").toLowerCase().split(/\s+/).filter(Boolean).includes("stylesheet")||t.remove();for(let t of Array.from(e.querySelectorAll("meta[http-equiv]")))(t.getAttribute("http-equiv")??"").toLowerCase()==="refresh"&&t.remove();for(let t of Array.from(e.querySelectorAll("a,area")))Gu(t),t.removeAttribute("data-inkly-href");for(let t of Array.from(e.querySelectorAll("form")))t.removeAttribute("action"),t.removeAttribute("method"),t.removeAttribute("target"),t.removeAttribute("data-inkly-action")}function Yu(e){let t=Array.from(e.querySelectorAll("style"));if(t.length===0)return"";let n=[],r=!0;for(let i of t){let a=i.textContent?.trim()??"",o=i.getAttribute("media")?.trim();if(o&&o.toLowerCase()!=="all"?n.push(`@media ${o} {${a}}`):n.push(a),r){let s=e.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("href","assets/document.css"),i.replaceWith(s),r=!1}else i.remove()}return n.join(`
|
|
5047
|
+
|
|
5048
|
+
`)}function Xu(e){let t="",n=0,r="",i=!1,a=0,o=!0,s=()=>{o&&(t+=" ".repeat(n),o=!1)},c=()=>{t=t.replace(/[ \t]+$/,""),t+=`
|
|
5049
|
+
`,o=!0};for(let d of e){if(r){s(),t+=d,i?i=!1:d==="\\"?i=!0:d===r&&(r="");continue}if(i){s(),t+=d,i=!1;continue}if(d==="\\"){s(),t+=d,i=!0;continue}if(d==='"'||d==="'"){s(),r=d,t+=d;continue}if(d==="("&&(a+=1),d===")"&&(a=Math.max(0,a-1)),d==="{"){s(),t=t.replace(/[ \t]+$/,""),t+=` {
|
|
5050
|
+
`,n+=1,o=!0;continue}if(d==="}"){n=Math.max(0,n-1),c(),s(),t+="}",c();continue}if(d===";"&&a===0){s(),t+=";",c();continue}if(d===","&&a===0){s(),t+=",",c();continue}s(),t+=d}return`${t.trim()}
|
|
5051
|
+
`}function Qa(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Vr(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function eo(e){return e==="id"?0:e==="data-inkly-id"?1:e==="class"?2:e==="href"?3:e==="src"?4:e==="srcset"?5:e==="alt"?6:e==="aria-label"?7:e==="role"?8:e==="type"?9:e==="style"?10:20}function Qu(e){return Array.from(e.attributes).sort((n,r)=>eo(n.name)-eo(r.name)||n.name.localeCompare(r.name))}function ep(e,t){let n=e.trim().split(/\s+/).filter(Boolean);if(n.length<=5&&e.length<=100)return`"${Vr(e)}"`;let r=" ".repeat(t+2);return`"${n.map(i=>`
|
|
5052
|
+
${r}${Vr(i)}`).join("")}
|
|
5053
|
+
${" ".repeat(t)}"`}function to(e,t){return e.name==="class"?`${e.name}=${ep(e.value,t+e.name.length+2)}`:`${e.name}="${Vr(e.value)}"`}function tp(e,t){let n=Qu(e),r=e.tagName.toLowerCase();if(n.length===0)return`<${r}>`;let i=`<${r} ${n.map(o=>to(o,t)).join(" ")}>`;if(i.length<=110&&!n.some(o=>o.name==="class"&&o.value.length>100))return i;let a=[`<${r}`];for(let o of n)a.push(`${" ".repeat(t+2)}${to(o,t+2)}`);return a.push(`${" ".repeat(t)}>`),a.join(`
|
|
5054
|
+
`)}function np(e){let t=e.tagName.toLowerCase();if(t==="pre"||t==="code"||t==="textarea"||t==="style")return!0;let n=e.getAttribute("class")??"";if(/(^|\s)whitespace-(?:pre|pre-wrap|pre-line|break-spaces)(\s|$)/.test(n))return!0;let r=e.getAttribute("style")??"";return/(?:^|;)\s*white-space\s*:\s*(?:pre|pre-wrap|pre-line|break-spaces)\b/i.test(r)}function Jr(e,t){let n=" ".repeat(t*2);if(e.nodeType===Node.TEXT_NODE){let d=(e.nodeValue??"").replace(/\s+/g," ").trim();return d?`${n}${Qa(d)}`:""}if(e.nodeType===Node.COMMENT_NODE||e.nodeType!==Node.ELEMENT_NODE)return"";let r=e,i=r.tagName.toLowerCase(),a=`${n}${tp(r,n.length)}`;if(Mu.has(i))return a;if(i==="template"&&"content"in r){let d=r,u=[];for(let p of Array.from(d.content.childNodes)){let h=Jr(p,t+1);h&&u.push(h)}return u.length===0?`${a}</${i}>`:`${a}
|
|
5053
5055
|
${u.join(`
|
|
5054
5056
|
`)}
|
|
5055
|
-
${n}</${
|
|
5056
|
-
`)&&
|
|
5057
|
+
${n}</${i}>`}if(np(r))return`${n}${r.outerHTML}`;let o=Array.from(r.childNodes).filter(d=>d.nodeType!==Node.COMMENT_NODE&&!(d.nodeType===Node.TEXT_NODE&&(d.nodeValue??"").trim().length===0));if(o.length>0&&o.every(d=>d.nodeType===Node.TEXT_NODE)){let d=o.map(u=>u.nodeValue??"").join("").replace(/\s+/g," ").trim();return d?`${a}${Qa(d)}</${i}>`:`${a}</${i}>`}let s=[];for(let d of Array.from(r.childNodes)){let u=Jr(d,t+1);u&&s.push(u)}if(s.length===0)return`${a}</${i}>`;let c=s[0];return s.length===1&&c&&c.trim()&&!c.includes(`
|
|
5058
|
+
`)&&a.length+c.trim().length<120?`${a}${c.trim()}</${i}>`:`${a}
|
|
5057
5059
|
${s.join(`
|
|
5058
5060
|
`)}
|
|
5059
|
-
${n}</${
|
|
5060
|
-
${
|
|
5061
|
-
`}var
|
|
5061
|
+
${n}</${i}>`}function rp(e){let t=e.documentElement;return`<!doctype html>
|
|
5062
|
+
${Jr(t,0)}
|
|
5063
|
+
`}var ip=.8,ap=1024;function op(e){let t=(e.toLowerCase().split(";")[0]??"").trim();return t==="image/png"||t==="image/jpeg"||t==="image/jpg"}async function sp(e,t){if(typeof createImageBitmap!="function"||typeof OffscreenCanvas!="function")return null;try{let n=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),r=await createImageBitmap(new Blob([n],{type:t}));try{let i=new OffscreenCanvas(r.width,r.height),a=i.getContext("2d");if(!a)return null;a.drawImage(r,0,0);let o=await i.convertToBlob({type:"image/webp",quality:ip});return o.type!=="image/webp"?null:new Uint8Array(await o.arrayBuffer())}finally{r.close()}}catch{return null}}async function lp(e,t,n){let r=new Map,i=new Map;for(let s of e.values()){if(!op(s.contentType)||s.bytes.byteLength<ap){i.set(s.filename,s);continue}let c=await sp(s.bytes,s.contentType);if(!c||c.byteLength>=s.bytes.byteLength){i.set(s.filename,s);continue}let d=`${await Fn(c)}.webp`;r.set(s.filename,d),i.has(d)||i.set(d,{filename:d,bytes:c,contentType:"image/webp"})}if(r.size===0)return{assets:[...e.values()],html:t,css:n};let a=t,o=n;for(let[s,c]of r)a=a.split(`assets/${s}`).join(`assets/${c}`),o=o.split(s).join(c);return{assets:[...i.values()],html:a,css:o}}async function io(e,t,n={}){let r=Vu(e);r=Ju(r),r=Zu(r);let i=await Wu(r);r=i.html;let a=cp(r);qu(a),Ku(a);let o=new Map;await Hu(a,t,i.assets,o);let s=(await Bu(Yu(a),t,i.assets,o)).replace(/url\((["']?)assets\//g,"url($1"),c=Xt(rp(a)),d=Xu(s);if(n.compressImages){let u=await lp(i.assets,c,d);return{html:u.html,css:u.css,assets:u.assets}}return{html:c,css:d,assets:[...i.assets.values()]}}function cp(e){let t=globalThis.DOMParser;if(!t)throw new Error("DOMParser is not available in this context. Run compactSnapshot in an offscreen document.");return new t().parseFromString(e,"text/html")}import{zipSync as dp}from"fflate";var up=/^(?:https?:)?\/\//i,pp=/^(?:#|data:|blob:|javascript:|mailto:|tel:|about:|chrome:|chrome-extension:)/i;function hp(e){return e.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,60).replace(/-+$/,"")||"demo"}function mp(e){let t="abcdefghijklmnopqrstuvwxyz0123456789",n=new Uint8Array(e);crypto.getRandomValues(n);let r="";for(let i=0;i<e;i+=1)r+=t[(n[i]??0)%t.length];return r}function fp(e){return`${hp(e)}-${mp(6)}`}function gp(e,t){return`# ${t}
|
|
5062
5064
|
|
|
5063
5065
|
This folder is a self-contained Inkly HTML capture. It works locally with
|
|
5064
5066
|
\`inkly-cli\` with no upload needed.
|
|
@@ -5068,12 +5070,13 @@ This folder is a self-contained Inkly HTML capture. It works locally with
|
|
|
5068
5070
|
1. If you don't have a hub yet, create one:
|
|
5069
5071
|
|
|
5070
5072
|
\`\`\`bash
|
|
5071
|
-
|
|
5073
|
+
npm install -g @inkly-org/cli
|
|
5074
|
+
inkly init my-hub
|
|
5072
5075
|
cd my-hub
|
|
5073
5076
|
\`\`\`
|
|
5074
5077
|
|
|
5075
|
-
2. Copy the \`${
|
|
5076
|
-
directory (so it lands at \`demos/${
|
|
5078
|
+
2. Copy the \`${e}/\` folder from this zip into your hub's \`demos/\`
|
|
5079
|
+
directory (so it lands at \`demos/${e}/\`).
|
|
5077
5080
|
|
|
5078
5081
|
3. Preview it:
|
|
5079
5082
|
|
|
@@ -5081,19 +5084,21 @@ This folder is a self-contained Inkly HTML capture. It works locally with
|
|
|
5081
5084
|
inkly dev
|
|
5082
5085
|
\`\`\`
|
|
5083
5086
|
|
|
5084
|
-
The demo appears under the slug \`${
|
|
5087
|
+
The demo appears under the slug \`${e}\`.
|
|
5085
5088
|
|
|
5086
5089
|
## What's inside
|
|
5087
5090
|
|
|
5088
|
-
- \`${
|
|
5089
|
-
- \`${
|
|
5090
|
-
- \`${
|
|
5091
|
-
- \`${
|
|
5092
|
-
- \`${
|
|
5093
|
-
`}function
|
|
5091
|
+
- \`${e}/demo.config.json\` - the demo definition.
|
|
5092
|
+
- \`${e}/assets.json\` - maps pooled asset ids to files in \`public/\`.
|
|
5093
|
+
- \`${e}/capture-metadata.json\` - HTML export diagnostics.
|
|
5094
|
+
- \`${e}/public/<file>\` - captured HTML asset bytes.
|
|
5095
|
+
- \`${e}/snapshots/snap-NNN/index.html\` and \`document.css\` - replayable snapshots.
|
|
5096
|
+
`}function bp(e){return e.trim().replace(/^['"]|['"]$/g,"")}function Hn(e,t){let n=bp(t.url);!n||pp.test(n)||!up.test(n)||e.set(`${t.stepId}\0${t.file}\0${t.kind}\0${n}`,{...t,url:n})}function yp(e){return e.split(",").map(t=>t.trim().split(/\s+/)[0]??"").filter(Boolean)}function xp(e,t){return e?.alphaId?t.includes(`data-inkly-id="${e.alphaId}"`)||t.includes(`data-inkly-id='${e.alphaId}'`)?e:{...e,alphaId:void 0}:e}function kp(e){let t=new Map,n=/\b(?:src|poster|data|action|formaction)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))/gi,r;for(;(r=n.exec(e.html))!==null;)Hn(t,{stepId:e.stepId,file:e.htmlPath,kind:"html-attribute",url:r[1]??r[2]??r[3]??""});let i=/<link\b(?=[^>]*\b(?:rel|as)\s*=\s*(?:"(?:stylesheet|preload|modulepreload|icon|apple-touch-icon|image_src)"|'(?:stylesheet|preload|modulepreload|icon|apple-touch-icon|image_src)'|[^\s"'<>`]*(?:stylesheet|preload|modulepreload|icon|apple-touch-icon|image_src)[^\s"'<>`]*))[^>]*\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))[^>]*>/gi,a;for(;(a=i.exec(e.html))!==null;)Hn(t,{stepId:e.stepId,file:e.htmlPath,kind:"html-attribute",url:a[1]??a[2]??a[3]??""});let o=/\b(?:srcset|imagesrcset)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>`]+))/gi,s;for(;(s=o.exec(e.html))!==null;){let u=s[1]??s[2]??s[3]??"";for(let p of yp(u))Hn(t,{stepId:e.stepId,file:e.htmlPath,kind:"html-srcset",url:p})}let c=/url\(\s*(?:"([^"]*)"|'([^']*)'|([^)"'\s]+))\s*\)/gi,d;for(;(d=c.exec(e.css))!==null;)Hn(t,{stepId:e.stepId,file:e.htmlPath.replace(/\/index\.html$/,"/document.css"),kind:"css-url",url:d[1]??d[2]??d[3]??""});return[...t.values()]}async function ao(e){let{name:t,steps:n,assets:r}=e;if(n.length===0)throw new Error("No HTML steps captured.");let i=fp(t),a=new Map;for(let _ of r)a.set(_.filename,`/${i}/${_.filename}`);let o={},s=[],c=[],d=new TextEncoder;for(let _=0;_<n.length;_+=1){let I=n[_];if(!I)continue;let $=`s${_+1}`,R=Ri(_+1),b=`snapshots/${R}/index.html`,z=lr(I.cssText??"",a),U=Di(Ni(Xt(lr(I.htmlText,a)),z.length>0),I.scroll);o[R]={"index.html":d.encode(U),"document.css":d.encode(z)},c.push(...kp({stepId:$,htmlPath:b,html:U,css:z})),s.push($i({stepId:$,htmlPath:b,naturalWidth:I.viewport.width,naturalHeight:I.viewport.height,scroll:I.scroll,sourceUrl:I.url||void 0,click:xp(I.click,U)}))}let u=r.map(_=>({id:_.filename,sha256:_.sha256,kind:kn(_.contentType),contentType:_.contentType,size:_.bytes.byteLength,publicUrl:`/${i}/${_.filename}`})),p=Sn({id:oe(),version:1,title:t,steps:s}),h=Rt.parse({version:1,assets:u,screens:[]}),f={version:1,kind:"html-capture",generatedAt:e.generatedAt??new Date().toISOString(),stepCount:n.length,assetCount:r.length,unresolvedExternalReferences:c},w={};for(let _ of r)w[_.filename]=_.bytes;let x={"README.md":d.encode(gp(i,t)),[i]:{"demo.config.json":d.encode(`${JSON.stringify(p,null,2)}
|
|
5094
5097
|
`),"assets.json":d.encode(`${JSON.stringify(h,null,2)}
|
|
5095
|
-
`),"capture-metadata.json":d.encode(`${JSON.stringify(
|
|
5096
|
-
`),snapshots:o,public:
|
|
5098
|
+
`),"capture-metadata.json":d.encode(`${JSON.stringify(f,null,2)}
|
|
5099
|
+
`),snapshots:o,public:w}};return{bytes:dp(x,{level:6}),filename:`${i}.zip`,slug:i}}import{JSDOM as zp}from"jsdom";import{Stagehand as Vb}from"@browserbasehq/stagehand";import{NodeHtmlMarkdown as Zb}from"node-html-markdown";var wp=["button","link","textbox","searchbox","checkbox","radio","combobox","listbox","option","switch","slider","spinbutton","tab","menuitem","menuitemcheckbox","menuitemradio","treeitem"],vp=["navigation","main","banner","contentinfo","complementary","search","form","dialog","alertdialog","menu","menubar","tablist","region"],sn="^\\s*(?:\\[[\\w-]+]\\s*)?",Mb=new RegExp(`${sn}(?:${wp.join("|")})\\b`,"i"),Lb=new RegExp(`${sn}(?:${vp.join("|")})\\b`,"i"),Ob=new RegExp(`${sn}heading\\b`,"i"),jb=new RegExp(`${sn}StaticText\\b`,"i");var zb=new RegExp(`${sn}[\\w-]+(?:,[^:]*)?:\\s`,"i");import Sp from"net";import Qb from"readline";import{rm as ty}from"fs/promises";import{join as qr}from"path";import{homedir as _p}from"os";function Cp(){return qr(process.env.INKLY_CAPTURE_AGENT_HOME||qr(_p(),".inkly"),"capture-agent","sessions")}function Gr(e){if(!/^[a-zA-Z0-9._:-]+$/.test(e))throw new Error(`invalid session id: ${e}`);return qr(Cp(),`${e}.nav.sock`)}async function G(e,t,n,r={}){let i=r.connectTimeoutMs??8e3,a=r.requestTimeoutMs??6e4,s={id:`${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`,type:"command",command:t,params:n},c=await Tp(e,i);return new Promise((d,u)=>{let p="",h=!1,f=x=>{h||(h=!0,clearTimeout(w),x())},w=setTimeout(()=>{f(()=>{c.destroy(),u(new Error(`nav request "${t}" timed out`))})},a);c.on("data",x=>{p+=x.toString();let _=p.indexOf(`
|
|
5100
|
+
`);if(_===-1)return;let I;try{I=JSON.parse(p.slice(0,_))}catch($){f(()=>{c.destroy(),u($ instanceof Error?$:new Error(String($)))});return}if(I.type==="error"){f(()=>{c.end(),u(new Error(I.error))});return}f(()=>{c.end(),d(I.data)})}),c.on("error",x=>{f(()=>u(x))}),c.on("close",()=>{f(()=>u(new Error("nav listener closed without a response")))}),c.write(`${JSON.stringify(s)}
|
|
5101
|
+
`)})}async function Tp(e,t){let n=Date.now(),r=null;for(;Date.now()-n<t;)try{return await Ap(e)}catch(i){r=i instanceof Error?i:new Error(String(i)),await new Promise(a=>setTimeout(a,150))}throw new Error(`could not reach the capture listener nav socket at ${e}`+(r?` (${r.message})`:"")+". Is the session started and is its listener ready?")}function Ap(e){return new Promise((t,n)=>{let r=Sp.createConnection(e),i=a=>{r.destroy(),n(a)};r.once("error",i),r.once("connect",()=>{r.off("error",i),t(r)})})}var oo=!1;function Up(){if(oo)return;let{window:e}=new zp("<!doctype html><html></html>"),t=globalThis;t.DOMParser??=e.DOMParser,t.Node??=e.Node,t.NodeFilter??=e.NodeFilter,t.Element??=e.Element,t.HTMLImageElement??=e.HTMLImageElement,oo=!0}var bo=`Options:
|
|
5097
5102
|
--url <url> URL to open and arm for recording.
|
|
5098
5103
|
--name <name> Demo name written into the exported ZIP.
|
|
5099
5104
|
--session <id> Session id printed by start.
|
|
@@ -5113,7 +5118,7 @@ This folder is a self-contained Inkly HTML capture. It works locally with
|
|
|
5113
5118
|
done once in this profile survives, so later captures of the same site need
|
|
5114
5119
|
no re-login. Implies --keep-profile. Run --headed the first time so the user
|
|
5115
5120
|
can sign in; reuse can run headless.
|
|
5116
|
-
--no-unpack On stop, write only the ZIP.`,
|
|
5121
|
+
--no-unpack On stop, write only the ZIP.`,dn=`inkly capture - capture an image/video walkthrough for an external browser agent
|
|
5117
5122
|
|
|
5118
5123
|
Usage:
|
|
5119
5124
|
inkly capture start --url <url> --name <name>
|
|
@@ -5121,9 +5126,10 @@ Usage:
|
|
|
5121
5126
|
inkly capture cancel --session <id>
|
|
5122
5127
|
inkly capture status --session <id>
|
|
5123
5128
|
inkly capture undo --session <id>
|
|
5129
|
+
inkly capture nav <verb> --session <id> (snapshot|click|fill|type|press|select|upload|get|is|wait|back|forward|reload|refs|mouse)
|
|
5124
5130
|
inkly capture profiles
|
|
5125
5131
|
|
|
5126
|
-
${
|
|
5132
|
+
${bo}
|
|
5127
5133
|
--video, --record-video Record motion segments. Enabled by default; use --no-video to disable.
|
|
5128
5134
|
--zoom Apply click zoom/pan to screenshot steps. Enabled by default; use --no-zoom to disable.
|
|
5129
5135
|
--compress-images Re-encode captured PNG/JPEG screenshots to WebP (smaller, near-lossless).
|
|
@@ -5132,7 +5138,7 @@ ${io}
|
|
|
5132
5138
|
Output:
|
|
5133
5139
|
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
5134
5140
|
For self-contained HTML snapshot capture, use \`inkly capture-html\`.
|
|
5135
|
-
`,
|
|
5141
|
+
`,un=`inkly capture-html - capture a self-contained HTML walkthrough for an external browser agent
|
|
5136
5142
|
|
|
5137
5143
|
Usage:
|
|
5138
5144
|
inkly capture-html start --url <url> --name <name>
|
|
@@ -5140,29 +5146,33 @@ Usage:
|
|
|
5140
5146
|
inkly capture-html cancel --session <id>
|
|
5141
5147
|
inkly capture-html status --session <id>
|
|
5142
5148
|
inkly capture-html undo --session <id>
|
|
5149
|
+
inkly capture-html nav <verb> --session <id> (snapshot|click|fill|type|press|select|upload|get|is|wait|back|forward|reload|refs|mouse)
|
|
5143
5150
|
inkly capture-html profiles
|
|
5144
5151
|
|
|
5145
|
-
${
|
|
5152
|
+
${bo}
|
|
5146
5153
|
--block-videos Replace <video> with its poster frame instead of inlining the video.
|
|
5147
5154
|
|
|
5148
5155
|
Output:
|
|
5149
5156
|
Every subcommand prints JSON. This command does not accept prompts and does not plan or drive the page.
|
|
5150
|
-
`,
|
|
5151
|
-
`)}function
|
|
5157
|
+
`,Fp=Zn(go(import.meta.url)),Hp=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/opt/google/chrome/chrome"],Bp=1440,Wp=900,Vp=12e4;var Jp=720,Zp=60,Ay=Math.round(Jp/Zp);function Bt(e){return new Promise(t=>setTimeout(t,e))}function Q(e){process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
5158
|
+
`)}function Se(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t];return typeof n=="string"?n:""}function Kr(e,t,n){let r=e[t];return typeof r=="number"?r:typeof r=="string"&&r.trim()?Number(r):n}function Ft(e,t,n){for(let r of t)if(Object.prototype.hasOwnProperty.call(e,r))return e[r]!==!1;return n}function qp(e){if(!e)return null;let t=/^\s*(\d+)\s*[x,]\s*(\d+)\s*$/i.exec(e);if(!t)throw new Error("--window-size must look like 1440x900");return{width:Number(t[1]),height:Number(t[2])}}function Ge(e,t,n){let r=Se(e,t);if(!r)throw new Error(`missing --${t} <value>
|
|
5152
5159
|
|
|
5153
|
-
${n}`);return r}function
|
|
5160
|
+
${n}`);return r}function Gp(e){return Se(e,"connect-to-browser")??process.env.INKLY_CAPTURE_BROWSER_URL}function Kp(e){if(Object.prototype.hasOwnProperty.call(e,"prompt"))throw new Error("inkly capture does not accept --prompt. The external agent owns planning.")}function qn(e,t){return fo(t)?t:Wn(e,t)}function yo(){return W(ti(),".inkly","capture-agent","profiles")}function Yp(e,t){if(t.includes("/")||fo(t))return qn(e,t);let n=t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64);return W(yo(),n||"default")}function so(e,t){let n=Wn(e);for(;;){let r=W(n,t);if(je(r))return r;let i=Zn(n);if(i===n)return null;n=i}}async function lo(e){let t=[e];for(;t.length>0;){let n=t.pop();if(!n)continue;let r=await ho(n,{withFileTypes:!0}).catch(()=>[]);for(let i of r){let a=W(n,i.name);if(i.isDirectory()){t.push(a);continue}if(i.name==="Google Chrome for Testing"&&a.includes("Google Chrome for Testing.app/Contents/MacOS"))return a}}return null}async function Xp(e,t){if(t){let s=qn(e,t);if(je(s))return s;throw new Error(`Chrome binary does not exist: ${s}`)}let n=process.env.CHROME_PATH;if(n&&je(n))return n;let r=Hp.find(s=>je(s));if(r)return r;let i=so(e,"chrome");if(i){let s=await lo(i);if(s)return s}let a=so(Fp,"chrome");if(a&&a!==i){let s=await lo(a);if(s)return s}let o=["/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing","/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary","/Applications/Chromium.app/Contents/MacOS/Chromium","/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"];for(let s of o)if(je(s))return s;throw new Error("No Chrome binary found. Pass --browser /path/to/chrome.")}var Vn=class{constructor(t){this.nextId=1;this.pending=new Map;this.listeners=new Map;this.ws=new Lp(t,{perMessageDeflate:!1,maxPayload:512*1024*1024}),this.ready=new Promise((n,r)=>{this.ws.once("open",()=>n()),this.ws.once("error",i=>r(i))}),this.ws.on("message",n=>{let r=JSON.parse(n.toString());if(typeof r.id=="number"&&this.pending.has(r.id)){let a=this.pending.get(r.id);if(this.pending.delete(r.id),!a)return;r.error?a.reject(new Error(`${r.error.message??"CDP error"}: ${JSON.stringify(r.error.data??"")}`)):a.resolve(r.result??{});return}if(!r.method)return;let i=this.listeners.get(r.method);if(i)for(let a of i)a(r.params,r.sessionId)})}async send(t,n={},r){await this.ready;let i=this.nextId;this.nextId+=1;let a={id:i,method:t,params:n};return r&&(a.sessionId=r),new Promise((o,s)=>{this.pending.set(i,{resolve:o,reject:s}),this.ws.send(JSON.stringify(a),c=>{c&&(this.pending.delete(i),s(c))})})}on(t,n){let r=this.listeners.get(t)??new Set;return r.add(n),this.listeners.set(t,r),()=>r.delete(n)}close(){try{this.ws.close()}catch{}}};async function xo(e,t,n,r=3e4){let i=await e.send("Runtime.evaluate",{expression:n,awaitPromise:!0,returnByValue:!0,timeout:r,userGesture:!0},t);if(i.exceptionDetails)throw new Error(`Runtime.evaluate failed: ${JSON.stringify(i.exceptionDetails)}`);return i.result?.value}async function Qp(e,t){let r=(await e.send("Target.attachToTarget",{targetId:t,flatten:!0})).sessionId;if(typeof r!="string")throw new Error("Target.attachToTarget returned no sessionId");return r}async function eh(e){let t=e.userDataDir?(await Ht(e.userDataDir,{recursive:!0}),e.userDataDir):await Rp(W(Dp(),"inkly-capture-agent-")),n=W(t,"chrome.log"),r=await po(n,"a"),i=["--remote-debugging-port=0",`--user-data-dir=${t}`,`--window-size=${e.width},${e.height}`,"--no-first-run","--no-default-browser-check","--disable-default-apps","--disable-background-networking","--disable-features=Translate,AutofillServerCommunication","--use-mock-keychain","--hide-scrollbars","--hide-crash-restore-bubble"];e.headless&&i.unshift("--headless=new");for(let p of["DevToolsActivePort","SingletonLock","SingletonCookie","SingletonSocket"])await fe(W(t,p),{force:!0}).catch(()=>{});let a=uo(e.browser,i,{detached:!0,stdio:["ignore",r.fd,r.fd]});a.unref(),await r.close();let o=W(t,"DevToolsActivePort"),s=Date.now(),c;a.once("exit",p=>{c=p});let d=!e.userDataDir,u=async p=>{let h=await _e(n,"utf8").then(f=>f.split(`
|
|
5161
|
+
`).filter(Boolean).slice(-10).join(`
|
|
5162
|
+
`)).catch(()=>"");throw a.pid&&await Xr(a.pid).catch(()=>{}),await wo(t).catch(()=>{}),d&&await fe(t,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),new Error(`${p} Chrome log (${n}):
|
|
5163
|
+
${h||"(empty \u2014 Chrome wrote nothing)"}`)};for(;Date.now()-s<2e4;){if(c!==void 0)return u("Chrome exited before DevTools was ready.");let p=await _e(o,"utf8").catch(()=>null);if(p){let h=p.trim().split(/\r?\n/),f=h[0],w=h[1];if(f&&w)return{pid:a.pid??null,profileDir:t,wsUrl:`ws://127.0.0.1:${f}${w}`,debuggingUrl:`http://127.0.0.1:${f}`,logPath:n}}await Bt(100)}return u("Timed out waiting for Chrome DevTools.")}async function th(e){if(e.startsWith("ws://")||e.startsWith("wss://")){let i=new URL(e);return{wsUrl:e,debuggingUrl:`${i.protocol==="wss:"?"https":"http"}://${i.host}`}}let t=new URL(e),n=await fetch(new URL("/json/version",t));if(!n.ok)throw new Error(`could not read Chrome DevTools metadata from ${t.toString()}: ${n.status}`);let r=await n.json();if(typeof r.webSocketDebuggerUrl!="string")throw new Error("Chrome DevTools metadata did not include webSocketDebuggerUrl");return{wsUrl:r.webSocketDebuggerUrl,debuggingUrl:`${t.protocol}//${t.host}`}}async function nh(e,t,n,r,i){let o=(await e.send("Target.createTarget",{url:"about:blank"})).targetId;if(typeof o!="string")throw new Error("Target.createTarget returned no targetId");let s=await Qp(e,o);await e.send("Page.enable",{},s),await e.send("Runtime.enable",{},s),await ih(e,s,o,n,r);let c=!1,d=e.on("Page.loadEventFired",(p,h)=>{h===s&&(c=!0)});await e.send("Page.navigate",{url:t},s);let u=Date.now();for(;!c&&Date.now()-u<i;)await Bt(100);return d(),await Bt(1e3),{targetId:o,sessionId:s}}async function rh(e,t){let n=await xo(e,t,`JSON.stringify({
|
|
5154
5164
|
innerWidth: window.innerWidth,
|
|
5155
5165
|
innerHeight: window.innerHeight,
|
|
5156
5166
|
outerWidth: window.outerWidth,
|
|
5157
5167
|
outerHeight: window.outerHeight
|
|
5158
|
-
})`,5e3),r=JSON.parse(String(n)),
|
|
5168
|
+
})`,5e3),r=JSON.parse(String(n)),i={innerWidth:Number(r.innerWidth),innerHeight:Number(r.innerHeight),outerWidth:Number(r.outerWidth),outerHeight:Number(r.outerHeight)};if(!Number.isFinite(i.innerWidth)||!Number.isFinite(i.innerHeight)||!Number.isFinite(i.outerWidth)||!Number.isFinite(i.outerHeight))throw new Error(`could not measure Chrome viewport: ${JSON.stringify(r)}`);return i}async function ih(e,t,n,r,i){try{let o=(await e.send("Browser.getWindowForTarget",{targetId:n})).windowId;if(typeof o!="number")throw new Error("Browser.getWindowForTarget returned no windowId");for(let s=0;s<4;s+=1){let c=await rh(e,t),d=Math.max(0,c.outerWidth-c.innerWidth),u=Math.max(0,c.outerHeight-c.innerHeight),p=r+d,h=i+u;if(Math.abs(c.innerWidth-r)<=1&&Math.abs(c.innerHeight-i)<=1)return;await e.send("Browser.setWindowBounds",{windowId:o,bounds:{windowState:"normal",width:p,height:h}}),await Bt(250)}}catch{}await e.send("Emulation.setDeviceMetricsOverride",{width:r,height:i,deviceScaleFactor:1,mobile:!1},t).catch(()=>{}),await Bt(100)}function ah(e){return e.toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"captured-demo"}function oh(e){return`${ah(e)}-${Math.random().toString(36).slice(2,8)}`}function ni(e){return Ip("sha256").update(e).digest("hex")}function sh(e,t){return`# ${t}
|
|
5159
5169
|
|
|
5160
5170
|
This folder is a self-contained Inkly demo captured with the Inkly CLI
|
|
5161
5171
|
agent runtime. It works locally with \`inkly-cli\` \u2014 no upload needed.
|
|
5162
5172
|
|
|
5163
5173
|
## Use it
|
|
5164
5174
|
|
|
5165
|
-
1. Copy the \`${
|
|
5175
|
+
1. Copy the \`${e}/\` folder from this zip into your hub's \`demos/\`
|
|
5166
5176
|
directory.
|
|
5167
5177
|
|
|
5168
5178
|
2. Preview it:
|
|
@@ -5173,13 +5183,13 @@ agent runtime. It works locally with \`inkly-cli\` \u2014 no upload needed.
|
|
|
5173
5183
|
|
|
5174
5184
|
## What's inside
|
|
5175
5185
|
|
|
5176
|
-
- \`${
|
|
5177
|
-
- \`${
|
|
5178
|
-
- \`${
|
|
5179
|
-
- \`${
|
|
5180
|
-
`}function
|
|
5181
|
-
`),"assets.json":
|
|
5182
|
-
`),public:d,snapshots:u}};return{bytes:
|
|
5186
|
+
- \`${e}/demo.config.json\` \u2014 the demo definition.
|
|
5187
|
+
- \`${e}/assets.json\` \u2014 maps each \`asset:<id>\` to a file in \`public/\`.
|
|
5188
|
+
- \`${e}/public/<file>\` \u2014 captured image/video bytes.
|
|
5189
|
+
- \`${e}/snapshots/snap-NNN/index.html\` \u2014 captured HTML snapshots, when present.
|
|
5190
|
+
`}function lh(e){switch(e.toLowerCase().split(";")[0]?.trim()){case"image/png":return"png";case"image/jpeg":case"image/jpg":return"jpg";case"image/webp":return"webp";case"image/gif":return"gif";case"image/svg+xml":return"svg";case"image/avif":return"avif";case"image/x-icon":case"image/vnd.microsoft.icon":return"ico";case"font/woff":return"woff";case"font/woff2":return"woff2";case"font/ttf":case"application/x-font-ttf":return"ttf";case"video/webm":return"webm";case"video/mp4":return"mp4";case"audio/mpeg":return"mp3";case"text/html":return"html";case"text/css":return"css";case"text/javascript":case"application/javascript":case"application/x-javascript":return"js";default:return"bin"}}async function ch(e,t,n,r,i){let a=new TextDecoder,o=new TextEncoder,s=new Map,c=0,d=0,u=0,p=" ";if(i.subsetFonts){let h=new Set;for(let f of Object.values(r)){let w=f["index.html"];if(!w)continue;let x=a.decode(w).replace(/<style[\s\S]*?<\/style>/gi," ").replace(/<[^>]+>/g," ");for(let _ of x)h.add(_)}for(let f of" 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.,:;!?@#$%&*()-_=+[]{}/\\|<>'\"`~\u2019\u201C\u201D\u2014\u2013\u2026\u2022\u2192")h.add(f);p=Array.from(h).join("")}for(let h of t){let f=h.publicUrl;if(!f)continue;let w=f.split("/").pop();if(!w)continue;let x=n[w];if(!x)continue;let _=null,I="",$="",R=(h.contentType??"").toLowerCase();try{if(i.compressImages&&h.kind==="image"&&/^image\/(png|jpe?g)$/.test(R)){let V=await Op(Buffer.from(x)).webp({quality:80}).toBuffer();V.length<x.byteLength&&(_=V,I="webp",$="image/webp")}else if(i.subsetFonts&&h.kind==="font"){let V=await jp(Buffer.from(x),p,{targetFormat:"woff2"});V.length<x.byteLength&&(_=V,I="woff2",$="font/woff2")}}catch{_=null}if(!_)continue;let b=new Uint8Array(_),z=ni(b),U=`${z.slice(0,16)}.${I}`,D=`/${e}/${U}`;u+=x.byteLength-b.byteLength,h.kind==="image"?c+=1:d+=1,delete n[w],n[U]=b,h.id===w&&(h.id=U),s.set(f,D),h.sha256=z,h.size=b.byteLength,h.contentType=$,h.publicUrl=D}if(s.size)for(let h of Object.values(r)){let f=h;for(let w of Object.keys(f)){let x=a.decode(f[w]);for(let[_,I]of s)x=x.split(_).join(I);f[w]=o.encode(x)}}return{images:c,fonts:d,savedBytes:u}}async function dh(e){let{name:t,screens:n,autoApplyZoom:r=!0,compressImages:i=!1,subsetFonts:a=!1}=e;if(n.length===0)throw new Error("No screens captured.");let o=oh(t),s=[],c=[],d={},u={},p=[],h=[],f=new TextEncoder,w=0;async function x(R,b,z,U,D){let V=ni(R),ne=D??`${V}.${lh(b)}`;d[ne]=R,w+=1;let Ce=z==="other"?ne:`cap-${String(w).padStart(3,"0")}`;return s.push({id:Ce,sha256:V,kind:z==="other"?kn(b):z,contentType:b,size:R.byteLength,viewport:U?{w:U.width,h:U.height}:void 0,file:ne}),Ce}for(let[R,b]of n.entries()){let z=`s${R+1}`,U=null;if(b.kind!=="html"){if(b.kind==="video"&&b.videoPath){let D=new Uint8Array(await _e(b.videoPath));U=await x(D,"video/webm","video",b.viewport);let V;if(b.posterPngPath){let ne=new Uint8Array(await _e(b.posterPngPath));V=await x(ne,"image/png","image",b.viewport)}p.push(sr({stepId:z,kind:"video",assetId:U,posterAssetId:V,naturalWidth:b.naturalSize.width,naturalHeight:b.naturalSize.height,sourceUrl:b.sourceUrl||void 0,title:b.title||void 0,click:b.click,autoApplyZoom:r,isLast:R===n.length-1})),h.push(b.click?.label||b.title||`Step ${R+1}`)}else{if(!b.pngPath)continue;let D=new Uint8Array(await _e(b.pngPath));U=await x(D,"image/png","image",b.viewport),p.push(sr({stepId:z,kind:"image",assetId:U,naturalWidth:b.naturalSize.width,naturalHeight:b.naturalSize.height,sourceUrl:b.sourceUrl||void 0,title:b.title||void 0,click:b.click,autoApplyZoom:r,isLast:R===n.length-1})),h.push(b.click?.label||b.title||`Step ${R+1}`)}c.push({index:R,id:Ei(R),assetId:U,sourceUrl:b.sourceUrl,capturedAt:b.capturedAt,naturalWidth:b.naturalSize.width,naturalHeight:b.naturalSize.height,precedingClick:b.click})}}if(p.length===0)throw new Error("No usable screens captured.");(i||a)&&await ch(o,s,d,u,{compressImages:i,subsetFonts:a});let _=Sn({id:oe(),version:1,title:t,steps:p}),I=Rt.parse({version:1,assets:s,screens:c}),$={"README.md":f.encode(sh(o,t)),[o]:{"demo.config.json":f.encode(`${JSON.stringify(_,null,2)}
|
|
5191
|
+
`),"assets.json":f.encode(`${JSON.stringify(I,null,2)}
|
|
5192
|
+
`),public:d,snapshots:u}};return{bytes:Mp($,{level:6}),filename:`${o}.zip`,slug:o,stepCount:n.length,labels:h}}function uh(e){return e?{x:e.x,y:e.y,alphaId:e.alphaId??void 0,label:e.label}:null}async function ph(e){let{name:t,screens:n}=e,r=n.filter(c=>c.kind==="html"&&c.htmlPath);if(r.length===0)throw new Error("No HTML screens captured.");let i=r.map((c,d)=>c.click?.label||c.title||`Step ${d+1}`);Up();let a=[],o=new Map;for(let c of r){let d=await _e(c.htmlPath,"utf8"),u=await io(d,c.sourceUrl||"");for(let p of u.assets)o.has(p.filename)||o.set(p.filename,{filename:p.filename,sha256:ni(p.bytes),contentType:p.contentType,bytes:p.bytes});a.push({htmlText:u.html,cssText:u.css,viewport:{width:c.naturalSize.width,height:c.naturalSize.height},scroll:c.scroll??{x:0,y:0,maxX:0,maxY:0},url:c.sourceUrl||"",click:uh(c.click)})}return{...await ao({name:t,steps:a,assets:[...o.values()]}),stepCount:r.length,labels:i}}var co=`(() => {
|
|
5183
5193
|
if (window.__inklyCliRecorderInstalled) return;
|
|
5184
5194
|
window.__inklyCliRecorderInstalled = true;
|
|
5185
5195
|
window.__inklyCliLastClick = null;
|
|
@@ -5363,7 +5373,7 @@ function selectorFor(el) {
|
|
|
5363
5373
|
window.addEventListener("scroll", onMotionScroll, true);
|
|
5364
5374
|
window.addEventListener("wheel", onMotionScroll, true);
|
|
5365
5375
|
window.addEventListener("touchmove", onMotionScroll, true);
|
|
5366
|
-
})();`;async function
|
|
5376
|
+
})();`;async function hh(e,t,n=!1){n&&(await e.send("Runtime.addBinding",{name:"__inklyCliCaptureEvent"},t).catch(()=>{}),await e.send("Runtime.addBinding",{name:"__inklyCliCaptureClick"},t).catch(()=>{})),await e.send("Page.addScriptToEvaluateOnNewDocument",{source:co},t),await xo(e,t,co,5e3).catch(()=>{})}var mh="__inklySingleFileFetch",Py=`(() => {
|
|
5367
5377
|
if (globalThis.__inklyFetchInstalled) return;
|
|
5368
5378
|
globalThis.__inklyFetchInstalled = true;
|
|
5369
5379
|
const pending = new Map();
|
|
@@ -5383,7 +5393,7 @@ function selectorFor(el) {
|
|
|
5383
5393
|
const id = nextId++;
|
|
5384
5394
|
pending.set(id, { resolve, reject });
|
|
5385
5395
|
try {
|
|
5386
|
-
globalThis.${
|
|
5396
|
+
globalThis.${mh}(JSON.stringify({
|
|
5387
5397
|
id,
|
|
5388
5398
|
url: String(url),
|
|
5389
5399
|
options: {
|
|
@@ -5406,13 +5416,84 @@ function selectorFor(el) {
|
|
|
5406
5416
|
return viaNode(url, options);
|
|
5407
5417
|
}
|
|
5408
5418
|
};
|
|
5409
|
-
})();`;var
|
|
5410
|
-
`)}async function
|
|
5411
|
-
`)}async function
|
|
5419
|
+
})();`;var Iy=Math.max(6e4,Number(process.env.INKLY_CAPTURE_TIMEOUT_MS)||24e4);function ri(){return W(process.env.INKLY_CAPTURE_AGENT_HOME||W(ti(),".inkly"),"capture-agent","sessions")}function fh(e){return W(process.env.INKLY_CAPTURE_AGENT_HOME||W(ti(),".inkly"),"capture-agent","captures",e)}async function gh(e,t){await Ht(t,{recursive:!0});let n=W(t,"listener.log"),r=await po(n,"a"),i=go(import.meta.url),a=W(Zn(i),"capture-listener.js"),o=uo(process.execPath,[a,"--session",e],{detached:!0,stdio:["ignore",r.fd,r.fd]});return o.unref(),await r.close(),{pid:o.pid??null,logPath:n}}async function bh(e,t){let n=Date.now();for(;Date.now()-n<t;){let r=await Ke(e).catch(()=>null);if(r?.cliListenerReadyAt)return r;await Bt(100)}return Ke(e)}function Gn(e){if(!/^[a-zA-Z0-9._:-]+$/.test(e))throw new Error(`invalid session id: ${e}`);return W(ri(),`${e}.json`)}function ii(e){return W(ri(),`${e}.listener.json`)}async function yh(e,t){await te(ii(e),`${JSON.stringify(t,null,2)}
|
|
5420
|
+
`)}async function xh(e){try{let t=await _e(ii(e),"utf8");return JSON.parse(t)}catch{return null}}async function kh(e){await te(Gn(e.id),`${JSON.stringify(e,null,2)}
|
|
5421
|
+
`)}async function Ke(e){let t=await _e(Gn(e),"utf8");return JSON.parse(t)}async function Yr(e){await fe(Gn(e),{force:!0}),await fe(ii(e),{force:!0}),await fe(Gr(e),{force:!0}).catch(()=>{}),await fe(Kn(e),{force:!0}).catch(()=>{})}function ko(e){try{return process.kill(e,0),!0}catch{return!1}}async function Xr(e){let t=(n,r)=>{try{process.kill(n,r)}catch{}};t(-e,"SIGTERM"),t(e,"SIGTERM");for(let n=0;n<8&&ko(e);n+=1)await new Promise(r=>setTimeout(r,100));t(-e,"SIGKILL"),t(e,"SIGKILL")}async function wo(e){if(!e||!e.includes("inkly"))return;let t=await new Promise(n=>{Pp("pgrep",["-f","--",e],{timeout:4e3},(r,i)=>{let a=String(i||"").split(`
|
|
5422
|
+
`).map(o=>Number(o.trim())).filter(o=>Number.isInteger(o)&&o>0&&o!==process.pid);n(a)})});for(let n of t)try{process.kill(n,"SIGKILL")}catch{}}async function wh(e){if(!e)return;let t=null;try{t=new Vn(e),await Promise.race([t.send("Browser.close"),new Promise((n,r)=>setTimeout(()=>r(new Error("Browser.close timed out")),2e3))])}catch{}finally{t?.close()}}async function cn(e){let t=e.cliListenerPid??null;!t&&e.id&&(t=(await xh(e.id))?.cliListenerPid??null),t&&await Xr(t),!e.attached&&(await wh(e.browserWsUrl),e.chromePid&&await Xr(e.chromePid),await wo(e.profileDir),e.keepProfile||e.profileDir&&await fe(e.profileDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}))}async function vh(e,t,n,r){let i=Ge(t,"url",r),a=Ge(t,"name",r);new URL(i);let o=qp(Se(t,"window-size")),s=o?.width??Kr(t,"width",Bp),c=o?.height??Kr(t,"height",Wp),d=Kr(t,"timeout",Vp),u=Gp(t),p=Se(t,"runtime");if(p&&p!=="cli")throw new Error("--runtime must be cli");let h=n,f=Ft(t,["zoom","auto-apply-zoom"],!0),x=Ft(t,["record-video","video"],!0)&&h!=="html",_=Ft(t,["block-videos","block-video"],!1),I=Ft(t,["compress-images","compress-image"],!1),$=Ft(t,["subset-fonts","subset-font"],!1),R=Ft(t,["headless"],!0)&&t.headed!==!0,b=Se(t,"profile"),z=!u&&b?Yp(e,b):null,U=z!=null&&je(W(z,"Default"));if(!Number.isInteger(s)||s<320)throw new Error("--width must be an integer >= 320");if(!Number.isInteger(c)||c<240)throw new Error("--height must be an integer >= 240");if(!Number.isInteger(d)||d<1e3)throw new Error("--timeout must be an integer >= 1000");let D=u?{pid:null,profileDir:null,...await th(u),logPath:null}:await(async()=>{let K=await Xp(e,Se(t,"browser"));return eh({browser:K,width:s,height:c,headless:R,timeoutMs:d,userDataDir:z})})(),V=new Vn(D.wsUrl),ne=null,Ce=!1,Wt=()=>{cn({id:"",runtime:"cli",createdAt:"",url:i,name:a,chromePid:D.pid,profileDir:D.profileDir,keepProfile:z!=null||!!u,browserWsUrl:D.wsUrl,browserDebuggingUrl:D.debuggingUrl,chromeLogPath:D.logPath,attached:!!u,tabId:0,tabUrl:"",targetId:"",width:s,height:c,cliScreens:[],captureDir:null,cliListenerPid:ne,cliListenerLogPath:null,cliListenerReadyAt:null}).finally(()=>{process.exit(130)})};process.on("SIGINT",Wt),process.on("SIGTERM",Wt),Ce=!0;let L=()=>{Ce&&(process.removeListener("SIGINT",Wt),process.removeListener("SIGTERM",Wt),Ce=!1)};try{await V.send("Target.setDiscoverTargets",{discover:!0}).catch(()=>{});let K=await nh(V,i,s,c,d);await V.send("Target.activateTarget",{targetId:K.targetId}).catch(()=>{});let ge=Ep();await hh(V,K.sessionId);let A=fh(ge),le={id:ge,runtime:"cli",createdAt:new Date().toISOString(),url:i,name:a,chromePid:D.pid,profileDir:D.profileDir,keepProfile:u?!0:z!=null||t["keep-profile"]===!0,browserWsUrl:D.wsUrl,browserDebuggingUrl:D.debuggingUrl,chromeLogPath:D.logPath,attached:!!u,tabId:0,tabUrl:i,targetId:K.targetId,width:s,height:c,cliScreens:[],cliCaptureKind:h,cliRecordVideo:x,cliHeadless:u?!1:R,cliBlockVideos:h==="html"?_:!1,cliCompressImages:h==="image"?I:!1,cliSubsetFonts:h==="image"?$:!1,autoApplyZoom:f,captureDir:A,cliListenerPid:null,cliListenerLogPath:null,cliListenerReadyAt:null};await Ht(A,{recursive:!0}),await kh(le);let Ye=await gh(le.id,A);ne=Ye.pid,await yh(le.id,{cliListenerPid:Ye.pid,cliListenerLogPath:Ye.logPath});let N=15e3,O=await bh(le.id,N);if(!O.cliListenerReadyAt){let vt=async M=>M?_e(M,"utf8").then(J=>J.split(`
|
|
5412
5423
|
`).filter(Boolean).slice(-12).join(`
|
|
5413
|
-
`)
|
|
5414
|
-
|
|
5415
|
-
|
|
5424
|
+
`)).catch(()=>""):"",E=await vt(Ye.logPath),F=await vt(O.chromeLogPath??D.logPath);throw new Error(`capture recorder failed to arm within ${N/1e3}s (listenerReadyAt is null). Every click would be silently dropped, so this session is unusable.
|
|
5425
|
+
Listener log (${Ye.logPath}):
|
|
5426
|
+
${E||"(empty)"}
|
|
5427
|
+
Chrome log (${O.chromeLogPath??D.logPath}):
|
|
5428
|
+
${F||"(empty)"}`)}return await B("inkly_cli_capture_session_started",{runtime:"cli",capture_kind:O.cliCaptureKind??h,record_video:O.cliRecordVideo===!0,auto_apply_zoom:O.autoApplyZoom!==!1,window_width:O.width,window_height:O.height,headless:u?null:R,attached:O.attached,persistent_profile:z!=null,profile_reused:U,connect_to_browser:!!u}),L(),Q({ok:!0,mode:"cli",session:{id:O.id,stateFile:Gn(O.id),createdAt:O.createdAt},browser:{pid:O.chromePid,debuggingUrl:O.browserDebuggingUrl,webSocketDebuggerUrl:O.browserWsUrl,headless:u?null:R,attached:O.attached,profile:z?{dir:z,persistent:!0,reused:U}:null},tab:{targetId:O.targetId,url:O.tabUrl},capture:{kind:O.cliCaptureKind??"image",video:O.cliRecordVideo===!0,recordVideo:O.cliRecordVideo===!0,autoApplyZoom:O.autoApplyZoom!==!1,window:{width:O.width,height:O.height},stepCount:0,automatic:!0,listenerPid:O.cliListenerPid??Ye.pid,listenerReadyAt:O.cliListenerReadyAt}}),0}catch(K){throw await cn({id:"",runtime:"cli",createdAt:"",url:i,name:a,chromePid:D.pid,profileDir:D.profileDir,keepProfile:z!=null||!!u,browserWsUrl:D.wsUrl,browserDebuggingUrl:D.debuggingUrl,chromeLogPath:D.logPath,attached:!!u,tabId:0,tabUrl:"",targetId:"",width:s,height:c,cliScreens:[],captureDir:null,cliListenerPid:ne,cliListenerLogPath:null,cliListenerReadyAt:null}),K}finally{L(),V.close()}}async function Sh(e,t){let n=Np(new Uint8Array(e)),r=Wn(t);await Ht(r,{recursive:!0});for(let[i,a]of Object.entries(n)){let o=i.replace(/\\/g,"/");if(!o||o.endsWith("/"))continue;let s=Wn(r,o);if(s!==r&&!s.startsWith(r+$p))throw new Error(`Unsafe zip entry: ${i}`);await Ht(Zn(s),{recursive:!0}),await mo(s,Buffer.from(a))}}async function _h(e,t,n){let r=Ge(t,"session",n),i=Ge(t,"out",n),a=qn(e,i),o=await Ke(r),s=await ai(r),c=Jn(o.cliScreens??[],s);if(c.length===0)return await cn(o),o.captureDir&&await fe(o.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Yr(o.id),await Qr(o.id),await B("inkly_cli_capture_session_stopped",{runtime:"cli",capture_kind:o.cliCaptureKind??"image",step_count:0,output_bytes:0,unpacked:!1,record_video:o.cliRecordVideo===!0,auto_apply_zoom:o.autoApplyZoom!==!1}),Q({ok:!1,mode:"cli",session:{id:o.id},error:"No steps captured \u2014 nothing to export. Each step comes from a click driven over CDP; the initial page load is not a step. The session has been cleaned up, so no `cancel` is needed.",output:{zipPath:null,demoDir:null,bytes:0,stepCount:0}}),1;let u=o.cliCaptureKind==="html"?await ph({name:o.name,screens:c}):await dh({name:o.name,screens:c,autoApplyZoom:o.autoApplyZoom!==!1,compressImages:o.cliCompressImages===!0,subsetFonts:o.cliSubsetFonts===!0});await Ht(a,{recursive:!0});let p=Buffer.from(u.bytes),h=W(a,u.filename);await mo(h,p);let f=null;return t["no-unpack"]!==!0&&(await Sh(p,a),f=W(a,u.slug)),await cn(o),o.captureDir&&await fe(o.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Yr(o.id),await Qr(o.id),await B("inkly_cli_capture_session_stopped",{runtime:"cli",capture_kind:o.cliCaptureKind??"image",step_count:u.stepCount,output_bytes:p.byteLength,unpacked:t["no-unpack"]!==!0,record_video:o.cliRecordVideo===!0,auto_apply_zoom:o.autoApplyZoom!==!1}),Q({ok:!0,mode:"cli",session:{id:o.id},output:{zipPath:h,demoDir:f,bytes:p.byteLength,stepCount:u.stepCount,stepLabels:u.labels}}),0}async function Ch(e,t){let n=Ge(e,"session",t),r=await Ke(n);return await cn(r),r.captureDir&&await fe(r.captureDir,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{}),await Yr(r.id),await Qr(r.id),await B("inkly_cli_capture_session_cancelled",{runtime:"cli",capture_kind:r.cliCaptureKind??"image",step_count:r.cliScreens?.length??0,record_video:r.cliRecordVideo===!0,auto_apply_zoom:r.autoApplyZoom!==!1}),Q({ok:!0,mode:"cli",session:{id:r.id}}),0}function vo(e){return e.pngPath||e.videoPath||e.htmlPath||e.posterPngPath||`t:${e.capturedAt??""}`}function Kn(e){return W(ri(),`${e}.undo.json`)}async function ai(e){try{let t=JSON.parse(await _e(Kn(e),"utf8"));return Array.isArray(t.droppedKeys)?t.droppedKeys.filter(n=>typeof n=="string"):[]}catch{return[]}}function Jn(e,t){if(t.length===0)return e;let n=new Set(t);return e.filter(r=>!n.has(vo(r)))}async function Qr(e){await fe(Kn(e),{force:!0}).catch(()=>{})}function ei(e,t){return e.click?.label||e.title||`Step ${t+1}`}async function Th(e,t){let n=Ge(e,"session",t),r=await Ke(n),i=await ai(n),a=Jn(r.cliScreens??[],i);if(a.length===0)return Q({ok:!1,mode:"cli",session:{id:r.id},error:"No recorded step to undo.",capture:{stepCount:0}}),1;let o=a[a.length-1],s=ei(o,a.length-1);i.push(vo(o)),await te(Kn(n),`${JSON.stringify({droppedKeys:i},null,2)}
|
|
5429
|
+
`);let c=Jn(r.cliScreens??[],i);return Q({ok:!0,mode:"cli",session:{id:r.id},capture:{undone:s,stepCount:c.length,stepLabels:c.map((d,u)=>ei(d,u))}}),0}async function Ah(e,t){let n=Ge(e,"session",t),r=await Ke(n),i=await ai(n),a=Jn(r.cliScreens??[],i),o=a.map((c,d)=>ei(c,d)),s=a.map((c,d)=>({index:d+1,label:o[d],url:c.sourceUrl||null,kind:c.kind??"image"}));return Q({ok:!0,mode:"cli",session:{id:r.id},capture:{kind:r.cliCaptureKind??"image",ready:!!r.cliListenerReadyAt,browserAlive:r.attached?null:!!(r.chromePid&&ko(r.chromePid)),listenerReadyAt:r.cliListenerReadyAt??null,stepCount:a.length,stepLabels:o,lastLabel:o[o.length-1]??null,steps:s}}),0}async function Yn(e){let{cwd:t,subcommand:n,args:r,kind:i,usage:a}=e;switch(Kp(r),await B("inkly_cli_capture_command_invoked",{capture_kind:i,subcommand:n??"(none)"}),n){case"start":return vh(t,r,i,a);case"stop":return _h(t,r,a);case"cancel":return Ch(r,a);case"status":return Ah(r,a);case"undo":return Th(r,a);case"profiles":return $h();case"nav":return Eh(r);default:return process.stdout.write(a),1}}var X=`inkly capture nav - drive the captured browser (Stagehand)
|
|
5430
|
+
|
|
5431
|
+
Usage:
|
|
5432
|
+
inkly capture nav snapshot --session <id> [--full] [--filter <t|/re/>] [--max-depth <n>] [--json]
|
|
5433
|
+
inkly capture nav refs --session <id>
|
|
5434
|
+
inkly capture nav click <selector> --session <id> [--no-snapshot] [--json]
|
|
5435
|
+
inkly capture nav fill <selector> <value> --session <id> [--enter] [--no-snapshot]
|
|
5436
|
+
inkly capture nav type <text> --session <id> [--delay <ms>] [--no-snapshot]
|
|
5437
|
+
inkly capture nav press <key> --session <id> (alias: key)
|
|
5438
|
+
inkly capture nav select <selector> <value...> --session <id>
|
|
5439
|
+
inkly capture nav scroll <down|up> [pixels] --session <id> (scenic scroll / video over on-screen content; a click auto-scrolls to its own target)
|
|
5440
|
+
inkly capture nav upload <selector> <file...> --session <id>
|
|
5441
|
+
inkly capture nav get <url|title|text|html|value|visible|checked|markdown|box> [<selector>] --session <id>
|
|
5442
|
+
inkly capture nav is <visible|checked> <selector> --session <id>
|
|
5443
|
+
inkly capture nav wait <load|selector|timeout> [<arg>] --session <id> [--state <s>] [--timeout <ms>]
|
|
5444
|
+
inkly capture nav back --session <id> [--wait <state>] [--timeout <ms>]
|
|
5445
|
+
inkly capture nav forward --session <id> [--wait <state>] [--timeout <ms>]
|
|
5446
|
+
inkly capture nav reload --session <id> [--wait <state>] [--timeout <ms>]
|
|
5447
|
+
inkly capture nav mouse click <x> <y> --session <id> [--button <left|right|middle>]
|
|
5448
|
+
inkly capture nav mouse hover <x> <y> --session <id>
|
|
5449
|
+
inkly capture nav mouse scroll <x> <y> <deltaX> <deltaY> --session <id> (prefer \`nav scroll\`)
|
|
5450
|
+
|
|
5451
|
+
<selector> accepts a ref from the last snapshot (@0-12, [0-12], ref=0-12, 0-12)
|
|
5452
|
+
or an XPath/CSS selector. Run \`nav snapshot\` first to populate refs.
|
|
5453
|
+
--wait / wait <load> arg accepts load | domcontentloaded | networkidle.
|
|
5454
|
+
|
|
5455
|
+
Output:
|
|
5456
|
+
\`snapshot\` prints a plain indented accessibility tree (roles + names + @refs)
|
|
5457
|
+
straight to stdout \u2014 no JSON, no maps; read refs directly from it. Action verbs
|
|
5458
|
+
(click/fill/type/select/scroll/back/...) print a one-line status header
|
|
5459
|
+
(\`ok | url=\u2026 | steps=N | <label>\`) then the FRESH trimmed tree, so you rarely
|
|
5460
|
+
need a standalone snapshot. Read the WHOLE returned tree \u2014 do NOT pipe through
|
|
5461
|
+
\`head\`/\`sed\` (truncating it cuts the refs and forces a wasteful re-snapshot);
|
|
5462
|
+
bound a long tree with \`--filter\`/\`--max-depth\` instead. Add \`--full\` to
|
|
5463
|
+
snapshot for the untrimmed tree, \`--no-snapshot\` to suppress the post-action
|
|
5464
|
+
tree, and \`--json\` for the structured object (with urlMap/xpathMap on snapshot).
|
|
5465
|
+
A driving verb fires real browser input, which the recorder captures as a step \u2014
|
|
5466
|
+
nav never writes steps.
|
|
5467
|
+
`;async function Ph(e){let n=(await Ke(e).catch(()=>null))?.cliScreens??[],r=n[n.length-1];return{steps:n.length,lastLabel:r&&(r.click?.label||r.title)||null,lastKind:r?.kind??null}}function oi(e){return e.json===!0}function Le(e){return e["no-snapshot"]===!0||e.snapshot===!1}function Ih(e,t){if(oi(t)){Q({ok:!0,...e});return}let n=typeof e.tree=="string"?e.tree:"";process.stdout.write(`${n}
|
|
5468
|
+
`)}async function Oe(e,t,n){if(oi(t)){Q({ok:!0,...e});return}let r=e,i=r.steps!==void 0?{steps:r.steps,lastLabel:r.lastLabel??null}:await Ph(n),a=r.snapshot?.url??"",o=["ok"];a&&o.push(`url=${a}`),i.steps!==null&&o.push(`steps=${i.steps}`),i.lastLabel&&o.push(i.lastLabel),process.stdout.write(`${o.join(" | ")}
|
|
5469
|
+
`);let s=r.snapshot?.tree;typeof s=="string"&&s.length>0&&process.stdout.write(`${s}
|
|
5470
|
+
`)}async function Eh(e){let t=typeof e._[2]=="string"?e._[2]:void 0;if(!t)return process.stdout.write(X),1;let n=Ge(e,"session",X),r=await Ke(n).catch(()=>null);if(!r)throw new Error(`no capture session "${n}" \u2014 run \`inkly capture start\` first`);if(r.runtime!=="cli")throw new Error("nav is only available for cli runtime sessions");let i=Gr(n);switch(t){case"snapshot":{let a=await G(i,"snapshot",{full:e.full===!0,json:oi(e),filter:Se(e,"filter"),maxDepth:Bn(e,"max-depth")});return Ih(a,e),0}case"refs":{let a=await G(i,"refs",{});return Q({ok:!0,...a}),0}case"click":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(!a)throw new Error(`nav click requires a <selector>
|
|
5471
|
+
|
|
5472
|
+
`+X);let o=await G(i,"click",{selector:a,noSnapshot:Le(e)});return await Oe(o,e,n),0}case"fill":{let a=typeof e._[3]=="string"?e._[3]:void 0,o=typeof e._[4]=="string"?e._[4]:void 0;if(!a||o===void 0)throw new Error(`nav fill requires <selector> <value>
|
|
5473
|
+
|
|
5474
|
+
`+X);let s=await G(i,"fill",{selector:a,value:o,pressEnter:e.enter===!0,noSnapshot:Le(e)});return await Oe(s,e,n),0}case"type":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(a===void 0)throw new Error(`nav type requires <text>
|
|
5475
|
+
|
|
5476
|
+
`+X);let o=await G(i,"type",{text:a,delay:Bn(e,"delay"),noSnapshot:Le(e)});return await Oe(o,e,n),0}case"press":case"key":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(!a)throw new Error(`nav press requires a <key>
|
|
5477
|
+
|
|
5478
|
+
`+X);let o=await G(i,"key",{key:a,noSnapshot:Le(e)});return await Oe(o,e,n),0}case"scroll":{let o=(typeof e._[3]=="string"?e._[3]:void 0)==="up"?"up":"down",s=ln(e._[4]),c=await G(i,"scroll",{direction:o,amount:s!==void 0&&s>0?s:void 0,noSnapshot:Le(e)});return await Oe(c,e,n),0}case"select":{let a=typeof e._[3]=="string"?e._[3]:void 0,o=e._.slice(4).filter(c=>typeof c=="string");if(!a||o.length===0)throw new Error(`nav select requires <selector> <value...>
|
|
5479
|
+
|
|
5480
|
+
`+X);let s=await G(i,"select",{selector:a,values:o,noSnapshot:Le(e)});return await Oe(s,e,n),0}case"upload":{let a=typeof e._[3]=="string"?e._[3]:void 0,o=e._.slice(4).filter(c=>typeof c=="string").map(c=>qn(process.cwd(),c));if(!a||o.length===0)throw new Error(`nav upload requires <selector> <file...>
|
|
5481
|
+
|
|
5482
|
+
`+X);let s=await G(i,"upload",{selector:a,files:o});return Q({ok:!0,...s}),0}case"get":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(!a)throw new Error(`nav get requires a target
|
|
5483
|
+
|
|
5484
|
+
`+X);let o=typeof e._[4]=="string"?e._[4]:void 0,s=await G(i,"get",{what:a,selector:o});return Q({ok:!0,...s}),0}case"is":{let a=typeof e._[3]=="string"?e._[3]:void 0,o=typeof e._[4]=="string"?e._[4]:void 0;if(!a||!o)throw new Error(`nav is requires <visible|checked> <selector>
|
|
5485
|
+
|
|
5486
|
+
`+X);let s=await G(i,"is",{check:a,selector:o});return Q({ok:!0,...s}),0}case"wait":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(!a)throw new Error(`nav wait requires <load|selector|timeout>
|
|
5487
|
+
|
|
5488
|
+
`+X);let o=/^\d+$/.test(a),s=o?"timeout":a,c=o?a:typeof e._[4]=="string"?e._[4]:void 0,d=await G(i,"wait",{type:s,arg:c,state:Se(e,"state"),timeoutMs:Bn(e,"timeout")});return Q({ok:!0,...d}),0}case"back":case"forward":case"reload":{let a=await G(i,t,{waitUntil:Se(e,"wait"),timeoutMs:Bn(e,"timeout"),noSnapshot:Le(e)});return await Oe(a,e,n),0}case"mouse":{let a=typeof e._[3]=="string"?e._[3]:void 0;if(a==="click"){let o=ln(e._[4]),s=ln(e._[5]);if(o===void 0||s===void 0)throw new Error(`nav mouse click requires <x> <y>
|
|
5489
|
+
|
|
5490
|
+
`+X);let c=await G(i,"mouse.click",{x:o,y:s,button:Se(e,"button"),noSnapshot:Le(e)});return await Oe(c,e,n),0}if(a==="hover"){let o=ln(e._[4]),s=ln(e._[5]);if(o===void 0||s===void 0)throw new Error(`nav mouse hover requires <x> <y>
|
|
5491
|
+
|
|
5492
|
+
`+X);let c=await G(i,"mouse.hover",{x:o,y:s});return Q({ok:!0,...c}),0}if(a==="scroll"){let o=Rh(),s=o[0],c=o[1],d=o[2],u=o[3];if(s===void 0||c===void 0||d===void 0||u===void 0)throw new Error(`nav mouse scroll requires <x> <y> <deltaX> <deltaY>
|
|
5493
|
+
|
|
5494
|
+
`+X);let p=await G(i,"mouse.scroll",{x:s,y:c,deltaX:d,deltaY:u,noSnapshot:Le(e)});return await Oe(p,e,n),0}throw new Error(`nav mouse requires <click|hover|scroll>
|
|
5495
|
+
|
|
5496
|
+
`+X)}default:return process.stdout.write(X),1}}function ln(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim()){let t=Number(e);return Number.isFinite(t)?t:void 0}}function Rh(){let e=process.argv.slice(2),t=e.findIndex(r=>r==="scroll"),n=[];if(t!==-1)for(let r=t+1;r<e.length&&n.length<4;r+=1){let i=e[r];if(i.startsWith("--"))break;/^-?\d+(\.\d+)?$/.test(i)&&n.push(Number(i))}return[n[0],n[1],n[2],n[3]]}function Bn(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t],r=typeof n=="number"?n:Number(n);return Number.isFinite(r)?r:void 0}async function $h(){let e=yo(),t=await ho(e,{withFileTypes:!0}).catch(()=>[]),n=[];for(let r of t){if(!r.isDirectory())continue;let i=W(e,r.name),a=je(W(i,"Default")),o=je(W(i,"Default","Network","Cookies"))||je(W(i,"Default","Cookies"));n.push({name:r.name,dir:i,initialized:a,hasCookies:o})}return await B("inkly_cli_capture_profiles_listed",{profile_count:n.length,initialized_count:n.filter(r=>r.initialized).length,cookie_count:n.filter(r=>r.hasCookies).length}),Q({ok:!0,profilesDir:e,profiles:n}),0}async function So(e){let{cwd:t,subcommand:n,args:r}=e;if(r.html===!0)throw new Error("inkly capture is image/video only. For HTML snapshot capture use `inkly capture-html`.");for(let i of["block-videos","block-video","compress-images","compress-image","subset-fonts","subset-font"])if(Object.prototype.hasOwnProperty.call(r,i))throw new Error(`--${i} only applies to HTML capture. Use \`inkly capture-html --${i}\`.`);return Yn({cwd:t,subcommand:n,args:r,kind:"image",usage:dn})}async function _o(e){let{cwd:t,subcommand:n,args:r}=e;return Yn({cwd:t,subcommand:n,args:r,kind:"html",usage:un})}var To=`inkly \u2014 Inkly CLI
|
|
5416
5497
|
|
|
5417
5498
|
Usage:
|
|
5418
5499
|
inkly init <name> [--layout <layout>] Scaffold a new demo hub.
|
|
@@ -5434,7 +5515,7 @@ Usage:
|
|
|
5434
5515
|
inkly help [command] Show CLI help.
|
|
5435
5516
|
|
|
5436
5517
|
Run \`inkly <command> --help\` for more.
|
|
5437
|
-
`,
|
|
5518
|
+
`,li=`inkly init \u2014 scaffold a new demo hub
|
|
5438
5519
|
|
|
5439
5520
|
Usage:
|
|
5440
5521
|
inkly init <name> [--layout <layout>]
|
|
@@ -5445,7 +5526,7 @@ Arguments:
|
|
|
5445
5526
|
Options:
|
|
5446
5527
|
--layout <layout> Hub index layout to write to inkly.json.
|
|
5447
5528
|
One of: sidebar, tabs.
|
|
5448
|
-
`,
|
|
5529
|
+
`,Ao=`inkly add \u2014 scaffold a new demo in the current hub
|
|
5449
5530
|
|
|
5450
5531
|
Usage:
|
|
5451
5532
|
inkly add <name> [--collection <name>]
|
|
@@ -5459,7 +5540,7 @@ Options:
|
|
|
5459
5540
|
--collection <name> Add the demo to this collection in inkly.json.
|
|
5460
5541
|
Creates the collection if it doesn't exist. When
|
|
5461
5542
|
omitted, the demo is not added to any collection.
|
|
5462
|
-
`,
|
|
5543
|
+
`,Po=`inkly demo \u2014 alias of \`inkly add\`
|
|
5463
5544
|
|
|
5464
5545
|
Usage:
|
|
5465
5546
|
inkly demo <slug> [--collection <name>]
|
|
@@ -5471,7 +5552,7 @@ Options:
|
|
|
5471
5552
|
--collection <name> Add the demo to this collection in inkly.json.
|
|
5472
5553
|
Creates the collection if it doesn't exist. When
|
|
5473
5554
|
omitted, the demo is not added to any collection.
|
|
5474
|
-
`,
|
|
5555
|
+
`,Io=`inkly validate \u2014 validate a demo hub
|
|
5475
5556
|
|
|
5476
5557
|
Usage:
|
|
5477
5558
|
inkly validate [--json] [--strict]
|
|
@@ -5479,7 +5560,7 @@ Usage:
|
|
|
5479
5560
|
Options:
|
|
5480
5561
|
--json Print machine-readable JSON.
|
|
5481
5562
|
--strict Treat warnings as failures.
|
|
5482
|
-
`,
|
|
5563
|
+
`,Eo=`inkly lock \u2014 pin the runtime via inkly.lock
|
|
5483
5564
|
|
|
5484
5565
|
Usage:
|
|
5485
5566
|
inkly lock [--json] [--local <path>]
|
|
@@ -5500,7 +5581,7 @@ Environment:
|
|
|
5500
5581
|
BUNDLES_R2_PUBLIC_BASE_URL
|
|
5501
5582
|
Override the bundles bucket's public base URL
|
|
5502
5583
|
(default https://www.runtime.inklyai.dev). Useful for staging.
|
|
5503
|
-
`,
|
|
5584
|
+
`,Ro=`inkly login \u2014 connect to the hosted app
|
|
5504
5585
|
|
|
5505
5586
|
Usage:
|
|
5506
5587
|
inkly login [--no-open]
|
|
@@ -5512,11 +5593,11 @@ overridden on the command line.
|
|
|
5512
5593
|
Options:
|
|
5513
5594
|
--no-open Print the grant URL without opening a browser.
|
|
5514
5595
|
--token <token> Automation fallback: save an existing API token.
|
|
5515
|
-
|
|
5596
|
+
`,$o=`inkly logout \u2014 remove saved platform API credentials
|
|
5516
5597
|
|
|
5517
5598
|
Usage:
|
|
5518
5599
|
inkly logout
|
|
5519
|
-
`,
|
|
5600
|
+
`,Do=`inkly sync \u2014 upload local capture blobs to CDN
|
|
5520
5601
|
|
|
5521
5602
|
Usage:
|
|
5522
5603
|
inkly sync [--demo <slug>] [--dry-run] [--json]
|
|
@@ -5525,7 +5606,7 @@ Options:
|
|
|
5525
5606
|
--demo <slug> Sync one demo instead of every demo.
|
|
5526
5607
|
--dry-run Report pending uploads without changing files.
|
|
5527
5608
|
--json Print machine-readable JSON.
|
|
5528
|
-
`,
|
|
5609
|
+
`,No=`inkly snapshot \u2014 publish a standalone snapshot of one demo
|
|
5529
5610
|
|
|
5530
5611
|
Usage:
|
|
5531
5612
|
inkly snapshot <demo-path> [--json]
|
|
@@ -5542,7 +5623,7 @@ Arguments:
|
|
|
5542
5623
|
Options:
|
|
5543
5624
|
--demo <slug> Select the demo by slug instead of by path.
|
|
5544
5625
|
--json Print machine-readable JSON.
|
|
5545
|
-
`,
|
|
5626
|
+
`,Mo=`inkly dev \u2014 start the local preview server
|
|
5546
5627
|
|
|
5547
5628
|
Usage:
|
|
5548
5629
|
inkly dev [<path>] [--port <n>]
|
|
@@ -5558,33 +5639,33 @@ Arguments:
|
|
|
5558
5639
|
Options:
|
|
5559
5640
|
--port <n> Preferred port. Defaults to 3000; if taken, the CLI
|
|
5560
5641
|
tries the next available port. Must be 1-65535.
|
|
5561
|
-
`,
|
|
5642
|
+
`,Lo=`inkly update \u2014 update the globally installed CLI
|
|
5562
5643
|
|
|
5563
5644
|
Usage:
|
|
5564
5645
|
inkly update [--dry-run]
|
|
5565
5646
|
|
|
5566
5647
|
Options:
|
|
5567
5648
|
--dry-run Print the update command without running it.
|
|
5568
|
-
`,
|
|
5649
|
+
`,Oo=`inkly doctor \u2014 run local diagnostics
|
|
5569
5650
|
|
|
5570
5651
|
Usage:
|
|
5571
5652
|
inkly doctor [--json]
|
|
5572
5653
|
|
|
5573
5654
|
Options:
|
|
5574
5655
|
--json Print machine-readable JSON.
|
|
5575
|
-
`,
|
|
5656
|
+
`,jo=`inkly status \u2014 show local CLI status
|
|
5576
5657
|
|
|
5577
5658
|
Usage:
|
|
5578
5659
|
inkly status [--json]
|
|
5579
5660
|
|
|
5580
5661
|
Options:
|
|
5581
5662
|
--json Print machine-readable JSON.
|
|
5582
|
-
`,
|
|
5663
|
+
`,zo=`inkly version \u2014 print the CLI version
|
|
5583
5664
|
|
|
5584
5665
|
Usage:
|
|
5585
5666
|
inkly version
|
|
5586
5667
|
inkly --version
|
|
5587
|
-
`,
|
|
5668
|
+
`,ci=`inkly help \u2014 show command help
|
|
5588
5669
|
|
|
5589
5670
|
Usage:
|
|
5590
5671
|
inkly help [command]
|
|
@@ -5608,25 +5689,25 @@ Commands:
|
|
|
5608
5689
|
capture Capture an image/video walkthrough for an agent.
|
|
5609
5690
|
capture-html
|
|
5610
5691
|
Capture a self-contained HTML walkthrough for an agent.
|
|
5611
|
-
`,
|
|
5612
|
-
|
|
5613
|
-
${
|
|
5614
|
-
|
|
5615
|
-
`+
|
|
5616
|
-
`),await
|
|
5617
|
-
|
|
5618
|
-
`+
|
|
5619
|
-
`),await
|
|
5620
|
-
`),await
|
|
5621
|
-
`),await
|
|
5622
|
-
`),await
|
|
5623
|
-
`),await
|
|
5624
|
-
`),await
|
|
5625
|
-
`),await
|
|
5626
|
-
`),await
|
|
5627
|
-
`),1;try{let s=await
|
|
5628
|
-
`),
|
|
5629
|
-
`),await
|
|
5630
|
-
|
|
5631
|
-
${
|
|
5632
|
-
`),await
|
|
5692
|
+
`,Oh={add:Ao,demo:Po,dev:Mo,doctor:Oo,capture:dn,"capture-html":un,help:ci,init:li,lock:Eo,login:Ro,logout:$o,snapshot:No,status:jo,sync:Do,update:Lo,validate:Io,version:zo};function jh(e,t){let n=Mh(e)?e:Lh(t,e);if(si(n))try{if(Nh(n).isFile())return n;let i=Co(n,"manifest.json");if(si(i))return i;let a=Co(n,"dist","manifest.json");if(si(a))return a}catch{}return n}function pn(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t];return typeof n=="string"?n:""}function zh(e){let t=new Set(["_","api-base","token","url","name","out","session"]);return Object.keys(e).filter(n=>!t.has(n)).filter(n=>e[n]!==!1&&e[n]!==void 0).sort()}async function Uh(e){let t=Dh(e,{alias:{h:"help",p:"port",v:"version"},boolean:["auto-apply-zoom","block-videos","check","compress-images","dry-run","enter","full","headed","headless","html","help","json","keep-profile","no-open","no-snapshot","no-unpack","record-video","strict","subset-fonts","version","video","zoom"],string:["browser","collection","connect-to-browser","demo","height","layout","local","name","out","port","profile","runtime","session","timeout","token","url","width","window-size"]}),[n,...r]=t._,i=n??(t.version?"version":t.help?"help":"(none)");if(await B("inkly_cli_invoked",{command:i,subcommand:typeof r[0]=="string"?r[0]:void 0,option_keys:zh(t),json:!!t.json,help:!!t.help}),t.version&&!n)return await Ir(),0;if(!n||t.help&&!n)return process.stdout.write(To),t.help?0:1;switch(n){case"help":{let a=r[0];if(!a)return process.stdout.write(ci),0;let o=Oh[a];return o?(process.stdout.write(o),0):(process.stderr.write(`inkly help: unknown command "${a}"
|
|
5693
|
+
|
|
5694
|
+
${ci}`),1)}case"init":{if(t.help)return process.stdout.write(li),0;let a=r[0];if(!a)return process.stderr.write(`inkly init: missing <name> argument
|
|
5695
|
+
|
|
5696
|
+
`+li),1;let o=pn(t,"layout");try{return await ua({name:a,cwd:process.cwd(),layout:o}),0}catch(s){return process.stderr.write(`inkly init failed: ${s.message}
|
|
5697
|
+
`),await B("inkly_cli_failed",{command:"init"}),await se("init",s),1}}case"add":case"demo":{let a=n==="add"?Ao:Po;if(t.help)return process.stdout.write(a),0;let o=r[0];if(!o)return process.stderr.write(`inkly ${n}: missing <name> argument
|
|
5698
|
+
|
|
5699
|
+
`+a),1;let s=typeof t.collection=="string"&&t.collection.length>0?t.collection:void 0;try{return await Ca({slug:o,cwd:process.cwd(),collection:s}),0}catch(c){return process.stderr.write(`inkly ${n} failed: ${c.message}
|
|
5700
|
+
`),await B("inkly_cli_failed",{command:n}),await se(n,c),1}}case"validate":return t.help?(process.stdout.write(Io),0):(await Mn({cwd:process.cwd(),json:!!t.json,strict:!!t.strict})).ok?0:1;case"lock":{if(t.help)return process.stdout.write(Eo),0;try{let a=pn(t,"local");return(await In({cwd:process.cwd(),check:!!t.check,json:!!t.json,manifestPath:a?jh(a,process.cwd()):void 0})).ok?0:1}catch(a){return process.stderr.write(`inkly lock failed: ${a.message}
|
|
5701
|
+
`),await B("inkly_cli_failed",{command:"lock"}),await se("lock",a),1}}case"version":return t.help?(process.stdout.write(zo),0):(await Ir(),0);case"update":{if(t.help)return process.stdout.write(Lo),0;try{return await Aa({dryRun:!!t["dry-run"]}),0}catch(a){return process.stderr.write(`inkly update failed: ${a.message}
|
|
5702
|
+
`),await B("inkly_cli_failed",{command:"update"}),await se("update",a),1}}case"doctor":return t.help?(process.stdout.write(Oo),0):(await Ra({cwd:process.cwd(),json:!!t.json})).ok?0:1;case"login":{if(t.help)return process.stdout.write(Ro),0;try{return await Oa({cwd:process.cwd(),local:process.env.INKLY_LOCAL==="1",token:pn(t,"token"),open:!t["no-open"]}),0}catch(a){return process.stderr.write(`inkly login failed: ${a.message}
|
|
5703
|
+
`),await B("inkly_cli_failed",{command:"login"}),await se("login",a),1}}case"logout":return t.help?(process.stdout.write($o),0):(await ja(),0);case"status":return t.help?(process.stdout.write(jo),0):(await za({cwd:process.cwd(),json:!!t.json})).loggedIn?0:1;case"sync":{if(t.help)return process.stdout.write(Do),0;try{return await Un({cwd:process.cwd(),demo:pn(t,"demo"),dryRun:!!t["dry-run"],json:!!t.json}),0}catch(a){return process.stderr.write(`inkly sync failed: ${a.message}
|
|
5704
|
+
`),await B("inkly_cli_failed",{command:"sync"}),await se("sync",a),1}}case"snapshot":{if(t.help)return process.stdout.write(No),0;try{return await Ga({cwd:process.cwd(),path:r[0],demo:pn(t,"demo"),json:!!t.json}),0}catch(a){return process.stderr.write(`inkly snapshot failed: ${a.message}
|
|
5705
|
+
`),await B("inkly_cli_failed",{command:"snapshot"}),await se("snapshot",a),1}}case"capture":{if(t.help)return process.stdout.write(dn),0;try{return await So({cwd:process.cwd(),subcommand:r[0],args:t})}catch(a){return process.stderr.write(`inkly capture failed: ${a.message}
|
|
5706
|
+
`),await B("inkly_cli_failed",{command:"capture",subcommand:r[0]}),await se("capture",a),1}}case"capture-html":{if(t.help)return process.stdout.write(un),0;try{return await _o({cwd:process.cwd(),subcommand:r[0],args:t})}catch(a){return process.stderr.write(`inkly capture-html failed: ${a.message}
|
|
5707
|
+
`),await B("inkly_cli_failed",{command:"capture-html",subcommand:r[0]}),await se("capture-html",a),1}}case"dev":{if(t.help)return process.stdout.write(Mo),0;let a=t.port,o=typeof a=="number"?a:typeof a=="string"?Number(a):3e3;if(!Number.isInteger(o)||o<1||o>65535)return process.stderr.write(`inkly dev: invalid --port value; expected an integer from 1 to 65535
|
|
5708
|
+
`),1;try{let s=await va({cwd:process.cwd(),port:o,path:r[0]});return await new Promise(c=>{let d=()=>{s.close().catch(u=>{process.stderr.write(`inkly dev: error during shutdown: ${u.message}
|
|
5709
|
+
`),B("inkly_cli_failed",{command:"dev.shutdown"}),se("dev.shutdown",u)}).finally(()=>c())};process.once("SIGINT",d),process.once("SIGTERM",d)}),0}catch(s){return process.stderr.write(`inkly dev failed: ${s.message}
|
|
5710
|
+
`),await B("inkly_cli_failed",{command:"dev"}),await se("dev",s),1}}default:return process.stderr.write(`inkly: unknown command "${n}"
|
|
5711
|
+
|
|
5712
|
+
${To}`),1}}Ka();Uh(process.argv.slice(2)).then(async e=>{await B("inkly_cli_exited",{command:process.argv[2]??"(none)",exit_code:e}),await Lr(),await Ya(),process.exit(e)},async e=>{process.stderr.write(`inkly: ${e.message}
|
|
5713
|
+
`),await B("inkly_cli_failed",{command:"main"}),await se("main",e),await Lr(),process.exit(1)});
|