@finda-co/novu-framework
Version:
The Code-First Notifications Workflow SDK.
13 lines • 218 kB
JavaScript
"use strict";var _o=Object.create;var Gt=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)Gt(w,s,{get:r[s],enumerable:!0})},br=(w,r,s,p)=>{if(r&&typeof r=="object"||typeof r=="function")for(let T of Po(r))!No.call(w,T)&&T!==s&&Gt(w,T,{get:()=>r[T],enumerable:!(p=Ro(r,T))||p.enumerable});return w};var at=(w,r,s)=>(s=w!=null?_o(Io(w)):{},br(r||!w||!w.__esModule?Gt(s,"default",{value:w,enumerable:!0}):s,w)),ko=w=>br(Gt({},"__esModule",{value:!0}),w);var Ta={};xo(Ta,{Client:()=>wt,CronExpression:()=>si,NovuRequestHandler:()=>bt,frameworkName:()=>ms,serve:()=>Sa,workflow:()=>hs});module.exports=ko(Ta);var Ur=require("liquidjs");var Pt=(p=>(p.TRIGGER="trigger",p.EXECUTE="execute",p.PREVIEW="preview",p))(Pt||{}),Kt=(p=>(p.DISCOVER="discover",p.HEALTH_CHECK="health-check",p.CODE="code",p))(Kt||{});var si=(U=>(U.EVERY_SECOND="* * * * * *",U.EVERY_5_SECONDS="*/5 * * * * *",U.EVERY_10_SECONDS="*/10 * * * * *",U.EVERY_30_SECONDS="*/30 * * * * *",U.EVERY_MINUTE="*/1 * * * *",U.EVERY_5_MINUTES="0 */5 * * * *",U.EVERY_10_MINUTES="0 */10 * * * *",U.EVERY_30_MINUTES="0 */30 * * * *",U.EVERY_HOUR="0 0-23/1 * * *",U.EVERY_2_HOURS="0 0-23/2 * * *",U.EVERY_3_HOURS="0 0-23/3 * * *",U.EVERY_4_HOURS="0 0-23/4 * * *",U.EVERY_5_HOURS="0 0-23/5 * * *",U.EVERY_6_HOURS="0 0-23/6 * * *",U.EVERY_7_HOURS="0 0-23/7 * * *",U.EVERY_8_HOURS="0 0-23/8 * * *",U.EVERY_9_HOURS="0 0-23/9 * * *",U.EVERY_10_HOURS="0 0-23/10 * * *",U.EVERY_11_HOURS="0 0-23/11 * * *",U.EVERY_12_HOURS="0 0-23/12 * * *",U.EVERY_DAY_AT_1AM="0 01 * * *",U.EVERY_DAY_AT_2AM="0 02 * * *",U.EVERY_DAY_AT_3AM="0 03 * * *",U.EVERY_DAY_AT_4AM="0 04 * * *",U.EVERY_DAY_AT_5AM="0 05 * * *",U.EVERY_DAY_AT_6AM="0 06 * * *",U.EVERY_DAY_AT_7AM="0 07 * * *",U.EVERY_DAY_AT_8AM="0 08 * * *",U.EVERY_DAY_AT_9AM="0 09 * * *",U.EVERY_DAY_AT_10AM="0 10 * * *",U.EVERY_DAY_AT_11AM="0 11 * * *",U.EVERY_DAY_AT_NOON="0 12 * * *",U.EVERY_DAY_AT_1PM="0 13 * * *",U.EVERY_DAY_AT_2PM="0 14 * * *",U.EVERY_DAY_AT_3PM="0 15 * * *",U.EVERY_DAY_AT_4PM="0 16 * * *",U.EVERY_DAY_AT_5PM="0 17 * * *",U.EVERY_DAY_AT_6PM="0 18 * * *",U.EVERY_DAY_AT_7PM="0 19 * * *",U.EVERY_DAY_AT_8PM="0 20 * * *",U.EVERY_DAY_AT_9PM="0 21 * * *",U.EVERY_DAY_AT_10PM="0 22 * * *",U.EVERY_DAY_AT_11PM="0 23 * * *",U.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",U.EVERY_WEEK="0 0 * * 0",U.EVERY_WEEKDAY="0 0 * * 1-5",U.EVERY_WEEKEND="0 0 * * 6,0",U.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",U.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",U.EVERY_2ND_HOUR="0 */2 * * *",U.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",U.EVERY_2ND_MONTH="0 0 1 */2 *",U.EVERY_QUARTER="0 0 1 */3 *",U.EVERY_6_MONTHS="0 0 1 */6 *",U.EVERY_YEAR="0 0 1 0 *",U.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",U.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",U.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",U.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",U.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",U.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",U.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",U.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",U.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",U.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",U.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",U.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",U.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",U.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",U.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",U.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",U.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",U.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",U.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",U.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",U.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",U.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",U.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",U.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",U.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",U.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",U.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",U.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5",U))(si||{});var We=(ce=>(ce.BRIDGE_ERROR="BridgeError",ce.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",ce.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",ce.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",ce.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",ce.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",ce.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",ce.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",ce.INVALID_ACTION_ERROR="InvalidActionError",ce.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",ce.MISSING_DEPENDENCY_ERROR="MissingDependencyError",ce.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",ce.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",ce.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",ce.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",ce.SIGNATURE_INVALID_ERROR="SignatureInvalidError",ce.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",ce.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",ce.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",ce.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",ce.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",ce.STEP_CONTROL_COMPILATION_FAILED_ERROR="StepControlCompilationFailedError",ce.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",ce.STEP_NOT_FOUND_ERROR="StepNotFoundError",ce.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",ce.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",ce.WORKFLOW_PAYLOAD_INVALID_ERROR="WorkflowPayloadInvalidError",ce))(We||{});var Ht=(p=>(p.POST="POST",p.GET="GET",p.OPTIONS="OPTIONS",p))(Ht||{});var zt=($=>($.EMAIL="email",$.SMS="sms",$.PUSH="push",$.CHAT="chat",$.IN_APP="in_app",$))(zt||{});var Mo=w=>{var s,p;if(typeof w!="object"||w===null)return!1;let r=Object.getPrototypeOf(w);return(p=(s=r==null?void 0:r.constructor)==null?void 0:s.name.endsWith("Error"))!=null?p:!1},et=class extends Error{},Xt=class extends et{constructor(){super(...arguments);this.statusCode=404}},Ce=class extends et{constructor(){super(...arguments);this.statusCode=400}},it=class extends et{constructor(){super(...arguments);this.statusCode=401}},rt=class extends et{constructor(r,{cause:s}={}){var p;Mo(s)?(super(`${r}: ${s.message}`),this.data={stack:(p=s.stack)!=null?p:r}):(super(`${r}${s?`: ${JSON.stringify(s,null,2)}`:""}`),this.data={stack:r})}},Qt=class extends et{constructor(){super(...arguments);this.statusCode=409}};var mt=class extends rt{constructor(s){super("Unknown BridgeError",{cause:s});this.statusCode=500;this.code="BridgeError"}};var Zt=class extends Ce{constructor(s,p){super(`Workflow with id: \`${s}\` has a corrupt state. Step with id: \`${p}\` does not exist. Please provide the missing state.`);this.code="ExecutionStateCorruptError";this.data={workflowId:s,stepId:p}}},Nt=class extends Ce{constructor(s,p){super(`Workflow with id: \`${s}\` has invalid \`payload\`. Please provide the correct event payload.`);this.code="ExecutionEventPayloadInvalidError";this.data=p}},en=class extends Ce{constructor(s,p){super(`Workflow with id: \`${s}\` has invalid \`controls\`. Please provide the correct event controls.`);this.code="ExecutionEventControlInvalidError";this.data=p}},tn=class extends Ce{constructor(s,p,T){super(`Workflow with id: \`${s}\` has an invalid state. Step with id: \`${p}\` has invalid \`controls\`. Please provide the correct step controls.`);this.code="ExecutionStateControlInvalidError";this.data=T}},nn=class extends Ce{constructor(s,p,T){super(`Workflow with id: \`${s}\` has an invalid state. Step with id: \`${p}\` has invalid output. Please provide the correct step output.`);this.code="ExecutionStateOutputInvalidError";this.data=T}},rn=class extends Ce{constructor(s,p,T){super(`Workflow with id: \`${s}\` has an invalid state. Step with id: \`${p}\` has invalid result. Please provide the correct step result.`);this.code="ExecutionStateResultInvalidError";this.data=T}},sn=class extends Ce{constructor(s,p,T){super(`Workflow with id: \`${s}\` has invalid controls syntax in step with id: \`${p}\`. Please correct step control syntax.`);this.code="StepControlCompilationFailedError";this.data=T}},on=class extends Ce{constructor(s,p,T,$){super(`Workflow with id: \`${s}\` has an invalid state. Step with id: \`${p}\` and provider with id: \`${T}\` has invalid output. Please provide the correct provider output.`);this.code="ExecutionProviderOutputInvalidError";this.data=$}},an=class extends Ce{constructor(s,p){super(`Workflow with id: \`${s}\` has invalid \`payload\`. Please provide the correct payload.`);this.code="WorkflowPayloadInvalidError";this.data=p}};var oi=w=>Object.values(w).map(r=>`\`${r}\``).join(", "),ln=w=>w.replaceAll(/(\w)(\w*)/g,(r,s,p)=>s.toUpperCase()+p.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 cn=class extends et{constructor(){super(...arguments);this.code="MethodNotAllowedError";this.statusCode=405;this.message=`Method not allowed. Please use one of ${oi(Ht)}`}},xt=class extends Ce{constructor(s,p){super(`Invalid query string: \`action\`=\`${s}\`. Please use one of ${oi(p)}`);this.code="InvalidActionError"}},pn=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 un=class extends Error{constructor(r,s,p){super(),this.data={message:p},this.statusCode=r,this.code=s}};var kt=class extends Qt{constructor(r,s){super(`${ln(r)} with id: \`${s}\` already exists. Please use a different id.`)}},st=class extends Xt{constructor(r,s){super(`${ln(r)} with id: \`${s}\` does not exist. Please provide a valid id.`)}},yt=class extends rt{constructor(s,p,T,$){super(`Failed to ${T} ${ln(s)} with id: \`${p}\``,{cause:$});this.statusCode=502}};var dn=class extends st{constructor(s){super("provider",s);this.code="ProviderNotFoundError"}},fn=class extends yt{constructor(s,p,T){super("provider",s,p,T);this.code="ProviderExecutionFailedError"}};var hn=class extends it{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"}},mn=class extends it{constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");this.code="SignatureNotFoundError"}},yn=class extends it{constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");this.code="SignatureInvalidError"}},gn=class extends it{constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);this.code="SignatureExpiredError"}},wn=class extends it{constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");this.code="SigningKeyNotFoundError"}};var bn=class extends st{constructor(s){super("step",s);this.code="StepNotFoundError"}},Sn=class extends kt{constructor(s){super("step",s);this.code="StepAlreadyExistsError"}},Mt=class extends yt{constructor(s,p,T){super("step",s,p,T);this.code="StepExecutionFailedError"}};var Ct=class extends st{constructor(s){super("workflow",s);this.code="WorkflowNotFoundError"}};var lt=w=>Object.values(We).includes(w==null?void 0:w.code),Tr=w=>!lt(w)&&typeof w.statusCode=="number"&&w.statusCode>=400&&w.statusCode<500;var Or=async(w,r)=>{let s=new TextEncoder,p=s.encode(w),T=s.encode(r),$=await crypto.subtle.importKey("raw",p,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),M=await crypto.subtle.sign("HMAC",$,T);return Array.from(new Uint8Array(M)).map(ee=>ee.toString(16).padStart(2,"0")).join("")};var Do=require("cross-fetch");var Ar=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 Tn=(w,r,s)=>{let{headers:p,...T}=s||{};if(!w)throw new pn;return{post:async($,M)=>{let ee=await fetch(`${r}/v1${$}`,{...T,method:"POST",headers:{...p,"Content-Type":"application/json",Authorization:`ApiKey ${w}`},body:JSON.stringify(M)}),re=await ee.json();if(ee.ok)return re;throw Er(re)?new un(re.statusCode,re.error,re.message):new mt(re)},delete:async $=>(await fetch(`${r}/v1${$}`,{...T,method:"DELETE",headers:{...p,"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 On(w){return w||process.env.NOVU_API_URL||"https://api.novu.co"}function An(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}},vr=w=>{if(!w)return w;let r=/^<!DOCTYPE .*?>/,s=w.match(r),p=(0,li.default)(w,Uo);return s?s[0]+p:p},En=w=>Object.keys(w).reduce((r,s)=>{let p=w[s];return typeof p=="string"?r[s]=vr(p):Array.isArray(p)?r[s]=p.map(T=>typeof T=="string"?vr(T):typeof T=="object"?En(T):T):typeof p=="object"&&p!==null?r[s]=En(p):r[s]=p,r},{});var Rr=at(require("ajv"),1),Pr=at(require("ajv-formats"),1);var _r=w=>typeof structuredClone=="function"?structuredClone(w):JSON.parse(JSON.stringify(w));var vn=class extends rt{constructor(s,p){let T=p.length===1?"it":"them";super(`Tried to use a ${s} in @novu/framework without ${p.join(", ")} installed. Please install ${T} by running \`npm install ${p.join(" ")}\`.`);this.statusCode=500;this.code="MissingDependencyError"}};var _n=async(w,r)=>{let s=new Set;if((await Promise.allSettled(w.map(T=>T.import))).forEach((T,$)=>{let M=w[$];T.status==="fulfilled"&&M.exports.every(re=>T.value[re]!==void 0)||s.add(M.name)}),s.size>0)throw new vn(r,Array.from(s))};var Rn=class{constructor(){this.requiredImports=[];this.ajv=new Rr.default({useDefaults:!0,removeAdditional:"failing"}),(0,Pr.default)(this.ajv),this.compiledSchemas=new Map}async canHandle(r){let s=r.type==="object"||!!r.anyOf||!!r.allOf||!!r.oneOf;return s&&await _n(this.requiredImports,"JSON schema"),s}async validate(r,s){let p=this.compiledSchemas.get(s);p||(p=this.ajv.compile(s),this.compiledSchemas.set(s,p));let T=_r(r);return p(T)?{success:!0,data:T}:{success:!1,errors:p.errors.map(M=>({path:M.instancePath,message:M.message}))}}async transformToJsonSchema(r){return r}};var Pn=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 _n(this.requiredImports,"Zod schema"),s}async validate(r,s){let p=await s.safeParseAsync(r);return p.success?{success:!0,data:p.data}:{success:!1,errors:p.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 In=new Pn,Nn=new Rn,xn=async(w,r)=>{if(await In.canHandle(w))return In.validate(r,w);if(await Nn.canHandle(w))return Nn.validate(r,w);throw new Error("Invalid schema")},Ne=async w=>{if(await In.canHandle(w))return In.transformToJsonSchema(w);if(await Nn.canHandle(w))return Nn.transformToJsonSchema(w);throw new Error("Invalid schema")};var kn=(()=>{var w=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,p=Object.prototype.hasOwnProperty,T=(e,t)=>function(){return e&&(t=(0,e[s(e)[0]])(e=0)),t},$=(e,t)=>function(){return t||(0,e[s(e)[0]])((t={exports:{}}).exports,t),t.exports},M=(e,t)=>{for(var n in t)w(e,n,{get:t[n],enumerable:!0})},ee=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of s(t))!p.call(e,c)&&c!==n&&w(e,c,{get:()=>t[c],enumerable:!(l=r(t,c))||l.enumerable});return e},re=e=>ee(w({},"__esModule",{value:!0}),e),Ee={};M(Ee,{JSONSchemaFaker:()=>gr,default:()=>wr,setDependencies:()=>ki});function Le(e,t){return typeof e=="string"?typeof t!="undefined"?At.register(e,t):At.get(e):At.registerMany(e)}function Ue(e,t){return e=typeof e=="undefined"?He.MIN_INTEGER:e,t=typeof t=="undefined"?He.MAX_INTEGER:t,Math.floor(te("random")()*(t-e+1))+e}function Re(e){return jt.default.prototype.max=te("defaultRandExpMax"),jt.default.prototype.randInt=(n,l)=>n+Math.floor(te("random")()*(1+(l-n))),new jt.default(e).gen()}function De(e){return e[Math.floor(te("random")()*e.length)]}function Fe(e){let t,n,l=e.length,c=e.slice();for(;l>0;)n=Math.floor(te("random")()*l),l-=1,t=c[l],c[l]=c[n],c[n]=t;return c}function ot(e,t){return te("random")()*(t-e)+e}function Je(e,t,n,l,c=!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),c?ot(e,t):Ue(e,t)}function Ut(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 Ut(e);let t=te("minDateTime"),n=te("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(ot(t.getTime(),n.getTime()))}function di(e,t,n){if(t=decodeURIComponent(t),n&&n[t])return ce(n[t]);let l=t.replace("#/","/").split("/"),c=e.$ref&&n&&n[e.$ref]||e;for(!c&&!l[0]&&(l[0]=e.$ref.split("#/")[0]),n&&t.includes("#/")&&n[l[0]]&&(c=n[l.shift()]),l[0]||l.shift();c&&l.length>0;){let f=l.shift();if(!c[f])throw new Error(`Prop not found: ${f} (${t})`);c=c[f]}return c}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,c,f]=t.split("-"),[d,O,D]=n.substr(0,8).split(":");return c=`0${Math.max(1,Math.min(12,c))}`.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),D=`0${Math.max(1,Math.min(59,D))}`.slice(-2),`${l}-${c}-${f}T${d}:${O}:${D}.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=te("minLength")||0,l.maxLength=te("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 c=n(l);if(c==null)return null;switch(e||t.type){case"number":c=$t(c)?parseFloat(c):c;break;case"integer":c=$t(c)?parseInt(c,10):c;break;case"boolean":c=!!c;break;case"string":{if(Ge(c))return c;c=String(c);let f=Math.max(l.minLength||0,0),d=Math.min(l.maxLength||1/0,1/0),O,D=0;for(;c.length<f;)if(O=c,t.pattern?c+=Q.randexp(t.pattern):c+=`${Q.pick([" ","/","_","-","+","=","@","^"])}${c}`,c===O){if(D+=1,D===3)break}else D=0;switch(c.length>d&&(c=c.substr(0,d)),t.format){case"date-time":case"datetime":c=new Date(ys(c)).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"full-date":case"date":c=new Date(fi(c)).toISOString().substr(0,10);break;case"time":c=new Date(`1969-01-01 ${c}`).toISOString().substr(11);break;default:break}break}default:break}return c}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,c)=>{e.type==="array"&&t.type==="array"?e[n][c]=dt(e[n][c]||{},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 ce(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(c=>ce(c,t))),l}let n={};return t.set(e,n),Object.keys(e).reduce((l,c)=>(l[c]=ce(e[c],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 Un(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=>Un(e,n))}function Os(e,t){return t.reduce((l,c)=>l+(Un(e,c)?1:0),0)===1}function As(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)}function Es(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 $n(e){return Object.prototype.toString.call(e)==="[object Object]"&&!Object.keys(e).length}function yi(e,t){t=t.items||t;let n=te("alwaysFakeOptionals"),l=Array.isArray(t.required)&&t.required.includes(e)||n,c=typeof t.thunk=="function"||t.additionalProperties&&typeof t.additionalProperties.thunk=="function";return!l&&!c}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($n(e[l]))yi(l,t)&&delete e[l];else{let c=t;t&&t.properties&&t.properties[l]&&(c=t.properties[l]);let f=Fn(e[l],c);$n(f)||(e[l]=f)}typeof e[l]=="undefined"&&delete e[l]}),!(!Object.keys(e).length&&n))return e}function vs(e){return(t,n,l,c)=>{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("."),D=e();for(;O.length>1;)D=D[O.shift()];return t=typeof D=="object"?D[O[0]]:D,typeof t=="function"&&(t=t.apply(D,d.map(S=>de.template(S,c)))),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 c=Ji.indexOf(t)>-1;return n.indexOf(l)>-1&&!c}).length>0}function Ps(e,t){let n=Object.keys(Et);for(let l=0;l<n.length;l+=1){let c=n[l],f=t[t.length-1];if(Rs(e,f,Et[c]))return c}}function Is(){return te("random")()>.5}function Ns(){return null}function xs(e,t,n,l,c,f){let d=[],O=[];function D(F){let v=JSON.stringify(F.value);return O.indexOf(v)===-1?(O.push(v),d.push(F),!0):!1}t.forEach(D);let S=100;for(;d.length!==t.length&&(D(f(n.items||l,e,c))||(S-=1),!!S););return d}function ks(e,t,n,l){let c=[];if(!(e.items||e.additionalItems)){if(de.hasProperties(e,"minItems","maxItems","uniqueItems")&&(e.minItems!==0||e.maxItems!==0))throw new Yt(`missing items for ${de.short(e)}`,t);return c}if(Array.isArray(e.items))return e.items.map((W,ae)=>{let X=t.concat(["items",ae]);return l(W,X,n)});let f=e.minItems,d=e.maxItems,O=te("minItems"),D=te("maxItems");O&&(f=typeof f=="undefined"?O:Math.min(O,f)),D&&(d=typeof d=="undefined"?D:Math.min(D,d),d&&d>D&&(d=D),f&&f>D&&(f=d));let S=te("alwaysFakeOptionals")===!0?1:te("optionalsProbability"),F=te("alwaysFakeOptionals")||te("fixedProbabilities")||!1,v=Q.number(f,d,1,5);S!==null&&(v=Math.max(F?Math.round((d||v)*S):Math.abs(Q.number(f,d)*S),f||0));let q=typeof e.additionalItems=="object"?e.additionalItems:{};for(let W=c.length;W<v;W+=1){let ae=t.concat(["items",W]),X=l(e.items||q,ae,n);c.push(X)}if(e.contains&&v>0){let W=Q.number(0,v-1);c[W]=l(e.contains,t.concat(["items",W]),n)}return e.uniqueItems?xs(t.concat(["items"]),c,e,q,n,l):c}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,c=l&&String(l).match(/e-(\d)|\.(\d+)$/);if(c){let f=(Math.random()*Q.number(0,10)+1)*l,d=c[1]||c[2].length,O=parseFloat(f.toFixed(d)),D=Q.number(t,n-1);return String(O).includes(".")?D+O:(D+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 c={},f=e.properties||{},d=e.patternProperties||{},O=typeof e.required=="boolean"?[]:(e.required||[]).slice(),D=e.additionalProperties!==!1,S=Object.keys(f),F=Object.keys(d),v=S.concat(F).reduce((Y,h)=>(O.indexOf(h)===-1&&Y.push(h),Y),[]),q=O.concat(v),W=D&&e.additionalProperties===!0?Vt:e.additionalProperties;if(!D&&S.length===0&&F.length===0&&de.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(te("requiredOnly")===!0)return O.forEach(Y=>{f[Y]&&(c[Y]=f[Y])}),l(c,t.concat(["properties"]),n,e);let ae=te("alwaysFakeOptionals")===!0?1:te("optionalsProbability"),X=te("alwaysFakeOptionals")||te("fixedProbabilities")||!1,ne=te("ignoreProperties")||[],he=te("reuseProperties"),ye=te("fillProperties"),j=e.maxProperties||q.length+(D?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)),ae!==null&&(X===!0?b=Math.round(g-O.length+ae*(q.length-g)):b=Q.number(g-O.length,ae*(q.length-g)));let R=Q.shuffle(v).slice(0,b),I=v.filter(Y=>R.indexOf(Y)!==-1),C=ae!==null||O.length===j?j:Q.number(0,j),_=O.concat(Q.shuffle(I).slice(0,C)).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<ne.length;x+=1)if(ne[x]instanceof RegExp&&ne[x].test(Y)||typeof ne[x]=="string"&&ne[x]===Y||typeof ne[x]=="function"&&ne[x](f[Y],Y)){V.push(Y);return}W===!1&&O.indexOf(Y)!==-1&&(c[Y]=f[Y]),f[Y]&&(c[Y]=f[Y]);let h;if(F.forEach(x=>{Y.match(new RegExp(x))&&(h=!0,c[Y]?de.merge(c[Y],d[x]):c[Q.randexp(Y)]=d[x])}),!h){let x=d[Y]||W;x&&W!==!1?c[d[Y]?Q.randexp(Y):Y]=f[Y]||x:J.push(Y)}});let Z=Object.keys(c).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(c[h]);return h}let ve=g;if(D&&!O.length&&(ve=Math.max(ae===null||W?Q.number(ye?1:0,j):0,g)),!I.length&&!b&&D&&X===!0&&ye){let Y=Q.number(0,j);for(let h=0;h<Y;h+=1)c[Wt(1)+Te(Y[h])]=W||Vt}for(;ye&&!(!(F.length||D)||Z>=ve);){if(D)if(he&&S.length-Z>ve){let Y=0,h;do{if(Y+=1,Y>1e3)break;h=Oe(O)||Q.pick(S)}while(typeof c[h]!="undefined");typeof c[h]=="undefined"&&(c[h]=f[h],Z+=1)}else if(F.length&&!W){let Y=Q.pick(F),h=Q.randexp(Y);c[h]||(c[h]=d[Y],Z+=1)}else{let Y=Oe(O)||Wt(1)+Te();c[Y]||(c[Y]=W||Vt,Z+=1)}for(let Y=0;Z<g&&Y<F.length;Y+=1){let h=F[Y],x=Q.randexp(h);c[x]||(c[x]=d[h],Z+=1)}}if(O.length===0&&(!D||ae===!1)){let Y=Q.number(g,j);for(;Z<Y;){let h=Oe(S);h&&(c[h]=f[h]),Z+=1}}let Pe=c;if(te("sortProperties")!==null){let Y=Object.keys(f);Pe=Object.keys(c).sort((x,G)=>te("sortProperties")?x.localeCompare(G):Y.indexOf(x)-Y.indexOf(G)).reduce((x,G)=>(x[G]=c[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 Wt(e).join(" ")}function Us(e=0,t=140){let n=Math.max(0,e),l=Q.number(n,t),c=gi();for(;c.length<n;)c+=gi();return c.length>l&&(c=c.substr(0,l)),c}function $s(){return[0,0,0,0].map(()=>Q.number(0,255)).join(".")}function Fs(){return Q.date().toISOString()}function js(){return Bt().slice(0,10)}function Ys(){return Bt().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 Bt();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(te("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,[c,f])=>(l[c]=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 c={...qs(e),schemaPath:t};if(t[t.length-1]!=="properties"){if(te("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:c}}if(te("useExamplesValue")&&typeof e.example!="undefined")return{value:de.typecast(null,e,()=>e.example),context:c};if(te("useDefaultValue")&&"default"in e&&(e.default!==""||!te("replaceEmptyByRandomValue")))return{value:e.default,context:c};if("template"in e)return{value:de.template(e.template,l),context:c};if("const"in e)return{value:e.const,context:c}}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:F}=ft(e,t.concat(["not"]),n,l);return{value:de.clean(S,e,!1),context:{...c,items:F}}}if(typeof e.thunk=="function"){let{value:S,context:F}=ft(e.thunk(l),t,n);return{value:S,context:{...c,items:F}}}if(e.jsonPath)return{value:e,context:c};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)),F=S===null?"null":typeof S;if(F===f||F==="number"&&f==="integer"||Array.isArray(S)&&f==="array")return{value:S,context:c}}if(typeof e.pattern=="string")return{value:de.typecast("string",e,()=>Q.randexp(e.pattern)),context:c};if(Array.isArray(e.enum))return{value:de.typecast(null,e,()=>Q.pick(e.enum)),context:c};if(typeof f=="string")if(vt[f])try{let S=vt[f](e,t,n,ft);return f==="array"?{value:S.map(({value:F})=>F),context:{...c,items:S.map(Array.isArray(e.items)?({context:F})=>F:({context:F})=>({...F,schemaPath:F.schemaPath.slice(0,-1)}))}}:f==="object"?S!==null?{value:S.value,context:{...c,items:S.context}}:{value:{},context:c}:{value:S,context:c}}catch(S){throw typeof S.path=="undefined"?new Yt(S.stack,t):S}else{if(te("failOnInvalidTypes"))throw new Yt(`unknown primitive ${de.short(f)}`,t.concat(["type"]));{let S=te("defaultInvalidTypeProduct");return typeof S=="string"&&vt[S]?{value:vt[S](e,t,n,ft),context:c}:{value:S,context:c}}}let d={},O={...c};Array.isArray(e)&&(d=[]);let D=te("pruneProperties")||[];return Object.keys(e).forEach(S=>{if(!D.includes(S)&&e[S]!==null)if(typeof e[S]=="object"&&S!=="definitions"){let{value:F,context:v}=ft(e[S],t.concat([S]),n,d);d[S]=de.clean(F,e[S],!1),O[S]=v,d[S]===null&&te("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(c=>jn(c,t,n,l));if(e.jsonPath){let{JSONPath:c}=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]=c(f.path,t).slice(0,f.count):n[d]=c(f.path,t)),f.cycle||f.reverse?Gs(n[d],f.reverse):Js(n[d])}return Object.keys(e).forEach(c=>{e[c]=jn(e[c],t,n,c)}),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 c=te("refDepthMin")||0,f=te("refDepthMax")||3;try{let{resolveSchema:d}=hr({refs:e,schema:t,container:n,synchronous:l,refDepthMin:c,refDepthMax:f}),O=dr(de.clone(t),[],d);return te("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:c,description:f,comment:d}=zs(e,t),O=[];te("renderTitle")&&c&&O.push(` ${c}`,""),te("renderDescription")&&f&&O.push(` ${f}`),te("renderComment")&&d&&O.push(` ${d}`),n.commentBefore=O.join(`
`),l instanceof mr?l.items.forEach(D=>{Yn(e,[...t,"items",D.key.value],D.key,D.value)}):l instanceof yr&&l.items.forEach((D,S)=>{Yn(e,[...t,"items",S],D)})}function Xs({value:e,context:t}){let n=_t.createNode(e);Yn(t,[],n);let l=new _t.Document;return l.contents=n,l.toString()}function wi(){Xe.define("autoIncrement",function(t,n){if(!this.offset){let l=n.minimum||1,c=l+He.MAX_NUMBER,f=t.initialOffset||n.initialOffset;this.offset=f||Q.number(l,c)}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(c=>{n[c.$id||c.id]=c}):n=e||{};function l(c){if(!c||typeof c!="object")return;if(Array.isArray(c))return c.forEach(l);let f=c.$id||c.id;typeof f=="string"&&!n[f]&&(n[f]=c),Object.keys(c).forEach(d=>{l(c[d])})}return l(e),l(t),n}var Si,Wn,Ti,Vn,Oi,Ai,$e,Ei,Bn,U,qn,vi,_i,Ri,Pi,Ii,Ot,Ft,Jn,Ni,xi,Gn,Kn,ki,Mi,Hn,ue,zn,Ci,Li,At,te,Xn,Qn,Di,Ui,$i,Fi,ji,Yi,He,jt,Q,Wi,de,Vi,Bi,ht,Zn,qi,Yt,Et,Ji,Gi,Ki,Hi,zi,Xi,Qi,Zi,er,ei,tr,nr,Wt,Vt,ir,ti,rr,Bt,sr,or,ni,qt,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,_t,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,$e=(e,t)=>function(){return t||(0,e[Vn(e)[0]])((t={exports:{}}).exports,t),t.exports},Ei=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of Vn(t))!Ai.call(e,c)&&c!==n&&Wn(e,c,{get:()=>t[c],enumerable:!(l=Ti(t,c))||l.enumerable});return e},Bn=(e,t,n)=>(n=e!=null?Si(Oi(e)):{},Ei(t||!e||!e.__esModule?Wn(n,"default",{value:e,enumerable:!0}):n,e)),U=$e({"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=$e({"node_modules/ret/lib/sets.js"(e){var t=U(),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()),c=()=>[{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:c(),not:!1}),e.notWhitespace=()=>({type:t.SET,set:c(),not:!0}),e.anyChar=()=>({type:t.SET,set:f(),not:!0})}}),vi=$e({"node_modules/ret/lib/util.js"(e){var t=U(),n=qn(),l="@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?",c={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,D,S,F,v,q,W,ae){if(S)return O;var X=D?8:F?parseInt(F,16):v?parseInt(v,16):q?parseInt(q,8):W?l.indexOf(W):c[ae],ne=String.fromCharCode(X);return/[[\]{}^$.|?*+()]/.test(ne)&&(ne="\\"+ne),ne}),f},e.tokenizeClass=(f,d)=>{for(var O=[],D=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g,S,F;(S=D.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(F=S[12])O.push({type:t.CHAR,value:F.charCodeAt(0)});else return[O,D.lastIndex];e.error(d,"Unterminated character class")},e.error=(f,d)=>{throw new SyntaxError("Invalid regular expression: /"+f+"/: "+d)}}}),_i=$e({"node_modules/ret/lib/positions.js"(e){var t=U();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=$e({"node_modules/ret/lib/index.js"(e,t){var n=vi(),l=U(),c=qn(),f=_i();t.exports=d=>{var O=0,D,S,F={type:l.ROOT,stack:[]},v=F,q=F.stack,W=[],ae=I=>{n.error(d,`Nothing to repeat at column ${I-1}`)},X=n.strToChars(d);for(D=X.length;O<D;)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(c.words());break;case"W":q.push(c.notWords());break;case"d":q.push(c.ints());break;case"D":q.push(c.notInts());break;case"s":q.push(c.whitespace());break;case"S":q.push(c.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 ne;X[O]==="^"?(ne=!0,O++):ne=!1;var he=n.tokenizeClass(X.slice(O),d);O+=he[1],q.push({type:l.SET,set:he[0],not:ne});break;case".":q.push(c.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(v),v=ye,q=ye.stack;break;case")":W.length===0&&n.error(d,`Unmatched ) at column ${O-1}`),v=W.pop(),q=v.options?v.options[v.options.length-1]:v.stack;break;case"|":v.options||(v.options=[v.stack],delete v.stack);var j=[];v.options.push(j),q=j;break;case"{":var g=/^(\d+)(,(\d+)?)?\}/.exec(X.slice(O)),b,R;g!==null?(q.length===0&&ae(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&&ae(O),q.push({type:l.REPETITION,min:0,max:1,value:q.pop()});break;case"+":q.length===0&&ae(O),q.push({type:l.REPETITION,min:1,max:1/0,value:q.pop()});break;case"*":q.length===0&&ae(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"),F},t.exports.types=l}}),Pi=$e({"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 Lt{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=D=>{for(var S=0;S<this.ranges.length&&!D.touches(this.ranges[S]);)S++;for(var F=this.ranges.slice(0,S);S<this.ranges.length&&D.touches(this.ranges[S]);)D=D.add(this.ranges[S]),S++;F.push(D),this.ranges=F.concat(this.ranges.slice(S)),this._update_length()};return f instanceof Lt?f.ranges.forEach(O):(d==null&&(d=f),O(new n(f,d))),this}subtract(f,d){var O=D=>{for(var S=0;S<this.ranges.length&&!D.overlaps(this.ranges[S]);)S++;for(var F=this.ranges.slice(0,S);S<this.ranges.length&&D.overlaps(this.ranges[S]);)F=F.concat(this.ranges[S].subtract(D)),S++;this.ranges=F.concat(this.ranges.slice(S)),this._update_length()};return f instanceof Lt?f.ranges.forEach(O):(d==null&&(d=f),O(new n(f,d))),this}intersect(f,d){var O=[],D=S=>{for(var F=0;F<this.ranges.length&&!S.overlaps(this.ranges[F]);)F++;for(;F<this.ranges.length&&S.overlaps(this.ranges[F]);){var v=Math.max(this.ranges[F].low,S.low),q=Math.min(this.ranges[F].high,S.high);O.push(new n(v,q)),F++}};return f instanceof Lt?f.ranges.forEach(D):(d==null&&(d=f),D(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 Lt(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=$e({"node_modules/randexp/lib/randexp.js"(e,t){var n=Ri(),l=Pi(),c=n.types;t.exports=class Dt{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:Dt.prototype.max!=null?Dt.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 D,S,F,v,q;switch(d.type){case c.ROOT:case c.GROUP:if(d.followedBy||d.notFollowedBy)return"";for(d.remember&&d.groupNumber===void 0&&(d.groupNumber=O.push(null)-1),D=d.options?this._randSelect(d.options):d.stack,S="",v=0,q=D.length;v<q;v++)S+=this._gen(D[v],O);return d.remember&&(O[d.groupNumber]=S),S;case c.POSITION:return"";case c.SET:var W=this._expand(d);return W.length?String.fromCharCode(this._randSelect(W)):"";case c.REPETITION:for(F=this.randInt(d.min,d.max===1/0?d.min+this.max:d.max),S="",v=0;v<F;v++)S+=this._gen(d.value,O);return S;case c.REFERENCE:return O[d.value-1]||"";case c.CHAR:var ae=this.ignoreCase&&this._randBool()?this._toOtherCase(d.value):d.value;return String.fromCharCode(ae)}}_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 D=0;D<d.set.length;D++){let S=this._expand(d.set[D]);if(O.add(S),this.ignoreCase)for(let F=0;F<S.length;F++){let v=S.index(F),q=this._toOtherCase(v);v!==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 D;return typeof d=="string"&&(d=new RegExp(d,O)),d._randexp===void 0?(D=new Dt(d,O),d._randexp=D):(D=d._randexp,D._setDefaults(d)),D.gen()}static sugar(){RegExp.prototype.gen=function(){return Dt.randexp(this)}}}}}),Ot=$e({"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:",c={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 C=0;C<b.length;++C){let _=b[C];if(j<_)return{line:C,col:j-b[C-1]+1};if(j===_)return{line:C+1,col:1}}let I=b.length;return{line:I,col:j-b[I-1]+1}}function D(j,g){let{lineStarts:b,src:R}=d(g);if(!b||!(j>=1)||j>b.length)return null;let I=b[j-1],C=b[j];for(;C&&C>I&&R[C-1]===`
`;)--C;return R.slice(I,C)}function S({start:j,end:g},b,R=80){let I=D(j.line,b);if(!I)return null;let{col:C}=j;if(I.length>R)if(C<=R-10)I=I.substr(0,R-1)+"\u2026";else{let J=Math.round(R/2);I.length>C+J&&(I=I.substr(0,C+J-1)+"\u2026"),C-=I.length-R,I="\u2026"+I.substr(1-R)}let _=1,N="";g&&(g.line===j.line&&C+(g.col-j.col)<=R+1?_=g.col-j.col:(_=Math.min(I.length+1,R)-C,N="\u2026"));let k=C>1?" ".repeat(C-1):"",V="^".repeat(_);return`${I}
${k}${V}${N}`}var F=class Ir{static copy(g){return new Ir(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 C=b;for(;C<g.length&&!(g[C]>R);)++C;this.origStart=R+C;let _=C;for(;C<g.length&&!(g[C]>=I);)++C;return this.origEnd=I+C,_}},v=class tt{static addStringTerminator(g,b,R){if(R[R.length-1]===`
`)return R;let I=tt.endOfWhiteSpace(g,b);return I>=g.length||g[I]===`
`?R+`
`:R}static atDocumentBoundary(g,b,R){let I=g[b];if(!I)return!0;let C=g[b-1];if(C&&C!==`
`)return!1;if(R){if(I!==R)return!1}else if(I!==t.DIRECTIVES_END&&I!==t.DOCUMENT_END)return!1;let _=g[b+1],N=g[b+2];if(_!==I||N!==I)return!1;let k=g[b+3];return!k||k===`
`||k===" "||k===" "}static endOfIdentifier(g,b){let R=g[b],I=R==="<",C=I?[`
`," "," ",">"]:[`
`,"