UNPKG

openapi-examples-validator

Version:
3 lines 47.9 kB
#!/usr/bin/env node (()=>{var e,t,r={476(e,t,r){const o=r(711),{ENOENT:s}=r(184).code,n={jsENOENT:s.code,jsonPathNotFound:"JsonPathNotFound",errorAndErrorsMutuallyExclusive:"ErrorErrorsMutuallyExclusive",parseError:"ParseError",validation:"Validation"};class a{static create(e){const{code:t,message:r,path:s,cause:i}=e,c=t||e.type||n.validation,l={message:r};return n.validation===c||n.errorAndErrorsMutuallyExclusive===c?o(l,e):(s&&o(l,{params:{path:s}}),i&&o(l,i)),new a(c,l)}constructor(e,t={}){Object.assign(this,{type:e,...t})}}e.exports={ApplicationError:a,ErrorType:n}},115(e,t,r){const o=r(723).version,s=r(858),{validateFile:n,validateExample:a,validateExamplesByMap:i}=r(497),c="true"===process.env.OPENAPI_EXAMPLES_VALIDATOR_TESTS;s.version(o).arguments("<filepath>").description("Validate embedded examples in OpenAPI-specs (JSON and YAML supported).\n To validate external examples, use the `-s` and `-e` option.\n To pass a mapping-file, to validate multiple external examples, use the `-m` option.").option("-s, --schema-jsonpath <schema-jsonpath>","Path to OpenAPI-schema, to validate the example file against").option("-e, --example-filepath <example-filepath>","file path to example file, to be validated").option("-m, --mapping-filepath <mapping-filepath>","file path to map, containing schema-paths as key and the file-path(s) to examples as value. If wildcards are used, the parameter has to be put in quotes.").option("-c, --cwd-to-mapping-file","changes to the directory of the mapping-file, before resolving the example's paths. Use this option, if your mapping-files use relative paths for the examples").option("-n, --no-additional-properties","don't allow properties that are not described in the schema").option("-r, --all-properties-required","make all the properties in the schema required").option("-o, --ignore-formats <ignored-formats...>",'Datatype formats to ignore (to prevent "unknown format" message in the error-console.)').action(async function(e,t){const{schemaJsonpath:r,exampleFilepath:o,mappingFilepath:s,cwdToMappingFile:l,allPropertiesRequired:p}=t,u=!t.additionalProperties,f=function(e){return null!=e&&Array.isArray(e)?1!==e.length||-1===e[0].indexOf("\n")?e:e[0].split("\n").filter(e=>!e.match(/^\s*$/)):e}(t.ignoreFormats);let h;s?(console.log("Validating with mapping file"),h=await i(e,s,{cwdToMappingFile:l,noAdditionalProperties:u,ignoreFormats:f,allPropertiesRequired:p})):r&&o?(console.log("Validating single external example"),h=await a(e,r,o,{noAdditionalProperties:u,ignoreFormats:f,allPropertiesRequired:p})):(console.log("Validating examples"),h=await n(e,{noAdditionalProperties:u,ignoreFormats:f,allPropertiesRequired:p})),function(e){const t=c;if(function(e){const{schemasWithExamples:t,examplesWithoutSchema:r,examplesTotal:o,matchingFilePathsMapping:s}=e,n=[`Schemas with examples found: ${t}`,`Examples without schema found: ${r}`,`Total examples found: ${o}`];null!=s&&n.push(`Matching mapping files found: ${s}`),process.stdout.write(`${n.join("\n")}\n`)}(e.statistics),e.valid)return process.stdout.write("\nNo errors found.\n\n"),void(!t&&process.exit(0));process.stdout.write("\nErrors found.\n\n"),process.stderr.write(JSON.stringify(e.errors,null," ")),!t&&process.exit(1)}(h)}),s.on("--help",()=>{console.log("\n\n Example for external example-file:\n"),console.log(" $ openapi-examples-validator -s $.paths./.get.responses.200.schema -e example.json openapi-spec.json\n\n")}),e.exports=s.parseAsync(process.argv)},285(e){e.exports={parent:"parent",parentProperty:"parentProperty",path:"path",pointer:"pointer",value:"value"}},600(e,t,r){const o=r(273),s=r(474),n=/^3\./;e.exports={getImplementation:function(e){return"string"==typeof e.swagger?o:e.openapi&&e.openapi.match(n)?s:null}}},299(e,t,r){const{applyCallbackToAllObjectModels:o}=r(935);e.exports={setAllPropertiesRequired:function(e,t=[]){o(e,t,()=>e=>{e.hasOwnProperty("properties")&&(e.required=Object.keys(e.properties))})}}},935(e,t,r){const{JSONPath:o}=r(940),s=r(285);function n(e,t,r=s.path,n){return o({json:e,path:t,flatten:!0,resultType:r,callback:n})}e.exports={applyCallbackToAllObjectModels:function(e,t,r){const o=new Set;n(e,"$..schema..").forEach(e=>{(function(e){if(!e.match(/\['properties']$/))return;const t=e.match(/(?<!\['properties'])(\['properties']\['properties'])+$/);return!t||t.length%2!=0})(e)||o.add(e)}),function(e,t,r){r.forEach(r=>{n(e,r).forEach(e=>{for(const r of t)r.startsWith(e)&&t.delete(r)})})}(e,o,t);for(const t of o){const o=r(t);n(e,t,s.value,(e,t,r)=>{var s;(s=e)&&("object"===s.type||s.properties)&&o(e,t,r)})}}}},305(e,t,r){const{applyCallbackToAllObjectModels:o}=r(935);e.exports={setNoAdditionalProperties:function(e,t=[]){const r=new RegExp("(?<!\\['properties'\\])\\['(?:"+s.join("|")+")'\\]");o(e,t,e=>t=>{r.test(e)?console.warn(`"additionalProperties" flag not set for ${e} because it has a parent with a JSON-schema combiner keyword.`):s.some(e=>t.hasOwnProperty(e))?console.warn(`"additionalProperties" flag not set for ${e} because it contains JSON-schema combiner keyword.`):t.hasOwnProperty("additionalProperties")||(t.additionalProperties=!1)})}};const s=["oneOf","allOf","anyOf","not"]},273(e,t,r){const o=r(984),{setAllPropertiesRequired:s}=r(299),{setNoAdditionalProperties:n}=r(305);function a(){return['$..examples[?(@property && typeof @property === "string" && @property.match(/[/+]json/))]']}e.exports={buildValidationMap:function(e){return e.reduce((e,t)=>{const r=function(e){const t=e.split("/"),r=t.lastIndexOf("examples");return t.splice(r,t.length-r,"schema"),t.join("/")}(t);return e[r]=(e[r]||new Set).add(t),e},{})},getJsonPathsToExamples:a,prepare:function(e,{noAdditionalProperties:t,allPropertiesRequired:r}={}){const a=o(e);return t&&n(a,['$..examples[?(@property && typeof @property === "string" && @property.match(/[/+]json/))]']),r&&s(a,['$..examples[?(@property && typeof @property === "string" && @property.match(/[/+]json/))]']),a}}},474(e,t,r){const o=r(984),{ApplicationError:s,ErrorType:n}=r(476),{setAllPropertiesRequired:a}=r(299),{setNoAdditionalProperties:i}=r(305),c='$..responses..content[?(@property && typeof @property === "string" && @property.match(/[/+]json/))]',l='$..requestBody.content[?(@property && typeof @property === "string" && @property.match(/[/+]json/))]',p=".example",u=".examples.*.value",f=`${c}${p}`,h=`${c}${u}`,d=`${l}${p}`,m=`${l}${u}`,y="single";function g(){return[f,h,"$..parameters..example","$..parameters..examples.*.value",d,m]}e.exports={buildValidationMap:function(e){const t=new Map;return e.reduce((e,r)=>{const{pathSchemaAsArray:o,exampleType:a}=function(e){const t=e.split("/"),r=t.lastIndexOf("example"),o=r>-1?y:"multi",s=o===y?r:t.lastIndexOf("examples");return t.splice(s,t.length-s,"schema"),{exampleType:o,pathSchemaAsArray:t}}(r),i=o.join("/"),c=t.get(i);return c&&c!==a&&function(e){const t=e.slice(0,e.length-1);throw s.create({type:n.errorAndErrorsMutuallyExclusive,message:'Properties "error" and "errors" are mutually exclusive',params:{pathContext:t.join("/")}})}(o),t.set(i,a),e[i]=(e[i]||new Set).add(r),e},{})},getJsonPathsToExamples:g,prepare:function(e,{noAdditionalProperties:t,allPropertiesRequired:r}={}){const s=o(e);return t&&i(s,g()),r&&a(s,g()),s}}},497(e,t,r){const o=r(711),s=r(149),n=r(668),a=r(258),i=r(896),c=r(928),l=r(410),p=r(496),{JSONPath:u}=r(940),f=r(231),{createError:h}=r(184).custom,d=r(285),{getValidatorFactory:m,compileValidate:y}=r(631),g=r(600),{ApplicationError:$,ErrorType:v}=r(476),{createValidationResponse:w,dereferenceJsonSchema:b}=r(427),x=Symbol("internal"),E="schemasWithExamples",j=["yaml","yml"],P=h(v.jsonPathNotFound);async function R(e){const t=function(e){const t=e.split(".").pop();return j.includes(t)}(e);let r;if(t)try{r=p.parse(i.readFileSync(e,"utf-8"))}catch(e){const{name:t,message:r}=e;throw new $(v.parseError,{message:`${t}: ${r}`})}else r=JSON.parse(i.readFileSync(e,"utf-8"));return await b(e,r)}function O(e){const t=k(),r=e(t);return w({errors:r,statistics:t})}function S(e,t,r,{cwdToMappingFile:o=!1,dirPathMapExternalExamples:a,ignoreFormats:p}){return n(Object.entries(t),([t,u])=>{let f=null;try{f=N(_(t,e),e)}catch(e){return $.create(e)}return n(s([u]),t=>{let s=[];try{const e=o?c.join(a,t):t,r=l.sync(e);if(0===r.length)return[$.create({type:v.jsENOENT,message:`No such file or directory: '${e}'`,path:e})];for(const e of r)s.push({path:c.normalize(e),content:JSON.parse(i.readFileSync(e,"utf-8"))})}catch(e){return[$.create(e)]}return n(s,t=>I({createValidator:F(e,{ignoreFormats:p}),schema:f,example:t.content,statistics:r,filePathExample:t.path}))})})}function A(e,t){return u({json:t,path:e,resultType:d.pointer})}function _(e,t){const r=A(e,t);return 0===r.length&&M(e),r.length>1?[$.create({type:v.jsonPathNotFound,message:`Path to schema cannot identify unique schema: '${e}'`,path:e})]:r[0]}function k(){const e={[x]:{[E]:new Set},examplesTotal:0,examplesWithoutSchema:0,get[E](){return e[x][E].size}};return e}function T(e,t){try{return a.get(t,e)}catch(e){return}}function I({createValidator:e,schema:t,example:r,statistics:o,filePathExample:s}){const n=[];if(o.examplesTotal++,!t)return o.examplesWithoutSchema++,n;o[x][E].add(t);const a=y(e(),t);return a(r)?n:n.concat(...a.errors.map($.create)).map(e=>s?(e.exampleFilePath=s,e):e)}function F(e,{ignoreFormats:t}){return m(e,{schemaId:"auto",discriminator:!0,strict:!1,allErrors:!0,formats:t&&t.reduce((e,t)=>(e[t]=()=>!0,e),{})})}function N(e,t,r=!1){const o=T(e,t);return r||o||M(e),o}function M(e){throw new P(`Path to schema can't be found: '${e}'`,{params:{path:e}})}t.validateFile=async function(e,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:o}={}){let s=null;try{s=await R(e)}catch(e){return w({errors:[$.create(e)]})}return async function(e,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:o}={}){const s=g.getImplementation(e);e=await f.dereference(e),e=s.prepare(e,{noAdditionalProperties:t,allPropertiesRequired:o});let n=s.getJsonPathsToExamples().reduce((t,r)=>t.concat(A(r,e)),[]);return function({impl:e},t,r,{ignoreFormats:o}){const s=k(),n={valid:!0,statistics:s,errors:[]},a=F(r,{ignoreFormats:o});let i;try{i=e.buildValidationMap(t)}catch(e){if(!(e instanceof $))throw e;return n.valid=!1,n.errors.push(e),n}return Object.keys(i).forEach(e=>{!function({openapiSpec:e,createValidator:t,schemaPointer:r,validationMap:o,statistics:s,validationResult:n}){const a=n.errors;o[r].forEach(o=>{const i=T(o,e),c=N(r,e,!0),l=I({createValidator:t,schema:c,example:i,statistics:s}).map(e=>(e.examplePath=o,e));l.length&&(n.valid=!1,a.splice(a.length-1,0,...l))})}({openapiSpec:r,createValidator:a,schemaPointer:e,validationMap:i,statistics:s,validationResult:n})}),n}({impl:s},n,e,{ignoreFormats:r})}(s,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:o})},t.validateExample=async function(e,t,r,{noAdditionalProperties:o,ignoreFormats:s,allPropertiesRequired:n}={}){let a=null,c=null,l=null;try{a=JSON.parse(i.readFileSync(r,"utf-8")),l=await R(e),l=g.getImplementation(l).prepare(l,{noAdditionalProperties:o,allPropertiesRequired:n}),c=N(_(t,l),l)}catch(e){return w({errors:[$.create(e)]})}return O(e=>I({createValidator:F(l,{ignoreFormats:s}),schema:c,example:a,statistics:e,filePathExample:r}))},t.validateExamplesByMap=async function(e,t,{cwdToMappingFile:r,noAdditionalProperties:s,ignoreFormats:n,allPropertiesRequired:a}={}){let p=0;const u=l.sync(t,{nonull:!0});let f=[];for(const t of u){let o=null,l=null;try{o=JSON.parse(i.readFileSync(t,"utf-8")),l=await R(e),l=g.getImplementation(l).prepare(l,{noAdditionalProperties:s,allPropertiesRequired:a})}catch(e){f.push(w({errors:[$.create(e)]}));continue}p++,f.push(O(e=>S(l,o,e,{cwdToMappingFile:r,dirPathMapExternalExamples:c.dirname(t),ignoreFormats:n}).map(e=>Object.assign(e,{mapFilePath:c.normalize(t)}))))}return o(f.reduce((e,t)=>{return e?(o=t,w({errors:(r=e).errors.concat(o.errors),statistics:Object.entries(r.statistics).reduce((e,[t,s])=>E===t?([r,o].forEach(t=>{const r=t.statistics[x][E].values();for(let t of r)e[x][E].add(t)}),e):(e[t]=s+o.statistics[t],e),k())})):t;var r,o},null),{statistics:{matchingFilePathsMapping:p}})}},427(e,t,r){const o=r(928),s=r(231);e.exports={createValidationResponse:function({errors:e,statistics:t={}}){return{valid:!e.length,statistics:t,errors:e}},dereferenceJsonSchema:async function(e,t){const r=process.cwd();process.chdir(o.dirname(e));const n=await s.dereference(t);return process.chdir(r),n}}},631(e,t,r){const{JSONPath:o}=r(940),s=r(258),{default:n}=r(804),{default:a}=r(402),i="$id",c="$..$ref",l="https://www.npmjs.com/package/openapi-examples-validator/defs.json";e.exports={getValidatorFactory:function(e,t){const r=function(e){const t={[i]:l};return o({path:c,json:e,callback(r){if(!r.startsWith("#"))return;const o=r.substring(1),n=s.get(e,o);s.set(t,o,n)}}),t}(e);return()=>{const e=new n(t);return a(e),e.addSchema(r),e}},compileValidate:function(e,t){const r=(s=t,{...s,[i]:"https://www.npmjs.com/package/openapi-examples-validator/schema.json"});var s;let n;o({path:c,json:r,callback(e,t,r){e.startsWith("#")&&(r.parent[r.parentProperty]=`${l}${e}`)}});try{n=e.compile(r)}catch(e){n=()=>{},n.errors=[e]}return n}}},723(e){e.exports={name:"openapi-examples-validator",version:"7.1.0",description:"Validates embedded examples in OpenAPI-JSONs",main:"dist/index.js",types:"dist/index.d.ts",engines:{node:">=20"},bin:{"openapi-examples-validator":"dist/cli.js"},"standard-version":{scripts:{postchangelog:"npm run release:create-dockerfile && npm run release:stage-artifacts"}},scripts:{"start-dev":"babel-node src/cli",build:"npm run build:clean && npm run build:webpack && npm run build:types","build:clean":"rimraf dist","build:webpack":"webpack --bail --progress --profile --mode production --config ./webpack/config.babel.js","build:types":"tsc -p tsconfig.json --noCheck",coverage:'rimraf ./coverage && nyc --reporter=lcov --reporter=text -x "dist/**/*" -x "test/**/*.js" npm test',test:"npm run build && npm run test:mocha","test-mutations":"stryker run","test:mocha":'mocha --require "./test/util/setup-tests" --recursive "./test/specs/**/*.js"',release:"npm run build && standard-version -a","release:create-dockerfile":"npm run build && node etc/src/build-dockerfile.js","release:stage-artifacts":"git add dist/*"},repository:{type:"git",url:"git+https://github.com/codekie/openapi-examples-validator.git"},keywords:["swagger","openapi","json","validate","examples"],author:"Josua Amann",license:"MIT",bugs:{url:"https://github.com/codekie/openapi-examples-validator/issues"},homepage:"https://github.com/codekie/openapi-examples-validator#readme",devDependencies:{"@babel/cli":"^7.28.6","@babel/core":"^7.29.0","@babel/eslint-parser":"^7.28.6","@babel/node":"^7.29.0","@babel/preset-env":"^7.29.2","@babel/register":"^7.28.6","@stryker-mutator/core":"^9.6.0","@stryker-mutator/mocha-runner":"^9.6.0","@types/glob":"^8.1.0","@types/json-pointer":"^1.0.34","@types/lodash.clonedeep":"^4.5.9","@types/lodash.flatmap":"^4.5.9","@types/lodash.flatten":"^4.4.9","@types/lodash.merge":"^4.6.9","@types/node":"*","babel-loader":"^10.1.1",chai:"^4.5.0","chai-string":"^1.6.0","core-js-pure":"^3.49.0",eslint:"^9.26.0","eslint-webpack-plugin":"^5.0.3",globals:"^16.0.0","json-loader":"^0.5.7",mocha:"^11.7.5","mocha-lcov-reporter":"^1.3.0",nyc:"^17.1.0",rimraf:"^6.1.3","standard-version":"^9.5.0",typescript:"^6.0.2",webpack:"^5.106.0","webpack-cli":"^6.0.1"},dependencies:{"@apidevtools/json-schema-ref-parser":"^15.3.5",ajv:"^8.18.0","ajv-draft-04":"^1.0.0","ajv-formats":"^2.1.1",commander:"^6.2.1",errno:"^1.0.0",glob:"^8.1.0","json-pointer":"^0.6.2","jsonpath-plus":"^10.4.0","lodash.clonedeep":"^4.5.0","lodash.flatmap":"^4.5.0","lodash.flatten":"^4.4.0","lodash.merge":"^4.6.2",yaml:"^2.8.3"}}},804(e){"use strict";e.exports=require("ajv-draft-04")},402(e){"use strict";e.exports=require("ajv-formats")},858(e){"use strict";e.exports=require("commander")},184(e){"use strict";e.exports=require("errno")},410(e){"use strict";e.exports=require("glob")},258(e){"use strict";e.exports=require("json-pointer")},940(e){"use strict";e.exports=require("jsonpath-plus")},984(e){"use strict";e.exports=require("lodash.clonedeep")},668(e){"use strict";e.exports=require("lodash.flatmap")},149(e){"use strict";e.exports=require("lodash.flatten")},711(e){"use strict";e.exports=require("lodash.merge")},496(e){"use strict";e.exports=require("yaml")},896(e){"use strict";e.exports=require("fs")},928(e){"use strict";e.exports=require("path")},231(e,t,r){"use strict";function o(e){return e.startsWith("\\\\?\\")?e:e.split("\\").join("/")}r.r(t),r.d(t,{$RefParser:()=>Ue,$Refs:()=>re,FileResolver:()=>ge,HTTPResolver:()=>$e,InvalidPointerError:()=>M,JSONParserError:()=>S,JSONParserErrorGroup:()=>A,MissingPointerError:()=>F,ParserError:()=>_,ResolverError:()=>T,UnmatchedParserError:()=>k,UnmatchedResolverError:()=>I,bundle:()=>Le,default:()=>Je,dereference:()=>De,dereferenceInternal:()=>Te,getJsonSchemaRefParserDefaultOptions:()=>we,isHandledError:()=>B,isUnsafeUrl:()=>w,jsonSchemaParserNormalizeArgs:()=>je,parse:()=>Ve,resolve:()=>Ce});const s=/^win/.test(globalThis.process?globalThis.process.platform:""),n=()=>s,a=/\//g,i=/^(\w{2,}):\/\//i,c=/~1/g,l=/~0/g,p=/^[a-zA-Z]:[\\/]/,u=[[/\?/g,"%3F"],[/#/g,"%23"]],f=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"],h=e=>new URL(e);function d(e,t){const r=new URL(o(e),"https://aaa.nonexistanturl.com"),s=new URL(o(t),r),n=t.match(/(\s*)$/)?.[1]||"";if("aaa.nonexistanturl.com"===s.hostname){const{pathname:e,search:t,hash:r}=s;return e+t+decodeURIComponent(r)+n}const a=s.toString()+n;if(a.includes("#")){const[e,t]=a.split("#",2);return e+"#"+decodeURIComponent(t||"")}return a}function m(){if("undefined"!=typeof window&&window.location&&window.location.href){const e=window.location.href;if(!e||!e.startsWith("http"))try{return new URL(e),e}catch{return"/"}return e}if("undefined"!=typeof process&&process.cwd){const e=process.cwd(),t=e.slice(-1);return"/"===t||"\\"===t?e:e+"/"}return"/"}function y(e){const t=i.exec(e||"");if(t)return t[1].toLowerCase()}function g(e){const t=e.lastIndexOf(".");return t>=0?function(e){const t=e.indexOf("?");return t>=0&&(e=e.substring(0,t)),e}(e.substring(t).toLowerCase()):""}function $(e){if(!e)return"#";const t=e.indexOf("#");return t>=0?e.substring(t):"#"}function v(e){if(!e)return"";const t=e.indexOf("#");return t>=0&&(e=e.substring(0,t)),e}function w(e){if(!e||"string"!=typeof e)return!0;const t=e.trim().toLowerCase();if(!t)return!0;if(t.startsWith("javascript:")||t.startsWith("vbscript:")||t.startsWith("data:"))return!0;if(t.startsWith("file:"))return!0;if("undefined"!=typeof window&&window.location&&window.location.href)return!1;const r=["localhost","127.0.0.1","::1","10.","172.16.","172.17.","172.18.","172.19.","172.20.","172.21.","172.22.","172.23.","172.24.","172.25.","172.26.","172.27.","172.28.","172.29.","172.30.","172.31.","192.168.","169.254.",".local",".internal",".intranet",".corp",".home",".lan"];try{const e=new URL(t.startsWith("//")?"http:"+t:t),o=e.hostname.toLowerCase();for(const e of r)if(o===e||o.startsWith(e)||o.endsWith(e))return!0;if(function(e){const t=e.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(!t)return!1;const[,r,o,s,n]=t.map(Number);return!(r>255||o>255||s>255||n>255)&&(10===r||127===r||172===r&&o>=16&&o<=31||192===r&&168===o||169===r&&254===o)}(o))return!0;const s=e.port;if(s&&function(e){return[22,23,25,53,135,139,445,993,995,1433,1521,3306,3389,5432,5900,6379,8080,8443,9200,27017].includes(e)}(parseInt(s)))return!0}catch{if(t.startsWith("/")&&!t.startsWith("//"))return!1;for(const e of r)if(t.includes(e))return!0}return!1}function b(e){if("undefined"!=typeof window||"undefined"!=typeof process&&process.browser)return!1;const t=y(e);return void 0===t||"file"===t}function x(e,t){e=e.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"),e=decodeURI(e);for(let t=0;t<f.length;t+=2)e=e.replace(f[t],f[t+1]);let r=e.toLowerCase().startsWith("file://");return r&&(e=e.replace(/^file:\/\//,"").replace(/^\//,""),n()&&"/"===e[1]&&(e=`${e[0]}:${e.substring(1)}`),t?e="file:///"+e:(r=!1,e=n()?e:"/"+e)),n()&&!r&&(e=e.replace(a,"\\")).match(/^[a-z]:\\/i)&&(e=e[0].toUpperCase()+e.substring(1)),e}function E(e){return e.length<=1||"#"!==e[0]||"/"!==e[1]?[]:e.slice(2).split("/").map(e=>e.replace(c,"/").replace(l,"~"))}const j=["function","symbol","undefined"],P=["constructor","prototype","__proto__"],R=Object.getPrototypeOf({});function O(){const e={},t=this;for(const r of function(e,t=[]){let r=[];for(;e&&e!==R;)r=r.concat(Object.getOwnPropertyNames(e),Object.getOwnPropertySymbols(e)),e=Object.getPrototypeOf(e);const o=new Set(r);for(const e of t.concat(P))o.delete(e);return o}(t))if("string"==typeof r){const o=t[r],s=typeof o;j.includes(s)||(e[r]=o)}return e}class S extends Error{name;message;source;path;code;constructor(e,t){super(),this.code="EUNKNOWN",this.name="JSONParserError",this.message=e,this.source=t,this.path=null}toJSON=O.bind(this);get footprint(){return`${this.path}+${this.source}+${this.code}+${this.message}`}}class A extends Error{files;constructor(e){super(),this.files=e,this.name="JSONParserErrorGroup",this.message=`${this.errors.length} error${this.errors.length>1?"s":""} occurred while reading '${x(e.$refs._root$Ref.path)}'`}toJSON=O.bind(this);static getParserErrors(e){const t=[];for(const r of Object.values(e.$refs._$refs))r.errors&&t.push(...r.errors);return t}get errors(){return A.getParserErrors(this.files)}}class _ extends S{code="EPARSER";name="ParserError";constructor(e,t){super(`Error parsing ${t}: ${e}`,t)}}class k extends S{code="EUNMATCHEDPARSER";name="UnmatchedParserError";constructor(e){super(`Could not find parser for "${e}"`,e)}}class T extends S{code="ERESOLVER";name="ResolverError";ioErrorCode;constructor(e,t){super(e.message||`Error reading file "${t}"`,t),"code"in e&&(this.ioErrorCode=String(e.code))}}class I extends S{code="EUNMATCHEDRESOLVER";name="UnmatchedResolverError";constructor(e){super(`Could not find resolver for "${e}"`,e)}}class F extends S{code="EMISSINGPOINTER";name="MissingPointerError";targetToken;targetRef;targetFound;parentPath;constructor(e,t,r,o,s){super(`Missing $ref pointer "${$(t)}". Token "${e}" does not exist.`,v(t)),this.targetToken=e,this.targetRef=r,this.targetFound=o,this.parentPath=s}}class N extends S{code="ETIMEOUT";name="TimeoutError";constructor(e){super(`Dereferencing timeout reached: ${e}ms`)}}class M extends S{code="EUNMATCHEDRESOLVER";name="InvalidPointerError";constructor(e,t){super(`Invalid $ref pointer "${e}". Pointers must begin with "#/"`,v(t))}}function B(e){return e instanceof S||e instanceof A}function q(e){return null===e.path&&(e.path=[]),e}function U(e,t){const r=function(e){if(e&&"object"==typeof e&&"$id"in e&&"string"==typeof e.$id&&e.$id.length>0)return e.$id}(t);return r?d(e,r):e}function J(e){if(!e||"object"!=typeof e||ArrayBuffer.isView(e))return!1;const t=e.$schema;if("string"==typeof t&&(t.includes("draft/2019-09/")||t.includes("draft/2020-12/")||t.includes("oas/3.1/")))return!0;const r=e.openapi;return"string"==typeof r&&/^3\.1(?:\.|$)/.test(r)}function W(e,t,r,o,s=!1){if(!s)return;const n=new Set,a=(t,r)=>{if(!t||"object"!=typeof t||ArrayBuffer.isView(t)||n.has(t))return;n.add(t);const i=U(r,t);i!==r&&e._addAlias(i,t,o,s);for(const e of Object.keys(t))a(t[e],i)};a(r,t)}const V=Symbol("null"),C=/\//g,L=/~/g,D=/~1/g,z=/~0/g;class H{$ref;path;originalPath;scopeBase;value;circular;indirections;constructor(e,t,r){this.$ref=e,this.path=t,this.originalPath=r||t,this.scopeBase=e.path||v(t),this.value=void 0,this.circular=!1,this.indirections=0}resolve(e,t,r){const o=H.parse(this.path,this.originalPath),s=[];this.value=Y(e),this.$ref.dynamicIdScope&&!Z(this.$ref)&&(this.scopeBase=U(this.scopeBase,this.value));for(let e=0;e<o.length;e++){const n=this.circular,a=te.isExtended$Ref(this.value);G(this,t,r)?this.path=H.join(this.path,o.slice(e)):!n&&this.circular&&a&&(this.circular=!1);const i=o[e];if(void 0===this.value[i]||null===this.value[i]&&e===o.length-1){let t=!1;for(let r=o.length-1;r>e;r--){const s=o.slice(e,r+1).join("/");if(void 0!==this.value[s]){this.value=this.value[s],e=r,t=!0;break}}if(t)continue;if(i in this.value&&null===this.value[i]){this.value=V;continue}this.value=null;const n=this.$ref.path||"",a=this.path.replace(n,""),c=H.join("",s),l=r?.replace(n,"");throw new F(i,decodeURI(this.originalPath),a,c,l)}this.value=this.value[i],s.push(i),this.$ref.dynamicIdScope&&(this.scopeBase=U(this.scopeBase,this.value))}const n=this.$ref.dynamicIdScope?this.scopeBase:this.path;return(!this.value||this.value.$ref&&d(n,this.value.$ref)!==r)&&G(this,t,r),this}set(e,t,r){const o=H.parse(this.path);let s;if(0===o.length)return this.value=t,t;this.value=Y(e),this.$ref.dynamicIdScope&&!Z(this.$ref)&&(this.scopeBase=U(this.scopeBase,this.value));for(let e=0;e<o.length-1;e++)G(this,r),s=o[e],this.value&&void 0!==this.value[s]?this.value=this.value[s]:this.value=X(this,s,{}),this.$ref.dynamicIdScope&&(this.scopeBase=U(this.scopeBase,this.value));return G(this,r),s=o[o.length-1],X(this,s,t),e}static parse(e,t){const r=$(e).substring(1);if(!r)return[];const o=r.split("/");for(let e=0;e<o.length;e++)o[e]=o[e].replace(D,"/").replace(z,"~");if(""!==o[0])throw new M(r,void 0===t?e:t);return o.slice(1)}static join(e,t){-1===e.indexOf("#")&&(e+="#"),t=Array.isArray(t)?t:[t];for(let r=0;r<t.length;r++)e+="/"+t[r].replace(L,"~0").replace(C,"~1");return e}}function G(e,t,r){if(te.isAllowed$Ref(e.value,t)){const o=d(e.$ref.dynamicIdScope?e.scopeBase:e.path,e.value.$ref);if(o!==e.path||function(e){return"string"==typeof e&&0==H.parse(e).length}(r)){const r=e.$ref.$refs._resolve(o,e.path,t);return null!==r&&(e.indirections+=r.indirections+1,te.isExtended$Ref(e.value)?(e.value=te.dereference(e.value,r.value,t),!1):(e.$ref=r.$ref,e.path=r.path,e.value=r.value,e.scopeBase=e.$ref.path,!0))}e.circular=!0}}const K=H;function X(e,t,r){if(!e.value||"object"!=typeof e.value)throw new S(`Error assigning $ref pointer "${e.path}". \nCannot set "${t}" of a non-object.`);return"-"===t&&Array.isArray(e.value)?e.value.push(r):e.value[t]=r,r}function Y(e){if(B(e))throw e;return e}function Z(e){return Boolean(e.path&&e.path in e.$refs._aliases)}class Q{path;value;$refs;pathType;dynamicIdScope=!1;errors=[];constructor(e){this.$refs=e}addError(e){void 0===this.errors&&(this.errors=[]);const t=this.errors.map(({footprint:e})=>e);"errors"in e&&Array.isArray(e.errors)?this.errors.push(...e.errors.map(q).filter(({footprint:e})=>!t.includes(e))):"footprint"in e&&t.includes(e.footprint)||this.errors.push(q(e))}exists(e,t){try{return this.resolve(e,t),!0}catch{return!1}}get(e,t){return this.resolve(e,t)?.value}resolve(e,t,r,o){const s=new K(this,e,r);try{const e=s.resolve(this.value,t,o);return e.value===V&&(e.value=null),e}catch(e){if(!t||!t.continueOnError||!B(e))throw e;return null===e.path&&(e.path=E($(o))),e instanceof M&&(e.source=decodeURI(v(o))),this.addError(e),null}}set(e,t){const r=new K(this,e);this.value=r.set(this.value,t),this.value===V&&(this.value=null)}static is$Ref(e){return Boolean(e)&&"object"==typeof e&&null!==e&&"$ref"in e&&"string"==typeof e.$ref&&e.$ref.length>0}static isExternal$Ref(e){return Q.is$Ref(e)&&"#"!==e.$ref[0]}static isAllowed$Ref(e,t){if(this.is$Ref(e)){if("#/"===e.$ref.substring(0,2)||"#"===e.$ref)return!0;if("#"!==e.$ref[0]&&(!t||t.resolve?.external))return!0}}static isExtended$Ref(e){return Q.is$Ref(e)&&Object.keys(e).length>1}static dereference(e,t,r){if(t&&"object"==typeof t&&Q.isExtended$Ref(e)){const o={};for(const t of Object.keys(e))"$ref"!==t&&(o[t]=e[t]);const s=r?.dereference?.mergeKeys??!0;for(const e of Object.keys(t)){const r=e;r in o?s&&"object"==typeof o[r]&&null!==o[r]&&"object"==typeof t[r]&&null!==t[r]&&(o[r]=ee(t[r],o[r])):o[r]=t[r]}return o}return t}}function ee(e,t){if("object"!=typeof e||null===e)return t;if("object"!=typeof t||null===t)return t;const r=Array.isArray(e)?[...e]:{...e};for(const o of Object.keys(t))Array.isArray(t[o])?r[o]=[...t[o]]:"object"==typeof t[o]&&null!==t[o]?r[o]=ee(e[o],t[o]):r[o]=t[o];return r}const te=Q;class re{circular;paths(...e){return oe(this._$refs,e.flat()).map(e=>o(e.decoded))}values(...e){const t=this._$refs;return oe(t,e.flat()).reduce((e,r)=>(e[o(r.decoded)]=t[r.encoded].value,e),{})}exists(e,t){try{return this._resolve(e,"",t),!0}catch{return!1}}get(e,t){return this._resolve(e,"",t).value}set(e,t){const r=d(this._root$Ref.path,e),o=this._getRef(r);if(!o)throw new Error(`Error resolving $ref pointer "${e}". \n"${v(r)}" not found.`);o.set(r,t)}_get$Ref(e){return e=d(this._root$Ref.path,e),this._getRef(e)}_add(e){const t=v(e),r=new te(this);return r.path=t,this._$refs[t]=r,this._root$Ref=this._root$Ref||r,r}_addAlias(e,t,r,o=!1){const s=v(e);if(!s||this._$refs[s]||this._aliases[s])return this._$refs[s]||this._aliases[s];const n=new te(this);return n.path=s,n.pathType=r,n.value=t,n.dynamicIdScope=o,this._aliases[s]=n,n}_resolve(e,t,r){const o=d(this._root$Ref.path,e),s=this._getRef(o);if(!s)throw new Error(`Error resolving $ref pointer "${e}". \n"${v(o)}" not found.`);return s.resolve(o,r,e,t)}_$refs={};_aliases={};_root$Ref;constructor(){this.circular=!1,this._$refs={},this._aliases={},this._root$Ref=null}toJSON=this.values;_getRef(e){const t=v(e);return this._$refs[t]||this._aliases[t]}}function oe(e,t){let r=Object.keys(e);return(t=Array.isArray(t[0])?t[0]:Array.prototype.slice.call(t)).length>0&&t[0]&&(r=r.filter(r=>t.includes(e[r].pathType))),r.map(t=>({encoded:t,decoded:"file"===e[t].pathType?x(t,!0):t}))}function se(e){return Object.keys(e||{}).filter(t=>"object"==typeof e[t]).map(t=>(e[t].name=t,e[t]))}function ne(e,t,r,o,s){return e.filter(e=>!!ce(e,t,r,o,s))}function ae(e){for(const t of e)t.order=t.order||Number.MAX_SAFE_INTEGER;return e.sort((e,t)=>e.order-t.order)}async function ie(e,t,r,o){let s,n,a=0;return new Promise((i,c)=>{function l(){if(s=e[a++],!s)return c(n);try{const n=ce(s,t,r,p,o);if(n&&"function"==typeof n.then)n.then(u,f);else if(void 0!==n)u(n);else if(a===e.length)throw new Error("No promise has been returned or callback has been called.")}catch(e){f(e)}}function p(e,t){e?f(e):u(t)}function u(e){i({plugin:s,result:e})}function f(e){n={plugin:s,error:e},l()}l()})}function ce(e,t,r,o,s){const n=e[t];if("function"==typeof n)return n.apply(e,[r,o,s]);if(!o){if(n instanceof RegExp)return n.test(r.url);if("string"==typeof n)return n===r.extension;if(Array.isArray(n))return-1!==n.indexOf(r.extension)}return n}const le=async function(e,t,r){let o="string"==typeof e?e:e.url;const s="string"==typeof e?void 0:e.baseUrl;let n="string"==typeof e?void 0:e.reference;const a=o.indexOf("#");let i="";if(a>=0&&(i=o.substring(a),o=o.substring(0,a)),n){const e=n.indexOf("#");e>=0&&(n=n.substring(0,e))}const c=t._add(o),l={url:o,hash:i,extension:g(o),...void 0!==n?{reference:n}:{},...void 0!==s?{baseUrl:s}:{}};try{const e=await async function(e,t,r){let o=se(t.resolve);o=ne(o,"canRead",e,void 0,r),ae(o);try{return await ie(o,"read",e,r)}catch(r){throw!r&&t.continueOnError?new I(e.url):r&&"error"in r?r.error instanceof T?r.error:new T(r,e.url):new SyntaxError(`Unable to resolve $ref pointer "${e.url}"`,{cause:r})}}(l,r,t);c.pathType=e.plugin.name,l.data=e.result;const o=await async function(e,t,r){const o=se(t.parse),s=ne(o,"canParse",e),n=s.length>0?s:o;ae(n);try{const t=await ie(n,"parse",e,r);if(!t.plugin.allowEmpty&&(void 0===(a=t.result)||"object"==typeof a&&0===Object.keys(a).length||"string"==typeof a&&0===a.trim().length||Buffer.isBuffer(a)&&0===a.length))throw new SyntaxError(`Error parsing "${e.url}" as ${t.plugin.name}. \nParsed value is empty`);return t}catch(r){throw!r&&t.continueOnError?new k(e.url):r&&r.message&&r.message.startsWith("Error parsing")?r:r&&"error"in r?r.error instanceof _?r.error:new _(r.error.message,e.url):new SyntaxError(`Unable to parse ${e.url}`,{cause:r})}var a}(l,r,t);return c.value=o.result,c.dynamicIdScope=J(c.value),W(t,c.path,c.value,c.pathType,c.dynamicIdScope),o.result}catch(e){throw B(e)&&(c.value=e),e}},pe={order:100,allowEmpty:!0,canParse:".json",allowBOM:!0,async parse(e){let t=e.data;if(Buffer.isBuffer(t)&&(t=t.toString()),"string"!=typeof t)return t;if(0!==t.trim().length)try{return JSON.parse(t)}catch(r){if(this.allowBOM)try{const e=t.indexOf("{");return t=t.slice(e),JSON.parse(t)}catch(t){throw new _(t.message,e.url)}throw new _(r.message,e.url)}}},ue=require("js-yaml"),fe={order:200,allowEmpty:!0,canParse:[".yaml",".yml",".json"],async parse(e){let t=e.data;if(Buffer.isBuffer(t)&&(t=t.toString()),"string"!=typeof t)return t;try{return ue.load(t,{schema:ue.JSON_SCHEMA})}catch{try{return ue.load(t)}catch(t){throw new _(t?.message||"Parser Error",e.url)}}}},he=/\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i,de={order:300,allowEmpty:!0,encoding:"utf8",canParse:e=>("string"==typeof e.data||Buffer.isBuffer(e.data))&&he.test(e.url),parse(e){if("string"==typeof e.data)return e.data;if(Buffer.isBuffer(e.data))return e.data.toString(this.encoding);throw new _("data is not text",e.url)}},me=/\.(jpeg|jpg|gif|png|bmp|ico)$/i,ye={order:400,allowEmpty:!0,canParse:e=>Buffer.isBuffer(e.data)&&me.test(e.url),parse:e=>Buffer.isBuffer(e.data)?e.data:Buffer.from(e.data)},ge={order:100,canRead:e=>b(e.url),async read(e){let t;const o=await Promise.resolve().then(r.t.bind(r,896,19));try{t=x(e.url)}catch(t){const r=t;throw r.message=`Malformed URI: ${e.url}: ${r.message}`,new T(r,e.url)}(t.endsWith("/")||t.endsWith("\\"))&&(t=t.slice(0,-1));try{return await o.promises.readFile(t)}catch(e){const r=e;throw r.message=`Error opening file ${t}: ${r.message}`,new T(r,t)}}},$e={order:200,headers:null,timeout:6e4,redirects:5,withCredentials:!1,safeUrlResolver:!0,canRead(e){return function(e){const t=y(e);return"http"===t||"https"===t||void 0===t&&"undefined"!=typeof window}(e.url)&&(!this.safeUrlResolver||!w(e.url))},read(e){const t=h(e.url);return"undefined"==typeof window||t.protocol||(t.protocol=h(location.href).protocol),ve(t,this)}};async function ve(e,t,r){e=h(e);const o=r||[];o.push(e.href);try{const r=await async function(e,t){let r,o;t.timeout&&"undefined"!=typeof AbortController&&(r=new AbortController,o=setTimeout(()=>r.abort(),t.timeout));const s=await fetch(e,{method:"GET",headers:t.headers||{},credentials:t.withCredentials?"include":"same-origin",signal:r?r.signal:null});return o&&clearTimeout(o),s}(e,t);if(r.status>=400){const e=new Error(`HTTP ERROR ${r.status}`);throw e.status=r.status,e}if(r.status>=300){if(!Number.isNaN(t.redirects)&&o.length>t.redirects){const e=new Error(`Error downloading ${o[0]}. \nToo many redirects: \n ${o.join(" \n ")}`);throw e.status=r.status,new T(e)}if("location"in r.headers&&r.headers.location)return ve(d(e.href,r.headers.location),t,o);{const e=new Error(`HTTP ${r.status} redirect with no location header`);throw e.status=r.status,e}}if(r.body){const e=await r.arrayBuffer();return Buffer.from(e)}return Buffer.alloc(0)}catch(t){const r=t;throw r.message=`Error downloading ${e.href}: ${r.message}`,new T(r,e.href)}}const we=()=>({parse:{json:{...pe},yaml:{...fe},text:{...de},binary:{...ye}},resolve:{file:{...ge},http:{...$e},external:!0},continueOnError:!1,bundle:{excludedPathMatcher:()=>!1},dereference:{circular:!0,excludedPathMatcher:()=>!1,referenceResolution:"relative",mergeKeys:!0},mutateInputSchema:!0}),be=e=>{const t=we();return e&&xe(t,e),t};function xe(e,t){if(Ee(t)){const r=Object.keys(t).filter(e=>!["__proto__","constructor","prototype"].includes(e));for(let o=0;o<r.length;o++){const s=r[o],n=t[s],a=e[s];Ee(n)?e[s]=xe(a||{},n):void 0!==n&&(e[s]=n)}}return e}function Ee(e){return e&&"object"==typeof e&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}const je=function(e){let t,r,o,s;const n=Array.prototype.slice.call(e);"function"==typeof n[n.length-1]&&(s=n.pop()),"string"==typeof n[0]?(t=n[0],"object"==typeof n[2]?(r=n[1],o=n[2]):(r=void 0,o=n[1])):(t="",r=n[0],o=n[1]);try{o=be(o)}catch(e){console.error(`JSON Schema Ref Parser: Error normalizing options: ${e}`)}return o.mutateInputSchema||"object"!=typeof r||(r=JSON.parse(JSON.stringify(r))),{path:t,schema:r,options:o,callback:s}};function Pe(e,t,r,o,s,n,a,i){a||=new Set;let c=[];if(e&&"object"==typeof e&&!ArrayBuffer.isView(e)&&!a.has(e)){a.add(e);const l=r;te.isExternal$Ref(e)&&c.push(async function(e,t,r,o,s,n){const a="root"===n.dereference?.externalReferenceResolution?m():o?r:t,i=d(a,e.$ref),c=v(i),l=s._get$Ref(c);if(l)return Promise.resolve(l.value);try{const t=e.$ref,r={url:i,baseUrl:a};"string"==typeof t&&(r.reference=t);const o=await le(r,s,n),l=s._get$Ref(c),p=Pe(o,c+"#",c,l?.dynamicIdScope??!1,s,n,new Set,!0);return Promise.all(p)}catch(e){if(!n?.continueOnError||!B(e))throw e;return s._$refs[c]&&(e.source=decodeURI(v(t)),e.path=E($(t))),[]}}(e,t,l,o,s,n));const p=Object.keys(e);for(const r of p){const p=K.join(t,r),u=e[r],f=o&&u&&"object"==typeof u&&!ArrayBuffer.isView(u)?U(l,u):l;c=c.concat(Pe(u,p,f,o,s,n,a,i))}}return c}const Re=function(e,t){if(!t.resolve?.external)return Promise.resolve();try{const r=e.$refs._root$Ref.dynamicIdScope?U(e.$refs._root$Ref.path,e.schema):e.$refs._root$Ref.path,o=Pe(e.schema,e.$refs._root$Ref.path+"#",r,e.$refs._root$Ref.dynamicIdScope,e.$refs,t);return Promise.all(o)}catch(e){return Promise.reject(e)}};function Oe(e,t,r,o,s,n,a,i,c,l){const p=null===t?e:e[t],u=l.bundle||{},f=u.excludedPathMatcher||(()=>!1);if(p&&"object"==typeof p&&!ArrayBuffer.isView(p)&&!f(n)){const f=o;if(te.isAllowed$Ref(p))Se(e,t,r,f,s,n,a,i,c,l);else{const e=Object.keys(p).sort((e,t)=>"definitions"===e||"$defs"===e?-1:"definitions"===t||"$defs"===t?1:e.length-t.length);for(const t of e){const e=K.join(r,t),o=K.join(n,t),h=p[t],d=s&&h&&"object"==typeof h&&!ArrayBuffer.isView(h)?U(f,h):f;te.isAllowed$Ref(h)?Se(p,t,e,d,s,o,a,i,c,l):Oe(p,t,e,d,s,o,a,i,c,l),h&&"object"==typeof h&&!Array.isArray(h)&&"$ref"in h&&u?.onBundle?.(h.$ref,p[t],p,t)}}}}function Se(e,t,r,o,s,n,a,i,c,l){const p=null===t?e:e[t],u=d(s?o:r,p.$ref),f=c._resolve(u,n,l);if(null===f)return;const h=K.parse(n).length,m=v(f.path),y=$(f.path),g=m!==c._root$Ref.path&&!c._aliases[m],w=te.isExtended$Ref(p);a+=f.indirections;const b=function(e,t,r){for(const o of e)if(o&&o.parent===t&&o.key===r)return o}(i,e,t);if(b){if(!(h<b.depth||a<b.indirections))return;!function(e,t){const r=e.indexOf(t);e.splice(r,1)}(i,b)}i.push({$ref:p,parent:e,key:t,pathFromRoot:n,depth:h,file:m,hash:y,value:f.value,circular:f.circular,extended:w,external:g,indirections:a}),b&&!g||Oe(f.value,null,f.path,f.$ref.path,f.$ref.dynamicIdScope,n,a+1,i,c,l)}function Ae(e,t){if(!t.startsWith("#/"))return t;const r=t.slice(2).split("/");let o=e;const s=[];for(const n of r){if(null==o||"object"!=typeof o)return t;if("$ref"in o&&"string"==typeof o.$ref&&o.$ref.startsWith("#/")){const r=o.$ref.slice(2).split("/");if(s.length=0,s.push(...r),o=_e(e,o.$ref),null==o||"object"!=typeof o)return t}const r=n.replace(/~1/g,"/").replace(/~0/g,"~");o=o[Array.isArray(o)?parseInt(r):r],s.push(n)}return"#/"+s.join("/")}function _e(e,t){if(!t.startsWith("#/"))return;const r=t.slice(2).split("/");let o=e;for(const e of r){if(null==o||"object"!=typeof o)return;const t=e.replace(/~1/g,"/").replace(/~0/g,"~");o=o[Array.isArray(o)?parseInt(t):t]}return o}function ke(e,t){for(const r of e)if("#"!==r.pathFromRoot&&"#/"!==r.pathFromRoot&&t.pathFromRoot.startsWith(r.pathFromRoot+"/")&&r.value&&"object"==typeof r.value&&"$id"in r.value)return!0;return!1}const Te=function(e,t){const r=Date.now(),o=e.$refs._root$Ref.dynamicIdScope?U(e.$refs._root$Ref.path,e.schema):e.$refs._root$Ref.path,s=Ie(e.schema,e.$refs._root$Ref.path,o,e.$refs._root$Ref.dynamicIdScope,"#",new Set,new Set,new Map,e.$refs,t,r,0);e.$refs.circular=s.circular,e.schema=s.value};function Ie(e,t,r,o,s,n,a,i,c,l,p,u){let f;const h={value:e,circular:!1};Ne(p,l);const d=l.dereference||{},m=d.maxDepth??500;if(u>m)throw new RangeError(`Maximum dereference depth (${m}) exceeded at ${s}. This likely indicates an extremely deep or recursive schema. You can increase this limit with the dereference.maxDepth option.`);const y=d.excludedPathMatcher||(()=>!1);if(("ignore"===d?.circular||!a.has(e))&&e&&"object"==typeof e&&!ArrayBuffer.isView(e)&&!y(s)){n.add(e),a.add(e);const m=r;if(te.isAllowed$Ref(e,l))f=Fe(e,t,m,o,s,n,a,i,c,l,p,u),h.circular=f.circular,h.value=f.value;else for(const r of Object.keys(e)){Ne(p,l);const g=K.join(t,r),$=K.join(s,r);if(y($))continue;const v=e[r],w=o&&v&&"object"==typeof v&&!ArrayBuffer.isView(v)?U(m,v):m;let b;if(te.isAllowed$Ref(v,l)){if(f=Fe(v,g,w,o,$,n,a,i,c,l,p,u),b=f.circular,e[r]!==f.value){const t=new Map;d?.preservedProperties&&("object"!=typeof e[r]||Array.isArray(e[r])||d?.preservedProperties.forEach(o=>{o in e[r]&&t.set(o,e[r][o])}));let o=f.value;d?.cloneReferences&&!b&&o&&"object"==typeof o&&(o=structuredClone(o)),e[r]=o,d?.preservedProperties&&t.size&&"object"==typeof e[r]&&!Array.isArray(e[r])&&t.forEach((t,o)=>{e[r][o]=t}),d?.onDereference?.(v.$ref,e[r],e,r)}}else n.has(v)?b=Me(g,c,l):(f=Ie(v,g,w,o,$,n,a,i,c,l,p,u+1),b=f.circular,e[r]!==f.value&&(e[r]=f.value));h.circular=h.circular||b}n.delete(e)}return h}function Fe(e,t,r,o,s,n,a,i,c,l,p,u){const f=d(te.isExternal$Ref(e)&&"root"===l?.dereference?.externalReferenceResolution?m():o?r:t,e.$ref),h=i.get(f);if(h){if(!h.circular){const t=Object.keys(e);if(t.length>1){const r={};for(const o of t)"$ref"===o||o in h.value||(r[o]=e[o]);return{circular:h.circular,value:Object.assign({},h.value,r)}}return h}if("object"!=typeof h.value||!("$ref"in h.value)||!("$ref"in e))return Me(t,c,l),h;if(h.value.$ref===e.$ref)return Me(t,c,l),h}const y=c._resolve(f,t,l);if(null===y)return{circular:!1,value:null};const g=y.circular;let $=g||n.has(y.value);$&&Me(t,c,l);let v=te.dereference(e,y.value,l);if(!$){const e=Ie(v,y.path,y.$ref.path,y.$ref.dynamicIdScope,s,n,a,i,c,l,p,u+1);$=e.circular,v=e.value}$&&!g&&"ignore"===l.dereference?.circular&&(v=e),g&&(v.$ref=s);const w={circular:$,value:v};return 1===Object.keys(e).length&&i.set(f,w),w}function Ne(e,t){if(t&&t.timeoutMs&&Date.now()-e>t.timeoutMs)throw new N(t.timeoutMs)}function Me(e,t,r){if(t.circular=!0,r?.dereference?.onCircular?.(e),!r.dereference.circular)throw new ReferenceError(`Circular $ref pointer found at ${e}`);return!0}const Be="object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:"function"==typeof setImmediate?setImmediate:function(e){setTimeout(e,0)};function qe(e,t){return e?void t.then(function(t){Be(function(){e(null,t)})},function(t){Be(function(){e(t)})}):t}class Ue{schema=null;$refs=new re;async parse(){const e=je(arguments);let t;if(!e.path&&!e.schema){const t=new Error(`Expected a file path, URL, or object. Got ${e.path||e.schema}`);return qe(e.callback,Promise.reject(t))}this.schema=null,this.$refs=new re;let r="http";if(b(e.path))e.path=function(e){if(n()){const s=m(),n=e.toUpperCase(),a=o(s).toUpperCase(),i=n.includes(a),c=n.includes(a),l=p.test(e)||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("file://");i||c||l||s.startsWith("http")||(r=e,e=(t=s).endsWith("/")||t.endsWith("\\")?t+r:t+"/"+r),e=o(e)}var t,r;e=encodeURI(e);for(const t of u)e=e.replace(t[0],t[1]);return e}(e.path),r="file";else if(!e.path&&e.schema&&"$id"in e.schema&&e.schema.$id){const t=h(e.schema.$id),r=t.port??("https:"===t.protocol?443:80);e.path=`${t.protocol}//${t.hostname}:${r}`}if(e.path=d(m(),e.path),e.schema&&"object"==typeof e.schema){const o=this.$refs._add(e.path);o.value=e.schema,o.pathType=r,o.dynamicIdScope=J(o.value),W(this.$refs,o.path,o.value,o.pathType,o.dynamicIdScope),t=Promise.resolve(e.schema)}else t=le(e.path,this.$refs,e.options);try{const r=await t;if(null===r||"object"!=typeof r||Buffer.isBuffer(r)){if(e.options.continueOnError)return this.schema=null,qe(e.callback,Promise.resolve(this.schema));throw new SyntaxError(`"${this.$refs._root$Ref.path||r}" is not a valid JSON Schema`)}return this.schema=r,qe(e.callback,Promise.resolve(this.schema))}catch(t){return e.options.continueOnError&&B(t)?(this.$refs._$refs[v(e.path)]&&this.$refs._$refs[v(e.path)].addError(t),qe(e.callback,Promise.resolve(null))):qe(e.callback,Promise.reject(t))}}static parse(){const e=new Ue;return e.parse.apply(e,arguments)}async resolve(){const e=je(arguments);try{return await this.parse(e.path,e.schema,e.options),await Re(this,e.options),We(this),qe(e.callback,Promise.resolve(this.$refs))}catch(t){return qe(e.callback,Promise.reject(t))}}static resolve(){const e=new Ue;return e.resolve.apply(e,arguments)}static bundle(){const e=new Ue;return e.bundle.apply(e,arguments)}async bundle(){const e=je(arguments);try{return await this.resolve(e.path,e.schema,e.options),function(e,t){const r=e.$refs._root$Ref.dynamicIdScope?U(e.$refs._root$Ref.path,e.schema):e.$refs._root$Ref.path,o=[];Oe(e,"schema",e.$refs._root$Ref.path+"#",r,e.$refs._root$Ref.dynamicIdScope,"#",0,o,e.$refs,t),function(e,t,r){let o,s,n;e.sort((e,t)=>{if(e.file!==t.file)return e.file<t.file?-1:1;if(e.hash!==t.hash)return e.hash<t.hash?-1:1;if(e.circular!==t.circular)return e.circular?-1:1;if(e.extended!==t.extended)return e.extended?1:-1;if(e.indirections!==t.indirections)return e.indirections-t.indirections;if(e.depth!==t.depth)return e.depth-t.depth;{const r=Math.max(e.pathFromRoot.lastIndexOf("/definitions"),e.pathFromRoot.lastIndexOf("/$defs")),o=Math.max(t.pathFromRoot.lastIndexOf("/definitions"),t.pathFromRoot.lastIndexOf("/$defs"));return r!==o?o-r:e.pathFromRoot.length-t.pathFromRoot.length}});for(const a of e){const i=t.bundle||{};if(a.external)if(a.file===o&&a.hash===s)r&&ke(e,a)?a.$ref.$ref=r+n:a.$ref.$ref=n;else if(a.file===o&&0===a.hash.indexOf(s+"/")){const t=K.join(n,K.parse(a.hash.replace(s,"#")));r&&ke(e,a)?a.$ref.$ref=r+t:a.$ref.$ref=t}else o=a.file,s=a.hash,n=a.pathFromRoot,a.$ref=a.parent[a.key]=te.dereference(a.$ref,a.value,t),a.circular&&(a.$ref.$ref=a.pathFromRoot);else!1!==i.optimizeInternalRefs&&(a.$ref.$ref=a.hash)}}(o,t,e.schema&&"object"==typeof e.schema&&"$id"in e.schema?e.schema.$id:void 0),!1!==(t.bundle||{}).optimizeInternalRefs&&function(e,t){for(const r of e){if(!r.$ref||"object"!=typeof r.$ref||!("$ref"in r.$ref))continue;const e=r.$ref.$ref;if("string"!=typeof e||!e.startsWith("#/"))continue;const o=Ae(t,e);o!==e&&(r.$ref.$ref=o)}}(o,e.schema)}(this,e.options),We(this),qe(e.callback,Promise.resolve(this.schema))}catch(t){return qe(e.callback,Promise.reject(t))}}static dereference(){const e=new Ue;return e.dereference.apply(e,arguments)}async dereference(){const e=je(arguments);try{return await this.resolve(e.path,e.schema,e.options),Te(this,e.options),We(this),qe(e.callback,Promise.resolve(this.schema))}catch(t){return qe(e.callback,Promise.reject(t))}}}const Je=Ue;function We(e){if(A.getParserErrors(e).length>0)throw new A(e)}const Ve=Ue.parse,Ce=Ue.resolve,Le=Ue.bundle,De=Ue.dereference}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,s),n.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(r,o){if(1&o&&(r=this(r)),8&o)return r;if("object"==typeof r&&r){if(4&o&&r.__esModule)return r;if(16&o&&"function"==typeof r.then)return r}var n=Object.create(null);s.r(n);var a={};e=e||[null,t({}),t([]),t(t)];for(var i=2&o&&r;("object"==typeof i||"function"==typeof i)&&!~e.indexOf(i);i=t(i))Object.getOwnPropertyNames(i).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,s.d(n,a),n},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n=s(115);for(var a in n)exports[a]=n[a];Object.defineProperty(exports,"__esModule",{value:!0})})(); //# sourceMappingURL=cli.js.map