UNPKG

@novu/framework

Version:

The Code-First Notifications Workflow SDK.

6 lines 218 kB
"use strict";var _o=Object.create;var Jt=Object.defineProperty;var Ro=Object.getOwnPropertyDescriptor;var Po=Object.getOwnPropertyNames;var Io=Object.getPrototypeOf,No=Object.prototype.hasOwnProperty;var xo=(w,r)=>{for(var s in r)Jt(w,s,{get:r[s],enumerable:!0})},br=(w,r,s,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let T of Po(r))!No.call(w,T)&&T!==s&&Jt(w,T,{get:()=>r[T],enumerable:!(c=Ro(r,T))||c.enumerable});return w};var at=(w,r,s)=>(s=w!=null?_o(Io(w)):{},br(r||!w||!w.__esModule?Jt(s,"default",{value:w,enumerable:!0}):s,w)),ko=w=>br(Jt({},"__esModule",{value:!0}),w);var Ta={};xo(Ta,{Client:()=>wt,CronExpression:()=>si,NovuRequestHandler:()=>kn,workflow:()=>ms});module.exports=ko(Ta);var Ur=require("liquidjs");function Mo(w,r){let s=r.split(".").reduce((c,T)=>{if(c&&typeof c=="object")return c[T]},w);if(s==null)return"";if(typeof s=="string")return s;if(typeof s=="number"||typeof s=="boolean")return String(s);if(typeof s=="object"){let c=JSON.stringify(s);return c==="{}"?"":c}return""}function Sr(w,r=2,s,c=", "){if(!Array.isArray(w)||w.length===0)return"";let T=s?w.map(ne=>typeof ne!="object"||!ne?"":Mo(ne,s)):w;if(T.length===1)return T[0];if(T.length===2)return`${T[0]} and ${T[1]}`;if(T.length===3&&r>=3)return`${T[0]}, ${c}${T[1]} and ${T[2]}`;let F=T.slice(0,r),D=T.length-r;return`${F.join(c)} and ${D} ${D===1?"other":"others"}`}var Rt=(c=>(c.TRIGGER="trigger",c.EXECUTE="execute",c.PREVIEW="preview",c))(Rt||{}),Gt=(c=>(c.DISCOVER="discover",c.HEALTH_CHECK="health-check",c.CODE="code",c))(Gt||{});var si=($=>($.EVERY_SECOND="* * * * * *",$.EVERY_5_SECONDS="*/5 * * * * *",$.EVERY_10_SECONDS="*/10 * * * * *",$.EVERY_30_SECONDS="*/30 * * * * *",$.EVERY_MINUTE="*/1 * * * *",$.EVERY_5_MINUTES="0 */5 * * * *",$.EVERY_10_MINUTES="0 */10 * * * *",$.EVERY_30_MINUTES="0 */30 * * * *",$.EVERY_HOUR="0 0-23/1 * * *",$.EVERY_2_HOURS="0 0-23/2 * * *",$.EVERY_3_HOURS="0 0-23/3 * * *",$.EVERY_4_HOURS="0 0-23/4 * * *",$.EVERY_5_HOURS="0 0-23/5 * * *",$.EVERY_6_HOURS="0 0-23/6 * * *",$.EVERY_7_HOURS="0 0-23/7 * * *",$.EVERY_8_HOURS="0 0-23/8 * * *",$.EVERY_9_HOURS="0 0-23/9 * * *",$.EVERY_10_HOURS="0 0-23/10 * * *",$.EVERY_11_HOURS="0 0-23/11 * * *",$.EVERY_12_HOURS="0 0-23/12 * * *",$.EVERY_DAY_AT_1AM="0 01 * * *",$.EVERY_DAY_AT_2AM="0 02 * * *",$.EVERY_DAY_AT_3AM="0 03 * * *",$.EVERY_DAY_AT_4AM="0 04 * * *",$.EVERY_DAY_AT_5AM="0 05 * * *",$.EVERY_DAY_AT_6AM="0 06 * * *",$.EVERY_DAY_AT_7AM="0 07 * * *",$.EVERY_DAY_AT_8AM="0 08 * * *",$.EVERY_DAY_AT_9AM="0 09 * * *",$.EVERY_DAY_AT_10AM="0 10 * * *",$.EVERY_DAY_AT_11AM="0 11 * * *",$.EVERY_DAY_AT_NOON="0 12 * * *",$.EVERY_DAY_AT_1PM="0 13 * * *",$.EVERY_DAY_AT_2PM="0 14 * * *",$.EVERY_DAY_AT_3PM="0 15 * * *",$.EVERY_DAY_AT_4PM="0 16 * * *",$.EVERY_DAY_AT_5PM="0 17 * * *",$.EVERY_DAY_AT_6PM="0 18 * * *",$.EVERY_DAY_AT_7PM="0 19 * * *",$.EVERY_DAY_AT_8PM="0 20 * * *",$.EVERY_DAY_AT_9PM="0 21 * * *",$.EVERY_DAY_AT_10PM="0 22 * * *",$.EVERY_DAY_AT_11PM="0 23 * * *",$.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",$.EVERY_WEEK="0 0 * * 0",$.EVERY_WEEKDAY="0 0 * * 1-5",$.EVERY_WEEKEND="0 0 * * 6,0",$.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",$.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",$.EVERY_2ND_HOUR="0 */2 * * *",$.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",$.EVERY_2ND_MONTH="0 0 1 */2 *",$.EVERY_QUARTER="0 0 1 */3 *",$.EVERY_6_MONTHS="0 0 1 */6 *",$.EVERY_YEAR="0 0 1 0 *",$.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",$.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",$.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",$.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",$.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",$.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",$.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",$.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",$.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",$.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",$.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",$.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",$.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",$.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",$.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",$.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",$.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",$.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",$.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",$.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",$.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",$.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",$.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",$.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",$.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",$.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",$.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",$.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5",$))(si||{});var We=(le=>(le.BRIDGE_ERROR="BridgeError",le.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",le.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",le.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",le.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",le.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",le.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",le.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",le.INVALID_ACTION_ERROR="InvalidActionError",le.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",le.MISSING_DEPENDENCY_ERROR="MissingDependencyError",le.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",le.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",le.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",le.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",le.SIGNATURE_INVALID_ERROR="SignatureInvalidError",le.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",le.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",le.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",le.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",le.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",le.STEP_CONTROL_COMPILATION_FAILED_ERROR="StepControlCompilationFailedError",le.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",le.STEP_NOT_FOUND_ERROR="StepNotFoundError",le.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",le.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",le.WORKFLOW_PAYLOAD_INVALID_ERROR="WorkflowPayloadInvalidError",le))(We||{});var Kt=(c=>(c.POST="POST",c.GET="GET",c.OPTIONS="OPTIONS",c))(Kt||{});var Ht=(F=>(F.EMAIL="email",F.SMS="sms",F.PUSH="push",F.CHAT="chat",F.IN_APP="in_app",F))(Ht||{});var Co=w=>{var s,c;if(typeof w!="object"||w===null)return!1;let r=Object.getPrototypeOf(w);return(c=(s=r==null?void 0:r.constructor)==null?void 0:s.name.endsWith("Error"))!=null?c:!1},et=class extends Error{},zt=class extends et{constructor(){super(...arguments);this.statusCode=404}},Ce=class extends et{constructor(){super(...arguments);this.statusCode=400}},rt=class extends et{constructor(){super(...arguments);this.statusCode=401}},st=class extends et{constructor(r,{cause:s}={}){var c;Co(s)?(super(`${r}: ${s.message}`),this.data={stack:(c=s.stack)!=null?c:r}):(super(`${r}${s?`: ${JSON.stringify(s,null,2)}`:""}`),this.data={stack:r})}},Xt=class extends et{constructor(){super(...arguments);this.statusCode=409}};var mt=class extends st{constructor(s){super("Unknown BridgeError",{cause:s});this.statusCode=500;this.code="BridgeError"}};var Qt=class extends Ce{constructor(s,c){super(`Workflow with id: \`${s}\` has a corrupt state. Step with id: \`${c}\` does not exist. Please provide the missing state.`);this.code="ExecutionStateCorruptError";this.data={workflowId:s,stepId:c}}},It=class extends Ce{constructor(s,c){super(`Workflow with id: \`${s}\` has invalid \`payload\`. Please provide the correct event payload.`);this.code="ExecutionEventPayloadInvalidError";this.data=c}},Zt=class extends Ce{constructor(s,c){super(`Workflow with id: \`${s}\` has invalid \`controls\`. Please provide the correct event controls.`);this.code="ExecutionEventControlInvalidError";this.data=c}},en=class extends Ce{constructor(s,c,T){super(`Workflow with id: \`${s}\` has an invalid state. Step with id: \`${c}\` has invalid \`controls\`. Please provide the correct step controls.`);this.code="ExecutionStateControlInvalidError";this.data=T}},tn=class extends Ce{constructor(s,c,T){super(`Workflow with id: \`${s}\` has an invalid state. Step with id: \`${c}\` has invalid output. Please provide the correct step output.`);this.code="ExecutionStateOutputInvalidError";this.data=T}},nn=class extends Ce{constructor(s,c,T){super(`Workflow with id: \`${s}\` has an invalid state. Step with id: \`${c}\` has invalid result. Please provide the correct step result.`);this.code="ExecutionStateResultInvalidError";this.data=T}},rn=class extends Ce{constructor(s,c,T){super(`Workflow with id: \`${s}\` has invalid controls syntax in step with id: \`${c}\`. Please correct step control syntax.`);this.code="StepControlCompilationFailedError";this.data=T}},sn=class extends Ce{constructor(s,c,T,F){super(`Workflow with id: \`${s}\` has an invalid state. Step with id: \`${c}\` and provider with id: \`${T}\` has invalid output. Please provide the correct provider output.`);this.code="ExecutionProviderOutputInvalidError";this.data=F}},on=class extends Ce{constructor(s,c){super(`Workflow with id: \`${s}\` has invalid \`payload\`. Please provide the correct payload.`);this.code="WorkflowPayloadInvalidError";this.data=c}};var oi=w=>Object.values(w).map(r=>`\`${r}\``).join(", "),an=w=>w.replaceAll(/(\w)(\w*)/g,(r,s,c)=>s.toUpperCase()+c.toLowerCase()).replaceAll(/[\s-]+/g,""),ai=(w,r=0)=>Array.isArray(w)||typeof w=="object"&&w!==null?JSON.stringify(w,null,r).replace(/"/g,"'").replace(/\n/g,"\\n"):String(w);var ln=class extends et{constructor(){super(...arguments);this.code="MethodNotAllowedError";this.statusCode=405;this.message=`Method not allowed. Please use one of ${oi(Kt)}`}},Nt=class extends Ce{constructor(s,c){super(`Invalid query string: \`action\`=\`${s}\`. Please use one of ${oi(c)}`);this.code="InvalidActionError"}},cn=class extends Ce{constructor(){super("Missing secret key. Set the `NOVU_SECRET_KEY` environment variable or pass `secretKey` to the client options.");this.code="MissingSecretKeyError"}};var pn=class extends Error{constructor(r,s,c){super(),this.data={message:c},this.statusCode=r,this.code=s}};var xt=class extends Xt{constructor(r,s){super(`${an(r)} with id: \`${s}\` already exists. Please use a different id.`)}},ot=class extends zt{constructor(r,s){super(`${an(r)} with id: \`${s}\` does not exist. Please provide a valid id.`)}},yt=class extends st{constructor(s,c,T,F){super(`Failed to ${T} ${an(s)} with id: \`${c}\``,{cause:F});this.statusCode=502}};var un=class extends ot{constructor(s){super("provider",s);this.code="ProviderNotFoundError"}},dn=class extends yt{constructor(s,c,T){super("provider",s,c,T);this.code="ProviderExecutionFailedError"}};var fn=class extends rt{constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `novu-signature` header is correct and try again.");this.code="SignatureMismatchError"}},hn=class extends rt{constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");this.code="SignatureNotFoundError"}},mn=class extends rt{constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");this.code="SignatureInvalidError"}},yn=class extends rt{constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);this.code="SignatureExpiredError"}},gn=class extends rt{constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");this.code="SigningKeyNotFoundError"}};var wn=class extends ot{constructor(s){super("step",s);this.code="StepNotFoundError"}},bn=class extends xt{constructor(s){super("step",s);this.code="StepAlreadyExistsError"}},kt=class extends yt{constructor(s,c,T){super("step",s,c,T);this.code="StepExecutionFailedError"}};var Mt=class extends ot{constructor(s){super("workflow",s);this.code="WorkflowNotFoundError"}};var lt=w=>Object.values(We).includes(w==null?void 0:w.code),Or=w=>!lt(w)&&typeof w.statusCode=="number"&&w.statusCode>=400&&w.statusCode<500;var Ar=async(w,r)=>{let s=new TextEncoder,c=s.encode(w),T=s.encode(r),F=await crypto.subtle.importKey("raw",c,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),D=await crypto.subtle.sign("HMAC",F,T);return Array.from(new Uint8Array(D)).map(ne=>ne.toString(16).padStart(2,"0")).join("")};var $o=require("cross-fetch");var vr=async()=>{if(process.env.NOVU_BRIDGE_ORIGIN)return`${process.env.NOVU_BRIDGE_ORIGIN}/api/novu`;if(process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"&&process.env.NEXT_PUBLIC_VERCEL_URL)return`https://${process.env.NEXT_PUBLIC_VERCEL_URL}/api/novu`;try{if(process.env.NODE_ENV==="development"){let r=await(await fetch("http://localhost:2022/.well-known/novu")).json();return`${r.tunnelOrigin}${r.route}`}}catch(w){console.error(w)}return""};function Er(w){return!!w&&typeof w=="object"&&"error"in w&&"message"in w&&"statusCode"in w}var Sn=(w,r)=>{if(!w)throw new cn;return{post:async(s,c)=>{let T=await fetch(`${r}/v1${s}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${w}`},body:JSON.stringify(c)}),F=await T.json();if(T.ok)return F;throw Er(F)?new pn(F.statusCode,F.error,F.message):new mt(F)},delete:async s=>(await fetch(`${r}/v1${s}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${w}`}})).json()}};var ct=at(require("chalk"),1),we={info:w=>ct.default.blue(w),warning:w=>ct.default.yellow(w),error:w=>ct.default.red(w),success:w=>ct.default.green(w),underline:w=>ct.default.underline(w),bold:w=>ct.default.bold(w)},_e={SUCCESS:we.success("\u2714"),ERROR:we.error("\u2717"),WARNING:we.warning("\u26A0"),INFO:we.info("\u2139"),ARROW:we.bold("\u2192"),MOCK:we.info("\u25CB"),HYDRATED:we.bold(we.info("\u2192")),STEP:we.info("\u03C3"),ACTION:we.info("\u03B1"),DURATION:we.info("\u0394"),PROVIDER:we.info("\u2699"),OUTPUT:we.info("\u21E2"),INPUT:we.info("\u21E0"),WORKFLOW:we.info("\u03C9"),STATE:we.info("\u03C3"),EXECUTE:we.info("\u03B5"),PREVIEW:we.info("\u03C1")};function Tn(w){return w||process.env.NOVU_API_URL||"https://api.novu.co"}function On(w){return w||process.env.NOVU_SECRET_KEY||process.env.NOVU_API_KEY||""}var li=at(require("sanitize-html"),1),Uo={allowedTags:li.default.defaults.allowedTags.concat(["style","img","html","head","body","link","meta","title"]),allowedAttributes:!1,allowVulnerableTags:!0,parseStyleAttributes:!1,parser:{lowerCaseAttributeNames:!0}},_r=w=>{if(!w)return w;let r=/^<!DOCTYPE .*?>/,s=w.match(r),c=(0,li.default)(w,Uo);return s?s[0]+c:c},An=w=>Object.keys(w).reduce((r,s)=>{let c=w[s];return typeof c=="string"?r[s]=_r(c):Array.isArray(c)?r[s]=c.map(T=>typeof T=="string"?_r(T):typeof T=="object"?An(T):T):typeof c=="object"&&c!==null?r[s]=An(c):r[s]=c,r},{});var Pr=at(require("ajv"),1),Ir=at(require("ajv-formats"),1);var Rr=w=>typeof structuredClone=="function"?structuredClone(w):JSON.parse(JSON.stringify(w));var vn=class extends st{constructor(s,c){let T=c.length===1?"it":"them";super(`Tried to use a ${s} in @novu/framework without ${c.join(", ")} installed. Please install ${T} by running \`npm install ${c.join(" ")}\`.`);this.statusCode=500;this.code="MissingDependencyError"}};var En=async(w,r)=>{let s=new Set;if((await Promise.allSettled(w.map(T=>T.import))).forEach((T,F)=>{let D=w[F];T.status==="fulfilled"&&D.exports.every(pe=>T.value[pe]!==void 0)||s.add(D.name)}),s.size>0)throw new vn(r,Array.from(s))};var _n=class{constructor(){this.requiredImports=[];this.ajv=new Pr.default({useDefaults:!0,removeAdditional:"failing"}),(0,Ir.default)(this.ajv),this.compiledSchemas=new Map}async canHandle(r){let s=r.type==="object"||!!r.anyOf||!!r.allOf||!!r.oneOf;return s&&await En(this.requiredImports,"JSON schema"),s}async validate(r,s){let c=this.compiledSchemas.get(s);c||(c=this.ajv.compile(s),this.compiledSchemas.set(s,c));let T=Rr(r);return c(T)?{success:!0,data:T}:{success:!1,errors:c.errors.map(D=>({path:D.instancePath,message:D.message}))}}async transformToJsonSchema(r){return r}};var Rn=class{constructor(){this.requiredImports=[{name:"zod",import:import("zod"),exports:["ZodType"]},{name:"zod-to-json-schema",import:import("zod-to-json-schema"),exports:["zodToJsonSchema"]}]}async canHandle(r){let s=r.safeParseAsync!==void 0;return s&&await En(this.requiredImports,"Zod schema"),s}async validate(r,s){let c=await s.safeParseAsync(r);return c.success?{success:!0,data:c.data}:{success:!1,errors:c.error.errors.map(T=>({path:`/${T.path.join("/")}`,message:T.message}))}}async transformToJsonSchema(r){let{zodToJsonSchema:s}=await import("zod-to-json-schema");return s(r)}};var Pn=new Rn,In=new _n,Nn=async(w,r)=>{if(await Pn.canHandle(w))return Pn.validate(r,w);if(await In.canHandle(w))return In.validate(r,w);throw new Error("Invalid schema")},Ne=async w=>{if(await Pn.canHandle(w))return Pn.transformToJsonSchema(w);if(await In.canHandle(w))return In.transformToJsonSchema(w);throw new Error("Invalid schema")};var xn=(()=>{var w=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,T=(e,t)=>function(){return e&&(t=(0,e[s(e)[0]])(e=0)),t},F=(e,t)=>function(){return t||(0,e[s(e)[0]])((t={exports:{}}).exports,t),t.exports},D=(e,t)=>{for(var n in t)w(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of s(t))!c.call(e,p)&&p!==n&&w(e,p,{get:()=>t[p],enumerable:!(l=r(t,p))||l.enumerable});return e},pe=e=>ne(w({},"__esModule",{value:!0}),e),ve={};D(ve,{JSONSchemaFaker:()=>gr,default:()=>wr,setDependencies:()=>ki});function Le(e,t){return typeof e=="string"?typeof t!="undefined"?Ot.register(e,t):Ot.get(e):Ot.registerMany(e)}function $e(e,t){return e=typeof e=="undefined"?He.MIN_INTEGER:e,t=typeof t=="undefined"?He.MAX_INTEGER:t,Math.floor(ee("random")()*(t-e+1))+e}function Re(e){return Ft.default.prototype.max=ee("defaultRandExpMax"),Ft.default.prototype.randInt=(n,l)=>n+Math.floor(ee("random")()*(1+(l-n))),new Ft.default(e).gen()}function De(e){return e[Math.floor(ee("random")()*e.length)]}function Ue(e){let t,n,l=e.length,p=e.slice();for(;l>0;)n=Math.floor(ee("random")()*l),l-=1,t=p[l],p[l]=p[n],p[n]=t;return p}function nt(e,t){return ee("random")()*(t-e)+e}function Je(e,t,n,l,p=!1){return n=typeof n=="undefined"?He.MIN_NUMBER:n,l=typeof l=="undefined"?He.MAX_NUMBER:l,e=typeof e=="undefined"?n:e,t=typeof t=="undefined"?l:t,t<e&&(t+=e),p?nt(e,t):$e(e,t)}function Dt(e){switch(e){case"seconds":return Je(0,60)*60;case"minutes":return Je(15,50)*612;case"hours":return Je(12,72)*36123;case"days":return Je(7,30)*86412345;case"weeks":return Je(4,52)*604812345;case"months":return Je(2,13)*2592012345;case"years":return Je(1,20)*31104012345;default:break}}function Dn(e){if(e)return Dt(e);let t=ee("minDateTime"),n=ee("maxDateTime");typeof t=="string"&&(t=new Date(t)),typeof n=="string"&&(n=new Date(n));let l=new Date().getTime();return typeof t=="number"&&(t=new Date(l+t)),typeof n=="number"&&(n=new Date(l+n)),new Date(nt(t.getTime(),n.getTime()))}function di(e,t,n){if(t=decodeURIComponent(t),n&&n[t])return le(n[t]);let l=t.replace("#/","/").split("/"),p=e.$ref&&n&&n[e.$ref]||e;for(!p&&!l[0]&&(l[0]=e.$ref.split("#/")[0]),n&&t.includes("#/")&&n[l[0]]&&(p=n[l.shift()]),l[0]||l.shift();p&&l.length>0;){let f=l.shift();if(!p[f])throw new Error(`Prop not found: ${f} (${t})`);p=p[f]}return p}function $t(e){return typeof e=="string"&&Wi.test(e)}function Ge(e){return["number","boolean"].includes(typeof e)}function Ke(e,...t){return t.filter(n=>typeof e[n]!="undefined").length>0}function fi(e){if(e.includes(" "))return new Date(e).toISOString().substr(0,10);let[t,n,l]=e.split("T")[0].split("-");return n=`0${Math.max(1,Math.min(12,n))}`.slice(-2),l=`0${Math.max(1,Math.min(31,l))}`.slice(-2),`${t}-${n}-${l}`}function ys(e){if(e.includes(" "))return new Date(e).toISOString().substr(0,10);let[t,n]=e.split("T"),[l,p,f]=t.split("-"),[d,O,L]=n.substr(0,8).split(":");return p=`0${Math.max(1,Math.min(12,p))}`.slice(-2),f=`0${Math.max(1,Math.min(31,f))}`.slice(-2),d=`0${Math.max(1,Math.min(23,d))}`.slice(-2),O=`0${Math.max(1,Math.min(59,O))}`.slice(-2),L=`0${Math.max(1,Math.min(59,L))}`.slice(-2),`${l}-${p}-${f}T${d}:${O}:${L}.000Z`}function gs(e,t,n){let l={};switch(e||t.type){case"integer":case"number":if(typeof t.minimum!="undefined"&&(l.minimum=t.minimum),typeof t.maximum!="undefined"&&(l.maximum=t.maximum),t.enum){let f=Math.max(l.minimum||0,0),d=Math.min(l.maximum||1/0,1/0);t.exclusiveMinimum&&f===t.minimum&&(f+=t.multipleOf||1),t.exclusiveMaximum&&d===t.maximum&&(d-=t.multipleOf||1),(f||d!==1/0)&&(t.enum=t.enum.filter(O=>O>=f&&O<=d))}break;case"string":{l.minLength=ee("minLength")||0,l.maxLength=ee("maxLength")||Number.MAX_SAFE_INTEGER,typeof t.minLength!="undefined"&&(l.minLength=Math.max(l.minLength,t.minLength)),typeof t.maxLength!="undefined"&&(l.maxLength=Math.min(l.maxLength,t.maxLength));break}default:break}let p=n(l);if(p==null)return null;switch(e||t.type){case"number":p=$t(p)?parseFloat(p):p;break;case"integer":p=$t(p)?parseInt(p,10):p;break;case"boolean":p=!!p;break;case"string":{if(Ge(p))return p;p=String(p);let f=Math.max(l.minLength||0,0),d=Math.min(l.maxLength||1/0,1/0),O,L=0;for(;p.length<f;)if(O=p,t.pattern?p+=Q.randexp(t.pattern):p+=`${Q.pick([" ","/","_","-","+","=","@","^"])}${p}`,p===O){if(L+=1,L===3)break}else L=0;switch(p.length>d&&(p=p.substr(0,d)),t.format){case"date-time":case"datetime":p=new Date(ys(p)).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"full-date":case"date":p=new Date(fi(p)).toISOString().substr(0,10);break;case"time":p=new Date(`1969-01-01 ${p}`).toISOString().substr(11);break;default:break}break}default:break}return p}function dt(e,t){return Object.keys(t).forEach(n=>{typeof t[n]!="object"||t[n]===null?e[n]=t[n]:Array.isArray(t[n])?(e[n]=e[n]||[],t[n].forEach((l,p)=>{e.type==="array"&&t.type==="array"?e[n][p]=dt(e[n][p]||{},l,!0):Array.isArray(e[n])&&e[n].indexOf(l)===-1&&e[n].push(l)})):typeof e[n]!="object"||e[n]===null||Array.isArray(e[n])?e[n]=dt({},t[n]):e[n]=dt(e[n],t[n])}),e}function le(e,t=new Map){if(!e||typeof e!="object")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){let l=[];return t.set(e,l),l.push(...e.map(p=>le(p,t))),l}let n={};return t.set(e,n),Object.keys(e).reduce((l,p)=>(l[p]=le(e[p],t),l),n)}function ws(e){let t=JSON.stringify(e),n=JSON.stringify(e,null,2);return t.length>400?`${n.substr(0,400)}...`:n}function hi(){return Q.pick([!1,!0,null,-1,NaN,Math.PI,1/0,void 0,[],{},Math.random(),Math.random().toString(36).substr(2)])}function bs(e,t){if(e.enum)return e.enum.includes(t);if(e.const)return e.const===t}function Ss(e,t){let n=dt({},t);if(typeof e.minimum!="undefined"&&(n.maximum=e.minimum,n.exclusiveMaximum=!0),typeof e.maximum!="undefined"&&(n.minimum=e.maximum>n.maximum?0:e.maximum,n.exclusiveMinimum=!0),typeof e.minLength!="undefined"&&(n.maxLength=e.minLength),typeof e.maxLength!="undefined"&&(n.minLength=e.maxLength>n.maxLength?0:e.maxLength),e.type)n.type=Q.pick(He.SCALAR_TYPES.filter(l=>(Array.isArray(e.type)?e.type:[e.type]).every(f=>l==="number"||l==="integer"?f!=="number"&&f!=="integer":l!==f)));else if(e.enum){let l;do l=hi();while(e.enum.indexOf(l)!==-1);n.enum=[l]}return e.required&&n.properties&&e.required.forEach(l=>{delete n.properties[l]}),n}function $n(e,t){let n=t.minimum!==void 0,l=t.maximum!==void 0;return(n||l)&&(!n||e>=t.minimum)&&(!l||e<=t.maximum)}function Ts(e,t){return!t.every(n=>$n(e,n))}function Os(e,t){return t.reduce((l,p)=>l+($n(e,p)?1:0),0)===1}function As(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)}function vs(e,t){return Object.keys(e).filter(n=>!t.includes(n)).reduce((n,l)=>(Array.isArray(e[l])?n[l]=e[l].slice():n[l]=e[l]instanceof Object?dt({},e[l]):e[l],n),{})}function mi(e,t){return Array.isArray(e)?e.map(n=>mi(n,t)):(typeof e=="string"&&(e=e.replace(/#\{([\w.-]+)\}/g,(n,l)=>t[l])),e)}function Un(e){return Object.prototype.toString.call(e)==="[object Object]"&&!Object.keys(e).length}function yi(e,t){t=t.items||t;let n=ee("alwaysFakeOptionals"),l=Array.isArray(t.required)&&t.required.includes(e)||n,p=typeof t.thunk=="function"||t.additionalProperties&&typeof t.additionalProperties.thunk=="function";return!l&&!p}function Fn(e,t,n=!1){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(l=>Fn(l,t,!0)).filter(l=>typeof l!="undefined");if(Object.keys(e).forEach(l=>{if(Un(e[l]))yi(l,t)&&delete e[l];else{let p=t;t&&t.properties&&t.properties[l]&&(p=t.properties[l]);let f=Fn(e[l],p);Un(f)||(e[l]=f)}typeof e[l]=="undefined"&&delete e[l]}),!(!Object.keys(e).length&&n))return e}function Es(e){return(t,n,l,p)=>{let f=t,d=[];typeof t=="object"&&(f=Object.keys(t)[0],Array.isArray(t[f])?d=t[f]:d.push(t[f]));let O=f.split("."),L=e();for(;O.length>1;)L=L[O.shift()];return t=typeof L=="object"?L[O[0]]:L,typeof t=="function"&&(t=t.apply(L,d.map(S=>de.template(S,p)))),Object.prototype.toString.call(t)==="[object Object]"&&Object.keys(t).forEach(S=>{if(typeof t[S]=="function")throw new Error(`Cannot resolve value for '${l}: ${f}', given: ${t}`)}),t}}function _s(e,t){if(typeof e=="undefined")return ht.list();if(typeof e=="string")if(typeof t=="function")ht.register(e,t);else if(t===null||t===!1)ht.unregister(e);else return ht.get(e);else ht.registerMany(e)}function Rs(e,t,n){return Object.keys(e).filter(l=>{let p=Ji.indexOf(t)>-1;return n.indexOf(l)>-1&&!p}).length>0}function Ps(e,t){let n=Object.keys(At);for(let l=0;l<n.length;l+=1){let p=n[l],f=t[t.length-1];if(Rs(e,f,At[p]))return p}}function Is(){return ee("random")()>.5}function Ns(){return null}function xs(e,t,n,l,p,f){let d=[],O=[];function L(U){let E=JSON.stringify(U.value);return O.indexOf(E)===-1?(O.push(E),d.push(U),!0):!1}t.forEach(L);let S=100;for(;d.length!==t.length&&(L(f(n.items||l,e,p))||(S-=1),!!S););return d}function ks(e,t,n,l){let p=[];if(!(e.items||e.additionalItems)){if(de.hasProperties(e,"minItems","maxItems","uniqueItems")&&(e.minItems!==0||e.maxItems!==0))throw new jt(`missing items for ${de.short(e)}`,t);return p}if(Array.isArray(e.items))return e.items.map((W,oe)=>{let X=t.concat(["items",oe]);return l(W,X,n)});let f=e.minItems,d=e.maxItems,O=ee("minItems"),L=ee("maxItems");O&&(f=typeof f=="undefined"?O:Math.min(O,f)),L&&(d=typeof d=="undefined"?L:Math.min(L,d),d&&d>L&&(d=L),f&&f>L&&(f=d));let S=ee("alwaysFakeOptionals")===!0?1:ee("optionalsProbability"),U=ee("alwaysFakeOptionals")||ee("fixedProbabilities")||!1,E=Q.number(f,d,1,5);S!==null&&(E=Math.max(U?Math.round((d||E)*S):Math.abs(Q.number(f,d)*S),f||0));let q=typeof e.additionalItems=="object"?e.additionalItems:{};for(let W=p.length;W<E;W+=1){let oe=t.concat(["items",W]),X=l(e.items||q,oe,n);p.push(X)}if(e.contains&&E>0){let W=Q.number(0,E-1);p[W]=l(e.contains,t.concat(["items",W]),n)}return e.uniqueItems?xs(t.concat(["items"]),p,e,q,n,l):p}function Ms(e){let t=typeof e.minimum=="undefined"||e.minimum===-Number.MAX_VALUE?He.MIN_INTEGER:e.minimum,n=typeof e.maximum=="undefined"||e.maximum===Number.MAX_VALUE?He.MAX_INTEGER:e.maximum,l=e.multipleOf,p=l&&String(l).match(/e-(\d)|\.(\d+)$/);if(p){let f=(Math.random()*Q.number(0,10)+1)*l,d=p[1]||p[2].length,O=parseFloat(f.toFixed(d)),L=Q.number(t,n-1);return String(O).includes(".")?L+O:(L+O).toExponential()}if(l&&(n=Math.floor(n/l)*l,t=Math.ceil(t/l)*l),e.exclusiveMinimum&&t===e.minimum&&(t+=l||1),e.exclusiveMaximum&&n===e.maximum&&(n-=l||1),t>n)return NaN;if(l){let f=Q.number(Math.floor(t/l),Math.floor(n/l))*l;for(;f<t;)f+=l;return f}return Q.number(t,n,void 0,void 0,e.type!=="integer")}function Cs(e){return Math.floor(ei({...e}))}function Ls(e){return Q.shuffle(nr).slice(0,e)}function Ds(e,t,n,l){let p={},f=e.properties||{},d=e.patternProperties||{},O=typeof e.required=="boolean"?[]:(e.required||[]).slice(),L=e.additionalProperties!==!1,S=Object.keys(f),U=Object.keys(d),E=S.concat(U).reduce((Y,h)=>(O.indexOf(h)===-1&&Y.push(h),Y),[]),q=O.concat(E),W=L&&e.additionalProperties===!0?Wt:e.additionalProperties;if(!L&&S.length===0&&U.length===0&&de.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(ee("requiredOnly")===!0)return O.forEach(Y=>{f[Y]&&(p[Y]=f[Y])}),l(p,t.concat(["properties"]),n,e);let oe=ee("alwaysFakeOptionals")===!0?1:ee("optionalsProbability"),X=ee("alwaysFakeOptionals")||ee("fixedProbabilities")||!1,te=ee("ignoreProperties")||[],he=ee("reuseProperties"),ye=ee("fillProperties"),j=e.maxProperties||q.length+(L?Q.number(1,5):0),g=Math.max(e.minProperties||0,O.length),b=Math.max(0,q.length-g);q.length===1&&!O.length&&(g=Math.max(Q.number(ye?1:0,j),g)),oe!==null&&(X===!0?b=Math.round(g-O.length+oe*(q.length-g)):b=Q.number(g-O.length,oe*(q.length-g)));let R=Q.shuffle(E).slice(0,b),I=E.filter(Y=>R.indexOf(Y)!==-1),M=oe!==null||O.length===j?j:Q.number(0,j),_=O.concat(Q.shuffle(I).slice(0,M)).slice(0,j),N=[],k=[];if(e.dependencies&&(Object.keys(e.dependencies).forEach(Y=>{let h=e.dependencies[Y];if(_.indexOf(Y)!==-1)if(Array.isArray(h))h.forEach(x=>{_.indexOf(x)===-1&&_.push(x)});else if(Array.isArray(h.oneOf||h.anyOf)){let x=h.oneOf||h.anyOf;k.push({prop:Y,values:x})}else N.push(h)}),N.length))return delete e.dependencies,l({allOf:N.concat(e)},t.concat(["properties"]),n,e);let V=[],J=[];_.forEach(Y=>{if(f[Y]&&["{}","true"].includes(JSON.stringify(f[Y].not)))return;for(let x=0;x<te.length;x+=1)if(te[x]instanceof RegExp&&te[x].test(Y)||typeof te[x]=="string"&&te[x]===Y||typeof te[x]=="function"&&te[x](f[Y],Y)){V.push(Y);return}W===!1&&O.indexOf(Y)!==-1&&(p[Y]=f[Y]),f[Y]&&(p[Y]=f[Y]);let h;if(U.forEach(x=>{Y.match(new RegExp(x))&&(h=!0,p[Y]?de.merge(p[Y],d[x]):p[Q.randexp(Y)]=d[x])}),!h){let x=d[Y]||W;x&&W!==!1?p[d[Y]?Q.randexp(Y):Y]=f[Y]||x:J.push(Y)}});let Z=Object.keys(p).length+(ye?0:V.length),Te=Y=>Q.randexp(`_?[_a-f\\d]{1,3}${Y?"\\$?":""}`);function Oe(Y){let h;do{if(!Y.length)break;h=Y.shift()}while(p[h]);return h}let Ee=g;if(L&&!O.length&&(Ee=Math.max(oe===null||W?Q.number(ye?1:0,j):0,g)),!I.length&&!b&&L&&X===!0&&ye){let Y=Q.number(0,j);for(let h=0;h<Y;h+=1)p[Yt(1)+Te(Y[h])]=W||Wt}for(;ye&&!(!(U.length||L)||Z>=Ee);){if(L)if(he&&S.length-Z>Ee){let Y=0,h;do{if(Y+=1,Y>1e3)break;h=Oe(O)||Q.pick(S)}while(typeof p[h]!="undefined");typeof p[h]=="undefined"&&(p[h]=f[h],Z+=1)}else if(U.length&&!W){let Y=Q.pick(U),h=Q.randexp(Y);p[h]||(p[h]=d[Y],Z+=1)}else{let Y=Oe(O)||Yt(1)+Te();p[Y]||(p[Y]=W||Wt,Z+=1)}for(let Y=0;Z<g&&Y<U.length;Y+=1){let h=U[Y],x=Q.randexp(h);p[x]||(p[x]=d[h],Z+=1)}}if(O.length===0&&(!L||oe===!1)){let Y=Q.number(g,j);for(;Z<Y;){let h=Oe(S);h&&(p[h]=f[h]),Z+=1}}let Pe=p;if(ee("sortProperties")!==null){let Y=Object.keys(f);Pe=Object.keys(p).sort((x,G)=>ee("sortProperties")?x.localeCompare(G):Y.indexOf(x)-Y.indexOf(G)).reduce((x,G)=>(x[G]=p[G],x),{})}let xe=l(Pe,t.concat(["properties"]),n,e);return k.forEach(Y=>{for(let h of Y.values)if(de.hasValue(h.properties[Y.prop],xe.value[Y.prop])){Object.keys(h.properties).forEach(x=>{x!==Y.prop&&de.merge(xe.value,l(h.properties,t.concat(["properties"]),n,e).value)});break}}),xe}function gi(){let e=Q.number(1,5);return Yt(e).join(" ")}function $s(e=0,t=140){let n=Math.max(0,e),l=Q.number(n,t),p=gi();for(;p.length<n;)p+=gi();return p.length>l&&(p=p.substr(0,l)),p}function Us(){return[0,0,0,0].map(()=>Q.number(0,255)).join(".")}function Fs(){return Q.date().toISOString()}function js(){return Vt().slice(0,10)}function Ys(){return Vt().slice(11)}function Ws(e){return Q.randexp(je[e]).replace(lr,(t,n)=>Q.randexp(je[n]))}function Vs(e,t){let n=Zn(e.format);if(typeof n=="function")return n(e);switch(e.format){case"date-time":case"datetime":return Vt();case"date":return sr();case"time":return or();case"ipv4":return rr();case"regex":return".+?";case"email":case"hostname":case"ipv6":case"uri":case"uri-reference":case"iri":case"iri-reference":case"idn-email":case"idn-hostname":case"json-pointer":case"slug":case"uri-template":case"uuid":case"duration":return cr(e.format);default:if(typeof n=="undefined"){if(ee("failOnInvalidFormat"))throw new Error(`unknown registry key ${de.short(e.format)}`);return t()}throw new Error(`unsupported format '${e.format}'`)}}function Bs(e){return de.typecast("string",e,n=>e.format?Vs(e,()=>ti(n.minLength,n.maxLength)):e.pattern?Q.randexp(e.pattern):ti(n.minLength,n.maxLength))}function qs({$comment:e,title:t,description:n}){return Object.entries({comment:e,title:t,description:n}).filter(([,l])=>l).reduce((l,[p,f])=>(l[p]=f,l),{})}function ft(e,t,n,l){if(e=n(e,null,t),e&&(e.oneOf||e.anyOf||e.allOf)&&(e=n(e,null,t)),!e)throw new Error(`Cannot traverse at '${t.join(".")}', given '${JSON.stringify(l)}'`);let p={...qs(e),schemaPath:t};if(t[t.length-1]!=="properties"){if(ee("useExamplesValue")&&Array.isArray(e.examples)){let S=e.examples.concat("default"in e?[e.default]:[]);return{value:de.typecast(null,e,()=>Q.pick(S)),context:p}}if(ee("useExamplesValue")&&typeof e.example!="undefined")return{value:de.typecast(null,e,()=>e.example),context:p};if(ee("useDefaultValue")&&"default"in e&&(e.default!==""||!ee("replaceEmptyByRandomValue")))return{value:e.default,context:p};if("template"in e)return{value:de.template(e.template,l),context:p};if("const"in e)return{value:e.const,context:p}}if(e.not&&typeof e.not=="object"&&(e=de.notValue(e.not,de.omitProps(e,["not"])),e.type&&e.type==="object")){let{value:S,context:U}=ft(e,t.concat(["not"]),n,l);return{value:de.clean(S,e,!1),context:{...p,items:U}}}if(typeof e.thunk=="function"){let{value:S,context:U}=ft(e.thunk(l),t,n);return{value:S,context:{...p,items:U}}}if(e.jsonPath)return{value:e,context:p};let f=e.type;if(Array.isArray(f)?f=Q.pick(f):typeof f=="undefined"&&(f=Gi(e,t)||f,f&&(e.type=f)),typeof e.generate=="function"){let S=de.typecast(null,e,()=>e.generate(l,t)),U=S===null?"null":typeof S;if(U===f||U==="number"&&f==="integer"||Array.isArray(S)&&f==="array")return{value:S,context:p}}if(typeof e.pattern=="string")return{value:de.typecast("string",e,()=>Q.randexp(e.pattern)),context:p};if(Array.isArray(e.enum))return{value:de.typecast(null,e,()=>Q.pick(e.enum)),context:p};if(typeof f=="string")if(vt[f])try{let S=vt[f](e,t,n,ft);return f==="array"?{value:S.map(({value:U})=>U),context:{...p,items:S.map(Array.isArray(e.items)?({context:U})=>U:({context:U})=>({...U,schemaPath:U.schemaPath.slice(0,-1)}))}}:f==="object"?S!==null?{value:S.value,context:{...p,items:S.context}}:{value:{},context:p}:{value:S,context:p}}catch(S){throw typeof S.path=="undefined"?new jt(S.stack,t):S}else{if(ee("failOnInvalidTypes"))throw new jt(`unknown primitive ${de.short(f)}`,t.concat(["type"]));{let S=ee("defaultInvalidTypeProduct");return typeof S=="string"&&vt[S]?{value:vt[S](e,t,n,ft),context:p}:{value:S,context:p}}}let d={},O={...p};Array.isArray(e)&&(d=[]);let L=ee("pruneProperties")||[];return Object.keys(e).forEach(S=>{if(!L.includes(S)&&e[S]!==null)if(typeof e[S]=="object"&&S!=="definitions"){let{value:U,context:E}=ft(e[S],t.concat([S]),n,d);d[S]=de.clean(U,e[S],!1),O[S]=E,d[S]===null&&ee("omitNulls")&&(delete d[S],delete O[S])}else d[S]=e[S]}),{value:d,context:O}}function Js(e){return Array.isArray(e)?Q.pick(e):e}function Gs(e,t){if(!Array.isArray(e))return e;let n=t?e.pop():e.shift();return t?e.unshift(n):e.push(n),n}function jn(e,t,n,l){if(!e||typeof e!="object")return e;if(n||(n={}),t||(t=e),Array.isArray(e))return e.map(p=>jn(p,t,n,l));if(e.jsonPath){let{JSONPath:p}=Kn(),f=typeof e.jsonPath!="object"?{path:e.jsonPath}:e.jsonPath;f.group=e.group||f.group||l,f.cycle=e.cycle||f.cycle||!1,f.reverse=e.reverse||f.reverse||!1,f.count=e.count||f.count||1;let d=`${f.group}__${f.path}`;return n[d]||(f.count>1?n[d]=p(f.path,t).slice(0,f.count):n[d]=p(f.path,t)),f.cycle||f.reverse?Gs(n[d],f.reverse):Js(n[d])}return Object.keys(e).forEach(p=>{e[p]=jn(e[p],t,n,p)}),e}function Ks(e,t,n,l){if(Object.prototype.toString.call(t)!=="[object Object]")throw new Error(`Invalid input, expecting object but given ${typeof t}`);let p=ee("refDepthMin")||0,f=ee("refDepthMax")||3;try{let{resolveSchema:d}=hr({refs:e,schema:t,container:n,synchronous:l,refDepthMin:p,refDepthMax:f}),O=dr(de.clone(t),[],d);return ee("resolveJsonPath")?{value:jn(O.value),context:O.context}:O}catch(d){throw d.path?new Error(`${d.message} in /${d.path.join("/")}`):d}}function Hs(e){return e.value}function zs(e,t){return t.reduce((n,l)=>l in n?n[l]:{},e)}function Yn(e,t,n,l=n){let{title:p,description:f,comment:d}=zs(e,t),O=[];ee("renderTitle")&&p&&O.push(` ${p}`,""),ee("renderDescription")&&f&&O.push(` ${f}`),ee("renderComment")&&d&&O.push(` ${d}`),n.commentBefore=O.join(` `),l instanceof mr?l.items.forEach(L=>{Yn(e,[...t,"items",L.key.value],L.key,L.value)}):l instanceof yr&&l.items.forEach((L,S)=>{Yn(e,[...t,"items",S],L)})}function Xs({value:e,context:t}){let n=Et.createNode(e);Yn(t,[],n);let l=new Et.Document;return l.contents=n,l.toString()}function wi(){Xe.define("autoIncrement",function(t,n){if(!this.offset){let l=n.minimum||1,p=l+He.MAX_NUMBER,f=t.initialOffset||n.initialOffset;this.offset=f||Q.number(l,p)}return t?this.offset++:n}),Xe.define("sequentialDate",function(t,n){if(this.now||(this.now=Q.date()),t){if(n=this.now.toISOString(),t=t===!0?"days":t,["seconds","minutes","hours","days","weeks","months","years"].indexOf(t)===-1)throw new Error(`Unsupported increment by ${de.short(t)}`);this.now.setTime(this.now.getTime()+Q.date(t))}return n})}function bi(e,t){let n={};Array.isArray(e)?e.forEach(p=>{n[p.$id||p.id]=p}):n=e||{};function l(p){if(!p||typeof p!="object")return;if(Array.isArray(p))return p.forEach(l);let f=p.$id||p.id;typeof f=="string"&&!n[f]&&(n[f]=p),Object.keys(p).forEach(d=>{l(p[d])})}return l(e),l(t),n}var Si,Wn,Ti,Vn,Oi,Ai,Fe,vi,Bn,$,qn,Ei,_i,Ri,Pi,Ii,Tt,Ut,Jn,Ni,xi,Gn,Kn,ki,Mi,Hn,ue,zn,Ci,Li,Ot,ee,Xn,Qn,Di,$i,Ui,Fi,ji,Yi,He,Ft,Q,Wi,de,Vi,Bi,ht,Zn,qi,jt,At,Ji,Gi,Ki,Hi,zi,Xi,Qi,Zi,er,ei,tr,nr,Yt,Wt,ir,ti,rr,Vt,sr,or,ni,Bt,ar,je,lr,cr,pr,ur,vt,dr,fr,hr,ii,ri,ke,Qs,Zs,eo,to,no,io,ro,so,oo,ao,lo,co,mr,yr,Et,Xe,Se,gr,wr,po=T({"src/shared.js"(){Si=Object.create,Wn=Object.defineProperty,Ti=Object.getOwnPropertyDescriptor,Vn=Object.getOwnPropertyNames,Oi=Object.getPrototypeOf,Ai=Object.prototype.hasOwnProperty,Fe=(e,t)=>function(){return t||(0,e[Vn(e)[0]])((t={exports:{}}).exports,t),t.exports},vi=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of Vn(t))!Ai.call(e,p)&&p!==n&&Wn(e,p,{get:()=>t[p],enumerable:!(l=Ti(t,p))||l.enumerable});return e},Bn=(e,t,n)=>(n=e!=null?Si(Oi(e)):{},vi(t||!e||!e.__esModule?Wn(n,"default",{value:e,enumerable:!0}):n,e)),$=Fe({"node_modules/ret/lib/types.js"(e,t){t.exports={ROOT:0,GROUP:1,POSITION:2,SET:3,RANGE:4,REPETITION:5,REFERENCE:6,CHAR:7}}}),qn=Fe({"node_modules/ret/lib/sets.js"(e){var t=$(),n=()=>[{type:t.RANGE,from:48,to:57}],l=()=>[{type:t.CHAR,value:95},{type:t.RANGE,from:97,to:122},{type:t.RANGE,from:65,to:90}].concat(n()),p=()=>[{type:t.CHAR,value:9},{type:t.CHAR,value:10},{type:t.CHAR,value:11},{type:t.CHAR,value:12},{type:t.CHAR,value:13},{type:t.CHAR,value:32},{type:t.CHAR,value:160},{type:t.CHAR,value:5760},{type:t.RANGE,from:8192,to:8202},{type:t.CHAR,value:8232},{type:t.CHAR,value:8233},{type:t.CHAR,value:8239},{type:t.CHAR,value:8287},{type:t.CHAR,value:12288},{type:t.CHAR,value:65279}],f=()=>[{type:t.CHAR,value:10},{type:t.CHAR,value:13},{type:t.CHAR,value:8232},{type:t.CHAR,value:8233}];e.words=()=>({type:t.SET,set:l(),not:!1}),e.notWords=()=>({type:t.SET,set:l(),not:!0}),e.ints=()=>({type:t.SET,set:n(),not:!1}),e.notInts=()=>({type:t.SET,set:n(),not:!0}),e.whitespace=()=>({type:t.SET,set:p(),not:!1}),e.notWhitespace=()=>({type:t.SET,set:p(),not:!0}),e.anyChar=()=>({type:t.SET,set:f(),not:!0})}}),Ei=Fe({"node_modules/ret/lib/util.js"(e){var t=$(),n=qn(),l="@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?",p={0:0,t:9,n:10,v:11,f:12,r:13};e.strToChars=function(f){var d=/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g;return f=f.replace(d,function(O,L,S,U,E,q,W,oe){if(S)return O;var X=L?8:U?parseInt(U,16):E?parseInt(E,16):q?parseInt(q,8):W?l.indexOf(W):p[oe],te=String.fromCharCode(X);return/[[\]{}^$.|?*+()]/.test(te)&&(te="\\"+te),te}),f},e.tokenizeClass=(f,d)=>{for(var O=[],L=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g,S,U;(S=L.exec(f))!=null;)if(S[1])O.push(n.words());else if(S[2])O.push(n.ints());else if(S[3])O.push(n.whitespace());else if(S[4])O.push(n.notWords());else if(S[5])O.push(n.notInts());else if(S[6])O.push(n.notWhitespace());else if(S[7])O.push({type:t.RANGE,from:(S[8]||S[9]).charCodeAt(0),to:S[10].charCodeAt(0)});else if(U=S[12])O.push({type:t.CHAR,value:U.charCodeAt(0)});else return[O,L.lastIndex];e.error(d,"Unterminated character class")},e.error=(f,d)=>{throw new SyntaxError("Invalid regular expression: /"+f+"/: "+d)}}}),_i=Fe({"node_modules/ret/lib/positions.js"(e){var t=$();e.wordBoundary=()=>({type:t.POSITION,value:"b"}),e.nonWordBoundary=()=>({type:t.POSITION,value:"B"}),e.begin=()=>({type:t.POSITION,value:"^"}),e.end=()=>({type:t.POSITION,value:"$"})}}),Ri=Fe({"node_modules/ret/lib/index.js"(e,t){var n=Ei(),l=$(),p=qn(),f=_i();t.exports=d=>{var O=0,L,S,U={type:l.ROOT,stack:[]},E=U,q=U.stack,W=[],oe=I=>{n.error(d,`Nothing to repeat at column ${I-1}`)},X=n.strToChars(d);for(L=X.length;O<L;)switch(S=X[O++],S){case"\\":switch(S=X[O++],S){case"b":q.push(f.wordBoundary());break;case"B":q.push(f.nonWordBoundary());break;case"w":q.push(p.words());break;case"W":q.push(p.notWords());break;case"d":q.push(p.ints());break;case"D":q.push(p.notInts());break;case"s":q.push(p.whitespace());break;case"S":q.push(p.notWhitespace());break;default:/\d/.test(S)?q.push({type:l.REFERENCE,value:parseInt(S,10)}):q.push({type:l.CHAR,value:S.charCodeAt(0)})}break;case"^":q.push(f.begin());break;case"$":q.push(f.end());break;case"[":var te;X[O]==="^"?(te=!0,O++):te=!1;var he=n.tokenizeClass(X.slice(O),d);O+=he[1],q.push({type:l.SET,set:he[0],not:te});break;case".":q.push(p.anyChar());break;case"(":var ye={type:l.GROUP,stack:[],remember:!0};S=X[O],S==="?"&&(S=X[O+1],O+=2,S==="="?ye.followedBy=!0:S==="!"?ye.notFollowedBy=!0:S!==":"&&n.error(d,`Invalid group, character '${S}' after '?' at column ${O-1}`),ye.remember=!1),q.push(ye),W.push(E),E=ye,q=ye.stack;break;case")":W.length===0&&n.error(d,`Unmatched ) at column ${O-1}`),E=W.pop(),q=E.options?E.options[E.options.length-1]:E.stack;break;case"|":E.options||(E.options=[E.stack],delete E.stack);var j=[];E.options.push(j),q=j;break;case"{":var g=/^(\d+)(,(\d+)?)?\}/.exec(X.slice(O)),b,R;g!==null?(q.length===0&&oe(O),b=parseInt(g[1],10),R=g[2]?g[3]?parseInt(g[3],10):1/0:b,O+=g[0].length,q.push({type:l.REPETITION,min:b,max:R,value:q.pop()})):q.push({type:l.CHAR,value:123});break;case"?":q.length===0&&oe(O),q.push({type:l.REPETITION,min:0,max:1,value:q.pop()});break;case"+":q.length===0&&oe(O),q.push({type:l.REPETITION,min:1,max:1/0,value:q.pop()});break;case"*":q.length===0&&oe(O),q.push({type:l.REPETITION,min:0,max:1/0,value:q.pop()});break;default:q.push({type:l.CHAR,value:S.charCodeAt(0)})}return W.length!==0&&n.error(d,"Unterminated group"),U},t.exports.types=l}}),Pi=Fe({"node_modules/drange/lib/index.js"(e,t){"use strict";var n=class gt{constructor(f,d){this.low=f,this.high=d,this.length=1+d-f}overlaps(f){return!(this.high<f.low||this.low>f.high)}touches(f){return!(this.high+1<f.low||this.low-1>f.high)}add(f){return new gt(Math.min(this.low,f.low),Math.max(this.high,f.high))}subtract(f){return f.low<=this.low&&f.high>=this.high?[]:f.low>this.low&&f.high<this.high?[new gt(this.low,f.low-1),new gt(f.high+1,this.high)]:f.low<=this.low?[new gt(f.high+1,this.high)]:[new gt(this.low,f.low-1)]}toString(){return this.low==this.high?this.low.toString():this.low+"-"+this.high}},l=class Ct{constructor(f,d){this.ranges=[],this.length=0,f!=null&&this.add(f,d)}_update_length(){this.length=this.ranges.reduce((f,d)=>f+d.length,0)}add(f,d){var O=L=>{for(var S=0;S<this.ranges.length&&!L.touches(this.ranges[S]);)S++;for(var U=this.ranges.slice(0,S);S<this.ranges.length&&L.touches(this.ranges[S]);)L=L.add(this.ranges[S]),S++;U.push(L),this.ranges=U.concat(this.ranges.slice(S)),this._update_length()};return f instanceof Ct?f.ranges.forEach(O):(d==null&&(d=f),O(new n(f,d))),this}subtract(f,d){var O=L=>{for(var S=0;S<this.ranges.length&&!L.overlaps(this.ranges[S]);)S++;for(var U=this.ranges.slice(0,S);S<this.ranges.length&&L.overlaps(this.ranges[S]);)U=U.concat(this.ranges[S].subtract(L)),S++;this.ranges=U.concat(this.ranges.slice(S)),this._update_length()};return f instanceof Ct?f.ranges.forEach(O):(d==null&&(d=f),O(new n(f,d))),this}intersect(f,d){var O=[],L=S=>{for(var U=0;U<this.ranges.length&&!S.overlaps(this.ranges[U]);)U++;for(;U<this.ranges.length&&S.overlaps(this.ranges[U]);){var E=Math.max(this.ranges[U].low,S.low),q=Math.min(this.ranges[U].high,S.high);O.push(new n(E,q)),U++}};return f instanceof Ct?f.ranges.forEach(L):(d==null&&(d=f),L(new n(f,d))),this.ranges=O,this._update_length(),this}index(f){for(var d=0;d<this.ranges.length&&this.ranges[d].length<=f;)f-=this.ranges[d].length,d++;return this.ranges[d].low+f}toString(){return"[ "+this.ranges.join(", ")+" ]"}clone(){return new Ct(this)}numbers(){return this.ranges.reduce((f,d)=>{for(var O=d.low;O<=d.high;)f.push(O),O++;return f},[])}subranges(){return this.ranges.map(f=>({low:f.low,high:f.high,length:1+f.high-f.low}))}};t.exports=l}}),Ii=Fe({"node_modules/randexp/lib/randexp.js"(e,t){var n=Ri(),l=Pi(),p=n.types;t.exports=class Lt{constructor(d,O){if(this._setDefaults(d),d instanceof RegExp)this.ignoreCase=d.ignoreCase,this.multiline=d.multiline,d=d.source;else if(typeof d=="string")this.ignoreCase=O&&O.indexOf("i")!==-1,this.multiline=O&&O.indexOf("m")!==-1;else throw new Error("Expected a regexp or string");this.tokens=n(d)}_setDefaults(d){this.max=d.max!=null?d.max:Lt.prototype.max!=null?Lt.prototype.max:100,this.defaultRange=d.defaultRange?d.defaultRange:this.defaultRange.clone(),d.randInt&&(this.randInt=d.randInt)}gen(){return this._gen(this.tokens,[])}_gen(d,O){var L,S,U,E,q;switch(d.type){case p.ROOT:case p.GROUP:if(d.followedBy||d.notFollowedBy)return"";for(d.remember&&d.groupNumber===void 0&&(d.groupNumber=O.push(null)-1),L=d.options?this._randSelect(d.options):d.stack,S="",E=0,q=L.length;E<q;E++)S+=this._gen(L[E],O);return d.remember&&(O[d.groupNumber]=S),S;case p.POSITION:return"";case p.SET:var W=this._expand(d);return W.length?String.fromCharCode(this._randSelect(W)):"";case p.REPETITION:for(U=this.randInt(d.min,d.max===1/0?d.min+this.max:d.max),S="",E=0;E<U;E++)S+=this._gen(d.value,O);return S;case p.REFERENCE:return O[d.value-1]||"";case p.CHAR:var oe=this.ignoreCase&&this._randBool()?this._toOtherCase(d.value):d.value;return String.fromCharCode(oe)}}_toOtherCase(d){return d+(97<=d&&d<=122?-32:65<=d&&d<=90?32:0)}_randBool(){return!this.randInt(0,1)}_randSelect(d){return d instanceof l?d.index(this.randInt(0,d.length-1)):d[this.randInt(0,d.length-1)]}_expand(d){if(d.type===n.types.CHAR)return new l(d.value);if(d.type===n.types.RANGE)return new l(d.from,d.to);{let O=new l;for(let L=0;L<d.set.length;L++){let S=this._expand(d.set[L]);if(O.add(S),this.ignoreCase)for(let U=0;U<S.length;U++){let E=S.index(U),q=this._toOtherCase(E);E!==q&&O.add(q)}}return d.not?this.defaultRange.clone().subtract(O):this.defaultRange.clone().intersect(O)}}randInt(d,O){return d+Math.floor(Math.random()*(1+O-d))}get defaultRange(){return this._range=this._range||new l(32,126)}set defaultRange(d){this._range=d}static randexp(d,O){var L;return typeof d=="string"&&(d=new RegExp(d,O)),d._randexp===void 0?(L=new Lt(d,O),d._randexp=L):(L=d._randexp,L._setDefaults(d)),L.gen()}static sugar(){RegExp.prototype.gen=function(){return Lt.randexp(this)}}}}}),Tt=Fe({"node_modules/yaml/dist/PlainValue-ec8e588e.js"(e){"use strict";var t={ANCHOR:"&",COMMENT:"#",TAG:"!",DIRECTIVES_END:"-",DOCUMENT_END:"."},n={ALIAS:"ALIAS",BLANK_LINE:"BLANK_LINE",BLOCK_FOLDED:"BLOCK_FOLDED",BLOCK_LITERAL:"BLOCK_LITERAL",COMMENT:"COMMENT",DIRECTIVE:"DIRECTIVE",DOCUMENT:"DOCUMENT",FLOW_MAP:"FLOW_MAP",FLOW_SEQ:"FLOW_SEQ",MAP:"MAP",MAP_KEY:"MAP_KEY",MAP_VALUE:"MAP_VALUE",PLAIN:"PLAIN",QUOTE_DOUBLE:"QUOTE_DOUBLE",QUOTE_SINGLE:"QUOTE_SINGLE",SEQ:"SEQ",SEQ_ITEM:"SEQ_ITEM"},l="tag:yaml.org,2002:",p={MAP:"tag:yaml.org,2002:map",SEQ:"tag:yaml.org,2002:seq",STR:"tag:yaml.org,2002:str"};function f(j){let g=[0],b=j.indexOf(` `);for(;b!==-1;)b+=1,g.push(b),b=j.indexOf(` `,b);return g}function d(j){let g,b;return typeof j=="string"?(g=f(j),b=j):(Array.isArray(j)&&(j=j[0]),j&&j.context&&(j.lineStarts||(j.lineStarts=f(j.context.src)),g=j.lineStarts,b=j.context.src)),{lineStarts:g,src:b}}function O(j,g){if(typeof j!="number"||j<0)return null;let{lineStarts:b,src:R}=d(g);if(!b||!R||j>R.length)return null;for(let M=0;M<b.length;++M){let _=b[M];if(j<_)return{line:M,col:j-b[M-1]+1};if(j===_)return{line:M+1,col:1}}let I=b.length;return{line:I,col:j-b[I-1]+1}}function L(j,g){let{lineStarts:b,src:R}=d(g);if(!b||!(j>=1)||j>b.length)return null;let I=b[j-1],M=b[j];for(;M&&M>I&&R[M-1]===` `;)--M;return R.slice(I,M)}function S({start:j,end:g},b,R=80){let I=L(j.line,b);if(!I)return null;let{col:M}=j;if(I.length>R)if(M<=R-10)I=I.substr(0,R-1)+"\u2026";else{let J=Math.round(R/2);I.length>M+J&&(I=I.substr(0,M+J-1)+"\u2026"),M-=I.length-R,I="\u2026"+I.substr(1-R)}let _=1,N="";g&&(g.line===j.line&&M+(g.col-j.col)<=R+1?_=g.col-j.col:(_=Math.min(I.length+1,R)-M,N="\u2026"));let k=M>1?" ".repeat(M-1):"",V="^".repeat(_);return`${I} ${k}${V}${N}`}var U=class Nr{static copy(g){return new Nr(g.start,g.end)}constructor(g,b){this.start=g,this.end=b||g}isEmpty(){return typeof this.start!="number"||!this.end||this.end<=this.start}setOrigRange(g,b){let{start:R,end:I}=this;if(g.length===0||I<=g[0])return this.origStart=R,this.origEnd=I,b;let M=b;for(;M<g.length&&!(g[M]>R);)++M;this.origStart=R+M;let _=M;for(;M<g.length&&