@stacksjs/error-handling 0.68.0 → 0.68.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,16 @@
1
1
  export {
2
+ err,
3
+ Err,
4
+ errAsync,
5
+ fromPromise,
6
+ fromSafePromise,
7
+ fromThrowable,
8
+ ok,
9
+ Ok,
10
+ okAsync,
11
+ Result,
12
+ ResultAsync,
13
+ } from 'neverthrow'
2
14
  export * from './handler'
3
15
  export * from './http'
4
16
  export * from './utils'
package/dist/index.js CHANGED
@@ -118,4 +118,4 @@ function moveProperties(source, destination, ignoreKeys) {
118
118
  }
119
119
  };`}function e6($){return`const REQUIRED = '${$.required}';
120
120
  const NOT_AN_OBJECT = '${$.object}';
121
- const NOT_AN_ARRAY = '${$.array}';`}var $4=Object.getPrototypeOf(async function(){}).constructor,m2=class{variablesCounter=0;#$;#g;#Y=new T6;constructor($,g){this.#$=$,this.#g=g||{convertEmptyStringsToNull:!1}}#M(){this.#Y.writeStatement(e6({required:"value is required",object:"value is not a valid object",array:"value is not a valid array",...this.#g.messages})),this.#Y.writeStatement(o6(this.#g)),this.#Y.writeStatement("let out;")}#Z(){this.#Y.writeStatement(a6()),this.#Y.writeStatement("return out;")}#J(){this.compileNode(this.#$.schema,this.#Y,{type:"root",variableName:"root",outputExpression:"out",fieldPathExpression:"out",wildCardPath:""})}#z(){return new $4("root","meta","refs","messagesProvider","errorReporter",this.#Y.toString())}createFieldFor($,g){switch(g.type){case"array":return p6(g);case"root":return n6(g);case"object":return l6($,this.variablesCounter,g);case"tuple":return s6($,g);case"record":return i6(g)}}compileNode($,g,Y,M){switch($.type){case"literal":return new d6($,g,this,Y,M).compile();case"array":return new R6($,g,this,Y,M).compile();case"record":return new f6($,g,this,Y,M).compile();case"object":return new r6($,g,this,Y,M).compile();case"tuple":return new N6($,g,this,Y,M).compile();case"union":return new c6($,g,this,Y,M).compile()}}compile(){this.#M(),this.#J(),this.#Z();let $=this.#z();return this.variablesCounter=0,this.#Y.flush(),$}};function f2(){let $=0,g={};return{toJSON(){return g},track(Y){$++;let M=`ref://${$}`;return g[M]=Y,M},trackValidation(Y){return this.track(Y)},trackParser(Y){return this.track(Y)},trackTransformer(Y){return this.track(Y)},trackConditional(Y){return this.track(Y)}}}function W($,g){let Y={validator:$,isAsync:g?.isAsync||$.constructor.name==="AsyncFunction",implicit:g?.implicit??!1};return function(...M){return{rule:Y,options:M[0]}}}var M9={};J0(M9,{COTYPE:()=>M4,IS_OF_TYPE:()=>C$,ITYPE:()=>g4,OTYPE:()=>Y4,PARSE:()=>E,UNIQUE_NAME:()=>Z$,VALIDATION:()=>E$});var Z$=Symbol.for("schema_name"),C$=Symbol.for("is_of_type"),E=Symbol.for("parse"),g4=Symbol.for("opaque_input_type"),Y4=Symbol.for("opaque_type"),M4=Symbol.for("camelcase_opaque_type"),E$=Symbol.for("to_validation"),h$=W(($,g,Y)=>{let M=g(Y);if(!Y.isDefined&&M)Y.report(X.required,"required",Y)},{implicit:!0}),v0=class extends y${optional($){return new J4(this,$)}nullable(){return new Z4(this)}transform($){return new z4($,this)}},Z4=class $ extends v0{#$;constructor(g){super();this.#$=g}clone(){return new $(this.#$.clone())}[E](g,Y,M){let Z=this.#$[E](g,Y,M);return Z.allowNull=!0,Z}},J4=class $ extends v0{#$;validations;constructor(g,Y){super();this.#$=g,this.validations=Y||[]}cloneValidations(){return this.validations.map((g)=>{return{options:g.options,rule:g.rule}})}compileValidations(g){return this.validations.map((Y)=>{return{ruleFnId:g.track({validator:Y.rule.validator,options:Y.options}),implicit:Y.rule.implicit,isAsync:Y.rule.isAsync}})}use(g){return this.validations.push(E$ in g?g[E$]():g),this}requiredWhen(g,Y,M){if(typeof g==="function")return this.use(h$(g));let Z;switch(Y){case"=":Z=(J)=>J===M;break;case"!=":Z=(J)=>J!==M;break;case"in":Z=(J)=>M.includes(J);break;case"notIn":Z=(J)=>!M.includes(J);break;case">":Z=(J)=>J>M;break;case"<":Z=(J)=>J<M;break;case">=":Z=(J)=>J>=M;break;case"<=":Z=(J)=>J<=M}return this.use(h$((J)=>{let z=B.getNestedValue(g,J);return Z(z)}))}requiredIfExists(g){let Y=Array.isArray(g)?g:[g];return this.use(h$((M)=>{return Y.every((Z)=>B.exists(B.getNestedValue(Z,M)))}))}requiredIfAnyExists(g){return this.use(h$((Y)=>{return g.some((M)=>B.exists(B.getNestedValue(M,Y)))}))}requiredIfMissing(g){let Y=Array.isArray(g)?g:[g];return this.use(h$((M)=>{return Y.every((Z)=>B.isMissing(B.getNestedValue(Z,M)))}))}requiredIfAnyMissing(g){return this.use(h$((Y)=>{return g.some((M)=>B.isMissing(B.getNestedValue(M,Y)))}))}clone(){return new $(this.#$.clone(),this.cloneValidations())}[E](g,Y,M){let Z=this.#$[E](g,Y,M);return Z.isOptional=!0,Z.validations=Z.validations.concat(this.compileValidations(Y)),Z}},z4=class $ extends v0{#$;#g;constructor(g,Y){super();this.#g=g,this.#$=Y}clone(){return new $(this.#g,this.#$.clone())}[E](g,Y,M){let Z=this.#$[E](g,Y,M);return Z.transformFnId=Y.trackTransformer(this.#g),Z}},x$=class extends v0{options;validations;constructor($,g){super();this.options={bail:!0,allowNull:!1,isOptional:!1,...$},this.validations=g||[]}cloneValidations(){return this.validations.map(($)=>{return{options:$.options,rule:$.rule}})}cloneOptions(){return{...this.options}}compileValidations($){return this.validations.map((g)=>{return{ruleFnId:$.track({validator:g.rule.validator,options:g.options}),implicit:g.rule.implicit,isAsync:g.rule.isAsync}})}parse($){return this.options.parse=$,this}use($){return this.validations.push(E$ in $?$[E$]():$),this}bail($){return this.options.bail=$,this}[E]($,g,Y){return{type:"literal",fieldName:$,propertyName:Y.toCamelCase?p($):$,bail:this.options.bail,allowNull:this.options.allowNull,isOptional:this.options.isOptional,parseFnId:this.options.parse?g.trackParser(this.options.parse):void 0,validations:this.compileValidations(g)}}},Z9=class $ extends x${constructor(g,Y){super(g,Y)}clone(){return new $(this.cloneOptions(),this.cloneValidations())}},f0=W(($,g,Y)=>{let M=typeof g.choices==="function"?g.choices(Y):g.choices;if(!M.includes($))Y.report(X.enum,"enum",Y,{choices:M})}),R$=class $ extends x${static rules={enum:f0};#$;getChoices(){return this.#$}constructor(g,Y,M){super(Y,M||[f0({choices:g})]);this.#$=g}clone(){return new $(this.#$,this.cloneOptions(),this.cloneValidations())}},I$=["YYYY-MM-DD","YYYY-MM-DD HH:mm:ss"];b.default.extend(K9.default);b.default.extend(z9.default);b.default.extend(H9.default);var H4=W(($,g,Y)=>{if(typeof $!=="string"&&typeof $!=="number"){Y.report(X.date,"date",Y);return}let M=!1,Z=g.formats||I$;if(Array.isArray(Z))Z=[...Z],M=Z.includes("x");else if(typeof Z!=="string")Z={...Z},M=Z.format==="x";let J=M?B.asNumber($):$,z=M&&!Number.isNaN(J)?b.default(J):b.default($,Z,!0);if(!z.isValid()){Y.report(X.date,"date",Y);return}Y.meta.$value=z,Y.meta.$formats=Z,Y.mutate(z.toDate(),Y)}),v2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=g.format||I$,J=Y.meta.$value,z=typeof g.expectedValue==="function"?g.expectedValue(Y):g.expectedValue,H=b.default(z,Z,!0);if(!H.isValid())throw new Error(`Invalid datetime value "${z}" value provided to the equals rule`);if(!J.isSame(H,M))Y.report(X["date.equals"],"date.equals",Y,{expectedValue:z,compare:M})}),u2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=g.format||I$,J=Y.meta.$value,z=typeof g.expectedValue==="function"?g.expectedValue(Y):g.expectedValue,H=z==="today"?b.default():z==="tomorrow"?b.default().add(1,"day"):b.default(z,Z,!0);if(!H.isValid())throw new Error(`Invalid datetime value "${z}" value provided to the after rule`);if(!J.isAfter(H,M))Y.report(X["date.after"],"date.after",Y,{expectedValue:z,compare:M})}),r2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=g.format||I$,J=Y.meta.$value,z=typeof g.expectedValue==="function"?g.expectedValue(Y):g.expectedValue,H=z==="today"?b.default():z==="tomorrow"?b.default().add(1,"day"):b.default(z,Z,!0);if(!H.isValid())throw new Error(`Invalid datetime value "${z}" value provided to the afterOrEqual rule`);if(!J.isSameOrAfter(H,M))Y.report(X["date.afterOrEqual"],"date.afterOrEqual",Y,{expectedValue:z,compare:M})}),n2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=g.format||I$,J=Y.meta.$value,z=typeof g.expectedValue==="function"?g.expectedValue(Y):g.expectedValue,H=z==="today"?b.default():z==="yesterday"?b.default().subtract(1,"day"):b.default(z,Z,!0);if(!H.isValid())throw new Error(`Invalid datetime value "${z}" value provided to the before rule`);if(!J.isBefore(H,M))Y.report(X["date.before"],"date.before",Y,{expectedValue:z,compare:M})}),t2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=g.format||I$,J=Y.meta.$value,z=typeof g.expectedValue==="function"?g.expectedValue(Y):g.expectedValue,H=z==="today"?b.default():z==="yesterday"?b.default().subtract(1,"day"):b.default(z,Z,!0);if(!H.isValid())throw new Error(`Invalid datetime value "${z}" value provided to the beforeOrEqual rule`);if(!J.isSameOrBefore(H,M))Y.report(X["date.beforeOrEqual"],"date.beforeOrEqual",Y,{expectedValue:z,compare:M})}),d2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(!Z.isSame(H,M))Y.report(X["date.sameAs"],"date.sameAs",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),p2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(Z.isSame(H,M))Y.report(X["date.notSameAs"],"date.notSameAs",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),s2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(!Z.isAfter(H,M))Y.report(X["date.afterField"],"date.afterField",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),a2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(!Z.isSameOrAfter(H,M))Y.report(X["date.afterOrSameAs"],"date.afterOrSameAs",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),l2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(!Z.isBefore(H,M))Y.report(X["date.beforeField"],"date.beforeField",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),i2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(!Z.isSameOrBefore(H,M))Y.report(X["date.beforeOrSameAs"],"date.beforeOrSameAs",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),o2=W(($,g,Y)=>{if(!Y.meta.$value)return;let Z=Y.meta.$value.day();if(Z!==0&&Z!==6)Y.report(X["date.weekend"],"date.weekend",Y)}),e2=W(($,g,Y)=>{if(!Y.meta.$value)return;let Z=Y.meta.$value.day();if(Z===0||Z===6)Y.report(X["date.weekday"],"date.weekday",Y)}),t1=class $ extends x${static rules={equals:v2,after:u2,afterOrEqual:r2,before:n2,beforeOrEqual:t2,sameAs:d2,notSameAs:p2,afterField:s2,afterOrSameAs:a2,beforeField:l2,beforeOrSameAs:i2,weekend:o2,weekday:e2};[Z$]="vine.date";[C$]=(g)=>{if(typeof g!=="string")return!1;return J9.default(g,this.options.formats||I$,!0).isValid()};constructor(g,Y){super(g,Y||[H4(g||{})])}equals(g,Y){return this.use(v2({expectedValue:g,...Y}))}after(g,Y){return this.use(u2({expectedValue:g,...Y}))}afterOrEqual(g,Y){return this.use(r2({expectedValue:g,...Y}))}before(g,Y){return this.use(n2({expectedValue:g,...Y}))}beforeOrEqual(g,Y){return this.use(t2({expectedValue:g,...Y}))}sameAs(g,Y){return this.use(d2({otherField:g,...Y}))}notSameAs(g,Y){return this.use(p2({otherField:g,...Y}))}afterField(g,Y){return this.use(s2({otherField:g,...Y}))}afterOrSameAs(g,Y){return this.use(a2({otherField:g,...Y}))}beforeField(g,Y){return this.use(l2({otherField:g,...Y}))}beforeOrSameAs(g,Y){return this.use(i2({otherField:g,...Y}))}weekend(){return this.use(o2())}weekday(){return this.use(e2())}clone(){return new $(this.cloneOptions(),this.cloneValidations())}},C9=class ${#$;#g=(g,Y)=>{Y.report(X.union,"union",Y)};constructor(g){this.#$=g}otherwise(g){return this.#g=g,this}clone(){let g=new $(this.#$);return g.otherwise(this.#g),g}[E](g,Y,M){return{type:"union",fieldName:g,propertyName:M.toCamelCase?p(g):g,elseConditionalFnRefId:Y.trackConditional(this.#g),conditions:this.#$.map((Z)=>Z[E](g,Y,M))}}},X9=class{#$;#g;constructor($,g){this.#$=g,this.#g=$}[E]($,g,Y){return{conditionalFnRefId:g.trackConditional(this.#g),schema:this.#$[E]($,g,Y)}}};function d1($){return new C9($)}d1.if=function $(g,Y){return new X9(g,Y)};d1.else=function $(g){return new X9(()=>!0,g)};var l$=class extends y${optional(){return new C4(this)}nullable(){return new K4(this)}},K4=class $ extends l${#$;constructor(g){super();this.#$=g}clone(){return new $(this.#$.clone())}[E](g,Y,M){let Z=this.#$[E](g,Y,M);if(Z.type!=="union")Z.allowNull=!0;return Z}},C4=class $ extends l${#$;constructor(g){super();this.#$=g}clone(){return new $(this.#$.clone())}[E](g,Y,M){let Z=this.#$[E](g,Y,M);if(Z.type!=="union")Z.isOptional=!0;return Z}},i$=class extends l${options;validations;constructor($,g){super();this.options=$||{bail:!0,allowNull:!1,isOptional:!1},this.validations=g||[]}cloneValidations(){return this.validations.map(($)=>{return{options:$.options,rule:$.rule}})}cloneOptions(){return{...this.options}}compileValidations($){return this.validations.map((g)=>{return{ruleFnId:$.track({validator:g.rule.validator,options:g.options}),implicit:g.rule.implicit,isAsync:g.rule.isAsync}})}parse($){return this.options.parse=$,this}use($){return this.validations.push(E$ in $?$[E$]():$),this}bail($){return this.options.bail=$,this}},W9=class $ extends i${#$;#g=!1;[Z$]="vine.array";[C$]=(g)=>{return Array.isArray(g)};constructor(g,Y,M){super(Y,M);this.#$=g}allowUnknownProperties(){return this.#g=!0,this}clone(){let g=new $(this.#$.map((Y)=>Y.clone()),this.cloneOptions(),this.cloneValidations());if(this.#g)g.allowUnknownProperties();return g}[E](g,Y,M){return{type:"tuple",fieldName:g,propertyName:M.toCamelCase?p(g):g,bail:this.options.bail,allowNull:this.options.allowNull,isOptional:this.options.isOptional,allowUnknownProperties:this.#g,parseFnId:this.options.parse?Y.trackParser(this.options.parse):void 0,validations:this.compileValidations(Y),properties:this.#$.map((Z,J)=>Z[E](String(J),Y,M))}}},$Y=W(($,g,Y)=>{if(!Y.isValid)return;if($.length<g.min)Y.report(X["array.minLength"],"array.minLength",Y,g)}),gY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length>g.max)Y.report(X["array.maxLength"],"array.maxLength",Y,g)}),YY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length!==g.size)Y.report(X["array.fixedLength"],"array.fixedLength",Y,g)}),MY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length<=0)Y.report(X.notEmpty,"notEmpty",Y)}),ZY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isDistinct($,g.fields))Y.report(X.distinct,"distinct",Y,g)}),JY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate($.filter((M)=>B.exists(M)&&M!==""),Y)}),Q9=class $ extends i${static rules={compact:JY,notEmpty:MY,distinct:ZY,minLength:$Y,maxLength:gY,fixedLength:YY};#$;[Z$]="vine.array";[C$]=(g)=>{return Array.isArray(g)};constructor(g,Y,M){super(Y,M);this.#$=g}minLength(g){return this.use($Y({min:g}))}maxLength(g){return this.use(gY({max:g}))}fixedLength(g){return this.use(YY({size:g}))}notEmpty(){return this.use(MY())}distinct(g){return this.use(ZY({fields:g}))}compact(){return this.use(JY())}clone(){return new $(this.#$.clone(),this.cloneOptions(),this.cloneValidations())}[E](g,Y,M){return{type:"array",fieldName:g,propertyName:M.toCamelCase?p(g):g,bail:this.options.bail,allowNull:this.options.allowNull,isOptional:this.options.isOptional,each:this.#$[E]("*",Y,M),parseFnId:this.options.parse?Y.trackParser(this.options.parse):void 0,validations:this.compileValidations(Y)}}},X4=class $ extends l${#$;[Z$]="types.object";[C$]=(g)=>{return g!==null&&typeof g==="object"&&!Array.isArray(g)};constructor(g){super();this.#$=g}clone(){return new $(this.#$.clone())}[E](g,Y,M){return M.toCamelCase=!0,this.#$[E](g,Y,M)}},q9=class $ extends i${#$;#g=[];#Y=!1;[Z$]="vine.object";[C$]=(g)=>{return g!==null&&typeof g==="object"&&!Array.isArray(g)};constructor(g,Y,M){super(Y,M);this.#$=g}getProperties(){return Object.keys(this.#$).reduce((g,Y)=>{return g[Y]=this.#$[Y].clone(),g},{})}allowUnknownProperties(){return this.#Y=!0,this}merge(g){return this.#g.push(g),this}clone(){let g=new $(this.getProperties(),this.cloneOptions(),this.cloneValidations());if(this.#g.forEach((Y)=>g.merge(Y)),this.#Y)g.allowUnknownProperties();return g}toCamelCase(){return new X4(this)}[E](g,Y,M){return{type:"object",fieldName:g,propertyName:M.toCamelCase?p(g):g,bail:this.options.bail,allowNull:this.options.allowNull,isOptional:this.options.isOptional,parseFnId:this.options.parse?Y.trackParser(this.options.parse):void 0,allowUnknownProperties:this.#Y,validations:this.compileValidations(Y),properties:Object.keys(this.#$).map((Z)=>{return this.#$[Z][E](Z,Y,M)}),groups:this.#g.map((Z)=>{return Z[E](Y,M)})}}},zY=W(($,g,Y)=>{if(!Y.isValid)return;if(Object.keys($).length<g.min)Y.report(X["record.minLength"],"record.minLength",Y,g)}),HY=W(($,g,Y)=>{if(!Y.isValid)return;if(Object.keys($).length>g.max)Y.report(X["record.maxLength"],"record.maxLength",Y,g)}),KY=W(($,g,Y)=>{if(!Y.isValid)return;if(Object.keys($).length!==g.size)Y.report(X["record.fixedLength"],"record.fixedLength",Y,g)}),CY=W(($,g,Y)=>{if(!Y.isValid)return;g(Object.keys($),Y)}),O9=class $ extends i${static rules={maxLength:HY,minLength:zY,fixedLength:KY,validateKeys:CY};#$;[Z$]="vine.object";[C$]=(g)=>{return g!==null&&typeof g==="object"&&!Array.isArray(g)};constructor(g,Y,M){super(Y,M);this.#$=g}minLength(g){return this.use(zY({min:g}))}maxLength(g){return this.use(HY({max:g}))}fixedLength(g){return this.use(KY({size:g}))}validateKeys(...g){return this.use(CY(...g))}clone(){return new $(this.#$.clone(),this.cloneOptions(),this.cloneValidations())}[E](g,Y,M){return{type:"record",fieldName:g,propertyName:M.toCamelCase?p(g):g,bail:this.options.bail,allowNull:this.options.allowNull,isOptional:this.options.isOptional,each:this.#$[E]("*",Y,M),parseFnId:this.options.parse?Y.trackParser(this.options.parse):void 0,validations:this.compileValidations(Y)}}},XY=W(($,g,Y)=>{if(typeof $!=="string")Y.report(X.string,"string",Y)}),WY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isEmail($,g))Y.report(X.email,"email",Y)}),QY=W(($,g,Y)=>{if(!Y.isValid)return;let M=g&&typeof g==="function"?g(Y):g,Z=M?.locale||"any";if(!B.isMobilePhone($,Z,M))Y.report(X.mobile,"mobile",Y)}),qY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isIP($,g?.version))Y.report(X.ipAddress,"ipAddress",Y)}),OY=W(($,g,Y)=>{if(!Y.isValid)return;if(!g.test($))Y.report(X.regex,"regex",Y)}),xY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isHexColor($))Y.report(X.hexCode,"hexCode",Y)}),GY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isURL($,g))Y.report(X.url,"url",Y)}),DY=W(async($,g,Y)=>{if(!Y.isValid)return;if(!await B.isActiveURL($))Y.report(X.activeUrl,"activeUrl",Y)}),UY=W(($,g,Y)=>{if(!Y.isValid)return;let M="a-zA-Z";if(g){if(g.allowSpaces)M+="\\s";if(g.allowDashes)M+="-";if(g.allowUnderscores)M+="_"}if(!new RegExp(`^[${M}]+\$`).test($))Y.report(X.alpha,"alpha",Y)}),LY=W(($,g,Y)=>{if(!Y.isValid)return;let M="a-zA-Z0-9";if(g){if(g.allowSpaces)M+="\\s";if(g.allowDashes)M+="-";if(g.allowUnderscores)M+="_"}if(!new RegExp(`^[${M}]+\$`).test($))Y.report(X.alphaNumeric,"alphaNumeric",Y)}),BY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length<g.min)Y.report(X.minLength,"minLength",Y,g)}),wY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length>g.max)Y.report(X.maxLength,"maxLength",Y,g)}),SY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length!==g.size)Y.report(X.fixedLength,"fixedLength",Y,g)}),PY=W(($,g,Y)=>{if(!Y.isValid)return;if(!$.endsWith(g.substring))Y.report(X.endsWith,"endsWith",Y,g)}),kY=W(($,g,Y)=>{if(!Y.isValid)return;if(!$.startsWith(g.substring))Y.report(X.startsWith,"startsWith",Y,g)}),AY=W(($,g,Y)=>{if(!Y.isValid)return;if(B.getNestedValue(g.otherField,Y)!==$){Y.report(X.sameAs,"sameAs",Y,g);return}}),FY=W(($,g,Y)=>{if(!Y.isValid)return;if(B.getNestedValue(g.otherField,Y)===$){Y.report(X.notSameAs,"notSameAs",Y,g);return}}),VY=W(($,g,Y)=>{if(!Y.isValid)return;let M=g?.confirmationField||`${Y.name}_confirmation`;if(Y.parent[M]!==$){Y.report(X.confirmed,"confirmed",Y,{otherField:M});return}}),EY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate($.trim(),Y)}),IY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate(G9.default.default($,g),Y)}),TY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate($.toLocaleUpperCase(g),Y)}),jY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate($.toLocaleLowerCase(g),Y)}),_Y=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate(p($),Y)}),yY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate(x9.default.default($),Y)}),NY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate(v1($,g),Y)}),hY=W(($,g,Y)=>{if(!Y.isValid)return;if(!(typeof g.choices==="function"?g.choices(Y):g.choices).includes($)){Y.report(X.in,"in",Y,g);return}}),RY=W(($,g,Y)=>{if(!Y.isValid)return;if((typeof g.list==="function"?g.list(Y):g.list).includes($)){Y.report(X.notIn,"notIn",Y,g);return}}),bY=W(($,g,Y)=>{if(!Y.isValid)return;let M=g?typeof g==="function"?g(Y)?.provider||[]:g.provider:[];if(!M.length){if(!B.isCreditCard($))Y.report(X.creditCard,"creditCard",Y,{providersList:"credit"})}else if(!M.find((J)=>B.isCreditCard($,{provider:J})))Y.report(X.creditCard,"creditCard",Y,{providers:M,providersList:M.join("/")})}),cY=W(($,g,Y)=>{if(!Y.isValid)return;let M=typeof g==="function"?g(Y).countryCode:g.countryCode;if(!M.find((J)=>B.isPassportNumber($,J)))Y.report(X.passport,"passport",Y,{countryCodes:M})}),mY=W(($,g,Y)=>{if(!Y.isValid)return;let M=g?typeof g==="function"?g(Y)?.countryCode||[]:g.countryCode:[];if(!M.length){if(!B.isPostalCode($,"any"))Y.report(X.postalCode,"postalCode",Y)}else if(!M.find((J)=>B.isPostalCode($,J)))Y.report(X.postalCode,"postalCode",Y,{countryCodes:M})}),fY=W(($,g,Y)=>{if(!Y.isValid)return;if(!g||!g.version){if(!B.isUUID($))Y.report(X.uuid,"uuid",Y)}else if(!g.version.find((Z)=>B.isUUID($,Z)))Y.report(X.uuid,"uuid",Y,g)}),vY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isAscii($))Y.report(X.ascii,"ascii",Y)}),uY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isIBAN($))Y.report(X.iban,"iban",Y)}),rY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isJWT($))Y.report(X.jwt,"jwt",Y)}),nY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isLatLong($))Y.report(X.coordinates,"coordinates",Y)}),u0=class $ extends x${static rules={in:hY,jwt:rY,url:GY,iban:uY,uuid:fY,trim:EY,email:WY,alpha:UY,ascii:vY,notIn:RY,regex:OY,escape:yY,sameAs:AY,mobile:QY,string:XY,hexCode:xY,passport:cY,endsWith:PY,confirmed:VY,activeUrl:DY,minLength:BY,notSameAs:FY,maxLength:wY,ipAddress:qY,creditCard:bY,postalCode:mY,startsWith:kY,toUpperCase:TY,toLowerCase:jY,toCamelCase:_Y,fixedLength:SY,coordinates:nY,normalizeUrl:NY,alphaNumeric:LY,normalizeEmail:IY};[Z$]="vine.string";[C$]=(g)=>{return typeof g==="string"};constructor(g,Y){super(g,Y||[XY()])}url(...g){return this.use(GY(...g))}activeUrl(){return this.use(DY())}email(...g){return this.use(WY(...g))}mobile(...g){return this.use(QY(...g))}ipAddress(g){return this.use(qY(g?{version:g}:void 0))}hexCode(){return this.use(xY())}regex(g){return this.use(OY(g))}alpha(g){return this.use(UY(g))}alphaNumeric(g){return this.use(LY(g))}minLength(g){return this.use(BY({min:g}))}maxLength(g){return this.use(wY({max:g}))}fixedLength(g){return this.use(SY({size:g}))}confirmed(g){return this.use(VY(g))}trim(){return this.use(EY())}normalizeEmail(g){return this.use(IY(g))}toUpperCase(){return this.use(TY())}toLowerCase(){return this.use(jY())}toCamelCase(){return this.use(_Y())}escape(){return this.use(yY())}normalizeUrl(...g){return this.use(NY(...g))}startsWith(g){return this.use(kY({substring:g}))}endsWith(g){return this.use(PY({substring:g}))}sameAs(g){return this.use(AY({otherField:g}))}notSameAs(g){return this.use(FY({otherField:g}))}in(g){return this.use(hY({choices:g}))}notIn(g){return this.use(RY({list:g}))}creditCard(...g){return this.use(bY(...g))}passport(...g){return this.use(cY(...g))}postalCode(...g){return this.use(mY(...g))}uuid(...g){return this.use(fY(...g))}ascii(){return this.use(vY())}iban(){return this.use(uY())}jwt(){return this.use(rY())}coordinates(){return this.use(nY())}clone(){return new $(this.cloneOptions(),this.cloneValidations())}},tY=W(($,g,Y)=>{let M=g.strict?$:B.asNumber($);if(typeof M!=="number"||Number.isNaN(M)||M===Number.POSITIVE_INFINITY||M===Number.NEGATIVE_INFINITY){Y.report(X.number,"number",Y);return}Y.mutate(M,Y)}),dY=W(($,g,Y)=>{if(!Y.isValid)return;if($<g.min)Y.report(X.min,"min",Y,g)}),pY=W(($,g,Y)=>{if(!Y.isValid)return;if($>g.max)Y.report(X.max,"max",Y,g)}),sY=W(($,g,Y)=>{if(!Y.isValid)return;if($<g.min||$>g.max)Y.report(X.range,"range",Y,g)}),aY=W(($,g,Y)=>{if(!Y.isValid)return;if($<0)Y.report(X.positive,"positive",Y)}),lY=W(($,g,Y)=>{if(!Y.isValid)return;if($>=0)Y.report(X.negative,"negative",Y)}),iY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isDecimal(String($),{force_decimal:g.range[0]!==0,decimal_digits:g.range.join(",")}))Y.report(X.decimal,"decimal",Y,{digits:g.range.join("-")})}),oY=W(($,g,Y)=>{if(!Y.isValid)return;if(!Number.isInteger($))Y.report(X.withoutDecimals,"withoutDecimals",Y)}),eY=W(($,g,Y)=>{if(!Y.isValid)return;if(!g.values.includes($))Y.report(X["number.in"],"in",Y,g)}),b$=class $ extends x${static rules={in:eY,max:pY,min:dY,range:sY,number:tY,decimal:iY,negative:lY,positive:aY,withoutDecimals:oY};[Z$]="vine.number";[C$]=(g)=>{let Y=B.asNumber(g);return!Number.isNaN(Y)};constructor(g,Y){super(g,Y||[tY(g||{})])}min(g){return this.use(dY({min:g}))}max(g){return this.use(pY({max:g}))}range(g){return this.use(sY({min:g[0],max:g[1]}))}positive(){return this.use(aY())}negative(){return this.use(lY())}decimal(g){return this.use(iY({range:Array.isArray(g)?g:[g]}))}withoutDecimals(){return this.use(oY())}clone(){return new $(this.cloneOptions(),this.cloneValidations())}in(g){return this.use(eY({values:g}))}},$9=W(($,g,Y)=>{let M=g.strict===!0?$:B.asBoolean($);if(typeof M!=="boolean"){Y.report(X.boolean,"boolean",Y);return}Y.mutate(M,Y)}),c$=class $ extends x${static rules={boolean:$9};[Z$]="vine.boolean";[C$]=(g)=>{return typeof(this.options.strict===!0?g:B.asBoolean(g))==="boolean"};constructor(g,Y){super(g,Y||[$9(g||{})])}clone(){return new $(this.cloneOptions(),this.cloneValidations())}},g9=W(($,g,Y)=>{let M=$;if(typeof g.expectedValue==="boolean")M=B.asBoolean($);else if(typeof g.expectedValue==="number")M=B.asNumber($);if(M!==g.expectedValue){Y.report(X.literal,"literal",Y,g);return}Y.mutate(M,Y)}),D9=class $ extends x${static rules={equals:g9};#$;constructor(g,Y,M){super(Y,M||[g9({expectedValue:g})]);this.#$=g}clone(){return new $(this.#$,this.cloneOptions(),this.cloneValidations())}},W4=["on","1","yes","true",!0,1],Y9=W(($,g,Y)=>{if(!W4.includes($))Y.report(X.accepted,"accepted",Y)}),U9=class $ extends x${static rules={accepted:Y9};constructor(g,Y){super(g,Y||[Y9()])}clone(){return new $(this.cloneOptions(),this.cloneValidations())}},Q4=class ${#$;#g=(g,Y)=>{Y.report(X.unionGroup,"unionGroup",Y)};constructor(g){this.#$=g}clone(){let g=new $(this.#$);return g.otherwise(this.#g),g}otherwise(g){return this.#g=g,this}[E](g,Y){return{type:"group",elseConditionalFnRefId:g.trackConditional(this.#g),conditions:this.#$.map((M)=>M[E](g,Y))}}},L9=class{#$;#g;constructor($,g){this.#$=g,this.#g=$}[E]($,g){return{schema:{type:"sub_object",properties:Object.keys(this.#$).map((Y)=>{return this.#$[Y][E](Y,$,g)}),groups:[]},conditionalFnRefId:$.trackConditional(this.#g)}}};function p1($){return new Q4($)}p1.if=function $(g,Y){return new L9(g,Y)};p1.else=function $(g){return new L9(()=>!0,g)};var q4=class $ extends x${static rules={enum:f0};#$;constructor(g,Y,M){super(Y,M||[f0({choices:Object.values(g)})]);this.#$=g}clone(){return new $(this.#$,this.cloneOptions(),this.cloneValidations())}},O4=class ${#$;#g=(g,Y)=>{Y.report(X.unionOfTypes,"unionOfTypes",Y)};constructor(g){this.#$=g}otherwise(g){return this.#g=g,this}clone(){let g=new $(this.#$);return g.otherwise(this.#g),g}[E](g,Y,M){return{type:"union",fieldName:g,propertyName:M.toCamelCase?p(g):g,elseConditionalFnRefId:Y.trackConditional(this.#g),conditions:this.#$.map((Z)=>{return{conditionalFnRefId:Y.trackConditional((J,z)=>{return Z[C$](J,z)}),schema:Z[E](g,Y,M)}})}}},x4=class extends y${group=p1;union=d1;string(){return new u0}boolean($){return new c$($)}accepted(){return new U9}number($){return new b$($)}date($){return new t1($)}literal($){return new D9($)}object($){return new q9($)}array($){return new Q9($)}tuple($){return new W9($)}record($){return new O9($)}enum($){if(Array.isArray($)||typeof $==="function")return new R$($);return new q4($)}any(){return new Z9}unionOfTypes($){let g=new Set;return $.forEach((Y)=>{if(!Y[C$]||!Y[Z$])throw new Error(`Cannot use "${Y.constructor.name}". The schema type is not compatible for use with "vine.unionOfTypes"`);if(g.has(Y[Z$]))throw new Error(`Cannot use duplicate schema "${Y[Z$]}". "vine.unionOfTypes" needs distinct schema types only`);g.add(Y[Z$])}),g.clear(),new O4($)}},G4={required:X.required,array:X.array,object:X.object},n1=class{#$;messagesProvider;errorReporter;#g($){let g=f2();return{compilerNode:{type:"root",schema:$[E]("",g,{toCamelCase:!1})},refs:g.toJSON()}}constructor($,g){let{compilerNode:Y,refs:M}=this.#g($);this.#$={schema:Y,refs:M};let Z=g.metaDataValidator,J=new m2(Y,{convertEmptyStringsToNull:g.convertEmptyStringsToNull,messages:G4}).compile();if(this.errorReporter=g.errorReporter,this.messagesProvider=g.messagesProvider,Z)this.validate=(z,H)=>{let K=H??{},x=K.meta??{},A=K.errorReporter??this.errorReporter,I=K.messagesProvider??this.messagesProvider;return Z(x),J(z,x,M,I,A())};else this.validate=(z,H)=>{let K=H??{},x=K.meta??{},A=K.errorReporter??this.errorReporter,I=K.messagesProvider??this.messagesProvider;return J(z,x,M,I,A())}}async tryValidate($,...[g]){try{return[null,await this.validate($,g)]}catch(Y){if(Y instanceof E1)return[Y,null];throw Y}}toJSON(){let{schema:$,refs:g}=this.#$;return{schema:structuredClone($),refs:g}}},B9=class extends x4{messagesProvider=new d$(X,Zg);errorReporter=()=>new I1;convertEmptyStringsToNull=!1;helpers=B;createRule=W;compile($){return new n1($,{convertEmptyStringsToNull:this.convertEmptyStringsToNull,messagesProvider:this.messagesProvider,errorReporter:this.errorReporter})}withMetaData($){return{compile:(g)=>{return new n1(g,{convertEmptyStringsToNull:this.convertEmptyStringsToNull,messagesProvider:this.messagesProvider,errorReporter:this.errorReporter,metaDataValidator:$})}}}validate($){return this.compile($.schema).validate($.data,$)}tryValidate($){return this.compile($.schema).tryValidate($.data,$)}},D4=new B9,D=D4;import{path as SC}from"@stacksjs/path";var S9={APP_NAME:D.string(),APP_ENV:D.enum(["local","dev","stage","prod"]),APP_KEY:D.string(),APP_URL:D.string(),PORT:D.number(),PORT_BACKEND:D.number(),PORT_ADMIN:D.number(),PORT_LIBRARY:D.number(),PORT_DESKTOP:D.number(),PORT_EMAIL:D.number(),PORT_DOCS:D.number(),PORT_INSPECT:D.number(),PORT_API:D.number(),PORT_SYSTEM_TRAY:D.number(),APP_MAINTENANCE:D.boolean(),DEBUG:D.boolean(),API_PREFIX:D.string(),DOCS_PREFIX:D.string(),DB_CONNECTION:D.enum(["mysql","sqlite","postgres"]),DB_HOST:D.string(),DB_PORT:D.number(),DB_DATABASE:D.string(),DB_USERNAME:D.string(),DB_PASSWORD:D.string(),AWS_ACCOUNT_ID:D.string(),AWS_ACCESS_KEY_ID:D.string(),AWS_SECRET_ACCESS_KEY:D.string(),AWS_DEFAULT_REGION:D.string(),AWS_DEFAULT_PASSWORD:D.string(),MAIL_MAILER:D.enum(["ses","sendmail","log","smtp"]),MAIL_HOST:D.string(),MAIL_PORT:D.number(),MAIL_USERNAME:D.string(),MAIL_PASSWORD:D.string(),MAIL_ENCRYPTION:D.string(),MAIL_FROM_NAME:D.string(),MAIL_FROM_ADDRESS:D.string(),SEARCH_ENGINE_DRIVER:D.enum(["meilisearch","algolia","typesense"]),MEILISEARCH_HOST:D.string(),MEILISEARCH_KEY:D.string(),FRONTEND_APP_ENV:D.enum(["development","staging","production"]),FRONTEND_APP_URL:D.string()};var U4={APP_ENV:["local","dev","development","staging","prod","production"],DB_CONNECTION:["mysql","sqlite","postgres","dynamodb"],MAIL_MAILER:["smtp","mailgun","ses","postmark","sendmail","log"],SEARCH_ENGINE_DRIVER:["opensearch"],FRONTEND_APP_ENV:["development","staging","production"]},L4=Object.entries(S9).reduce(($,[g,Y])=>{let M;switch(typeof Y){case"string":M=D.string();break;case"number":M=D.number();break;case"boolean":M=D.boolean();break;default:if(Array.isArray(Y)){M=D.enum(Y);break}if(typeof Y==="object"){let J=Symbol.for("schema_name"),z=Y[J];if(z==="vine.string"){M=D.string();break}if(z==="vine.number"){M=D.number();break}if(z==="vine.boolean"){M=D.boolean();break}if(!z){M=D.enum(U4.APP_ENV);break}console.error("Unknown env value type",typeof Y)}throw new Error(`Invalid env value for ${g}`)}let Z=g;return $[Z]=M,$},{}),bC=D.object(L4);var w4={get:($,g)=>{let Y=$[g];if(typeof Y==="string"&&/^\d+$/.test(Y)&&g!=="AWS_ACCOUNT_ID")return Number(Y);if(typeof Y==="string"&&/^true|false$/.test(Y))return Y==="true";if(Y instanceof R$)return $[g];if(Y instanceof c$)return!!$[g];if(Y instanceof b$)return Number($[g]);return Y}};function S4(){return typeof Bun!=="undefined"?Bun.env:B4.env}var U=new Proxy(S4(),w4);var P9={name:U.APP_NAME??"Stacks",description:"Stacks is a full-stack framework for building modern web applications.",env:U.APP_ENV??"local",url:U.APP_URL??"stacks.localhost",redirectUrls:["stacksjs.com"],debug:U.DEBUG??!1,key:U.APP_KEY,maintenanceMode:U.APP_MAINTENANCE??!1,docMode:!1,timezone:"America/Los_Angeles",locale:"en",fallbackLocale:"en",cipher:"aes-256-cbc"};var k9={driver:"dynamodb",prefix:"stacks",ttl:3600,drivers:{dynamodb:{key:U.AWS_ACCESS_KEY_ID||"",secret:U.AWS_SECRET_ACCESS_KEY||"",region:U.AWS_DEFAULT_REGION||"us-east-1",table:"cache",endpoint:""},memcached:{persistent_id:"",sasl:["",""],options:{},servers:[{host:"127.0.0.1",port:11211,weight:100}]},redis:{connection:"cache",host:"127.0.0.1",port:6379,password:"",username:"stacks"}}};var A9={name:"My Custom CLI",command:"custom-cli",description:"This is an example command to illustrate how to create your own commands. Check out `../app/commands` for more.",deploy:!0};var r0={firewall:{enabled:!0,countryCodes:["RU","IR"],ipAddresses:[],rateLimitPerMinute:1000,useIpReputationLists:!0,useKnownBadInputsRuleSet:!0,queryString:[],httpHeaders:[]}};var F9={sites:{root:"stacksjs.org",path:"dist",modals:{domain:"modals.stacksjs.org",path:"dist"},stepper:{domain:"stepper.stacksjs.org",path:"dist"},notification:{domain:"notification.stacksjs.org",path:"dist"},docs:{domain:"docs.stacksjs.org",path:"dist"},tlsx:{domain:"tlsx.stacksjs.org",path:"dist"},dtsx:{domain:"dtsx.stacksjs.org",path:"dist"},spreadsheet:{domain:"spreadsheet.stacksjs.org",path:"dist"}},infrastructure:{type:"serverless",driver:"aws",firewall:r0.firewall,environments:["production","staging","development"],storage:{},api:{prefix:U.API_PREFIX||"api",description:"My awesome Stacks API",deploy:!0,memorySize:512,prewarm:10,timeout:30},cdn:{compress:!0,allowedMethods:"ALL",cachedMethods:"GET_HEAD",originShieldRegion:"us-east-1",minTtl:0,defaultTtl:86400,maxTtl:31536000,cookieBehavior:"none",allowList:{cookies:[],headers:[],queryStrings:[]},realtimeLogs:{enabled:!0,samplingRate:1}},fileSystem:!0}};var V9={default:U.DB_CONNECTION||"sqlite",connections:{sqlite:{database:U.DB_DATABASE||"database/stacks.sqlite",prefix:""},dynamodb:{key:U.AWS_ACCESS_KEY_ID||"",secret:U.AWS_SECRET_ACCESS_KEY||"",region:U.AWS_DEFAULT_REGION||"us-east-1",prefix:U.DB_DATABASE||"stacks",endpoint:"http://localhost",port:U.DB_PORT||8000},mysql:{name:U.DB_DATABASE||"stacks",host:U.DB_HOST||"127.0.0.1",port:U.DB_PORT||3306,username:U.DB_USERNAME||"root",password:U.DB_PASSWORD||"",prefix:""},postgres:{name:U.DB_DATABASE||"stacks",host:U.DB_HOST||"127.0.0.1",port:U.DB_PORT||3306,username:U.DB_USERNAME||"",password:U.DB_PASSWORD||"",prefix:""}},migrations:"migrations",migrationLocks:"migration_locks"};var E9={a:[{name:U.APP_URL||"",address:"10.0.0.1",ttl:300},{name:"www",address:"@",ttl:300}],aaaa:[],cname:[],mx:[],txt:[],nameservers:[]};var I9={from:{name:U.MAIL_FROM_NAME||"Stacks",address:U.MAIL_FROM_ADDRESS||"no-reply@stacksjs.org"},mailboxes:["chris@stacksjs.org","blake@stacksjs.org","glenn@stacksjs.org"],url:U.APP_URL||"http://localhost:3000",charset:"UTF-8",server:{scan:!0}};var T9={messages:{string:"The {{ field }} field must be a string",email:"The {{ field }} field must be a valid email address",regex:"The {{ field }} field format is invalid",url:"The {{ field }} field must be a valid URL",activeUrl:"The {{ field }} field must be a valid URL",alpha:"The {{ field }} field must contain only letters",alphaNumeric:"The {{ field }} field must contain only letters and numbers",minLength:"The {{ field }} field must have at least {{ min }} characters",maxLength:"The {{ field }} field must not be greater than {{ max }} characters",fixedLength:"The {{ field }} field must be {{ size }} characters long",confirmed:"The {{ field }} field and {{ otherField }} field must be the same",endsWith:"The {{ field }} field must end with {{ substring }}",startsWith:"The {{ field }} field must start with {{ substring }}",sameAs:"The {{ field }} field and {{ otherField }} field must be the same",notSameAs:"The {{ field }} field and {{ otherField }} field must be different",in:"The selected {{ field }} is invalid",notIn:"The selected {{ field }} is invalid",ipAddress:"The {{ field }} field must be a valid IP address",uuid:"The {{ field }} field must be a valid UUID",ascii:"The {{ field }} field must only contain ASCII characters",creditCard:"The {{ field }} field must be a valid {{ providersList }} card number",hexCode:"The {{ field }} field must be a valid hex color code",iban:"The {{ field }} field must be a valid IBAN number",jwt:"The {{ field }} field must be a valid JWT token",coordinates:"The {{ field }} field must contain latitude and longitude coordinates",mobile:"The {{ field }} field must be a valid mobile phone number",passport:"The {{ field }} field must be a valid passport number",postalCode:"The {{ field }} field must be a valid postal code",boolean:"The value must be a boolean",number:"The {{ field }} field must be a number",min:"The {{ field }} field must be at least {{ min }}",max:"The {{ field }} field must not be greater than {{ max }}",range:"The {{ field }} field must be between {{ min }} and {{ max }}",positive:"The {{ field }} field must be positive",negative:"The {{ field }} field must be negative",decimal:"The {{ field }} field must have {{ digits }} decimal places",withoutDecimals:"The {{ field }} field must not have decimal places",date:"The {{ field }} field must be a datetime value","date.equals":"The {{ field }} field must be a date equal to {{ expectedValue }}","date.after":"The {{ field }} field must be a date after {{ expectedValue }}","date.before":"The {{ field }} field must be a date before {{ expectedValue }}","date.afterOrEqual":"The {{ field }} field must be a date after or equal to {{ expectedValue }}","date.beforeOrEqual":"The {{ field }} field must be a date before or equal to {{ expectedValue }}","date.sameAs":"The {{ field }} field and {{ otherField }} field must be the same","date.notSameAs":"The {{ field }} field and {{ otherField }} field must be different","date.afterField":"The {{ field }} field must be a date after {{ otherField }}",accepted:"The {{ field }} field must be accepted",enum:"The selected {{ field }} is invalid",literal:"The {{ field }} field must be {{ expectedValue }}",object:"The {{ field }} field must be an object",record:"The {{ field }} field must be an object","record.minLength":"The {{ field }} field must have at least {{ min }} items","record.maxLength":"The {{ field }} field must not have more than {{ max }} items","record.fixedLength":"The {{ field }} field must contain {{ size }} items",array:"The {{ field }} field must be an array","array.minLength":"The {{ field }} field must have at least {{ min }} items","array.maxLength":"The {{ field }} field must not have more than {{ max }} items","array.fixedLength":"The {{ field }} field must contain {{ size }} items",notEmpty:"The {{ field }} field must not be empty",distinct:"The {{ field }} field has duplicate values",tuple:"The {{ field }} field must be an array",union:"Invalid value provided for {{ field }} field",unionGroup:"Invalid value provided for {{ field }} field",unionOfTypes:"Invalid value provided for {{ field }} field"}};var j9={hooks:{"pre-commit":"lint-staged"},scopes:["","ci","deps","dx","release","docs","test","core","actions","arrays","auth","build","cache","cli","cloud","collections","config","database","datetime","docs","errors","git","lint","x-ray","modules","notifications","objects","path","realtime","router","buddy","security","server","storage","strings","tests","types","ui","utils"],messages:{type:"Select the type of change that you\u2019re committing:",scope:"Select the SCOPE of this change (optional):",customScope:"Select the SCOPE of this change:",subject:"Write a SHORT, IMPERATIVE tense description of the change:\n",body:'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',breaking:'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',footerPrefixesSelect:"Select the ISSUES type of the change list by this change (optional):",customFooterPrefixes:"Input ISSUES prefix:",footer:"List any ISSUES by this change. E.g.: #31, #34:\n",confirmCommit:"Are you sure you want to proceed with the commit above?"},types:[{value:"feat",name:"feat: \u2728 A new feature",emoji:":sparkles:"},{value:"fix",name:"fix: \uD83D\uDC1B A bug fix",emoji:":bug:"},{value:"docs",name:"docs: \uD83D\uDCDD Documentation only changes",emoji:":memo:"},{value:"style",name:"style: \uD83D\uDC84 Changes that do not affect the meaning of the code",emoji:":lipstick:"},{value:"refactor",name:"refactor: \u267B\uFE0F A code change that neither fixes a bug nor adds a feature",emoji:":recycle:"},{value:"perf",name:"perf: \u26A1\uFE0F A code change that improves performance",emoji:":zap:"},{value:"test",name:"test: \u2705 Adding missing tests or adjusting existing tests",emoji:":white_check_mark:"},{value:"build",name:"build: \uD83D\uDCE6\uFE0F Changes that affect the build system or external dependencies",emoji:":package:"},{value:"ci",name:"ci: \uD83C\uDFA1 Changes to our CI configuration files and scripts",emoji:":ferris_wheel:"},{value:"chore",name:"chore: \uD83D\uDD28 Other changes that don\u2019t modify src or test files",emoji:":hammer:"},{value:"revert",name:"revert: \u23EA\uFE0F Reverts a previous commit",emoji:":rewind:"}]};var _9={driver:"argon2",bcrypt:{rounds:10,cost:4},argon2:{memory:65536,threads:1,time:1}};var y9={name:"hello-world",owner:"@stacksjs",repository:"stacksjs/stacks",license:"MIT",author:"Chris Breuer",contributors:["Chris Breuer <chris@stacksjs.org>"],defaultLanguage:"en",releaseable:!0,vueComponents:{name:"hello-world-vue",description:"Your Vue component library description",keywords:["component","library","vue","vite","typescript","javascript"],tags:[{name:["HelloWorld","AppHelloWorld"],description:"The Hello World custom element, built via this framework.",attributes:[{name:"greeting",description:"The greeting."}]}]},webComponents:{name:"hello-world-elements",description:"Your framework agnostic web component library description.",keywords:["custom-elements","web-components","library","framework-agnostic","typescript","javascript"],tags:[{name:["HelloWorld","AppHelloWorld"],description:"The Hello World custom element, built via this framework.",attributes:[{name:"greeting",description:"The greeting."}]}]},functions:{name:"hello-world-fx",description:"Your function library description.",keywords:["functions","composables","library","typescript","javascript"],shouldGenerateSourcemap:!1,files:["counter","dark"]}};import{storagePath as N9}from"@stacksjs/path";var h9={logsPath:N9("logs/stacks.log"),deploymentsPath:N9("logs/deployments.log")};var R9={default:"email"};var b9={driver:"stripe",stripe:{publishableKey:U.STRIPE_PUBLISHABLE_KEY||"",secretKey:U.STRIPE_SECRET_KEY||""}};var c9={frontend:U.PORT??3000,backend:U.PORT_BACKEND??3001,admin:U.PORT_ADMIN??3002,library:U.PORT_LIBRARY??3003,desktop:U.PORT_DESKTOP??3004,email:U.PORT_EMAIL??3005,docs:U.PORT_DOCS??3006,inspect:U.PORT_INSPECT??3007,api:U.PORT_API??3008,systemTray:U.PORT_SYSTEM_TRAY??3009,database:3010};var m9={default:"sync",connections:{sync:{driver:"sync"},sqs:{driver:"sqs",key:"",secret:"",prefix:"",suffix:"",queue:"default",region:"us-east-1"}}};var f9={plans:[{productName:"Stacks Hobby",description:"All the Stacks features.",pricing:[{key:"stacks_hobby_monthly",price:3900,interval:"month",currency:"usd"},{key:"stacks_hobby_yearly",price:37900,interval:"year",currency:"usd"}],metadata:{createdBy:"admin",version:"1.0.0"}},{productName:"Stacks Pro",description:"All the Stacks features, including being able to invite team members.",pricing:[{key:"stacks_pro_monthly",price:5900,interval:"month",currency:"usd"},{key:"stacks_pro_yearly",price:57900,interval:"year",currency:"usd"}],metadata:{createdBy:"admin",version:"1.0.0"}}],webhook:{endpoint:"/webhooks/stripe",secret:""},currencies:["usd"],coupons:[{code:"SUMMER2024",amountOff:500,duration:"once"}],products:[{name:"Stacks Pro",description:"All the Stacks features.",images:["url_to_image"]}]};var v9={driver:"opensearch"};var u9={aws:{accountId:U.AWS_ACCOUNT_ID||"",appId:U.AWS_ACCESS_KEY_ID||"",apiKey:U.AWS_SECRET_ACCESS_KEY||"",region:U.AWS_DEFAULT_REGION||"us-east-1"},algolia:{appId:"",apiKey:""},meilisearch:{appId:"",apiKey:""},lemonSqueezy:{appId:"",apiKey:""},stripe:{appId:"",apiKey:""}};var r9={driver:"s3"};var n9={name:"Stacks",members:{chris:"chris@stacksjs.org",blake:"blake@stacksjs.org",zoltan:"zoltan@stacksjs.org",freddy:"freddy@stacksjs.org",glenn:"glenn@stacksjs.org",dorell:"dorell@stacksjs.org",avery:"avery@stacksjs.org",adelino:"adelino@stacksjs.org"}};var t9={shortcuts:[["btn","inline-flex items-center px-4 py-2 ml-2 border border-transparent shadow-sm text-base font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 cursor-pointer"]],safelist:"prose prose-sm m-auto text-left",trigger:":stx:",classPrefix:"stx-",reset:"tailwind",icons:["heroicons"],fonts:{email:{title:"Mona",text:"Hubot"},desktop:{title:"Mona",text:"Hubot"},mobile:{title:"Mona",text:"Hubot"},web:{title:"Mona",text:"Hubot"}},theme:{colors:{veryCool:"#0000ff",brand:{primary:"hsl(var(--hue, 217) 78% 51%)"}}}};var P4={ai:a1,analytics:l1,app:P9,cache:k9,cli:A9,cloud:F9,database:V9,dns:E9,email:I9,errors:T9,git:j9,hashing:_9,library:y9,logging:h9,notification:R9,queue:m9,payment:b9,ports:c9,saas:f9,searchEngine:v9,security:r0,services:u9,storage:r9,team:n9,ui:t9},s1=P4;async function d9($){if(!$?.port)$={port:3000};return console.log("Creating local tunnel",$.port),"localTunnel"}async function B$($){return await d9({port:$})}async function k4({domain:$=v.app.url||"stacks",type:g="frontend",localhost:Y=!1,https:M=void 0,network:Z=void 0}={}){let J=$.replace(/\.[^.]+$/,".localhost");switch(g){case"frontend":if(Z)return await B$(v.ports?.frontend||3000);if(Y)return`http://localhost:${v.ports?.frontend}`;break;case"backend":if(Z)return await B$(v.ports?.backend||3001);if(Y)return`http://localhost:${v.ports?.backend}`;J=`api.${J}`;break;case"admin":if(Z)return await B$(v.ports?.admin||3002);if(Y)return`http://localhost:${v.ports?.admin}`;J=`admin.${J}`;break;case"library":if(Z)return await B$(v.ports?.library||3003);if(Y)return`http://localhost:${v.ports?.library}`;J=`libs.${J}`;break;case"email":if(Z)return await B$(v.ports?.email||3005);if(Y)return`http://localhost:${v.ports?.email}`;J=`email.${J}`;break;case"desktop":if(Z)return await B$(v.ports?.desktop||3004);if(Y)return`http://localhost:${v.ports?.desktop}`;J=`desktop.${J}`;break;case"docs":if(Z)return await B$(v.ports?.docs||3006);if(Y)return`http://localhost:${v.ports?.docs}`;J=`docs.${J}`;break;case"inspect":if(Z)return await B$(v.ports?.inspect||3007);if(Y)return`http://localhost:${v.ports?.inspect}`;J=`inspect.${J}`;break;default:if(Y)return`http://localhost:${v.ports?.frontend}`}if(M)return`https://${J}`;return`http://${J}`}function A4($){return $}function F4($){return $}function V4($){return $}function E4($){return $}function I4($){return $}function T4($){return $}function j4($){return $}function _4($){return $}function y4($){return $}function N4($){return $}function h4($){return $}function R4($){return $}function b4($){return $}function c4($){return $}function m4($){return $}function f4($){return $}function v4($){return $}function u4($){return $}function r4($){return $}function n4($){return $}function t4($){return $}function d4($){return $}function p4($){return $}function s4($){return $}function a4($){return $}function l4($){return $}function i4($){return $}var y={...a0,...s1},o4=y.ai,e4=y.analytics,T$=y.app,$8=y.cache,g8=y.cloud,Y8=y.cli,M8=y.database,Z8=y.dns,J8=y.docs,z8=y.email,H8=y.errors,K8=y.git,C8=y.hashing,X8=y.library,W8=y.logging,Q8=y.notification,q8=y.payment,O8=y.ports,x8=y.queue,G8=y.security,D8=y.saas,U8=y.searchEngine,L8=y.services,B8=y.storage,w8=y.team,S8=y.ui;function P8(){if(T$.env==="local")return"dev";if(T$.env==="development")return"dev";if(T$.env==="staging")return"stage";if(T$.env==="production")return"prod";if(!T$.env)throw new Error("Couldn\'t determine app environment");return T$.env}import*as o$ from"@stacksjs/path";class e${static isTestEnvironment=!1;static shouldExitProcess=!0;static handle($,g){if(this.shouldExitProcess=g?.shouldExit!==!1,g?.silent!==!0)this.writeErrorToConsole($);let Y;if(g?.message)Y=g.message;else if($ instanceof Error)Y=$.message;else if(typeof $==="string")Y=$;else Y=JSON.stringify($);let M=new Error(Y);if($ instanceof Error)Object.assign(M,$);return this.writeErrorToFile(M).catch((Z)=>console.error(Z)),M}static handleError($,g){return this.handle($,g),$}static async writeErrorToFile($){if(!($ instanceof Error)){console.error("Error is not an instance of Error:",$);return}let g=`[${new Date().toISOString()}] ${$.name}: ${$.message}\n`,Y=o$.logsPath("stacks.log")??o$.logsPath("errors.log");try{await a9(o$.dirname(Y),{recursive:!0}),await s9(Y,g)}catch(M){console.error("Failed to write to error file:",M)}}static writeErrorToConsole($){console.error($);let g=typeof $==="string"?$:$ instanceof Error?$.message:JSON.stringify($);if(g.includes("bunx --bun cdk destroy")||g===`Failed to execute command: ${p9("bunx --bun eslint . --fix")}`||g===`Failed to execute command: ${p9("bun storage/framework/core/actions/src/lint/fix.ts")}`){if(!this.isTestEnvironment)console.log("No need to worry. The edge function is currently being destroyed. Please run `buddy undeploy` shortly again, and continue doing so until it succeeds running."),console.log("Hoping to see you back soon!")}if(this.shouldExitProcess)F8.exit(1)}}function GW($,g){let Y;if(Mg($))Y=$;else if($ instanceof Error)Y=$.message;else if(g instanceof Error)Y=g.message;else Y=String($);return E8(`ERROR: ${V8(Y)}`),e$.handle($,g)}async function E8($,g){let Y=`[${new Date().toISOString()}] ${$}\n`;try{let M=g?.logFile??v.logging.logsPath??"storage/logs/stacks.log";try{await k8(M)}catch{console.log("Creating log file directory...",M),await a9(A8(M),{recursive:!0})}await s9(M,Y)}catch(M){console.error("Failed to write to log file:",M)}}class w9 extends Error{$;constructor($,g){super(g);this.status=$;this.name="Server Error!"}}function BW($,g,Y){try{let M=$();if(M instanceof Promise)return M.catch((Z)=>{if(Y)Y(e$.handle(Z));return g});return M}catch(M){if(Y)Y(e$.handle(M));return g}}var I8={withStackTrace:!1},o9=($,g,Y=I8)=>{let M=g.isOk()?{type:"Ok",value:g.value}:{type:"Err",value:g.error},Z=Y.withStackTrace?new Error().stack:void 0;return{data:M,message:$,stack:Z}};function m$($,g,Y,M){function Z(J){return J instanceof Y?J:new Y(function(z){z(J)})}return new(Y||(Y=Promise))(function(J,z){function H(A){try{x(M.next(A))}catch(I){z(I)}}function K(A){try{x(M.throw(A))}catch(I){z(I)}}function x(A){A.done?J(A.value):Z(A.value).then(H,K)}x((M=M.apply($,g||[])).next())})}function l9($){var g=typeof Symbol==="function"&&Symbol.iterator,Y=g&&$[g],M=0;if(Y)return Y.call($);if($&&typeof $.length==="number")return{next:function(){if($&&M>=$.length)$=void 0;return{value:$&&$[M++],done:!$}}};throw new TypeError(g?"Object is not iterable.":"Symbol.iterator is not defined.")}function G$($){return this instanceof G$?(this.v=$,this):new G$($)}function i9($,g,Y){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var M=Y.apply($,g||[]),Z,J=[];return Z=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),H("next"),H("throw"),H("return",z),Z[Symbol.asyncIterator]=function(){return this},Z;function z(k){return function(O){return Promise.resolve(O).then(k,I)}}function H(k,O){if(M[k]){if(Z[k]=function(V){return new Promise(function(N,_){J.push([k,V,N,_])>1||K(k,V)})},O)Z[k]=O(Z[k])}}function K(k,O){try{x(M[k](O))}catch(V){u(J[0][3],V)}}function x(k){k.value instanceof G$?Promise.resolve(k.value.v).then(A,I):u(J[0][2],k)}function A(k){K("next",k)}function I(k){K("throw",k)}function u(k,O){if(k(O),J.shift(),J.length)K(J[0][0],J[0][1])}}function T8($){var g,Y;return g={},M("next"),M("throw",function(Z){throw Z}),M("return"),g[Symbol.iterator]=function(){return this},g;function M(Z,J){g[Z]=$[Z]?function(z){return(Y=!Y)?{value:G$($[Z](z)),done:!1}:J?J(z):z}:J}}function j8($){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var g=$[Symbol.asyncIterator],Y;return g?g.call($):($=typeof l9==="function"?l9($):$[Symbol.iterator](),Y={},M("next"),M("throw"),M("return"),Y[Symbol.asyncIterator]=function(){return this},Y);function M(J){Y[J]=$[J]&&function(z){return new Promise(function(H,K){z=$[J](z),Z(H,K,z.done,z.value)})}}function Z(J,z,H,K){Promise.resolve(K).then(function(x){J({value:x,done:H})},z)}}class n{constructor($){this._promise=$}static fromSafePromise($){let g=$.then((Y)=>new X$(Y));return new n(g)}static fromPromise($,g){let Y=$.then((M)=>new X$(M)).catch((M)=>new W$(g(M)));return new n(Y)}static fromThrowable($,g){return(...Y)=>{return new n((()=>m$(this,void 0,void 0,function*(){try{return new X$(yield $(...Y))}catch(M){return new W$(g?g(M):M)}}))())}}static combine($){return h8($)}static combineWithAllErrors($){return R8($)}map($){return new n(this._promise.then((g)=>m$(this,void 0,void 0,function*(){if(g.isErr())return new W$(g.error);return new X$(yield $(g.value))})))}andThrough($){return new n(this._promise.then((g)=>m$(this,void 0,void 0,function*(){if(g.isErr())return new W$(g.error);let Y=yield $(g.value);if(Y.isErr())return new W$(Y.error);return new X$(g.value)})))}andTee($){return new n(this._promise.then((g)=>m$(this,void 0,void 0,function*(){if(g.isErr())return new W$(g.error);try{yield $(g.value)}catch(Y){}return new X$(g.value)})))}mapErr($){return new n(this._promise.then((g)=>m$(this,void 0,void 0,function*(){if(g.isOk())return new X$(g.value);return new W$(yield $(g.error))})))}andThen($){return new n(this._promise.then((g)=>{if(g.isErr())return new W$(g.error);let Y=$(g.value);return Y instanceof n?Y._promise:Y}))}orElse($){return new n(this._promise.then((g)=>m$(this,void 0,void 0,function*(){if(g.isErr())return $(g.error);return new X$(g.value)})))}match($,g){return this._promise.then((Y)=>Y.match($,g))}unwrapOr($){return this._promise.then((g)=>g.unwrapOr($))}safeUnwrap(){return i9(this,arguments,function*$(){return yield G$(yield G$(yield*T8(j8(yield G$(this._promise.then((g)=>g.safeUnwrap()))))))})}then($,g){return this._promise.then($,g)}[Symbol.asyncIterator](){return i9(this,arguments,function*$(){let g=yield G$(this._promise);if(g.isErr())yield yield G$($0(g.error));return yield G$(g.value)})}}var _8=($)=>new n(Promise.resolve(new X$($))),$0=($)=>new n(Promise.resolve(new W$($))),y8=n.fromPromise,N8=n.fromSafePromise,SW=n.fromThrowable,e9=($)=>{let g=A$([]);for(let Y of $)if(Y.isErr()){g=D$(Y.error);break}else g.map((M)=>M.push(Y.value));return g},h8=($)=>n.fromSafePromise(Promise.all($)).andThen(e9),$M=($)=>{let g=A$([]);for(let Y of $)if(Y.isErr()&&g.isErr())g.error.push(Y.error);else if(Y.isErr()&&g.isOk())g=D$([Y.error]);else if(Y.isOk()&&g.isOk())g.value.push(Y.value);return g},R8=($)=>n.fromSafePromise(Promise.all($)).andThen($M);var g0=void 0;(function($){function g(Z,J){return(...z)=>{try{let H=Z(...z);return A$(H)}catch(H){return D$(J?J(H):H)}}}$.fromThrowable=g;function Y(Z){return e9(Z)}$.combine=Y;function M(Z){return $M(Z)}$.combineWithAllErrors=M})(g0||(g0={}));var A$=($)=>new X$($);function D$($){return new W$($)}class X${constructor($){this.value=$}isOk(){return!0}isErr(){return!this.isOk()}map($){return A$($(this.value))}mapErr($){return A$(this.value)}andThen($){return $(this.value)}andThrough($){return $(this.value).map((g)=>this.value)}andTee($){try{$(this.value)}catch(g){}return A$(this.value)}orElse($){return A$(this.value)}asyncAndThen($){return $(this.value)}asyncAndThrough($){return $(this.value).map(()=>this.value)}asyncMap($){return n.fromSafePromise($(this.value))}unwrapOr($){return this.value}match($,g){return $(this.value)}safeUnwrap(){let $=this.value;return function*(){return $}()}_unsafeUnwrap($){return this.value}_unsafeUnwrapErr($){throw o9("Called `_unsafeUnwrapErr` on an Ok",this,$)}*[Symbol.iterator](){return this.value}}class W${constructor($){this.error=$}isOk(){return!1}isErr(){return!this.isOk()}map($){return D$(this.error)}mapErr($){return D$($(this.error))}andThrough($){return D$(this.error)}andTee($){return D$(this.error)}andThen($){return D$(this.error)}orElse($){return $(this.error)}asyncAndThen($){return $0(this.error)}asyncAndThrough($){return $0(this.error)}asyncMap($){return $0(this.error)}unwrapOr($){return $}match($,g){return g(this.error)}safeUnwrap(){let $=this.error;return function*(){throw yield D$($),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap($){throw o9("Called `_unsafeUnwrap` on an Err",this,$)}_unsafeUnwrapErr($){return this.error}*[Symbol.iterator](){let $=this;return yield $,$}}var b8=g0.fromThrowable;var gM=W$,YM=X$,MM=n,ZM=D$,JM=$0;var zM=y8,HM=N8,KM=b8,CM=A$,XM=_8;export{E8 as writeToLogFile,BW as rescue,XM as okAsync,CM as ok,GW as handleError,KM as fromThrowable,HM as fromSafePromise,zM as fromPromise,JM as errAsync,ZM as err,MM as ResultAsync,g0 as Result,YM as Ok,w9 as HttpError,e$ as ErrorHandler,gM as Err};
121
+ const NOT_AN_ARRAY = '${$.array}';`}var $4=Object.getPrototypeOf(async function(){}).constructor,m2=class{variablesCounter=0;#$;#g;#Y=new T6;constructor($,g){this.#$=$,this.#g=g||{convertEmptyStringsToNull:!1}}#M(){this.#Y.writeStatement(e6({required:"value is required",object:"value is not a valid object",array:"value is not a valid array",...this.#g.messages})),this.#Y.writeStatement(o6(this.#g)),this.#Y.writeStatement("let out;")}#Z(){this.#Y.writeStatement(a6()),this.#Y.writeStatement("return out;")}#J(){this.compileNode(this.#$.schema,this.#Y,{type:"root",variableName:"root",outputExpression:"out",fieldPathExpression:"out",wildCardPath:""})}#z(){return new $4("root","meta","refs","messagesProvider","errorReporter",this.#Y.toString())}createFieldFor($,g){switch(g.type){case"array":return p6(g);case"root":return n6(g);case"object":return l6($,this.variablesCounter,g);case"tuple":return s6($,g);case"record":return i6(g)}}compileNode($,g,Y,M){switch($.type){case"literal":return new d6($,g,this,Y,M).compile();case"array":return new R6($,g,this,Y,M).compile();case"record":return new f6($,g,this,Y,M).compile();case"object":return new r6($,g,this,Y,M).compile();case"tuple":return new N6($,g,this,Y,M).compile();case"union":return new c6($,g,this,Y,M).compile()}}compile(){this.#M(),this.#J(),this.#Z();let $=this.#z();return this.variablesCounter=0,this.#Y.flush(),$}};function f2(){let $=0,g={};return{toJSON(){return g},track(Y){$++;let M=`ref://${$}`;return g[M]=Y,M},trackValidation(Y){return this.track(Y)},trackParser(Y){return this.track(Y)},trackTransformer(Y){return this.track(Y)},trackConditional(Y){return this.track(Y)}}}function W($,g){let Y={validator:$,isAsync:g?.isAsync||$.constructor.name==="AsyncFunction",implicit:g?.implicit??!1};return function(...M){return{rule:Y,options:M[0]}}}var M9={};J0(M9,{COTYPE:()=>M4,IS_OF_TYPE:()=>C$,ITYPE:()=>g4,OTYPE:()=>Y4,PARSE:()=>E,UNIQUE_NAME:()=>Z$,VALIDATION:()=>E$});var Z$=Symbol.for("schema_name"),C$=Symbol.for("is_of_type"),E=Symbol.for("parse"),g4=Symbol.for("opaque_input_type"),Y4=Symbol.for("opaque_type"),M4=Symbol.for("camelcase_opaque_type"),E$=Symbol.for("to_validation"),h$=W(($,g,Y)=>{let M=g(Y);if(!Y.isDefined&&M)Y.report(X.required,"required",Y)},{implicit:!0}),v0=class extends y${optional($){return new J4(this,$)}nullable(){return new Z4(this)}transform($){return new z4($,this)}},Z4=class $ extends v0{#$;constructor(g){super();this.#$=g}clone(){return new $(this.#$.clone())}[E](g,Y,M){let Z=this.#$[E](g,Y,M);return Z.allowNull=!0,Z}},J4=class $ extends v0{#$;validations;constructor(g,Y){super();this.#$=g,this.validations=Y||[]}cloneValidations(){return this.validations.map((g)=>{return{options:g.options,rule:g.rule}})}compileValidations(g){return this.validations.map((Y)=>{return{ruleFnId:g.track({validator:Y.rule.validator,options:Y.options}),implicit:Y.rule.implicit,isAsync:Y.rule.isAsync}})}use(g){return this.validations.push(E$ in g?g[E$]():g),this}requiredWhen(g,Y,M){if(typeof g==="function")return this.use(h$(g));let Z;switch(Y){case"=":Z=(J)=>J===M;break;case"!=":Z=(J)=>J!==M;break;case"in":Z=(J)=>M.includes(J);break;case"notIn":Z=(J)=>!M.includes(J);break;case">":Z=(J)=>J>M;break;case"<":Z=(J)=>J<M;break;case">=":Z=(J)=>J>=M;break;case"<=":Z=(J)=>J<=M}return this.use(h$((J)=>{let z=B.getNestedValue(g,J);return Z(z)}))}requiredIfExists(g){let Y=Array.isArray(g)?g:[g];return this.use(h$((M)=>{return Y.every((Z)=>B.exists(B.getNestedValue(Z,M)))}))}requiredIfAnyExists(g){return this.use(h$((Y)=>{return g.some((M)=>B.exists(B.getNestedValue(M,Y)))}))}requiredIfMissing(g){let Y=Array.isArray(g)?g:[g];return this.use(h$((M)=>{return Y.every((Z)=>B.isMissing(B.getNestedValue(Z,M)))}))}requiredIfAnyMissing(g){return this.use(h$((Y)=>{return g.some((M)=>B.isMissing(B.getNestedValue(M,Y)))}))}clone(){return new $(this.#$.clone(),this.cloneValidations())}[E](g,Y,M){let Z=this.#$[E](g,Y,M);return Z.isOptional=!0,Z.validations=Z.validations.concat(this.compileValidations(Y)),Z}},z4=class $ extends v0{#$;#g;constructor(g,Y){super();this.#g=g,this.#$=Y}clone(){return new $(this.#g,this.#$.clone())}[E](g,Y,M){let Z=this.#$[E](g,Y,M);return Z.transformFnId=Y.trackTransformer(this.#g),Z}},x$=class extends v0{options;validations;constructor($,g){super();this.options={bail:!0,allowNull:!1,isOptional:!1,...$},this.validations=g||[]}cloneValidations(){return this.validations.map(($)=>{return{options:$.options,rule:$.rule}})}cloneOptions(){return{...this.options}}compileValidations($){return this.validations.map((g)=>{return{ruleFnId:$.track({validator:g.rule.validator,options:g.options}),implicit:g.rule.implicit,isAsync:g.rule.isAsync}})}parse($){return this.options.parse=$,this}use($){return this.validations.push(E$ in $?$[E$]():$),this}bail($){return this.options.bail=$,this}[E]($,g,Y){return{type:"literal",fieldName:$,propertyName:Y.toCamelCase?p($):$,bail:this.options.bail,allowNull:this.options.allowNull,isOptional:this.options.isOptional,parseFnId:this.options.parse?g.trackParser(this.options.parse):void 0,validations:this.compileValidations(g)}}},Z9=class $ extends x${constructor(g,Y){super(g,Y)}clone(){return new $(this.cloneOptions(),this.cloneValidations())}},f0=W(($,g,Y)=>{let M=typeof g.choices==="function"?g.choices(Y):g.choices;if(!M.includes($))Y.report(X.enum,"enum",Y,{choices:M})}),R$=class $ extends x${static rules={enum:f0};#$;getChoices(){return this.#$}constructor(g,Y,M){super(Y,M||[f0({choices:g})]);this.#$=g}clone(){return new $(this.#$,this.cloneOptions(),this.cloneValidations())}},I$=["YYYY-MM-DD","YYYY-MM-DD HH:mm:ss"];b.default.extend(K9.default);b.default.extend(z9.default);b.default.extend(H9.default);var H4=W(($,g,Y)=>{if(typeof $!=="string"&&typeof $!=="number"){Y.report(X.date,"date",Y);return}let M=!1,Z=g.formats||I$;if(Array.isArray(Z))Z=[...Z],M=Z.includes("x");else if(typeof Z!=="string")Z={...Z},M=Z.format==="x";let J=M?B.asNumber($):$,z=M&&!Number.isNaN(J)?b.default(J):b.default($,Z,!0);if(!z.isValid()){Y.report(X.date,"date",Y);return}Y.meta.$value=z,Y.meta.$formats=Z,Y.mutate(z.toDate(),Y)}),v2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=g.format||I$,J=Y.meta.$value,z=typeof g.expectedValue==="function"?g.expectedValue(Y):g.expectedValue,H=b.default(z,Z,!0);if(!H.isValid())throw new Error(`Invalid datetime value "${z}" value provided to the equals rule`);if(!J.isSame(H,M))Y.report(X["date.equals"],"date.equals",Y,{expectedValue:z,compare:M})}),u2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=g.format||I$,J=Y.meta.$value,z=typeof g.expectedValue==="function"?g.expectedValue(Y):g.expectedValue,H=z==="today"?b.default():z==="tomorrow"?b.default().add(1,"day"):b.default(z,Z,!0);if(!H.isValid())throw new Error(`Invalid datetime value "${z}" value provided to the after rule`);if(!J.isAfter(H,M))Y.report(X["date.after"],"date.after",Y,{expectedValue:z,compare:M})}),r2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=g.format||I$,J=Y.meta.$value,z=typeof g.expectedValue==="function"?g.expectedValue(Y):g.expectedValue,H=z==="today"?b.default():z==="tomorrow"?b.default().add(1,"day"):b.default(z,Z,!0);if(!H.isValid())throw new Error(`Invalid datetime value "${z}" value provided to the afterOrEqual rule`);if(!J.isSameOrAfter(H,M))Y.report(X["date.afterOrEqual"],"date.afterOrEqual",Y,{expectedValue:z,compare:M})}),n2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=g.format||I$,J=Y.meta.$value,z=typeof g.expectedValue==="function"?g.expectedValue(Y):g.expectedValue,H=z==="today"?b.default():z==="yesterday"?b.default().subtract(1,"day"):b.default(z,Z,!0);if(!H.isValid())throw new Error(`Invalid datetime value "${z}" value provided to the before rule`);if(!J.isBefore(H,M))Y.report(X["date.before"],"date.before",Y,{expectedValue:z,compare:M})}),t2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=g.format||I$,J=Y.meta.$value,z=typeof g.expectedValue==="function"?g.expectedValue(Y):g.expectedValue,H=z==="today"?b.default():z==="yesterday"?b.default().subtract(1,"day"):b.default(z,Z,!0);if(!H.isValid())throw new Error(`Invalid datetime value "${z}" value provided to the beforeOrEqual rule`);if(!J.isSameOrBefore(H,M))Y.report(X["date.beforeOrEqual"],"date.beforeOrEqual",Y,{expectedValue:z,compare:M})}),d2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(!Z.isSame(H,M))Y.report(X["date.sameAs"],"date.sameAs",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),p2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(Z.isSame(H,M))Y.report(X["date.notSameAs"],"date.notSameAs",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),s2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(!Z.isAfter(H,M))Y.report(X["date.afterField"],"date.afterField",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),a2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(!Z.isSameOrAfter(H,M))Y.report(X["date.afterOrSameAs"],"date.afterOrSameAs",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),l2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(!Z.isBefore(H,M))Y.report(X["date.beforeField"],"date.beforeField",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),i2=W(($,g,Y)=>{if(!Y.meta.$value)return;let M=g.compare||"day",Z=Y.meta.$value,J=g.format||Y.meta.$formats,z=B.getNestedValue(g.otherField,Y),H=b.default(z,J,!0);if(!H.isValid())return;if(!Z.isSameOrBefore(H,M))Y.report(X["date.beforeOrSameAs"],"date.beforeOrSameAs",Y,{otherField:g.otherField,expectedValue:z,compare:M})}),o2=W(($,g,Y)=>{if(!Y.meta.$value)return;let Z=Y.meta.$value.day();if(Z!==0&&Z!==6)Y.report(X["date.weekend"],"date.weekend",Y)}),e2=W(($,g,Y)=>{if(!Y.meta.$value)return;let Z=Y.meta.$value.day();if(Z===0||Z===6)Y.report(X["date.weekday"],"date.weekday",Y)}),t1=class $ extends x${static rules={equals:v2,after:u2,afterOrEqual:r2,before:n2,beforeOrEqual:t2,sameAs:d2,notSameAs:p2,afterField:s2,afterOrSameAs:a2,beforeField:l2,beforeOrSameAs:i2,weekend:o2,weekday:e2};[Z$]="vine.date";[C$]=(g)=>{if(typeof g!=="string")return!1;return J9.default(g,this.options.formats||I$,!0).isValid()};constructor(g,Y){super(g,Y||[H4(g||{})])}equals(g,Y){return this.use(v2({expectedValue:g,...Y}))}after(g,Y){return this.use(u2({expectedValue:g,...Y}))}afterOrEqual(g,Y){return this.use(r2({expectedValue:g,...Y}))}before(g,Y){return this.use(n2({expectedValue:g,...Y}))}beforeOrEqual(g,Y){return this.use(t2({expectedValue:g,...Y}))}sameAs(g,Y){return this.use(d2({otherField:g,...Y}))}notSameAs(g,Y){return this.use(p2({otherField:g,...Y}))}afterField(g,Y){return this.use(s2({otherField:g,...Y}))}afterOrSameAs(g,Y){return this.use(a2({otherField:g,...Y}))}beforeField(g,Y){return this.use(l2({otherField:g,...Y}))}beforeOrSameAs(g,Y){return this.use(i2({otherField:g,...Y}))}weekend(){return this.use(o2())}weekday(){return this.use(e2())}clone(){return new $(this.cloneOptions(),this.cloneValidations())}},C9=class ${#$;#g=(g,Y)=>{Y.report(X.union,"union",Y)};constructor(g){this.#$=g}otherwise(g){return this.#g=g,this}clone(){let g=new $(this.#$);return g.otherwise(this.#g),g}[E](g,Y,M){return{type:"union",fieldName:g,propertyName:M.toCamelCase?p(g):g,elseConditionalFnRefId:Y.trackConditional(this.#g),conditions:this.#$.map((Z)=>Z[E](g,Y,M))}}},X9=class{#$;#g;constructor($,g){this.#$=g,this.#g=$}[E]($,g,Y){return{conditionalFnRefId:g.trackConditional(this.#g),schema:this.#$[E]($,g,Y)}}};function d1($){return new C9($)}d1.if=function $(g,Y){return new X9(g,Y)};d1.else=function $(g){return new X9(()=>!0,g)};var l$=class extends y${optional(){return new C4(this)}nullable(){return new K4(this)}},K4=class $ extends l${#$;constructor(g){super();this.#$=g}clone(){return new $(this.#$.clone())}[E](g,Y,M){let Z=this.#$[E](g,Y,M);if(Z.type!=="union")Z.allowNull=!0;return Z}},C4=class $ extends l${#$;constructor(g){super();this.#$=g}clone(){return new $(this.#$.clone())}[E](g,Y,M){let Z=this.#$[E](g,Y,M);if(Z.type!=="union")Z.isOptional=!0;return Z}},i$=class extends l${options;validations;constructor($,g){super();this.options=$||{bail:!0,allowNull:!1,isOptional:!1},this.validations=g||[]}cloneValidations(){return this.validations.map(($)=>{return{options:$.options,rule:$.rule}})}cloneOptions(){return{...this.options}}compileValidations($){return this.validations.map((g)=>{return{ruleFnId:$.track({validator:g.rule.validator,options:g.options}),implicit:g.rule.implicit,isAsync:g.rule.isAsync}})}parse($){return this.options.parse=$,this}use($){return this.validations.push(E$ in $?$[E$]():$),this}bail($){return this.options.bail=$,this}},W9=class $ extends i${#$;#g=!1;[Z$]="vine.array";[C$]=(g)=>{return Array.isArray(g)};constructor(g,Y,M){super(Y,M);this.#$=g}allowUnknownProperties(){return this.#g=!0,this}clone(){let g=new $(this.#$.map((Y)=>Y.clone()),this.cloneOptions(),this.cloneValidations());if(this.#g)g.allowUnknownProperties();return g}[E](g,Y,M){return{type:"tuple",fieldName:g,propertyName:M.toCamelCase?p(g):g,bail:this.options.bail,allowNull:this.options.allowNull,isOptional:this.options.isOptional,allowUnknownProperties:this.#g,parseFnId:this.options.parse?Y.trackParser(this.options.parse):void 0,validations:this.compileValidations(Y),properties:this.#$.map((Z,J)=>Z[E](String(J),Y,M))}}},$Y=W(($,g,Y)=>{if(!Y.isValid)return;if($.length<g.min)Y.report(X["array.minLength"],"array.minLength",Y,g)}),gY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length>g.max)Y.report(X["array.maxLength"],"array.maxLength",Y,g)}),YY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length!==g.size)Y.report(X["array.fixedLength"],"array.fixedLength",Y,g)}),MY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length<=0)Y.report(X.notEmpty,"notEmpty",Y)}),ZY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isDistinct($,g.fields))Y.report(X.distinct,"distinct",Y,g)}),JY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate($.filter((M)=>B.exists(M)&&M!==""),Y)}),Q9=class $ extends i${static rules={compact:JY,notEmpty:MY,distinct:ZY,minLength:$Y,maxLength:gY,fixedLength:YY};#$;[Z$]="vine.array";[C$]=(g)=>{return Array.isArray(g)};constructor(g,Y,M){super(Y,M);this.#$=g}minLength(g){return this.use($Y({min:g}))}maxLength(g){return this.use(gY({max:g}))}fixedLength(g){return this.use(YY({size:g}))}notEmpty(){return this.use(MY())}distinct(g){return this.use(ZY({fields:g}))}compact(){return this.use(JY())}clone(){return new $(this.#$.clone(),this.cloneOptions(),this.cloneValidations())}[E](g,Y,M){return{type:"array",fieldName:g,propertyName:M.toCamelCase?p(g):g,bail:this.options.bail,allowNull:this.options.allowNull,isOptional:this.options.isOptional,each:this.#$[E]("*",Y,M),parseFnId:this.options.parse?Y.trackParser(this.options.parse):void 0,validations:this.compileValidations(Y)}}},X4=class $ extends l${#$;[Z$]="types.object";[C$]=(g)=>{return g!==null&&typeof g==="object"&&!Array.isArray(g)};constructor(g){super();this.#$=g}clone(){return new $(this.#$.clone())}[E](g,Y,M){return M.toCamelCase=!0,this.#$[E](g,Y,M)}},q9=class $ extends i${#$;#g=[];#Y=!1;[Z$]="vine.object";[C$]=(g)=>{return g!==null&&typeof g==="object"&&!Array.isArray(g)};constructor(g,Y,M){super(Y,M);this.#$=g}getProperties(){return Object.keys(this.#$).reduce((g,Y)=>{return g[Y]=this.#$[Y].clone(),g},{})}allowUnknownProperties(){return this.#Y=!0,this}merge(g){return this.#g.push(g),this}clone(){let g=new $(this.getProperties(),this.cloneOptions(),this.cloneValidations());if(this.#g.forEach((Y)=>g.merge(Y)),this.#Y)g.allowUnknownProperties();return g}toCamelCase(){return new X4(this)}[E](g,Y,M){return{type:"object",fieldName:g,propertyName:M.toCamelCase?p(g):g,bail:this.options.bail,allowNull:this.options.allowNull,isOptional:this.options.isOptional,parseFnId:this.options.parse?Y.trackParser(this.options.parse):void 0,allowUnknownProperties:this.#Y,validations:this.compileValidations(Y),properties:Object.keys(this.#$).map((Z)=>{return this.#$[Z][E](Z,Y,M)}),groups:this.#g.map((Z)=>{return Z[E](Y,M)})}}},zY=W(($,g,Y)=>{if(!Y.isValid)return;if(Object.keys($).length<g.min)Y.report(X["record.minLength"],"record.minLength",Y,g)}),HY=W(($,g,Y)=>{if(!Y.isValid)return;if(Object.keys($).length>g.max)Y.report(X["record.maxLength"],"record.maxLength",Y,g)}),KY=W(($,g,Y)=>{if(!Y.isValid)return;if(Object.keys($).length!==g.size)Y.report(X["record.fixedLength"],"record.fixedLength",Y,g)}),CY=W(($,g,Y)=>{if(!Y.isValid)return;g(Object.keys($),Y)}),O9=class $ extends i${static rules={maxLength:HY,minLength:zY,fixedLength:KY,validateKeys:CY};#$;[Z$]="vine.object";[C$]=(g)=>{return g!==null&&typeof g==="object"&&!Array.isArray(g)};constructor(g,Y,M){super(Y,M);this.#$=g}minLength(g){return this.use(zY({min:g}))}maxLength(g){return this.use(HY({max:g}))}fixedLength(g){return this.use(KY({size:g}))}validateKeys(...g){return this.use(CY(...g))}clone(){return new $(this.#$.clone(),this.cloneOptions(),this.cloneValidations())}[E](g,Y,M){return{type:"record",fieldName:g,propertyName:M.toCamelCase?p(g):g,bail:this.options.bail,allowNull:this.options.allowNull,isOptional:this.options.isOptional,each:this.#$[E]("*",Y,M),parseFnId:this.options.parse?Y.trackParser(this.options.parse):void 0,validations:this.compileValidations(Y)}}},XY=W(($,g,Y)=>{if(typeof $!=="string")Y.report(X.string,"string",Y)}),WY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isEmail($,g))Y.report(X.email,"email",Y)}),QY=W(($,g,Y)=>{if(!Y.isValid)return;let M=g&&typeof g==="function"?g(Y):g,Z=M?.locale||"any";if(!B.isMobilePhone($,Z,M))Y.report(X.mobile,"mobile",Y)}),qY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isIP($,g?.version))Y.report(X.ipAddress,"ipAddress",Y)}),OY=W(($,g,Y)=>{if(!Y.isValid)return;if(!g.test($))Y.report(X.regex,"regex",Y)}),xY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isHexColor($))Y.report(X.hexCode,"hexCode",Y)}),GY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isURL($,g))Y.report(X.url,"url",Y)}),DY=W(async($,g,Y)=>{if(!Y.isValid)return;if(!await B.isActiveURL($))Y.report(X.activeUrl,"activeUrl",Y)}),UY=W(($,g,Y)=>{if(!Y.isValid)return;let M="a-zA-Z";if(g){if(g.allowSpaces)M+="\\s";if(g.allowDashes)M+="-";if(g.allowUnderscores)M+="_"}if(!new RegExp(`^[${M}]+\$`).test($))Y.report(X.alpha,"alpha",Y)}),LY=W(($,g,Y)=>{if(!Y.isValid)return;let M="a-zA-Z0-9";if(g){if(g.allowSpaces)M+="\\s";if(g.allowDashes)M+="-";if(g.allowUnderscores)M+="_"}if(!new RegExp(`^[${M}]+\$`).test($))Y.report(X.alphaNumeric,"alphaNumeric",Y)}),BY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length<g.min)Y.report(X.minLength,"minLength",Y,g)}),wY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length>g.max)Y.report(X.maxLength,"maxLength",Y,g)}),SY=W(($,g,Y)=>{if(!Y.isValid)return;if($.length!==g.size)Y.report(X.fixedLength,"fixedLength",Y,g)}),PY=W(($,g,Y)=>{if(!Y.isValid)return;if(!$.endsWith(g.substring))Y.report(X.endsWith,"endsWith",Y,g)}),kY=W(($,g,Y)=>{if(!Y.isValid)return;if(!$.startsWith(g.substring))Y.report(X.startsWith,"startsWith",Y,g)}),AY=W(($,g,Y)=>{if(!Y.isValid)return;if(B.getNestedValue(g.otherField,Y)!==$){Y.report(X.sameAs,"sameAs",Y,g);return}}),FY=W(($,g,Y)=>{if(!Y.isValid)return;if(B.getNestedValue(g.otherField,Y)===$){Y.report(X.notSameAs,"notSameAs",Y,g);return}}),VY=W(($,g,Y)=>{if(!Y.isValid)return;let M=g?.confirmationField||`${Y.name}_confirmation`;if(Y.parent[M]!==$){Y.report(X.confirmed,"confirmed",Y,{otherField:M});return}}),EY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate($.trim(),Y)}),IY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate(G9.default.default($,g),Y)}),TY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate($.toLocaleUpperCase(g),Y)}),jY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate($.toLocaleLowerCase(g),Y)}),_Y=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate(p($),Y)}),yY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate(x9.default.default($),Y)}),NY=W(($,g,Y)=>{if(!Y.isValid)return;Y.mutate(v1($,g),Y)}),hY=W(($,g,Y)=>{if(!Y.isValid)return;if(!(typeof g.choices==="function"?g.choices(Y):g.choices).includes($)){Y.report(X.in,"in",Y,g);return}}),RY=W(($,g,Y)=>{if(!Y.isValid)return;if((typeof g.list==="function"?g.list(Y):g.list).includes($)){Y.report(X.notIn,"notIn",Y,g);return}}),bY=W(($,g,Y)=>{if(!Y.isValid)return;let M=g?typeof g==="function"?g(Y)?.provider||[]:g.provider:[];if(!M.length){if(!B.isCreditCard($))Y.report(X.creditCard,"creditCard",Y,{providersList:"credit"})}else if(!M.find((J)=>B.isCreditCard($,{provider:J})))Y.report(X.creditCard,"creditCard",Y,{providers:M,providersList:M.join("/")})}),cY=W(($,g,Y)=>{if(!Y.isValid)return;let M=typeof g==="function"?g(Y).countryCode:g.countryCode;if(!M.find((J)=>B.isPassportNumber($,J)))Y.report(X.passport,"passport",Y,{countryCodes:M})}),mY=W(($,g,Y)=>{if(!Y.isValid)return;let M=g?typeof g==="function"?g(Y)?.countryCode||[]:g.countryCode:[];if(!M.length){if(!B.isPostalCode($,"any"))Y.report(X.postalCode,"postalCode",Y)}else if(!M.find((J)=>B.isPostalCode($,J)))Y.report(X.postalCode,"postalCode",Y,{countryCodes:M})}),fY=W(($,g,Y)=>{if(!Y.isValid)return;if(!g||!g.version){if(!B.isUUID($))Y.report(X.uuid,"uuid",Y)}else if(!g.version.find((Z)=>B.isUUID($,Z)))Y.report(X.uuid,"uuid",Y,g)}),vY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isAscii($))Y.report(X.ascii,"ascii",Y)}),uY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isIBAN($))Y.report(X.iban,"iban",Y)}),rY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isJWT($))Y.report(X.jwt,"jwt",Y)}),nY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isLatLong($))Y.report(X.coordinates,"coordinates",Y)}),u0=class $ extends x${static rules={in:hY,jwt:rY,url:GY,iban:uY,uuid:fY,trim:EY,email:WY,alpha:UY,ascii:vY,notIn:RY,regex:OY,escape:yY,sameAs:AY,mobile:QY,string:XY,hexCode:xY,passport:cY,endsWith:PY,confirmed:VY,activeUrl:DY,minLength:BY,notSameAs:FY,maxLength:wY,ipAddress:qY,creditCard:bY,postalCode:mY,startsWith:kY,toUpperCase:TY,toLowerCase:jY,toCamelCase:_Y,fixedLength:SY,coordinates:nY,normalizeUrl:NY,alphaNumeric:LY,normalizeEmail:IY};[Z$]="vine.string";[C$]=(g)=>{return typeof g==="string"};constructor(g,Y){super(g,Y||[XY()])}url(...g){return this.use(GY(...g))}activeUrl(){return this.use(DY())}email(...g){return this.use(WY(...g))}mobile(...g){return this.use(QY(...g))}ipAddress(g){return this.use(qY(g?{version:g}:void 0))}hexCode(){return this.use(xY())}regex(g){return this.use(OY(g))}alpha(g){return this.use(UY(g))}alphaNumeric(g){return this.use(LY(g))}minLength(g){return this.use(BY({min:g}))}maxLength(g){return this.use(wY({max:g}))}fixedLength(g){return this.use(SY({size:g}))}confirmed(g){return this.use(VY(g))}trim(){return this.use(EY())}normalizeEmail(g){return this.use(IY(g))}toUpperCase(){return this.use(TY())}toLowerCase(){return this.use(jY())}toCamelCase(){return this.use(_Y())}escape(){return this.use(yY())}normalizeUrl(...g){return this.use(NY(...g))}startsWith(g){return this.use(kY({substring:g}))}endsWith(g){return this.use(PY({substring:g}))}sameAs(g){return this.use(AY({otherField:g}))}notSameAs(g){return this.use(FY({otherField:g}))}in(g){return this.use(hY({choices:g}))}notIn(g){return this.use(RY({list:g}))}creditCard(...g){return this.use(bY(...g))}passport(...g){return this.use(cY(...g))}postalCode(...g){return this.use(mY(...g))}uuid(...g){return this.use(fY(...g))}ascii(){return this.use(vY())}iban(){return this.use(uY())}jwt(){return this.use(rY())}coordinates(){return this.use(nY())}clone(){return new $(this.cloneOptions(),this.cloneValidations())}},tY=W(($,g,Y)=>{let M=g.strict?$:B.asNumber($);if(typeof M!=="number"||Number.isNaN(M)||M===Number.POSITIVE_INFINITY||M===Number.NEGATIVE_INFINITY){Y.report(X.number,"number",Y);return}Y.mutate(M,Y)}),dY=W(($,g,Y)=>{if(!Y.isValid)return;if($<g.min)Y.report(X.min,"min",Y,g)}),pY=W(($,g,Y)=>{if(!Y.isValid)return;if($>g.max)Y.report(X.max,"max",Y,g)}),sY=W(($,g,Y)=>{if(!Y.isValid)return;if($<g.min||$>g.max)Y.report(X.range,"range",Y,g)}),aY=W(($,g,Y)=>{if(!Y.isValid)return;if($<0)Y.report(X.positive,"positive",Y)}),lY=W(($,g,Y)=>{if(!Y.isValid)return;if($>=0)Y.report(X.negative,"negative",Y)}),iY=W(($,g,Y)=>{if(!Y.isValid)return;if(!B.isDecimal(String($),{force_decimal:g.range[0]!==0,decimal_digits:g.range.join(",")}))Y.report(X.decimal,"decimal",Y,{digits:g.range.join("-")})}),oY=W(($,g,Y)=>{if(!Y.isValid)return;if(!Number.isInteger($))Y.report(X.withoutDecimals,"withoutDecimals",Y)}),eY=W(($,g,Y)=>{if(!Y.isValid)return;if(!g.values.includes($))Y.report(X["number.in"],"in",Y,g)}),b$=class $ extends x${static rules={in:eY,max:pY,min:dY,range:sY,number:tY,decimal:iY,negative:lY,positive:aY,withoutDecimals:oY};[Z$]="vine.number";[C$]=(g)=>{let Y=B.asNumber(g);return!Number.isNaN(Y)};constructor(g,Y){super(g,Y||[tY(g||{})])}min(g){return this.use(dY({min:g}))}max(g){return this.use(pY({max:g}))}range(g){return this.use(sY({min:g[0],max:g[1]}))}positive(){return this.use(aY())}negative(){return this.use(lY())}decimal(g){return this.use(iY({range:Array.isArray(g)?g:[g]}))}withoutDecimals(){return this.use(oY())}clone(){return new $(this.cloneOptions(),this.cloneValidations())}in(g){return this.use(eY({values:g}))}},$9=W(($,g,Y)=>{let M=g.strict===!0?$:B.asBoolean($);if(typeof M!=="boolean"){Y.report(X.boolean,"boolean",Y);return}Y.mutate(M,Y)}),c$=class $ extends x${static rules={boolean:$9};[Z$]="vine.boolean";[C$]=(g)=>{return typeof(this.options.strict===!0?g:B.asBoolean(g))==="boolean"};constructor(g,Y){super(g,Y||[$9(g||{})])}clone(){return new $(this.cloneOptions(),this.cloneValidations())}},g9=W(($,g,Y)=>{let M=$;if(typeof g.expectedValue==="boolean")M=B.asBoolean($);else if(typeof g.expectedValue==="number")M=B.asNumber($);if(M!==g.expectedValue){Y.report(X.literal,"literal",Y,g);return}Y.mutate(M,Y)}),D9=class $ extends x${static rules={equals:g9};#$;constructor(g,Y,M){super(Y,M||[g9({expectedValue:g})]);this.#$=g}clone(){return new $(this.#$,this.cloneOptions(),this.cloneValidations())}},W4=["on","1","yes","true",!0,1],Y9=W(($,g,Y)=>{if(!W4.includes($))Y.report(X.accepted,"accepted",Y)}),U9=class $ extends x${static rules={accepted:Y9};constructor(g,Y){super(g,Y||[Y9()])}clone(){return new $(this.cloneOptions(),this.cloneValidations())}},Q4=class ${#$;#g=(g,Y)=>{Y.report(X.unionGroup,"unionGroup",Y)};constructor(g){this.#$=g}clone(){let g=new $(this.#$);return g.otherwise(this.#g),g}otherwise(g){return this.#g=g,this}[E](g,Y){return{type:"group",elseConditionalFnRefId:g.trackConditional(this.#g),conditions:this.#$.map((M)=>M[E](g,Y))}}},L9=class{#$;#g;constructor($,g){this.#$=g,this.#g=$}[E]($,g){return{schema:{type:"sub_object",properties:Object.keys(this.#$).map((Y)=>{return this.#$[Y][E](Y,$,g)}),groups:[]},conditionalFnRefId:$.trackConditional(this.#g)}}};function p1($){return new Q4($)}p1.if=function $(g,Y){return new L9(g,Y)};p1.else=function $(g){return new L9(()=>!0,g)};var q4=class $ extends x${static rules={enum:f0};#$;constructor(g,Y,M){super(Y,M||[f0({choices:Object.values(g)})]);this.#$=g}clone(){return new $(this.#$,this.cloneOptions(),this.cloneValidations())}},O4=class ${#$;#g=(g,Y)=>{Y.report(X.unionOfTypes,"unionOfTypes",Y)};constructor(g){this.#$=g}otherwise(g){return this.#g=g,this}clone(){let g=new $(this.#$);return g.otherwise(this.#g),g}[E](g,Y,M){return{type:"union",fieldName:g,propertyName:M.toCamelCase?p(g):g,elseConditionalFnRefId:Y.trackConditional(this.#g),conditions:this.#$.map((Z)=>{return{conditionalFnRefId:Y.trackConditional((J,z)=>{return Z[C$](J,z)}),schema:Z[E](g,Y,M)}})}}},x4=class extends y${group=p1;union=d1;string(){return new u0}boolean($){return new c$($)}accepted(){return new U9}number($){return new b$($)}date($){return new t1($)}literal($){return new D9($)}object($){return new q9($)}array($){return new Q9($)}tuple($){return new W9($)}record($){return new O9($)}enum($){if(Array.isArray($)||typeof $==="function")return new R$($);return new q4($)}any(){return new Z9}unionOfTypes($){let g=new Set;return $.forEach((Y)=>{if(!Y[C$]||!Y[Z$])throw new Error(`Cannot use "${Y.constructor.name}". The schema type is not compatible for use with "vine.unionOfTypes"`);if(g.has(Y[Z$]))throw new Error(`Cannot use duplicate schema "${Y[Z$]}". "vine.unionOfTypes" needs distinct schema types only`);g.add(Y[Z$])}),g.clear(),new O4($)}},G4={required:X.required,array:X.array,object:X.object},n1=class{#$;messagesProvider;errorReporter;#g($){let g=f2();return{compilerNode:{type:"root",schema:$[E]("",g,{toCamelCase:!1})},refs:g.toJSON()}}constructor($,g){let{compilerNode:Y,refs:M}=this.#g($);this.#$={schema:Y,refs:M};let Z=g.metaDataValidator,J=new m2(Y,{convertEmptyStringsToNull:g.convertEmptyStringsToNull,messages:G4}).compile();if(this.errorReporter=g.errorReporter,this.messagesProvider=g.messagesProvider,Z)this.validate=(z,H)=>{let K=H??{},x=K.meta??{},A=K.errorReporter??this.errorReporter,I=K.messagesProvider??this.messagesProvider;return Z(x),J(z,x,M,I,A())};else this.validate=(z,H)=>{let K=H??{},x=K.meta??{},A=K.errorReporter??this.errorReporter,I=K.messagesProvider??this.messagesProvider;return J(z,x,M,I,A())}}async tryValidate($,...[g]){try{return[null,await this.validate($,g)]}catch(Y){if(Y instanceof E1)return[Y,null];throw Y}}toJSON(){let{schema:$,refs:g}=this.#$;return{schema:structuredClone($),refs:g}}},B9=class extends x4{messagesProvider=new d$(X,Zg);errorReporter=()=>new I1;convertEmptyStringsToNull=!1;helpers=B;createRule=W;compile($){return new n1($,{convertEmptyStringsToNull:this.convertEmptyStringsToNull,messagesProvider:this.messagesProvider,errorReporter:this.errorReporter})}withMetaData($){return{compile:(g)=>{return new n1(g,{convertEmptyStringsToNull:this.convertEmptyStringsToNull,messagesProvider:this.messagesProvider,errorReporter:this.errorReporter,metaDataValidator:$})}}}validate($){return this.compile($.schema).validate($.data,$)}tryValidate($){return this.compile($.schema).tryValidate($.data,$)}},D4=new B9,D=D4;import{path as SC}from"@stacksjs/path";var S9={APP_NAME:D.string(),APP_ENV:D.enum(["local","dev","stage","prod"]),APP_KEY:D.string(),APP_URL:D.string(),PORT:D.number(),PORT_BACKEND:D.number(),PORT_ADMIN:D.number(),PORT_LIBRARY:D.number(),PORT_DESKTOP:D.number(),PORT_EMAIL:D.number(),PORT_DOCS:D.number(),PORT_INSPECT:D.number(),PORT_API:D.number(),PORT_SYSTEM_TRAY:D.number(),APP_MAINTENANCE:D.boolean(),DEBUG:D.boolean(),API_PREFIX:D.string(),DOCS_PREFIX:D.string(),DB_CONNECTION:D.enum(["mysql","sqlite","postgres"]),DB_HOST:D.string(),DB_PORT:D.number(),DB_DATABASE:D.string(),DB_USERNAME:D.string(),DB_PASSWORD:D.string(),AWS_ACCOUNT_ID:D.string(),AWS_ACCESS_KEY_ID:D.string(),AWS_SECRET_ACCESS_KEY:D.string(),AWS_DEFAULT_REGION:D.string(),AWS_DEFAULT_PASSWORD:D.string(),MAIL_MAILER:D.enum(["ses","sendmail","log","smtp"]),MAIL_HOST:D.string(),MAIL_PORT:D.number(),MAIL_USERNAME:D.string(),MAIL_PASSWORD:D.string(),MAIL_ENCRYPTION:D.string(),MAIL_FROM_NAME:D.string(),MAIL_FROM_ADDRESS:D.string(),SEARCH_ENGINE_DRIVER:D.enum(["meilisearch","algolia","typesense"]),MEILISEARCH_HOST:D.string(),MEILISEARCH_KEY:D.string(),FRONTEND_APP_ENV:D.enum(["development","staging","production"]),FRONTEND_APP_URL:D.string()};var U4={APP_ENV:["local","dev","development","staging","prod","production"],DB_CONNECTION:["mysql","sqlite","postgres","dynamodb"],MAIL_MAILER:["smtp","mailgun","ses","postmark","sendmail","log"],SEARCH_ENGINE_DRIVER:["opensearch"],FRONTEND_APP_ENV:["development","staging","production"]},L4=Object.entries(S9).reduce(($,[g,Y])=>{let M;switch(typeof Y){case"string":M=D.string();break;case"number":M=D.number();break;case"boolean":M=D.boolean();break;default:if(Array.isArray(Y)){M=D.enum(Y);break}if(typeof Y==="object"){let J=Symbol.for("schema_name"),z=Y[J];if(z==="vine.string"){M=D.string();break}if(z==="vine.number"){M=D.number();break}if(z==="vine.boolean"){M=D.boolean();break}if(!z){M=D.enum(U4.APP_ENV);break}console.error("Unknown env value type",typeof Y)}throw new Error(`Invalid env value for ${g}`)}let Z=g;return $[Z]=M,$},{}),bC=D.object(L4);var w4={get:($,g)=>{let Y=$[g];if(typeof Y==="string"&&/^\d+$/.test(Y)&&g!=="AWS_ACCOUNT_ID")return Number(Y);if(typeof Y==="string"&&/^true|false$/.test(Y))return Y==="true";if(Y instanceof R$)return $[g];if(Y instanceof c$)return!!$[g];if(Y instanceof b$)return Number($[g]);return Y}};function S4(){return typeof Bun!=="undefined"?Bun.env:B4.env}var U=new Proxy(S4(),w4);var P9={name:U.APP_NAME??"Stacks",description:"Stacks is a full-stack framework for building modern web applications.",env:U.APP_ENV??"local",url:U.APP_URL??"stacks.localhost",redirectUrls:["stacksjs.com"],debug:U.DEBUG??!1,key:U.APP_KEY,maintenanceMode:U.APP_MAINTENANCE??!1,docMode:!1,timezone:"America/Los_Angeles",locale:"en",fallbackLocale:"en",cipher:"aes-256-cbc"};var k9={driver:"dynamodb",prefix:"stacks",ttl:3600,drivers:{dynamodb:{key:U.AWS_ACCESS_KEY_ID||"",secret:U.AWS_SECRET_ACCESS_KEY||"",region:U.AWS_DEFAULT_REGION||"us-east-1",table:"cache",endpoint:""},memcached:{persistent_id:"",sasl:["",""],options:{},servers:[{host:"127.0.0.1",port:11211,weight:100}]},redis:{connection:"cache",host:"127.0.0.1",port:6379,password:"",username:"stacks"}}};var A9={name:"My Custom CLI",command:"custom-cli",description:"This is an example command to illustrate how to create your own commands. Check out `../app/commands` for more.",deploy:!0};var r0={firewall:{enabled:!0,countryCodes:["RU","IR"],ipAddresses:[],rateLimitPerMinute:1000,useIpReputationLists:!0,useKnownBadInputsRuleSet:!0,queryString:[],httpHeaders:[]}};var F9={sites:{root:"stacksjs.org",path:"dist",modals:{domain:"modals.stacksjs.org",path:"dist"},stepper:{domain:"stepper.stacksjs.org",path:"dist"},notification:{domain:"notification.stacksjs.org",path:"dist"},docs:{domain:"docs.stacksjs.org",path:"dist"},tlsx:{domain:"tlsx.stacksjs.org",path:"dist"},dtsx:{domain:"dtsx.stacksjs.org",path:"dist"},spreadsheet:{domain:"spreadsheet.stacksjs.org",path:"dist"}},infrastructure:{type:"serverless",driver:"aws",firewall:r0.firewall,environments:["production","staging","development"],storage:{},api:{prefix:U.API_PREFIX||"api",description:"My awesome Stacks API",deploy:!0,memorySize:512,prewarm:10,timeout:30},cdn:{compress:!0,allowedMethods:"ALL",cachedMethods:"GET_HEAD",originShieldRegion:"us-east-1",minTtl:0,defaultTtl:86400,maxTtl:31536000,cookieBehavior:"none",allowList:{cookies:[],headers:[],queryStrings:[]},realtimeLogs:{enabled:!0,samplingRate:1}},fileSystem:!0}};var V9={default:U.DB_CONNECTION||"sqlite",connections:{sqlite:{database:U.DB_DATABASE||"database/stacks.sqlite",prefix:""},dynamodb:{key:U.AWS_ACCESS_KEY_ID||"",secret:U.AWS_SECRET_ACCESS_KEY||"",region:U.AWS_DEFAULT_REGION||"us-east-1",prefix:U.DB_DATABASE||"stacks",endpoint:"http://localhost",port:U.DB_PORT||8000},mysql:{name:U.DB_DATABASE||"stacks",host:U.DB_HOST||"127.0.0.1",port:U.DB_PORT||3306,username:U.DB_USERNAME||"root",password:U.DB_PASSWORD||"",prefix:""},postgres:{name:U.DB_DATABASE||"stacks",host:U.DB_HOST||"127.0.0.1",port:U.DB_PORT||3306,username:U.DB_USERNAME||"",password:U.DB_PASSWORD||"",prefix:""}},migrations:"migrations",migrationLocks:"migration_locks"};var E9={a:[{name:U.APP_URL||"",address:"10.0.0.1",ttl:300},{name:"www",address:"@",ttl:300}],aaaa:[],cname:[],mx:[],txt:[],nameservers:[]};var I9={from:{name:U.MAIL_FROM_NAME||"Stacks",address:U.MAIL_FROM_ADDRESS||"no-reply@stacksjs.org"},mailboxes:["chris@stacksjs.org","blake@stacksjs.org","glenn@stacksjs.org"],url:U.APP_URL||"http://localhost:3000",charset:"UTF-8",server:{scan:!0}};var T9={messages:{string:"The {{ field }} field must be a string",email:"The {{ field }} field must be a valid email address",regex:"The {{ field }} field format is invalid",url:"The {{ field }} field must be a valid URL",activeUrl:"The {{ field }} field must be a valid URL",alpha:"The {{ field }} field must contain only letters",alphaNumeric:"The {{ field }} field must contain only letters and numbers",minLength:"The {{ field }} field must have at least {{ min }} characters",maxLength:"The {{ field }} field must not be greater than {{ max }} characters",fixedLength:"The {{ field }} field must be {{ size }} characters long",confirmed:"The {{ field }} field and {{ otherField }} field must be the same",endsWith:"The {{ field }} field must end with {{ substring }}",startsWith:"The {{ field }} field must start with {{ substring }}",sameAs:"The {{ field }} field and {{ otherField }} field must be the same",notSameAs:"The {{ field }} field and {{ otherField }} field must be different",in:"The selected {{ field }} is invalid",notIn:"The selected {{ field }} is invalid",ipAddress:"The {{ field }} field must be a valid IP address",uuid:"The {{ field }} field must be a valid UUID",ascii:"The {{ field }} field must only contain ASCII characters",creditCard:"The {{ field }} field must be a valid {{ providersList }} card number",hexCode:"The {{ field }} field must be a valid hex color code",iban:"The {{ field }} field must be a valid IBAN number",jwt:"The {{ field }} field must be a valid JWT token",coordinates:"The {{ field }} field must contain latitude and longitude coordinates",mobile:"The {{ field }} field must be a valid mobile phone number",passport:"The {{ field }} field must be a valid passport number",postalCode:"The {{ field }} field must be a valid postal code",boolean:"The value must be a boolean",number:"The {{ field }} field must be a number",min:"The {{ field }} field must be at least {{ min }}",max:"The {{ field }} field must not be greater than {{ max }}",range:"The {{ field }} field must be between {{ min }} and {{ max }}",positive:"The {{ field }} field must be positive",negative:"The {{ field }} field must be negative",decimal:"The {{ field }} field must have {{ digits }} decimal places",withoutDecimals:"The {{ field }} field must not have decimal places",date:"The {{ field }} field must be a datetime value","date.equals":"The {{ field }} field must be a date equal to {{ expectedValue }}","date.after":"The {{ field }} field must be a date after {{ expectedValue }}","date.before":"The {{ field }} field must be a date before {{ expectedValue }}","date.afterOrEqual":"The {{ field }} field must be a date after or equal to {{ expectedValue }}","date.beforeOrEqual":"The {{ field }} field must be a date before or equal to {{ expectedValue }}","date.sameAs":"The {{ field }} field and {{ otherField }} field must be the same","date.notSameAs":"The {{ field }} field and {{ otherField }} field must be different","date.afterField":"The {{ field }} field must be a date after {{ otherField }}",accepted:"The {{ field }} field must be accepted",enum:"The selected {{ field }} is invalid",literal:"The {{ field }} field must be {{ expectedValue }}",object:"The {{ field }} field must be an object",record:"The {{ field }} field must be an object","record.minLength":"The {{ field }} field must have at least {{ min }} items","record.maxLength":"The {{ field }} field must not have more than {{ max }} items","record.fixedLength":"The {{ field }} field must contain {{ size }} items",array:"The {{ field }} field must be an array","array.minLength":"The {{ field }} field must have at least {{ min }} items","array.maxLength":"The {{ field }} field must not have more than {{ max }} items","array.fixedLength":"The {{ field }} field must contain {{ size }} items",notEmpty:"The {{ field }} field must not be empty",distinct:"The {{ field }} field has duplicate values",tuple:"The {{ field }} field must be an array",union:"Invalid value provided for {{ field }} field",unionGroup:"Invalid value provided for {{ field }} field",unionOfTypes:"Invalid value provided for {{ field }} field"}};var j9={hooks:{"pre-commit":"lint-staged"},scopes:["","ci","deps","dx","release","docs","test","core","actions","arrays","auth","build","cache","cli","cloud","collections","config","database","datetime","docs","errors","git","lint","x-ray","modules","notifications","objects","path","realtime","router","buddy","security","server","storage","strings","tests","types","ui","utils"],messages:{type:"Select the type of change that you\u2019re committing:",scope:"Select the SCOPE of this change (optional):",customScope:"Select the SCOPE of this change:",subject:"Write a SHORT, IMPERATIVE tense description of the change:\n",body:'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',breaking:'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',footerPrefixesSelect:"Select the ISSUES type of the change list by this change (optional):",customFooterPrefixes:"Input ISSUES prefix:",footer:"List any ISSUES by this change. E.g.: #31, #34:\n",confirmCommit:"Are you sure you want to proceed with the commit above?"},types:[{value:"feat",name:"feat: \u2728 A new feature",emoji:":sparkles:"},{value:"fix",name:"fix: \uD83D\uDC1B A bug fix",emoji:":bug:"},{value:"docs",name:"docs: \uD83D\uDCDD Documentation only changes",emoji:":memo:"},{value:"style",name:"style: \uD83D\uDC84 Changes that do not affect the meaning of the code",emoji:":lipstick:"},{value:"refactor",name:"refactor: \u267B\uFE0F A code change that neither fixes a bug nor adds a feature",emoji:":recycle:"},{value:"perf",name:"perf: \u26A1\uFE0F A code change that improves performance",emoji:":zap:"},{value:"test",name:"test: \u2705 Adding missing tests or adjusting existing tests",emoji:":white_check_mark:"},{value:"build",name:"build: \uD83D\uDCE6\uFE0F Changes that affect the build system or external dependencies",emoji:":package:"},{value:"ci",name:"ci: \uD83C\uDFA1 Changes to our CI configuration files and scripts",emoji:":ferris_wheel:"},{value:"chore",name:"chore: \uD83D\uDD28 Other changes that don\u2019t modify src or test files",emoji:":hammer:"},{value:"revert",name:"revert: \u23EA\uFE0F Reverts a previous commit",emoji:":rewind:"}]};var _9={driver:"argon2",bcrypt:{rounds:10,cost:4},argon2:{memory:65536,threads:1,time:1}};var y9={name:"hello-world",owner:"@stacksjs",repository:"stacksjs/stacks",license:"MIT",author:"Chris Breuer",contributors:["Chris Breuer <chris@stacksjs.org>"],defaultLanguage:"en",releaseable:!0,vueComponents:{name:"hello-world-vue",description:"Your Vue component library description",keywords:["component","library","vue","vite","typescript","javascript"],tags:[{name:["HelloWorld","AppHelloWorld"],description:"The Hello World custom element, built via this framework.",attributes:[{name:"greeting",description:"The greeting."}]}]},webComponents:{name:"hello-world-elements",description:"Your framework agnostic web component library description.",keywords:["custom-elements","web-components","library","framework-agnostic","typescript","javascript"],tags:[{name:["HelloWorld","AppHelloWorld"],description:"The Hello World custom element, built via this framework.",attributes:[{name:"greeting",description:"The greeting."}]}]},functions:{name:"hello-world-fx",description:"Your function library description.",keywords:["functions","composables","library","typescript","javascript"],shouldGenerateSourcemap:!1,files:["counter","dark"]}};import{storagePath as N9}from"@stacksjs/path";var h9={logsPath:N9("logs/stacks.log"),deploymentsPath:N9("logs/deployments.log")};var R9={default:"email"};var b9={driver:"stripe",stripe:{publishableKey:U.STRIPE_PUBLISHABLE_KEY||"",secretKey:U.STRIPE_SECRET_KEY||""}};var c9={frontend:U.PORT??3000,backend:U.PORT_BACKEND??3001,admin:U.PORT_ADMIN??3002,library:U.PORT_LIBRARY??3003,desktop:U.PORT_DESKTOP??3004,email:U.PORT_EMAIL??3005,docs:U.PORT_DOCS??3006,inspect:U.PORT_INSPECT??3007,api:U.PORT_API??3008,systemTray:U.PORT_SYSTEM_TRAY??3009,database:3010};var m9={default:"sync",connections:{sync:{driver:"sync"},sqs:{driver:"sqs",key:"",secret:"",prefix:"",suffix:"",queue:"default",region:"us-east-1"}}};var f9={plans:[{productName:"Stacks Hobby",description:"All the Stacks features.",pricing:[{key:"stacks_hobby_monthly",price:3900,interval:"month",currency:"usd"},{key:"stacks_hobby_yearly",price:37900,interval:"year",currency:"usd"}],metadata:{createdBy:"admin",version:"1.0.0"}},{productName:"Stacks Pro",description:"All the Stacks features, including being able to invite team members.",pricing:[{key:"stacks_pro_monthly",price:5900,interval:"month",currency:"usd"},{key:"stacks_pro_yearly",price:57900,interval:"year",currency:"usd"}],metadata:{createdBy:"admin",version:"1.0.0"}}],webhook:{endpoint:"/webhooks/stripe",secret:""},currencies:["usd"],coupons:[{code:"SUMMER2024",amountOff:500,duration:"once"}],products:[{name:"Stacks Pro",description:"All the Stacks features.",images:["url_to_image"]}]};var v9={driver:"opensearch"};var u9={aws:{accountId:U.AWS_ACCOUNT_ID||"",appId:U.AWS_ACCESS_KEY_ID||"",apiKey:U.AWS_SECRET_ACCESS_KEY||"",region:U.AWS_DEFAULT_REGION||"us-east-1"},algolia:{appId:"",apiKey:""},meilisearch:{appId:"",apiKey:""},lemonSqueezy:{appId:"",apiKey:""},stripe:{appId:"",apiKey:""}};var r9={driver:"s3"};var n9={name:"Stacks",members:{chris:"chris@stacksjs.org",blake:"blake@stacksjs.org",zoltan:"zoltan@stacksjs.org",freddy:"freddy@stacksjs.org",glenn:"glenn@stacksjs.org",dorell:"dorell@stacksjs.org",avery:"avery@stacksjs.org",adelino:"adelino@stacksjs.org"}};var t9={shortcuts:[["btn","inline-flex items-center px-4 py-2 ml-2 border border-transparent shadow-sm text-base font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 cursor-pointer"]],safelist:"prose prose-sm m-auto text-left",trigger:":stx:",classPrefix:"stx-",reset:"tailwind",icons:["heroicons"],fonts:{email:{title:"Mona",text:"Hubot"},desktop:{title:"Mona",text:"Hubot"},mobile:{title:"Mona",text:"Hubot"},web:{title:"Mona",text:"Hubot"}},theme:{colors:{veryCool:"#0000ff",brand:{primary:"hsl(var(--hue, 217) 78% 51%)"}}}};var P4={ai:a1,analytics:l1,app:P9,cache:k9,cli:A9,cloud:F9,database:V9,dns:E9,email:I9,errors:T9,git:j9,hashing:_9,library:y9,logging:h9,notification:R9,queue:m9,payment:b9,ports:c9,saas:f9,searchEngine:v9,security:r0,services:u9,storage:r9,team:n9,ui:t9},s1=P4;async function d9($){if(!$?.port)$={port:3000};return console.log("Creating local tunnel",$.port),"localTunnel"}async function B$($){return await d9({port:$})}async function k4({domain:$=v.app.url||"stacks",type:g="frontend",localhost:Y=!1,https:M=void 0,network:Z=void 0}={}){let J=$.replace(/\.[^.]+$/,".localhost");switch(g){case"frontend":if(Z)return await B$(v.ports?.frontend||3000);if(Y)return`http://localhost:${v.ports?.frontend}`;break;case"backend":if(Z)return await B$(v.ports?.backend||3001);if(Y)return`http://localhost:${v.ports?.backend}`;J=`api.${J}`;break;case"admin":if(Z)return await B$(v.ports?.admin||3002);if(Y)return`http://localhost:${v.ports?.admin}`;J=`admin.${J}`;break;case"library":if(Z)return await B$(v.ports?.library||3003);if(Y)return`http://localhost:${v.ports?.library}`;J=`libs.${J}`;break;case"email":if(Z)return await B$(v.ports?.email||3005);if(Y)return`http://localhost:${v.ports?.email}`;J=`email.${J}`;break;case"desktop":if(Z)return await B$(v.ports?.desktop||3004);if(Y)return`http://localhost:${v.ports?.desktop}`;J=`desktop.${J}`;break;case"docs":if(Z)return await B$(v.ports?.docs||3006);if(Y)return`http://localhost:${v.ports?.docs}`;J=`docs.${J}`;break;case"inspect":if(Z)return await B$(v.ports?.inspect||3007);if(Y)return`http://localhost:${v.ports?.inspect}`;J=`inspect.${J}`;break;default:if(Y)return`http://localhost:${v.ports?.frontend}`}if(M)return`https://${J}`;return`http://${J}`}function A4($){return $}function F4($){return $}function V4($){return $}function E4($){return $}function I4($){return $}function T4($){return $}function j4($){return $}function _4($){return $}function y4($){return $}function N4($){return $}function h4($){return $}function R4($){return $}function b4($){return $}function c4($){return $}function m4($){return $}function f4($){return $}function v4($){return $}function u4($){return $}function r4($){return $}function n4($){return $}function t4($){return $}function d4($){return $}function p4($){return $}function s4($){return $}function a4($){return $}function l4($){return $}function i4($){return $}var y={...a0,...s1},o4=y.ai,e4=y.analytics,T$=y.app,$8=y.cache,g8=y.cloud,Y8=y.cli,M8=y.database,Z8=y.dns,J8=y.docs,z8=y.email,H8=y.errors,K8=y.git,C8=y.hashing,X8=y.library,W8=y.logging,Q8=y.notification,q8=y.payment,O8=y.ports,x8=y.queue,G8=y.security,D8=y.saas,U8=y.searchEngine,L8=y.services,B8=y.storage,w8=y.team,S8=y.ui;function P8(){if(T$.env==="local")return"dev";if(T$.env==="development")return"dev";if(T$.env==="staging")return"stage";if(T$.env==="production")return"prod";if(!T$.env)throw new Error("Couldn\'t determine app environment");return T$.env}import*as o$ from"@stacksjs/path";class e${static isTestEnvironment=!1;static shouldExitProcess=!0;static handle($,g){if(this.shouldExitProcess=g?.shouldExit!==!1,g?.silent!==!0)this.writeErrorToConsole($);let Y;if(g?.message)Y=g.message;else if($ instanceof Error)Y=$.message;else if(typeof $==="string")Y=$;else Y=JSON.stringify($);let M=new Error(Y);if($ instanceof Error)Object.assign(M,$);return this.writeErrorToFile(M).catch((Z)=>console.error(Z)),M}static handleError($,g){return this.handle($,g),$}static async writeErrorToFile($){if(!($ instanceof Error)){console.error("Error is not an instance of Error:",$);return}let g=`[${new Date().toISOString()}] ${$.name}: ${$.message}\n`,Y=o$.logsPath("stacks.log")??o$.logsPath("errors.log");try{await a9(o$.dirname(Y),{recursive:!0}),await s9(Y,g)}catch(M){console.error("Failed to write to error file:",M)}}static writeErrorToConsole($){console.error($);let g=typeof $==="string"?$:$ instanceof Error?$.message:JSON.stringify($);if(g.includes("bunx --bun cdk destroy")||g===`Failed to execute command: ${p9("bunx --bun eslint . --fix")}`||g===`Failed to execute command: ${p9("bun storage/framework/core/actions/src/lint/fix.ts")}`){if(!this.isTestEnvironment)console.log("No need to worry. The edge function is currently being destroyed. Please run `buddy undeploy` shortly again, and continue doing so until it succeeds running."),console.log("Hoping to see you back soon!")}if(this.shouldExitProcess)F8.exit(1)}}function GW($,g){let Y;if(Mg($))Y=$;else if($ instanceof Error)Y=$.message;else if(g instanceof Error)Y=g.message;else Y=String($);return E8(`ERROR: ${V8(Y)}`),e$.handle($,g)}async function E8($,g){let Y=`[${new Date().toISOString()}] ${$}\n`;try{let M=g?.logFile??v.logging.logsPath??"storage/logs/stacks.log";try{await k8(M)}catch{await a9(A8(M),{recursive:!0})}await s9(M,Y)}catch(M){console.error("Failed to write to log file:",M)}}class w9 extends Error{$;constructor($,g){super(g);this.status=$;this.name="Server Error!"}}function BW($,g,Y){try{let M=$();if(M instanceof Promise)return M.catch((Z)=>{if(Y)Y(e$.handle(Z));return g});return M}catch(M){if(Y)Y(e$.handle(M));return g}}var I8={withStackTrace:!1},o9=($,g,Y=I8)=>{let M=g.isOk()?{type:"Ok",value:g.value}:{type:"Err",value:g.error},Z=Y.withStackTrace?new Error().stack:void 0;return{data:M,message:$,stack:Z}};function m$($,g,Y,M){function Z(J){return J instanceof Y?J:new Y(function(z){z(J)})}return new(Y||(Y=Promise))(function(J,z){function H(A){try{x(M.next(A))}catch(I){z(I)}}function K(A){try{x(M.throw(A))}catch(I){z(I)}}function x(A){A.done?J(A.value):Z(A.value).then(H,K)}x((M=M.apply($,g||[])).next())})}function l9($){var g=typeof Symbol==="function"&&Symbol.iterator,Y=g&&$[g],M=0;if(Y)return Y.call($);if($&&typeof $.length==="number")return{next:function(){if($&&M>=$.length)$=void 0;return{value:$&&$[M++],done:!$}}};throw new TypeError(g?"Object is not iterable.":"Symbol.iterator is not defined.")}function G$($){return this instanceof G$?(this.v=$,this):new G$($)}function i9($,g,Y){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var M=Y.apply($,g||[]),Z,J=[];return Z=Object.create((typeof AsyncIterator==="function"?AsyncIterator:Object).prototype),H("next"),H("throw"),H("return",z),Z[Symbol.asyncIterator]=function(){return this},Z;function z(k){return function(O){return Promise.resolve(O).then(k,I)}}function H(k,O){if(M[k]){if(Z[k]=function(V){return new Promise(function(N,_){J.push([k,V,N,_])>1||K(k,V)})},O)Z[k]=O(Z[k])}}function K(k,O){try{x(M[k](O))}catch(V){u(J[0][3],V)}}function x(k){k.value instanceof G$?Promise.resolve(k.value.v).then(A,I):u(J[0][2],k)}function A(k){K("next",k)}function I(k){K("throw",k)}function u(k,O){if(k(O),J.shift(),J.length)K(J[0][0],J[0][1])}}function T8($){var g,Y;return g={},M("next"),M("throw",function(Z){throw Z}),M("return"),g[Symbol.iterator]=function(){return this},g;function M(Z,J){g[Z]=$[Z]?function(z){return(Y=!Y)?{value:G$($[Z](z)),done:!1}:J?J(z):z}:J}}function j8($){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var g=$[Symbol.asyncIterator],Y;return g?g.call($):($=typeof l9==="function"?l9($):$[Symbol.iterator](),Y={},M("next"),M("throw"),M("return"),Y[Symbol.asyncIterator]=function(){return this},Y);function M(J){Y[J]=$[J]&&function(z){return new Promise(function(H,K){z=$[J](z),Z(H,K,z.done,z.value)})}}function Z(J,z,H,K){Promise.resolve(K).then(function(x){J({value:x,done:H})},z)}}class n{constructor($){this._promise=$}static fromSafePromise($){let g=$.then((Y)=>new X$(Y));return new n(g)}static fromPromise($,g){let Y=$.then((M)=>new X$(M)).catch((M)=>new W$(g(M)));return new n(Y)}static fromThrowable($,g){return(...Y)=>{return new n((()=>m$(this,void 0,void 0,function*(){try{return new X$(yield $(...Y))}catch(M){return new W$(g?g(M):M)}}))())}}static combine($){return h8($)}static combineWithAllErrors($){return R8($)}map($){return new n(this._promise.then((g)=>m$(this,void 0,void 0,function*(){if(g.isErr())return new W$(g.error);return new X$(yield $(g.value))})))}andThrough($){return new n(this._promise.then((g)=>m$(this,void 0,void 0,function*(){if(g.isErr())return new W$(g.error);let Y=yield $(g.value);if(Y.isErr())return new W$(Y.error);return new X$(g.value)})))}andTee($){return new n(this._promise.then((g)=>m$(this,void 0,void 0,function*(){if(g.isErr())return new W$(g.error);try{yield $(g.value)}catch(Y){}return new X$(g.value)})))}mapErr($){return new n(this._promise.then((g)=>m$(this,void 0,void 0,function*(){if(g.isOk())return new X$(g.value);return new W$(yield $(g.error))})))}andThen($){return new n(this._promise.then((g)=>{if(g.isErr())return new W$(g.error);let Y=$(g.value);return Y instanceof n?Y._promise:Y}))}orElse($){return new n(this._promise.then((g)=>m$(this,void 0,void 0,function*(){if(g.isErr())return $(g.error);return new X$(g.value)})))}match($,g){return this._promise.then((Y)=>Y.match($,g))}unwrapOr($){return this._promise.then((g)=>g.unwrapOr($))}safeUnwrap(){return i9(this,arguments,function*$(){return yield G$(yield G$(yield*T8(j8(yield G$(this._promise.then((g)=>g.safeUnwrap()))))))})}then($,g){return this._promise.then($,g)}[Symbol.asyncIterator](){return i9(this,arguments,function*$(){let g=yield G$(this._promise);if(g.isErr())yield yield G$($0(g.error));return yield G$(g.value)})}}var _8=($)=>new n(Promise.resolve(new X$($))),$0=($)=>new n(Promise.resolve(new W$($))),y8=n.fromPromise,N8=n.fromSafePromise,SW=n.fromThrowable,e9=($)=>{let g=A$([]);for(let Y of $)if(Y.isErr()){g=D$(Y.error);break}else g.map((M)=>M.push(Y.value));return g},h8=($)=>n.fromSafePromise(Promise.all($)).andThen(e9),$M=($)=>{let g=A$([]);for(let Y of $)if(Y.isErr()&&g.isErr())g.error.push(Y.error);else if(Y.isErr()&&g.isOk())g=D$([Y.error]);else if(Y.isOk()&&g.isOk())g.value.push(Y.value);return g},R8=($)=>n.fromSafePromise(Promise.all($)).andThen($M);var g0=void 0;(function($){function g(Z,J){return(...z)=>{try{let H=Z(...z);return A$(H)}catch(H){return D$(J?J(H):H)}}}$.fromThrowable=g;function Y(Z){return e9(Z)}$.combine=Y;function M(Z){return $M(Z)}$.combineWithAllErrors=M})(g0||(g0={}));var A$=($)=>new X$($);function D$($){return new W$($)}class X${constructor($){this.value=$}isOk(){return!0}isErr(){return!this.isOk()}map($){return A$($(this.value))}mapErr($){return A$(this.value)}andThen($){return $(this.value)}andThrough($){return $(this.value).map((g)=>this.value)}andTee($){try{$(this.value)}catch(g){}return A$(this.value)}orElse($){return A$(this.value)}asyncAndThen($){return $(this.value)}asyncAndThrough($){return $(this.value).map(()=>this.value)}asyncMap($){return n.fromSafePromise($(this.value))}unwrapOr($){return this.value}match($,g){return $(this.value)}safeUnwrap(){let $=this.value;return function*(){return $}()}_unsafeUnwrap($){return this.value}_unsafeUnwrapErr($){throw o9("Called `_unsafeUnwrapErr` on an Ok",this,$)}*[Symbol.iterator](){return this.value}}class W${constructor($){this.error=$}isOk(){return!1}isErr(){return!this.isOk()}map($){return D$(this.error)}mapErr($){return D$($(this.error))}andThrough($){return D$(this.error)}andTee($){return D$(this.error)}andThen($){return D$(this.error)}orElse($){return $(this.error)}asyncAndThen($){return $0(this.error)}asyncAndThrough($){return $0(this.error)}asyncMap($){return $0(this.error)}unwrapOr($){return $}match($,g){return g(this.error)}safeUnwrap(){let $=this.error;return function*(){throw yield D$($),new Error("Do not use this generator out of `safeTry`")}()}_unsafeUnwrap($){throw o9("Called `_unsafeUnwrap` on an Err",this,$)}_unsafeUnwrapErr($){return this.error}*[Symbol.iterator](){let $=this;return yield $,$}}var b8=g0.fromThrowable;var gM=W$,YM=X$,MM=n,ZM=D$,JM=$0;var zM=y8,HM=N8,KM=b8,CM=A$,XM=_8;export{E8 as writeToLogFile,BW as rescue,XM as okAsync,CM as ok,GW as handleError,KM as fromThrowable,HM as fromSafePromise,zM as fromPromise,JM as errAsync,ZM as err,MM as ResultAsync,g0 as Result,YM as Ok,w9 as HttpError,e$ as ErrorHandler,gM as Err};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/error-handling",
3
3
  "type": "module",
4
- "version": "0.68.0",
4
+ "version": "0.68.2",
5
5
  "description": "Type safe error handling.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": ["Chris Breuer <chris@stacksjs.org>"],
@@ -34,12 +34,12 @@
34
34
  "prepublishOnly": "bun run build"
35
35
  },
36
36
  "devDependencies": {
37
- "@stacksjs/cli": "0.67.0",
38
- "@stacksjs/config": "0.67.0",
39
- "@stacksjs/development": "0.67.0",
40
- "@stacksjs/path": "0.67.0",
41
- "@stacksjs/types": "0.67.0",
42
- "@stacksjs/validation": "0.67.0",
37
+ "@stacksjs/cli": "0.68.1",
38
+ "@stacksjs/config": "0.68.1",
39
+ "@stacksjs/development": "0.68.1",
40
+ "@stacksjs/path": "0.68.1",
41
+ "@stacksjs/types": "0.68.1",
42
+ "@stacksjs/validation": "0.68.1",
43
43
  "neverthrow": "^8.1.1"
44
44
  }
45
45
  }