@bylqwjc/media-editor-server 1.0.24 → 1.0.26

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.
@@ -1 +1 @@
1
- import{outputSize as t,isOverlayHidden as e,findFilterPreset as n,normalizeDeg as s,overlayLayerRenderOrder as o}from"./chunk-VDEZTXEA.js";export{DEG2RAD,FILTER_PRESETS,buildFilterCss,centeredMaxRect,clampRect,evenize,findFilterPreset,fitRects,normalizeDeg,outputSize,rotatedSize}from"./chunk-VDEZTXEA.js";export{MIN_CLIP,canRedo,canUndo,clampAudioClip,clipDuration,clipStartsAt,contentDuration,createHistory,duplicateClip,locateOutput,pushHistory,redo,remapSrcIndices,removeClip,reorderClips,replacePresent,splitAtOutput,totalDuration,trimClipEdge,undo,usedVideoSrcIndices}from"./chunk-7D4QE3R2.js";import{DEFAULT_FILTERS as a}from"./chunk-T5QIAKTR.js";export{AudioClip,Clip,DEFAULT_FILTERS,ExportSettings,Overlay,Transition,VideoEditState,defaultVideoEditState}from"./chunk-T5QIAKTR.js";export{DEFAULT_PLATFORM_TARGETS,EDITOR_MESSAGES,IMAGE_PLATFORM_PRESETS,IMAGE_RATIO_PRESETS,VIDEO_PLATFORM_RATIO_PRESETS,VIDEO_RATIO_PRESETS,VIDEO_SIZE_PRESETS,buildImagePlatformPresets,buildVideoPlatformRatioPresets,buildVideoSizePresets,compensateAnnotationRotation,parseRatio,tEditor,toHant}from"./chunk-KO6CX4IJ.js";function r(t,e,n,s){const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(n,Math.max(e,o)):s}function i(t,e){const n=r(t,2,8192,e);return n%2==0?n:n-1}function u(t){return t.exportSettings??void 0}function c(t){return r(u(t)?.frameRate,12,120,30)}function h(e){const n=t(e.canvas,e),s=function(e){const n=t(e.canvas,e),s=u(e);if(!s)return n;const o=Number.isFinite(Number(s.width))&&Number(s.width)>0,a=Number.isFinite(Number(s.height))&&Number(s.height)>0;if(!o&&!a)return n;const r=n.w>0&&n.h>0?n.w/n.h:1;if(o&&a)return{w:i(s.width,n.w),h:i(s.height,n.h)};if(o){const t=i(s.width,n.w);return{w:t,h:i(t/r,n.h)}}const c=i(s.height,n.h);return{w:i(c*r,n.w),h:c}}(e);return s.w===n.w&&s.h===n.h?[]:[`scale=${s.w}:${s.h}`]}function l(t){const{brightness:e,contrast:n,saturation:s}=t,o=t.gamma??0,a=t.temperature??0,r=t.tint??0,i=t.vibrance??0,u=t.highlights??0,c=t.shadows??0,h=t.whites??0,l=t.blacks??0,p=t.lightSense??0;if(0===e&&0===n&&0===s&&0===o&&0===a&&0===r&&0===i&&0===u&&0===c&&0===h&&0===l&&0===p)return null;const $=[],f=e+.08*u+.06*c+.05*h-.05*l+.08*p,m=n+.08*h+.08*l,d=s+.65*i;0!==f&&$.push(`brightness=${f.toFixed(3)}`),0!==m&&$.push(`contrast=${(1+m).toFixed(3)}`),0!==d&&$.push(`saturation=${(1+d).toFixed(3)}`),0!==o&&$.push(`gamma=${(1+o*(o>0?1:.5)).toFixed(3)}`);const v=$.length?[`eq=${$.join(":")}`]:[];return 0===a&&0===r||v.push(`colorbalance=rs=${(.18*a+.08*r).toFixed(3)}:gs=${(.02*a-.04*r).toFixed(3)}:bs=${(.18*-a-.08*r).toFixed(3)}`),v.join(",")}function p(t){return Boolean(t.hidden)}function $(t,e,n,s,o,a){return p(e)?`color=c=black:s=${s}x${o}:r=${a}:d=${Math.max(.001,e.out-e.in)},setsar=1,format=yuv420p[v${n}]`:`[${t}:v]trim=start=${e.in}:end=${e.out},setpts=PTS-STARTPTS,scale=${s}:${o}:force_original_aspect_ratio=increase,crop=${s}:${o},setsar=1,fps=${a},format=yuv420p[v${n}]`}function f(t,e={}){const o=[];if(t.flipX&&o.push("hflip"),t.flipY&&o.push("vflip"),o.push(...function(t){const e=s(t);if(0===e)return[];if(90===e)return["transpose=1"];if(180===e)return["transpose=1","transpose=1"];if(270===e)return["transpose=2"];const n=`${e}*PI/180`;return[`rotate=${n}:ow=rotw(${n}):oh=roth(${n}):c=black`]}(t.rotation)),t.crop){const{x:e,y:n,width:s,height:a}=t.crop;o.push(`crop=${s}:${a}:${e}:${n}`)}if(t.scale){const{width:e,height:n,fit:s}=t.scale;"force"===s?o.push(`scale=${e}:${n}`):"cover"===s?o.push(`scale=${e}:${n}:force_original_aspect_ratio=increase`,`crop=${e}:${n}`):o.push(`scale=${e}:${n}:force_original_aspect_ratio=decrease`,`pad=${e}:${n}:(ow-iw)/2:(oh-ih)/2:${function(t){if("string"!=typeof t)return"0x000000";const e=t.trim(),n=e.match(/^#?([0-9a-fA-F]{3})$/);if(n)return`0x${n[1].split("").map(t=>t+t).join("").toLowerCase()}`;const s=e.match(/^#?([0-9a-fA-F]{6})$/);return s?`0x${s[1].toLowerCase()}`:"0x000000"}(t.scale.backgroundColor)}`)}const a=l(t.filters);a&&o.push(a);const r=n(t.filterPreset);return r&&o.push(r.vf),!1!==e.includeExportScale&&o.push(...h(t)),o.push(`fps=${c(t)}`),s(t.rotation)%90==0||t.scale||o.push("scale=trunc(iw/2)*2:trunc(ih/2)*2"),o}function m(t,e){const n=function(t){const e=String(u(t)?.format??"mp4").toLowerCase();return"mov"===e||"mxf"===e?e:"mp4"}(e),s="mxf"===n?["-c:v","mpeg2video","-pix_fmt","yuv422p"]:["-c:v","libx264","-preset","veryfast","-pix_fmt","yuv420p","-movflags","+faststart"],o=function(t){const e=Number(u(t)?.videoBitrateKbps);return Number.isFinite(e)&&e>=100?Math.round(e):0}(e);if(o>0?s.push("-b:v",`${o}k`,"-maxrate",`${o}k`,"-bufsize",`${Math.max(2*o,512)}k`):"mxf"===n&&s.push("-q:v","2"),t)if("mxf"===n)s.push("-c:a","pcm_s16le");else{s.push("-c:a",function(t){return"mp3"===u(t)?.audioCodec?"libmp3lame":"aac"}(e));const t=function(t){const e=Number(u(t)?.audioBitrateKbps);return Number.isFinite(e)&&e>=32?Math.round(e):0}(e);t>0&&s.push("-b:a",`${t}k`)}return"mxf"===n&&s.push("-f","mxf"),s}var d="aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo",v="anullsrc=r=44100:cl=stereo";function x(t){return t>.02?`,afade=t=in:st=0:d=0.01,afade=t=out:st=${Math.round(1e3*(t-.01))/1e3}:d=0.01`:""}function g(t,n=Number.POSITIVE_INFINITY){const s=[];for(const o of t??[]){if(e(o))continue;if("adjust"===o.type)continue;const t=Number(o.startAt),a=Number(o.endAt);if(Number.isFinite(t)&&Number.isFinite(a)&&!(a<=t)&&(s.push({startAt:Math.max(0,t),endAt:Math.max(t+.01,a)}),s.length>=n))break}return s}function b(t,e=2){const n=Math.max(e,Math.floor(Number(t)||e));return n%2==0?n:n-1}function S(t){const e=Number.isFinite(t.startAt)?Math.max(0,Number(t.startAt)):0,n=Number(t.endAt);return Number.isFinite(n)?{startAt:e,endAt:Math.max(e+.1,n)}:{startAt:e,endAt:e+3}}function A(t){const e=l({...a,...t}),s=n(t.filterPreset);return[e,s?.vf].filter(t=>Boolean(t))}function T(t,e){const n=Math.max(2,b(e.w)),s=Math.max(2,b(e.h)),o=Math.max(0,Math.min(n-2,b(t.x,0))),a=Math.max(0,Math.min(s-2,b(t.y,0))),r=Math.min(n-o,Math.max(2,b(t.w))),i=Math.min(s-a,Math.max(2,b(t.h)));return r<=1||i<=1?null:{x:o,y:a,w:r,h:i}}function y(t,n){const s=[];for(const o of t??[]){if(e(o))continue;if("adjust"!==o.type)continue;const t=T(o,n);if(!t)continue;const a=A(o);a.length&&s.push({rect:t,filters:a,...S(o)})}return s}function E(t,e,n,s){let o=e;return s.forEach((e,s)=>{const a=`[vtimed${n+s}]`;t.push(`${o}[${n+s}:v]overlay=0:0:enable='between(t,${e.startAt.toFixed(3)},${e.endAt.toFixed(3)})'${a}`),o=a}),o}function M(t,e,n){let s=e;return n.forEach((e,n)=>{const o=`[vadjsrc${n}]`,a=`[vadjbase${n}]`,r=`[vadjcrop${n}]`,i=`[vadj${n}]`,{rect:u}=e;t.push(`${s}split=2${o}${a}`),t.push(`${o}crop=${u.w}:${u.h}:${u.x}:${u.y},${e.filters.join(",")}${r}`),t.push(`${a}${r}overlay=${u.x}:${u.y}:enable='between(t,${e.startAt.toFixed(3)},${e.endAt.toFixed(3)})'${i}`),s=i}),s}function F(t){const e=Number(t.startAt),n=Number(t.endAt);return!Number.isFinite(e)||!Number.isFinite(n)||n<=e?"":`:enable='between(t,${Math.max(0,e).toFixed(3)},${Math.max(e+.01,n).toFixed(3)})'`}function w(t,e,n,s){const o=`[${s}src]`,a=`[${s}base]`,r=`[${s}crop]`,i=`[${s}]`,{rect:u}=n;return t.push(`${e}split=2${o}${a}`),t.push(`${o}crop=${u.w}:${u.h}:${u.x}:${u.y},${n.filters.join(",")}${r}`),t.push(`${a}${r}overlay=${u.x}:${u.y}:enable='between(t,${n.startAt.toFixed(3)},${n.endAt.toFixed(3)})'${i}`),i}function P(t,n,s,a,r,i,u){let c=n,h=0,l=0;for(const n of o(a??[])){if(e(n))continue;if("adjust"===n.type){const e=T(n,i),s=A(n);if(!e||!s.length)continue;c=w(t,c,{rect:e,filters:s,...S(n)},`v${u}adj${l}`),l++;continue}if(h>=r){h++;continue}const o=`[v${u}lay${h}]`;t.push(`${c}[${s+h}:v]overlay=0:0${F(n)}${o}`),c=o,h++}return c}function _(e,n,s){const{videoPaths:o,videoHasAudio:a,audioPaths:r,overlayPath:i,textOverlayPaths:u=[],overlayLayerPaths:l=[]}=n,b=(e.audioClips??[]).filter(t=>!t.muted),S=l.length>0,A=S?[]:g(e.overlays,u.length),T=S?[]:u.slice(0,A.length),F=S?l:[],w=S?[]:y(e.overlays,t(e.canvas,e));if(1===o.length&&0===b.length)return function(e,n,s,o,a,r=[],i=[]){const u=f(e,{includeExportScale:!1}),l=e.clips,d=e.keepAudio&&a,v=l.length>=2,b=l.some(p),S=c(e),A=i.length>0,T=A?[]:g(e.overlays,r.length),F=A?[]:r.slice(0,T.length),w=A?i:[],_=A?[]:y(e.overlays,t(e.canvas,e));if(v||b||o||F.length||w.length||_.length){const a=[];let r;if(v){l.forEach((t,n)=>{a.push($(0,t,n,e.canvas.w,e.canvas.h,S)),d&&a.push(`[0:a]atrim=start=${t.in}:end=${t.out},asetpts=PTS-STARTPTS${x(t.out-t.in)}[a${n}]`)});const t=l.map((t,e)=>d?`[v${e}][a${e}]`:`[v${e}]`).join(""),n=d?"[vcat][acat]":"[vcat]";a.push(`${t}concat=n=${l.length}:v=1:a=${d?1:0}${n}`),r="[vcat]"}else b?(a.push($(0,l[0],0,e.canvas.w,e.canvas.h,S)),r="[v0]"):r="[0:v]";u.length&&(a.push(`${r}${u.join(",")}[vflt]`),r="[vflt]"),w.length?(o&&(a.push(`${r}[1:v]overlay=0:0[vlegacy]`),r="[vlegacy]"),r=P(a,r,1+(o?1:0),e.overlays,w.length,t(e.canvas,e),"s")):_.length&&(r=M(a,r,_)),!w.length&&o?(a.push(`${r}[1:v]overlay=0:0[vout]`),r="[vout]"):"[0:v]"===r&&(a.push("[0:v]null[vout]"),r="[vout]"),F.length&&(r=E(a,r,1+(o?1:0),T));const i=h(e);i.length&&(a.push(`${r}${i.join(",")}[vscaled]`),r="[vscaled]");const c=[];v||1!==l.length||c.push("-ss",String(l[0].in),"-t",String(l[0].out-l[0].in));const p=["-y",...c,"-i",n];o&&p.push("-i",o);for(const t of w)p.push("-i",t);for(const t of F)p.push("-i",t);return p.push("-filter_complex",a.join(";"),"-map",r),d&&p.push("-map",v?"[acat]":"0:a?"),p.push(...m(d,e)),p.push(s),p}const R=["-ss",String(l[0].in),"-t",String(l[0].out-l[0].in)],I=f(e),j=["-y",...R,"-i",n];return I.length&&j.push("-vf",I.join(",")),d||j.push("-an"),j.push(...m(d,e)),j.push(s),j}(e,o[0],s,i,a[0]??!1,T,F);const _=o.length,R=r.length,I=e.canvas.w,j=e.canvas.h,N=e.clips,k=e.keepAudio&&N.some(t=>a[t.srcIdx]),O=c(e),C=N.reduce((t,e)=>t+(e.out-e.in),0),D=[];N.forEach((t,e)=>{D.push($(t.srcIdx,t,e,I,j,O)),k&&(a[t.srcIdx]?D.push(`[${t.srcIdx}:a]atrim=start=${t.in}:end=${t.out},asetpts=PTS-STARTPTS${x(t.out-t.in)},${d}[a${e}]`):D.push(`${v},atrim=start=0:end=${t.out-t.in},asetpts=PTS-STARTPTS,${d}[a${e}]`))});const L=N.map((t,e)=>k?`[v${e}][a${e}]`:`[v${e}]`).join("");D.push(`${L}concat=n=${N.length}:v=1:a=${k?1:0}${k?"[vcat][acat]":"[vcat]"}`);let V=k?"[acat]":"";if(!k&&b.length&&(D.push(`${v},atrim=start=0:end=${C},asetpts=PTS-STARTPTS,${d}[acat]`),V="[acat]"),b.length){b.forEach((t,e)=>{const n=Math.max(0,Math.round(1e3*t.startAt));D.push(function(t,e,n,s){const o=Math.min(2,Math.max(.5,e.speed??1)),a=function(t){return Math.max(.001,(t.out-t.in)/Math.max(.01,t.speed??1))}(e),r=Math.min(Math.max(0,e.fadeIn??0),a),i=Math.min(Math.max(0,e.fadeOut??0),a),u=[`atrim=start=${e.in}:end=${e.out}`,"asetpts=PTS-STARTPTS"];return Math.abs(o-1)>.001&&u.push(`atempo=${o.toFixed(3)}`),r>0&&u.push(`afade=t=in:st=0:d=${r.toFixed(3)}`),i>0&&u.push(`afade=t=out:st=${Math.max(0,a-i).toFixed(3)}:d=${i.toFixed(3)}`),u.push(`volume=${e.volume}`,d,`adelay=${n}|${n}`),`${t}${u.join(",")}[${s}]`}(`[${_+t.srcIdx}:a]`,t,n,`mu${e}`))});const t=`${V}${b.map((t,e)=>`[mu${e}]`).join("")}`;D.push(`${t}amix=inputs=${1+b.length}:duration=first:dropout_transition=0:normalize=0,alimiter=limit=0.95:level=disabled:latency=1[aout]`),V="[aout]"}let z="[vcat]";const G=f(e,{includeExportScale:!1});G.length&&(D.push(`${z}${G.join(",")}[vflt]`),z="[vflt]"),F.length?(i&&(D.push(`${z}[${_+R}:v]overlay=0:0[vlegacy]`),z="[vlegacy]"),z=P(D,z,_+R+(i?1:0),e.overlays,F.length,t(e.canvas,e),"m")):w.length&&(z=M(D,z,w)),!F.length&&i&&(D.push(`${z}[${_+R}:v]overlay=0:0[vout]`),z="[vout]"),T.length&&(z=E(D,z,_+R+(i?1:0),A));const K=h(e);K.length&&(D.push(`${z}${K.join(",")}[vscaled]`),z="[vscaled]");const B=["-y"];for(const t of o)B.push("-i",t);for(const t of r)B.push("-i",t);i&&B.push("-i",i);for(const t of F)B.push("-i",t);for(const t of T)B.push("-i",t);B.push("-filter_complex",D.join(";"),"-map",z);const H=!!V;return H&&B.push("-map",V),B.push(...m(H,e)),H&&B.push("-ar","44100","-ac","2"),B.push(s),B}function R(t,e,n){return["-y","-ss",String(e),"-i",t,"-frames:v","1","-q:v","2",n]}export{_ as buildFfmpegArgs,R as buildPosterArgs};
1
+ import{outputSize as t,isOverlayHidden as e,findFilterPreset as n,normalizeDeg as s,overlayLayerRenderOrder as o}from"./chunk-VDEZTXEA.js";export{DEG2RAD,FILTER_PRESETS,buildFilterCss,centeredMaxRect,clampRect,evenize,findFilterPreset,fitRects,normalizeDeg,outputSize,rotatedSize}from"./chunk-VDEZTXEA.js";export{MIN_CLIP,canRedo,canUndo,clampAudioClip,clipDuration,clipStartsAt,contentDuration,createHistory,duplicateClip,locateOutput,pushHistory,redo,remapSrcIndices,removeClip,reorderClips,replacePresent,splitAtOutput,totalDuration,trimClipEdge,undo,usedVideoSrcIndices}from"./chunk-7D4QE3R2.js";import{DEFAULT_FILTERS as a}from"./chunk-7PSQLYXL.js";export{AudioClip,Clip,DEFAULT_FILTERS,ExportSettings,Overlay,Transition,VideoEditState,defaultVideoEditState}from"./chunk-7PSQLYXL.js";export{DEFAULT_PLATFORM_TARGETS,EDITOR_MESSAGES,IMAGE_PLATFORM_PRESETS,IMAGE_RATIO_PRESETS,VIDEO_PLATFORM_RATIO_PRESETS,VIDEO_RATIO_PRESETS,VIDEO_SIZE_PRESETS,buildImagePlatformPresets,buildVideoPlatformRatioPresets,buildVideoSizePresets,compensateAnnotationRotation,parseRatio,tEditor,toHant}from"./chunk-FAFKY4LX.js";function r(t,e,n,s){const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(n,Math.max(e,o)):s}function i(t,e){const n=r(t,2,8192,e);return n%2==0?n:n-1}function u(t){return t.exportSettings??void 0}function c(t){return r(u(t)?.frameRate,12,120,30)}function h(e){const n=t(e.canvas,e),s=function(e){const n=t(e.canvas,e),s=u(e);if(!s)return n;const o=Number.isFinite(Number(s.width))&&Number(s.width)>0,a=Number.isFinite(Number(s.height))&&Number(s.height)>0;if(!o&&!a)return n;const r=n.w>0&&n.h>0?n.w/n.h:1;if(o&&a)return{w:i(s.width,n.w),h:i(s.height,n.h)};if(o){const t=i(s.width,n.w);return{w:t,h:i(t/r,n.h)}}const c=i(s.height,n.h);return{w:i(c*r,n.w),h:c}}(e);return s.w===n.w&&s.h===n.h?[]:[`scale=${s.w}:${s.h}`]}function l(t){const{brightness:e,contrast:n,saturation:s}=t,o=t.gamma??0,a=t.temperature??0,r=t.tint??0,i=t.vibrance??0,u=t.highlights??0,c=t.shadows??0,h=t.whites??0,l=t.blacks??0,p=t.lightSense??0;if(0===e&&0===n&&0===s&&0===o&&0===a&&0===r&&0===i&&0===u&&0===c&&0===h&&0===l&&0===p)return null;const $=[],f=e+.08*u+.06*c+.05*h-.05*l+.08*p,m=n+.08*h+.08*l,d=s+.65*i;0!==f&&$.push(`brightness=${f.toFixed(3)}`),0!==m&&$.push(`contrast=${(1+m).toFixed(3)}`),0!==d&&$.push(`saturation=${(1+d).toFixed(3)}`),0!==o&&$.push(`gamma=${(1+o*(o>0?1:.5)).toFixed(3)}`);const v=$.length?[`eq=${$.join(":")}`]:[];return 0===a&&0===r||v.push(`colorbalance=rs=${(.18*a+.08*r).toFixed(3)}:gs=${(.02*a-.04*r).toFixed(3)}:bs=${(.18*-a-.08*r).toFixed(3)}`),v.join(",")}function p(t){return Boolean(t.hidden)}function $(t,e,n,s,o,a){return p(e)?`color=c=black:s=${s}x${o}:r=${a}:d=${Math.max(.001,e.out-e.in)},setsar=1,format=yuv420p[v${n}]`:`[${t}:v]trim=start=${e.in}:end=${e.out},setpts=PTS-STARTPTS,scale=${s}:${o}:force_original_aspect_ratio=increase,crop=${s}:${o},setsar=1,fps=${a},format=yuv420p[v${n}]`}function f(t,e={}){const o=[];if(t.flipX&&o.push("hflip"),t.flipY&&o.push("vflip"),o.push(...function(t){const e=s(t);if(0===e)return[];if(90===e)return["transpose=1"];if(180===e)return["transpose=1","transpose=1"];if(270===e)return["transpose=2"];const n=`${e}*PI/180`;return[`rotate=${n}:ow=rotw(${n}):oh=roth(${n}):c=black`]}(t.rotation)),t.crop){const{x:e,y:n,width:s,height:a}=t.crop;o.push(`crop=${s}:${a}:${e}:${n}`)}if(t.scale){const{width:e,height:n,fit:s}=t.scale;"force"===s?o.push(`scale=${e}:${n}`):"cover"===s?o.push(`scale=${e}:${n}:force_original_aspect_ratio=increase`,`crop=${e}:${n}`):o.push(`scale=${e}:${n}:force_original_aspect_ratio=decrease`,`pad=${e}:${n}:(ow-iw)/2:(oh-ih)/2:${function(t){if("string"!=typeof t)return"0x000000";const e=t.trim(),n=e.match(/^#?([0-9a-fA-F]{3})$/);if(n)return`0x${n[1].split("").map(t=>t+t).join("").toLowerCase()}`;const s=e.match(/^#?([0-9a-fA-F]{6})$/);return s?`0x${s[1].toLowerCase()}`:"0x000000"}(t.scale.backgroundColor)}`)}const a=l(t.filters);a&&o.push(a);const r=n(t.filterPreset);return r&&o.push(r.vf),!1!==e.includeExportScale&&o.push(...h(t)),o.push(`fps=${c(t)}`),s(t.rotation)%90==0||t.scale||o.push("scale=trunc(iw/2)*2:trunc(ih/2)*2"),o}function m(t,e){const n=function(t){const e=String(u(t)?.format??"mp4").toLowerCase();return"mov"===e||"mxf"===e?e:"mp4"}(e),s="mxf"===n?["-c:v","mpeg2video","-pix_fmt","yuv422p"]:["-c:v","libx264","-preset","veryfast","-pix_fmt","yuv420p","-movflags","+faststart"],o=function(t){const e=Number(u(t)?.videoBitrateKbps);return Number.isFinite(e)&&e>=100?Math.round(e):0}(e);if(o>0?s.push("-b:v",`${o}k`,"-maxrate",`${o}k`,"-bufsize",`${Math.max(2*o,512)}k`):"mxf"===n&&s.push("-q:v","2"),t)if("mxf"===n)s.push("-c:a","pcm_s16le");else{s.push("-c:a",function(t){return"mp3"===u(t)?.audioCodec?"libmp3lame":"aac"}(e));const t=function(t){const e=Number(u(t)?.audioBitrateKbps);return Number.isFinite(e)&&e>=32?Math.round(e):0}(e);t>0&&s.push("-b:a",`${t}k`)}return"mxf"===n&&s.push("-f","mxf"),s}var d="aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo",v="anullsrc=r=44100:cl=stereo";function x(t){return t>.02?`,afade=t=in:st=0:d=0.01,afade=t=out:st=${Math.round(1e3*(t-.01))/1e3}:d=0.01`:""}function g(t,n=Number.POSITIVE_INFINITY){const s=[];for(const o of t??[]){if(e(o))continue;if("adjust"===o.type)continue;const t=Number(o.startAt),a=Number(o.endAt);if(Number.isFinite(t)&&Number.isFinite(a)&&!(a<=t)&&(s.push({startAt:Math.max(0,t),endAt:Math.max(t+.01,a)}),s.length>=n))break}return s}function b(t,e=2){const n=Math.max(e,Math.floor(Number(t)||e));return n%2==0?n:n-1}function S(t){const e=Number.isFinite(t.startAt)?Math.max(0,Number(t.startAt)):0,n=Number(t.endAt);return Number.isFinite(n)?{startAt:e,endAt:Math.max(e+.1,n)}:{startAt:e,endAt:e+3}}function A(t){const e=l({...a,...t}),s=n(t.filterPreset);return[e,s?.vf].filter(t=>Boolean(t))}function y(t,e){const n=Math.max(2,b(e.w)),s=Math.max(2,b(e.h)),o=Math.max(0,Math.min(n-2,b(t.x,0))),a=Math.max(0,Math.min(s-2,b(t.y,0))),r=Math.min(n-o,Math.max(2,b(t.w))),i=Math.min(s-a,Math.max(2,b(t.h)));return r<=1||i<=1?null:{x:o,y:a,w:r,h:i}}function T(t,n){const s=[];for(const o of t??[]){if(e(o))continue;if("adjust"!==o.type)continue;const t=y(o,n);if(!t)continue;const a=A(o);a.length&&s.push({rect:t,filters:a,...S(o)})}return s}function E(t,e,n,s){let o=e;return s.forEach((e,s)=>{const a=`[vtimed${n+s}]`;t.push(`${o}[${n+s}:v]overlay=0:0:enable='between(t,${e.startAt.toFixed(3)},${e.endAt.toFixed(3)})'${a}`),o=a}),o}function M(t,e,n){let s=e;return n.forEach((e,n)=>{const o=`[vadjsrc${n}]`,a=`[vadjbase${n}]`,r=`[vadjcrop${n}]`,i=`[vadj${n}]`,{rect:u}=e;t.push(`${s}split=2${o}${a}`),t.push(`${o}crop=${u.w}:${u.h}:${u.x}:${u.y},${e.filters.join(",")}${r}`),t.push(`${a}${r}overlay=${u.x}:${u.y}:enable='between(t,${e.startAt.toFixed(3)},${e.endAt.toFixed(3)})'${i}`),s=i}),s}function F(t){const e=Number(t.startAt),n=Number(t.endAt);return!Number.isFinite(e)||!Number.isFinite(n)||n<=e?"":`:enable='between(t,${Math.max(0,e).toFixed(3)},${Math.max(e+.01,n).toFixed(3)})'`}function P(t,e,n,s){const o=`[${s}src]`,a=`[${s}base]`,r=`[${s}crop]`,i=`[${s}]`,{rect:u}=n;return t.push(`${e}split=2${o}${a}`),t.push(`${o}crop=${u.w}:${u.h}:${u.x}:${u.y},${n.filters.join(",")}${r}`),t.push(`${a}${r}overlay=${u.x}:${u.y}:enable='between(t,${n.startAt.toFixed(3)},${n.endAt.toFixed(3)})'${i}`),i}function w(t,n,s,a,r,i,u){let c=n,h=0,l=0;for(const n of o(a??[])){if(e(n))continue;if("adjust"===n.type){const e=y(n,i),s=A(n);if(!e||!s.length)continue;c=P(t,c,{rect:e,filters:s,...S(n)},`v${u}adj${l}`),l++;continue}if(h>=r){h++;continue}const o=`[v${u}lay${h}]`;t.push(`${c}[${s+h}:v]overlay=0:0${F(n)}${o}`),c=o,h++}return c}function _(e,n,s){const{videoPaths:o,videoHasAudio:a,audioPaths:r,overlayPath:i,textOverlayPaths:u=[],overlayLayerPaths:l=[]}=n,b=(e.audioClips??[]).filter(t=>!t.muted),S=l.length>0,A=S?[]:g(e.overlays,u.length),y=S?[]:u.slice(0,A.length),F=S?l:[],P=S?[]:T(e.overlays,t(e.canvas,e));if(1===o.length&&0===b.length)return function(e,n,s,o,a,r=[],i=[]){const u=f(e,{includeExportScale:!1}),l=e.clips,d=e.keepAudio&&a,v=l.length>=2,b=l.some(p),S=c(e),A=i.length>0,y=A?[]:g(e.overlays,r.length),F=A?[]:r.slice(0,y.length),P=A?i:[],_=A?[]:T(e.overlays,t(e.canvas,e));if(v||b||o||F.length||P.length||_.length){const a=[];let r;if(v){l.forEach((t,n)=>{a.push($(0,t,n,e.canvas.w,e.canvas.h,S)),d&&a.push(`[0:a]atrim=start=${t.in}:end=${t.out},asetpts=PTS-STARTPTS${x(t.out-t.in)}[a${n}]`)});const t=l.map((t,e)=>d?`[v${e}][a${e}]`:`[v${e}]`).join(""),n=d?"[vcat][acat]":"[vcat]";a.push(`${t}concat=n=${l.length}:v=1:a=${d?1:0}${n}`),r="[vcat]"}else b?(a.push($(0,l[0],0,e.canvas.w,e.canvas.h,S)),r="[v0]"):r="[0:v]";u.length&&(a.push(`${r}${u.join(",")}[vflt]`),r="[vflt]"),P.length?(o&&(a.push(`${r}[1:v]overlay=0:0[vlegacy]`),r="[vlegacy]"),r=w(a,r,1+(o?1:0),e.overlays,P.length,t(e.canvas,e),"s")):_.length&&(r=M(a,r,_)),!P.length&&o?(a.push(`${r}[1:v]overlay=0:0[vout]`),r="[vout]"):"[0:v]"===r&&(a.push("[0:v]null[vout]"),r="[vout]"),F.length&&(r=E(a,r,1+(o?1:0),y));const i=h(e);i.length&&(a.push(`${r}${i.join(",")}[vscaled]`),r="[vscaled]");const c=[];v||1!==l.length||c.push("-ss",String(l[0].in),"-t",String(l[0].out-l[0].in));const p=["-y",...c,"-i",n];o&&p.push("-i",o);for(const t of P)p.push("-i",t);for(const t of F)p.push("-i",t);return p.push("-filter_complex",a.join(";"),"-map",r),d&&p.push("-map",v?"[acat]":"0:a?"),p.push(...m(d,e)),p.push(s),p}const R=["-ss",String(l[0].in),"-t",String(l[0].out-l[0].in)],j=f(e),I=["-y",...R,"-i",n];return j.length&&I.push("-vf",j.join(",")),d||I.push("-an"),I.push(...m(d,e)),I.push(s),I}(e,o[0],s,i,a[0]??!1,y,F);const _=o.length,R=r.length,j=e.canvas.w,I=e.canvas.h,N=e.clips,k=e.keepAudio&&N.some(t=>a[t.srcIdx]),L=c(e),O=N.reduce((t,e)=>t+(e.out-e.in),0),C=[];N.forEach((t,e)=>{C.push($(t.srcIdx,t,e,j,I,L)),k&&(a[t.srcIdx]?C.push(`[${t.srcIdx}:a]atrim=start=${t.in}:end=${t.out},asetpts=PTS-STARTPTS${x(t.out-t.in)},${d}[a${e}]`):C.push(`${v},atrim=start=0:end=${t.out-t.in},asetpts=PTS-STARTPTS,${d}[a${e}]`))});const D=N.map((t,e)=>k?`[v${e}][a${e}]`:`[v${e}]`).join("");C.push(`${D}concat=n=${N.length}:v=1:a=${k?1:0}${k?"[vcat][acat]":"[vcat]"}`);let V=k?"[acat]":"";if(!k&&b.length&&(C.push(`${v},atrim=start=0:end=${O},asetpts=PTS-STARTPTS,${d}[acat]`),V="[acat]"),b.length){b.forEach((t,e)=>{const n=Math.max(0,Math.round(1e3*t.startAt));C.push(function(t,e,n,s){const o=Math.min(2,Math.max(.5,e.speed??1)),a=function(t){return Math.max(.001,(t.out-t.in)/Math.max(.01,t.speed??1))}(e),r=Math.min(Math.max(0,e.fadeIn??0),a),i=Math.min(Math.max(0,e.fadeOut??0),a),u=[`atrim=start=${e.in}:end=${e.out}`,"asetpts=PTS-STARTPTS"];return Math.abs(o-1)>.001&&u.push(`atempo=${o.toFixed(3)}`),r>0&&u.push(`afade=t=in:st=0:d=${r.toFixed(3)}`),i>0&&u.push(`afade=t=out:st=${Math.max(0,a-i).toFixed(3)}:d=${i.toFixed(3)}`),u.push(`volume=${e.volume}`,d,`adelay=${n}|${n}`),`${t}${u.join(",")}[${s}]`}(`[${_+t.srcIdx}:a]`,t,n,`mu${e}`))});const t=`${V}${b.map((t,e)=>`[mu${e}]`).join("")}`;C.push(`${t}amix=inputs=${1+b.length}:duration=first:dropout_transition=0:normalize=0,alimiter=limit=0.95:level=disabled:latency=1[aout]`),V="[aout]"}let z="[vcat]";const X=f(e,{includeExportScale:!1});X.length&&(C.push(`${z}${X.join(",")}[vflt]`),z="[vflt]"),F.length?(i&&(C.push(`${z}[${_+R}:v]overlay=0:0[vlegacy]`),z="[vlegacy]"),z=w(C,z,_+R+(i?1:0),e.overlays,F.length,t(e.canvas,e),"m")):P.length&&(z=M(C,z,P)),!F.length&&i&&(C.push(`${z}[${_+R}:v]overlay=0:0[vout]`),z="[vout]"),y.length&&(z=E(C,z,_+R+(i?1:0),A));const G=h(e);G.length&&(C.push(`${z}${G.join(",")}[vscaled]`),z="[vscaled]");const Y=["-y"];for(const t of o)Y.push("-i",t);for(const t of r)Y.push("-i",t);i&&Y.push("-i",i);for(const t of F)Y.push("-i",t);for(const t of y)Y.push("-i",t);Y.push("-filter_complex",C.join(";"),"-map",z);const B=!!V;return B&&Y.push("-map",V),Y.push(...m(B,e)),B&&Y.push("-ar","44100","-ac","2"),Y.push(s),Y}function R(t,e,n){return["-y","-ss",String(e),"-i",t,"-frames:v","1","-q:v","2",n]}export{_ as buildFfmpegArgs,R as buildPosterArgs};
@@ -514,6 +514,7 @@ declare const ExportSettings: z.ZodOptional<z.ZodObject<{
514
514
  width: z.ZodOptional<z.ZodNumber>;
515
515
  height: z.ZodOptional<z.ZodNumber>;
516
516
  frameRate: z.ZodDefault<z.ZodNumber>;
517
+ bitrateMode: z.ZodOptional<z.ZodEnum<["auto", "custom"]>>;
517
518
  videoBitrateKbps: z.ZodOptional<z.ZodNumber>;
518
519
  audioBitrateKbps: z.ZodOptional<z.ZodNumber>;
519
520
  audioCodec: z.ZodDefault<z.ZodEnum<["aac", "mp3"]>>;
@@ -524,6 +525,7 @@ declare const ExportSettings: z.ZodOptional<z.ZodObject<{
524
525
  width?: number | undefined;
525
526
  fileName?: string | undefined;
526
527
  height?: number | undefined;
528
+ bitrateMode?: "custom" | "auto" | undefined;
527
529
  videoBitrateKbps?: number | undefined;
528
530
  audioBitrateKbps?: number | undefined;
529
531
  }, {
@@ -532,6 +534,7 @@ declare const ExportSettings: z.ZodOptional<z.ZodObject<{
532
534
  format?: "mp4" | "mov" | "mxf" | undefined;
533
535
  height?: number | undefined;
534
536
  frameRate?: number | undefined;
537
+ bitrateMode?: "custom" | "auto" | undefined;
535
538
  videoBitrateKbps?: number | undefined;
536
539
  audioBitrateKbps?: number | undefined;
537
540
  audioCodec?: "aac" | "mp3" | undefined;
@@ -1170,6 +1173,7 @@ declare const VideoEditState: z.ZodEffects<z.ZodObject<{
1170
1173
  width: z.ZodOptional<z.ZodNumber>;
1171
1174
  height: z.ZodOptional<z.ZodNumber>;
1172
1175
  frameRate: z.ZodDefault<z.ZodNumber>;
1176
+ bitrateMode: z.ZodOptional<z.ZodEnum<["auto", "custom"]>>;
1173
1177
  videoBitrateKbps: z.ZodOptional<z.ZodNumber>;
1174
1178
  audioBitrateKbps: z.ZodOptional<z.ZodNumber>;
1175
1179
  audioCodec: z.ZodDefault<z.ZodEnum<["aac", "mp3"]>>;
@@ -1180,6 +1184,7 @@ declare const VideoEditState: z.ZodEffects<z.ZodObject<{
1180
1184
  width?: number | undefined;
1181
1185
  fileName?: string | undefined;
1182
1186
  height?: number | undefined;
1187
+ bitrateMode?: "custom" | "auto" | undefined;
1183
1188
  videoBitrateKbps?: number | undefined;
1184
1189
  audioBitrateKbps?: number | undefined;
1185
1190
  }, {
@@ -1188,6 +1193,7 @@ declare const VideoEditState: z.ZodEffects<z.ZodObject<{
1188
1193
  format?: "mp4" | "mov" | "mxf" | undefined;
1189
1194
  height?: number | undefined;
1190
1195
  frameRate?: number | undefined;
1196
+ bitrateMode?: "custom" | "auto" | undefined;
1191
1197
  videoBitrateKbps?: number | undefined;
1192
1198
  audioBitrateKbps?: number | undefined;
1193
1199
  audioCodec?: "aac" | "mp3" | undefined;
@@ -1410,6 +1416,7 @@ declare const VideoEditState: z.ZodEffects<z.ZodObject<{
1410
1416
  width?: number | undefined;
1411
1417
  fileName?: string | undefined;
1412
1418
  height?: number | undefined;
1419
+ bitrateMode?: "custom" | "auto" | undefined;
1413
1420
  videoBitrateKbps?: number | undefined;
1414
1421
  audioBitrateKbps?: number | undefined;
1415
1422
  } | undefined;
@@ -1630,6 +1637,7 @@ declare const VideoEditState: z.ZodEffects<z.ZodObject<{
1630
1637
  format?: "mp4" | "mov" | "mxf" | undefined;
1631
1638
  height?: number | undefined;
1632
1639
  frameRate?: number | undefined;
1640
+ bitrateMode?: "custom" | "auto" | undefined;
1633
1641
  videoBitrateKbps?: number | undefined;
1634
1642
  audioBitrateKbps?: number | undefined;
1635
1643
  audioCodec?: "aac" | "mp3" | undefined;
@@ -1852,6 +1860,7 @@ declare const VideoEditState: z.ZodEffects<z.ZodObject<{
1852
1860
  width?: number | undefined;
1853
1861
  fileName?: string | undefined;
1854
1862
  height?: number | undefined;
1863
+ bitrateMode?: "custom" | "auto" | undefined;
1855
1864
  videoBitrateKbps?: number | undefined;
1856
1865
  audioBitrateKbps?: number | undefined;
1857
1866
  } | undefined;
@@ -2072,6 +2081,7 @@ declare const VideoEditState: z.ZodEffects<z.ZodObject<{
2072
2081
  format?: "mp4" | "mov" | "mxf" | undefined;
2073
2082
  height?: number | undefined;
2074
2083
  frameRate?: number | undefined;
2084
+ bitrateMode?: "custom" | "auto" | undefined;
2075
2085
  videoBitrateKbps?: number | undefined;
2076
2086
  audioBitrateKbps?: number | undefined;
2077
2087
  audioCodec?: "aac" | "mp3" | undefined;
package/core/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@media-editor/core",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "媒体编辑器框架无关内核:状态/时间轴/ffmpeg 参数/几何/标注渲染/VideoEditorEngine/图片编辑器纯配置工厂(零 React)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1 +1 @@
1
- import{ZodError as R,ZodIssueCode as o}from"./ZodError.js";import{defaultErrorMap as _e,getErrorMap as ye}from"./errors.js";import{errorUtil as l}from"./helpers/errorUtil.js";import{DIRTY as W,INVALID as f,OK as x,ParseStatus as w,addIssueToContext as c,isAborted as ge,isAsync as ie,isDirty as ve,isValid as D,makeIssue as ke}from"./helpers/parseUtil.js";import{util as k,ZodParsedType as h,getParsedType as j}from"./helpers/util.js";class C{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const xe=(r,e)=>{if(D(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;const t=new R(r.common.issues);return this._error=t,this._error}}};function _(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:a}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(d,i)=>{const{message:n}=r;return d.code==="invalid_enum_value"?{message:n??i.defaultError}:typeof i.data>"u"?{message:n??s??i.defaultError}:d.code!=="invalid_type"?{message:i.defaultError}:{message:n??t??i.defaultError}},description:a}}class y{get description(){return this._def.description}_getType(e){return j(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:j(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new w,ctx:{common:e.parent.common,data:e.data,parsedType:j(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ie(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:j(e)},a=this._parseSync({data:e,path:s.path,parent:s});return xe(s,a)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:j(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return D(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>D(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:j(e)},a=this._parse({data:e,path:s.path,parent:s}),d=await(ie(a)?a:Promise.resolve(a));return xe(s,d)}refine(e,t){const s=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,d)=>{const i=e(a),n=()=>d.addIssue({code:o.custom,...s(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(n(),!1)):i?!0:(n(),!1)})}refinement(e,t){return this._refinement((s,a)=>e(s)?!0:(a.addIssue(typeof t=="function"?t(s,a):t),!1))}_refinement(e){return new b({schema:this,typeName:p.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 I.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Z.create(this)}promise(){return K.create(this,this._def)}or(e){return J.create([this,e],this._def)}and(e){return G.create(this,e,this._def)}transform(e){return new b({..._(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new te({..._(this._def),innerType:this,defaultValue:t,typeName:p.ZodDefault})}brand(){return new fe({typeName:p.ZodBranded,type:this,..._(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new se({..._(this._def),innerType:this,catchValue:t,typeName:p.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return re.create(this,e)}readonly(){return ae.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const je=/^c[^\s-]{8,}$/i,Pe=/^[0-9a-z]+$/,Ie=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ee=/^[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,Fe=/^[a-z0-9_-]{21}$/i,Le=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Me=/^[-+]?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)?)??$/,$e=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ze="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let pe;const De=/^(?:(?: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])$/,Ue=/^(?:(?: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])$/,Ve=/^(([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]))$/,Ke=/^(([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])$/,Be=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,We=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,we="((\\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])))",Ye=new RegExp(`^${we}$`);function be(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function qe(r){return new RegExp(`^${be(r)}$`)}function Ze(r){let e=`${we}T${be(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function He(r,e){return!!((e==="v4"||!e)&&De.test(r)||(e==="v6"||!e)&&Ve.test(r))}function Je(r,e){if(!Le.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(s));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function Ge(r,e){return!!((e==="v4"||!e)&&Ue.test(r)||(e==="v6"||!e)&&Ke.test(r))}class T extends y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const a=this._getOrReturnCtx(e);return c(a,{code:o.invalid_type,expected:h.string,received:a.parsedType}),f}const t=new w;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:o.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:o.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if(a.kind==="length"){const d=e.data.length>a.value,i=e.data.length<a.value;(d||i)&&(s=this._getOrReturnCtx(e,s),d?c(s,{code:o.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&c(s,{code:o.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),t.dirty())}else if(a.kind==="email")$e.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"email",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="emoji")pe||(pe=new RegExp(ze,"u")),pe.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"emoji",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="uuid")Ee.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"uuid",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="nanoid")Fe.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"nanoid",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="cuid")je.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"cuid",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="cuid2")Pe.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"cuid2",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="ulid")Ie.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"ulid",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),c(s,{validation:"url",code:o.invalid_string,message:a.message}),t.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"regex",code:o.invalid_string,message:a.message}),t.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),c(s,{code:o.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),t.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),c(s,{code:o.invalid_string,validation:{startsWith:a.value},message:a.message}),t.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),c(s,{code:o.invalid_string,validation:{endsWith:a.value},message:a.message}),t.dirty()):a.kind==="datetime"?Ze(a).test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{code:o.invalid_string,validation:"datetime",message:a.message}),t.dirty()):a.kind==="date"?Ye.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{code:o.invalid_string,validation:"date",message:a.message}),t.dirty()):a.kind==="time"?qe(a).test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{code:o.invalid_string,validation:"time",message:a.message}),t.dirty()):a.kind==="duration"?Me.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"duration",code:o.invalid_string,message:a.message}),t.dirty()):a.kind==="ip"?He(e.data,a.version)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"ip",code:o.invalid_string,message:a.message}),t.dirty()):a.kind==="jwt"?Je(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"jwt",code:o.invalid_string,message:a.message}),t.dirty()):a.kind==="cidr"?Ge(e.data,a.version)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"cidr",code:o.invalid_string,message:a.message}),t.dirty()):a.kind==="base64"?Be.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"base64",code:o.invalid_string,message:a.message}),t.dirty()):a.kind==="base64url"?We.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"base64url",code:o.invalid_string,message:a.message}),t.dirty()):k.assertNever(a);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(a=>e.test(a),{validation:t,code:o.invalid_string,...l.errToObj(s)})}_addCheck(e){return new T({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...l.errToObj(e)})}url(e){return this._addCheck({kind:"url",...l.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...l.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...l.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...l.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...l.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...l.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...l.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...l.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...l.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...l.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...l.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...l.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,...l.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,...l.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...l.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...l.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...l.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...l.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...l.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...l.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...l.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...l.errToObj(t)})}nonempty(e){return this.min(1,l.errToObj(e))}trim(){return new T({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new T({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new T({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}T.create=r=>new T({checks:[],typeName:p.ZodString,coerce:r?.coerce??!1,..._(r)});function Xe(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,a=t>s?t:s,d=Number.parseInt(r.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return d%i/10**a}class E extends y{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)!==h.number){const a=this._getOrReturnCtx(e);return c(a,{code:o.invalid_type,expected:h.number,received:a.parsedType}),f}let t;const s=new w;for(const a of this._def.checks)a.kind==="int"?k.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),c(t,{code:o.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.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)&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Xe(e.data,a.value)!==0&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),c(t,{code:o.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,l.toString(t))}gt(e,t){return this.setLimit("min",e,!1,l.toString(t))}lte(e,t){return this.setLimit("max",e,!0,l.toString(t))}lt(e,t){return this.setLimit("max",e,!1,l.toString(t))}setLimit(e,t,s,a){return new E({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:l.toString(a)}]})}_addCheck(e){return new E({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:l.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:l.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:l.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:l.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:l.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:l.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:l.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:l.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:l.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const 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(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}E.create=r=>new E({checks:[],typeName:p.ZodNumber,coerce:r?.coerce||!1,..._(r)});class F extends y{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)!==h.bigint)return this._getInvalidInput(e);let t;const s=new w;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.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)&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.bigint,received:t.parsedType}),f}gte(e,t){return this.setLimit("min",e,!0,l.toString(t))}gt(e,t){return this.setLimit("min",e,!1,l.toString(t))}lte(e,t){return this.setLimit("max",e,!0,l.toString(t))}lt(e,t){return this.setLimit("max",e,!1,l.toString(t))}setLimit(e,t,s,a){return new F({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:l.toString(a)}]})}_addCheck(e){return new F({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:l.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:l.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:l.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:l.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:l.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}F.create=r=>new F({checks:[],typeName:p.ZodBigInt,coerce:r?.coerce??!1,..._(r)});class Y extends y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.boolean,received:t.parsedType}),f}return x(e.data)}}Y.create=r=>new Y({typeName:p.ZodBoolean,coerce:r?.coerce||!1,..._(r)});class $ extends y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const a=this._getOrReturnCtx(e);return c(a,{code:o.invalid_type,expected:h.date,received:a.parsedType}),f}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return c(a,{code:o.invalid_date}),f}const t=new w;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:o.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),t.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:o.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),t.dirty()):k.assertNever(a);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new $({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:l.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:l.toString(t)})}get minDate(){let e=null;for(const 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(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}$.create=r=>new $({checks:[],coerce:r?.coerce||!1,typeName:p.ZodDate,..._(r)});class de extends y{_parse(e){if(this._getType(e)!==h.symbol){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.symbol,received:t.parsedType}),f}return x(e.data)}}de.create=r=>new de({typeName:p.ZodSymbol,..._(r)});class q extends y{_parse(e){if(this._getType(e)!==h.undefined){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.undefined,received:t.parsedType}),f}return x(e.data)}}q.create=r=>new q({typeName:p.ZodUndefined,..._(r)});class H extends y{_parse(e){if(this._getType(e)!==h.null){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.null,received:t.parsedType}),f}return x(e.data)}}H.create=r=>new H({typeName:p.ZodNull,..._(r)});class U extends y{constructor(){super(...arguments),this._any=!0}_parse(e){return x(e.data)}}U.create=r=>new U({typeName:p.ZodAny,..._(r)});class M extends y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return x(e.data)}}M.create=r=>new M({typeName:p.ZodUnknown,..._(r)});class N extends y{_parse(e){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.never,received:t.parsedType}),f}}N.create=r=>new N({typeName:p.ZodNever,..._(r)});class oe extends y{_parse(e){if(this._getType(e)!==h.undefined){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.void,received:t.parsedType}),f}return x(e.data)}}oe.create=r=>new oe({typeName:p.ZodVoid,..._(r)});class Z extends y{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==h.array)return c(t,{code:o.invalid_type,expected:h.array,received:t.parsedType}),f;if(a.exactLength!==null){const i=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(i||n)&&(c(t,{code:i?o.too_big:o.too_small,minimum:n?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(c(t,{code:o.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(c(t,{code:o.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,n)=>a.type._parseAsync(new C(t,i,t.path,n)))).then(i=>w.mergeArray(s,i));const d=[...t.data].map((i,n)=>a.type._parseSync(new C(t,i,t.path,n)));return w.mergeArray(s,d)}get element(){return this._def.type}min(e,t){return new Z({...this._def,minLength:{value:e,message:l.toString(t)}})}max(e,t){return new Z({...this._def,maxLength:{value:e,message:l.toString(t)}})}length(e,t){return new Z({...this._def,exactLength:{value:e,message:l.toString(t)}})}nonempty(e){return this.min(1,e)}}Z.create=(r,e)=>new Z({type:r,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,..._(e)});function V(r){if(r instanceof v){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=O.create(V(s))}return new v({...r._def,shape:()=>e})}else return r instanceof Z?new Z({...r._def,type:V(r.element)}):r instanceof O?O.create(V(r.unwrap())):r instanceof I?I.create(V(r.unwrap())):r instanceof A?A.create(r.items.map(e=>V(e))):r}class v extends y{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==h.object){const u=this._getOrReturnCtx(e);return c(u,{code:o.invalid_type,expected:h.object,received:u.parsedType}),f}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:d}=this._getCached(),i=[];if(!(this._def.catchall instanceof N&&this._def.unknownKeys==="strip"))for(const u in s.data)d.includes(u)||i.push(u);const n=[];for(const u of d){const m=a[u],g=s.data[u];n.push({key:{status:"valid",value:u},value:m._parse(new C(s,g,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof N){const u=this._def.unknownKeys;if(u==="passthrough")for(const m of i)n.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(u==="strict")i.length>0&&(c(s,{code:o.unrecognized_keys,keys:i}),t.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const m of i){const g=s.data[m];n.push({key:{status:"valid",value:m},value:u._parse(new C(s,g,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const m of n){const g=await m.key,S=await m.value;u.push({key:g,value:S,alwaysSet:m.alwaysSet})}return u}).then(u=>w.mergeObjectSync(t,u)):w.mergeObjectSync(t,n)}get shape(){return this._def.shape()}strict(e){return l.errToObj,new v({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{const a=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:l.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new v({...this._def,unknownKeys:"strip"})}passthrough(){return new v({...this._def,unknownKeys:"passthrough"})}extend(e){return new v({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new v({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:p.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new v({...this._def,catchall:e})}pick(e){const t={};for(const s of k.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new v({...this._def,shape:()=>t})}omit(e){const t={};for(const s of k.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new v({...this._def,shape:()=>t})}deepPartial(){return V(this)}partial(e){const t={};for(const s of k.objectKeys(this.shape)){const a=this.shape[s];e&&!e[s]?t[s]=a:t[s]=a.optional()}return new v({...this._def,shape:()=>t})}required(e){const t={};for(const s of k.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof O;)a=a._def.innerType;t[s]=a}return new v({...this._def,shape:()=>t})}keyof(){return Te(k.objectKeys(this.shape))}}v.create=(r,e)=>new v({shape:()=>r,unknownKeys:"strip",catchall:N.create(),typeName:p.ZodObject,..._(e)}),v.strictCreate=(r,e)=>new v({shape:()=>r,unknownKeys:"strict",catchall:N.create(),typeName:p.ZodObject,..._(e)}),v.lazycreate=(r,e)=>new v({shape:r,unknownKeys:"strip",catchall:N.create(),typeName:p.ZodObject,..._(e)});class J extends y{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function a(d){for(const n of d)if(n.result.status==="valid")return n.result;for(const n of d)if(n.result.status==="dirty")return t.common.issues.push(...n.ctx.common.issues),n.result;const i=d.map(n=>new R(n.ctx.common.issues));return c(t,{code:o.invalid_union,unionErrors:i}),f}if(t.common.async)return Promise.all(s.map(async d=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await d._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let d;const i=[];for(const u of s){const m={...t,common:{...t.common,issues:[]},parent:null},g=u._parseSync({data:t.data,path:t.path,parent:m});if(g.status==="valid")return g;g.status==="dirty"&&!d&&(d={result:g,ctx:m}),m.common.issues.length&&i.push(m.common.issues)}if(d)return t.common.issues.push(...d.ctx.common.issues),d.result;const n=i.map(u=>new R(u));return c(t,{code:o.invalid_union,unionErrors:n}),f}}get options(){return this._def.options}}J.create=(r,e)=>new J({options:r,typeName:p.ZodUnion,..._(e)});const P=r=>r instanceof X?P(r.schema):r instanceof b?P(r.innerType()):r instanceof Q?[r.value]:r instanceof L?r.options:r instanceof ee?k.objectValues(r.enum):r instanceof te?P(r._def.innerType):r instanceof q?[void 0]:r instanceof H?[null]:r instanceof O?[void 0,...P(r.unwrap())]:r instanceof I?[null,...P(r.unwrap())]:r instanceof fe||r instanceof ae?P(r.unwrap()):r instanceof se?P(r._def.innerType):[];class le extends y{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return c(t,{code:o.invalid_type,expected:h.object,received:t.parsedType}),f;const s=this.discriminator,a=t.data[s],d=this.optionsMap.get(a);return d?t.common.async?d._parseAsync({data:t.data,path:t.path,parent:t}):d._parseSync({data:t.data,path:t.path,parent:t}):(c(t,{code:o.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const d of t){const i=P(d.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of i){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,d)}}return new le({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,..._(s)})}}function me(r,e){const t=j(r),s=j(e);if(r===e)return{valid:!0,data:r};if(t===h.object&&s===h.object){const a=k.objectKeys(e),d=k.objectKeys(r).filter(n=>a.indexOf(n)!==-1),i={...r,...e};for(const n of d){const u=me(r[n],e[n]);if(!u.valid)return{valid:!1};i[n]=u.data}return{valid:!0,data:i}}else if(t===h.array&&s===h.array){if(r.length!==e.length)return{valid:!1};const a=[];for(let d=0;d<r.length;d++){const i=r[d],n=e[d],u=me(i,n);if(!u.valid)return{valid:!1};a.push(u.data)}return{valid:!0,data:a}}else return t===h.date&&s===h.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class G extends y{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(d,i)=>{if(ge(d)||ge(i))return f;const n=me(d.value,i.value);return n.valid?((ve(d)||ve(i))&&t.dirty(),{status:t.value,value:n.data}):(c(s,{code:o.invalid_intersection_types}),f)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([d,i])=>a(d,i)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}G.create=(r,e,t)=>new G({left:r,right:e,typeName:p.ZodIntersection,..._(t)});class A extends y{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return c(s,{code:o.invalid_type,expected:h.array,received:s.parsedType}),f;if(s.data.length<this._def.items.length)return c(s,{code:o.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;!this._def.rest&&s.data.length>this._def.items.length&&(c(s,{code:o.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map((d,i)=>{const n=this._def.items[i]||this._def.rest;return n?n._parse(new C(s,d,s.path,i)):null}).filter(d=>!!d);return s.common.async?Promise.all(a).then(d=>w.mergeArray(t,d)):w.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new A({...this._def,rest:e})}}A.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new A({items:r,typeName:p.ZodTuple,rest:null,..._(e)})};class ne extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.object)return c(s,{code:o.invalid_type,expected:h.object,received:s.parsedType}),f;const a=[],d=this._def.keyType,i=this._def.valueType;for(const n in s.data)a.push({key:d._parse(new C(s,n,s.path,n)),value:i._parse(new C(s,s.data[n],s.path,n)),alwaysSet:n in s.data});return s.common.async?w.mergeObjectAsync(t,a):w.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof y?new ne({keyType:e,valueType:t,typeName:p.ZodRecord,..._(s)}):new ne({keyType:T.create(),valueType:e,typeName:p.ZodRecord,..._(t)})}}class ce extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return c(s,{code:o.invalid_type,expected:h.map,received:s.parsedType}),f;const a=this._def.keyType,d=this._def.valueType,i=[...s.data.entries()].map(([n,u],m)=>({key:a._parse(new C(s,n,s.path,[m,"key"])),value:d._parse(new C(s,u,s.path,[m,"value"]))}));if(s.common.async){const n=new Map;return Promise.resolve().then(async()=>{for(const u of i){const m=await u.key,g=await u.value;if(m.status==="aborted"||g.status==="aborted")return f;(m.status==="dirty"||g.status==="dirty")&&t.dirty(),n.set(m.value,g.value)}return{status:t.value,value:n}})}else{const n=new Map;for(const u of i){const m=u.key,g=u.value;if(m.status==="aborted"||g.status==="aborted")return f;(m.status==="dirty"||g.status==="dirty")&&t.dirty(),n.set(m.value,g.value)}return{status:t.value,value:n}}}}ce.create=(r,e,t)=>new ce({valueType:e,keyType:r,typeName:p.ZodMap,..._(t)});class z extends y{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return c(s,{code:o.invalid_type,expected:h.set,received:s.parsedType}),f;const a=this._def;a.minSize!==null&&s.data.size<a.minSize.value&&(c(s,{code:o.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&s.data.size>a.maxSize.value&&(c(s,{code:o.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const d=this._def.valueType;function i(u){const m=new Set;for(const g of u){if(g.status==="aborted")return f;g.status==="dirty"&&t.dirty(),m.add(g.value)}return{status:t.value,value:m}}const n=[...s.data.values()].map((u,m)=>d._parse(new C(s,u,s.path,m)));return s.common.async?Promise.all(n).then(u=>i(u)):i(n)}min(e,t){return new z({...this._def,minSize:{value:e,message:l.toString(t)}})}max(e,t){return new z({...this._def,maxSize:{value:e,message:l.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}z.create=(r,e)=>new z({valueType:r,minSize:null,maxSize:null,typeName:p.ZodSet,..._(e)});class B extends y{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return c(t,{code:o.invalid_type,expected:h.function,received:t.parsedType}),f;function s(n,u){return ke({data:n,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ye(),_e].filter(m=>!!m),issueData:{code:o.invalid_arguments,argumentsError:u}})}function a(n,u){return ke({data:n,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ye(),_e].filter(m=>!!m),issueData:{code:o.invalid_return_type,returnTypeError:u}})}const d={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof K){const n=this;return x(async function(...u){const m=new R([]),g=await n._def.args.parseAsync(u,d).catch(he=>{throw m.addIssue(s(u,he)),m}),S=await Reflect.apply(i,this,g);return await n._def.returns._def.type.parseAsync(S,d).catch(he=>{throw m.addIssue(a(S,he)),m})})}else{const n=this;return x(function(...u){const m=n._def.args.safeParse(u,d);if(!m.success)throw new R([s(u,m.error)]);const g=Reflect.apply(i,this,m.data),S=n._def.returns.safeParse(g,d);if(!S.success)throw new R([a(g,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new B({...this._def,args:A.create(e).rest(M.create())})}returns(e){return new B({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new B({args:e||A.create([]).rest(M.create()),returns:t||M.create(),typeName:p.ZodFunction,..._(s)})}}class X extends y{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}X.create=(r,e)=>new X({getter:r,typeName:p.ZodLazy,..._(e)});class Q extends y{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return c(t,{received:t.data,code:o.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:e.data}}get value(){return this._def.value}}Q.create=(r,e)=>new Q({value:r,typeName:p.ZodLiteral,..._(e)});function Te(r,e){return new L({values:r,typeName:p.ZodEnum,..._(e)})}class L extends y{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return c(t,{expected:k.joinValues(s),received:t.parsedType,code:o.invalid_type}),f}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return c(t,{received:t.data,code:o.invalid_enum_value,options:s}),f}return x(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return L.create(e,{...this._def,...t})}exclude(e,t=this._def){return L.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}L.create=Te;class ee extends y{_parse(e){const t=k.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){const a=k.objectValues(t);return c(s,{expected:k.joinValues(a),received:s.parsedType,code:o.invalid_type}),f}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=k.objectValues(t);return c(s,{received:s.data,code:o.invalid_enum_value,options:a}),f}return x(e.data)}get enum(){return this._def.values}}ee.create=(r,e)=>new ee({values:r,typeName:p.ZodNativeEnum,..._(e)});class K extends y{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return c(t,{code:o.invalid_type,expected:h.promise,received:t.parsedType}),f;const s=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return x(s.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}K.create=(r,e)=>new K({type:r,typeName:p.ZodPromise,..._(e)});class b extends y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=this._def.effect||null,d={addIssue:i=>{c(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(d.addIssue=d.addIssue.bind(d),a.type==="preprocess"){const i=a.transform(s.data,d);if(s.common.async)return Promise.resolve(i).then(async n=>{if(t.value==="aborted")return f;const u=await this._def.schema._parseAsync({data:n,path:s.path,parent:s});return u.status==="aborted"?f:u.status==="dirty"?W(u.value):t.value==="dirty"?W(u.value):u});{if(t.value==="aborted")return f;const n=this._def.schema._parseSync({data:i,path:s.path,parent:s});return n.status==="aborted"?f:n.status==="dirty"?W(n.value):t.value==="dirty"?W(n.value):n}}if(a.type==="refinement"){const i=n=>{const u=a.refinement(n,d);if(s.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return n};if(s.common.async===!1){const n=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?f:(n.status==="dirty"&&t.dirty(),i(n.value),{status:t.value,value:n.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(n=>n.status==="aborted"?f:(n.status==="dirty"&&t.dirty(),i(n.value).then(()=>({status:t.value,value:n.value}))))}if(a.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!D(i))return f;const n=a.transform(i.value,d);if(n instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:n}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>D(i)?Promise.resolve(a.transform(i.value,d)).then(n=>({status:t.value,value:n})):f);k.assertNever(a)}}b.create=(r,e,t)=>new b({schema:r,typeName:p.ZodEffects,effect:e,..._(t)}),b.createWithPreprocess=(r,e,t)=>new b({schema:e,effect:{type:"preprocess",transform:r},typeName:p.ZodEffects,..._(t)});class O extends y{_parse(e){return this._getType(e)===h.undefined?x(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}O.create=(r,e)=>new O({innerType:r,typeName:p.ZodOptional,..._(e)});class I extends y{_parse(e){return this._getType(e)===h.null?x(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}I.create=(r,e)=>new I({innerType:r,typeName:p.ZodNullable,..._(e)});class te extends y{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}te.create=(r,e)=>new te({innerType:r,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class se extends y{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ie(a)?a.then(d=>({status:"valid",value:d.status==="valid"?d.value:this._def.catchValue({get error(){return new R(s.common.issues)},input:s.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new R(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}se.create=(r,e)=>new se({innerType:r,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class ue extends y{_parse(e){if(this._getType(e)!==h.nan){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.nan,received:t.parsedType}),f}return{status:"valid",value:e.data}}}ue.create=r=>new ue({typeName:p.ZodNaN,..._(r)});const Qe=Symbol("zod_brand");class fe extends y{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class re extends y{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?f:a.status==="dirty"?(t.dirty(),W(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const a=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?f:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:s.path,parent:s})}}static create(e,t){return new re({in:e,out:t,typeName:p.ZodPipeline})}}class ae extends y{_parse(e){const t=this._def.innerType._parse(e),s=a=>(D(a)&&(a.value=Object.freeze(a.value)),a);return ie(t)?t.then(a=>s(a)):s(t)}unwrap(){return this._def.innerType}}ae.create=(r,e)=>new ae({innerType:r,typeName:p.ZodReadonly,..._(e)});function Ce(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Oe(r,e={},t){return r?U.create().superRefine((s,a)=>{const d=r(s);if(d instanceof Promise)return d.then(i=>{if(!i){const n=Ce(e,s),u=n.fatal??t??!0;a.addIssue({code:"custom",...n,fatal:u})}});if(!d){const i=Ce(e,s),n=i.fatal??t??!0;a.addIssue({code:"custom",...i,fatal:n})}}):U.create()}const et={object:v.lazycreate};var p;(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"})(p||(p={}));class Ut{constructor(...e){}}const tt=(r,e={message:`Input not instance of ${r.name}`})=>Oe(t=>t instanceof r,e),Ae=T.create,Ne=E.create,st=ue.create,at=F.create,Se=Y.create,rt=$.create,nt=de.create,it=q.create,dt=H.create,ot=U.create,ct=M.create,ut=N.create,lt=oe.create,ht=Z.create,pt=v.create,mt=v.strictCreate,ft=J.create,_t=le.create,yt=G.create,gt=A.create,vt=ne.create,kt=ce.create,xt=z.create,wt=B.create,bt=X.create,Zt=Q.create,Tt=L.create,Ct=ee.create,Ot=K.create,Re=b.create,At=O.create,Nt=I.create,St=b.createWithPreprocess,Rt=re.create,jt=()=>Ae().optional(),Pt=()=>Ne().optional(),It=()=>Se().optional(),Et={string:r=>T.create({...r,coerce:!0}),number:r=>E.create({...r,coerce:!0}),boolean:r=>Y.create({...r,coerce:!0}),bigint:r=>F.create({...r,coerce:!0}),date:r=>$.create({...r,coerce:!0})},Ft=f;export{Qe as BRAND,Ft as NEVER,y as Schema,U as ZodAny,Z as ZodArray,F as ZodBigInt,Y as ZodBoolean,fe as ZodBranded,se as ZodCatch,$ as ZodDate,te as ZodDefault,le as ZodDiscriminatedUnion,b as ZodEffects,L as ZodEnum,p as ZodFirstPartyTypeKind,B as ZodFunction,G as ZodIntersection,X as ZodLazy,Q as ZodLiteral,ce as ZodMap,ue as ZodNaN,ee as ZodNativeEnum,N as ZodNever,H as ZodNull,I as ZodNullable,E as ZodNumber,v as ZodObject,O as ZodOptional,re as ZodPipeline,K as ZodPromise,ae as ZodReadonly,ne as ZodRecord,y as ZodSchema,z as ZodSet,T as ZodString,de as ZodSymbol,b as ZodTransformer,A as ZodTuple,y as ZodType,q as ZodUndefined,J as ZodUnion,M as ZodUnknown,oe as ZodVoid,ot as any,ht as array,at as bigint,Se as boolean,Et as coerce,Oe as custom,rt as date,Ze as datetimeRegex,_t as discriminatedUnion,Re as effect,Tt as enum,wt as function,tt as instanceof,yt as intersection,et as late,bt as lazy,Zt as literal,kt as map,st as nan,Ct as nativeEnum,ut as never,dt as null,Nt as nullable,Ne as number,pt as object,It as oboolean,Pt as onumber,At as optional,jt as ostring,Rt as pipeline,St as preprocess,Ot as promise,vt as record,xt as set,mt as strictObject,Ae as string,nt as symbol,Re as transformer,gt as tuple,it as undefined,ft as union,ct as unknown,lt as void};
1
+ import{ZodError as R,ZodIssueCode as o}from"./ZodError.js";import{defaultErrorMap as _e,getErrorMap as ye}from"./errors.js";import{errorUtil as l}from"./helpers/errorUtil.js";import{DIRTY as W,INVALID as f,OK as x,ParseStatus as w,addIssueToContext as c,isAborted as ge,isAsync as ie,isDirty as ve,isValid as D,makeIssue as ke}from"./helpers/parseUtil.js";import{util as k,ZodParsedType as h,getParsedType as j}from"./helpers/util.js";class C{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const xe=(n,e)=>{if(D(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new R(n.common.issues);return this._error=t,this._error}}};function _(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:a}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(d,i)=>{const{message:r}=n;return d.code==="invalid_enum_value"?{message:r??i.defaultError}:typeof i.data>"u"?{message:r??s??i.defaultError}:d.code!=="invalid_type"?{message:i.defaultError}:{message:r??t??i.defaultError}},description:a}}class y{get description(){return this._def.description}_getType(e){return j(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:j(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new w,ctx:{common:e.parent.common,data:e.data,parsedType:j(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ie(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:j(e)},a=this._parseSync({data:e,path:s.path,parent:s});return xe(s,a)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:j(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return D(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>D(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:j(e)},a=this._parse({data:e,path:s.path,parent:s}),d=await(ie(a)?a:Promise.resolve(a));return xe(s,d)}refine(e,t){const s=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,d)=>{const i=e(a),r=()=>d.addIssue({code:o.custom,...s(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(r(),!1)):i?!0:(r(),!1)})}refinement(e,t){return this._refinement((s,a)=>e(s)?!0:(a.addIssue(typeof t=="function"?t(s,a):t),!1))}_refinement(e){return new b({schema:this,typeName:p.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 I.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Z.create(this)}promise(){return K.create(this,this._def)}or(e){return J.create([this,e],this._def)}and(e){return G.create(this,e,this._def)}transform(e){return new b({..._(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new te({..._(this._def),innerType:this,defaultValue:t,typeName:p.ZodDefault})}brand(){return new fe({typeName:p.ZodBranded,type:this,..._(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new se({..._(this._def),innerType:this,catchValue:t,typeName:p.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ne.create(this,e)}readonly(){return ae.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const je=/^c[^\s-]{8,}$/i,Pe=/^[0-9a-z]+$/,Ie=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ee=/^[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,Fe=/^[a-z0-9_-]{21}$/i,Me=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Le=/^[-+]?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)?)??$/,$e=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ze="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let pe;const De=/^(?:(?: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])$/,Ue=/^(?:(?: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])$/,Ve=/^(([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]))$/,Ke=/^(([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])$/,Be=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,We=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,we="((\\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])))",Ye=new RegExp(`^${we}$`);function be(n){let e="[0-5]\\d";n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`);const t=n.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function qe(n){return new RegExp(`^${be(n)}$`)}function Ze(n){let e=`${we}T${be(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function He(n,e){return!!((e==="v4"||!e)&&De.test(n)||(e==="v6"||!e)&&Ve.test(n))}function Je(n,e){if(!Me.test(n))return!1;try{const[t]=n.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),a=JSON.parse(atob(s));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function Ge(n,e){return!!((e==="v4"||!e)&&Ue.test(n)||(e==="v6"||!e)&&Ke.test(n))}class T extends y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const a=this._getOrReturnCtx(e);return c(a,{code:o.invalid_type,expected:h.string,received:a.parsedType}),f}const t=new w;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:o.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:o.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if(a.kind==="length"){const d=e.data.length>a.value,i=e.data.length<a.value;(d||i)&&(s=this._getOrReturnCtx(e,s),d?c(s,{code:o.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&c(s,{code:o.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),t.dirty())}else if(a.kind==="email")$e.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"email",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="emoji")pe||(pe=new RegExp(ze,"u")),pe.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"emoji",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="uuid")Ee.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"uuid",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="nanoid")Fe.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"nanoid",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="cuid")je.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"cuid",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="cuid2")Pe.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"cuid2",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="ulid")Ie.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"ulid",code:o.invalid_string,message:a.message}),t.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),c(s,{validation:"url",code:o.invalid_string,message:a.message}),t.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"regex",code:o.invalid_string,message:a.message}),t.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),c(s,{code:o.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),t.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),c(s,{code:o.invalid_string,validation:{startsWith:a.value},message:a.message}),t.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),c(s,{code:o.invalid_string,validation:{endsWith:a.value},message:a.message}),t.dirty()):a.kind==="datetime"?Ze(a).test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{code:o.invalid_string,validation:"datetime",message:a.message}),t.dirty()):a.kind==="date"?Ye.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{code:o.invalid_string,validation:"date",message:a.message}),t.dirty()):a.kind==="time"?qe(a).test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{code:o.invalid_string,validation:"time",message:a.message}),t.dirty()):a.kind==="duration"?Le.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"duration",code:o.invalid_string,message:a.message}),t.dirty()):a.kind==="ip"?He(e.data,a.version)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"ip",code:o.invalid_string,message:a.message}),t.dirty()):a.kind==="jwt"?Je(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"jwt",code:o.invalid_string,message:a.message}),t.dirty()):a.kind==="cidr"?Ge(e.data,a.version)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"cidr",code:o.invalid_string,message:a.message}),t.dirty()):a.kind==="base64"?Be.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"base64",code:o.invalid_string,message:a.message}),t.dirty()):a.kind==="base64url"?We.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"base64url",code:o.invalid_string,message:a.message}),t.dirty()):k.assertNever(a);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(a=>e.test(a),{validation:t,code:o.invalid_string,...l.errToObj(s)})}_addCheck(e){return new T({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...l.errToObj(e)})}url(e){return this._addCheck({kind:"url",...l.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...l.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...l.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...l.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...l.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...l.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...l.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...l.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...l.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...l.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...l.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...l.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,...l.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,...l.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...l.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...l.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...l.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...l.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...l.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...l.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...l.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...l.errToObj(t)})}nonempty(e){return this.min(1,l.errToObj(e))}trim(){return new T({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new T({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new T({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}T.create=n=>new T({checks:[],typeName:p.ZodString,coerce:n?.coerce??!1,..._(n)});function Xe(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,a=t>s?t:s,d=Number.parseInt(n.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return d%i/10**a}class E extends y{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)!==h.number){const a=this._getOrReturnCtx(e);return c(a,{code:o.invalid_type,expected:h.number,received:a.parsedType}),f}let t;const s=new w;for(const a of this._def.checks)a.kind==="int"?k.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),c(t,{code:o.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.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)&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Xe(e.data,a.value)!==0&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),c(t,{code:o.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,l.toString(t))}gt(e,t){return this.setLimit("min",e,!1,l.toString(t))}lte(e,t){return this.setLimit("max",e,!0,l.toString(t))}lt(e,t){return this.setLimit("max",e,!1,l.toString(t))}setLimit(e,t,s,a){return new E({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:l.toString(a)}]})}_addCheck(e){return new E({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:l.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:l.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:l.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:l.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:l.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:l.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:l.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:l.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:l.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const 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(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}E.create=n=>new E({checks:[],typeName:p.ZodNumber,coerce:n?.coerce||!1,..._(n)});class F extends y{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)!==h.bigint)return this._getInvalidInput(e);let t;const s=new w;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.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)&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),c(t,{code:o.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):k.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.bigint,received:t.parsedType}),f}gte(e,t){return this.setLimit("min",e,!0,l.toString(t))}gt(e,t){return this.setLimit("min",e,!1,l.toString(t))}lte(e,t){return this.setLimit("max",e,!0,l.toString(t))}lt(e,t){return this.setLimit("max",e,!1,l.toString(t))}setLimit(e,t,s,a){return new F({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:l.toString(a)}]})}_addCheck(e){return new F({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:l.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:l.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:l.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:l.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:l.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}F.create=n=>new F({checks:[],typeName:p.ZodBigInt,coerce:n?.coerce??!1,..._(n)});class Y extends y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.boolean,received:t.parsedType}),f}return x(e.data)}}Y.create=n=>new Y({typeName:p.ZodBoolean,coerce:n?.coerce||!1,..._(n)});class $ extends y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const a=this._getOrReturnCtx(e);return c(a,{code:o.invalid_type,expected:h.date,received:a.parsedType}),f}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return c(a,{code:o.invalid_date}),f}const t=new w;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:o.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),t.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:o.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),t.dirty()):k.assertNever(a);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new $({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:l.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:l.toString(t)})}get minDate(){let e=null;for(const 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(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}$.create=n=>new $({checks:[],coerce:n?.coerce||!1,typeName:p.ZodDate,..._(n)});class de extends y{_parse(e){if(this._getType(e)!==h.symbol){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.symbol,received:t.parsedType}),f}return x(e.data)}}de.create=n=>new de({typeName:p.ZodSymbol,..._(n)});class q extends y{_parse(e){if(this._getType(e)!==h.undefined){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.undefined,received:t.parsedType}),f}return x(e.data)}}q.create=n=>new q({typeName:p.ZodUndefined,..._(n)});class H extends y{_parse(e){if(this._getType(e)!==h.null){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.null,received:t.parsedType}),f}return x(e.data)}}H.create=n=>new H({typeName:p.ZodNull,..._(n)});class U extends y{constructor(){super(...arguments),this._any=!0}_parse(e){return x(e.data)}}U.create=n=>new U({typeName:p.ZodAny,..._(n)});class L extends y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return x(e.data)}}L.create=n=>new L({typeName:p.ZodUnknown,..._(n)});class N extends y{_parse(e){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.never,received:t.parsedType}),f}}N.create=n=>new N({typeName:p.ZodNever,..._(n)});class oe extends y{_parse(e){if(this._getType(e)!==h.undefined){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.void,received:t.parsedType}),f}return x(e.data)}}oe.create=n=>new oe({typeName:p.ZodVoid,..._(n)});class Z extends y{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==h.array)return c(t,{code:o.invalid_type,expected:h.array,received:t.parsedType}),f;if(a.exactLength!==null){const i=t.data.length>a.exactLength.value,r=t.data.length<a.exactLength.value;(i||r)&&(c(t,{code:i?o.too_big:o.too_small,minimum:r?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(c(t,{code:o.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(c(t,{code:o.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,r)=>a.type._parseAsync(new C(t,i,t.path,r)))).then(i=>w.mergeArray(s,i));const d=[...t.data].map((i,r)=>a.type._parseSync(new C(t,i,t.path,r)));return w.mergeArray(s,d)}get element(){return this._def.type}min(e,t){return new Z({...this._def,minLength:{value:e,message:l.toString(t)}})}max(e,t){return new Z({...this._def,maxLength:{value:e,message:l.toString(t)}})}length(e,t){return new Z({...this._def,exactLength:{value:e,message:l.toString(t)}})}nonempty(e){return this.min(1,e)}}Z.create=(n,e)=>new Z({type:n,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,..._(e)});function V(n){if(n instanceof v){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=O.create(V(s))}return new v({...n._def,shape:()=>e})}else return n instanceof Z?new Z({...n._def,type:V(n.element)}):n instanceof O?O.create(V(n.unwrap())):n instanceof I?I.create(V(n.unwrap())):n instanceof A?A.create(n.items.map(e=>V(e))):n}class v extends y{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==h.object){const u=this._getOrReturnCtx(e);return c(u,{code:o.invalid_type,expected:h.object,received:u.parsedType}),f}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:d}=this._getCached(),i=[];if(!(this._def.catchall instanceof N&&this._def.unknownKeys==="strip"))for(const u in s.data)d.includes(u)||i.push(u);const r=[];for(const u of d){const m=a[u],g=s.data[u];r.push({key:{status:"valid",value:u},value:m._parse(new C(s,g,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof N){const u=this._def.unknownKeys;if(u==="passthrough")for(const m of i)r.push({key:{status:"valid",value:m},value:{status:"valid",value:s.data[m]}});else if(u==="strict")i.length>0&&(c(s,{code:o.unrecognized_keys,keys:i}),t.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const m of i){const g=s.data[m];r.push({key:{status:"valid",value:m},value:u._parse(new C(s,g,s.path,m)),alwaysSet:m in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const m of r){const g=await m.key,S=await m.value;u.push({key:g,value:S,alwaysSet:m.alwaysSet})}return u}).then(u=>w.mergeObjectSync(t,u)):w.mergeObjectSync(t,r)}get shape(){return this._def.shape()}strict(e){return l.errToObj,new v({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{const a=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:l.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new v({...this._def,unknownKeys:"strip"})}passthrough(){return new v({...this._def,unknownKeys:"passthrough"})}extend(e){return new v({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new v({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:p.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new v({...this._def,catchall:e})}pick(e){const t={};for(const s of k.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new v({...this._def,shape:()=>t})}omit(e){const t={};for(const s of k.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new v({...this._def,shape:()=>t})}deepPartial(){return V(this)}partial(e){const t={};for(const s of k.objectKeys(this.shape)){const a=this.shape[s];e&&!e[s]?t[s]=a:t[s]=a.optional()}return new v({...this._def,shape:()=>t})}required(e){const t={};for(const s of k.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof O;)a=a._def.innerType;t[s]=a}return new v({...this._def,shape:()=>t})}keyof(){return Te(k.objectKeys(this.shape))}}v.create=(n,e)=>new v({shape:()=>n,unknownKeys:"strip",catchall:N.create(),typeName:p.ZodObject,..._(e)}),v.strictCreate=(n,e)=>new v({shape:()=>n,unknownKeys:"strict",catchall:N.create(),typeName:p.ZodObject,..._(e)}),v.lazycreate=(n,e)=>new v({shape:n,unknownKeys:"strip",catchall:N.create(),typeName:p.ZodObject,..._(e)});class J extends y{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function a(d){for(const r of d)if(r.result.status==="valid")return r.result;for(const r of d)if(r.result.status==="dirty")return t.common.issues.push(...r.ctx.common.issues),r.result;const i=d.map(r=>new R(r.ctx.common.issues));return c(t,{code:o.invalid_union,unionErrors:i}),f}if(t.common.async)return Promise.all(s.map(async d=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await d._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let d;const i=[];for(const u of s){const m={...t,common:{...t.common,issues:[]},parent:null},g=u._parseSync({data:t.data,path:t.path,parent:m});if(g.status==="valid")return g;g.status==="dirty"&&!d&&(d={result:g,ctx:m}),m.common.issues.length&&i.push(m.common.issues)}if(d)return t.common.issues.push(...d.ctx.common.issues),d.result;const r=i.map(u=>new R(u));return c(t,{code:o.invalid_union,unionErrors:r}),f}}get options(){return this._def.options}}J.create=(n,e)=>new J({options:n,typeName:p.ZodUnion,..._(e)});const P=n=>n instanceof X?P(n.schema):n instanceof b?P(n.innerType()):n instanceof Q?[n.value]:n instanceof M?n.options:n instanceof ee?k.objectValues(n.enum):n instanceof te?P(n._def.innerType):n instanceof q?[void 0]:n instanceof H?[null]:n instanceof O?[void 0,...P(n.unwrap())]:n instanceof I?[null,...P(n.unwrap())]:n instanceof fe||n instanceof ae?P(n.unwrap()):n instanceof se?P(n._def.innerType):[];class le extends y{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return c(t,{code:o.invalid_type,expected:h.object,received:t.parsedType}),f;const s=this.discriminator,a=t.data[s],d=this.optionsMap.get(a);return d?t.common.async?d._parseAsync({data:t.data,path:t.path,parent:t}):d._parseSync({data:t.data,path:t.path,parent:t}):(c(t,{code:o.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const d of t){const i=P(d.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const r of i){if(a.has(r))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(r)}`);a.set(r,d)}}return new le({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,..._(s)})}}function me(n,e){const t=j(n),s=j(e);if(n===e)return{valid:!0,data:n};if(t===h.object&&s===h.object){const a=k.objectKeys(e),d=k.objectKeys(n).filter(r=>a.indexOf(r)!==-1),i={...n,...e};for(const r of d){const u=me(n[r],e[r]);if(!u.valid)return{valid:!1};i[r]=u.data}return{valid:!0,data:i}}else if(t===h.array&&s===h.array){if(n.length!==e.length)return{valid:!1};const a=[];for(let d=0;d<n.length;d++){const i=n[d],r=e[d],u=me(i,r);if(!u.valid)return{valid:!1};a.push(u.data)}return{valid:!0,data:a}}else return t===h.date&&s===h.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class G extends y{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(d,i)=>{if(ge(d)||ge(i))return f;const r=me(d.value,i.value);return r.valid?((ve(d)||ve(i))&&t.dirty(),{status:t.value,value:r.data}):(c(s,{code:o.invalid_intersection_types}),f)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([d,i])=>a(d,i)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}G.create=(n,e,t)=>new G({left:n,right:e,typeName:p.ZodIntersection,..._(t)});class A extends y{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return c(s,{code:o.invalid_type,expected:h.array,received:s.parsedType}),f;if(s.data.length<this._def.items.length)return c(s,{code:o.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;!this._def.rest&&s.data.length>this._def.items.length&&(c(s,{code:o.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map((d,i)=>{const r=this._def.items[i]||this._def.rest;return r?r._parse(new C(s,d,s.path,i)):null}).filter(d=>!!d);return s.common.async?Promise.all(a).then(d=>w.mergeArray(t,d)):w.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new A({...this._def,rest:e})}}A.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new A({items:n,typeName:p.ZodTuple,rest:null,..._(e)})};class re extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.object)return c(s,{code:o.invalid_type,expected:h.object,received:s.parsedType}),f;const a=[],d=this._def.keyType,i=this._def.valueType;for(const r in s.data)a.push({key:d._parse(new C(s,r,s.path,r)),value:i._parse(new C(s,s.data[r],s.path,r)),alwaysSet:r in s.data});return s.common.async?w.mergeObjectAsync(t,a):w.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof y?new re({keyType:e,valueType:t,typeName:p.ZodRecord,..._(s)}):new re({keyType:T.create(),valueType:e,typeName:p.ZodRecord,..._(t)})}}class ce extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return c(s,{code:o.invalid_type,expected:h.map,received:s.parsedType}),f;const a=this._def.keyType,d=this._def.valueType,i=[...s.data.entries()].map(([r,u],m)=>({key:a._parse(new C(s,r,s.path,[m,"key"])),value:d._parse(new C(s,u,s.path,[m,"value"]))}));if(s.common.async){const r=new Map;return Promise.resolve().then(async()=>{for(const u of i){const m=await u.key,g=await u.value;if(m.status==="aborted"||g.status==="aborted")return f;(m.status==="dirty"||g.status==="dirty")&&t.dirty(),r.set(m.value,g.value)}return{status:t.value,value:r}})}else{const r=new Map;for(const u of i){const m=u.key,g=u.value;if(m.status==="aborted"||g.status==="aborted")return f;(m.status==="dirty"||g.status==="dirty")&&t.dirty(),r.set(m.value,g.value)}return{status:t.value,value:r}}}}ce.create=(n,e,t)=>new ce({valueType:e,keyType:n,typeName:p.ZodMap,..._(t)});class z extends y{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return c(s,{code:o.invalid_type,expected:h.set,received:s.parsedType}),f;const a=this._def;a.minSize!==null&&s.data.size<a.minSize.value&&(c(s,{code:o.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&s.data.size>a.maxSize.value&&(c(s,{code:o.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const d=this._def.valueType;function i(u){const m=new Set;for(const g of u){if(g.status==="aborted")return f;g.status==="dirty"&&t.dirty(),m.add(g.value)}return{status:t.value,value:m}}const r=[...s.data.values()].map((u,m)=>d._parse(new C(s,u,s.path,m)));return s.common.async?Promise.all(r).then(u=>i(u)):i(r)}min(e,t){return new z({...this._def,minSize:{value:e,message:l.toString(t)}})}max(e,t){return new z({...this._def,maxSize:{value:e,message:l.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}z.create=(n,e)=>new z({valueType:n,minSize:null,maxSize:null,typeName:p.ZodSet,..._(e)});class B extends y{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return c(t,{code:o.invalid_type,expected:h.function,received:t.parsedType}),f;function s(r,u){return ke({data:r,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ye(),_e].filter(m=>!!m),issueData:{code:o.invalid_arguments,argumentsError:u}})}function a(r,u){return ke({data:r,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ye(),_e].filter(m=>!!m),issueData:{code:o.invalid_return_type,returnTypeError:u}})}const d={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof K){const r=this;return x(async function(...u){const m=new R([]),g=await r._def.args.parseAsync(u,d).catch(he=>{throw m.addIssue(s(u,he)),m}),S=await Reflect.apply(i,this,g);return await r._def.returns._def.type.parseAsync(S,d).catch(he=>{throw m.addIssue(a(S,he)),m})})}else{const r=this;return x(function(...u){const m=r._def.args.safeParse(u,d);if(!m.success)throw new R([s(u,m.error)]);const g=Reflect.apply(i,this,m.data),S=r._def.returns.safeParse(g,d);if(!S.success)throw new R([a(g,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new B({...this._def,args:A.create(e).rest(L.create())})}returns(e){return new B({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new B({args:e||A.create([]).rest(L.create()),returns:t||L.create(),typeName:p.ZodFunction,..._(s)})}}class X extends y{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}X.create=(n,e)=>new X({getter:n,typeName:p.ZodLazy,..._(e)});class Q extends y{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return c(t,{received:t.data,code:o.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:e.data}}get value(){return this._def.value}}Q.create=(n,e)=>new Q({value:n,typeName:p.ZodLiteral,..._(e)});function Te(n,e){return new M({values:n,typeName:p.ZodEnum,..._(e)})}class M extends y{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return c(t,{expected:k.joinValues(s),received:t.parsedType,code:o.invalid_type}),f}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return c(t,{received:t.data,code:o.invalid_enum_value,options:s}),f}return x(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return M.create(e,{...this._def,...t})}exclude(e,t=this._def){return M.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}M.create=Te;class ee extends y{_parse(e){const t=k.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){const a=k.objectValues(t);return c(s,{expected:k.joinValues(a),received:s.parsedType,code:o.invalid_type}),f}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=k.objectValues(t);return c(s,{received:s.data,code:o.invalid_enum_value,options:a}),f}return x(e.data)}get enum(){return this._def.values}}ee.create=(n,e)=>new ee({values:n,typeName:p.ZodNativeEnum,..._(e)});class K extends y{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return c(t,{code:o.invalid_type,expected:h.promise,received:t.parsedType}),f;const s=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return x(s.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}K.create=(n,e)=>new K({type:n,typeName:p.ZodPromise,..._(e)});class b extends y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=this._def.effect||null,d={addIssue:i=>{c(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(d.addIssue=d.addIssue.bind(d),a.type==="preprocess"){const i=a.transform(s.data,d);if(s.common.async)return Promise.resolve(i).then(async r=>{if(t.value==="aborted")return f;const u=await this._def.schema._parseAsync({data:r,path:s.path,parent:s});return u.status==="aborted"?f:u.status==="dirty"?W(u.value):t.value==="dirty"?W(u.value):u});{if(t.value==="aborted")return f;const r=this._def.schema._parseSync({data:i,path:s.path,parent:s});return r.status==="aborted"?f:r.status==="dirty"?W(r.value):t.value==="dirty"?W(r.value):r}}if(a.type==="refinement"){const i=r=>{const u=a.refinement(r,d);if(s.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return r};if(s.common.async===!1){const r=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?f:(r.status==="dirty"&&t.dirty(),i(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(r=>r.status==="aborted"?f:(r.status==="dirty"&&t.dirty(),i(r.value).then(()=>({status:t.value,value:r.value}))))}if(a.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!D(i))return f;const r=a.transform(i.value,d);if(r instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:r}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>D(i)?Promise.resolve(a.transform(i.value,d)).then(r=>({status:t.value,value:r})):f);k.assertNever(a)}}b.create=(n,e,t)=>new b({schema:n,typeName:p.ZodEffects,effect:e,..._(t)}),b.createWithPreprocess=(n,e,t)=>new b({schema:e,effect:{type:"preprocess",transform:n},typeName:p.ZodEffects,..._(t)});class O extends y{_parse(e){return this._getType(e)===h.undefined?x(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}O.create=(n,e)=>new O({innerType:n,typeName:p.ZodOptional,..._(e)});class I extends y{_parse(e){return this._getType(e)===h.null?x(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}I.create=(n,e)=>new I({innerType:n,typeName:p.ZodNullable,..._(e)});class te extends y{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}te.create=(n,e)=>new te({innerType:n,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class se extends y{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ie(a)?a.then(d=>({status:"valid",value:d.status==="valid"?d.value:this._def.catchValue({get error(){return new R(s.common.issues)},input:s.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new R(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}se.create=(n,e)=>new se({innerType:n,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class ue extends y{_parse(e){if(this._getType(e)!==h.nan){const t=this._getOrReturnCtx(e);return c(t,{code:o.invalid_type,expected:h.nan,received:t.parsedType}),f}return{status:"valid",value:e.data}}}ue.create=n=>new ue({typeName:p.ZodNaN,..._(n)});const Qe=Symbol("zod_brand");class fe extends y{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class ne extends y{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?f:a.status==="dirty"?(t.dirty(),W(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const a=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?f:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:s.path,parent:s})}}static create(e,t){return new ne({in:e,out:t,typeName:p.ZodPipeline})}}class ae extends y{_parse(e){const t=this._def.innerType._parse(e),s=a=>(D(a)&&(a.value=Object.freeze(a.value)),a);return ie(t)?t.then(a=>s(a)):s(t)}unwrap(){return this._def.innerType}}ae.create=(n,e)=>new ae({innerType:n,typeName:p.ZodReadonly,..._(e)});function Ce(n,e){const t=typeof n=="function"?n(e):typeof n=="string"?{message:n}:n;return typeof t=="string"?{message:t}:t}function Oe(n,e={},t){return n?U.create().superRefine((s,a)=>{const d=n(s);if(d instanceof Promise)return d.then(i=>{if(!i){const r=Ce(e,s),u=r.fatal??t??!0;a.addIssue({code:"custom",...r,fatal:u})}});if(!d){const i=Ce(e,s),r=i.fatal??t??!0;a.addIssue({code:"custom",...i,fatal:r})}}):U.create()}const et={object:v.lazycreate};var p;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(p||(p={}));class Ut{constructor(...e){}}const tt=(n,e={message:`Input not instance of ${n.name}`})=>Oe(t=>t instanceof n,e),Ae=T.create,Ne=E.create,st=ue.create,at=F.create,Se=Y.create,nt=$.create,rt=de.create,it=q.create,dt=H.create,ot=U.create,ct=L.create,ut=N.create,lt=oe.create,ht=Z.create,pt=v.create,mt=v.strictCreate,ft=J.create,_t=le.create,yt=G.create,gt=A.create,vt=re.create,kt=ce.create,xt=z.create,wt=B.create,bt=X.create,Zt=Q.create,Tt=M.create,Ct=ee.create,Ot=K.create,Re=b.create,At=O.create,Nt=I.create,St=b.createWithPreprocess,Rt=ne.create,jt=()=>Ae().optional(),Pt=()=>Ne().optional(),It=()=>Se().optional(),Et={string:n=>T.create({...n,coerce:!0}),number:n=>E.create({...n,coerce:!0}),boolean:n=>Y.create({...n,coerce:!0}),bigint:n=>F.create({...n,coerce:!0}),date:n=>$.create({...n,coerce:!0})},Ft=f;export{Qe as BRAND,Ft as NEVER,y as Schema,U as ZodAny,Z as ZodArray,F as ZodBigInt,Y as ZodBoolean,fe as ZodBranded,se as ZodCatch,$ as ZodDate,te as ZodDefault,le as ZodDiscriminatedUnion,b as ZodEffects,M as ZodEnum,p as ZodFirstPartyTypeKind,B as ZodFunction,G as ZodIntersection,X as ZodLazy,Q as ZodLiteral,ce as ZodMap,ue as ZodNaN,ee as ZodNativeEnum,N as ZodNever,H as ZodNull,I as ZodNullable,E as ZodNumber,v as ZodObject,O as ZodOptional,ne as ZodPipeline,K as ZodPromise,ae as ZodReadonly,re as ZodRecord,y as ZodSchema,z as ZodSet,T as ZodString,de as ZodSymbol,b as ZodTransformer,A as ZodTuple,y as ZodType,q as ZodUndefined,J as ZodUnion,L as ZodUnknown,oe as ZodVoid,ot as any,ht as array,at as bigint,Se as boolean,Et as coerce,Oe as custom,nt as date,Ze as datetimeRegex,_t as discriminatedUnion,Re as effect,Tt as enum,wt as function,tt as instanceof,yt as intersection,et as late,bt as lazy,Zt as literal,kt as map,st as nan,Ct as nativeEnum,ut as never,dt as null,Nt as nullable,Ne as number,pt as object,It as oboolean,Pt as onumber,At as optional,jt as ostring,Rt as pipeline,St as preprocess,Ot as promise,vt as record,xt as set,mt as strictObject,Ae as string,rt as symbol,Re as transformer,gt as tuple,it as undefined,ft as union,ct as unknown,lt as void};
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var r in t)__defProp(e,r,{get:t[r],enumerable:!0})},__copyProps=(e,t,r,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of __getOwnPropNames(t))__hasOwnProp.call(e,s)||s===r||__defProp(e,s,{get:()=>t[s],enumerable:!(o=__getOwnPropDesc(t,s))||o.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),express_exports={};function filesArray(e){return Array.isArray(e.files)?e.files:e.files&&"object"==typeof e.files?Object.values(e.files).flat():[]}function collect(e,t){const r=[];for(let o=0;;o++){const s=e.find(e=>e.fieldname===`${t}_${o}`);if(!s)break;r.push({type:s.mimetype,bytes:s.buffer})}return r}function reply(e,t){if(t.ok)return e.setHeader("Content-Type",t.contentType),e.setHeader("Content-Disposition",`attachment; filename="${t.filename}"`),e.setHeader("Cache-Control","no-store"),void e.send(t.bytes);e.status(t.status).json({error:t.error,message:t.message})}function expressVideoExport(e){return async(t,r)=>{const o=filesArray(t),s=o.find(e=>"overlay"===e.fieldname);if(s&&"image/png"!==s.mimetype)return void reply(r,{ok:!1,status:415,error:"BAD_OVERLAY",message:"overlay 必须是 PNG"});const n=collect(o,"textOverlay");if(n.some(e=>"image/png"!==e.type))return void reply(r,{ok:!1,status:415,error:"BAD_OVERLAY",message:"textOverlay must be PNG"});const i=o.find(e=>"videoCover"===e.fieldname);if(i&&!/^image\/(?:png|jpe?g)$/.test(i.mimetype))return void reply(r,{ok:!1,status:415,error:"BAD_COVER",message:"videoCover must be PNG or JPEG"});const a={videos:collect(o,"video"),audios:collect(o,"audio"),overlay:s?.buffer,videoCover:i?.buffer,textOverlays:n.map(e=>e.bytes),editStateRaw:"string"==typeof t.body?.editState?t.body.editState:""};reply(r,await e.handle(a))}}function expressPoster(e){return async(t,r)=>{const o=filesArray(t).find(e=>"file"===e.fieldname),s=t.body?.time;reply(r,o&&"string"==typeof s?await e.handle({type:o.mimetype,bytes:o.buffer},Number(s)):{ok:!1,status:400,error:"BAD_REQUEST",message:"缺少 file 或 time"})}}__export(express_exports,{expressPoster:()=>expressPoster,expressVideoExport:()=>expressVideoExport}),module.exports=__toCommonJS(express_exports);
1
+ "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var r in t)__defProp(e,r,{get:t[r],enumerable:!0})},__copyProps=(e,t,r,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of __getOwnPropNames(t))__hasOwnProp.call(e,s)||s===r||__defProp(e,s,{get:()=>t[s],enumerable:!(o=__getOwnPropDesc(t,s))||o.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),express_exports={};__export(express_exports,{expressPoster:()=>expressPoster,expressVideoExport:()=>expressVideoExport}),module.exports=__toCommonJS(express_exports);var MAX_SLOTS=16;function filesArray(e){return Array.isArray(e.files)?e.files:e.files&&"object"==typeof e.files?Object.values(e.files).flat():[]}function collect(e,t){const r=[];for(let o=0;;o++){const s=e.find(e=>e.fieldname===`${t}_${o}`);if(!s)break;r.push({type:s.mimetype,bytes:s.buffer})}return r}function collectSlots(e,t){const r=[];for(let o=0;o<MAX_SLOTS;o++){const s=e.find(e=>e.fieldname===`${t}_${o}`);s&&(r[o]={type:s.mimetype,bytes:s.buffer})}return r}function bodyString(e,t){const r=e?.[t];return"string"==typeof r?r||void 0:Array.isArray(r)&&"string"==typeof r[0]&&r[0]||void 0}function bodyNumber(e,t){const r=bodyString(e,t);if(!r)return;const o=Number(r);return Number.isFinite(o)?o:void 0}function collectRemoteVideos(e){const t=[];for(let r=0;r<MAX_SLOTS;r++){const o=bodyString(e,`videoUrl_${r}`);o&&(t[r]={url:o,name:bodyString(e,`videoName_${r}`),type:bodyString(e,`videoType_${r}`),size:bodyNumber(e,`videoSize_${r}`)})}return t}function reply(e,t){if(t.ok)return e.setHeader("Content-Type",t.contentType),e.setHeader("Content-Disposition",`attachment; filename="${t.filename}"`),e.setHeader("Cache-Control","no-store"),void e.send(t.bytes);e.status(t.status).json({error:t.error,message:t.message})}function expressVideoExport(e){return async(t,r)=>{const o=filesArray(t),s=o.find(e=>"overlay"===e.fieldname);if(s&&"image/png"!==s.mimetype)return void reply(r,{ok:!1,status:415,error:"BAD_OVERLAY",message:"overlay 必须是 PNG"});const n=collect(o,"textOverlay");if(n.some(e=>"image/png"!==e.type))return void reply(r,{ok:!1,status:415,error:"BAD_OVERLAY",message:"textOverlay must be PNG"});const i=o.find(e=>"videoCover"===e.fieldname);if(i&&!/^image\/(?:png|jpe?g)$/.test(i.mimetype))return void reply(r,{ok:!1,status:415,error:"BAD_COVER",message:"videoCover must be PNG or JPEG"});const a={videos:collectSlots(o,"video"),videoUrls:collectRemoteVideos(t.body),audios:collect(o,"audio"),overlay:s?.buffer,videoCover:i?.buffer,textOverlays:n.map(e=>e.bytes),editStateRaw:"string"==typeof t.body?.editState?t.body.editState:""};reply(r,await e.handle(a))}}function expressPoster(e){return async(t,r)=>{const o=filesArray(t).find(e=>"file"===e.fieldname),s=t.body?.time;reply(r,o&&"string"==typeof s?await e.handle({type:o.mimetype,bytes:o.buffer},Number(s)):{ok:!1,status:400,error:"BAD_REQUEST",message:"缺少 file 或 time"})}}
@@ -1,4 +1,4 @@
1
- import { P as PosterHandler, V as VideoExportHandler } from '../handler-BEalyBz9.js';
1
+ import { P as PosterHandler, V as VideoExportHandler } from '../handler-BiOIAlrh.js';
2
2
 
3
3
  /**
4
4
  * Express 适配器。用法:
@@ -1 +1 @@
1
- function e(e){return Array.isArray(e.files)?e.files:e.files&&"object"==typeof e.files?Object.values(e.files).flat():[]}function t(e,t){const r=[];for(let s=0;;s++){const o=e.find(e=>e.fieldname===`${t}_${s}`);if(!o)break;r.push({type:o.mimetype,bytes:o.buffer})}return r}function r(e,t){if(t.ok)return e.setHeader("Content-Type",t.contentType),e.setHeader("Content-Disposition",`attachment; filename="${t.filename}"`),e.setHeader("Cache-Control","no-store"),void e.send(t.bytes);e.status(t.status).json({error:t.error,message:t.message})}function s(s){return async(o,i)=>{const n=e(o),a=n.find(e=>"overlay"===e.fieldname);if(a&&"image/png"!==a.mimetype)return void r(i,{ok:!1,status:415,error:"BAD_OVERLAY",message:"overlay 必须是 PNG"});const f=t(n,"textOverlay");if(f.some(e=>"image/png"!==e.type))return void r(i,{ok:!1,status:415,error:"BAD_OVERLAY",message:"textOverlay must be PNG"});const d=n.find(e=>"videoCover"===e.fieldname);if(d&&!/^image\/(?:png|jpe?g)$/.test(d.mimetype))return void r(i,{ok:!1,status:415,error:"BAD_COVER",message:"videoCover must be PNG or JPEG"});const m={videos:t(n,"video"),audios:t(n,"audio"),overlay:a?.buffer,videoCover:d?.buffer,textOverlays:f.map(e=>e.bytes),editStateRaw:"string"==typeof o.body?.editState?o.body.editState:""};r(i,await s.handle(m))}}function o(t){return async(s,o)=>{const i=e(s).find(e=>"file"===e.fieldname),n=s.body?.time;r(o,i&&"string"==typeof n?await t.handle({type:i.mimetype,bytes:i.buffer},Number(n)):{ok:!1,status:400,error:"BAD_REQUEST",message:"缺少 file 或 time"})}}export{o as expressPoster,s as expressVideoExport};
1
+ function e(e){return Array.isArray(e.files)?e.files:e.files&&"object"==typeof e.files?Object.values(e.files).flat():[]}function t(e,t){const r=[];for(let o=0;;o++){const i=e.find(e=>e.fieldname===`${t}_${o}`);if(!i)break;r.push({type:i.mimetype,bytes:i.buffer})}return r}function r(e,t){const r=[];for(let o=0;o<16;o++){const i=e.find(e=>e.fieldname===`${t}_${o}`);i&&(r[o]={type:i.mimetype,bytes:i.buffer})}return r}function o(e,t){const r=e?.[t];return"string"==typeof r?r||void 0:Array.isArray(r)&&"string"==typeof r[0]&&r[0]||void 0}function i(e,t){const r=o(e,t);if(!r)return;const i=Number(r);return Number.isFinite(i)?i:void 0}function n(e){const t=[];for(let r=0;r<16;r++){const n=o(e,`videoUrl_${r}`);n&&(t[r]={url:n,name:o(e,`videoName_${r}`),type:o(e,`videoType_${r}`),size:i(e,`videoSize_${r}`)})}return t}function s(e,t){if(t.ok)return e.setHeader("Content-Type",t.contentType),e.setHeader("Content-Disposition",`attachment; filename="${t.filename}"`),e.setHeader("Cache-Control","no-store"),void e.send(t.bytes);e.status(t.status).json({error:t.error,message:t.message})}function a(o){return async(i,a)=>{const f=e(i),u=f.find(e=>"overlay"===e.fieldname);if(u&&"image/png"!==u.mimetype)return void s(a,{ok:!1,status:415,error:"BAD_OVERLAY",message:"overlay 必须是 PNG"});const d=t(f,"textOverlay");if(d.some(e=>"image/png"!==e.type))return void s(a,{ok:!1,status:415,error:"BAD_OVERLAY",message:"textOverlay must be PNG"});const y=f.find(e=>"videoCover"===e.fieldname);if(y&&!/^image\/(?:png|jpe?g)$/.test(y.mimetype))return void s(a,{ok:!1,status:415,error:"BAD_COVER",message:"videoCover must be PNG or JPEG"});const m={videos:r(f,"video"),videoUrls:n(i.body),audios:t(f,"audio"),overlay:u?.buffer,videoCover:y?.buffer,textOverlays:d.map(e=>e.bytes),editStateRaw:"string"==typeof i.body?.editState?i.body.editState:""};s(a,await o.handle(m))}}function f(t){return async(r,o)=>{const i=e(r).find(e=>"file"===e.fieldname),n=r.body?.time;s(o,i&&"string"==typeof n?await t.handle({type:i.mimetype,bytes:i.buffer},Number(n)):{ok:!1,status:400,error:"BAD_REQUEST",message:"缺少 file 或 time"})}}export{f as expressPoster,a as expressVideoExport};
@@ -1 +1 @@
1
- "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var o in t)__defProp(e,o,{get:t[o],enumerable:!0})},__copyProps=(e,t,o,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of __getOwnPropNames(t))__hasOwnProp.call(e,a)||a===o||__defProp(e,a,{get:()=>t[a],enumerable:!(r=__getOwnPropDesc(t,a))||r.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),web_exports={};__export(web_exports,{toWebPosterHandler:()=>toWebPosterHandler,toWebVideoHandler:()=>toWebVideoHandler}),module.exports=__toCommonJS(web_exports);var MAX_SLOTS=16;function isUploadFormFile(e){return"object"==typeof e&&null!==e&&"string"==typeof e.type&&"function"==typeof e.arrayBuffer}async function fileToUpload(e){return{type:e.type,bytes:Buffer.from(await e.arrayBuffer())}}function toResponse(e){return e.ok?new Response(new Uint8Array(e.bytes),{status:200,headers:{"Content-Type":e.contentType,"Content-Disposition":`attachment; filename="${e.filename}"`,"Cache-Control":"no-store"}}):new Response(JSON.stringify({error:e.error,message:e.message}),{status:e.status,headers:{"Content-Type":"application/json"}})}function toWebVideoHandler(e){return async t=>{let o;try{o=await t.formData()}catch{return toResponse({ok:!1,status:400,error:"BAD_REQUEST",message:"请求体解析失败"})}const r=[];for(let e=0;e<MAX_SLOTS;e++){const t=o.get(`video_${e}`);if(!isUploadFormFile(t))break;r.push(await fileToUpload(t))}const a=[];for(let e=0;e<MAX_SLOTS;e++){const t=o.get(`audio_${e}`);if(!isUploadFormFile(t))break;a.push(await fileToUpload(t))}const s=o.get("editState"),n=o.get("overlay"),i=isUploadFormFile(n)?n:void 0,p=i?Buffer.from(await i.arrayBuffer()):void 0;if(i&&"image/png"!==i.type)return toResponse({ok:!1,status:415,error:"BAD_OVERLAY",message:"overlay 必须是 PNG"});const f=o.get("videoCover"),l=isUploadFormFile(f)?f:void 0,u=l?Buffer.from(await l.arrayBuffer()):void 0;if(l&&!/^image\/(?:png|jpe?g)$/.test(l.type))return toResponse({ok:!1,status:415,error:"BAD_COVER",message:"videoCover must be PNG or JPEG"});const _=[];for(let e=0;e<MAX_SLOTS;e++){const t=o.get(`textOverlay_${e}`);if(!isUploadFormFile(t))break;if("image/png"!==t.type)return toResponse({ok:!1,status:415,error:"BAD_OVERLAY",message:"textOverlay 必须是 PNG"});_.push(Buffer.from(await t.arrayBuffer()))}const d={videos:r,audios:a,overlay:p,videoCover:u,textOverlays:_,editStateRaw:"string"==typeof s?s:""};return toResponse(await e.handle(d))}}function toWebPosterHandler(e){return async t=>{let o;try{o=await t.formData()}catch{return toResponse({ok:!1,status:400,error:"BAD_REQUEST",message:"请求体解析失败"})}const r=o.get("file"),a=o.get("time");return isUploadFormFile(r)&&"string"==typeof a?toResponse(await e.handle(await fileToUpload(r),Number(a))):toResponse({ok:!1,status:400,error:"BAD_REQUEST",message:"缺少 file 或 time"})}}
1
+ "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var o in t)__defProp(e,o,{get:t[o],enumerable:!0})},__copyProps=(e,t,o,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of __getOwnPropNames(t))__hasOwnProp.call(e,a)||a===o||__defProp(e,a,{get:()=>t[a],enumerable:!(r=__getOwnPropDesc(t,a))||r.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),web_exports={};__export(web_exports,{toWebPosterHandler:()=>toWebPosterHandler,toWebVideoHandler:()=>toWebVideoHandler}),module.exports=__toCommonJS(web_exports);var MAX_SLOTS=16;function isUploadFormFile(e){return"object"==typeof e&&null!==e&&"string"==typeof e.type&&"function"==typeof e.arrayBuffer}async function fileToUpload(e){return{type:e.type,bytes:Buffer.from(await e.arrayBuffer())}}function optionalString(e){return"string"==typeof e&&e?e:void 0}function optionalNumber(e){if("string"!=typeof e||!e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}function toResponse(e){return e.ok?new Response(new Uint8Array(e.bytes),{status:200,headers:{"Content-Type":e.contentType,"Content-Disposition":`attachment; filename="${e.filename}"`,"Cache-Control":"no-store"}}):new Response(JSON.stringify({error:e.error,message:e.message}),{status:e.status,headers:{"Content-Type":"application/json"}})}function toWebVideoHandler(e){return async t=>{let o;try{o=await t.formData()}catch{return toResponse({ok:!1,status:400,error:"BAD_REQUEST",message:"请求体解析失败"})}const r=[],a=[];for(let e=0;e<MAX_SLOTS;e++){const t=o.get(`video_${e}`),n=optionalString(o.get(`videoUrl_${e}`));isUploadFormFile(t)&&(r[e]=await fileToUpload(t)),n&&(a[e]={url:n,name:optionalString(o.get(`videoName_${e}`)),type:optionalString(o.get(`videoType_${e}`)),size:optionalNumber(o.get(`videoSize_${e}`))})}const n=[];for(let e=0;e<MAX_SLOTS;e++){const t=o.get(`audio_${e}`);if(!isUploadFormFile(t))break;n.push(await fileToUpload(t))}const s=o.get("editState"),i=o.get("overlay"),p=isUploadFormFile(i)?i:void 0,f=p?Buffer.from(await p.arrayBuffer()):void 0;if(p&&"image/png"!==p.type)return toResponse({ok:!1,status:415,error:"BAD_OVERLAY",message:"overlay 必须是 PNG"});const l=o.get("videoCover"),u=isUploadFormFile(l)?l:void 0,_=u?Buffer.from(await u.arrayBuffer()):void 0;if(u&&!/^image\/(?:png|jpe?g)$/.test(u.type))return toResponse({ok:!1,status:415,error:"BAD_COVER",message:"videoCover must be PNG or JPEG"});const d=[];for(let e=0;e<MAX_SLOTS;e++){const t=o.get(`textOverlay_${e}`);if(!isUploadFormFile(t))break;if("image/png"!==t.type)return toResponse({ok:!1,status:415,error:"BAD_OVERLAY",message:"textOverlay 必须是 PNG"});d.push(Buffer.from(await t.arrayBuffer()))}const m={videos:r,videoUrls:a,audios:n,overlay:f,videoCover:_,textOverlays:d,editStateRaw:"string"==typeof s?s:""};return toResponse(await e.handle(m))}}function toWebPosterHandler(e){return async t=>{let o;try{o=await t.formData()}catch{return toResponse({ok:!1,status:400,error:"BAD_REQUEST",message:"请求体解析失败"})}const r=o.get("file"),a=o.get("time");return isUploadFormFile(r)&&"string"==typeof a?toResponse(await e.handle(await fileToUpload(r),Number(a))):toResponse({ok:!1,status:400,error:"BAD_REQUEST",message:"缺少 file 或 time"})}}
@@ -1,4 +1,4 @@
1
- import { P as PosterHandler, V as VideoExportHandler } from '../handler-BEalyBz9.js';
1
+ import { P as PosterHandler, V as VideoExportHandler } from '../handler-BiOIAlrh.js';
2
2
 
3
3
  /**
4
4
  * Web 标准适配器(Next.js App Router 路由 / 任何接收 Request 返回 Response 的运行时)。
@@ -1 +1 @@
1
- function e(e){return"object"==typeof e&&null!==e&&"string"==typeof e.type&&"function"==typeof e.arrayBuffer}async function t(e){return{type:e.type,bytes:Buffer.from(await e.arrayBuffer())}}function r(e){return e.ok?new Response(new Uint8Array(e.bytes),{status:200,headers:{"Content-Type":e.contentType,"Content-Disposition":`attachment; filename="${e.filename}"`,"Cache-Control":"no-store"}}):new Response(JSON.stringify({error:e.error,message:e.message}),{status:e.status,headers:{"Content-Type":"application/json"}})}function a(a){return async o=>{let s;try{s=await o.formData()}catch{return r({ok:!1,status:400,error:"BAD_REQUEST",message:"请求体解析失败"})}const n=[];for(let r=0;r<16;r++){const a=s.get(`video_${r}`);if(!e(a))break;n.push(await t(a))}const i=[];for(let r=0;r<16;r++){const a=s.get(`audio_${r}`);if(!e(a))break;i.push(await t(a))}const f=s.get("editState"),u=s.get("overlay"),y=e(u)?u:void 0,c=y?Buffer.from(await y.arrayBuffer()):void 0;if(y&&"image/png"!==y.type)return r({ok:!1,status:415,error:"BAD_OVERLAY",message:"overlay 必须是 PNG"});const g=s.get("videoCover"),p=e(g)?g:void 0,m=p?Buffer.from(await p.arrayBuffer()):void 0;if(p&&!/^image\/(?:png|jpe?g)$/.test(p.type))return r({ok:!1,status:415,error:"BAD_COVER",message:"videoCover must be PNG or JPEG"});const l=[];for(let t=0;t<16;t++){const a=s.get(`textOverlay_${t}`);if(!e(a))break;if("image/png"!==a.type)return r({ok:!1,status:415,error:"BAD_OVERLAY",message:"textOverlay 必须是 PNG"});l.push(Buffer.from(await a.arrayBuffer()))}const v={videos:n,audios:i,overlay:c,videoCover:m,textOverlays:l,editStateRaw:"string"==typeof f?f:""};return r(await a.handle(v))}}function o(a){return async o=>{let s;try{s=await o.formData()}catch{return r({ok:!1,status:400,error:"BAD_REQUEST",message:"请求体解析失败"})}const n=s.get("file"),i=s.get("time");return e(n)&&"string"==typeof i?r(await a.handle(await t(n),Number(i))):r({ok:!1,status:400,error:"BAD_REQUEST",message:"缺少 file 或 time"})}}export{o as toWebPosterHandler,a as toWebVideoHandler};
1
+ function e(e){return"object"==typeof e&&null!==e&&"string"==typeof e.type&&"function"==typeof e.arrayBuffer}async function t(e){return{type:e.type,bytes:Buffer.from(await e.arrayBuffer())}}function r(e){return"string"==typeof e&&e?e:void 0}function o(e){if("string"!=typeof e||!e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}function a(e){return e.ok?new Response(new Uint8Array(e.bytes),{status:200,headers:{"Content-Type":e.contentType,"Content-Disposition":`attachment; filename="${e.filename}"`,"Cache-Control":"no-store"}}):new Response(JSON.stringify({error:e.error,message:e.message}),{status:e.status,headers:{"Content-Type":"application/json"}})}function n(n){return async s=>{let i;try{i=await s.formData()}catch{return a({ok:!1,status:400,error:"BAD_REQUEST",message:"请求体解析失败"})}const f=[],u=[];for(let a=0;a<16;a++){const n=i.get(`video_${a}`),s=r(i.get(`videoUrl_${a}`));e(n)&&(f[a]=await t(n)),s&&(u[a]={url:s,name:r(i.get(`videoName_${a}`)),type:r(i.get(`videoType_${a}`)),size:o(i.get(`videoSize_${a}`))})}const y=[];for(let r=0;r<16;r++){const o=i.get(`audio_${r}`);if(!e(o))break;y.push(await t(o))}const g=i.get("editState"),c=i.get("overlay"),p=e(c)?c:void 0,m=p?Buffer.from(await p.arrayBuffer()):void 0;if(p&&"image/png"!==p.type)return a({ok:!1,status:415,error:"BAD_OVERLAY",message:"overlay 必须是 PNG"});const v=i.get("videoCover"),d=e(v)?v:void 0,l=d?Buffer.from(await d.arrayBuffer()):void 0;if(d&&!/^image\/(?:png|jpe?g)$/.test(d.type))return a({ok:!1,status:415,error:"BAD_COVER",message:"videoCover must be PNG or JPEG"});const w=[];for(let t=0;t<16;t++){const r=i.get(`textOverlay_${t}`);if(!e(r))break;if("image/png"!==r.type)return a({ok:!1,status:415,error:"BAD_OVERLAY",message:"textOverlay 必须是 PNG"});w.push(Buffer.from(await r.arrayBuffer()))}const B={videos:f,videoUrls:u,audios:y,overlay:m,videoCover:l,textOverlays:w,editStateRaw:"string"==typeof g?g:""};return a(await n.handle(B))}}function s(r){return async o=>{let n;try{n=await o.formData()}catch{return a({ok:!1,status:400,error:"BAD_REQUEST",message:"请求体解析失败"})}const s=n.get("file"),i=n.get("time");return e(s)&&"string"==typeof i?a(await r.handle(await t(s),Number(i))):a({ok:!1,status:400,error:"BAD_REQUEST",message:"缺少 file 或 time"})}}export{s as toWebPosterHandler,n as toWebVideoHandler};
@@ -12,7 +12,14 @@ interface UploadFile {
12
12
  type: string;
13
13
  bytes: Buffer;
14
14
  }
15
+ interface RemoteUploadSource {
16
+ url: string;
17
+ type?: string;
18
+ name?: string;
19
+ size?: number;
20
+ }
15
21
  interface ParsedVideoExport {
22
+ videoUrls?: Array<RemoteUploadSource | undefined>;
16
23
  videos: UploadFile[];
17
24
  audios: UploadFile[];
18
25
  overlay?: Buffer;
@@ -46,4 +53,4 @@ declare function createPosterHandler(opts?: {
46
53
  maxBytes?: number;
47
54
  }): PosterHandler;
48
55
 
49
- export { DEFAULT_LIMITS as D, type ExportErr as E, type PosterHandler as P, type UploadFile as U, type VideoExportHandler as V, type ExportLimits as a, type ExportOk as b, type ExportResult as c, type ParsedVideoExport as d, createPosterHandler as e, createVideoExportHandler as f };
56
+ export { DEFAULT_LIMITS as D, type ExportErr as E, type PosterHandler as P, type RemoteUploadSource as R, type UploadFile as U, type VideoExportHandler as V, type ExportLimits as a, type ExportOk as b, type ExportResult as c, type ParsedVideoExport as d, createPosterHandler as e, createVideoExportHandler as f };