diff --git a/pr-preview/pr-116/assets/index-r4OhAEWK.js b/pr-preview/pr-116/assets/index-mIYrox27.js similarity index 89% rename from pr-preview/pr-116/assets/index-r4OhAEWK.js rename to pr-preview/pr-116/assets/index-mIYrox27.js index face472..a71589c 100644 --- a/pr-preview/pr-116/assets/index-r4OhAEWK.js +++ b/pr-preview/pr-116/assets/index-mIYrox27.js @@ -44,12 +44,7 @@ fold marks: ${a} total: ${s.concat(a)}`),s.concat(a)}}build_3_6s_sheetList(e){const t=this.page,n=s=>[t(s+2),t(s+11),t(s+10),t(s+3),t(s+6),t(s+7)],i=s=>[t(s+8),t(s+5),t(s+4),t(s+9),t(s+12),t(s+1)];return this.build_strips_sheetList(3,3,e,n,i)}build_4_8s_sheetList(e){const t=this.page,n=s=>[t(s+2),t(s+15),t(s+14),t(s+3),t(s+6),t(s+11),t(s+10),t(s+7)],i=s=>[t(s+8),t(s+9),t(s+12),t(s+5),t(s+4),t(s+13),t(s+16),t(s+1)];return this.build_strips_sheetList(4,4,e,n,i)}build_6_10s_sheetList(e){const t=this.page,n=s=>[t(s+6),t(s+3),t(s+2),t(s+7),t(s+10),t(s+19),t(s+18),t(s+11),t(s+14),t(s+15)],i=s=>[t(s+16),t(s+13),t(s+12),t(s+17),t(s+20),t(s+9),t(s+8),t(s+1),t(s+4),t(s+5)];return this.build_strips_sheetList(6,5,e,n,i)}build_strips_sheetList(e,t,n,i,s){const a=[],o=[],l=this.blankPage,c=t*4,d=Math.ceil(n/c);console.log(`Building the ${e} rows of ${t*2} pages. Given ${n} page count, there will be ${d} rows...`);for(let h=0;h adding front ${a[a.length-1]} and back ${o[a.length-1]}`)}const f=[];for(let h=0;h row ${h} => sheet ${u} grabs front ${a[h]} and back ${o[h]}`)}if(f[f.length-1].length{u.forEach(g=>{this.rotate180(g)})}));return f}build_strip_lineFunction(e,t){return n=>{const i=l=>n.isPacked?n.gap[1]:n.gap[1]*(2*l),s=l=>n.isPacked?n.gap[0]:l*n.gap[0],a=[this.cutVertical(n.paperSize[1],s(0)),this.cutVertical(n.paperSize[1],s(t)+n.renderPageSize[0]*t)];for(let l=0;l<=e;++l)a.push(this.cutHorizontal(n.paperSize[0],i(l)+n.renderPageSize[1]*l));let o=[];return[...Array(e).keys()].forEach(l=>{[...Array(t).keys()].forEach(c=>{o=o.concat(this.crosshairMark(s(c)+n.renderPageSize[0]*c,i(l)+n.renderPageSize[1]*l,5))})}),console.log(`Providing lines: base cuts: ${a} fold marks:${o} -total: ${a.concat(o)}`),a.concat(o)}}build_2_16s_sheetList(e){const t=this.page,n=this.flipPage,i=[],s=Math.ceil(e/32);console.log(`Building the 32 pages. Given ${e} page count, there will be ${s} sheets...`);for(let a=0;a{const t=s=>e.isPacked?e.gap[1]:e.gap[1]*(2*s),n=s=>e.isPacked?e.gap[0]:s*e.gap[0];let i=[];return[0,1,2,3,4].forEach(s=>{[0,1,2,3,4].forEach(a=>{i=i.concat(this.crosshairMark(n(a)+e.renderPageSize[0]*a,t(s)+e.renderPageSize[1]*s,5))})}),[{...this.foldHorizontal(e.paperSize[0],e.paperSize[1]/2,0),opacity:.4},this.cutVertical(e.paperSize[1],e.paperSize[0]/2),this.cutVertical(e.paperSize[1],e.paperSize[0]-e.gap[0]),this.cutVertical(e.paperSize[1],e.gap[0])].concat(i)}}foldHorizontal(e,t){return{start:{x:0,y:t},end:{x:e,y:t},thickness:.25,opacity:.4,dashArray:[2,5]}}foldVertical(e,t){return{start:{x:t,y:0},end:{x:t,y:e},thickness:.25,opacity:.4,dashArray:[2,5]}}cutHorizontal(e,t){return{start:{x:0,y:t},end:{x:e,y:t},thickness:.5,opacity:.4}}cutVertical(e,t){return{start:{x:t,y:0},end:{x:t,y:e},thickness:.5,opacity:.4}}crosshairMark(e,t,n){return[{start:{x:e-n/2,y:t},end:{x:e+n/2,y:t},thickness:.5,opacity:.4},{start:{x:e,y:t-n/2},end:{x:e,y:t+n/2},thickness:.5,opacity:.4}]}auditForBlanks(e,t){return e.forEach(n=>{n.num>=t&&(n.isBlank=!0,n.num=0)}),e}page(e){return{num:e,isBlank:!1,vFlip:!1}}flipPage(e){return{num:e,isBlank:!1,vFlip:!0}}blankPage(){return{num:0,isBlank:!0,vFlip:!1}}rotate180(e){e.vFlip=!e.vFlip}}var Ue;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ue||(Ue={}));var gc;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(gc||(gc={}));const ae=Ue.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Nr=r=>{switch(typeof r){case"undefined":return ae.undefined;case"string":return ae.string;case"number":return isNaN(r)?ae.nan:ae.number;case"boolean":return ae.boolean;case"function":return ae.function;case"bigint":return ae.bigint;case"symbol":return ae.symbol;case"object":return Array.isArray(r)?ae.array:r===null?ae.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ae.promise:typeof Map<"u"&&r instanceof Map?ae.map:typeof Set<"u"&&r instanceof Set?ae.set:typeof Date<"u"&&r instanceof Date?ae.date:ae.object;default:return ae.unknown}},$=Ue.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Fx=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Qt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,l=0;for(;lt.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Qt.create=r=>new Qt(r);const ys=(r,e)=>{let t;switch(r.code){case $.invalid_type:r.received===ae.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case $.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Ue.jsonStringifyReplacer)}`;break;case $.unrecognized_keys:t=`Unrecognized key(s) in object: ${Ue.joinValues(r.keys,", ")}`;break;case $.invalid_union:t="Invalid input";break;case $.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Ue.joinValues(r.options)}`;break;case $.invalid_enum_value:t=`Invalid enum value. Expected ${Ue.joinValues(r.options)}, received '${r.received}'`;break;case $.invalid_arguments:t="Invalid function arguments";break;case $.invalid_return_type:t="Invalid function return type";break;case $.invalid_date:t="Invalid date";break;case $.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Ue.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case $.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case $.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case $.custom:t="Invalid input";break;case $.invalid_intersection_types:t="Intersection results could not be merged";break;case $.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case $.not_finite:t="Number must be finite";break;default:t=e.defaultError,Ue.assertNever(r)}return{message:t}};let wh=ys;function Ax(r){wh=r}function ja(){return wh}const Va=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};let o="";const l=n.filter(c=>!!c).slice().reverse();for(const c of l)o=c(a,{data:e,defaultError:o}).message;return{...i,path:s,message:i.message||o}},Cx=[];function oe(r,e){const t=Va({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ja(),ys].filter(n=>!!n)});r.common.issues.push(t)}class yt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Se;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t)n.push({key:await i.key,value:await i.value});return yt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return Se;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const Se=Object.freeze({status:"aborted"}),kh=r=>({status:"dirty",value:r}),At=r=>({status:"valid",value:r}),mc=r=>r.status==="aborted",xc=r=>r.status==="dirty",vs=r=>r.status==="valid",Wa=r=>typeof Promise<"u"&&r instanceof Promise;var me;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(me||(me={}));class hr{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Cd=(r,e)=>{if(vs(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 Qt(r.common.issues);return this._error=t,this._error}}};function Ae(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>a.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:n??o.defaultError}:{message:t??o.defaultError},description:i}}class Ee{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)}get description(){return this._def.description}_getType(e){return Nr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Nr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new yt,ctx:{common:e.parent.common,data:e.data,parsedType:Nr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Wa(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 n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nr(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Cd(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nr(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Wa(i)?i:Promise.resolve(i));return Cd(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:$.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new tr({schema:this,typeName:ye.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Sr.create(this,this._def)}nullable(){return En.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $t.create(this,this._def)}promise(){return xi.create(this,this._def)}or(e){return Fs.create([this,e],this._def)}and(e){return As.create(this,e,this._def)}transform(e){return new tr({...Ae(this._def),schema:this,typeName:ye.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Os({...Ae(this._def),innerType:this,defaultValue:t,typeName:ye.ZodDefault})}brand(){return new Fh({typeName:ye.ZodBranded,type:this,...Ae(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ka({...Ae(this._def),innerType:this,catchValue:t,typeName:ye.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Hs.create(this,e)}readonly(){return Ya.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ex=/^c[^\s-]{8,}$/i,Tx=/^[a-z][a-z0-9]*$/,_x=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ox=/^[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,Rx=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Px="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Io;const Dx=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,zx=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Bx=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Nx(r,e){return!!((e==="v4"||!e)&&Dx.test(r)||(e==="v6"||!e)&&zx.test(r))}class Xt extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ae.string){const s=this._getOrReturnCtx(e);return oe(s,{code:$.invalid_type,expected:ae.string,received:s.parsedType}),Se}const n=new yt;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.lengths.value&&(i=this._getOrReturnCtx(e,i),oe(i,{code:$.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.lengthe.test(i),{validation:t,code:$.invalid_string,...me.errToObj(n)})}_addCheck(e){return new Xt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...me.errToObj(e)})}url(e){return this._addCheck({kind:"url",...me.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...me.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...me.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...me.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...me.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...me.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...me.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...me.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...me.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...me.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...me.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...me.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...me.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...me.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...me.errToObj(t)})}nonempty(e){return this.min(1,me.errToObj(e))}trim(){return new Xt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Xt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Xt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}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 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 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{var e;return new Xt({checks:[],typeName:ye.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ae(r)})};function Ix(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class nn extends Ee{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)!==ae.number){const s=this._getOrReturnCtx(e);return oe(s,{code:$.invalid_type,expected:ae.number,received:s.parsedType}),Se}let n;const i=new yt;for(const s of this._def.checks)s.kind==="int"?Ue.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),oe(n,{code:$.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.datas.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),oe(n,{code:$.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Ix(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),oe(n,{code:$.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),oe(n,{code:$.not_finite,message:s.message}),i.dirty()):Ue.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,me.toString(t))}setLimit(e,t,n,i){return new nn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:me.toString(i)}]})}_addCheck(e){return new nn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:me.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:me.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:me.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:me.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:me.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.valuee.kind==="int"||e.kind==="multipleOf"&&Ue.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.valuenew nn({checks:[],typeName:ye.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Ae(r)});class sn extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==ae.bigint){const s=this._getOrReturnCtx(e);return oe(s,{code:$.invalid_type,expected:ae.bigint,received:s.parsedType}),Se}let n;const i=new yt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.datas.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),oe(n,{code:$.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),oe(n,{code:$.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ue.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,me.toString(t))}setLimit(e,t,n,i){return new sn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:me.toString(i)}]})}_addCheck(e){return new sn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:me.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{var e;return new sn({checks:[],typeName:ye.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ae(r)})};class ws extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ae.boolean){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.boolean,received:n.parsedType}),Se}return At(e.data)}}ws.create=r=>new ws({typeName:ye.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Ae(r)});class An extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ae.date){const s=this._getOrReturnCtx(e);return oe(s,{code:$.invalid_type,expected:ae.date,received:s.parsedType}),Se}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return oe(s,{code:$.invalid_date}),Se}const n=new yt;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()s.value&&(i=this._getOrReturnCtx(e,i),oe(i,{code:$.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Ue.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new An({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:me.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:me.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.valuenew An({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:ye.ZodDate,...Ae(r)});class Ha extends Ee{_parse(e){if(this._getType(e)!==ae.symbol){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.symbol,received:n.parsedType}),Se}return At(e.data)}}Ha.create=r=>new Ha({typeName:ye.ZodSymbol,...Ae(r)});class ks extends Ee{_parse(e){if(this._getType(e)!==ae.undefined){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.undefined,received:n.parsedType}),Se}return At(e.data)}}ks.create=r=>new ks({typeName:ye.ZodUndefined,...Ae(r)});class Ss extends Ee{_parse(e){if(this._getType(e)!==ae.null){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.null,received:n.parsedType}),Se}return At(e.data)}}Ss.create=r=>new Ss({typeName:ye.ZodNull,...Ae(r)});class mi extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return At(e.data)}}mi.create=r=>new mi({typeName:ye.ZodAny,...Ae(r)});class xn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return At(e.data)}}xn.create=r=>new xn({typeName:ye.ZodUnknown,...Ae(r)});class Cr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return oe(t,{code:$.invalid_type,expected:ae.never,received:t.parsedType}),Se}}Cr.create=r=>new Cr({typeName:ye.ZodNever,...Ae(r)});class Ga extends Ee{_parse(e){if(this._getType(e)!==ae.undefined){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.void,received:n.parsedType}),Se}return At(e.data)}}Ga.create=r=>new Ga({typeName:ye.ZodVoid,...Ae(r)});class $t extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ae.array)return oe(t,{code:$.invalid_type,expected:ae.array,received:t.parsedType}),Se;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.lengthi.maxLength.value&&(oe(t,{code:$.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new hr(t,a,t.path,o)))).then(a=>yt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new hr(t,a,t.path,o)));return yt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new $t({...this._def,minLength:{value:e,message:me.toString(t)}})}max(e,t){return new $t({...this._def,maxLength:{value:e,message:me.toString(t)}})}length(e,t){return new $t({...this._def,exactLength:{value:e,message:me.toString(t)}})}nonempty(e){return this.min(1,e)}}$t.create=(r,e)=>new $t({type:r,minLength:null,maxLength:null,exactLength:null,typeName:ye.ZodArray,...Ae(e)});function Vn(r){if(r instanceof Ye){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Sr.create(Vn(n))}return new Ye({...r._def,shape:()=>e})}else return r instanceof $t?new $t({...r._def,type:Vn(r.element)}):r instanceof Sr?Sr.create(Vn(r.unwrap())):r instanceof En?En.create(Vn(r.unwrap())):r instanceof fr?fr.create(r.items.map(e=>Vn(e))):r}class Ye extends Ee{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=Ue.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ae.object){const c=this._getOrReturnCtx(e);return oe(c,{code:$.invalid_type,expected:ae.object,received:c.parsedType}),Se}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Cr&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||o.push(c);const l=[];for(const c of a){const d=s[c],f=i.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new hr(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Cr){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of o)l.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")o.length>0&&(oe(i,{code:$.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of o){const f=i.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new hr(i,f,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const f=await d.key;c.push({key:f,value:await d.value,alwaysSet:d.alwaysSet})}return c}).then(c=>yt.mergeObjectSync(n,c)):yt.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return me.errToObj,new Ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const l=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=me.errToObj(e).message)!==null&&o!==void 0?o:l}:{message:l}}}:{}})}strip(){return new Ye({...this._def,unknownKeys:"strip"})}passthrough(){return new Ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ye.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ye({...this._def,catchall:e})}pick(e){const t={};return Ue.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}omit(e){const t={};return Ue.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}deepPartial(){return Vn(this)}partial(e){const t={};return Ue.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Ye({...this._def,shape:()=>t})}required(e){const t={};return Ue.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Sr;)s=s._def.innerType;t[n]=s}}),new Ye({...this._def,shape:()=>t})}keyof(){return Sh(Ue.objectKeys(this.shape))}}Ye.create=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strip",catchall:Cr.create(),typeName:ye.ZodObject,...Ae(e)});Ye.strictCreate=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strict",catchall:Cr.create(),typeName:ye.ZodObject,...Ae(e)});Ye.lazycreate=(r,e)=>new Ye({shape:r,unknownKeys:"strip",catchall:Cr.create(),typeName:ye.ZodObject,...Ae(e)});class Fs extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new Qt(o.ctx.common.issues));return oe(t,{code:$.invalid_union,unionErrors:a}),Se}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const l of n){const c={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(l=>new Qt(l));return oe(t,{code:$.invalid_union,unionErrors:o}),Se}}get options(){return this._def.options}}Fs.create=(r,e)=>new Fs({options:r,typeName:ye.ZodUnion,...Ae(e)});const va=r=>r instanceof Es?va(r.schema):r instanceof tr?va(r.innerType()):r instanceof Ts?[r.value]:r instanceof an?r.options:r instanceof _s?Object.keys(r.enum):r instanceof Os?va(r._def.innerType):r instanceof ks?[void 0]:r instanceof Ss?[null]:null;class mo extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ae.object)return oe(t,{code:$.invalid_type,expected:ae.object,received:t.parsedType}),Se;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(oe(t,{code:$.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Se)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=va(s.shape[e]);if(!a)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new mo({typeName:ye.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Ae(n)})}}function bc(r,e){const t=Nr(r),n=Nr(e);if(r===e)return{valid:!0,data:r};if(t===ae.object&&n===ae.object){const i=Ue.objectKeys(e),s=Ue.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const l=bc(r[o],e[o]);if(!l.valid)return{valid:!1};a[o]=l.data}return{valid:!0,data:a}}else if(t===ae.array&&n===ae.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s{if(mc(s)||mc(a))return Se;const o=bc(s.value,a.value);return o.valid?((xc(s)||xc(a))&&t.dirty(),{status:t.value,value:o.data}):(oe(n,{code:$.invalid_intersection_types}),Se)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}As.create=(r,e,t)=>new As({left:r,right:e,typeName:ye.ZodIntersection,...Ae(t)});class fr extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.array)return oe(n,{code:$.invalid_type,expected:ae.array,received:n.parsedType}),Se;if(n.data.lengththis._def.items.length&&(oe(n,{code:$.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new hr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>yt.mergeArray(t,a)):yt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new fr({...this._def,rest:e})}}fr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fr({items:r,typeName:ye.ZodTuple,rest:null,...Ae(e)})};class Cs extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.object)return oe(n,{code:$.invalid_type,expected:ae.object,received:n.parsedType}),Se;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new hr(n,o,n.path,o)),value:a._parse(new hr(n,n.data[o],n.path,o))});return n.common.async?yt.mergeObjectAsync(t,i):yt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new Cs({keyType:e,valueType:t,typeName:ye.ZodRecord,...Ae(n)}):new Cs({keyType:Xt.create(),valueType:e,typeName:ye.ZodRecord,...Ae(t)})}}class Za extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.map)return oe(n,{code:$.invalid_type,expected:ae.map,received:n.parsedType}),Se;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,l],c)=>({key:i._parse(new hr(n,o,n.path,[c,"key"])),value:s._parse(new hr(n,l,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of a){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return Se;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const l of a){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return Se;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}}}}Za.create=(r,e,t)=>new Za({valueType:e,keyType:r,typeName:ye.ZodMap,...Ae(t)});class Cn extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.set)return oe(n,{code:$.invalid_type,expected:ae.set,received:n.parsedType}),Se;const i=this._def;i.minSize!==null&&n.data.sizei.maxSize.value&&(oe(n,{code:$.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(l){const c=new Set;for(const d of l){if(d.status==="aborted")return Se;d.status==="dirty"&&t.dirty(),c.add(d.value)}return{status:t.value,value:c}}const o=[...n.data.values()].map((l,c)=>s._parse(new hr(n,l,n.path,c)));return n.common.async?Promise.all(o).then(l=>a(l)):a(o)}min(e,t){return new Cn({...this._def,minSize:{value:e,message:me.toString(t)}})}max(e,t){return new Cn({...this._def,maxSize:{value:e,message:me.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Cn.create=(r,e)=>new Cn({valueType:r,minSize:null,maxSize:null,typeName:ye.ZodSet,...Ae(e)});class ti extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ae.function)return oe(t,{code:$.invalid_type,expected:ae.function,received:t.parsedType}),Se;function n(o,l){return Va({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ja(),ys].filter(c=>!!c),issueData:{code:$.invalid_arguments,argumentsError:l}})}function i(o,l){return Va({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ja(),ys].filter(c=>!!c),issueData:{code:$.invalid_return_type,returnTypeError:l}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof xi){const o=this;return At(async function(...l){const c=new Qt([]),d=await o._def.args.parseAsync(l,s).catch(u=>{throw c.addIssue(n(l,u)),c}),f=await Reflect.apply(a,this,d);return await o._def.returns._def.type.parseAsync(f,s).catch(u=>{throw c.addIssue(i(f,u)),c})})}else{const o=this;return At(function(...l){const c=o._def.args.safeParse(l,s);if(!c.success)throw new Qt([n(l,c.error)]);const d=Reflect.apply(a,this,c.data),f=o._def.returns.safeParse(d,s);if(!f.success)throw new Qt([i(d,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ti({...this._def,args:fr.create(e).rest(xn.create())})}returns(e){return new ti({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ti({args:e||fr.create([]).rest(xn.create()),returns:t||xn.create(),typeName:ye.ZodFunction,...Ae(n)})}}class Es extends Ee{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})}}Es.create=(r,e)=>new Es({getter:r,typeName:ye.ZodLazy,...Ae(e)});class Ts extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return oe(t,{received:t.data,code:$.invalid_literal,expected:this._def.value}),Se}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ts.create=(r,e)=>new Ts({value:r,typeName:ye.ZodLiteral,...Ae(e)});function Sh(r,e){return new an({values:r,typeName:ye.ZodEnum,...Ae(e)})}class an extends Ee{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return oe(t,{expected:Ue.joinValues(n),received:t.parsedType,code:$.invalid_type}),Se}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return oe(t,{received:t.data,code:$.invalid_enum_value,options:n}),Se}return At(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){return an.create(e)}exclude(e){return an.create(this.options.filter(t=>!e.includes(t)))}}an.create=Sh;class _s extends Ee{_parse(e){const t=Ue.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ae.string&&n.parsedType!==ae.number){const i=Ue.objectValues(t);return oe(n,{expected:Ue.joinValues(i),received:n.parsedType,code:$.invalid_type}),Se}if(t.indexOf(e.data)===-1){const i=Ue.objectValues(t);return oe(n,{received:n.data,code:$.invalid_enum_value,options:i}),Se}return At(e.data)}get enum(){return this._def.values}}_s.create=(r,e)=>new _s({values:r,typeName:ye.ZodNativeEnum,...Ae(e)});class xi extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ae.promise&&t.common.async===!1)return oe(t,{code:$.invalid_type,expected:ae.promise,received:t.parsedType}),Se;const n=t.parsedType===ae.promise?t.data:Promise.resolve(t.data);return At(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}xi.create=(r,e)=>new xi({type:r,typeName:ye.ZodPromise,...Ae(e)});class tr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ye.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{oe(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(a).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:a,path:n.path,parent:n})}if(i.type==="refinement"){const a=o=>{const l=i.refinement(o,s);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Se:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?Se:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!vs(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>vs(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Ue.assertNever(i)}}tr.create=(r,e,t)=>new tr({schema:r,typeName:ye.ZodEffects,effect:e,...Ae(t)});tr.createWithPreprocess=(r,e,t)=>new tr({schema:e,effect:{type:"preprocess",transform:r},typeName:ye.ZodEffects,...Ae(t)});class Sr extends Ee{_parse(e){return this._getType(e)===ae.undefined?At(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sr.create=(r,e)=>new Sr({innerType:r,typeName:ye.ZodOptional,...Ae(e)});class En extends Ee{_parse(e){return this._getType(e)===ae.null?At(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}En.create=(r,e)=>new En({innerType:r,typeName:ye.ZodNullable,...Ae(e)});class Os extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ae.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Os.create=(r,e)=>new Os({innerType:r,typeName:ye.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ae(e)});class Ka extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Wa(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Qt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Qt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ka.create=(r,e)=>new Ka({innerType:r,typeName:ye.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ae(e)});class Xa extends Ee{_parse(e){if(this._getType(e)!==ae.nan){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.nan,received:n.parsedType}),Se}return{status:"valid",value:e.data}}}Xa.create=r=>new Xa({typeName:ye.ZodNaN,...Ae(r)});const Mx=Symbol("zod_brand");class Fh extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Hs extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Se:s.status==="dirty"?(t.dirty(),kh(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Se:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Hs({in:e,out:t,typeName:ye.ZodPipeline})}}class Ya extends Ee{_parse(e){const t=this._def.innerType._parse(e);return vs(t)&&(t.value=Object.freeze(t.value)),t}}Ya.create=(r,e)=>new Ya({innerType:r,typeName:ye.ZodReadonly,...Ae(e)});const Ah=(r,e={},t)=>r?mi.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,l=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,c=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...c,fatal:l})}}):mi.create(),Lx={object:Ye.lazycreate};var ye;(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"})(ye||(ye={}));const Ux=(r,e={message:`Input not instance of ${r.name}`})=>Ah(t=>t instanceof r,e),Ch=Xt.create,Eh=nn.create,qx=Xa.create,jx=sn.create,Th=ws.create,Vx=An.create,Wx=Ha.create,Hx=ks.create,Gx=Ss.create,Zx=mi.create,Kx=xn.create,Xx=Cr.create,Yx=Ga.create,Jx=$t.create,Qx=Ye.create,$x=Ye.strictCreate,e1=Fs.create,t1=mo.create,r1=As.create,n1=fr.create,i1=Cs.create,s1=Za.create,a1=Cn.create,o1=ti.create,c1=Es.create,l1=Ts.create,d1=an.create,u1=_s.create,h1=xi.create,Ed=tr.create,f1=Sr.create,p1=En.create,g1=tr.createWithPreprocess,m1=Hs.create,x1=()=>Ch().optional(),b1=()=>Eh().optional(),y1=()=>Th().optional(),v1={string:r=>Xt.create({...r,coerce:!0}),number:r=>nn.create({...r,coerce:!0}),boolean:r=>ws.create({...r,coerce:!0}),bigint:r=>sn.create({...r,coerce:!0}),date:r=>An.create({...r,coerce:!0})},w1=Se;var Ne=Object.freeze({__proto__:null,defaultErrorMap:ys,setErrorMap:Ax,getErrorMap:ja,makeIssue:Va,EMPTY_PATH:Cx,addIssueToContext:oe,ParseStatus:yt,INVALID:Se,DIRTY:kh,OK:At,isAborted:mc,isDirty:xc,isValid:vs,isAsync:Wa,get util(){return Ue},get objectUtil(){return gc},ZodParsedType:ae,getParsedType:Nr,ZodType:Ee,ZodString:Xt,ZodNumber:nn,ZodBigInt:sn,ZodBoolean:ws,ZodDate:An,ZodSymbol:Ha,ZodUndefined:ks,ZodNull:Ss,ZodAny:mi,ZodUnknown:xn,ZodNever:Cr,ZodVoid:Ga,ZodArray:$t,ZodObject:Ye,ZodUnion:Fs,ZodDiscriminatedUnion:mo,ZodIntersection:As,ZodTuple:fr,ZodRecord:Cs,ZodMap:Za,ZodSet:Cn,ZodFunction:ti,ZodLazy:Es,ZodLiteral:Ts,ZodEnum:an,ZodNativeEnum:_s,ZodPromise:xi,ZodEffects:tr,ZodTransformer:tr,ZodOptional:Sr,ZodNullable:En,ZodDefault:Os,ZodCatch:Ka,ZodNaN:Xa,BRAND:Mx,ZodBranded:Fh,ZodPipeline:Hs,ZodReadonly:Ya,custom:Ah,Schema:Ee,ZodSchema:Ee,late:Lx,get ZodFirstPartyTypeKind(){return ye},coerce:v1,any:Zx,array:Jx,bigint:jx,boolean:Th,date:Vx,discriminatedUnion:t1,effect:Ed,enum:d1,function:o1,instanceof:Ux,intersection:r1,lazy:c1,literal:l1,map:s1,nan:qx,nativeEnum:u1,never:Xx,null:Gx,nullable:p1,number:Eh,object:Qx,oboolean:y1,onumber:b1,optional:f1,ostring:x1,pipeline:m1,preprocess:g1,promise:h1,record:i1,set:a1,strictObject:$x,string:Ch,symbol:Wx,transformer:Ed,tuple:n1,undefined:Hx,union:e1,unknown:Kx,void:Yx,NEVER:w1,ZodIssueCode:$,quotelessJson:Fx,ZodError:Qt});const k1=Ne.union([Ne.string(),Ne.array(Ne.number())]).transform(r=>Array.isArray(r)?r:r.split(/, */)).pipe(Ne.array(Ne.coerce.number())),un=Ne.union([Ne.string().toLowerCase().pipe(Ne.enum(["true","false","on"])),Ne.boolean()]).transform(r=>r==="true"||r==="on"||r===!0),qe=r=>r.optional().catch(()=>{}),S1=qe(Ne.enum(["none","90cw","90ccw","out_binding","in_binding"])).default("none"),F1=qe(Ne.enum(["all","only_out","only_in","in_n_out"])).default("all"),A1=Object.keys(gi),C1=qe(Ne.enum([...A1,"CUSTOM"])).default("A4"),E1=qe(Ne.enum(["pt","in","cm"])).default("pt"),T1=qe(Ne.enum(["single","duplex"])).default("duplex"),_1=qe(Ne.enum(["folio","quarto","octavo","sextodecimo"])).default("folio"),O1=qe(Ne.enum(["centered","lockratio","stretch"])).default("lockratio"),R1=qe(Ne.enum(["centered","binding_aligned"])).default("centered"),P1=qe(Ne.enum(["booklet","perfect","standardsig","customsig","1_3rd","A7_2_16s","8_zine","a_3_6s","a9_3_3_4","a_4_8s","a10_6_10s"])).default("standardsig"),D1=qe(Ne.enum(["wacky_pack","wacky_gap"])).default("wacky_pack"),z1=qe(Ne.enum(["aggregated","signatures","both"])).default("both"),nl=Ne.object({printFile:z1,sourceRotation:S1,rotatePage:qe(un).default(!1),paperSize:C1,paperSizeUnit:E1,printerType:T1,paperRotation90:qe(un).default(!1),pageLayout:_1,cropMarks:qe(un).default(!1),cutMarks:qe(un).default(!1),pdfEdgeMarks:qe(un).default(!1),sigOrderMarks:qe(un).default(!1),pageScaling:O1,pagePositioning:R1,mainForeEdgePaddingPt:qe(Ne.coerce.number()).default(0),bindingEdgePaddingPt:qe(Ne.coerce.number()).default(0),topEdgePaddingPt:qe(Ne.coerce.number()).default(0),bottomEdgePaddingPt:qe(Ne.coerce.number()).default(0),sigFormat:P1,sigLength:qe(Ne.coerce.number()).default(4),customSigLength:qe(k1).default(null),foreEdgePaddingPt:qe(Ne.coerce.number()).default(0),wackySpacing:D1,flyleafs:qe(Ne.coerce.number()).default(1),sewingMarksEnabled:qe(un).default(!1),sewingMarkLocation:F1,sewingMarksMarginPt:qe(Ne.coerce.number()).default(72),sewingMarksAmount:qe(Ne.coerce.number()).default(3),sewingMarksTapeWidthPt:qe(Ne.coerce.number()).default(36),paperSizeCustomWidth:qe(Ne.coerce.number()).default(0),paperSizeCustomHeight:qe(Ne.coerce.number()).default(0)}),B1=nl.parse({}),il="bookbinderSettings";function _h(){const r={},e=JSON.parse(localStorage.getItem(il));return e||(Oh(r),_h())}function Oh(r){localStorage.setItem(il,JSON.stringify(r))}function N1(){localStorage.removeItem(il)}const I1=r=>{const e=new URL(r).searchParams.entries();return Object.fromEntries(e)},M1=(r,e)=>{const t=new URL(r);for(const[n,i]of Object.entries(e))if(i!=null){if(i===B1[n]){t.searchParams.delete(n);continue}t.searchParams.set(n,String(i))}return t.toString()},L1=r=>{const e=new URL(r);return e.search="",e.toString()},Rh=r=>{window.history.pushState({},"",r.toString())},U1=r=>nl.parse({sourceRotation:r.get("source_rotation"),paperSize:r.get("paper_size"),paperSizeUnit:r.get("paper_size_unit"),printerType:r.get("printer_type"),rotatePage:r.has("rotate_page"),paperRotation90:r.has("paper_rotation_90"),pageLayout:r.get("pagelayout"),cropMarks:r.has("cropmarks"),sigOrderMarks:r.has("sig_order_marks"),pdfEdgeMarks:r.has("pdf_edge_marks"),cutMarks:r.has("cutmarks"),pageScaling:r.get("page_scaling"),pagePositioning:r.get("page_positioning"),mainForeEdgePaddingPt:r.get("main_fore_edge_padding_pt"),bindingEdgePaddingPt:r.get("binding_edge_padding_pt"),topEdgePaddingPt:r.get("top_edge_padding_pt"),bottomEdgePaddingPt:r.get("bottom_edge_padding_pt"),sigFormat:r.get("sig_format"),sigLength:r.get("sig_length"),customSigLength:r.get("custom_sig"),foreEdgePaddingPt:r.get("fore_edge_padding_pt"),wackySpacing:r.get("wacky_spacing"),fileDownload:r.get("file_download"),printFile:r.get("print_file"),flyleafs:r.get("flyleafs"),paperSizeCustomWidth:r.get("paper_size_custom_width"),paperSizeCustomHeight:r.get("paper_size_custom_height"),sewingMarksEnabled:r.has("add_sewing_marks_checkbox"),sewingMarkLocation:r.get("sewing_mark_locations"),sewingMarksMarginPt:r.get("sewing_marks_margin_pt"),sewingMarksAmount:r.get("sewing_marks_amount"),sewingMarksTapeWidthPt:r.get("sewing_marks_tape_width_pt")}),Ph=r=>{Rh(M1(window.location.href,r))},Dh=()=>{const r=I1(window.location.href),t=Object.keys(r).length>0?r:_h(),n=nl.parse(t);return Ph(n),n};function zh(r){r.createpages().then(()=>{console.log("... pages created"),G1(r),Z1(r),Y1()})}function q1(r){const e=U1(r);return Oh(e),Ph(e),e}function Bh(){const r=Dh();return J1(r),r}const j1=()=>(N1(),Rh(L1(window.location.href)),Bh());function V1(r,e){r.setAttribute("disabled",!0),r.style.fontSize="13px",r.innerText="Generating, this may take a little while...",console.log("The whole Book model:",e),e.createoutputfiles(!1).then(()=>{console.log("Generated result!")}).catch(n=>{console.error(n)}).finally(()=>{r.removeAttribute("disabled"),r.style.fontSize="24px",r.innerText="Generate PDF Output"})}function W1(r,e){r.setAttribute("disabled",!0),r.innerText="Generating Preview...",Ih(),e.createoutputfiles(!0).then(()=>{console.log("Preview result!")}).catch(n=>{console.error(n)}).finally(()=>{r.removeAttribute("disabled"),r.innerText="Preview Output"})}function H1(r){const e=j1();r.update(e),sl(),xo()}function Nh(r){const e=document.getElementById("sewing_marks_details");r?e.setAttribute("open",0):e.removeAttribute("open")}function G1(r){const e=document.getElementById("page_count");e.innerText=r.pagecount}function Z1(r){const e=document.getElementById("total_sheets"),t=document.getElementById("sig_count"),n=document.getElementById("sig_arrange"),i=document.getElementById("total_pages");if(r.book==null||r.book==null)return;const s=r.book.pagelistdetails.reduce((a,o)=>(o.forEach(l=>a+=l.length?l.length:1),a),0);e.innerText=r.book.sheets,t.innerText=r.book.sigconfig.length,n.innerText=r.book.sigconfig.join(", "),i.innerText=s}function K1(r){document.getElementById("show_layout_info").style.display="block",console.log("So much info from updatePageLayoutInfo: ",r);const e=r.dimensions.layout.rotations[0]==-90||r.dimensions.layout.rotations[0]==90||r.dimensions.layout.rotations[0][0]==-90||r.dimensions.layout.rotations[0][0]==90,t=r.dimensions.layoutCell,n=[r.dimensions.xPdfWidthFunc(),r.dimensions.yPdfHeightFunc()],i=Math.min(Math.min(250/t[0],250/t[1]),Math.min(250/n[0],250/n[1]));let s=[t[0]*i,t[1]*i],a=document.getElementById("grid_layout_preview");a.style.width=`${s[0]}px`,a.style.height=`${s[1]}px`,s=[n[0]*i,n[1]*i],a=document.getElementById("pdf_on_page_layout_preview"),a.style.width=`${s[0]}px`,a.style.height=`${s[1]}px`,s=[r.dimensions.xBindingShiftFunc()*i,r.dimensions.yTopShiftFunc()*i],a.style.margin=`${s[1]}px ${s[0]}px`,document.getElementById("page_grid_layout").innerText=`${r.dimensions.layout.rows} rows x ${r.dimensions.layout.cols} cols`,document.getElementById("page_grid_dimensions").innerText=`${t[0]}, ${t[1]}`,document.getElementById("pdf_source_dimensions").innerText=`${r.cropbox.width}, ${r.cropbox.height}`,document.getElementById("pdf_page_dimensions").innerText=`${n[0].toFixed(2)}, ${n[1].toFixed(2)}`,document.getElementById("pdf_offset_dimensions").innerHTML=` - ${r.dimensions.xBindingShiftFunc().toFixed(2)} from spine
- ${r.dimensions.yTopShiftFunc().toFixed(2)} from top
- ${r.dimensions.xForeEdgeShiftFunc().toFixed(2)} from fore edge
- ${r.dimensions.yBottomShiftFunc().toFixed(2)} from bottom - `,document.getElementById("pdf_scale_dimensions").innerText=`${r.dimensions.pdfScale[0].toFixed(2)}, ${r.dimensions.pdfScale[1].toFixed(2)}`,document.getElementById("pdf_page_rotation_info").innerText=`${e}`}function xo(){const r=document.getElementById("paper_size"),e=document.getElementById("paper_size_unit").value;for(const t of Array.from(r.children)){const n=t.value,i=gi[n];let s=`${n} (${i[0]} x ${i[1]} pt)`;e=="in"?s=`${n} (${(i[0]*.0138889).toFixed(1)} x ${(i[1]*.0138889).toFixed(1)} inches)`:e=="cm"&&(s=`${n} (${(i[0]*.0352778).toFixed(2)} x ${(i[1]*.0352778).toFixed(2)} cm)`),t.setAttribute("label",s)}}function sl(){const r=document.getElementById("paper_size_custom_width").value,e=document.getElementById("paper_size_custom_height").value,t=document.getElementById("paper_size"),n=r.length>0&&e.length>0&&!isNaN(r)&&!isNaN(e),i=t.children.namedItem("CUSTOM");if(!(i==null&&!n))if(i!=null&&!n)i.remove();else if(i==null){const s=document.createElement("option");s.setAttribute("value","CUSTOM"),s.setAttribute("name","CUSTOM"),gi.CUSTOM=[Number(r),Number(e)],t.appendChild(s)}else gi.CUSTOM=[Number(r),Number(e)]}function X1(){const r=document.getElementById("paper_size");Object.keys(gi).forEach(e=>{const t=document.createElement("option");t.setAttribute("value",e),t.setAttribute("name",e),e=="A4"&&t.setAttribute("selected",!0),t.innerText=e,r.appendChild(t)}),xo()}function Y1(){const r=document.getElementById("a9_3_3_4").checked||document.getElementById("a10_6_10s").checked||document.getElementById("a_3_6s").checked||document.getElementById("a_4_8s").checked||document.getElementById("A7_2_16s").checked||document.getElementById("1_3rd").checked;console.log("Is a wacky layout? ",r),document.getElementById("book_size").querySelectorAll("input").forEach(e=>{e.disabled=r}),document.getElementById("book_size").style.opacity=r?.3:1}function J1(r){document.querySelectorAll("[type=radio]").forEach(n=>{n.checked=!1}),document.querySelectorAll("[type=checkbox]").forEach(n=>{n.checked=!1}),r.paperRotation90&&(document.querySelector("input[name='paper_rotation_90']").checked=!0),r.rotatePage&&(document.querySelector("input[name='rotate_page']").checked=!0),r.cropMarks&&(document.querySelector("input[name='cropmarks']").checked=!0),r.sigOrderMarks&&(document.querySelector("input[name='sig_order_marks']").checked=!0),r.pdfEdgeMarks&&(document.querySelector("input[name='pdf_edge_marks']").checked=!0),r.cutMarks&&(document.querySelector("input[name='cutmarks']").checked=!0),document.querySelector(`input[name="sig_format"][value="${r.sigFormat}"]`).checked=!0,document.querySelector(`input[name="wacky_spacing"][value="${r.wackySpacing}"]`).checked=!0,Nh(r.sewingMarksEnabled),document.querySelector('input[name="add_sewing_marks_checkbox"]').checked=r.sewingMarksEnabled,document.querySelector('select[name="sewing_mark_locations"]').value=r.sewingMarkLocation,document.querySelector('input[name="sewing_marks_margin_pt"]').value=r.sewingMarksMarginPt,document.querySelector('input[name="sewing_marks_amount"]').value=r.sewingMarksAmount,document.querySelector('input[name="sewing_marks_tape_width_pt"]').value=r.sewingMarksTapeWidthPt,document.querySelector('input[name="main_fore_edge_padding_pt"]').value=r.mainForeEdgePaddingPt,document.querySelector('input[name="binding_edge_padding_pt"]').value=r.bindingEdgePaddingPt,document.querySelector('input[name="top_edge_padding_pt"]').value=r.topEdgePaddingPt,document.querySelector('input[name="bottom_edge_padding_pt"]').value=r.bottomEdgePaddingPt,document.querySelector('input[name="fore_edge_padding_pt"]').value=r.foreEdgePaddingPt,document.querySelector('input[name="flyleafs"]').value=r.flyleafs,document.querySelector('select[name="source_rotation"]').value=r.sourceRotation,document.querySelector('select[name="pagelayout"]').value=r.pageLayout,document.querySelector('select[name="page_scaling"]').value=r.pageScaling,document.querySelector('select[name="page_positioning"]').value=r.pagePositioning,document.querySelector('select[name="print_file"]').value=r.printFile,document.querySelector('select[name="paper_size"]').value=r.paperSize,document.querySelector('select[name="paper_size_unit"]').value=r.paperSizeUnit,document.querySelector('select[name="printer_type"]').value=r.printerType,r.paperSize==="CUSTOM"&&r.paperSizeCustomHeight!==void 0&&r.paperSizeCustomWidth!==void 0&&(document.querySelector('input[name="paper_size_custom_height"]').value=r.paperSizeCustomHeight,document.querySelector('input[name="paper_size_custom_width"]').value=r.paperSizeCustomWidth,sl(),xo(),document.querySelector('select[name="paper_size"]').value="CUSTOM"),r.sigFormat=="customsig"?document.querySelector("input[name='custom_sig']").value=r.customSigLength:document.querySelector("input[name='sig_length']").value=r.sigLength;const e=Array.from(document.getElementsByClassName("source_rotation_example")),t=`${r.sourceRotation}_example`;e.forEach(n=>{n.style.display=n.id===t?"block":"none"})}function Ih(){const r=document.getElementById("pdf");r.style.display="none",r.src=""}function da(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Mh={exports:{}};/*! +total: ${a.concat(o)}`),a.concat(o)}}build_2_16s_sheetList(e){const t=this.page,n=this.flipPage,i=[],s=Math.ceil(e/32);console.log(`Building the 32 pages. Given ${e} page count, there will be ${s} sheets...`);for(let a=0;a{const t=s=>e.isPacked?e.gap[1]:e.gap[1]*(2*s),n=s=>e.isPacked?e.gap[0]:s*e.gap[0];let i=[];return[0,1,2,3,4].forEach(s=>{[0,1,2,3,4].forEach(a=>{i=i.concat(this.crosshairMark(n(a)+e.renderPageSize[0]*a,t(s)+e.renderPageSize[1]*s,5))})}),[{...this.foldHorizontal(e.paperSize[0],e.paperSize[1]/2,0),opacity:.4},this.cutVertical(e.paperSize[1],e.paperSize[0]/2),this.cutVertical(e.paperSize[1],e.paperSize[0]-e.gap[0]),this.cutVertical(e.paperSize[1],e.gap[0])].concat(i)}}foldHorizontal(e,t){return{start:{x:0,y:t},end:{x:e,y:t},thickness:.25,opacity:.4,dashArray:[2,5]}}foldVertical(e,t){return{start:{x:t,y:0},end:{x:t,y:e},thickness:.25,opacity:.4,dashArray:[2,5]}}cutHorizontal(e,t){return{start:{x:0,y:t},end:{x:e,y:t},thickness:.5,opacity:.4}}cutVertical(e,t){return{start:{x:t,y:0},end:{x:t,y:e},thickness:.5,opacity:.4}}crosshairMark(e,t,n){return[{start:{x:e-n/2,y:t},end:{x:e+n/2,y:t},thickness:.5,opacity:.4},{start:{x:e,y:t-n/2},end:{x:e,y:t+n/2},thickness:.5,opacity:.4}]}auditForBlanks(e,t){return e.forEach(n=>{n.num>=t&&(n.isBlank=!0,n.num=0)}),e}page(e){return{num:e,isBlank:!1,vFlip:!1}}flipPage(e){return{num:e,isBlank:!1,vFlip:!0}}blankPage(){return{num:0,isBlank:!0,vFlip:!1}}rotate180(e){e.vFlip=!e.vFlip}}function da(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var wh={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files @@ -60,6 +55,11 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(r,e){(function(t){r.exports=t()})(function(){return function t(n,i,s){function a(c,d){if(!i[c]){if(!n[c]){var f=typeof da=="function"&&da;if(!d&&f)return f(c,!0);if(o)return o(c,!0);var h=new Error("Cannot find module '"+c+"'");throw h.code="MODULE_NOT_FOUND",h}var u=i[c]={exports:{}};n[c][0].call(u.exports,function(g){var p=n[c][1][g];return a(p||g)},u,u.exports,t,n,i,s)}return i[c].exports}for(var o=typeof da=="function"&&da,l=0;l>2,u=(3&c)<<4|d>>4,g=1>6:64,p=2>4,d=(15&h)<<4|(u=o.indexOf(l.charAt(p++)))>>2,f=(3&u)<<6|(g=o.indexOf(l.charAt(p++))),v[x++]=c,u!==64&&(v[x++]=d),g!==64&&(v[x++]=f);return v}},{"./support":30,"./utils":32}],2:[function(t,n,i){var s=t("./external"),a=t("./stream/DataWorker"),o=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(d,f,h,u,g){this.compressedSize=d,this.uncompressedSize=f,this.crc32=h,this.compression=u,this.compressedContent=g}c.prototype={getContentWorker:function(){var d=new a(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new a(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(d,f,h){return d.pipe(new o).pipe(new l("uncompressedSize")).pipe(f.compressWorker(h)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},n.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,n,i){var s=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,n,i){var s=t("./utils"),a=function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l}();n.exports=function(o,l){return o!==void 0&&o.length?s.getTypeOf(o)!=="string"?function(c,d,f,h){var u=a,g=h+f;c^=-1;for(var p=h;p>>8^u[255&(c^d[p])];return-1^c}(0|l,o,o.length,0):function(c,d,f,h){var u=a,g=h+f;c^=-1;for(var p=h;p>>8^u[255&(c^d.charCodeAt(p))];return-1^c}(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(t,n,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,n,i){var s=null;s=typeof Promise<"u"?Promise:t("lie"),n.exports={Promise:s}},{lie:37}],7:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=t("pako"),o=t("./utils"),l=t("./stream/GenericWorker"),c=s?"uint8array":"array";function d(f,h){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=h,this.meta={}}i.magic="\b\0",o.inherits(d,l),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(c,f.data),!1)},d.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(h){f.push({data:h,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,n,i){function s(u,g){var p,x="";for(p=0;p>>=8;return x}function a(u,g,p,x,m,v){var w,A,T=u.file,_=u.compression,k=v!==c.utf8encode,C=o.transformTo("string",v(T.name)),S=o.transformTo("string",c.utf8encode(T.name)),O=T.comment,P=o.transformTo("string",v(O)),E=o.transformTo("string",c.utf8encode(O)),R=S.length!==T.name.length,b=E.length!==O.length,N="",V="",q="",ne=T.dir,H=T.date,ie={crc32:0,compressedSize:0,uncompressedSize:0};g&&!p||(ie.crc32=u.crc32,ie.compressedSize=u.compressedSize,ie.uncompressedSize=u.uncompressedSize);var I=0;g&&(I|=8),k||!R&&!b||(I|=2048);var L=0,se=0;ne&&(L|=16),m==="UNIX"?(se=798,L|=function(ee,Ve){var Ke=ee;return ee||(Ke=Ve?16893:33204),(65535&Ke)<<16}(T.unixPermissions,ne)):(se=20,L|=function(ee){return 63&(ee||0)}(T.dosPermissions)),w=H.getUTCHours(),w<<=6,w|=H.getUTCMinutes(),w<<=5,w|=H.getUTCSeconds()/2,A=H.getUTCFullYear()-1980,A<<=4,A|=H.getUTCMonth()+1,A<<=5,A|=H.getUTCDate(),R&&(V=s(1,1)+s(d(C),4)+S,N+="up"+s(V.length,2)+V),b&&(q=s(1,1)+s(d(P),4)+E,N+="uc"+s(q.length,2)+q);var K="";return K+=` -\0`,K+=s(I,2),K+=_.magic,K+=s(w,2),K+=s(A,2),K+=s(ie.crc32,4),K+=s(ie.compressedSize,4),K+=s(ie.uncompressedSize,4),K+=s(C.length,2),K+=s(N.length,2),{fileRecord:f.LOCAL_FILE_HEADER+K+C+N,dirRecord:f.CENTRAL_FILE_HEADER+s(se,2)+K+s(P.length,2)+"\0\0\0\0"+s(L,4)+s(x,4)+C+N+P}}var o=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),d=t("../crc32"),f=t("../signature");function h(u,g,p,x){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=p,this.encodeFileName=x,this.streamFiles=u,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(h,l),h.prototype.push=function(u){var g=u.meta.percent||0,p=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(u):(this.bytesWritten+=u.data.length,l.prototype.push.call(this,{data:u.data,meta:{currentFile:this.currentFile,percent:p?(g+100*(p-x-1))/p:100}}))},h.prototype.openedSource=function(u){this.currentSourceOffset=this.bytesWritten,this.currentFile=u.file.name;var g=this.streamFiles&&!u.file.dir;if(g){var p=a(u,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:p.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(u){this.accumulate=!1;var g=this.streamFiles&&!u.file.dir,p=a(u,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(p.dirRecord),g)this.push({data:function(x){return f.DATA_DESCRIPTOR+s(x.crc32,4)+s(x.compressedSize,4)+s(x.uncompressedSize,4)}(u),meta:{percent:100}});else for(this.push({data:p.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var u=this.bytesWritten,g=0;g=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return s.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},n.exports=a},{"../utils":32}],19:[function(t,n,i){var s=t("./Uint8ArrayReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},n.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){var s=t("./DataReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},n.exports=a},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){var s=t("./ArrayReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},n.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var s=t("../utils"),a=t("../support"),o=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),d=t("./Uint8ArrayReader");n.exports=function(f){var h=s.getTypeOf(f);return s.checkSupport(h),h!=="string"||a.uint8array?h==="nodebuffer"?new c(f):a.uint8array?new d(s.transformTo("uint8array",f)):new o(s.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,n,i){var s=t("./GenericWorker"),a=t("../utils");function o(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,s),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},n.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){var s=t("./GenericWorker"),a=t("../crc32");function o(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(o,s),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},n.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,n,i){var s=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(o,a),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},n.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){var s=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(d){c.dataIsReady=!0,c.data=d,c.max=d&&d.length||0,c.type=s.getTypeOf(d),c.isPaused||c._tickAndRepeat()},function(d){c.error(d)})}s.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(t,n,i){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l "+a:a}},n.exports=s},{}],29:[function(t,n,i){var s=t("../utils"),a=t("./ConvertWorker"),o=t("./GenericWorker"),l=t("../base64"),c=t("../support"),d=t("../external"),f=null;if(c.nodestream)try{f=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(g,p){return new d.Promise(function(x,m){var v=[],w=g._internalType,A=g._outputType,T=g._mimeType;g.on("data",function(_,k){v.push(_),p&&p(k)}).on("error",function(_){v=[],m(_)}).on("end",function(){try{var _=function(k,C,S){switch(k){case"blob":return s.newBlob(s.transformTo("arraybuffer",C),S);case"base64":return l.encode(C);default:return s.transformTo(k,C)}}(A,function(k,C){var S,O=0,P=null,E=0;for(S=0;S"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),i.blob=a.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,n,i){for(var s=t("./utils"),a=t("./support"),o=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),d=0;d<256;d++)c[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;c[254]=c[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function h(){l.call(this,"utf-8 encode")}i.utf8encode=function(u){return a.nodebuffer?o.newBufferFrom(u,"utf-8"):function(g){var p,x,m,v,w,A=g.length,T=0;for(v=0;v>>6:(x<65536?p[w++]=224|x>>>12:(p[w++]=240|x>>>18,p[w++]=128|x>>>12&63),p[w++]=128|x>>>6&63),p[w++]=128|63&x);return p}(u)},i.utf8decode=function(u){return a.nodebuffer?s.transformTo("nodebuffer",u).toString("utf-8"):function(g){var p,x,m,v,w=g.length,A=new Array(2*w);for(p=x=0;p>10&1023,A[x++]=56320|1023&m)}return A.length!==x&&(A.subarray?A=A.subarray(0,x):A.length=x),s.applyFromCharCode(A)}(u=s.transformTo(a.uint8array?"uint8array":"array",u))},s.inherits(f,l),f.prototype.processChunk=function(u){var g=s.transformTo(a.uint8array?"uint8array":"array",u.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var p=g;(g=new Uint8Array(p.length+this.leftOver.length)).set(this.leftOver,0),g.set(p,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var x=function(v,w){var A;for((w=w||v.length)>v.length&&(w=v.length),A=w-1;0<=A&&(192&v[A])==128;)A--;return A<0||A===0?w:A+c[v[A]]>w?A:w}(g),m=g;x!==g.length&&(a.uint8array?(m=g.subarray(0,x),this.leftOver=g.subarray(x,g.length)):(m=g.slice(0,x),this.leftOver=g.slice(x,g.length))),this.push({data:i.utf8decode(m),meta:u.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,s.inherits(h,l),h.prototype.processChunk=function(u){this.push({data:i.utf8encode(u.data),meta:u.meta})},i.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var s=t("./support"),a=t("./base64"),o=t("./nodejsUtils"),l=t("./external");function c(p){return p}function d(p,x){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),u==0&&(this.dosPermissions=63&this.externalFileAttributes),u==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var u=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=u.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=u.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=u.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=u.readInt(4))}},readExtraFields:function(u){var g,p,x,m=u.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});u.index+4>>6:(u<65536?h[x++]=224|u>>>12:(h[x++]=240|u>>>18,h[x++]=128|u>>>12&63),h[x++]=128|u>>>6&63),h[x++]=128|63&u);return h},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var h=new s.Buf8(f.length),u=0,g=h.length;u>10&1023,v[g++]=56320|1023&p)}return d(v,g)},i.utf8border=function(f,h){var u;for((h=h||f.length)>f.length&&(h=f.length),u=h-1;0<=u&&(192&f[u])==128;)u--;return u<0||u===0?h:u+l[f[u]]>h?u:h}},{"./common":41}],43:[function(t,n,i){n.exports=function(s,a,o,l){for(var c=65535&s|0,d=s>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3>>1:a>>>1;o[l]=a}return o}();n.exports=function(a,o,l,c){var d=s,f=c+l;a^=-1;for(var h=c;h>>8^d[255&(a^o[h])];return-1^a}},{}],46:[function(t,n,i){var s,a=t("../utils/common"),o=t("./trees"),l=t("./adler32"),c=t("./crc32"),d=t("./messages"),f=0,h=4,u=0,g=-2,p=-1,x=4,m=2,v=8,w=9,A=286,T=30,_=19,k=2*A+1,C=15,S=3,O=258,P=O+S+1,E=42,R=113,b=1,N=2,V=3,q=4;function ne(y,G){return y.msg=d[G],G}function H(y){return(y<<1)-(4y.avail_out&&(W=y.avail_out),W!==0&&(a.arraySet(y.output,G.pending_buf,G.pending_out,W,y.next_out),y.next_out+=W,G.pending_out+=W,y.total_out+=W,y.avail_out-=W,G.pending-=W,G.pending===0&&(G.pending_out=0))}function L(y,G){o._tr_flush_block(y,0<=y.block_start?y.block_start:-1,y.strstart-y.block_start,G),y.block_start=y.strstart,I(y.strm)}function se(y,G){y.pending_buf[y.pending++]=G}function K(y,G){y.pending_buf[y.pending++]=G>>>8&255,y.pending_buf[y.pending++]=255&G}function ee(y,G){var W,B,z=y.max_chain_length,M=y.strstart,X=y.prev_length,J=y.nice_match,j=y.strstart>y.w_size-P?y.strstart-(y.w_size-P):0,te=y.window,ce=y.w_mask,re=y.prev,be=y.strstart+O,He=te[M+X-1],De=te[M+X];y.prev_length>=y.good_match&&(z>>=2),J>y.lookahead&&(J=y.lookahead);do if(te[(W=G)+X]===De&&te[W+X-1]===He&&te[W]===te[M]&&te[++W]===te[M+1]){M+=2,W++;do;while(te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&Mj&&--z!=0);return X<=y.lookahead?X:y.lookahead}function Ve(y){var G,W,B,z,M,X,J,j,te,ce,re=y.w_size;do{if(z=y.window_size-y.lookahead-y.strstart,y.strstart>=re+(re-P)){for(a.arraySet(y.window,y.window,re,re,0),y.match_start-=re,y.strstart-=re,y.block_start-=re,G=W=y.hash_size;B=y.head[--G],y.head[G]=re<=B?B-re:0,--W;);for(G=W=re;B=y.prev[--G],y.prev[G]=re<=B?B-re:0,--W;);z+=re}if(y.strm.avail_in===0)break;if(X=y.strm,J=y.window,j=y.strstart+y.lookahead,te=z,ce=void 0,ce=X.avail_in,te=S)for(M=y.strstart-y.insert,y.ins_h=y.window[M],y.ins_h=(y.ins_h<=S&&(y.ins_h=(y.ins_h<=S)if(B=o._tr_tally(y,y.strstart-y.match_start,y.match_length-S),y.lookahead-=y.match_length,y.match_length<=y.max_lazy_match&&y.lookahead>=S){for(y.match_length--;y.strstart++,y.ins_h=(y.ins_h<=S&&(y.ins_h=(y.ins_h<=S&&y.match_length<=y.prev_length){for(z=y.strstart+y.lookahead-S,B=o._tr_tally(y,y.strstart-1-y.prev_match,y.prev_length-S),y.lookahead-=y.prev_length-1,y.prev_length-=2;++y.strstart<=z&&(y.ins_h=(y.ins_h<y.pending_buf_size-5&&(W=y.pending_buf_size-5);;){if(y.lookahead<=1){if(Ve(y),y.lookahead===0&&G===f)return b;if(y.lookahead===0)break}y.strstart+=y.lookahead,y.lookahead=0;var B=y.block_start+W;if((y.strstart===0||y.strstart>=B)&&(y.lookahead=y.strstart-B,y.strstart=B,L(y,!1),y.strm.avail_out===0)||y.strstart-y.block_start>=y.w_size-P&&(L(y,!1),y.strm.avail_out===0))return b}return y.insert=0,G===h?(L(y,!0),y.strm.avail_out===0?V:q):(y.strstart>y.block_start&&(L(y,!1),y.strm.avail_out),b)}),new Oe(4,4,8,4,Ke),new Oe(4,5,16,8,Ke),new Oe(4,6,32,32,Ke),new Oe(4,4,16,16,de),new Oe(8,16,32,32,de),new Oe(8,16,128,128,de),new Oe(8,32,128,256,de),new Oe(32,128,258,1024,de),new Oe(32,258,258,4096,de)],i.deflateInit=function(y,G){return Ht(y,G,v,15,8,0)},i.deflateInit2=Ht,i.deflateReset=nr,i.deflateResetKeep=$e,i.deflateSetHeader=function(y,G){return y&&y.state?y.state.wrap!==2?g:(y.state.gzhead=G,u):g},i.deflate=function(y,G){var W,B,z,M;if(!y||!y.state||5>8&255),se(B,B.gzhead.time>>16&255),se(B,B.gzhead.time>>24&255),se(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),se(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(se(B,255&B.gzhead.extra.length),se(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(y.adler=c(y.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(se(B,0),se(B,0),se(B,0),se(B,0),se(B,0),se(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),se(B,3),B.status=R);else{var X=v+(B.w_bits-8<<4)<<8;X|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(X|=32),X+=31-X%31,B.status=R,K(B,X),B.strstart!==0&&(K(B,y.adler>>>16),K(B,65535&y.adler)),y.adler=1}if(B.status===69)if(B.gzhead.extra){for(z=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>z&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),I(y),z=B.pending,B.pending!==B.pending_buf_size));)se(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>z&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){z=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>z&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),I(y),z=B.pending,B.pending===B.pending_buf_size)){M=1;break}M=B.gzindexz&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),M===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){z=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>z&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),I(y),z=B.pending,B.pending===B.pending_buf_size)){M=1;break}M=B.gzindexz&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),M===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&I(y),B.pending+2<=B.pending_buf_size&&(se(B,255&y.adler),se(B,y.adler>>8&255),y.adler=0,B.status=R)):B.status=R),B.pending!==0){if(I(y),y.avail_out===0)return B.last_flush=-1,u}else if(y.avail_in===0&&H(G)<=H(W)&&G!==h)return ne(y,-5);if(B.status===666&&y.avail_in!==0)return ne(y,-5);if(y.avail_in!==0||B.lookahead!==0||G!==f&&B.status!==666){var J=B.strategy===2?function(j,te){for(var ce;;){if(j.lookahead===0&&(Ve(j),j.lookahead===0)){if(te===f)return b;break}if(j.match_length=0,ce=o._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++,ce&&(L(j,!1),j.strm.avail_out===0))return b}return j.insert=0,te===h?(L(j,!0),j.strm.avail_out===0?V:q):j.last_lit&&(L(j,!1),j.strm.avail_out===0)?b:N}(B,G):B.strategy===3?function(j,te){for(var ce,re,be,He,De=j.window;;){if(j.lookahead<=O){if(Ve(j),j.lookahead<=O&&te===f)return b;if(j.lookahead===0)break}if(j.match_length=0,j.lookahead>=S&&0j.lookahead&&(j.match_length=j.lookahead)}if(j.match_length>=S?(ce=o._tr_tally(j,1,j.match_length-S),j.lookahead-=j.match_length,j.strstart+=j.match_length,j.match_length=0):(ce=o._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++),ce&&(L(j,!1),j.strm.avail_out===0))return b}return j.insert=0,te===h?(L(j,!0),j.strm.avail_out===0?V:q):j.last_lit&&(L(j,!1),j.strm.avail_out===0)?b:N}(B,G):s[B.level].func(B,G);if(J!==V&&J!==q||(B.status=666),J===b||J===V)return y.avail_out===0&&(B.last_flush=-1),u;if(J===N&&(G===1?o._tr_align(B):G!==5&&(o._tr_stored_block(B,0,0,!1),G===3&&(ie(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),I(y),y.avail_out===0))return B.last_flush=-1,u}return G!==h?u:B.wrap<=0?1:(B.wrap===2?(se(B,255&y.adler),se(B,y.adler>>8&255),se(B,y.adler>>16&255),se(B,y.adler>>24&255),se(B,255&y.total_in),se(B,y.total_in>>8&255),se(B,y.total_in>>16&255),se(B,y.total_in>>24&255)):(K(B,y.adler>>>16),K(B,65535&y.adler)),I(y),0=W.w_size&&(M===0&&(ie(W.head),W.strstart=0,W.block_start=0,W.insert=0),te=new a.Buf8(W.w_size),a.arraySet(te,G,ce-W.w_size,W.w_size,0),G=te,ce=W.w_size),X=y.avail_in,J=y.next_in,j=y.input,y.avail_in=ce,y.next_in=0,y.input=G,Ve(W);W.lookahead>=S;){for(B=W.strstart,z=W.lookahead-(S-1);W.ins_h=(W.ins_h<>>=S=C>>>24,w-=S,(S=C>>>16&255)===0)N[d++]=65535&C;else{if(!(16&S)){if(!(64&S)){C=A[(65535&C)+(v&(1<>>=S,w-=S),w<15&&(v+=b[l++]<>>=S=C>>>24,w-=S,!(16&(S=C>>>16&255))){if(!(64&S)){C=T[(65535&C)+(v&(1<>>=S,w-=S,(S=d-f)>3,v&=(1<<(w-=O<<3))-1,s.next_in=l,s.next_out=d,s.avail_in=l>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(E){var R;return E&&E.state?(R=E.state,E.total_in=E.total_out=R.total=0,E.msg="",R.wrap&&(E.adler=1&R.wrap),R.mode=g,R.last=0,R.havedict=0,R.dmax=32768,R.head=null,R.hold=0,R.bits=0,R.lencode=R.lendyn=new s.Buf32(p),R.distcode=R.distdyn=new s.Buf32(x),R.sane=1,R.back=-1,h):u}function A(E){var R;return E&&E.state?((R=E.state).wsize=0,R.whave=0,R.wnext=0,w(E)):u}function T(E,R){var b,N;return E&&E.state?(N=E.state,R<0?(b=0,R=-R):(b=1+(R>>4),R<48&&(R&=15)),R&&(R<8||15=q.wsize?(s.arraySet(q.window,R,b-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(N<(V=q.wsize-q.wnext)&&(V=N),s.arraySet(q.window,R,b-N,V,q.wnext),(N-=V)?(s.arraySet(q.window,R,b-N,N,0),q.wnext=N,q.whave=q.wsize):(q.wnext+=V,q.wnext===q.wsize&&(q.wnext=0),q.whave>>8&255,b.check=o(b.check,M,2,0),L=I=0,b.mode=2;break}if(b.flags=0,b.head&&(b.head.done=!1),!(1&b.wrap)||(((255&I)<<8)+(I>>8))%31){E.msg="incorrect header check",b.mode=30;break}if((15&I)!=8){E.msg="unknown compression method",b.mode=30;break}if(L-=4,y=8+(15&(I>>>=4)),b.wbits===0)b.wbits=y;else if(y>b.wbits){E.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(M[0]=255&I,M[1]=I>>>8&255,b.check=o(b.check,M,2,0)),L=I=0,b.mode=3;case 3:for(;L<32;){if(H===0)break e;H--,I+=N[q++]<>>8&255,M[2]=I>>>16&255,M[3]=I>>>24&255,b.check=o(b.check,M,4,0)),L=I=0,b.mode=4;case 4:for(;L<16;){if(H===0)break e;H--,I+=N[q++]<>8),512&b.flags&&(M[0]=255&I,M[1]=I>>>8&255,b.check=o(b.check,M,2,0)),L=I=0,b.mode=5;case 5:if(1024&b.flags){for(;L<16;){if(H===0)break e;H--,I+=N[q++]<>>8&255,b.check=o(b.check,M,2,0)),L=I=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(H<(ee=b.length)&&(ee=H),ee&&(b.head&&(y=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,N,q,ee,y)),512&b.flags&&(b.check=o(b.check,N,ee,q)),H-=ee,q+=ee,b.length-=ee),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(H===0)break e;for(ee=0;y=N[q+ee++],b.head&&y&&b.length<65536&&(b.head.name+=String.fromCharCode(y)),y&&ee>9&1,b.head.done=!0),E.adler=b.check=0,b.mode=12;break;case 10:for(;L<32;){if(H===0)break e;H--,I+=N[q++]<>>=7&L,L-=7&L,b.mode=27;break}for(;L<3;){if(H===0)break e;H--,I+=N[q++]<>>=1)){case 0:b.mode=14;break;case 1:if(O(b),b.mode=20,R!==6)break;I>>>=2,L-=2;break e;case 2:b.mode=17;break;case 3:E.msg="invalid block type",b.mode=30}I>>>=2,L-=2;break;case 14:for(I>>>=7&L,L-=7&L;L<32;){if(H===0)break e;H--,I+=N[q++]<>>16^65535)){E.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&I,L=I=0,b.mode=15,R===6)break e;case 15:b.mode=16;case 16:if(ee=b.length){if(H>>=5,L-=5,b.ndist=1+(31&I),I>>>=5,L-=5,b.ncode=4+(15&I),I>>>=4,L-=4,286>>=3,L-=3}for(;b.have<19;)b.lens[X[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,W={bits:b.lenbits},G=c(0,b.lens,0,19,b.lencode,0,b.work,W),b.lenbits=W.bits,G){E.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,Je=65535&z,!((de=z>>>24)<=L);){if(H===0)break e;H--,I+=N[q++]<>>=de,L-=de,b.lens[b.have++]=Je;else{if(Je===16){for(B=de+2;L>>=de,L-=de,b.have===0){E.msg="invalid bit length repeat",b.mode=30;break}y=b.lens[b.have-1],ee=3+(3&I),I>>>=2,L-=2}else if(Je===17){for(B=de+3;L>>=de)),I>>>=3,L-=3}else{for(B=de+7;L>>=de)),I>>>=7,L-=7}if(b.have+ee>b.nlen+b.ndist){E.msg="invalid bit length repeat",b.mode=30;break}for(;ee--;)b.lens[b.have++]=y}}if(b.mode===30)break;if(b.lens[256]===0){E.msg="invalid code -- missing end-of-block",b.mode=30;break}if(b.lenbits=9,W={bits:b.lenbits},G=c(d,b.lens,0,b.nlen,b.lencode,0,b.work,W),b.lenbits=W.bits,G){E.msg="invalid literal/lengths set",b.mode=30;break}if(b.distbits=6,b.distcode=b.distdyn,W={bits:b.distbits},G=c(f,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,W),b.distbits=W.bits,G){E.msg="invalid distances set",b.mode=30;break}if(b.mode=20,R===6)break e;case 20:b.mode=21;case 21:if(6<=H&&258<=ie){E.next_out=ne,E.avail_out=ie,E.next_in=q,E.avail_in=H,b.hold=I,b.bits=L,l(E,K),ne=E.next_out,V=E.output,ie=E.avail_out,q=E.next_in,N=E.input,H=E.avail_in,I=b.hold,L=b.bits,b.mode===12&&(b.back=-1);break}for(b.back=0;Oe=(z=b.lencode[I&(1<>>16&255,Je=65535&z,!((de=z>>>24)<=L);){if(H===0)break e;H--,I+=N[q++]<>$e)])>>>16&255,Je=65535&z,!($e+(de=z>>>24)<=L);){if(H===0)break e;H--,I+=N[q++]<>>=$e,L-=$e,b.back+=$e}if(I>>>=de,L-=de,b.back+=de,b.length=Je,Oe===0){b.mode=26;break}if(32&Oe){b.back=-1,b.mode=12;break}if(64&Oe){E.msg="invalid literal/length code",b.mode=30;break}b.extra=15&Oe,b.mode=22;case 22:if(b.extra){for(B=b.extra;L>>=b.extra,L-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=23;case 23:for(;Oe=(z=b.distcode[I&(1<>>16&255,Je=65535&z,!((de=z>>>24)<=L);){if(H===0)break e;H--,I+=N[q++]<>$e)])>>>16&255,Je=65535&z,!($e+(de=z>>>24)<=L);){if(H===0)break e;H--,I+=N[q++]<>>=$e,L-=$e,b.back+=$e}if(I>>>=de,L-=de,b.back+=de,64&Oe){E.msg="invalid distance code",b.mode=30;break}b.offset=Je,b.extra=15&Oe,b.mode=24;case 24:if(b.extra){for(B=b.extra;L>>=b.extra,L-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){E.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(ie===0)break e;if(ee=K-ie,b.offset>ee){if((ee=b.offset-ee)>b.whave&&b.sane){E.msg="invalid distance too far back",b.mode=30;break}Ve=ee>b.wnext?(ee-=b.wnext,b.wsize-ee):b.wnext-ee,ee>b.length&&(ee=b.length),Ke=b.window}else Ke=V,Ve=ne-b.offset,ee=b.length;for(iek?(S=Ve[Ke+x[R]],L[se+x[R]]):(S=96,0),v=1<>ne)+(w-=v)]=C<<24|S<<16|O|0,w!==0;);for(v=1<>=1;if(v!==0?(I&=v-1,I+=v):I=0,R++,--K[E]==0){if(E===N)break;E=f[h+x[R]]}if(V>>7)]}function se(z,M){z.pending_buf[z.pending++]=255&M,z.pending_buf[z.pending++]=M>>>8&255}function K(z,M,X){z.bi_valid>m-X?(z.bi_buf|=M<>m-z.bi_valid,z.bi_valid+=X-m):(z.bi_buf|=M<>>=1,X<<=1,0<--M;);return X>>>1}function Ke(z,M,X){var J,j,te=new Array(x+1),ce=0;for(J=1;J<=x;J++)te[J]=ce=ce+X[J-1]<<1;for(j=0;j<=M;j++){var re=z[2*j+1];re!==0&&(z[2*j]=Ve(te[re]++,re))}}function de(z){var M;for(M=0;M>1;1<=X;X--)$e(z,te,X);for(j=be;X=z.heap[1],z.heap[1]=z.heap[z.heap_len--],$e(z,te,1),J=z.heap[1],z.heap[--z.heap_max]=X,z.heap[--z.heap_max]=J,te[2*j]=te[2*X]+te[2*J],z.depth[j]=(z.depth[X]>=z.depth[J]?z.depth[X]:z.depth[J])+1,te[2*X+1]=te[2*J+1]=j,z.heap[1]=j++,$e(z,te,1),2<=z.heap_len;);z.heap[--z.heap_max]=z.heap[1],function(De,Bt){var Ei,ir,Ti,et,Gs,bo,mr=Bt.dyn_tree,al=Bt.max_code,Uh=Bt.stat_desc.static_tree,qh=Bt.stat_desc.has_stree,jh=Bt.stat_desc.extra_bits,ol=Bt.stat_desc.extra_base,_i=Bt.stat_desc.max_length,Zs=0;for(et=0;et<=x;et++)De.bl_count[et]=0;for(mr[2*De.heap[De.heap_max]+1]=0,Ei=De.heap_max+1;Ei>=7;j>>=1)if(1&He&&re.dyn_ltree[2*be]!==0)return a;if(re.dyn_ltree[18]!==0||re.dyn_ltree[20]!==0||re.dyn_ltree[26]!==0)return o;for(be=32;be>>3,(te=z.static_len+3+7>>>3)<=j&&(j=te)):j=te=X+5,X+4<=j&&M!==-1?B(z,M,X,J):z.strategy===4||te===j?(K(z,2+(J?1:0),3),nr(z,P,E)):(K(z,4+(J?1:0),3),function(re,be,He,De){var Bt;for(K(re,be-257,5),K(re,He-1,5),K(re,De-4,4),Bt=0;Bt>>8&255,z.pending_buf[z.d_buf+2*z.last_lit+1]=255&M,z.pending_buf[z.l_buf+z.last_lit]=255&X,z.last_lit++,M===0?z.dyn_ltree[2*X]++:(z.matches++,M--,z.dyn_ltree[2*(b[X]+f+1)]++,z.dyn_dtree[2*L(M)]++),z.last_lit===z.lit_bufsize-1},i._tr_align=function(z){K(z,2,3),ee(z,w,P),function(M){M.bi_valid===16?(se(M,M.bi_buf),M.bi_buf=0,M.bi_valid=0):8<=M.bi_valid&&(M.pending_buf[M.pending++]=255&M.bi_buf,M.bi_buf>>=8,M.bi_valid-=8)}(z)}},{"../utils/common":41}],53:[function(t,n,i){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,n,i){(function(s){(function(a,o){if(!a.setImmediate){var l,c,d,f,h=1,u={},g=!1,p=a.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(a);x=x&&x.setTimeout?x:a,l={}.toString.call(a.process)==="[object process]"?function(A){process.nextTick(function(){v(A)})}:function(){if(a.postMessage&&!a.importScripts){var A=!0,T=a.onmessage;return a.onmessage=function(){A=!1},a.postMessage("","*"),a.onmessage=T,A}}()?(f="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",w,!1):a.attachEvent("onmessage",w),function(A){a.postMessage(f+A,"*")}):a.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){v(A.data)},function(A){d.port2.postMessage(A)}):p&&"onreadystatechange"in p.createElement("script")?(c=p.documentElement,function(A){var T=p.createElement("script");T.onreadystatechange=function(){v(A),T.onreadystatechange=null,c.removeChild(T),T=null},c.appendChild(T)}):function(A){setTimeout(v,0,A)},x.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var T=new Array(arguments.length-1),_=0;_"u"?s===void 0?this:s:self)}).call(this,typeof _t<"u"?_t:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Mh);var Q1=Mh.exports;const $1=vc(Q1);function eb(r,e,t,n){const i={opacity:.4,dashArray:[1,5]};let s,a,o,l,c,d;const[f,h]=t,u=[];switch(n){case 32:r&&(i.dashArray=[1,5],s=e?f*.75:f*.25,c=h*.5,d=e?h*.75:h*.25,u.push({...Td(s,c,d),...i}));case 16:r&&(i.dashArray=[3,5],l=e?h*.75:h*.25,a=f*.5,o=e?0:h,u.push({..._d(l,a,o),...i}));case 8:r&&(i.dashArray=[5,5],s=f*.5,c=h*.5,d=e?0:h,u.push({...Td(s,c,d),...i}));case 4:r||(i.dashArray=[10,5],u.push({..._d(h*.5,0,f),...i}));break}return u}function tb(r,e){let t=[];const[n,i]=r;switch(e){case 32:t=[...t,...Mo(i*.75,0,n),...Mo(i*.25,0,n),...Lo(n*.5,i*.75),...Lo(n*.5,i*.25)];case 16:t=[...t,...ib(n*.5,0,i),...Lo(n*.5,i*.5)];case 8:t=[...t,...Mo(i*.5,0,n)]}return t}function rb(r,e,t,n,i,s){if(console.log("try to draw"),e.isLeftPage)return[];if(console.log(" on right"),t=="only_out"&&!r.isSigStart)return[];if(console.log(" a"),t=="only_in"&&!r.isSigMiddle)return[];if(console.log(" b"),t=="in_n_out"&&!(r.isSigStart||r.isSigMiddle))return[];console.log(" c");var a=Math.abs(e.rotation)===90;let o=0,l=0;a?(o=Math.abs(e.spineMarkTop[0]-e.spineMarkBottom[0]),l=e.spineMarkTop[1]):(o=Math.abs(e.spineMarkTop[1]-e.spineMarkBottom[1]),l=e.spineMarkTop[0]);const d=(o-2*i)/(n+1),f=[];for(let p=1;p<=n;p++){const x=s/2;f.push({pointHeight:i+d*p+x},{pointHeight:i+d*p-x})}const h=[{pointHeight:i},{pointHeight:o-i},...f],u={size:1,color:Zc(0)};return h.map(p=>(p={...p,...u},a?(p.y=l,p.x=p.pointHeight+e.spineMarkBottom[0]):(p.y=p.pointHeight+e.spineMarkBottom[1],p.x=l),p))}function Ja(r,e,t){let n,i,s,a;r?([n,i]=e.spineMarkTop,[s,a]=e.spineMarkTop):([n,i]=e.spineMarkBottom,[s,a]=e.spineMarkBottom),e.rotation==0||e.rotation==180?(n-=t/2,s+=t/2):(i-=t/2,a+=t/2);const o={start:{x:n,y:i},end:{x:s,y:a},thickness:e.rotation==0?.5:.25,color:Me(0,0,0),opacity:1};return console.log(" --> draw this: ",o),o}function nb(r,e,t,n,i){const s=Ja(!0,e,n),a=Ja(!1,e,n);let o=s.start.x,l=s.start.y;const c=e.rotation==0?s.start.y-a.start.y:s.start.x-a.start.x;let d=Math.min(i,c/t);const f=d*r.signatureNum;if(e.rotation==0)d=d*-1,l-=f;else{const h=d;d=n,n=h*-1,o-=f}return{x:o,y:l,width:n,height:d,borderWidth:0,color:Me(0,0,0),opacity:.5}}function Td(r,e,t){return{start:{x:r,y:e},end:{x:r,y:t}}}function _d(r,e,t){return{start:{x:e,y:r},end:{x:t,y:r}}}function ib(r,e,t){return[{start:{x:r,y:e},end:{x:r,y:e+Ur},opacity:.4},{start:{x:r,y:t-Ur},end:{x:r,y:t},opacity:.4}]}function Mo(r,e,t){return[{start:{x:e,y:r},end:{x:e+Ur,y:r},opacity:.4},{start:{x:t-Ur,y:r},end:{x:t,y:r},opacity:.4}]}function Lo(r,e){return[{start:{x:r-Ur,y:e},end:{x:r+Ur,y:e},opacity:.4},{start:{x:r,y:e-Ur},end:{x:r,y:e+Ur},opacity:.4}]}function Od(r){const e=Lh(r),{layoutCell:t,xForeEdgeShiftFunc:n,xBindingShiftFunc:i,yTopShiftFunc:s,yBottomShiftFunc:a,pdfScale:o}=e,[l,c]=t,d=[];return e.layout.rotations.forEach((f,h)=>{f.forEach((u,g)=>{const p=n(),x=i(),m=s(),v=a();let w=g%2==0,A=g*l+(w?p:x),T=h*c+v,_=[g*l,(h+1)*c-m],k=[(g+1)*l,h*c+v];u==-180?(w=g%2==1,T=(h+1)*c-v,A=(g+1)*l-(w?p:x),_=[(g+1)*l,(h+1)*c],k=[(g+1)*l,h*c]):u==90?(w=h%2==0,A=(1+g)*c-v,T=h*l+(w?x:p),_=[(1+g)*c,h*l],k=[g*c,h*l]):u==-90&&(w=h%2==1,A=g*c+v,T=(1+h)*l-(w?p:x),_=[(g+1)*c-m,(w?h:h+1)*l],k=[g*c+v,(w?h:h+1)*l]),console.log(`>> (${h},${g})[${u}] : [${A},${T}] :: [xForeEdgeShift: ${p}][xBindingShift: ${x}]`),d.push({rotation:u,sx:o[0],sy:o[1],x:A,y:T,spineMarkTop:_,spineMarkBottom:k,isLeftPage:w})})}),console.log("And in the end of it all, (calculatelayout) we get: ",d),d}function Lh(r){const{cropbox:e,padding_pt:t,papersize:n,page_layout:i,page_positioning:s,page_scaling:a}=r,{width:o,height:l}=e,c=o+Math.max(t.binding,0)+Math.max(t.fore_edge,0),d=l+Math.max(t.top,0)+Math.max(t.bottom,0);let f=n[0]/i.cols,h=n[1]/i.rows;if(i.landscape){const k=f;f=h,h=k}let u=1,g=1;if(a=="lockratio"){const k=Math.min(f/c,h/d);u=k,g=k}else a=="stretch"&&(u=f/c,g=h/d);const p={fore_edge:t.fore_edge*u,binding:t.binding*u,bottom:t.bottom*g,top:t.top*g},x=s;return{layout:i,rawPdfSize:[o,l],pdfScale:[u,g],pdfSize:[c,d],layoutCell:[f,h],padding:p,xForeEdgeShiftFunc:function(){const k=f-c*u;return p.fore_edge+(x=="centered"?k/2:k)},xBindingShiftFunc:function(){const k=f-c*u;return p.binding+(x=="centered"?k/2:0)},xPdfWidthFunc:function(){return c*u-p.fore_edge-p.binding},yPdfHeightFunc:function(){return d*g-p.top-p.bottom},yTopShiftFunc:function(){const k=h-d*g;return p.top+k/2},yBottomShiftFunc:function(){const k=h-d*g;return p.bottom+k/2},positioning:x}}async function sb(r,e){const t=await Ze.create(),n=Math.max(r.getPageCount(),e.getPageCount()),i=[],s=t.copyPages(r,r.getPageIndices()),a=t.copyPages(e,e.getPageIndices());i.push(s,a);const[o,l]=await Promise.all([s,a]);for(let c=0;ctypeof s=="number");let i=await t.embedPdf(r,e);return n&&(i=i.reduce((s,a,o)=>(s[e[o]]=a,s),[])),[t,i]}class ab{constructor(e){this.inputpdf=null,this.managedDoc=null,this.signatureconfig=[],this.spineoffset=!1,this.input=null,this.currentdoc=null,this.pagecount=null,this.cropbox=null,this.orderedpages=[],this.rearrangedpages=[],this.filelist=[],this.zip=null,this.update(e)}update(e){this.duplex=e.printerType==="duplex",this.duplexrotate=e.rotatePage,this.paper_rotation_90=e.paperRotation90,this.papersize=gi[e.paperSize],e.paperRotation90&&(this.papersize=[this.papersize[1],this.papersize[0]]),this.source_rotation=e.sourceRotation,this.print_file=e.printFile,this.page_scaling=e.pageScaling,this.page_positioning=e.pagePositioning,this.flyleafs=e.flyleafs,this.cropmarks=e.cropMarks,this.sewingMarks={sewingMarkLocation:e.sewingMarkLocation,isEnabled:e.sewingMarksEnabled,amount:e.sewingMarksAmount,marginPt:e.sewingMarksMarginPt,tapeWidthPt:e.sewingMarksTapeWidthPt},this.pdfEdgeMarks=e.pdfEdgeMarks,this.sigOrderMarks=e.sigOrderMarks,this.cutmarks=e.cutMarks,this.format=e.sigFormat,e.sigFormat==="standardsig"&&(this.sigsize=e.sigLength),this.customsig=this.format==="customsig",this.customsig&&(this.signatureconfig=e.customSigLength);const t=vx[e.pageLayout];this.page_layout=t,this.per_sheet=t.per_sheet,this.pack_pages=e.wackySpacing==="wacky_pack",this.fore_edge_padding_pt=e.foreEdgePaddingPt,this.padding_pt={top:e.topEdgePaddingPt,bottom:e.bottomEdgePaddingPt,binding:e.bindingEdgePaddingPt,fore_edge:e.mainForeEdgePaddingPt}}async openpdf(e){this.inputpdf=e.name,this.input=await e.arrayBuffer(),this.currentdoc=await Ze.load(this.input),this.fixBlankPages()}fixBlankPages(){const e=this.currentdoc.getPages();this.cropbox=null,e.forEach(t=>{t.node.Contents()?this.cropbox||(this.cropbox=t.getCropBox()):t.drawLine({start:{x:25,y:26},end:{x:125,y:126},opacity:0})})}createpagelist(){this.pagecount=this.currentdoc.getPageCount(),this.orderedpages=Array.from({length:this.pagecount},(n,i)=>i);for(let n=0;n0){t+=1;const n=t*this.per_sheet-e;for(let i=0;i{const a=n.map(async(o,l)=>{console.log(o),t[l]={name:`${this.filename}_signature${l}`},[t[l].front,t[l].back]=await this.createSignatures({pageIndexDetails:o})});await Promise.all(a)})(),(this.duplex||e)&&(await(async()=>{const o=t.map(async(l,c)=>{t[c].duplex=await sb(l.front,l.back),t[c].back=t[c].front=null});await Promise.all(o)})(),i=t[0].duplex),i}async saveClassicFiles(e){this.print_file!="aggregated"&&await(async()=>{const n=e.map(async i=>{var s,a,o;await((s=i.front)==null?void 0:s.save().then(l=>{this.zip.file(`signatures/${i.name}_side1.pdf`,l)})),await((a=i.back)==null?void 0:a.save().then(l=>{this.zip.file(`signatures/${i.name}_side2.pdf`,l)})),await((o=i.duplex)==null?void 0:o.save().then(l=>{this.zip.file(`signatures/${i.name}_duplex.pdf`,l)}))});await Promise.all(n)})(),this.print_file!="signatures"&&await(async()=>{const n={front:this.duplex?null:await Ze.create(),back:this.duplex?null:await Ze.create(),duplex:this.duplex?await Ze.create():null};for(const i of e)n.front&&(await n.front.copyPages(i.front,i.front.getPageIndices())).forEach(a=>n.front.addPage(a)),n.back&&(await n.back.copyPages(i.back,i.back.getPageIndices())).forEach(a=>n.back.addPage(a)),n.duplex&&(await n.duplex.copyPages(i.duplex,i.duplex.getPageIndices())).forEach(a=>n.duplex.addPage(a));n.front&&await n.front.save().then(i=>{this.zip.file(`${this.filename}_typeset_side1.pdf`,i)}),n.back&&await n.back.save().then(i=>{this.zip.file(`${this.filename}_typeset_side2.pdf`,i)}),n.duplex&&await n.duplex.save().then(i=>{this.zip.file(`${this.filename}_typeset.pdf`,i)})})()}async displayPreview(e){console.log("Attempting to generate preview for ",e);const t=document.getElementById("pdf"),n=await e.saveAsBase64({dataUri:!0}),i=e.catalog.getOrCreateViewerPreferences();i.setHideToolbar(!1),i.setHideMenubar(!1),i.setHideWindowUI(!1),i.setFitWindow(!0),i.setCenterWindow(!0),i.setDisplayDocTitle(!0),t.src=n,t.style.width="450px";const s=this.papersize[1]/this.papersize[0]*500;t.style.height=`${s}px`,t.style.display=""}async writepages(e){const t=e.pageList,n=e.back,i=e.maxSigCount,s=[],a=[];t.forEach((g,p)=>{g.info!="b"?s.push(g.info):a.push(p)});const[o,l]=await Rd(this.managedDoc,s);a.forEach(g=>l.splice(g,0,"b"));let c=0;const d=this.per_sheet/2;let f=d;const h=Od(this);let u=n;for(;f<=t.length;){const g=t.slice(c,f);u=this.draw_block_onto_page({outPDF:o,embeddedPages:l,block_start:c,block_end:f,sigDetails:g,papersize:this.papersize,positions:h,cropmarks:this.cropmarks,sigOrderMarks:this.sigOrderMarks,pdfEdgeMarks:this.pdfEdgeMarks,cutmarks:this.cutmarks,alt:e.alt,side2flag:u,maxSigCount:i,sewingMarks:this.sewingMarks}),c+=d,f+=d}return o}draw_block_onto_page(e){const t=e.sigDetails,n=e.block_start,i=e.block_end,s=e.papersize,a=e.outPDF,o=e.positions,l=e.cropmarks,c=e.sigOrderMarks,d=e.pdfEdgeMarks,f=e.cutmarks,h=e.alt,u=e.maxSigCount;let g=e.side2flag;const p=e.sewingMarks,x=e.embeddedPages.slice(n,i),m=a.addPage(s),v=f?tb(s,this.per_sheet):[],w=l?eb(g,this.duplexrotate,s,this.per_sheet):[],A=[...v,...w],T=[],_=[];return x.forEach((k,C)=>{if(!(k=="b"||k===void 0))if(k instanceof ps){const{y:O,x:P,sx:E,sy:R,rotation:b}=o[C];m.drawPage(k,{y:O,x:P,xScale:E,yScale:R,rotate:pe(b)})}else console.error("Unexpected type for page: ",k);t[C].isSigStart?(d&&A.push(Ja(!0,o[C],5)),c&&T.push(nb(t[C],o[C],u,5,20))):t[C].isSigEnd&&d&&A.push(Ja(!1,o[C],5));const S=p.isEnabled?rb(t[C],o[C],p.sewingMarkLocation,p.amount,p.marginPt,p.tapeWidthPt):[];_.push(...S)}),A.forEach(k=>{m.drawLine(k)}),T.forEach(k=>{m.drawRectangle(k)}),_.forEach(k=>{m.drawCircle(k)}),h&&(g=!g),g}async createSignatures(e){const t=e.pageIndexDetails,n=[this.writepages({pageList:t[0],back:!1,alt:!1,maxSigCount:e.maxSigCount}),this.writepages({pageList:t[1],back:!0,alt:!1,maxSigCount:e.maxSigCount})],[i,s]=await Promise.all(n);return[i,s]}bundleSettings(){const e=Dh(),t=`Imposer settings: ${JSON.stringify(e,null,2)} +\0`,K+=s(I,2),K+=_.magic,K+=s(w,2),K+=s(A,2),K+=s(ie.crc32,4),K+=s(ie.compressedSize,4),K+=s(ie.uncompressedSize,4),K+=s(C.length,2),K+=s(N.length,2),{fileRecord:f.LOCAL_FILE_HEADER+K+C+N,dirRecord:f.CENTRAL_FILE_HEADER+s(se,2)+K+s(P.length,2)+"\0\0\0\0"+s(L,4)+s(x,4)+C+N+P}}var o=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),d=t("../crc32"),f=t("../signature");function h(u,g,p,x){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=g,this.zipPlatform=p,this.encodeFileName=x,this.streamFiles=u,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(h,l),h.prototype.push=function(u){var g=u.meta.percent||0,p=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(u):(this.bytesWritten+=u.data.length,l.prototype.push.call(this,{data:u.data,meta:{currentFile:this.currentFile,percent:p?(g+100*(p-x-1))/p:100}}))},h.prototype.openedSource=function(u){this.currentSourceOffset=this.bytesWritten,this.currentFile=u.file.name;var g=this.streamFiles&&!u.file.dir;if(g){var p=a(u,g,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:p.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(u){this.accumulate=!1;var g=this.streamFiles&&!u.file.dir,p=a(u,g,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(p.dirRecord),g)this.push({data:function(x){return f.DATA_DESCRIPTOR+s(x.crc32,4)+s(x.compressedSize,4)+s(x.uncompressedSize,4)}(u),meta:{percent:100}});else for(this.push({data:p.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var u=this.bytesWritten,g=0;g=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return s.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},n.exports=a},{"../utils":32}],19:[function(t,n,i){var s=t("./Uint8ArrayReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},n.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){var s=t("./DataReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},n.exports=a},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){var s=t("./ArrayReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},n.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var s=t("../utils"),a=t("../support"),o=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),d=t("./Uint8ArrayReader");n.exports=function(f){var h=s.getTypeOf(f);return s.checkSupport(h),h!=="string"||a.uint8array?h==="nodebuffer"?new c(f):a.uint8array?new d(s.transformTo("uint8array",f)):new o(s.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,n,i){var s=t("./GenericWorker"),a=t("../utils");function o(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,s),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},n.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){var s=t("./GenericWorker"),a=t("../crc32");function o(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(o,s),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},n.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,n,i){var s=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(o,a),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},n.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){var s=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(d){c.dataIsReady=!0,c.data=d,c.max=d&&d.length||0,c.type=s.getTypeOf(d),c.isPaused||c._tickAndRepeat()},function(d){c.error(d)})}s.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(t,n,i){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l "+a:a}},n.exports=s},{}],29:[function(t,n,i){var s=t("../utils"),a=t("./ConvertWorker"),o=t("./GenericWorker"),l=t("../base64"),c=t("../support"),d=t("../external"),f=null;if(c.nodestream)try{f=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(g,p){return new d.Promise(function(x,m){var v=[],w=g._internalType,A=g._outputType,T=g._mimeType;g.on("data",function(_,k){v.push(_),p&&p(k)}).on("error",function(_){v=[],m(_)}).on("end",function(){try{var _=function(k,C,S){switch(k){case"blob":return s.newBlob(s.transformTo("arraybuffer",C),S);case"base64":return l.encode(C);default:return s.transformTo(k,C)}}(A,function(k,C){var S,O=0,P=null,E=0;for(S=0;S"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),i.blob=a.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,n,i){for(var s=t("./utils"),a=t("./support"),o=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),d=0;d<256;d++)c[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;c[254]=c[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function h(){l.call(this,"utf-8 encode")}i.utf8encode=function(u){return a.nodebuffer?o.newBufferFrom(u,"utf-8"):function(g){var p,x,m,v,w,A=g.length,T=0;for(v=0;v>>6:(x<65536?p[w++]=224|x>>>12:(p[w++]=240|x>>>18,p[w++]=128|x>>>12&63),p[w++]=128|x>>>6&63),p[w++]=128|63&x);return p}(u)},i.utf8decode=function(u){return a.nodebuffer?s.transformTo("nodebuffer",u).toString("utf-8"):function(g){var p,x,m,v,w=g.length,A=new Array(2*w);for(p=x=0;p>10&1023,A[x++]=56320|1023&m)}return A.length!==x&&(A.subarray?A=A.subarray(0,x):A.length=x),s.applyFromCharCode(A)}(u=s.transformTo(a.uint8array?"uint8array":"array",u))},s.inherits(f,l),f.prototype.processChunk=function(u){var g=s.transformTo(a.uint8array?"uint8array":"array",u.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var p=g;(g=new Uint8Array(p.length+this.leftOver.length)).set(this.leftOver,0),g.set(p,this.leftOver.length)}else g=this.leftOver.concat(g);this.leftOver=null}var x=function(v,w){var A;for((w=w||v.length)>v.length&&(w=v.length),A=w-1;0<=A&&(192&v[A])==128;)A--;return A<0||A===0?w:A+c[v[A]]>w?A:w}(g),m=g;x!==g.length&&(a.uint8array?(m=g.subarray(0,x),this.leftOver=g.subarray(x,g.length)):(m=g.slice(0,x),this.leftOver=g.slice(x,g.length))),this.push({data:i.utf8decode(m),meta:u.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,s.inherits(h,l),h.prototype.processChunk=function(u){this.push({data:i.utf8encode(u.data),meta:u.meta})},i.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var s=t("./support"),a=t("./base64"),o=t("./nodejsUtils"),l=t("./external");function c(p){return p}function d(p,x){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),u==0&&(this.dosPermissions=63&this.externalFileAttributes),u==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var u=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=u.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=u.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=u.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=u.readInt(4))}},readExtraFields:function(u){var g,p,x,m=u.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});u.index+4>>6:(u<65536?h[x++]=224|u>>>12:(h[x++]=240|u>>>18,h[x++]=128|u>>>12&63),h[x++]=128|u>>>6&63),h[x++]=128|63&u);return h},i.buf2binstring=function(f){return d(f,f.length)},i.binstring2buf=function(f){for(var h=new s.Buf8(f.length),u=0,g=h.length;u>10&1023,v[g++]=56320|1023&p)}return d(v,g)},i.utf8border=function(f,h){var u;for((h=h||f.length)>f.length&&(h=f.length),u=h-1;0<=u&&(192&f[u])==128;)u--;return u<0||u===0?h:u+l[f[u]]>h?u:h}},{"./common":41}],43:[function(t,n,i){n.exports=function(s,a,o,l){for(var c=65535&s|0,d=s>>>16&65535|0,f=0;o!==0;){for(o-=f=2e3>>1:a>>>1;o[l]=a}return o}();n.exports=function(a,o,l,c){var d=s,f=c+l;a^=-1;for(var h=c;h>>8^d[255&(a^o[h])];return-1^a}},{}],46:[function(t,n,i){var s,a=t("../utils/common"),o=t("./trees"),l=t("./adler32"),c=t("./crc32"),d=t("./messages"),f=0,h=4,u=0,g=-2,p=-1,x=4,m=2,v=8,w=9,A=286,T=30,_=19,k=2*A+1,C=15,S=3,O=258,P=O+S+1,E=42,R=113,b=1,N=2,V=3,q=4;function ne(y,G){return y.msg=d[G],G}function H(y){return(y<<1)-(4y.avail_out&&(W=y.avail_out),W!==0&&(a.arraySet(y.output,G.pending_buf,G.pending_out,W,y.next_out),y.next_out+=W,G.pending_out+=W,y.total_out+=W,y.avail_out-=W,G.pending-=W,G.pending===0&&(G.pending_out=0))}function L(y,G){o._tr_flush_block(y,0<=y.block_start?y.block_start:-1,y.strstart-y.block_start,G),y.block_start=y.strstart,I(y.strm)}function se(y,G){y.pending_buf[y.pending++]=G}function K(y,G){y.pending_buf[y.pending++]=G>>>8&255,y.pending_buf[y.pending++]=255&G}function ee(y,G){var W,B,z=y.max_chain_length,M=y.strstart,X=y.prev_length,J=y.nice_match,j=y.strstart>y.w_size-P?y.strstart-(y.w_size-P):0,te=y.window,ce=y.w_mask,re=y.prev,be=y.strstart+O,He=te[M+X-1],De=te[M+X];y.prev_length>=y.good_match&&(z>>=2),J>y.lookahead&&(J=y.lookahead);do if(te[(W=G)+X]===De&&te[W+X-1]===He&&te[W]===te[M]&&te[++W]===te[M+1]){M+=2,W++;do;while(te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&te[++M]===te[++W]&&Mj&&--z!=0);return X<=y.lookahead?X:y.lookahead}function Ve(y){var G,W,B,z,M,X,J,j,te,ce,re=y.w_size;do{if(z=y.window_size-y.lookahead-y.strstart,y.strstart>=re+(re-P)){for(a.arraySet(y.window,y.window,re,re,0),y.match_start-=re,y.strstart-=re,y.block_start-=re,G=W=y.hash_size;B=y.head[--G],y.head[G]=re<=B?B-re:0,--W;);for(G=W=re;B=y.prev[--G],y.prev[G]=re<=B?B-re:0,--W;);z+=re}if(y.strm.avail_in===0)break;if(X=y.strm,J=y.window,j=y.strstart+y.lookahead,te=z,ce=void 0,ce=X.avail_in,te=S)for(M=y.strstart-y.insert,y.ins_h=y.window[M],y.ins_h=(y.ins_h<=S&&(y.ins_h=(y.ins_h<=S)if(B=o._tr_tally(y,y.strstart-y.match_start,y.match_length-S),y.lookahead-=y.match_length,y.match_length<=y.max_lazy_match&&y.lookahead>=S){for(y.match_length--;y.strstart++,y.ins_h=(y.ins_h<=S&&(y.ins_h=(y.ins_h<=S&&y.match_length<=y.prev_length){for(z=y.strstart+y.lookahead-S,B=o._tr_tally(y,y.strstart-1-y.prev_match,y.prev_length-S),y.lookahead-=y.prev_length-1,y.prev_length-=2;++y.strstart<=z&&(y.ins_h=(y.ins_h<y.pending_buf_size-5&&(W=y.pending_buf_size-5);;){if(y.lookahead<=1){if(Ve(y),y.lookahead===0&&G===f)return b;if(y.lookahead===0)break}y.strstart+=y.lookahead,y.lookahead=0;var B=y.block_start+W;if((y.strstart===0||y.strstart>=B)&&(y.lookahead=y.strstart-B,y.strstart=B,L(y,!1),y.strm.avail_out===0)||y.strstart-y.block_start>=y.w_size-P&&(L(y,!1),y.strm.avail_out===0))return b}return y.insert=0,G===h?(L(y,!0),y.strm.avail_out===0?V:q):(y.strstart>y.block_start&&(L(y,!1),y.strm.avail_out),b)}),new Oe(4,4,8,4,Ke),new Oe(4,5,16,8,Ke),new Oe(4,6,32,32,Ke),new Oe(4,4,16,16,de),new Oe(8,16,32,32,de),new Oe(8,16,128,128,de),new Oe(8,32,128,256,de),new Oe(32,128,258,1024,de),new Oe(32,258,258,4096,de)],i.deflateInit=function(y,G){return Ht(y,G,v,15,8,0)},i.deflateInit2=Ht,i.deflateReset=nr,i.deflateResetKeep=$e,i.deflateSetHeader=function(y,G){return y&&y.state?y.state.wrap!==2?g:(y.state.gzhead=G,u):g},i.deflate=function(y,G){var W,B,z,M;if(!y||!y.state||5>8&255),se(B,B.gzhead.time>>16&255),se(B,B.gzhead.time>>24&255),se(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),se(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(se(B,255&B.gzhead.extra.length),se(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(y.adler=c(y.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(se(B,0),se(B,0),se(B,0),se(B,0),se(B,0),se(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),se(B,3),B.status=R);else{var X=v+(B.w_bits-8<<4)<<8;X|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(X|=32),X+=31-X%31,B.status=R,K(B,X),B.strstart!==0&&(K(B,y.adler>>>16),K(B,65535&y.adler)),y.adler=1}if(B.status===69)if(B.gzhead.extra){for(z=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>z&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),I(y),z=B.pending,B.pending!==B.pending_buf_size));)se(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>z&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){z=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>z&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),I(y),z=B.pending,B.pending===B.pending_buf_size)){M=1;break}M=B.gzindexz&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),M===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){z=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>z&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),I(y),z=B.pending,B.pending===B.pending_buf_size)){M=1;break}M=B.gzindexz&&(y.adler=c(y.adler,B.pending_buf,B.pending-z,z)),M===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&I(y),B.pending+2<=B.pending_buf_size&&(se(B,255&y.adler),se(B,y.adler>>8&255),y.adler=0,B.status=R)):B.status=R),B.pending!==0){if(I(y),y.avail_out===0)return B.last_flush=-1,u}else if(y.avail_in===0&&H(G)<=H(W)&&G!==h)return ne(y,-5);if(B.status===666&&y.avail_in!==0)return ne(y,-5);if(y.avail_in!==0||B.lookahead!==0||G!==f&&B.status!==666){var J=B.strategy===2?function(j,te){for(var ce;;){if(j.lookahead===0&&(Ve(j),j.lookahead===0)){if(te===f)return b;break}if(j.match_length=0,ce=o._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++,ce&&(L(j,!1),j.strm.avail_out===0))return b}return j.insert=0,te===h?(L(j,!0),j.strm.avail_out===0?V:q):j.last_lit&&(L(j,!1),j.strm.avail_out===0)?b:N}(B,G):B.strategy===3?function(j,te){for(var ce,re,be,He,De=j.window;;){if(j.lookahead<=O){if(Ve(j),j.lookahead<=O&&te===f)return b;if(j.lookahead===0)break}if(j.match_length=0,j.lookahead>=S&&0j.lookahead&&(j.match_length=j.lookahead)}if(j.match_length>=S?(ce=o._tr_tally(j,1,j.match_length-S),j.lookahead-=j.match_length,j.strstart+=j.match_length,j.match_length=0):(ce=o._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++),ce&&(L(j,!1),j.strm.avail_out===0))return b}return j.insert=0,te===h?(L(j,!0),j.strm.avail_out===0?V:q):j.last_lit&&(L(j,!1),j.strm.avail_out===0)?b:N}(B,G):s[B.level].func(B,G);if(J!==V&&J!==q||(B.status=666),J===b||J===V)return y.avail_out===0&&(B.last_flush=-1),u;if(J===N&&(G===1?o._tr_align(B):G!==5&&(o._tr_stored_block(B,0,0,!1),G===3&&(ie(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),I(y),y.avail_out===0))return B.last_flush=-1,u}return G!==h?u:B.wrap<=0?1:(B.wrap===2?(se(B,255&y.adler),se(B,y.adler>>8&255),se(B,y.adler>>16&255),se(B,y.adler>>24&255),se(B,255&y.total_in),se(B,y.total_in>>8&255),se(B,y.total_in>>16&255),se(B,y.total_in>>24&255)):(K(B,y.adler>>>16),K(B,65535&y.adler)),I(y),0=W.w_size&&(M===0&&(ie(W.head),W.strstart=0,W.block_start=0,W.insert=0),te=new a.Buf8(W.w_size),a.arraySet(te,G,ce-W.w_size,W.w_size,0),G=te,ce=W.w_size),X=y.avail_in,J=y.next_in,j=y.input,y.avail_in=ce,y.next_in=0,y.input=G,Ve(W);W.lookahead>=S;){for(B=W.strstart,z=W.lookahead-(S-1);W.ins_h=(W.ins_h<>>=S=C>>>24,w-=S,(S=C>>>16&255)===0)N[d++]=65535&C;else{if(!(16&S)){if(!(64&S)){C=A[(65535&C)+(v&(1<>>=S,w-=S),w<15&&(v+=b[l++]<>>=S=C>>>24,w-=S,!(16&(S=C>>>16&255))){if(!(64&S)){C=T[(65535&C)+(v&(1<>>=S,w-=S,(S=d-f)>3,v&=(1<<(w-=O<<3))-1,s.next_in=l,s.next_out=d,s.avail_in=l>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(E){var R;return E&&E.state?(R=E.state,E.total_in=E.total_out=R.total=0,E.msg="",R.wrap&&(E.adler=1&R.wrap),R.mode=g,R.last=0,R.havedict=0,R.dmax=32768,R.head=null,R.hold=0,R.bits=0,R.lencode=R.lendyn=new s.Buf32(p),R.distcode=R.distdyn=new s.Buf32(x),R.sane=1,R.back=-1,h):u}function A(E){var R;return E&&E.state?((R=E.state).wsize=0,R.whave=0,R.wnext=0,w(E)):u}function T(E,R){var b,N;return E&&E.state?(N=E.state,R<0?(b=0,R=-R):(b=1+(R>>4),R<48&&(R&=15)),R&&(R<8||15=q.wsize?(s.arraySet(q.window,R,b-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(N<(V=q.wsize-q.wnext)&&(V=N),s.arraySet(q.window,R,b-N,V,q.wnext),(N-=V)?(s.arraySet(q.window,R,b-N,N,0),q.wnext=N,q.whave=q.wsize):(q.wnext+=V,q.wnext===q.wsize&&(q.wnext=0),q.whave>>8&255,b.check=o(b.check,M,2,0),L=I=0,b.mode=2;break}if(b.flags=0,b.head&&(b.head.done=!1),!(1&b.wrap)||(((255&I)<<8)+(I>>8))%31){E.msg="incorrect header check",b.mode=30;break}if((15&I)!=8){E.msg="unknown compression method",b.mode=30;break}if(L-=4,y=8+(15&(I>>>=4)),b.wbits===0)b.wbits=y;else if(y>b.wbits){E.msg="invalid window size",b.mode=30;break}b.dmax=1<>8&1),512&b.flags&&(M[0]=255&I,M[1]=I>>>8&255,b.check=o(b.check,M,2,0)),L=I=0,b.mode=3;case 3:for(;L<32;){if(H===0)break e;H--,I+=N[q++]<>>8&255,M[2]=I>>>16&255,M[3]=I>>>24&255,b.check=o(b.check,M,4,0)),L=I=0,b.mode=4;case 4:for(;L<16;){if(H===0)break e;H--,I+=N[q++]<>8),512&b.flags&&(M[0]=255&I,M[1]=I>>>8&255,b.check=o(b.check,M,2,0)),L=I=0,b.mode=5;case 5:if(1024&b.flags){for(;L<16;){if(H===0)break e;H--,I+=N[q++]<>>8&255,b.check=o(b.check,M,2,0)),L=I=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(H<(ee=b.length)&&(ee=H),ee&&(b.head&&(y=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),s.arraySet(b.head.extra,N,q,ee,y)),512&b.flags&&(b.check=o(b.check,N,ee,q)),H-=ee,q+=ee,b.length-=ee),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(H===0)break e;for(ee=0;y=N[q+ee++],b.head&&y&&b.length<65536&&(b.head.name+=String.fromCharCode(y)),y&&ee>9&1,b.head.done=!0),E.adler=b.check=0,b.mode=12;break;case 10:for(;L<32;){if(H===0)break e;H--,I+=N[q++]<>>=7&L,L-=7&L,b.mode=27;break}for(;L<3;){if(H===0)break e;H--,I+=N[q++]<>>=1)){case 0:b.mode=14;break;case 1:if(O(b),b.mode=20,R!==6)break;I>>>=2,L-=2;break e;case 2:b.mode=17;break;case 3:E.msg="invalid block type",b.mode=30}I>>>=2,L-=2;break;case 14:for(I>>>=7&L,L-=7&L;L<32;){if(H===0)break e;H--,I+=N[q++]<>>16^65535)){E.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&I,L=I=0,b.mode=15,R===6)break e;case 15:b.mode=16;case 16:if(ee=b.length){if(H>>=5,L-=5,b.ndist=1+(31&I),I>>>=5,L-=5,b.ncode=4+(15&I),I>>>=4,L-=4,286>>=3,L-=3}for(;b.have<19;)b.lens[X[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,W={bits:b.lenbits},G=c(0,b.lens,0,19,b.lencode,0,b.work,W),b.lenbits=W.bits,G){E.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have>>16&255,Je=65535&z,!((de=z>>>24)<=L);){if(H===0)break e;H--,I+=N[q++]<>>=de,L-=de,b.lens[b.have++]=Je;else{if(Je===16){for(B=de+2;L>>=de,L-=de,b.have===0){E.msg="invalid bit length repeat",b.mode=30;break}y=b.lens[b.have-1],ee=3+(3&I),I>>>=2,L-=2}else if(Je===17){for(B=de+3;L>>=de)),I>>>=3,L-=3}else{for(B=de+7;L>>=de)),I>>>=7,L-=7}if(b.have+ee>b.nlen+b.ndist){E.msg="invalid bit length repeat",b.mode=30;break}for(;ee--;)b.lens[b.have++]=y}}if(b.mode===30)break;if(b.lens[256]===0){E.msg="invalid code -- missing end-of-block",b.mode=30;break}if(b.lenbits=9,W={bits:b.lenbits},G=c(d,b.lens,0,b.nlen,b.lencode,0,b.work,W),b.lenbits=W.bits,G){E.msg="invalid literal/lengths set",b.mode=30;break}if(b.distbits=6,b.distcode=b.distdyn,W={bits:b.distbits},G=c(f,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,W),b.distbits=W.bits,G){E.msg="invalid distances set",b.mode=30;break}if(b.mode=20,R===6)break e;case 20:b.mode=21;case 21:if(6<=H&&258<=ie){E.next_out=ne,E.avail_out=ie,E.next_in=q,E.avail_in=H,b.hold=I,b.bits=L,l(E,K),ne=E.next_out,V=E.output,ie=E.avail_out,q=E.next_in,N=E.input,H=E.avail_in,I=b.hold,L=b.bits,b.mode===12&&(b.back=-1);break}for(b.back=0;Oe=(z=b.lencode[I&(1<>>16&255,Je=65535&z,!((de=z>>>24)<=L);){if(H===0)break e;H--,I+=N[q++]<>$e)])>>>16&255,Je=65535&z,!($e+(de=z>>>24)<=L);){if(H===0)break e;H--,I+=N[q++]<>>=$e,L-=$e,b.back+=$e}if(I>>>=de,L-=de,b.back+=de,b.length=Je,Oe===0){b.mode=26;break}if(32&Oe){b.back=-1,b.mode=12;break}if(64&Oe){E.msg="invalid literal/length code",b.mode=30;break}b.extra=15&Oe,b.mode=22;case 22:if(b.extra){for(B=b.extra;L>>=b.extra,L-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=23;case 23:for(;Oe=(z=b.distcode[I&(1<>>16&255,Je=65535&z,!((de=z>>>24)<=L);){if(H===0)break e;H--,I+=N[q++]<>$e)])>>>16&255,Je=65535&z,!($e+(de=z>>>24)<=L);){if(H===0)break e;H--,I+=N[q++]<>>=$e,L-=$e,b.back+=$e}if(I>>>=de,L-=de,b.back+=de,64&Oe){E.msg="invalid distance code",b.mode=30;break}b.offset=Je,b.extra=15&Oe,b.mode=24;case 24:if(b.extra){for(B=b.extra;L>>=b.extra,L-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){E.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(ie===0)break e;if(ee=K-ie,b.offset>ee){if((ee=b.offset-ee)>b.whave&&b.sane){E.msg="invalid distance too far back",b.mode=30;break}Ve=ee>b.wnext?(ee-=b.wnext,b.wsize-ee):b.wnext-ee,ee>b.length&&(ee=b.length),Ke=b.window}else Ke=V,Ve=ne-b.offset,ee=b.length;for(iek?(S=Ve[Ke+x[R]],L[se+x[R]]):(S=96,0),v=1<>ne)+(w-=v)]=C<<24|S<<16|O|0,w!==0;);for(v=1<>=1;if(v!==0?(I&=v-1,I+=v):I=0,R++,--K[E]==0){if(E===N)break;E=f[h+x[R]]}if(V>>7)]}function se(z,M){z.pending_buf[z.pending++]=255&M,z.pending_buf[z.pending++]=M>>>8&255}function K(z,M,X){z.bi_valid>m-X?(z.bi_buf|=M<>m-z.bi_valid,z.bi_valid+=X-m):(z.bi_buf|=M<>>=1,X<<=1,0<--M;);return X>>>1}function Ke(z,M,X){var J,j,te=new Array(x+1),ce=0;for(J=1;J<=x;J++)te[J]=ce=ce+X[J-1]<<1;for(j=0;j<=M;j++){var re=z[2*j+1];re!==0&&(z[2*j]=Ve(te[re]++,re))}}function de(z){var M;for(M=0;M>1;1<=X;X--)$e(z,te,X);for(j=be;X=z.heap[1],z.heap[1]=z.heap[z.heap_len--],$e(z,te,1),J=z.heap[1],z.heap[--z.heap_max]=X,z.heap[--z.heap_max]=J,te[2*j]=te[2*X]+te[2*J],z.depth[j]=(z.depth[X]>=z.depth[J]?z.depth[X]:z.depth[J])+1,te[2*X+1]=te[2*J+1]=j,z.heap[1]=j++,$e(z,te,1),2<=z.heap_len;);z.heap[--z.heap_max]=z.heap[1],function(De,Bt){var Ei,ir,Ti,et,Gs,bo,mr=Bt.dyn_tree,al=Bt.max_code,Uh=Bt.stat_desc.static_tree,qh=Bt.stat_desc.has_stree,jh=Bt.stat_desc.extra_bits,ol=Bt.stat_desc.extra_base,_i=Bt.stat_desc.max_length,Zs=0;for(et=0;et<=x;et++)De.bl_count[et]=0;for(mr[2*De.heap[De.heap_max]+1]=0,Ei=De.heap_max+1;Ei>=7;j>>=1)if(1&He&&re.dyn_ltree[2*be]!==0)return a;if(re.dyn_ltree[18]!==0||re.dyn_ltree[20]!==0||re.dyn_ltree[26]!==0)return o;for(be=32;be>>3,(te=z.static_len+3+7>>>3)<=j&&(j=te)):j=te=X+5,X+4<=j&&M!==-1?B(z,M,X,J):z.strategy===4||te===j?(K(z,2+(J?1:0),3),nr(z,P,E)):(K(z,4+(J?1:0),3),function(re,be,He,De){var Bt;for(K(re,be-257,5),K(re,He-1,5),K(re,De-4,4),Bt=0;Bt>>8&255,z.pending_buf[z.d_buf+2*z.last_lit+1]=255&M,z.pending_buf[z.l_buf+z.last_lit]=255&X,z.last_lit++,M===0?z.dyn_ltree[2*X]++:(z.matches++,M--,z.dyn_ltree[2*(b[X]+f+1)]++,z.dyn_dtree[2*L(M)]++),z.last_lit===z.lit_bufsize-1},i._tr_align=function(z){K(z,2,3),ee(z,w,P),function(M){M.bi_valid===16?(se(M,M.bi_buf),M.bi_buf=0,M.bi_valid=0):8<=M.bi_valid&&(M.pending_buf[M.pending++]=255&M.bi_buf,M.bi_buf>>=8,M.bi_valid-=8)}(z)}},{"../utils/common":41}],53:[function(t,n,i){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,n,i){(function(s){(function(a,o){if(!a.setImmediate){var l,c,d,f,h=1,u={},g=!1,p=a.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(a);x=x&&x.setTimeout?x:a,l={}.toString.call(a.process)==="[object process]"?function(A){process.nextTick(function(){v(A)})}:function(){if(a.postMessage&&!a.importScripts){var A=!0,T=a.onmessage;return a.onmessage=function(){A=!1},a.postMessage("","*"),a.onmessage=T,A}}()?(f="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",w,!1):a.attachEvent("onmessage",w),function(A){a.postMessage(f+A,"*")}):a.MessageChannel?((d=new MessageChannel).port1.onmessage=function(A){v(A.data)},function(A){d.port2.postMessage(A)}):p&&"onreadystatechange"in p.createElement("script")?(c=p.documentElement,function(A){var T=p.createElement("script");T.onreadystatechange=function(){v(A),T.onreadystatechange=null,c.removeChild(T),T=null},c.appendChild(T)}):function(A){setTimeout(v,0,A)},x.setImmediate=function(A){typeof A!="function"&&(A=new Function(""+A));for(var T=new Array(arguments.length-1),_=0;_"u"?s===void 0?this:s:self)}).call(this,typeof _t<"u"?_t:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(wh);var Fx=wh.exports;const Ax=vc(Fx);var Ue;(function(r){r.assertEqual=i=>i;function e(i){}r.assertIs=e;function t(i){throw new Error}r.assertNever=t,r.arrayToEnum=i=>{const s={};for(const a of i)s[a]=a;return s},r.getValidEnumValues=i=>{const s=r.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),a={};for(const o of s)a[o]=i[o];return r.objectValues(a)},r.objectValues=i=>r.objectKeys(i).map(function(s){return i[s]}),r.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},r.find=(i,s)=>{for(const a of i)if(s(a))return a},r.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}r.joinValues=n,r.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ue||(Ue={}));var gc;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(gc||(gc={}));const ae=Ue.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Nr=r=>{switch(typeof r){case"undefined":return ae.undefined;case"string":return ae.string;case"number":return isNaN(r)?ae.nan:ae.number;case"boolean":return ae.boolean;case"function":return ae.function;case"bigint":return ae.bigint;case"symbol":return ae.symbol;case"object":return Array.isArray(r)?ae.array:r===null?ae.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?ae.promise:typeof Map<"u"&&r instanceof Map?ae.map:typeof Set<"u"&&r instanceof Set?ae.set:typeof Date<"u"&&r instanceof Date?ae.date:ae.object;default:return ae.unknown}},$=Ue.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Cx=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Qt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(s){return s.message},n={_errors:[]},i=s=>{for(const a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(t(a));else{let o=n,l=0;for(;lt.message){const t={},n=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Qt.create=r=>new Qt(r);const ys=(r,e)=>{let t;switch(r.code){case $.invalid_type:r.received===ae.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case $.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Ue.jsonStringifyReplacer)}`;break;case $.unrecognized_keys:t=`Unrecognized key(s) in object: ${Ue.joinValues(r.keys,", ")}`;break;case $.invalid_union:t="Invalid input";break;case $.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Ue.joinValues(r.options)}`;break;case $.invalid_enum_value:t=`Invalid enum value. Expected ${Ue.joinValues(r.options)}, received '${r.received}'`;break;case $.invalid_arguments:t="Invalid function arguments";break;case $.invalid_return_type:t="Invalid function return type";break;case $.invalid_date:t="Invalid date";break;case $.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Ue.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case $.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case $.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case $.custom:t="Invalid input";break;case $.invalid_intersection_types:t="Intersection results could not be merged";break;case $.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case $.not_finite:t="Number must be finite";break;default:t=e.defaultError,Ue.assertNever(r)}return{message:t}};let kh=ys;function Ex(r){kh=r}function ja(){return kh}const Va=r=>{const{data:e,path:t,errorMaps:n,issueData:i}=r,s=[...t,...i.path||[]],a={...i,path:s};let o="";const l=n.filter(c=>!!c).slice().reverse();for(const c of l)o=c(a,{data:e,defaultError:o}).message;return{...i,path:s,message:i.message||o}},Tx=[];function oe(r,e){const t=Va({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ja(),ys].filter(n=>!!n)});r.common.issues.push(t)}class yt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const i of t){if(i.status==="aborted")return Se;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const i of t)n.push({key:await i.key,value:await i.value});return yt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const i of t){const{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return Se;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[s.value]=a.value)}return{status:e.value,value:n}}}const Se=Object.freeze({status:"aborted"}),Sh=r=>({status:"dirty",value:r}),At=r=>({status:"valid",value:r}),mc=r=>r.status==="aborted",xc=r=>r.status==="dirty",vs=r=>r.status==="valid",Wa=r=>typeof Promise<"u"&&r instanceof Promise;var me;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(me||(me={}));class hr{constructor(e,t,n,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Cd=(r,e)=>{if(vs(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 Qt(r.common.issues);return this._error=t,this._error}}};function Ae(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:i}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,o)=>a.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:n??o.defaultError}:{message:t??o.defaultError},description:i}}class Ee{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)}get description(){return this._def.description}_getType(e){return Nr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Nr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new yt,ctx:{common:e.parent.common,data:e.data,parsedType:Nr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Wa(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 n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const i={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nr(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Cd(i,s)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nr(e)},i=this._parse({data:e,path:n.path,parent:n}),s=await(Wa(i)?i:Promise.resolve(i));return Cd(n,s)}refine(e,t){const n=i=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(i):t;return this._refinement((i,s)=>{const a=e(i),o=()=>s.addIssue({code:$.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof t=="function"?t(n,i):t),!1))}_refinement(e){return new tr({schema:this,typeName:ye.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Sr.create(this,this._def)}nullable(){return En.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $t.create(this,this._def)}promise(){return xi.create(this,this._def)}or(e){return Fs.create([this,e],this._def)}and(e){return As.create(this,e,this._def)}transform(e){return new tr({...Ae(this._def),schema:this,typeName:ye.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Os({...Ae(this._def),innerType:this,defaultValue:t,typeName:ye.ZodDefault})}brand(){return new Ah({typeName:ye.ZodBranded,type:this,...Ae(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ka({...Ae(this._def),innerType:this,catchValue:t,typeName:ye.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Hs.create(this,e)}readonly(){return Ya.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const _x=/^c[^\s-]{8,}$/i,Ox=/^[a-z][a-z0-9]*$/,Rx=/^[0-9A-HJKMNP-TV-Z]{26}$/,Px=/^[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,Dx=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Io;const Bx=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Nx=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ix=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Mx(r,e){return!!((e==="v4"||!e)&&Bx.test(r)||(e==="v6"||!e)&&Nx.test(r))}class Xt extends Ee{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ae.string){const s=this._getOrReturnCtx(e);return oe(s,{code:$.invalid_type,expected:ae.string,received:s.parsedType}),Se}const n=new yt;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.lengths.value&&(i=this._getOrReturnCtx(e,i),oe(i,{code:$.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.lengthe.test(i),{validation:t,code:$.invalid_string,...me.errToObj(n)})}_addCheck(e){return new Xt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...me.errToObj(e)})}url(e){return this._addCheck({kind:"url",...me.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...me.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...me.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...me.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...me.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...me.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...me.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...me.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...me.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...me.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...me.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...me.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...me.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...me.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...me.errToObj(t)})}nonempty(e){return this.min(1,me.errToObj(e))}trim(){return new Xt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Xt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Xt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}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 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 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{var e;return new Xt({checks:[],typeName:ye.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ae(r)})};function Lx(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=t>n?t:n,s=parseInt(r.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}class nn extends Ee{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)!==ae.number){const s=this._getOrReturnCtx(e);return oe(s,{code:$.invalid_type,expected:ae.number,received:s.parsedType}),Se}let n;const i=new yt;for(const s of this._def.checks)s.kind==="int"?Ue.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),oe(n,{code:$.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.datas.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),oe(n,{code:$.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?Lx(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),oe(n,{code:$.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),oe(n,{code:$.not_finite,message:s.message}),i.dirty()):Ue.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,me.toString(t))}setLimit(e,t,n,i){return new nn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:me.toString(i)}]})}_addCheck(e){return new nn({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:me.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:me.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:me.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:me.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:me.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.valuee.kind==="int"||e.kind==="multipleOf"&&Ue.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.valuenew nn({checks:[],typeName:ye.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...Ae(r)});class sn extends Ee{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==ae.bigint){const s=this._getOrReturnCtx(e);return oe(s,{code:$.invalid_type,expected:ae.bigint,received:s.parsedType}),Se}let n;const i=new yt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.datas.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),oe(n,{code:$.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),oe(n,{code:$.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ue.assertNever(s);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,me.toString(t))}gt(e,t){return this.setLimit("min",e,!1,me.toString(t))}lte(e,t){return this.setLimit("max",e,!0,me.toString(t))}lt(e,t){return this.setLimit("max",e,!1,me.toString(t))}setLimit(e,t,n,i){return new sn({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:me.toString(i)}]})}_addCheck(e){return new sn({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:me.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:me.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:me.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:me.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:me.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{var e;return new sn({checks:[],typeName:ye.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...Ae(r)})};class ws extends Ee{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ae.boolean){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.boolean,received:n.parsedType}),Se}return At(e.data)}}ws.create=r=>new ws({typeName:ye.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...Ae(r)});class An extends Ee{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ae.date){const s=this._getOrReturnCtx(e);return oe(s,{code:$.invalid_type,expected:ae.date,received:s.parsedType}),Se}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return oe(s,{code:$.invalid_date}),Se}const n=new yt;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()s.value&&(i=this._getOrReturnCtx(e,i),oe(i,{code:$.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Ue.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new An({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:me.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:me.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.valuenew An({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:ye.ZodDate,...Ae(r)});class Ha extends Ee{_parse(e){if(this._getType(e)!==ae.symbol){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.symbol,received:n.parsedType}),Se}return At(e.data)}}Ha.create=r=>new Ha({typeName:ye.ZodSymbol,...Ae(r)});class ks extends Ee{_parse(e){if(this._getType(e)!==ae.undefined){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.undefined,received:n.parsedType}),Se}return At(e.data)}}ks.create=r=>new ks({typeName:ye.ZodUndefined,...Ae(r)});class Ss extends Ee{_parse(e){if(this._getType(e)!==ae.null){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.null,received:n.parsedType}),Se}return At(e.data)}}Ss.create=r=>new Ss({typeName:ye.ZodNull,...Ae(r)});class mi extends Ee{constructor(){super(...arguments),this._any=!0}_parse(e){return At(e.data)}}mi.create=r=>new mi({typeName:ye.ZodAny,...Ae(r)});class xn extends Ee{constructor(){super(...arguments),this._unknown=!0}_parse(e){return At(e.data)}}xn.create=r=>new xn({typeName:ye.ZodUnknown,...Ae(r)});class Cr extends Ee{_parse(e){const t=this._getOrReturnCtx(e);return oe(t,{code:$.invalid_type,expected:ae.never,received:t.parsedType}),Se}}Cr.create=r=>new Cr({typeName:ye.ZodNever,...Ae(r)});class Ga extends Ee{_parse(e){if(this._getType(e)!==ae.undefined){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.void,received:n.parsedType}),Se}return At(e.data)}}Ga.create=r=>new Ga({typeName:ye.ZodVoid,...Ae(r)});class $t extends Ee{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==ae.array)return oe(t,{code:$.invalid_type,expected:ae.array,received:t.parsedType}),Se;if(i.exactLength!==null){const a=t.data.length>i.exactLength.value,o=t.data.lengthi.maxLength.value&&(oe(t,{code:$.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((a,o)=>i.type._parseAsync(new hr(t,a,t.path,o)))).then(a=>yt.mergeArray(n,a));const s=[...t.data].map((a,o)=>i.type._parseSync(new hr(t,a,t.path,o)));return yt.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new $t({...this._def,minLength:{value:e,message:me.toString(t)}})}max(e,t){return new $t({...this._def,maxLength:{value:e,message:me.toString(t)}})}length(e,t){return new $t({...this._def,exactLength:{value:e,message:me.toString(t)}})}nonempty(e){return this.min(1,e)}}$t.create=(r,e)=>new $t({type:r,minLength:null,maxLength:null,exactLength:null,typeName:ye.ZodArray,...Ae(e)});function Vn(r){if(r instanceof Ye){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Sr.create(Vn(n))}return new Ye({...r._def,shape:()=>e})}else return r instanceof $t?new $t({...r._def,type:Vn(r.element)}):r instanceof Sr?Sr.create(Vn(r.unwrap())):r instanceof En?En.create(Vn(r.unwrap())):r instanceof fr?fr.create(r.items.map(e=>Vn(e))):r}class Ye extends Ee{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=Ue.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==ae.object){const c=this._getOrReturnCtx(e);return oe(c,{code:$.invalid_type,expected:ae.object,received:c.parsedType}),Se}const{status:n,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof Cr&&this._def.unknownKeys==="strip"))for(const c in i.data)a.includes(c)||o.push(c);const l=[];for(const c of a){const d=s[c],f=i.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new hr(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Cr){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of o)l.push({key:{status:"valid",value:d},value:{status:"valid",value:i.data[d]}});else if(c==="strict")o.length>0&&(oe(i,{code:$.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of o){const f=i.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new hr(i,f,i.path,d)),alwaysSet:d in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const f=await d.key;c.push({key:f,value:await d.value,alwaysSet:d.alwaysSet})}return c}).then(c=>yt.mergeObjectSync(n,c)):yt.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return me.errToObj,new Ye({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var i,s,a,o;const l=(a=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,t,n).message)!==null&&a!==void 0?a:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=me.errToObj(e).message)!==null&&o!==void 0?o:l}:{message:l}}}:{}})}strip(){return new Ye({...this._def,unknownKeys:"strip"})}passthrough(){return new Ye({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ye({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ye({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ye.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ye({...this._def,catchall:e})}pick(e){const t={};return Ue.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}omit(e){const t={};return Ue.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Ye({...this._def,shape:()=>t})}deepPartial(){return Vn(this)}partial(e){const t={};return Ue.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?t[n]=i:t[n]=i.optional()}),new Ye({...this._def,shape:()=>t})}required(e){const t={};return Ue.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Sr;)s=s._def.innerType;t[n]=s}}),new Ye({...this._def,shape:()=>t})}keyof(){return Fh(Ue.objectKeys(this.shape))}}Ye.create=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strip",catchall:Cr.create(),typeName:ye.ZodObject,...Ae(e)});Ye.strictCreate=(r,e)=>new Ye({shape:()=>r,unknownKeys:"strict",catchall:Cr.create(),typeName:ye.ZodObject,...Ae(e)});Ye.lazycreate=(r,e)=>new Ye({shape:r,unknownKeys:"strip",catchall:Cr.create(),typeName:ye.ZodObject,...Ae(e)});class Fs extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function i(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const a=s.map(o=>new Qt(o.ctx.common.issues));return oe(t,{code:$.invalid_union,unionErrors:a}),Se}if(t.common.async)return Promise.all(n.map(async s=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await s._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(i);{let s;const a=[];for(const l of n){const c={...t,common:{...t.common,issues:[]},parent:null},d=l._parseSync({data:t.data,path:t.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:c}),c.common.issues.length&&a.push(c.common.issues)}if(s)return t.common.issues.push(...s.ctx.common.issues),s.result;const o=a.map(l=>new Qt(l));return oe(t,{code:$.invalid_union,unionErrors:o}),Se}}get options(){return this._def.options}}Fs.create=(r,e)=>new Fs({options:r,typeName:ye.ZodUnion,...Ae(e)});const va=r=>r instanceof Es?va(r.schema):r instanceof tr?va(r.innerType()):r instanceof Ts?[r.value]:r instanceof an?r.options:r instanceof _s?Object.keys(r.enum):r instanceof Os?va(r._def.innerType):r instanceof ks?[void 0]:r instanceof Ss?[null]:null;class mo extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ae.object)return oe(t,{code:$.invalid_type,expected:ae.object,received:t.parsedType}),Se;const n=this.discriminator,i=t.data[n],s=this.optionsMap.get(i);return s?t.common.async?s._parseAsync({data:t.data,path:t.path,parent:t}):s._parseSync({data:t.data,path:t.path,parent:t}):(oe(t,{code:$.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Se)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const i=new Map;for(const s of t){const a=va(s.shape[e]);if(!a)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of a){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,s)}}return new mo({typeName:ye.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...Ae(n)})}}function bc(r,e){const t=Nr(r),n=Nr(e);if(r===e)return{valid:!0,data:r};if(t===ae.object&&n===ae.object){const i=Ue.objectKeys(e),s=Ue.objectKeys(r).filter(o=>i.indexOf(o)!==-1),a={...r,...e};for(const o of s){const l=bc(r[o],e[o]);if(!l.valid)return{valid:!1};a[o]=l.data}return{valid:!0,data:a}}else if(t===ae.array&&n===ae.array){if(r.length!==e.length)return{valid:!1};const i=[];for(let s=0;s{if(mc(s)||mc(a))return Se;const o=bc(s.value,a.value);return o.valid?((xc(s)||xc(a))&&t.dirty(),{status:t.value,value:o.data}):(oe(n,{code:$.invalid_intersection_types}),Se)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}As.create=(r,e,t)=>new As({left:r,right:e,typeName:ye.ZodIntersection,...Ae(t)});class fr extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.array)return oe(n,{code:$.invalid_type,expected:ae.array,received:n.parsedType}),Se;if(n.data.lengththis._def.items.length&&(oe(n,{code:$.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new hr(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>yt.mergeArray(t,a)):yt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new fr({...this._def,rest:e})}}fr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new fr({items:r,typeName:ye.ZodTuple,rest:null,...Ae(e)})};class Cs extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.object)return oe(n,{code:$.invalid_type,expected:ae.object,received:n.parsedType}),Se;const i=[],s=this._def.keyType,a=this._def.valueType;for(const o in n.data)i.push({key:s._parse(new hr(n,o,n.path,o)),value:a._parse(new hr(n,n.data[o],n.path,o))});return n.common.async?yt.mergeObjectAsync(t,i):yt.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof Ee?new Cs({keyType:e,valueType:t,typeName:ye.ZodRecord,...Ae(n)}):new Cs({keyType:Xt.create(),valueType:e,typeName:ye.ZodRecord,...Ae(t)})}}class Za extends Ee{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.map)return oe(n,{code:$.invalid_type,expected:ae.map,received:n.parsedType}),Se;const i=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([o,l],c)=>({key:i._parse(new hr(n,o,n.path,[c,"key"])),value:s._parse(new hr(n,l,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of a){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return Se;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const l of a){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return Se;(c.status==="dirty"||d.status==="dirty")&&t.dirty(),o.set(c.value,d.value)}return{status:t.value,value:o}}}}Za.create=(r,e,t)=>new Za({valueType:e,keyType:r,typeName:ye.ZodMap,...Ae(t)});class Cn extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==ae.set)return oe(n,{code:$.invalid_type,expected:ae.set,received:n.parsedType}),Se;const i=this._def;i.minSize!==null&&n.data.sizei.maxSize.value&&(oe(n,{code:$.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());const s=this._def.valueType;function a(l){const c=new Set;for(const d of l){if(d.status==="aborted")return Se;d.status==="dirty"&&t.dirty(),c.add(d.value)}return{status:t.value,value:c}}const o=[...n.data.values()].map((l,c)=>s._parse(new hr(n,l,n.path,c)));return n.common.async?Promise.all(o).then(l=>a(l)):a(o)}min(e,t){return new Cn({...this._def,minSize:{value:e,message:me.toString(t)}})}max(e,t){return new Cn({...this._def,maxSize:{value:e,message:me.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Cn.create=(r,e)=>new Cn({valueType:r,minSize:null,maxSize:null,typeName:ye.ZodSet,...Ae(e)});class ti extends Ee{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ae.function)return oe(t,{code:$.invalid_type,expected:ae.function,received:t.parsedType}),Se;function n(o,l){return Va({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ja(),ys].filter(c=>!!c),issueData:{code:$.invalid_arguments,argumentsError:l}})}function i(o,l){return Va({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ja(),ys].filter(c=>!!c),issueData:{code:$.invalid_return_type,returnTypeError:l}})}const s={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof xi){const o=this;return At(async function(...l){const c=new Qt([]),d=await o._def.args.parseAsync(l,s).catch(u=>{throw c.addIssue(n(l,u)),c}),f=await Reflect.apply(a,this,d);return await o._def.returns._def.type.parseAsync(f,s).catch(u=>{throw c.addIssue(i(f,u)),c})})}else{const o=this;return At(function(...l){const c=o._def.args.safeParse(l,s);if(!c.success)throw new Qt([n(l,c.error)]);const d=Reflect.apply(a,this,c.data),f=o._def.returns.safeParse(d,s);if(!f.success)throw new Qt([i(d,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ti({...this._def,args:fr.create(e).rest(xn.create())})}returns(e){return new ti({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ti({args:e||fr.create([]).rest(xn.create()),returns:t||xn.create(),typeName:ye.ZodFunction,...Ae(n)})}}class Es extends Ee{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})}}Es.create=(r,e)=>new Es({getter:r,typeName:ye.ZodLazy,...Ae(e)});class Ts extends Ee{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return oe(t,{received:t.data,code:$.invalid_literal,expected:this._def.value}),Se}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ts.create=(r,e)=>new Ts({value:r,typeName:ye.ZodLiteral,...Ae(e)});function Fh(r,e){return new an({values:r,typeName:ye.ZodEnum,...Ae(e)})}class an extends Ee{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return oe(t,{expected:Ue.joinValues(n),received:t.parsedType,code:$.invalid_type}),Se}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return oe(t,{received:t.data,code:$.invalid_enum_value,options:n}),Se}return At(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){return an.create(e)}exclude(e){return an.create(this.options.filter(t=>!e.includes(t)))}}an.create=Fh;class _s extends Ee{_parse(e){const t=Ue.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==ae.string&&n.parsedType!==ae.number){const i=Ue.objectValues(t);return oe(n,{expected:Ue.joinValues(i),received:n.parsedType,code:$.invalid_type}),Se}if(t.indexOf(e.data)===-1){const i=Ue.objectValues(t);return oe(n,{received:n.data,code:$.invalid_enum_value,options:i}),Se}return At(e.data)}get enum(){return this._def.values}}_s.create=(r,e)=>new _s({values:r,typeName:ye.ZodNativeEnum,...Ae(e)});class xi extends Ee{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==ae.promise&&t.common.async===!1)return oe(t,{code:$.invalid_type,expected:ae.promise,received:t.parsedType}),Se;const n=t.parsedType===ae.promise?t.data:Promise.resolve(t.data);return At(n.then(i=>this._def.type.parseAsync(i,{path:t.path,errorMap:t.common.contextualErrorMap})))}}xi.create=(r,e)=>new xi({type:r,typeName:ye.ZodPromise,...Ae(e)});class tr extends Ee{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ye.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{oe(n,a),a.fatal?t.abort():t.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const a=i.transform(n.data,s);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(a).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:a,path:n.path,parent:n})}if(i.type==="refinement"){const a=o=>{const l=i.refinement(o,s);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Se:(o.status==="dirty"&&t.dirty(),a(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?Se:(o.status==="dirty"&&t.dirty(),a(o.value).then(()=>({status:t.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!vs(a))return a;const o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>vs(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:t.value,value:o})):a);Ue.assertNever(i)}}tr.create=(r,e,t)=>new tr({schema:r,typeName:ye.ZodEffects,effect:e,...Ae(t)});tr.createWithPreprocess=(r,e,t)=>new tr({schema:e,effect:{type:"preprocess",transform:r},typeName:ye.ZodEffects,...Ae(t)});class Sr extends Ee{_parse(e){return this._getType(e)===ae.undefined?At(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sr.create=(r,e)=>new Sr({innerType:r,typeName:ye.ZodOptional,...Ae(e)});class En extends Ee{_parse(e){return this._getType(e)===ae.null?At(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}En.create=(r,e)=>new En({innerType:r,typeName:ye.ZodNullable,...Ae(e)});class Os extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===ae.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Os.create=(r,e)=>new Os({innerType:r,typeName:ye.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ae(e)});class Ka extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Wa(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Qt(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Qt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ka.create=(r,e)=>new Ka({innerType:r,typeName:ye.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ae(e)});class Xa extends Ee{_parse(e){if(this._getType(e)!==ae.nan){const n=this._getOrReturnCtx(e);return oe(n,{code:$.invalid_type,expected:ae.nan,received:n.parsedType}),Se}return{status:"valid",value:e.data}}}Xa.create=r=>new Xa({typeName:ye.ZodNaN,...Ae(r)});const Ux=Symbol("zod_brand");class Ah extends Ee{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Hs extends Ee{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Se:s.status==="dirty"?(t.dirty(),Sh(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Se:i.status==="dirty"?(t.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,t){return new Hs({in:e,out:t,typeName:ye.ZodPipeline})}}class Ya extends Ee{_parse(e){const t=this._def.innerType._parse(e);return vs(t)&&(t.value=Object.freeze(t.value)),t}}Ya.create=(r,e)=>new Ya({innerType:r,typeName:ye.ZodReadonly,...Ae(e)});const Ch=(r,e={},t)=>r?mi.create().superRefine((n,i)=>{var s,a;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,l=(a=(s=o.fatal)!==null&&s!==void 0?s:t)!==null&&a!==void 0?a:!0,c=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...c,fatal:l})}}):mi.create(),qx={object:Ye.lazycreate};var ye;(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"})(ye||(ye={}));const jx=(r,e={message:`Input not instance of ${r.name}`})=>Ch(t=>t instanceof r,e),Eh=Xt.create,Th=nn.create,Vx=Xa.create,Wx=sn.create,_h=ws.create,Hx=An.create,Gx=Ha.create,Zx=ks.create,Kx=Ss.create,Xx=mi.create,Yx=xn.create,Jx=Cr.create,Qx=Ga.create,$x=$t.create,e1=Ye.create,t1=Ye.strictCreate,r1=Fs.create,n1=mo.create,i1=As.create,s1=fr.create,a1=Cs.create,o1=Za.create,c1=Cn.create,l1=ti.create,d1=Es.create,u1=Ts.create,h1=an.create,f1=_s.create,p1=xi.create,Ed=tr.create,g1=Sr.create,m1=En.create,x1=tr.createWithPreprocess,b1=Hs.create,y1=()=>Eh().optional(),v1=()=>Th().optional(),w1=()=>_h().optional(),k1={string:r=>Xt.create({...r,coerce:!0}),number:r=>nn.create({...r,coerce:!0}),boolean:r=>ws.create({...r,coerce:!0}),bigint:r=>sn.create({...r,coerce:!0}),date:r=>An.create({...r,coerce:!0})},S1=Se;var Ne=Object.freeze({__proto__:null,defaultErrorMap:ys,setErrorMap:Ex,getErrorMap:ja,makeIssue:Va,EMPTY_PATH:Tx,addIssueToContext:oe,ParseStatus:yt,INVALID:Se,DIRTY:Sh,OK:At,isAborted:mc,isDirty:xc,isValid:vs,isAsync:Wa,get util(){return Ue},get objectUtil(){return gc},ZodParsedType:ae,getParsedType:Nr,ZodType:Ee,ZodString:Xt,ZodNumber:nn,ZodBigInt:sn,ZodBoolean:ws,ZodDate:An,ZodSymbol:Ha,ZodUndefined:ks,ZodNull:Ss,ZodAny:mi,ZodUnknown:xn,ZodNever:Cr,ZodVoid:Ga,ZodArray:$t,ZodObject:Ye,ZodUnion:Fs,ZodDiscriminatedUnion:mo,ZodIntersection:As,ZodTuple:fr,ZodRecord:Cs,ZodMap:Za,ZodSet:Cn,ZodFunction:ti,ZodLazy:Es,ZodLiteral:Ts,ZodEnum:an,ZodNativeEnum:_s,ZodPromise:xi,ZodEffects:tr,ZodTransformer:tr,ZodOptional:Sr,ZodNullable:En,ZodDefault:Os,ZodCatch:Ka,ZodNaN:Xa,BRAND:Ux,ZodBranded:Ah,ZodPipeline:Hs,ZodReadonly:Ya,custom:Ch,Schema:Ee,ZodSchema:Ee,late:qx,get ZodFirstPartyTypeKind(){return ye},coerce:k1,any:Xx,array:$x,bigint:Wx,boolean:_h,date:Hx,discriminatedUnion:n1,effect:Ed,enum:h1,function:l1,instanceof:jx,intersection:i1,lazy:d1,literal:u1,map:o1,nan:Vx,nativeEnum:f1,never:Jx,null:Kx,nullable:m1,number:Th,object:e1,oboolean:w1,onumber:v1,optional:g1,ostring:y1,pipeline:b1,preprocess:x1,promise:p1,record:a1,set:c1,strictObject:t1,string:Eh,symbol:Gx,transformer:Ed,tuple:s1,undefined:Zx,union:r1,unknown:Yx,void:Qx,NEVER:S1,ZodIssueCode:$,quotelessJson:Cx,ZodError:Qt});const F1=Ne.union([Ne.string(),Ne.array(Ne.number())]).transform(r=>Array.isArray(r)?r:r.split(/, */)).pipe(Ne.array(Ne.coerce.number())),un=Ne.union([Ne.string().toLowerCase().pipe(Ne.enum(["true","false","on"])),Ne.boolean()]).transform(r=>r==="true"||r==="on"||r===!0),qe=r=>r.optional().catch(()=>{}),A1=qe(Ne.enum(["none","90cw","90ccw","out_binding","in_binding"])).default("none"),C1=qe(Ne.enum(["all","only_out","only_in","in_n_out"])).default("all"),E1=Object.keys(gi),T1=qe(Ne.enum([...E1,"CUSTOM"])).default("A4"),_1=qe(Ne.enum(["pt","in","cm"])).default("pt"),O1=qe(Ne.enum(["single","duplex"])).default("duplex"),R1=qe(Ne.enum(["folio","quarto","octavo","sextodecimo"])).default("folio"),P1=qe(Ne.enum(["centered","lockratio","stretch"])).default("lockratio"),D1=qe(Ne.enum(["centered","binding_aligned"])).default("centered"),z1=qe(Ne.enum(["booklet","perfect","standardsig","customsig","1_3rd","A7_2_16s","8_zine","a_3_6s","a9_3_3_4","a_4_8s","a10_6_10s"])).default("standardsig"),B1=qe(Ne.enum(["wacky_pack","wacky_gap"])).default("wacky_pack"),N1=qe(Ne.enum(["aggregated","signatures","both"])).default("both"),nl=Ne.object({printFile:N1,sourceRotation:A1,rotatePage:qe(un).default(!1),paperSize:T1,paperSizeUnit:_1,printerType:O1,paperRotation90:qe(un).default(!1),pageLayout:R1,cropMarks:qe(un).default(!1),cutMarks:qe(un).default(!1),pdfEdgeMarks:qe(un).default(!1),sigOrderMarks:qe(un).default(!1),pageScaling:P1,pagePositioning:D1,mainForeEdgePaddingPt:qe(Ne.coerce.number()).default(0),bindingEdgePaddingPt:qe(Ne.coerce.number()).default(0),topEdgePaddingPt:qe(Ne.coerce.number()).default(0),bottomEdgePaddingPt:qe(Ne.coerce.number()).default(0),sigFormat:z1,sigLength:qe(Ne.coerce.number()).default(4),customSigLength:qe(F1).default(null),foreEdgePaddingPt:qe(Ne.coerce.number()).default(0),wackySpacing:B1,flyleafs:qe(Ne.coerce.number()).default(1),sewingMarksEnabled:qe(un).default(!1),sewingMarkLocation:C1,sewingMarksMarginPt:qe(Ne.coerce.number()).default(72),sewingMarksAmount:qe(Ne.coerce.number()).default(3),sewingMarksTapeWidthPt:qe(Ne.coerce.number()).default(36),paperSizeCustomWidth:qe(Ne.coerce.number()).default(0),paperSizeCustomHeight:qe(Ne.coerce.number()).default(0)}),I1=nl.parse({}),il="bookbinderSettings";function Oh(){const r={},e=JSON.parse(localStorage.getItem(il));return e||(Rh(r),Oh())}function Rh(r){localStorage.setItem(il,JSON.stringify(r))}function M1(){localStorage.removeItem(il)}function L1(r,e){r.setAttribute("disabled",!0),r.style.fontSize="13px",r.innerText="Generating, this may take a little while...",console.log("The whole Book model:",e),e.createoutputfiles(!1).then(()=>{console.log("Generated result!")}).catch(n=>{console.error(n)}).finally(()=>{r.removeAttribute("disabled"),r.style.fontSize="24px",r.innerText="Generate PDF Output"})}function U1(r,e){r.setAttribute("disabled",!0),r.innerText="Generating Preview...",Dh(),e.createoutputfiles(!0).then(()=>{console.log("Preview result!")}).catch(n=>{console.error(n)}).finally(()=>{r.removeAttribute("disabled"),r.innerText="Preview Output"})}function q1(r){const e=$1();r.update(e),sl(),xo()}function Ph(r){const e=document.getElementById("sewing_marks_details");r?e.setAttribute("open",0):e.removeAttribute("open")}function j1(r){const e=document.getElementById("page_count");e.innerText=r.pagecount}function V1(r){const e=document.getElementById("total_sheets"),t=document.getElementById("sig_count"),n=document.getElementById("sig_arrange"),i=document.getElementById("total_pages");if(r.book==null||r.book==null)return;const s=r.book.pagelistdetails.reduce((a,o)=>(o.forEach(l=>a+=l.length?l.length:1),a),0);e.innerText=r.book.sheets,t.innerText=r.book.sigconfig.length,n.innerText=r.book.sigconfig.join(", "),i.innerText=s}function W1(r){document.getElementById("show_layout_info").style.display="block",console.log("So much info from updatePageLayoutInfo: ",r);const e=r.dimensions.layout.rotations[0]==-90||r.dimensions.layout.rotations[0]==90||r.dimensions.layout.rotations[0][0]==-90||r.dimensions.layout.rotations[0][0]==90,t=r.dimensions.layoutCell,n=[r.dimensions.xPdfWidthFunc(),r.dimensions.yPdfHeightFunc()],i=Math.min(Math.min(250/t[0],250/t[1]),Math.min(250/n[0],250/n[1]));let s=[t[0]*i,t[1]*i],a=document.getElementById("grid_layout_preview");a.style.width=`${s[0]}px`,a.style.height=`${s[1]}px`,s=[n[0]*i,n[1]*i],a=document.getElementById("pdf_on_page_layout_preview"),a.style.width=`${s[0]}px`,a.style.height=`${s[1]}px`,s=[r.dimensions.xBindingShiftFunc()*i,r.dimensions.yTopShiftFunc()*i],a.style.margin=`${s[1]}px ${s[0]}px`,document.getElementById("page_grid_layout").innerText=`${r.dimensions.layout.rows} rows x ${r.dimensions.layout.cols} cols`,document.getElementById("page_grid_dimensions").innerText=`${t[0]}, ${t[1]}`,document.getElementById("pdf_source_dimensions").innerText=`${r.cropbox.width}, ${r.cropbox.height}`,document.getElementById("pdf_page_dimensions").innerText=`${n[0].toFixed(2)}, ${n[1].toFixed(2)}`,document.getElementById("pdf_offset_dimensions").innerHTML=` + ${r.dimensions.xBindingShiftFunc().toFixed(2)} from spine
+ ${r.dimensions.yTopShiftFunc().toFixed(2)} from top
+ ${r.dimensions.xForeEdgeShiftFunc().toFixed(2)} from fore edge
+ ${r.dimensions.yBottomShiftFunc().toFixed(2)} from bottom + `,document.getElementById("pdf_scale_dimensions").innerText=`${r.dimensions.pdfScale[0].toFixed(2)}, ${r.dimensions.pdfScale[1].toFixed(2)}`,document.getElementById("pdf_page_rotation_info").innerText=`${e}`}function xo(){const r=document.getElementById("paper_size"),e=document.getElementById("paper_size_unit").value;for(const t of Array.from(r.children)){const n=t.value,i=gi[n];let s=`${n} (${i[0]} x ${i[1]} pt)`;e=="in"?s=`${n} (${(i[0]*.0138889).toFixed(1)} x ${(i[1]*.0138889).toFixed(1)} inches)`:e=="cm"&&(s=`${n} (${(i[0]*.0352778).toFixed(2)} x ${(i[1]*.0352778).toFixed(2)} cm)`),t.setAttribute("label",s)}}function sl(){const r=document.getElementById("paper_size_custom_width").value,e=document.getElementById("paper_size_custom_height").value,t=document.getElementById("paper_size"),n=r.length>0&&e.length>0&&!isNaN(r)&&!isNaN(e),i=t.children.namedItem("CUSTOM");if(!(i==null&&!n))if(i!=null&&!n)i.remove();else if(i==null){const s=document.createElement("option");s.setAttribute("value","CUSTOM"),s.setAttribute("name","CUSTOM"),gi.CUSTOM=[Number(r),Number(e)],t.appendChild(s)}else gi.CUSTOM=[Number(r),Number(e)]}function H1(){const r=document.getElementById("paper_size");Object.keys(gi).forEach(e=>{const t=document.createElement("option");t.setAttribute("value",e),t.setAttribute("name",e),e=="A4"&&t.setAttribute("selected",!0),t.innerText=e,r.appendChild(t)}),xo()}function G1(){const r=document.getElementById("a9_3_3_4").checked||document.getElementById("a10_6_10s").checked||document.getElementById("a_3_6s").checked||document.getElementById("a_4_8s").checked||document.getElementById("A7_2_16s").checked||document.getElementById("1_3rd").checked;console.log("Is a wacky layout? ",r),document.getElementById("book_size").querySelectorAll("input").forEach(e=>{e.disabled=r}),document.getElementById("book_size").style.opacity=r?.3:1}function Z1(r){document.querySelectorAll("[type=radio]").forEach(n=>{n.checked=!1}),document.querySelectorAll("[type=checkbox]").forEach(n=>{n.checked=!1}),r.paperRotation90&&(document.querySelector("input[name='paper_rotation_90']").checked=!0),r.rotatePage&&(document.querySelector("input[name='rotate_page']").checked=!0),r.cropMarks&&(document.querySelector("input[name='cropmarks']").checked=!0),r.sigOrderMarks&&(document.querySelector("input[name='sig_order_marks']").checked=!0),r.pdfEdgeMarks&&(document.querySelector("input[name='pdf_edge_marks']").checked=!0),r.cutMarks&&(document.querySelector("input[name='cutmarks']").checked=!0),document.querySelector(`input[name="sig_format"][value="${r.sigFormat}"]`).checked=!0,document.querySelector(`input[name="wacky_spacing"][value="${r.wackySpacing}"]`).checked=!0,Ph(r.sewingMarksEnabled),document.querySelector('input[name="add_sewing_marks_checkbox"]').checked=r.sewingMarksEnabled,document.querySelector('select[name="sewing_mark_locations"]').value=r.sewingMarkLocation,document.querySelector('input[name="sewing_marks_margin_pt"]').value=r.sewingMarksMarginPt,document.querySelector('input[name="sewing_marks_amount"]').value=r.sewingMarksAmount,document.querySelector('input[name="sewing_marks_tape_width_pt"]').value=r.sewingMarksTapeWidthPt,document.querySelector('input[name="main_fore_edge_padding_pt"]').value=r.mainForeEdgePaddingPt,document.querySelector('input[name="binding_edge_padding_pt"]').value=r.bindingEdgePaddingPt,document.querySelector('input[name="top_edge_padding_pt"]').value=r.topEdgePaddingPt,document.querySelector('input[name="bottom_edge_padding_pt"]').value=r.bottomEdgePaddingPt,document.querySelector('input[name="fore_edge_padding_pt"]').value=r.foreEdgePaddingPt,document.querySelector('input[name="flyleafs"]').value=r.flyleafs,document.querySelector('select[name="source_rotation"]').value=r.sourceRotation,document.querySelector('select[name="pagelayout"]').value=r.pageLayout,document.querySelector('select[name="page_scaling"]').value=r.pageScaling,document.querySelector('select[name="page_positioning"]').value=r.pagePositioning,document.querySelector('select[name="print_file"]').value=r.printFile,document.querySelector('select[name="paper_size"]').value=r.paperSize,document.querySelector('select[name="paper_size_unit"]').value=r.paperSizeUnit,document.querySelector('select[name="printer_type"]').value=r.printerType,r.paperSize==="CUSTOM"&&r.paperSizeCustomHeight!==void 0&&r.paperSizeCustomWidth!==void 0&&(document.querySelector('input[name="paper_size_custom_height"]').value=r.paperSizeCustomHeight,document.querySelector('input[name="paper_size_custom_width"]').value=r.paperSizeCustomWidth,sl(),xo(),document.querySelector('select[name="paper_size"]').value="CUSTOM"),r.sigFormat=="customsig"?document.querySelector("input[name='custom_sig']").value=r.customSigLength:document.querySelector("input[name='sig_length']").value=r.sigLength;const e=Array.from(document.getElementsByClassName("source_rotation_example")),t=`${r.sourceRotation}_example`;e.forEach(n=>{n.style.display=n.id===t?"block":"none"})}function Dh(){const r=document.getElementById("pdf");r.style.display="none",r.src=""}const K1=r=>{const e=new URL(r).searchParams.entries();return Object.fromEntries(e)},X1=(r,e)=>{const t=new URL(r);for(const[n,i]of Object.entries(e))if(i!=null){if(i===I1[n]){t.searchParams.delete(n);continue}t.searchParams.set(n,String(i))}return t.toString()},Y1=r=>{const e=new URL(r);return e.search="",e.toString()},zh=r=>{window.history.pushState({},"",r.toString())},J1=r=>nl.parse({sourceRotation:r.get("source_rotation"),paperSize:r.get("paper_size"),paperSizeUnit:r.get("paper_size_unit"),printerType:r.get("printer_type"),rotatePage:r.has("rotate_page"),paperRotation90:r.has("paper_rotation_90"),pageLayout:r.get("pagelayout"),cropMarks:r.has("cropmarks"),sigOrderMarks:r.has("sig_order_marks"),pdfEdgeMarks:r.has("pdf_edge_marks"),cutMarks:r.has("cutmarks"),pageScaling:r.get("page_scaling"),pagePositioning:r.get("page_positioning"),mainForeEdgePaddingPt:r.get("main_fore_edge_padding_pt"),bindingEdgePaddingPt:r.get("binding_edge_padding_pt"),topEdgePaddingPt:r.get("top_edge_padding_pt"),bottomEdgePaddingPt:r.get("bottom_edge_padding_pt"),sigFormat:r.get("sig_format"),sigLength:r.get("sig_length"),customSigLength:r.get("custom_sig"),foreEdgePaddingPt:r.get("fore_edge_padding_pt"),wackySpacing:r.get("wacky_spacing"),fileDownload:r.get("file_download"),printFile:r.get("print_file"),flyleafs:r.get("flyleafs"),paperSizeCustomWidth:r.get("paper_size_custom_width"),paperSizeCustomHeight:r.get("paper_size_custom_height"),sewingMarksEnabled:r.has("add_sewing_marks_checkbox"),sewingMarkLocation:r.get("sewing_mark_locations"),sewingMarksMarginPt:r.get("sewing_marks_margin_pt"),sewingMarksAmount:r.get("sewing_marks_amount"),sewingMarksTapeWidthPt:r.get("sewing_marks_tape_width_pt")}),Bh=r=>{zh(X1(window.location.href,r))},Nh=()=>{const r=K1(window.location.href),t=Object.keys(r).length>0?r:Oh(),n=nl.parse(t);return Bh(n),n};function Ih(r){r.createpages().then(e=>{W1(e),console.log("... pages created"),j1(r),V1(r),G1()})}function Q1(r){const e=J1(r);return Rh(e),Bh(e),e}function Mh(){const r=Nh();return Z1(r),r}const $1=()=>(M1(),zh(Y1(window.location.href)),Mh());function eb(r,e,t,n){const i={opacity:.4,dashArray:[1,5]};let s,a,o,l,c,d;const[f,h]=t,u=[];switch(n){case 32:r&&(i.dashArray=[1,5],s=e?f*.75:f*.25,c=h*.5,d=e?h*.75:h*.25,u.push({...Td(s,c,d),...i}));case 16:r&&(i.dashArray=[3,5],l=e?h*.75:h*.25,a=f*.5,o=e?0:h,u.push({..._d(l,a,o),...i}));case 8:r&&(i.dashArray=[5,5],s=f*.5,c=h*.5,d=e?0:h,u.push({...Td(s,c,d),...i}));case 4:r||(i.dashArray=[10,5],u.push({..._d(h*.5,0,f),...i}));break}return u}function tb(r,e){let t=[];const[n,i]=r;switch(e){case 32:t=[...t,...Mo(i*.75,0,n),...Mo(i*.25,0,n),...Lo(n*.5,i*.75),...Lo(n*.5,i*.25)];case 16:t=[...t,...ib(n*.5,0,i),...Lo(n*.5,i*.5)];case 8:t=[...t,...Mo(i*.5,0,n)]}return t}function rb(r,e,t,n,i,s){if(console.log("try to draw"),e.isLeftPage)return[];if(console.log(" on right"),t=="only_out"&&!r.isSigStart)return[];if(console.log(" a"),t=="only_in"&&!r.isSigMiddle)return[];if(console.log(" b"),t=="in_n_out"&&!(r.isSigStart||r.isSigMiddle))return[];console.log(" c");var a=Math.abs(e.rotation)===90;let o=0,l=0;a?(o=Math.abs(e.spineMarkTop[0]-e.spineMarkBottom[0]),l=e.spineMarkTop[1]):(o=Math.abs(e.spineMarkTop[1]-e.spineMarkBottom[1]),l=e.spineMarkTop[0]);const d=(o-2*i)/(n+1),f=[];for(let p=1;p<=n;p++){const x=s/2;f.push({pointHeight:i+d*p+x},{pointHeight:i+d*p-x})}const h=[{pointHeight:i},{pointHeight:o-i},...f],u={size:1,color:Zc(0)};return h.map(p=>(p={...p,...u},a?(p.y=l,p.x=p.pointHeight+e.spineMarkBottom[0]):(p.y=p.pointHeight+e.spineMarkBottom[1],p.x=l),p))}function Ja(r,e,t){let n,i,s,a;r?([n,i]=e.spineMarkTop,[s,a]=e.spineMarkTop):([n,i]=e.spineMarkBottom,[s,a]=e.spineMarkBottom),e.rotation==0||e.rotation==180?(n-=t/2,s+=t/2):(i-=t/2,a+=t/2);const o={start:{x:n,y:i},end:{x:s,y:a},thickness:e.rotation==0?.5:.25,color:Me(0,0,0),opacity:1};return console.log(" --> draw this: ",o),o}function nb(r,e,t,n,i){const s=Ja(!0,e,n),a=Ja(!1,e,n);let o=s.start.x,l=s.start.y;const c=e.rotation==0?s.start.y-a.start.y:s.start.x-a.start.x;let d=Math.min(i,c/t);const f=d*r.signatureNum;if(e.rotation==0)d=d*-1,l-=f;else{const h=d;d=n,n=h*-1,o-=f}return{x:o,y:l,width:n,height:d,borderWidth:0,color:Me(0,0,0),opacity:.5}}function Td(r,e,t){return{start:{x:r,y:e},end:{x:r,y:t}}}function _d(r,e,t){return{start:{x:e,y:r},end:{x:t,y:r}}}function ib(r,e,t){return[{start:{x:r,y:e},end:{x:r,y:e+Ur},opacity:.4},{start:{x:r,y:t-Ur},end:{x:r,y:t},opacity:.4}]}function Mo(r,e,t){return[{start:{x:e,y:r},end:{x:e+Ur,y:r},opacity:.4},{start:{x:t-Ur,y:r},end:{x:t,y:r},opacity:.4}]}function Lo(r,e){return[{start:{x:r-Ur,y:e},end:{x:r+Ur,y:e},opacity:.4},{start:{x:r,y:e-Ur},end:{x:r,y:e+Ur},opacity:.4}]}function Od(r){const e=Lh(r),{layoutCell:t,xForeEdgeShiftFunc:n,xBindingShiftFunc:i,yTopShiftFunc:s,yBottomShiftFunc:a,pdfScale:o}=e,[l,c]=t,d=[];return e.layout.rotations.forEach((f,h)=>{f.forEach((u,g)=>{const p=n(),x=i(),m=s(),v=a();let w=g%2==0,A=g*l+(w?p:x),T=h*c+v,_=[g*l,(h+1)*c-m],k=[(g+1)*l,h*c+v];u==-180?(w=g%2==1,T=(h+1)*c-v,A=(g+1)*l-(w?p:x),_=[(g+1)*l,(h+1)*c],k=[(g+1)*l,h*c]):u==90?(w=h%2==0,A=(1+g)*c-v,T=h*l+(w?x:p),_=[(1+g)*c,h*l],k=[g*c,h*l]):u==-90&&(w=h%2==1,A=g*c+v,T=(1+h)*l-(w?p:x),_=[(g+1)*c-m,(w?h:h+1)*l],k=[g*c+v,(w?h:h+1)*l]),console.log(`>> (${h},${g})[${u}] : [${A},${T}] :: [xForeEdgeShift: ${p}][xBindingShift: ${x}]`),d.push({rotation:u,sx:o[0],sy:o[1],x:A,y:T,spineMarkTop:_,spineMarkBottom:k,isLeftPage:w})})}),console.log("And in the end of it all, (calculatelayout) we get: ",d),d}function Lh(r){const{cropbox:e,padding_pt:t,papersize:n,page_layout:i,page_positioning:s,page_scaling:a}=r,{width:o,height:l}=e,c=o+Math.max(t.binding,0)+Math.max(t.fore_edge,0),d=l+Math.max(t.top,0)+Math.max(t.bottom,0);let f=n[0]/i.cols,h=n[1]/i.rows;if(i.landscape){const k=f;f=h,h=k}let u=1,g=1;if(a=="lockratio"){const k=Math.min(f/c,h/d);u=k,g=k}else a=="stretch"&&(u=f/c,g=h/d);const p={fore_edge:t.fore_edge*u,binding:t.binding*u,bottom:t.bottom*g,top:t.top*g},x=s;return{layout:i,rawPdfSize:[o,l],pdfScale:[u,g],pdfSize:[c,d],layoutCell:[f,h],padding:p,xForeEdgeShiftFunc:function(){const k=f-c*u;return p.fore_edge+(x=="centered"?k/2:k)},xBindingShiftFunc:function(){const k=f-c*u;return p.binding+(x=="centered"?k/2:0)},xPdfWidthFunc:function(){return c*u-p.fore_edge-p.binding},yPdfHeightFunc:function(){return d*g-p.top-p.bottom},yTopShiftFunc:function(){const k=h-d*g;return p.top+k/2},yBottomShiftFunc:function(){const k=h-d*g;return p.bottom+k/2},positioning:x}}async function sb(r,e){const t=await Ze.create(),n=Math.max(r.getPageCount(),e.getPageCount()),i=[],s=t.copyPages(r,r.getPageIndices()),a=t.copyPages(e,e.getPageIndices());i.push(s,a);const[o,l]=await Promise.all([s,a]);for(let c=0;ctypeof s=="number");let i=await t.embedPdf(r,e);return n&&(i=i.reduce((s,a,o)=>(s[e[o]]=a,s),[])),[t,i]}class ab{constructor(e){this.inputpdf=null,this.managedDoc=null,this.signatureconfig=[],this.spineoffset=!1,this.input=null,this.currentdoc=null,this.pagecount=null,this.cropbox=null,this.orderedpages=[],this.rearrangedpages=[],this.filelist=[],this.zip=null,this.update(e)}update(e){this.duplex=e.printerType==="duplex",this.duplexrotate=e.rotatePage,this.paper_rotation_90=e.paperRotation90,this.papersize=gi[e.paperSize],e.paperRotation90&&(this.papersize=[this.papersize[1],this.papersize[0]]),this.source_rotation=e.sourceRotation,this.print_file=e.printFile,this.page_scaling=e.pageScaling,this.page_positioning=e.pagePositioning,this.flyleafs=e.flyleafs,this.cropmarks=e.cropMarks,this.sewingMarks={sewingMarkLocation:e.sewingMarkLocation,isEnabled:e.sewingMarksEnabled,amount:e.sewingMarksAmount,marginPt:e.sewingMarksMarginPt,tapeWidthPt:e.sewingMarksTapeWidthPt},this.pdfEdgeMarks=e.pdfEdgeMarks,this.sigOrderMarks=e.sigOrderMarks,this.cutmarks=e.cutMarks,this.format=e.sigFormat,e.sigFormat==="standardsig"&&(this.sigsize=e.sigLength),this.customsig=this.format==="customsig",this.customsig&&(this.signatureconfig=e.customSigLength);const t=vx[e.pageLayout];this.page_layout=t,this.per_sheet=t.per_sheet,this.pack_pages=e.wackySpacing==="wacky_pack",this.fore_edge_padding_pt=e.foreEdgePaddingPt,this.padding_pt={top:e.topEdgePaddingPt,bottom:e.bottomEdgePaddingPt,binding:e.bindingEdgePaddingPt,fore_edge:e.mainForeEdgePaddingPt}}async openpdf(e){this.inputpdf=e.name,this.input=await e.arrayBuffer(),this.currentdoc=await Ze.load(this.input),this.fixBlankPages()}fixBlankPages(){const e=this.currentdoc.getPages();this.cropbox=null,e.forEach(t=>{t.node.Contents()?this.cropbox||(this.cropbox=t.getCropBox()):t.drawLine({start:{x:25,y:26},end:{x:125,y:126},opacity:0})})}createpagelist(){this.pagecount=this.currentdoc.getPageCount(),this.orderedpages=Array.from({length:this.pagecount},(n,i)=>i);for(let n=0;n0){t+=1;const n=t*this.per_sheet-e;for(let i=0;i{const a=n.map(async(o,l)=>{console.log(o),t[l]={name:`${this.filename}_signature${l}`},[t[l].front,t[l].back]=await this.createSignatures({pageIndexDetails:o})});await Promise.all(a)})(),(this.duplex||e)&&(await(async()=>{const o=t.map(async(l,c)=>{t[c].duplex=await sb(l.front,l.back),t[c].back=t[c].front=null});await Promise.all(o)})(),i=t[0].duplex),i}async saveClassicFiles(e){this.print_file!="aggregated"&&await(async()=>{const n=e.map(async i=>{var s,a,o;await((s=i.front)==null?void 0:s.save().then(l=>{this.zip.file(`signatures/${i.name}_side1.pdf`,l)})),await((a=i.back)==null?void 0:a.save().then(l=>{this.zip.file(`signatures/${i.name}_side2.pdf`,l)})),await((o=i.duplex)==null?void 0:o.save().then(l=>{this.zip.file(`signatures/${i.name}_duplex.pdf`,l)}))});await Promise.all(n)})(),this.print_file!="signatures"&&await(async()=>{const n={front:this.duplex?null:await Ze.create(),back:this.duplex?null:await Ze.create(),duplex:this.duplex?await Ze.create():null};for(const i of e)n.front&&(await n.front.copyPages(i.front,i.front.getPageIndices())).forEach(a=>n.front.addPage(a)),n.back&&(await n.back.copyPages(i.back,i.back.getPageIndices())).forEach(a=>n.back.addPage(a)),n.duplex&&(await n.duplex.copyPages(i.duplex,i.duplex.getPageIndices())).forEach(a=>n.duplex.addPage(a));n.front&&await n.front.save().then(i=>{this.zip.file(`${this.filename}_typeset_side1.pdf`,i)}),n.back&&await n.back.save().then(i=>{this.zip.file(`${this.filename}_typeset_side2.pdf`,i)}),n.duplex&&await n.duplex.save().then(i=>{this.zip.file(`${this.filename}_typeset.pdf`,i)})})()}async displayPreview(e){console.log("Attempting to generate preview for ",e);const t=document.getElementById("pdf"),n=await e.saveAsBase64({dataUri:!0}),i=e.catalog.getOrCreateViewerPreferences();i.setHideToolbar(!1),i.setHideMenubar(!1),i.setHideWindowUI(!1),i.setFitWindow(!0),i.setCenterWindow(!0),i.setDisplayDocTitle(!0),t.src=n,t.style.width="450px";const s=this.papersize[1]/this.papersize[0]*500;t.style.height=`${s}px`,t.style.display=""}async writepages(e){const t=e.pageList,n=e.back,i=e.maxSigCount,s=[],a=[];t.forEach((g,p)=>{g.info!="b"?s.push(g.info):a.push(p)});const[o,l]=await Rd(this.managedDoc,s);a.forEach(g=>l.splice(g,0,"b"));let c=0;const d=this.per_sheet/2;let f=d;const h=Od(this);let u=n;for(;f<=t.length;){const g=t.slice(c,f);u=this.draw_block_onto_page({outPDF:o,embeddedPages:l,block_start:c,block_end:f,sigDetails:g,papersize:this.papersize,positions:h,cropmarks:this.cropmarks,sigOrderMarks:this.sigOrderMarks,pdfEdgeMarks:this.pdfEdgeMarks,cutmarks:this.cutmarks,alt:e.alt,side2flag:u,maxSigCount:i,sewingMarks:this.sewingMarks}),c+=d,f+=d}return o}draw_block_onto_page(e){const t=e.sigDetails,n=e.block_start,i=e.block_end,s=e.papersize,a=e.outPDF,o=e.positions,l=e.cropmarks,c=e.sigOrderMarks,d=e.pdfEdgeMarks,f=e.cutmarks,h=e.alt,u=e.maxSigCount;let g=e.side2flag;const p=e.sewingMarks,x=e.embeddedPages.slice(n,i),m=a.addPage(s),v=f?tb(s,this.per_sheet):[],w=l?eb(g,this.duplexrotate,s,this.per_sheet):[],A=[...v,...w],T=[],_=[];return x.forEach((k,C)=>{if(!(k=="b"||k===void 0))if(k instanceof ps){const{y:O,x:P,sx:E,sy:R,rotation:b}=o[C];m.drawPage(k,{y:O,x:P,xScale:E,yScale:R,rotate:pe(b)})}else console.error("Unexpected type for page: ",k);t[C].isSigStart?(d&&A.push(Ja(!0,o[C],5)),c&&T.push(nb(t[C],o[C],u,5,20))):t[C].isSigEnd&&d&&A.push(Ja(!1,o[C],5));const S=p.isEnabled?rb(t[C],o[C],p.sewingMarkLocation,p.amount,p.marginPt,p.tapeWidthPt):[];_.push(...S)}),A.forEach(k=>{m.drawLine(k)}),T.forEach(k=>{m.drawRectangle(k)}),_.forEach(k=>{m.drawCircle(k)}),h&&(g=!g),g}async createSignatures(e){const t=e.pageIndexDetails,n=[this.writepages({pageList:t[0],back:!1,alt:!1,maxSigCount:e.maxSigCount}),this.writepages({pageList:t[1],back:!0,alt:!1,maxSigCount:e.maxSigCount})],[i,s]=await Promise.all(n);return[i,s]}bundleSettings(){const e=Nh(),t=`Imposer settings: ${JSON.stringify(e,null,2)} -Link to the imposer with these settings: ${window.location.href}`;this.zip.file("settings.txt",t)}saveZip(){return console.log("Saving zip... "),this.bundleSettings(),this.zip.generateAsync({type:"blob"}).then(e=>{console.log(" calling saveAs on ",this.filename),yx.saveAs(e,`${this.filename}_bookbinder.zip`)})}async buildSheets(e,t){const n=t.sheetMaker(this.pagecount),i=t.lineMaker();console.log("Working with the sheet descritpion: ",n);const s=await Ze.create(),a=await Ze.create();for(let o=0;o{console.log("Calling zip.file on ",o),this.zip.file(o,l)}),this.filelist.push(o)}if(!this.duplex){console.log("Trying to save to PDF (back pages)");const o=`${e}_${t.fileNameMod}_backs.pdf`;await a.save().then(l=>{console.log("Calling zip.file on ",o),this.zip.file(o,l)}),this.filelist.push(o)}return console.log("buildSheets complete"),s}async write_single_page(e,t,n,i,s,a){const o=[];if(console.log(s),s=s.filter(C=>!i||C.filter(S=>S.isBlank==!1).length>0),console.log(s),console.log(`Hitting that write_single_page : isPacked[${this.pack_pages}] || (front ${n}/ first ${i}) [${s.length},${s[0].length}]`),s.forEach(C=>{C.forEach(S=>{S.isBlank||o.push(S.num)})}),o.length==0){console.warn("All the pages are empty! : ",s);return}const l=await e.embedPdf(this.managedDoc,o),c=t?[this.papersize[1],this.papersize[0]]:[this.papersize[0],this.papersize[1]],d=e.addPage(c),f=l.slice(0,1)[0],h=c[1]/s.length,u=c[0]/s[0].length,g=h/f.height,p=u/(f.width+this.fore_edge_padding_pt),x=Math.min(g,p),m=c[1]-f.height*x*s.length,v=this.pack_pages?m/2:m/(s.length*2),w=c[0]-(f.width+this.fore_edge_padding_pt)*x*s[0].length,A=this.pack_pages?w/2:w/s[0].length,T=x*f.width,_=x*f.height,k=x*this.fore_edge_padding_pt;for(let C=0;C{d.drawLine(C)})}}function ob(r,e){const t=new FormData(e),n=q1(t);r.update(n),sl(),xo(),r.inputpdf&&zh(r)}function cb(r,e){Ih();const t=r.target.files;t.length>0&&e.openpdf(t[0]).then(()=>zh(e))}window.addEventListener("DOMContentLoaded",()=>{X1();const r=Bh(),e=document.getElementById("generate"),t=document.getElementById("preview"),n=document.getElementById("reset_settings"),i=document.getElementById("bookbinder"),s=document.getElementById("input_file"),a=document.querySelectorAll("input, select"),o=document.getElementById("source_rotation"),l=document.getElementById("add_sewing_marks_checkbox"),c=Array.from(document.getElementsByClassName("source_rotation_example")),d=new ab(r);a.forEach(f=>{f.addEventListener("change",()=>ob(d,i))}),s.addEventListener("change",f=>{cb(f,d),e.removeAttribute("disabled"),t.removeAttribute("disabled")}),e.addEventListener("click",()=>V1(e,d)),t.addEventListener("click",()=>W1(t,d)),n.addEventListener("click",()=>{console.log("Resetting settings..."),H1(d)}),o.addEventListener("change",f=>{const h=`${f.target.value}_example`;c.forEach(u=>{u.style.display=u.id===h?"block":"none"})}),l.addEventListener("change",f=>{const h=f.srcElement.checked;Nh(h)})}); +Link to the imposer with these settings: ${window.location.href}`;this.zip.file("settings.txt",t)}saveZip(){return console.log("Saving zip... "),this.bundleSettings(),this.zip.generateAsync({type:"blob"}).then(e=>{console.log(" calling saveAs on ",this.filename),yx.saveAs(e,`${this.filename}_bookbinder.zip`)})}async buildSheets(e,t){const n=t.sheetMaker(this.pagecount),i=t.lineMaker();console.log("Working with the sheet descritpion: ",n);const s=await Ze.create(),a=await Ze.create();for(let o=0;o{console.log("Calling zip.file on ",o),this.zip.file(o,l)}),this.filelist.push(o)}if(!this.duplex){console.log("Trying to save to PDF (back pages)");const o=`${e}_${t.fileNameMod}_backs.pdf`;await a.save().then(l=>{console.log("Calling zip.file on ",o),this.zip.file(o,l)}),this.filelist.push(o)}return console.log("buildSheets complete"),s}async write_single_page(e,t,n,i,s,a){const o=[];if(console.log(s),s=s.filter(C=>!i||C.filter(S=>S.isBlank==!1).length>0),console.log(s),console.log(`Hitting that write_single_page : isPacked[${this.pack_pages}] || (front ${n}/ first ${i}) [${s.length},${s[0].length}]`),s.forEach(C=>{C.forEach(S=>{S.isBlank||o.push(S.num)})}),o.length==0){console.warn("All the pages are empty! : ",s);return}const l=await e.embedPdf(this.managedDoc,o),c=t?[this.papersize[1],this.papersize[0]]:[this.papersize[0],this.papersize[1]],d=e.addPage(c),f=l.slice(0,1)[0],h=c[1]/s.length,u=c[0]/s[0].length,g=h/f.height,p=u/(f.width+this.fore_edge_padding_pt),x=Math.min(g,p),m=c[1]-f.height*x*s.length,v=this.pack_pages?m/2:m/(s.length*2),w=c[0]-(f.width+this.fore_edge_padding_pt)*x*s[0].length,A=this.pack_pages?w/2:w/s[0].length,T=x*f.width,_=x*f.height,k=x*this.fore_edge_padding_pt;for(let C=0;C{d.drawLine(C)})}}function ob(r,e){const t=new FormData(e),n=Q1(t);r.update(n),sl(),xo(),r.inputpdf&&Ih(r)}function cb(r,e){Dh();const t=r.target.files;t.length>0&&e.openpdf(t[0]).then(()=>Ih(e))}window.addEventListener("DOMContentLoaded",()=>{H1();const r=Mh(),e=document.getElementById("generate"),t=document.getElementById("preview"),n=document.getElementById("reset_settings"),i=document.getElementById("bookbinder"),s=document.getElementById("input_file"),a=document.querySelectorAll("input, select"),o=document.getElementById("source_rotation"),l=document.getElementById("add_sewing_marks_checkbox"),c=Array.from(document.getElementsByClassName("source_rotation_example")),d=new ab(r);a.forEach(f=>{f.addEventListener("change",()=>ob(d,i))}),s.addEventListener("change",f=>{cb(f,d),e.removeAttribute("disabled"),t.removeAttribute("disabled")}),e.addEventListener("click",()=>L1(e,d)),t.addEventListener("click",()=>U1(t,d)),n.addEventListener("click",()=>{console.log("Resetting settings..."),q1(d)}),o.addEventListener("change",f=>{const h=`${f.target.value}_example`;c.forEach(u=>{u.style.display=u.id===h?"block":"none"})}),l.addEventListener("change",f=>{const h=f.srcElement.checked;Ph(h)})}); diff --git a/pr-preview/pr-116/index.html b/pr-preview/pr-116/index.html index eb36434..ef246ff 100644 --- a/pr-preview/pr-116/index.html +++ b/pr-preview/pr-116/index.html @@ -11,7 +11,7 @@ - +