captionseasy-transcribe 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ishaan Gupta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,22 @@
1
- # Temporary Holding Version
1
+ # captionseasy-transcribe
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ This is the optional **transcription add-on** for [`captionseasy`](https://www.npmjs.com/package/captionseasy). It runs local Whisper speech-to-text with word timestamps:
4
+ - Whisper runs through transformers.js on onnxruntime-node. The prebuilt binaries ship in the npm package, so there is no compiler, no Python and no API key.
5
+ - The models are the same ones the CaptionsEasy studio uses: `whisper-base` (English, or auto-detect) and a Hinglish fine-tune that writes Hindi/English in Roman letters.
6
+
7
+ ```bash
8
+ npm i captionseasy captionseasy-transcribe
9
+ npx captionseasy transcribe talk.mp4 --out talk.words.json # [{ text, startMs, endMs }]
10
+ ```
11
+
12
+ ```ts
13
+ import { transcribe } from "captionseasy"; // loads this add-on on demand
14
+ const { words } = await transcribe("talk.mp4", { language: "en" }); // "en" | "hinglish" | "auto"
15
+ ```
16
+
17
+ **Size:**
18
+ - About 540 MB installed, mostly the onnxruntime binaries.
19
+ - The speech model downloads once into your per-user cache: about 205 MB for English, about 77 MB for Hinglish. Set `CAPTIONSEASY_CACHE` to put it somewhere else.
20
+ - After that download it works offline.
21
+
22
+ **Licence:** MIT. Whisper is MIT-licensed.
@@ -0,0 +1,6 @@
1
+ import type { TranscribeOptions, Transcript } from "./types.js";
2
+ /** Transcribe a local video or audio file into timed words. */
3
+ export declare const transcribe: (videoPath: string, opts?: TranscribeOptions) => Promise<Transcript>;
4
+ /** Free the speech models held in memory (long-running hosts). */
5
+ export declare const unloadModels: () => Promise<void>;
6
+ export type { Language, TranscribeOptions, Transcript, TranscriptWord } from "./types.js";
package/dist/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ import { createRequire as __ceCreateRequire } from 'node:module'; const require = __ceCreateRequire(import.meta.url);
2
+ var Nt=Object.defineProperty;var Dt=(r,e)=>{for(var t in e)Nt(r,t,{get:e[t],enumerable:!0})};import{performance as At}from"node:perf_hooks";var ke=()=>globalThis.crypto.randomUUID().replace(/-/g,"").slice(0,12);var o={};Dt(o,{BRAND:()=>ir,DIRTY:()=>q,EMPTY_PATH:()=>Lt,INVALID:()=>y,NEVER:()=>Ur,OK:()=>T,ParseStatus:()=>C,Schema:()=>v,ZodAny:()=>Z,ZodArray:()=>B,ZodBigInt:()=>X,ZodBoolean:()=>Y,ZodBranded:()=>Se,ZodCatch:()=>ce,ZodDate:()=>K,ZodDefault:()=>ie,ZodDiscriminatedUnion:()=>Ae,ZodEffects:()=>j,ZodEnum:()=>ae,ZodError:()=>E,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>Re,ZodIntersection:()=>re,ZodIssueCode:()=>l,ZodLazy:()=>ne,ZodLiteral:()=>se,ZodMap:()=>ge,ZodNaN:()=>xe,ZodNativeEnum:()=>oe,ZodNever:()=>I,ZodNull:()=>ee,ZodNullable:()=>$,ZodNumber:()=>G,ZodObject:()=>A,ZodOptional:()=>O,ZodParsedType:()=>f,ZodPipeline:()=>Me,ZodPromise:()=>U,ZodReadonly:()=>ue,ZodRecord:()=>Oe,ZodSchema:()=>v,ZodSet:()=>ye,ZodString:()=>V,ZodSymbol:()=>fe,ZodTransformer:()=>j,ZodTuple:()=>P,ZodType:()=>v,ZodUndefined:()=>Q,ZodUnion:()=>te,ZodUnknown:()=>F,ZodVoid:()=>he,addIssueToContext:()=>m,any:()=>gr,array:()=>_r,bigint:()=>lr,boolean:()=>nt,coerce:()=>Zr,custom:()=>et,date:()=>pr,datetimeRegex:()=>Ke,defaultErrorMap:()=>W,discriminatedUnion:()=>Sr,effect:()=>Pr,enum:()=>Ir,function:()=>Or,getErrorMap:()=>le,getParsedType:()=>D,instanceof:()=>ur,intersection:()=>Mr,isAborted:()=>Te,isAsync:()=>pe,isDirty:()=>Ee,isValid:()=>z,late:()=>cr,lazy:()=>Rr,literal:()=>jr,makeIssue:()=>we,map:()=>Er,nan:()=>dr,nativeEnum:()=>Nr,never:()=>xr,null:()=>hr,nullable:()=>Wr,number:()=>rt,object:()=>vr,objectUtil:()=>je,oboolean:()=>Vr,onumber:()=>zr,optional:()=>$r,ostring:()=>Br,pipeline:()=>Fr,preprocess:()=>Lr,promise:()=>Dr,quotelessJson:()=>Pt,record:()=>Tr,set:()=>Ar,setErrorMap:()=>Wt,strictObject:()=>kr,string:()=>tt,symbol:()=>mr,transformer:()=>Pr,tuple:()=>Cr,undefined:()=>fr,union:()=>wr,unknown:()=>yr,util:()=>k,void:()=>br});var k;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{let a={};for(let c of s)a[c]=c;return a},r.getValidEnumValues=s=>{let a=r.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),c={};for(let i of a)c[i]=s[i];return r.objectValues(c)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let c in s)Object.prototype.hasOwnProperty.call(s,c)&&a.push(c);return a},r.find=(s,a)=>{for(let c of s)if(a(c))return c},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(k||(k={}));var je;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(je||(je={}));var f=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}};var l=k.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"]),Pt=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),E=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let c of a.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)n._errors.push(t(c));else{let i=n,d=0;for(;d<c.path.length;){let u=c.path[d];d===c.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(c))):i[u]=i[u]||{_errors:[]},i=i[u],d++}}};return s(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let s of this.issues)if(s.path.length>0){let a=s.path[0];t[a]=t[a]||[],t[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};E.create=r=>new E(r);var $t=(r,e)=>{let t;switch(r.code){case l.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,k.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${k.joinValues(r.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${k.joinValues(r.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${k.joinValues(r.options)}, received '${r.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:k.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case l.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case l.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,k.assertNever(r)}return{message:t}},W=$t;var He=W;function Wt(r){He=r}function le(){return He}var we=r=>{let{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],c={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let i="",d=n.filter(u=>!!u).slice().reverse();for(let u of d)i=u(c,{data:e,defaultError:i}).message;return{...s,path:a,message:i}},Lt=[];function m(r,e){let t=le(),n=we({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===W?void 0:W].filter(s=>!!s)});r.common.issues.push(n)}var C=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let s of t){if(s.status==="aborted")return y;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let a=await s.key,c=await s.value;n.push({key:a,value:c})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:a,value:c}=s;if(a.status==="aborted"||c.status==="aborted")return y;a.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(n[a.value]=c.value)}return{status:e.value,value:n}}},y=Object.freeze({status:"aborted"}),q=r=>({status:"dirty",value:r}),T=r=>({status:"valid",value:r}),Te=r=>r.status==="aborted",Ee=r=>r.status==="dirty",z=r=>r.status==="valid",pe=r=>typeof Promise<"u"&&r instanceof Promise;var h;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));var R=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}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}},qe=(r,e)=>{if(z(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new E(r.common.issues);return this._error=t,this._error}}};function b(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(c,i)=>{let{message:d}=r;return c.code==="invalid_enum_value"?{message:d??i.defaultError}:typeof i.data>"u"?{message:d??n??i.defaultError}:c.code!=="invalid_type"?{message:i.defaultError}:{message:d??t??i.defaultError}},description:s}}var v=class{get description(){return this._def.description}_getType(e){return D(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new C,ctx:{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(pe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},s=this._parseSync({data:e,path:n.path,parent:n});return qe(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return z(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>z(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(pe(s)?s:Promise.resolve(s));return qe(n,a)}refine(e,t){let n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{let c=e(s),i=()=>a.addIssue({code:l.custom,...n(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(d=>d?!0:(i(),!1)):c?!0:(i(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new j({schema:this,typeName:x.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:t=>this["~validate"](t)}}optional(){return O.create(this,this._def)}nullable(){return $.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return B.create(this)}promise(){return U.create(this,this._def)}or(e){return te.create([this,e],this._def)}and(e){return re.create(this,e,this._def)}transform(e){return new j({...b(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new ie({...b(this._def),innerType:this,defaultValue:t,typeName:x.ZodDefault})}brand(){return new Se({typeName:x.ZodBranded,type:this,...b(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new ce({...b(this._def),innerType:this,catchValue:t,typeName:x.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Me.create(this,e)}readonly(){return ue.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ft=/^c[^\s-]{8,}$/i,Bt=/^[0-9a-z]+$/,zt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Vt=/^[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,Zt=/^[a-z0-9_-]{21}$/i,Ut=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Jt=/^[-+]?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)?)??$/,Ht=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,qt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ie,Gt=/^(?:(?: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])$/,Xt=/^(?:(?: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])$/,Yt=/^(([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]))$/,Kt=/^(([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])$/,Qt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,er=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Xe="((\\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])))",tr=new RegExp(`^${Xe}$`);function Ye(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function rr(r){return new RegExp(`^${Ye(r)}$`)}function Ke(r){let e=`${Xe}T${Ye(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function nr(r,e){return!!((e==="v4"||!e)&&Gt.test(r)||(e==="v6"||!e)&&Yt.test(r))}function sr(r,e){if(!Ut.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function ar(r,e){return!!((e==="v4"||!e)&&Xt.test(r)||(e==="v6"||!e)&&Kt.test(r))}var V=class r extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_type,expected:f.string,received:a.parsedType}),y}let n=new C,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let c=e.data.length>a.value,i=e.data.length<a.value;(c||i)&&(s=this._getOrReturnCtx(e,s),c?m(s,{code:l.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&m(s,{code:l.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Ht.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ie||(Ie=new RegExp(qt,"u")),Ie.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Vt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")Zt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"nanoid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Ft.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Bt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")zt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:l.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:l.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:l.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ke(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?tr.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?rr(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:l.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Jt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"duration",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?nr(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?sr(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"jwt",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?ar(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cidr",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Qt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64",code:l.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?er.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64url",code:l.invalid_string,message:a.message}),n.dirty()):k.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:l.invalid_string,...h.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...h.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};V.create=r=>new V({checks:[],typeName:x.ZodString,coerce:r?.coerce??!1,...b(r)});function or(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=Number.parseInt(r.toFixed(s).replace(".","")),c=Number.parseInt(e.toFixed(s).replace(".",""));return a%c/10**s}var G=class r extends v{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)!==f.number){let a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_type,expected:f.number,received:a.parsedType}),y}let n,s=new C;for(let a of this._def.checks)a.kind==="int"?k.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:l.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?or(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:l.not_finite,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:h.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};G.create=r=>new G({checks:[],typeName:x.ZodNumber,coerce:r?.coerce||!1,...b(r)});var X=class r extends v{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)!==f.bigint)return this._getInvalidInput(e);let n,s=new C;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:l.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return m(t,{code:l.invalid_type,expected:f.bigint,received:t.parsedType}),y}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:h.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};X.create=r=>new X({checks:[],typeName:x.ZodBigInt,coerce:r?.coerce??!1,...b(r)});var Y=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:f.boolean,received:n.parsedType}),y}return T(e.data)}};Y.create=r=>new Y({typeName:x.ZodBoolean,coerce:r?.coerce||!1,...b(r)});var K=class r extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_type,expected:f.date,received:a.parsedType}),y}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return m(a,{code:l.invalid_date}),y}let n=new C,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:l.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:l.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):k.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};K.create=r=>new K({checks:[],coerce:r?.coerce||!1,typeName:x.ZodDate,...b(r)});var fe=class extends v{_parse(e){if(this._getType(e)!==f.symbol){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:f.symbol,received:n.parsedType}),y}return T(e.data)}};fe.create=r=>new fe({typeName:x.ZodSymbol,...b(r)});var Q=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:f.undefined,received:n.parsedType}),y}return T(e.data)}};Q.create=r=>new Q({typeName:x.ZodUndefined,...b(r)});var ee=class extends v{_parse(e){if(this._getType(e)!==f.null){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:f.null,received:n.parsedType}),y}return T(e.data)}};ee.create=r=>new ee({typeName:x.ZodNull,...b(r)});var Z=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return T(e.data)}};Z.create=r=>new Z({typeName:x.ZodAny,...b(r)});var F=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return T(e.data)}};F.create=r=>new F({typeName:x.ZodUnknown,...b(r)});var I=class extends v{_parse(e){let t=this._getOrReturnCtx(e);return m(t,{code:l.invalid_type,expected:f.never,received:t.parsedType}),y}};I.create=r=>new I({typeName:x.ZodNever,...b(r)});var he=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:f.void,received:n.parsedType}),y}return T(e.data)}};he.create=r=>new he({typeName:x.ZodVoid,...b(r)});var B=class r extends v{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==f.array)return m(t,{code:l.invalid_type,expected:f.array,received:t.parsedType}),y;if(s.exactLength!==null){let c=t.data.length>s.exactLength.value,i=t.data.length<s.exactLength.value;(c||i)&&(m(t,{code:c?l.too_big:l.too_small,minimum:i?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(m(t,{code:l.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(m(t,{code:l.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((c,i)=>s.type._parseAsync(new R(t,c,t.path,i)))).then(c=>C.mergeArray(n,c));let a=[...t.data].map((c,i)=>s.type._parseSync(new R(t,c,t.path,i)));return C.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}};B.create=(r,e)=>new B({type:r,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...b(e)});function me(r){if(r instanceof A){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=O.create(me(n))}return new A({...r._def,shape:()=>e})}else return r instanceof B?new B({...r._def,type:me(r.element)}):r instanceof O?O.create(me(r.unwrap())):r instanceof $?$.create(me(r.unwrap())):r instanceof P?P.create(r.items.map(e=>me(e))):r}var A=class r extends v{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(),t=k.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){let u=this._getOrReturnCtx(e);return m(u,{code:l.invalid_type,expected:f.object,received:u.parsedType}),y}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:c}=this._getCached(),i=[];if(!(this._def.catchall instanceof I&&this._def.unknownKeys==="strip"))for(let u in s.data)c.includes(u)||i.push(u);let d=[];for(let u of c){let p=a[u],g=s.data[u];d.push({key:{status:"valid",value:u},value:p._parse(new R(s,g,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof I){let u=this._def.unknownKeys;if(u==="passthrough")for(let p of i)d.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(u==="strict")i.length>0&&(m(s,{code:l.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let p of i){let g=s.data[p];d.push({key:{status:"valid",value:p},value:u._parse(new R(s,g,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let p of d){let g=await p.key,w=await p.value;u.push({key:g,value:w,alwaysSet:p.alwaysSet})}return u}).then(u=>C.mergeObjectSync(n,u)):C.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;return t.code==="unrecognized_keys"?{message:h.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let n of k.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let n of k.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}deepPartial(){return me(this)}partial(e){let t={};for(let n of k.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let n of k.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof O;)a=a._def.innerType;t[n]=a}return new r({...this._def,shape:()=>t})}keyof(){return Qe(k.objectKeys(this.shape))}};A.create=(r,e)=>new A({shape:()=>r,unknownKeys:"strip",catchall:I.create(),typeName:x.ZodObject,...b(e)});A.strictCreate=(r,e)=>new A({shape:()=>r,unknownKeys:"strict",catchall:I.create(),typeName:x.ZodObject,...b(e)});A.lazycreate=(r,e)=>new A({shape:r,unknownKeys:"strip",catchall:I.create(),typeName:x.ZodObject,...b(e)});var te=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(let i of a)if(i.result.status==="valid")return i.result;for(let i of a)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;let c=a.map(i=>new E(i.ctx.common.issues));return m(t,{code:l.invalid_union,unionErrors:c}),y}if(t.common.async)return Promise.all(n.map(async a=>{let c={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:c}),ctx:c}})).then(s);{let a,c=[];for(let d of n){let u={...t,common:{...t.common,issues:[]},parent:null},p=d._parseSync({data:t.data,path:t.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:u}),u.common.issues.length&&c.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let i=c.map(d=>new E(d));return m(t,{code:l.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}};te.create=(r,e)=>new te({options:r,typeName:x.ZodUnion,...b(e)});var L=r=>r instanceof ne?L(r.schema):r instanceof j?L(r.innerType()):r instanceof se?[r.value]:r instanceof ae?r.options:r instanceof oe?k.objectValues(r.enum):r instanceof ie?L(r._def.innerType):r instanceof Q?[void 0]:r instanceof ee?[null]:r instanceof O?[void 0,...L(r.unwrap())]:r instanceof $?[null,...L(r.unwrap())]:r instanceof Se||r instanceof ue?L(r.unwrap()):r instanceof ce?L(r._def.innerType):[],Ae=class r extends v{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return m(t,{code:l.invalid_type,expected:f.object,received:t.parsedType}),y;let n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let a of t){let c=L(a.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of c){if(s.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,a)}}return new r({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...b(n)})}};function Ne(r,e){let t=D(r),n=D(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&n===f.object){let s=k.objectKeys(e),a=k.objectKeys(r).filter(i=>s.indexOf(i)!==-1),c={...r,...e};for(let i of a){let d=Ne(r[i],e[i]);if(!d.valid)return{valid:!1};c[i]=d.data}return{valid:!0,data:c}}else if(t===f.array&&n===f.array){if(r.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<r.length;a++){let c=r[a],i=e[a],d=Ne(c,i);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===f.date&&n===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var re=class extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(a,c)=>{if(Te(a)||Te(c))return y;let i=Ne(a.value,c.value);return i.valid?((Ee(a)||Ee(c))&&t.dirty(),{status:t.value,value:i.data}):(m(n,{code:l.invalid_intersection_types}),y)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,c])=>s(a,c)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};re.create=(r,e,t)=>new re({left:r,right:e,typeName:x.ZodIntersection,...b(t)});var P=class r extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return m(n,{code:l.invalid_type,expected:f.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return m(n,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...n.data].map((c,i)=>{let d=this._def.items[i]||this._def.rest;return d?d._parse(new R(n,c,n.path,i)):null}).filter(c=>!!c);return n.common.async?Promise.all(a).then(c=>C.mergeArray(t,c)):C.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};P.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new P({items:r,typeName:x.ZodTuple,rest:null,...b(e)})};var Oe=class r extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return m(n,{code:l.invalid_type,expected:f.object,received:n.parsedType}),y;let s=[],a=this._def.keyType,c=this._def.valueType;for(let i in n.data)s.push({key:a._parse(new R(n,i,n.path,i)),value:c._parse(new R(n,n.data[i],n.path,i)),alwaysSet:i in n.data});return n.common.async?C.mergeObjectAsync(t,s):C.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof v?new r({keyType:e,valueType:t,typeName:x.ZodRecord,...b(n)}):new r({keyType:V.create(),valueType:e,typeName:x.ZodRecord,...b(t)})}},ge=class extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return m(n,{code:l.invalid_type,expected:f.map,received:n.parsedType}),y;let s=this._def.keyType,a=this._def.valueType,c=[...n.data.entries()].map(([i,d],u)=>({key:s._parse(new R(n,i,n.path,[u,"key"])),value:a._parse(new R(n,d,n.path,[u,"value"]))}));if(n.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let d of c){let u=await d.key,p=await d.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),i.set(u.value,p.value)}return{status:t.value,value:i}})}else{let i=new Map;for(let d of c){let u=d.key,p=d.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),i.set(u.value,p.value)}return{status:t.value,value:i}}}};ge.create=(r,e,t)=>new ge({valueType:e,keyType:r,typeName:x.ZodMap,...b(t)});var ye=class r extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return m(n,{code:l.invalid_type,expected:f.set,received:n.parsedType}),y;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(m(n,{code:l.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(m(n,{code:l.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let a=this._def.valueType;function c(d){let u=new Set;for(let p of d){if(p.status==="aborted")return y;p.status==="dirty"&&t.dirty(),u.add(p.value)}return{status:t.value,value:u}}let i=[...n.data.values()].map((d,u)=>a._parse(new R(n,d,n.path,u)));return n.common.async?Promise.all(i).then(d=>c(d)):c(i)}min(e,t){return new r({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};ye.create=(r,e)=>new ye({valueType:r,minSize:null,maxSize:null,typeName:x.ZodSet,...b(e)});var Re=class r extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return m(t,{code:l.invalid_type,expected:f.function,received:t.parsedType}),y;function n(i,d){return we({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,le(),W].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:d}})}function s(i,d){return we({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,le(),W].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:d}})}let a={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof U){let i=this;return T(async function(...d){let u=new E([]),p=await i._def.args.parseAsync(d,a).catch(_=>{throw u.addIssue(n(d,_)),u}),g=await Reflect.apply(c,this,p);return await i._def.returns._def.type.parseAsync(g,a).catch(_=>{throw u.addIssue(s(g,_)),u})})}else{let i=this;return T(function(...d){let u=i._def.args.safeParse(d,a);if(!u.success)throw new E([n(d,u.error)]);let p=Reflect.apply(c,this,u.data),g=i._def.returns.safeParse(p,a);if(!g.success)throw new E([s(p,g.error)]);return g.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:P.create(e).rest(F.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||P.create([]).rest(F.create()),returns:t||F.create(),typeName:x.ZodFunction,...b(n)})}},ne=class extends v{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ne.create=(r,e)=>new ne({getter:r,typeName:x.ZodLazy,...b(e)});var se=class extends v{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}};se.create=(r,e)=>new se({value:r,typeName:x.ZodLiteral,...b(e)});function Qe(r,e){return new ae({values:r,typeName:x.ZodEnum,...b(e)})}var ae=class r extends v{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{expected:k.joinValues(n),received:t.parsedType,code:l.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{received:t.data,code:l.invalid_enum_value,options:n}),y}return T(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};ae.create=Qe;var oe=class extends v{_parse(e){let t=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=k.objectValues(t);return m(n,{expected:k.joinValues(s),received:n.parsedType,code:l.invalid_type}),y}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=k.objectValues(t);return m(n,{received:n.data,code:l.invalid_enum_value,options:s}),y}return T(e.data)}get enum(){return this._def.values}};oe.create=(r,e)=>new oe({values:r,typeName:x.ZodNativeEnum,...b(e)});var U=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return m(t,{code:l.invalid_type,expected:f.promise,received:t.parsedType}),y;let n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return T(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};U.create=(r,e)=>new U({type:r,typeName:x.ZodPromise,...b(e)});var j=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:c=>{m(n,c),c.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let c=s.transform(n.data,a);if(n.common.async)return Promise.resolve(c).then(async i=>{if(t.value==="aborted")return y;let d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?y:d.status==="dirty"?q(d.value):t.value==="dirty"?q(d.value):d});{if(t.value==="aborted")return y;let i=this._def.schema._parseSync({data:c,path:n.path,parent:n});return i.status==="aborted"?y:i.status==="dirty"?q(i.value):t.value==="dirty"?q(i.value):i}}if(s.type==="refinement"){let c=i=>{let d=s.refinement(i,a);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?y:(i.status==="dirty"&&t.dirty(),c(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?y:(i.status==="dirty"&&t.dirty(),c(i.value).then(()=>({status:t.value,value:i.value}))))}if(s.type==="transform")if(n.common.async===!1){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!z(c))return y;let i=s.transform(c.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>z(c)?Promise.resolve(s.transform(c.value,a)).then(i=>({status:t.value,value:i})):y);k.assertNever(s)}};j.create=(r,e,t)=>new j({schema:r,typeName:x.ZodEffects,effect:e,...b(t)});j.createWithPreprocess=(r,e,t)=>new j({schema:e,effect:{type:"preprocess",transform:r},typeName:x.ZodEffects,...b(t)});var O=class extends v{_parse(e){return this._getType(e)===f.undefined?T(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};O.create=(r,e)=>new O({innerType:r,typeName:x.ZodOptional,...b(e)});var $=class extends v{_parse(e){return this._getType(e)===f.null?T(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(r,e)=>new $({innerType:r,typeName:x.ZodNullable,...b(e)});var ie=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ie.create=(r,e)=>new ie({innerType:r,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var ce=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return pe(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new E(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new E(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ce.create=(r,e)=>new ce({innerType:r,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var xe=class extends v{_parse(e){if(this._getType(e)!==f.nan){let n=this._getOrReturnCtx(e);return m(n,{code:l.invalid_type,expected:f.nan,received:n.parsedType}),y}return{status:"valid",value:e.data}}};xe.create=r=>new xe({typeName:x.ZodNaN,...b(r)});var ir=Symbol("zod_brand"),Se=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Me=class r extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),q(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?y:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:x.ZodPipeline})}},ue=class extends v{_parse(e){let t=this._def.innerType._parse(e),n=s=>(z(s)&&(s.value=Object.freeze(s.value)),s);return pe(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};ue.create=(r,e)=>new ue({innerType:r,typeName:x.ZodReadonly,...b(e)});function Ge(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function et(r,e={},t){return r?Z.create().superRefine((n,s)=>{let a=r(n);if(a instanceof Promise)return a.then(c=>{if(!c){let i=Ge(e,n),d=i.fatal??t??!0;s.addIssue({code:"custom",...i,fatal:d})}});if(!a){let c=Ge(e,n),i=c.fatal??t??!0;s.addIssue({code:"custom",...c,fatal:i})}}):Z.create()}var cr={object:A.lazycreate},x;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(x||(x={}));var ur=(r,e={message:`Input not instance of ${r.name}`})=>et(t=>t instanceof r,e),tt=V.create,rt=G.create,dr=xe.create,lr=X.create,nt=Y.create,pr=K.create,mr=fe.create,fr=Q.create,hr=ee.create,gr=Z.create,yr=F.create,xr=I.create,br=he.create,_r=B.create,vr=A.create,kr=A.strictCreate,wr=te.create,Sr=Ae.create,Mr=re.create,Cr=P.create,Tr=Oe.create,Er=ge.create,Ar=ye.create,Or=Re.create,Rr=ne.create,jr=se.create,Ir=ae.create,Nr=oe.create,Dr=U.create,Pr=j.create,$r=O.create,Wr=$.create,Lr=j.createWithPreprocess,Fr=Me.create,Br=()=>tt().optional(),zr=()=>rt().optional(),Vr=()=>nt().optional(),Zr={string:(r=>V.create({...r,coerce:!0})),number:(r=>G.create({...r,coerce:!0})),boolean:(r=>Y.create({...r,coerce:!0})),bigint:(r=>X.create({...r,coerce:!0})),date:(r=>K.create({...r,coerce:!0}))};var Ur=y;var Jr=o.enum(["neutral","excited","funny","serious","sad","angry","surprised","question","hype","calm"]),De=o.object({id:o.string().min(1),text:o.string(),startMs:o.number().nonnegative(),endMs:o.number().nonnegative(),revealMs:o.number().optional(),confidence:o.number().min(0).max(1).optional(),hidden:o.boolean().optional(),emphasis:o.enum(["none","strong","hero"]).optional(),color:o.string().optional(),emoji:o.object({char:o.string(),position:o.enum(["before","after","above"])}).nullable().optional(),source:o.object({text:o.enum(["asr","user"]).optional(),emphasis:o.enum(["ai","heuristic","user"]).optional(),emoji:o.enum(["ai","user"]).optional(),filler:o.boolean().optional()}).optional()}),Hr=o.object({emotion:Jr.optional(),emotionSource:o.enum(["ai","heuristic","user"]).optional(),position:o.object({x:o.number(),y:o.number()}).nullable().optional(),styleOverride:o.record(o.unknown()).nullable().optional()}),be=o.object({version:o.literal(2),language:o.string().default("en"),direction:o.enum(["ltr","rtl"]).default("ltr"),words:o.array(De),manualBreaks:o.array(o.string()).default([]),noBreakAfter:o.array(o.string()).default([]),cards:o.record(Hr).default({}),meta:o.object({userEdited:o.boolean().default(!1),createdFromTranscriptId:o.string().optional(),enrichedAt:o.string().optional()}).default({})});var qr=o.enum(["tiktok","reels","shorts","youtube","linkedin","podcast","custom"]),Gr=3,st=o.object({platform:qr.default("custom"),maxWordsPerCard:o.number().int().min(1).max(12).default(Gr),maxLines:o.number().int().min(1).max(3).default(2),maxCharsPerLine:o.number().int().min(8).max(60).default(24),pauseMs:o.number().min(150).max(1500).default(400),holdMs:o.number().min(0).max(1500).default(500),minCardMs:o.number().min(200).max(2e3).default(900),gapBehavior:o.enum(["hold","clear"]).default("hold"),syncOffsetMs:o.number().min(-1e3).max(1e3).default(0),removeFillers:o.boolean().default(!1),fillerList:o.array(o.string()).default([]),profanity:o.enum(["off","mask","emoji","hide"]).default("off"),customVocabulary:o.array(o.string()).default([]),romanize:o.boolean().default(!1),language:o.string().default("auto"),translateTo:o.string().nullable().default(null),bilingual:o.boolean().default(!1)});var Xr=["none","color","pop","box","underline","marker","glow","bounce","shake","fill-sweep","scale-up","outline-fill"],Yr=["none","fade","rise","drop","pop","zoom","slide-left","slide-right","blur-in","typewriter","wave","flip","elastic","glitch","mask-reveal","letter-spin","letter-elastic","letter-snap","letter-burst","letter-stretch"],Kr=["none","fade","fall","zoom-out","blur-out","slide-up","letter-spin","letter-elastic","letter-snap","letter-burst","letter-stretch"],Qr=["linear","outQuad","outCubic","outExpo","inOutCubic","spring"],J=o.string(),at=o.enum(["none","upper","lower","title","sentence"]),ot=o.object({enabled:o.boolean().default(!1),width:o.number().min(0).max(40).default(4),color:J.default("#000000")}),it=o.discriminatedUnion("type",[o.object({type:o.literal("solid"),color:J}),o.object({type:o.literal("gradient"),stops:o.array(o.object({color:J,at:o.number().min(0).max(1)})).min(2),angle:o.number().default(135)})]),ct=o.object({templateId:o.string().default("sentence_highlight"),fontId:o.string().default("Montserrat"),fontWeight:o.number().int().min(100).max(900).default(800),fontStyle:o.enum(["normal","italic"]).default("normal"),fontSize:o.number().min(12).max(300).default(64),casing:at.default("none"),letterSpacing:o.number().default(0),wordSpacing:o.number().default(0),lineHeight:o.number().min(.7).max(2.5).default(1.15),align:o.enum(["left","center","right"]).default("center"),maxWidth:o.number().min(.3).max(1).default(.86),fill:it.default({type:"solid",color:"#FFFFFF"}),inactiveOpacity:o.number().min(0).max(1).default(1),hero:o.object({fontId:o.string().optional(),fontWeight:o.number().int().optional(),scale:o.number().min(.5).max(4).default(1.4),fill:it.optional(),stroke:ot.optional(),casing:at.optional(),rotate:o.number().default(0)}).default({}),active:o.object({effect:o.enum(Xr).default("color"),color:J.default("#FFE600"),scale:o.number().min(.8).max(2).default(1.08),boxColor:J.optional(),boxRadius:o.number().min(0).max(100).default(12)}).default({}),stroke:ot.default({}),shadows:o.array(o.object({x:o.number(),y:o.number(),blur:o.number().min(0),color:J})).max(12).default([]),glow:o.object({enabled:o.boolean().default(!1),color:J.default("#FFFFFF"),radius:o.number().min(0).max(80).default(12),intensity:o.number().min(0).max(2).default(.8)}).default({}),background:o.object({type:o.enum(["none","pill","box","bar","word-box","bubble"]).default("none"),color:J.default("#000000"),opacity:o.number().min(0).max(1).default(.7),padding:o.number().min(0).max(120).default(16),radius:o.number().min(0).max(120).default(16),blur:o.number().min(0).max(60).default(0)}).default({}),position:o.object({x:o.number().min(0).max(1),y:o.number().min(0).max(1)}).default({x:.5,y:.72}),safeBox:o.object({top:o.number().min(0).max(.5),bottom:o.number().min(0).max(.5),left:o.number().min(0).max(.5),right:o.number().min(0).max(.5)}).default({top:.06,bottom:.1,left:.06,right:.06}),rotation:o.number().min(-45).max(45).default(0),entrance:o.object({type:o.enum(Yr).default("rise"),durationMs:o.number().min(0).max(1500).default(220),stagger:o.enum(["none","word","char"]).default("none"),easing:o.enum(Qr).default("outExpo")}).default({}),exit:o.object({type:o.enum(Kr).default("none"),durationMs:o.number().min(0).max(1e3).default(120)}).default({}),motionIntensity:o.number().min(0).max(2).default(1),emotionReactivity:o.number().min(0).max(1).default(.6),emoji:o.object({enabled:o.boolean().default(!1),size:o.number().min(.5).max(3).default(1),animation:o.enum(["pop","float","spin","none"]).default("pop")}).default({}),templateOptions:o.record(o.unknown()).default({})});var Pe=["transcribe","enrich","render","proxy","thumbnail"];var en=o.object({family:o.string(),weight:o.number().default(400),style:o.string().default("normal"),url:o.string().url().optional()}),tn=o.object({kind:o.literal("transcribe"),videoId:o.string(),engine:o.enum(["local","cloud"]),model:o.string().default("small"),language:o.string().default("auto"),prompt:o.string().optional(),romanize:o.boolean().default(!1)}),rn=o.object({kind:o.literal("enrich"),documentRevision:o.number().int(),features:o.array(o.enum(["hero","emoji","emotion","fillers"]))}),nn=o.object({kind:o.literal("proxy"),videoId:o.string(),targetHeight:o.number().default(720)}),sn=o.object({kind:o.literal("thumbnail"),videoId:o.string(),atMs:o.number().optional()}),an=["mp4","mov_alpha","webm_alpha","png"],on=o.object({kind:o.literal("render"),exportId:o.string(),format:o.enum(an),width:o.number().int().positive(),height:o.number().int().positive(),fps:o.number().positive(),crf:o.number().int().min(0).max(51).default(21),range:o.object({startMs:o.number().nonnegative(),endMs:o.number().positive()}).optional(),docSnapshot:be,style:ct,settings:st,fonts:o.array(en).default([]),sourceVideoId:o.string()}),Ts=o.discriminatedUnion("kind",[tn,rn,nn,sn,on]),ut=o.object({kinds:o.array(o.enum(Pe)).default([]),whisper:o.object({installed:o.boolean(),models:o.array(o.string())}).optional(),gpu:o.enum(["nvidia","apple","amd"]).nullable().optional(),cpuCores:o.number().optional(),ramGb:o.number().optional(),diskFreeGb:o.number().optional(),chromeReady:o.boolean().optional(),ffmpeg:o.boolean().optional()});var cn=o.object({durationMs:o.number().nonnegative(),width:o.number().int().positive(),height:o.number().int().positive(),fps:o.number().positive().optional(),rotation:o.number().optional(),videoCodec:o.string().optional(),audioCodec:o.string().optional(),hasAudio:o.boolean().optional(),previewMode:o.enum(["native","converted","captions-only"]).optional(),needsCompat:o.boolean().optional()}),Ns=o.object({filename:o.string().min(1).max(300),size:o.number().int().positive(),mime:o.string(),probe:cn.optional(),local:o.boolean().optional()}),Ds=o.object({needsProxy:o.boolean().optional()}).default({}),Ps=o.object({expectedRevision:o.number().int().nonnegative(),doc:be}),un=["mp4","mov_alpha","webm_alpha","srt","vtt","ass","txt","json","png"];var $s=o.object({kind:o.enum(un),width:o.number().int().min(64).max(7680).optional(),height:o.number().int().min(64).max(7680).optional(),fps:o.number().min(1).max(120).optional(),crf:o.number().int().min(0).max(51).optional(),range:o.object({startMs:o.number().nonnegative(),endMs:o.number().positive()}).optional()}),Ws=o.object({workerName:o.string().min(1).max(80).default("My Computer"),platform:o.string().max(40).optional(),version:o.string().max(40).optional()}),Ls=o.object({deviceCode:o.string().min(16).max(200),workerName:o.string().trim().min(1).max(80).optional(),platform:o.string().max(40).optional()}),Fs=o.object({userCode:o.string().min(4).max(20),approve:o.boolean().default(!0)}),Bs=o.object({version:o.string().max(40).optional(),platform:o.string().max(40).optional(),capabilities:ut.optional(),currentJobId:o.string().uuid().nullable().optional()}),zs=o.object({kinds:o.array(o.enum(Pe)).min(1),waitMs:o.number().int().min(0).max(25e3).default(0)}),Vs=o.object({stage:o.string().max(60),progress:o.number().min(0).max(100),message:o.string().max(500).optional()}),Zs=o.object({errorCode:o.string().max(60).default("WORKER_ERROR"),message:o.string().max(2e3),retryable:o.boolean().default(!1)}),dn=o.object({kind:o.literal("transcribe"),engine:o.enum(["whisper_cpp"]),model:o.string(),language:o.string().default("en"),durationMs:o.number().nonnegative().optional(),width:o.number().int().positive().optional(),height:o.number().int().positive().optional(),words:o.array(De).max(2e5)}),ln=o.object({kind:o.literal("proxy"),previewPath:o.string()}),pn=o.object({kind:o.literal("thumbnail"),thumbnailPath:o.string()}),mn=o.object({kind:o.literal("render"),path:o.string(),size:o.number().int().nonnegative(),durationMs:o.number().nonnegative().optional(),renderMs:o.number().nonnegative().optional()}),Us=o.discriminatedUnion("kind",[dn,ln,pn,mn]);var fn=/^\s*[\[(<*♪♫]+\s*(blank[_ ]?audio|music|silence|noise|applause|laughter|inaudible|no speech)?[^\])>*]*[\])>*♪♫]*\s*$/i;function hn(r){let e=[];for(let t of r){let n=/^\s/.test(t.text)||e.length===0,s=t.text.trim();if(!s)continue;let a=e[e.length-1];!n&&a&&!/[.!?]$/.test(a.text)?(a.text+=s,a.endMs=Math.max(a.endMs,t.endMs),t.confidence!=null&&(a.confidence=Math.min(a.confidence??1,t.confidence))):e.push({...t,text:s})}return e}function dt(r,e={}){let t=e.minWordMs??40,n=new Map((e.vocabulary??[]).map(i=>[i.toLowerCase(),i])),s=r.map(i=>({...i,text:i.text.replace(/\s+/g," ")})).filter(i=>i.text.trim()&&!fn.test(i.text.trim())&&Number.isFinite(i.startMs)&&Number.isFinite(i.endMs));s.sort((i,d)=>i.startMs-d.startMs||i.endMs-d.endMs);let a=[],c=0;for(let i of s){let d=i.text.trim();e.romanize&&!yn(d)&&(d=e.romanize(d));let u=n.get(d.replace(/[^\p{L}\p{N}'-]/gu,"").toLowerCase());u&&(d=d.replace(/[\p{L}\p{N}'-]+/u,u));let p=Math.max(Math.round(i.startMs),c),g=Math.max(Math.round(i.endMs),p+t);e.durationMs!=null&&(p>=e.durationMs||(g=Math.min(g,e.durationMs),g-p<1))||(a.push({id:ke(),text:d,startMs:p,endMs:g,...i.confidence!=null?{confidence:xn(i.confidence)}:{},source:{text:"asr"}}),c=p)}for(let i=0;i<a.length-1;i++){let d=a[i],u=a[i+1];d.endMs>u.startMs&&(d.endMs=Math.max(d.startMs+1,u.startMs))}return lt(a)}function lt(r,e=4){let t=n=>n.text.toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");for(let n of[1,2,3,4])for(let s=0;s+n*e<=r.length;s++){let a=1;for(;s+(a+1)*n<=r.length&&gn(r,s,s+a*n,n,t);)a++;if(a>=e)return lt([...r.slice(0,s+n),...r.slice(s+a*n)],e)}return r}function gn(r,e,t,n,s){for(let a=0;a<n;a++)if(s(r[e+a])!==s(r[t+a])||!s(r[e+a]))return!1;return!0}var yn=r=>/^[\x00-\x7F]*$/.test(r),xn=r=>Math.min(1,Math.max(0,r));function pt(r,e){return dt(hn(r),e)}var bn=["fuck","fucking","shit","bitch","asshole","bastard","dick","cunt","bullshit","motherfucker","damn"],la=new Set(bn);var de=Math.round(480),mt=.2,_n=.4,vn=2,kn=.1,ht=(r,e,t)=>{let n=0;for(let s=e;s<t;s++)n+=r[s]*r[s];return Math.sqrt(n/Math.max(1,t-e))};function wn(r){let e=Math.floor(r.length/de);if(!e)return[];let t=new Float32Array(e);for(let _=0;_<e;_++)t[_]=ht(r,_*de,(_+1)*de);let n=Float32Array.from(t).sort(),s=n[Math.floor(e*.1)],a=n[Math.floor(e*.98)];if(a<.004)return[];let c=Math.max(.0035,Math.min(s*3.5,a*.3),a*.06),i=Math.round(.3/.03),d=[],u=-1,p=0;for(let _=0;_<e;_++)t[_]>=c?(u<0&&(u=_),p=0):u>=0&&++p>i&&(d.push({start:u*de,end:(_-p+1)*de}),u=-1);u>=0&&d.push({start:u*de,end:e*de});let g=d.filter(_=>_.end-_.start>=16e3*.15),w=[];for(let _ of g){let S=w[w.length-1];S&&_.start-S.end<16e3*_n?S.end=_.end:w.push({..._})}return w.map((_,S)=>({start:Math.max(S?Math.floor((w[S-1].end+_.start)/2):0,_.start-mt*16e3),end:Math.min(S<w.length-1?Math.ceil((_.end+w[S+1].start)/2):r.length,_.end+mt*16e3)}))}function Sn(r,e,t=28){let n=[],s=e.start,a=t;for(;e.end-s>a*16e3;){let c=s+a*16e3;a=28;let i=Math.max(s+16e3*Math.min(10,t*.6),c-2.5*16e3),d=16e3*.05,u=c,p=1/0;for(let g=i;g+d<=c;g+=d){let w=ht(r,Math.round(g),Math.round(g+d));w<p&&(p=w,u=g+d/2)}n.push({start:s,end:Math.round(u)}),s=Math.round(u)}return n.push({start:s,end:e.end}),n}function gt(r,e=wn(r),t=0,n=!0){let s=[],a=null,c=Math.round(kn*16e3),d=e.map(u=>({start:Math.max(u.start,t),end:u.end})).filter(u=>u.end-u.start>=16e3*.15).flatMap((u,p)=>Sn(r,u,n&&p===0?10:28));for(let u of d){let p=u.end-u.start,g=(n&&s.length===1?10:28)*16e3;(!a||a.samples+c+p>g||u.start-a.origEnd>vn*16e3)&&(a={pieces:[],samples:0,origStart:u.start,origEnd:u.start},s.push(a));let _=a;_.pieces.length&&(_.samples+=c),_.pieces.push({packedStart:_.samples,packedEnd:_.samples+p,origStart:u.start}),_.samples+=p,_.origEnd=u.end}return s}function yt(r,e){let t=new Float32Array(e.samples);for(let n of e.pieces)t.set(r.subarray(n.origStart,n.origStart+(n.packedEnd-n.packedStart)),n.packedStart);return t}function $e(r,e){let t=e*16e3,n=r.pieces;for(let a=0;a<n.length;a++){let c=n[a];if(t<=c.packedEnd){if(t>=c.packedStart)return(c.origStart+(t-c.packedStart))/16e3;let i=n[a-1],d=i?t-i.packedEnd:1/0;return i&&d<c.packedStart-t?(i.origStart+(i.packedEnd-i.packedStart))/16e3:c.origStart/16e3}}let s=n[n.length-1];return(s.origStart+(s.packedEnd-s.packedStart))/16e3}var ft=16;function We(r){let e=r.map(s=>s.text.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"")),t=new Set,n=[...Array.from({length:ft-4},(s,a)=>ft-a),1,2,3,4];for(let s of n){let a=s===1?4:3,c=s>=5;for(let i=0;i+s*a<=r.length;){let d=1;for(;i+(d+1)*s<=r.length&&Mn(e,i,i+d*s,s);)d++;if(d>=a){let u=c?1:2;for(let p=i+u*s;p<i+d*s;p++)t.add(p);if(c){let p=i+d*s,g=0;for(;g<s-1&&p+g<r.length&&e[p+g]&&e[p+g]===e[i+g];)g++;if(g>=Math.ceil(s/2))for(let w=0;w<g;w++)t.add(p+w);i=p+g}else i+=d*s}else i++}}return t.size?r.filter((s,a)=>!t.has(a)):r}function Mn(r,e,t,n){for(let s=0;s<n;s++)if(!r[e+s]||r[e+s]!==r[t+s])return!1;return!0}function xt(r,e,t,n){let s=.6+.12*r.trim().length;return Math.max(e+.05,Math.min(t,e+s,n))}function bt(r,e=20){let t=r.length;for(let n=1;n<=e;n++){let s=n===1?8:n===2?4:3;if(n*s>t)break;let a=!0;for(let c=1;c<s&&a;c++)for(let i=0;i<n;i++)if(r[t-1-i]!=r[t-1-i-c*n]){a=!1;break}if(a)return!0}return!1}var N=class extends Error{code;details;constructor(e,t,n){super(t),this.name="CaptionsEasyError",this.code=e,this.details=n}};import{existsSync as Cn,statSync as Tn}from"node:fs";import{resolve as En}from"node:path";function _t(r,e="file"){let t=En(r);if(!Cn(t)||!Tn(t).isFile())throw new N("FILE_NOT_FOUND",`${e} not found: ${t}`);return t}import{spawn as On}from"node:child_process";import{spawn as An}from"node:child_process";import{RenderInternals as vt}from"@remotion/renderer";function kt(){return vt.getExecutablePath({type:"ffmpeg",indent:!1,logLevel:"error",binariesDirectory:null})}function wt(){return vt.getExecutablePath({type:"ffprobe",indent:!1,logLevel:"error",binariesDirectory:null})}function St(r,e,t={}){return new Promise((n,s)=>{let a=An(r,e,{windowsHide:!0}),c="",i="",d=()=>a.kill("SIGKILL");t.signal?.addEventListener("abort",d,{once:!0}),a.stdout.on("data",u=>c+=u.toString()),a.stderr.on("data",u=>{let p=u.toString();if(i=(i+p).slice(-3e3),t.onStderr)for(let g of p.split(/\r?\n|\r/))g&&t.onStderr(g)}),a.on("error",s),a.on("close",u=>{if(t.signal?.removeEventListener("abort",d),t.signal?.aborted)return s(new DOMException("Aborted","AbortError"));u===0?n(c):s(new Error(`${r.split(/[\\/]/).pop()} exited with ${u}: ${i.trim().split(`
3
+ `).slice(-6).join(`
4
+ `)}`))})})}var Le=16e3,Mt=r=>{if(!r)return 0;let[e,t]=r.split("/").map(Number);return t?e/t:e??0};async function Ct(r){let e=await St(wt(),["-v","error","-print_format","json","-show_format","-show_streams",r]).catch(i=>{throw new N("NO_VIDEO",`Could not read ${r} as a video: ${i instanceof Error?i.message:i}`)}),t=JSON.parse(e),n=t.streams?.find(i=>i.codec_type==="video"&&!i.disposition?.attached_pic),s=Number(n?.tags?.rotate??n?.side_data_list?.find(i=>i.rotation!==void 0)?.rotation??0),a=Math.abs(s)%180===90,c=Mt(n?.avg_frame_rate)||Mt(n?.r_frame_rate)||30;return{width:(a?n?.height:n?.width)??0,height:(a?n?.width:n?.height)??0,fps:Math.min(120,Math.max(1,c)),durationMs:Math.round(Number(t.format?.duration??n?.duration??0)*1e3),hasAudio:!!t.streams?.some(i=>i.codec_type==="audio"),hasVideo:!!n}}function Tt(r){return new Promise((e,t)=>{let n=On(kt(),["-v","error","-i",r,"-vn","-ac","1","-ar",String(Le),"-c:a","pcm_s16le","-f","wav","pipe:1"],{windowsHide:!0}),s=[],a="";n.stdout.on("data",c=>s.push(c)),n.stderr.on("data",c=>a=(a+c.toString()).slice(-2e3)),n.on("error",t),n.on("close",c=>{if(c!==0)return t(new N("NO_AUDIO",`Could not decode the audio of ${r}: ${a.trim()||`ffmpeg exited with ${c}`}`));e(Rn(Buffer.concat(s)))})})}function Rn(r){let e=12;for(;e+8<=r.length;){let t=r.toString("ascii",e,e+4),n=r.readUInt32LE(e+4);if(t==="data"){let s=n&&e+8+n<=r.length?e+8+n:r.length,a=Math.floor((s-e-8)/2),c=new Float32Array(a);for(let i=0;i<a;i++)c[i]=r.readInt16LE(e+8+i*2)/32768;return c}e+=8+n+n%2}return new Float32Array(0)}import{mkdirSync as Dn}from"node:fs";import{join as Pn}from"node:path";import M from"node:path";import Et from"node:os";import Fe from"node:process";var H=Et.homedir(),Be=Et.tmpdir(),{env:_e}=Fe,jn=r=>{let e=M.join(H,"Library");return{data:M.join(e,"Application Support",r),config:M.join(e,"Preferences",r),cache:M.join(e,"Caches",r),log:M.join(e,"Logs",r),temp:M.join(Be,r)}},In=r=>{let e=_e.APPDATA||M.join(H,"AppData","Roaming"),t=_e.LOCALAPPDATA||M.join(H,"AppData","Local");return{data:M.join(t,r,"Data"),config:M.join(e,r,"Config"),cache:M.join(t,r,"Cache"),log:M.join(t,r,"Log"),temp:M.join(Be,r)}},Nn=r=>{let e=M.basename(H);return{data:M.join(_e.XDG_DATA_HOME||M.join(H,".local","share"),r),config:M.join(_e.XDG_CONFIG_HOME||M.join(H,".config"),r),cache:M.join(_e.XDG_CACHE_HOME||M.join(H,".cache"),r),log:M.join(_e.XDG_STATE_HOME||M.join(H,".local","state"),r),temp:M.join(Be,e,r)}};function ze(r,{suffix:e="nodejs"}={}){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);return e&&(r+=`-${e}`),Fe.platform==="darwin"?jn(r):Fe.platform==="win32"?In(r):Nn(r)}var $n=ze("captionseasy",{suffix:""});function Wn(){let r=process.env.CAPTIONSEASY_CACHE??$n.cache;return Dn(r,{recursive:!0}),r}var Ve=()=>Pn(Wn(),"models");if(16e3!==Le)throw new Error("sample rate mismatch");var Ot={encoder_model:"fp32",decoder_model_merged:"q4"},Ln={encoder_model:"q8",decoder_model_merged:"q8"},Rt={en:{id:"onnx-community/whisper-base_timestamped",revision:"608c49e61301901684bc36cac8f74b95ff6b5a8e",language:"en",tokensPerSecond:7,label:"whisper-base",dtype:Ot},auto:{id:"onnx-community/whisper-base_timestamped",revision:"608c49e61301901684bc36cac8f74b95ff6b5a8e",language:null,tokensPerSecond:9,label:"whisper-base (auto language)",dtype:Ot},hinglish:{id:"ishaan-g/whisper-hinglish-swift_timestamped",revision:"eb0fe25c3aba1799633033ad4a58ef0cad877606",language:"en",tokensPerSecond:12,label:"whisper-hinglish-swift",dtype:Ln}},Ce=new Map,Ze=(r,e)=>{r||process.stderr.write(e)};async function Fn(r,e){let t=`${r.id}@${r.revision}`,n=Ce.get(t);return n||(n=(async()=>{let s=await import("@huggingface/transformers");s.env.cacheDir=Ve(),s.env.allowLocalModels=!1;let a=new Map,c=-1,i=!1,d=p=>{if(p.status!=="progress"||!p.file||!p.total)return;a.set(p.file,{loaded:p.loaded??0,total:p.total});let g=0,w=0;a.forEach(ve=>(g+=ve.loaded,w+=ve.total));let _=process.stderr.isTTY,S=_?Math.floor(g/w*100):Math.floor(g/w*10)*10;if(S!==c&&w>5e6){i||Ze(e,`captionseasy: downloading speech model ${r.id} (one time, cached in ${Ve()})
5
+ `),i=!0,c=S;let ve=` ${S}% ${(g/1048576).toFixed(0)} / ${(w/1048576).toFixed(0)} MB`;Ze(e,_?`\r${ve}`:`${ve}
6
+ `)}},u=await s.pipeline("automatic-speech-recognition",r.id,{revision:r.revision,device:"cpu",dtype:r.dtype,progress_callback:d});return i&&process.stderr.isTTY&&Ze(e,`
7
+ `),{asr:u,dispose:()=>u.dispose()}})(),n.catch(()=>Ce.delete(t)),Ce.set(t,n)),n}var Ue;async function Bn(){if(!Ue){let{StoppingCriteria:r}=await import("@huggingface/transformers");class e extends r{_call(n){return n.map(s=>bt(s))}}Ue=new e}return Ue}async function zn(r,e,t,n){let s=yt(t,n),a=s.length/16e3,c=await r(s,{return_timestamps:"word",task:"transcribe",max_new_tokens:Math.min(440,Math.ceil(a*e.tokensPerSecond)+20),stopping_criteria:await Bn(),...e.language?{language:e.language}:{}}),i=[];for(let d of c.chunks??[]){if(!d.text.trim())continue;let[u,p]=d.timestamp,g=xt(d.text,u,p??u+.3,a);i.push({text:d.text,startMs:$e(n,u)*1e3,endMs:$e(n,g)*1e3})}return We(i)}async function jt(r,e={}){let t=_t(r,"Video"),n=e.language??"en",s=Rt[n];if(!s)throw new N("BAD_ARGS",`language must be one of: ${Object.keys(Rt).join(", ")}`);let a=At.now(),c=await Ct(t);if(!c.hasAudio)throw new N("NO_AUDIO",`${t} has no audio track to transcribe.`);let i=Fn(s,e.quiet);i.catch(()=>{});let d=await Tt(t),u=d.length/16e3*1e3,p;try{p=await i}catch(S){throw new N("TRANSCRIBE_FAILED",`Could not load the speech model ${s.id}: ${S instanceof Error?S.message:S}. The first run needs internet access to download it.`)}let g=gt(d),w=[];for(let S=0;S<g.length;S++)e.onProgress?.(S/g.length),w.push(...await zn(p.asr,s,d,g[S]));e.onProgress?.(1);let _=pt(We(w),{durationMs:c.durationMs||u});return{language:n==="hinglish"?"hi-Latn":n==="auto"?"auto":"en",model:`${s.id}@${s.revision.slice(0,7)}`,durationMs:Math.round(c.durationMs||u),elapsedMs:Math.round(At.now()-a),words:_.map(S=>({text:S.text,startMs:S.startMs,endMs:S.endMs}))}}async function It(){let r=[...Ce.values()];Ce.clear(),await Promise.all(r.map(e=>e.then(t=>t.dispose()).catch(()=>{})))}var po=jt,mo=It;export{po as transcribe,mo as unloadModels};
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Public types of the `captionseasy` package. Self-contained on purpose (no imports), so the published typings never
3
+ * point at the private workspace packages they are bundled from.
4
+ */
5
+ /** Which speech model transcribes: English, Hinglish (Hindi/English written in Roman letters) or auto-detect. */
6
+ export type Language = "en" | "hinglish" | "auto";
7
+ /** One spoken word with its timing on the video's clock (milliseconds). */
8
+ export interface TranscriptWord {
9
+ text: string;
10
+ startMs: number;
11
+ endMs: number;
12
+ }
13
+ export interface Transcript {
14
+ /** "en", "hi-Latn" (Hinglish) or "auto" */
15
+ language: string;
16
+ /** speech model id@revision that wrote the words */
17
+ model: string;
18
+ durationMs: number;
19
+ /** wall-clock time the transcription took */
20
+ elapsedMs: number;
21
+ words: TranscriptWord[];
22
+ }
23
+ export interface TranscribeOptions {
24
+ /** default "en" */
25
+ language?: Language;
26
+ /** 0..1 while the speech windows are transcribed */
27
+ onProgress?: (fraction: number) => void;
28
+ /** no model-download progress on stderr */
29
+ quiet?: boolean;
30
+ }
31
+ /** A look: a complete, designed caption style. Refer to it by `number` (permanent) or `id`. */
32
+ export interface LookSummary {
33
+ number: number;
34
+ id: string;
35
+ name: string;
36
+ /** gallery section ("viral", "popular", "premium" ...) */
37
+ section: string;
38
+ tags: string[];
39
+ description: string;
40
+ /** "word" (one word at a time), "sentence", "karaoke" ... */
41
+ layout: string;
42
+ /** words shown per caption card by default */
43
+ wordsPerCard: number;
44
+ }
45
+ export type ControlType = "number" | "color" | "boolean" | "enum" | "font";
46
+ /** One thing you may change about a look, addressed by `key` (a dot path into the style). */
47
+ export interface LookControl {
48
+ key: string;
49
+ label: string;
50
+ type: ControlType;
51
+ min?: number;
52
+ max?: number;
53
+ step?: number;
54
+ /** allowed values for "enum" (and the bundled fonts for "font") */
55
+ options?: (string | number)[];
56
+ /** the look's own value */
57
+ default: unknown;
58
+ /** this control only takes effect once another key has this value ("stroke.enabled=true"); setting it turns that on */
59
+ dependsOn?: string;
60
+ description?: string;
61
+ }
62
+ /** Caption pacing/timing keys (shared by every look). */
63
+ export interface SettingControl {
64
+ key: string;
65
+ label: string;
66
+ type: ControlType;
67
+ min?: number;
68
+ max?: number;
69
+ step?: number;
70
+ options?: (string | number)[];
71
+ default: unknown;
72
+ description?: string;
73
+ }
74
+ export interface LookDetails extends LookSummary {
75
+ retired: boolean;
76
+ /** the look's style values that its controls read (a flat dot-path map) */
77
+ defaults: Record<string, unknown>;
78
+ /** ONLY the style controls this look's template really responds to */
79
+ controls: LookControl[];
80
+ /** caption pacing (words per card, timing) */
81
+ settings: SettingControl[];
82
+ }
83
+ export interface ListLooksOptions {
84
+ /** free text matched against number, id, name, description, tags, section and layout (every word must match) */
85
+ query?: string;
86
+ /** every tag must match (case-insensitive substring) */
87
+ tags?: string[];
88
+ /** a gallery section id ("viral", "popular", "premium", "simple" ...) */
89
+ section?: string;
90
+ }
91
+ /** A look number (118, "118", "#118") or id ("chrome_sweep"). */
92
+ export type LookRef = number | string;
93
+ /** Style overrides: flat dot paths (`{"active.color": "#FF0000"}`) or nested objects; validated against the look. */
94
+ export type StyleOverrides = Record<string, unknown>;
95
+ /** Caption pacing overrides, e.g. `{ maxWordsPerCard: 2, gapBehavior: "clear" }`. */
96
+ export type SettingsOverrides = Record<string, unknown>;
97
+ export interface BuildCaptionsInput {
98
+ words: TranscriptWord[];
99
+ look: LookRef;
100
+ overrides?: StyleOverrides;
101
+ settings?: SettingsOverrides;
102
+ /** language tag stored in the caption doc (default "en") */
103
+ language?: string;
104
+ }
105
+ /** Validated input for the CaptionedVideo composition (plus what was chosen). */
106
+ export interface CaptionsProps {
107
+ /** CaptionDoc v2: words with ids */
108
+ doc: Record<string, unknown> & {
109
+ version: 2;
110
+ words: (TranscriptWord & {
111
+ id: string;
112
+ })[];
113
+ };
114
+ /** full CaptionStyle (every field filled in) */
115
+ style: Record<string, unknown> & {
116
+ templateId: string;
117
+ };
118
+ /** full ProjectSettings */
119
+ settings: Record<string, unknown> & {
120
+ maxWordsPerCard: number;
121
+ };
122
+ look: {
123
+ number: number;
124
+ id: string;
125
+ name: string;
126
+ };
127
+ /** non-fatal notes (e.g. "turned on stroke.enabled because stroke.width was set") */
128
+ warnings: string[];
129
+ }
130
+ export type OverlayFormat = "mov" | "webm";
131
+ export interface RenderOptions {
132
+ /** local video file */
133
+ video: string;
134
+ /** timed words; omit (with no transcript) to transcribe the video first */
135
+ words?: TranscriptWord[];
136
+ /** a Transcript from transcribe() (or its JSON); alternative to `words` */
137
+ transcript?: {
138
+ words: TranscriptWord[];
139
+ language?: string;
140
+ };
141
+ /** language for transcription when no words are given (default "en") */
142
+ language?: Language;
143
+ look: LookRef;
144
+ overrides?: StyleOverrides;
145
+ settings?: SettingsOverrides;
146
+ /** output path; default "<video>.captioned.mp4" (burn) or "<video>.captions.mov|webm" (overlay) */
147
+ out?: string;
148
+ /** "burn" (default): captions over the video, MP4 with the original audio. "overlay": transparent captions only. */
149
+ mode?: "burn" | "overlay";
150
+ /** overlay container: "mov" = ProRes 4444 with alpha (default, edits in every NLE), "webm" = VP9 with alpha (small, web) */
151
+ overlayFormat?: OverlayFormat;
152
+ /** 0..1 */
153
+ onProgress?: (fraction: number, stage: "transcribe" | "render") => void;
154
+ /** frames rendered in parallel (default: half the CPU cores) */
155
+ concurrency?: number;
156
+ quiet?: boolean;
157
+ }
158
+ export interface RenderResult {
159
+ out: string;
160
+ mode: "burn" | "overlay";
161
+ durationMs: number;
162
+ width: number;
163
+ height: number;
164
+ fps: number;
165
+ look: {
166
+ number: number;
167
+ id: string;
168
+ name: string;
169
+ };
170
+ /** words that were captioned */
171
+ words: number;
172
+ renderMs: number;
173
+ /** set when the video was transcribed as part of this call */
174
+ transcribeMs?: number;
175
+ warnings: string[];
176
+ }
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "captionseasy-transcribe",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Transcription add-on for captionseasy: local Whisper speech-to-text with word timestamps (transformers.js + onnxruntime-node, prebuilt, no compiler). Free, offline after the first model download.",
5
+ "license": "MIT",
6
+ "author": "Ishaan Gupta",
7
+ "bugs": {
8
+ "url": "https://github.com/Ishaan-Gpt/Captions-Easy/issues"
9
+ },
10
+ "type": "module",
11
+ "engines": {
12
+ "node": ">=20"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "homepage": "https://github.com/Ishaan-Gpt/Captions-Easy/tree/main/packages/cli-transcribe#readme",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/Ishaan-Gpt/Captions-Easy.git",
21
+ "directory": "packages/cli-transcribe"
22
+ },
23
+ "keywords": [
24
+ "captionseasy",
25
+ "captions",
26
+ "video",
27
+ "whisper",
28
+ "speech-to-text",
29
+ "transcription",
30
+ "word-timestamps"
31
+ ],
32
+ "main": "./dist/index.mjs",
33
+ "types": "./dist/index.d.ts",
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.mjs"
38
+ },
39
+ "./package.json": "./package.json"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "README.md",
44
+ "LICENSE"
45
+ ],
46
+ "scripts": {
47
+ "build": "node ../cli/scripts/build.mjs transcribe",
48
+ "typecheck": "tsc --noEmit",
49
+ "test": "vitest run"
50
+ },
51
+ "dependencies": {
52
+ "@huggingface/transformers": "4.3.0",
53
+ "@remotion/renderer": "4.0.484"
54
+ },
55
+ "devDependencies": {
56
+ "@capseasy/companion": "workspace:*",
57
+ "@capseasy/shared": "workspace:*",
58
+ "@motion-ai/caption-engine": "workspace:*",
59
+ "@types/node": "^20",
60
+ "esbuild": "^0.28.1",
61
+ "typescript": "^5.6.0",
62
+ "vitest": "^4.1.9",
63
+ "tsx": "^4.19.0"
64
+ }
65
+ }